@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.
- package/README.md +560 -90
- package/dist/index.js +2 -1
- package/dist/index.js.map +1 -0
- package/package.json +38 -54
- package/LICENSE +0 -21
- package/dist/.tsbuildinfo +0 -1
- package/dist-types/actions/bulkTranslate.d.ts +0 -6
- package/dist-types/actions/manageDNTFields.d.ts +0 -11
- package/dist-types/actions/translateDocument.d.ts +0 -6
- package/dist-types/components/RadioWithDefault.d.ts +0 -16
- package/dist-types/components/auth/AuthNavbar.d.ts +0 -17
- package/dist-types/components/auth/AuthStatus.d.ts +0 -26
- package/dist-types/components/auth/AuthStatusWrapper.d.ts +0 -14
- package/dist-types/components/auth/MigrationPrompt.d.ts +0 -19
- package/dist-types/components/auth/MigrationPromptWrapper.d.ts +0 -13
- package/dist-types/components/auth/OAuthCallback.d.ts +0 -19
- package/dist-types/components/auth/index.d.ts +0 -14
- package/dist-types/components/config/LocaleConfigTool.d.ts +0 -16
- package/dist-types/components/config/LocaleConfigToolWrapper.d.ts +0 -12
- package/dist-types/components/config/OAuthConfig.d.ts +0 -25
- package/dist-types/components/config/OAuthConfigWrapper.d.ts +0 -12
- package/dist-types/components/config/PasswordInput.d.ts +0 -13
- package/dist-types/components/config/index.d.ts +0 -8
- package/dist-types/components/config/localeConfigToolDefinition.d.ts +0 -12
- package/dist-types/components/config/oauthConfigToolDefinition.d.ts +0 -12
- package/dist-types/components/dialogs/ConfirmationDialog.d.ts +0 -20
- package/dist-types/components/dialogs/ErrorDialog.d.ts +0 -20
- package/dist-types/components/dialogs/LocaleSelectionDialog.d.ts +0 -62
- package/dist-types/components/dialogs/SuccessDialog.d.ts +0 -18
- package/dist-types/components/dialogs/index.d.ts +0 -11
- package/dist-types/components/dnt/DNTFieldBadge.d.ts +0 -15
- package/dist-types/components/dnt/DNTFieldComponent.d.ts +0 -16
- package/dist-types/components/dnt/DNTFieldInput.d.ts +0 -13
- package/dist-types/components/dnt/DebugDNTBadge.d.ts +0 -19
- package/dist-types/components/dnt/index.d.ts +0 -7
- package/dist-types/config/index.d.ts +0 -5
- package/dist-types/config/pluginConfig.d.ts +0 -162
- package/dist-types/index.d.ts +0 -11
- package/dist-types/plugin.d.ts +0 -12
- package/dist-types/services/authStateManager.d.ts +0 -93
- package/dist-types/services/collisionDetectionService.d.ts +0 -85
- package/dist-types/services/contentExtractor.d.ts +0 -161
- package/dist-types/services/dialogService.d.ts +0 -95
- package/dist-types/services/dntServiceManager.d.ts +0 -43
- package/dist-types/services/dntStorageAdapter.d.ts +0 -72
- package/dist-types/services/documentCreationService.d.ts +0 -262
- package/dist-types/services/localeService.d.ts +0 -159
- package/dist-types/services/localeStorageAdapter.d.ts +0 -41
- package/dist-types/services/oauthConfigStorage.d.ts +0 -45
- package/dist-types/services/oauthService.d.ts +0 -47
- package/dist-types/services/oauthServiceManager.d.ts +0 -195
- package/dist-types/services/tokenStorage.d.ts +0 -53
- package/dist-types/services/translationService.d.ts +0 -385
- package/dist-types/services/unifiedConfigStorage.d.ts +0 -158
- package/dist-types/test-utils.d.ts +0 -8
- package/dist-types/types/dialog.d.ts +0 -118
- package/dist-types/types/dnt.d.ts +0 -83
- package/dist-types/types/index.d.ts +0 -11
- package/dist-types/types/locale.d.ts +0 -115
- package/dist-types/types/oauth.d.ts +0 -89
- package/dist-types/types/pluginConfig.d.ts +0 -64
- package/dist-types/types/translation.d.ts +0 -121
- package/dist-types/utils/dntDefaults.d.ts +0 -101
- package/dist-types/utils/htmlFormatter.d.ts +0 -65
- package/dist-types/utils/index.d.ts +0 -16
- package/dist-types/utils/logger.d.ts +0 -104
- package/dist-types/utils/oauthErrorFeedback.d.ts +0 -75
- package/dist-types/utils/oauthLogger.d.ts +0 -175
- package/dist-types/utils/validator.d.ts +0 -66
|
@@ -1,262 +0,0 @@
|
|
|
1
|
-
import { SanityDocument, SanityClient } from 'sanity';
|
|
2
|
-
import { TranslationResponse } from './translationService';
|
|
3
|
-
import { CollisionResolutionMode, ExistingDocumentHandling } from '../types/pluginConfig';
|
|
4
|
-
/**
|
|
5
|
-
* Options for document creation from translation
|
|
6
|
-
*/
|
|
7
|
-
export interface DocumentCreationOptions {
|
|
8
|
-
/** Target language code for the translated document */
|
|
9
|
-
targetLanguage?: string;
|
|
10
|
-
/** Source language code of the original document */
|
|
11
|
-
sourceLanguage?: string;
|
|
12
|
-
/** Whether to create the document as a variant of the original */
|
|
13
|
-
createAsVariant?: boolean;
|
|
14
|
-
/** ID of the parent document when creating as a variant */
|
|
15
|
-
parentDocumentId?: string;
|
|
16
|
-
/** Creation mode: 'draft' creates a draft document, 'published' creates a published document */
|
|
17
|
-
creationMode?: 'draft' | 'published';
|
|
18
|
-
/**
|
|
19
|
-
* Whether the title was found at the document's top level during extraction.
|
|
20
|
-
* When false, the translated title should not be written as a top-level field.
|
|
21
|
-
* This is tracked in-memory by the plugin, not sent to the translation backend.
|
|
22
|
-
*/
|
|
23
|
-
titleFoundAtTopLevel?: boolean;
|
|
24
|
-
/**
|
|
25
|
-
* Whether the body/content was found at the document's top level during extraction.
|
|
26
|
-
* When false, the translated body should not be written as a top-level field.
|
|
27
|
-
* This is tracked in-memory by the plugin, not sent to the translation backend.
|
|
28
|
-
*/
|
|
29
|
-
bodyFoundAtTopLevel?: boolean;
|
|
30
|
-
/**
|
|
31
|
-
* The field name where body content was originally found (e.g., 'body', 'content', or nested path).
|
|
32
|
-
* Used to write translated content back to the correct location.
|
|
33
|
-
*/
|
|
34
|
-
bodyFieldName?: string;
|
|
35
|
-
/**
|
|
36
|
-
* How to handle collisions when a translated document already exists.
|
|
37
|
-
* - 'replace': Overwrite the existing document with new translations
|
|
38
|
-
* - 'create': Create a new document (default behavior if not specified)
|
|
39
|
-
*/
|
|
40
|
-
collisionResolutionMode?: CollisionResolutionMode;
|
|
41
|
-
/**
|
|
42
|
-
* How to handle the existing document when creating a new one (only for 'create' mode).
|
|
43
|
-
* - 'draft': Set the existing document to draft state
|
|
44
|
-
* - 'delete': Delete the existing document
|
|
45
|
-
*/
|
|
46
|
-
existingDocumentHandling?: ExistingDocumentHandling;
|
|
47
|
-
}
|
|
48
|
-
export interface SlugFallbackInfo {
|
|
49
|
-
documentId: string;
|
|
50
|
-
originalSlug: string;
|
|
51
|
-
fallbackSlug: string;
|
|
52
|
-
locale: string;
|
|
53
|
-
reason: string;
|
|
54
|
-
}
|
|
55
|
-
/**
|
|
56
|
-
* Information about a collision that was detected and resolved
|
|
57
|
-
*/
|
|
58
|
-
export interface CollisionResolutionInfo {
|
|
59
|
-
/** Whether a collision was detected */
|
|
60
|
-
collisionDetected: boolean;
|
|
61
|
-
/** The resolution action that was taken */
|
|
62
|
-
resolutionAction?: 'replaced' | 'created_new' | 'none';
|
|
63
|
-
/** The ID of the document that was replaced, updated, or deleted */
|
|
64
|
-
existingDocumentId?: string;
|
|
65
|
-
/** How the existing document was handled (for 'create' mode) */
|
|
66
|
-
existingDocumentAction?: 'set_to_draft' | 'deleted' | 'none';
|
|
67
|
-
/** How the collision was detected */
|
|
68
|
-
matchedBy?: 'parent' | 'slug-locale';
|
|
69
|
-
}
|
|
70
|
-
export interface DocumentCreationResult {
|
|
71
|
-
success: boolean;
|
|
72
|
-
documentId?: string;
|
|
73
|
-
document?: SanityDocument;
|
|
74
|
-
error?: string;
|
|
75
|
-
slugFallback?: SlugFallbackInfo;
|
|
76
|
-
/** Information about collision detection and resolution */
|
|
77
|
-
collisionInfo?: CollisionResolutionInfo;
|
|
78
|
-
}
|
|
79
|
-
export interface BulkDocumentCreationResult {
|
|
80
|
-
totalDocuments: number;
|
|
81
|
-
successfulCreations: number;
|
|
82
|
-
failedCreations: number;
|
|
83
|
-
results: DocumentCreationResult[];
|
|
84
|
-
errors: string[];
|
|
85
|
-
rollbackInfo?: RollbackInfo;
|
|
86
|
-
slugFallbacks: SlugFallbackInfo[];
|
|
87
|
-
}
|
|
88
|
-
export interface RollbackInfo {
|
|
89
|
-
canRollback: boolean;
|
|
90
|
-
createdDocumentIds: string[];
|
|
91
|
-
rollbackInstructions: string[];
|
|
92
|
-
}
|
|
93
|
-
export declare class DocumentCreationService {
|
|
94
|
-
private client;
|
|
95
|
-
private defaultCreationMode;
|
|
96
|
-
private collisionDetectionService;
|
|
97
|
-
private defaultCollisionResolutionMode;
|
|
98
|
-
private defaultExistingDocumentHandling;
|
|
99
|
-
constructor(client: SanityClient, defaultCreationMode?: 'draft' | 'published');
|
|
100
|
-
/**
|
|
101
|
-
* Set the default document creation mode
|
|
102
|
-
* @param mode - The creation mode to use by default ('draft' or 'published')
|
|
103
|
-
*/
|
|
104
|
-
setDefaultCreationMode(mode: 'draft' | 'published'): void;
|
|
105
|
-
/**
|
|
106
|
-
* Set the default collision resolution mode
|
|
107
|
-
* @param mode - How to handle collisions ('replace' or 'create')
|
|
108
|
-
*/
|
|
109
|
-
setDefaultCollisionResolutionMode(mode: CollisionResolutionMode): void;
|
|
110
|
-
/**
|
|
111
|
-
* Set the default existing document handling mode
|
|
112
|
-
* @param handling - How to handle existing documents when creating new ('draft' or 'delete')
|
|
113
|
-
*/
|
|
114
|
-
setDefaultExistingDocumentHandling(handling: ExistingDocumentHandling): void;
|
|
115
|
-
/**
|
|
116
|
-
* Configure collision resolution defaults
|
|
117
|
-
* @param mode - Collision resolution mode
|
|
118
|
-
* @param handling - Existing document handling (only applicable when mode is 'create')
|
|
119
|
-
*/
|
|
120
|
-
setCollisionResolutionConfig(mode: CollisionResolutionMode, handling?: ExistingDocumentHandling): void;
|
|
121
|
-
/**
|
|
122
|
-
* Replace an existing document with new translated content
|
|
123
|
-
* Requirements: EARS 4 - Resolution Behavior - Replace
|
|
124
|
-
*
|
|
125
|
-
* @param existingDocument - The document to replace
|
|
126
|
-
* @param newDocument - The new translated document content
|
|
127
|
-
* @param creationMode - Whether to create as draft or published
|
|
128
|
-
*/
|
|
129
|
-
private replaceExistingDocument;
|
|
130
|
-
/**
|
|
131
|
-
* Handle an existing document when creating a new translation (for 'create' mode)
|
|
132
|
-
* Requirements: EARS 5 - Resolution Behavior - Create
|
|
133
|
-
*
|
|
134
|
-
* @param existingDocument - The existing document to handle
|
|
135
|
-
* @param handling - How to handle the existing document ('draft' or 'delete')
|
|
136
|
-
*/
|
|
137
|
-
private handleExistingDocument;
|
|
138
|
-
/**
|
|
139
|
-
* Create a new Sanity document from translation response
|
|
140
|
-
* Requirements: 1.1, 1.2, 2.1, 3.2, 3.4
|
|
141
|
-
*/
|
|
142
|
-
createDocumentFromTranslation(originalDocument: SanityDocument, translationResponse: TranslationResponse, options?: DocumentCreationOptions): Promise<DocumentCreationResult>;
|
|
143
|
-
/**
|
|
144
|
-
* Validate inputs for document creation
|
|
145
|
-
* Requirements: 4.3, 4.4
|
|
146
|
-
*/
|
|
147
|
-
private validateInputsForDocumentCreation;
|
|
148
|
-
/**
|
|
149
|
-
* Validate business rules for document creation
|
|
150
|
-
* Requirements: 4.3, 4.4
|
|
151
|
-
*/
|
|
152
|
-
private validateBusinessRules;
|
|
153
|
-
/**
|
|
154
|
-
* Check if document has meaningful content
|
|
155
|
-
* Searches both top-level and nested fields for title/body content
|
|
156
|
-
*/
|
|
157
|
-
private documentHasContent;
|
|
158
|
-
/**
|
|
159
|
-
* Recursively search nested objects for title or body content
|
|
160
|
-
*/
|
|
161
|
-
private hasContentInNestedFields;
|
|
162
|
-
/**
|
|
163
|
-
* Format error messages with additional context
|
|
164
|
-
* Requirements: 4.3, 4.4
|
|
165
|
-
*/
|
|
166
|
-
private formatErrorMessage;
|
|
167
|
-
/**
|
|
168
|
-
* Create multiple documents from bulk translation responses
|
|
169
|
-
* Requirements: 2.1, 3.2, 3.4
|
|
170
|
-
*/
|
|
171
|
-
createBulkDocumentsFromTranslations(originalDocuments: SanityDocument[], translationResponses: TranslationResponse[], options?: DocumentCreationOptions): Promise<BulkDocumentCreationResult>;
|
|
172
|
-
/**
|
|
173
|
-
* Validate bulk translation responses before document creation
|
|
174
|
-
* Requirements: 4.3, 4.4
|
|
175
|
-
*/
|
|
176
|
-
private validateBulkTranslationResponses;
|
|
177
|
-
/**
|
|
178
|
-
* Validate translation response before document creation
|
|
179
|
-
* Requirements: 4.3, 4.4
|
|
180
|
-
*/
|
|
181
|
-
private validateTranslationResponseForCreation;
|
|
182
|
-
/**
|
|
183
|
-
* Create rollback plan for failed bulk operations
|
|
184
|
-
* Requirements: 4.3, 4.4
|
|
185
|
-
*/
|
|
186
|
-
createRollbackPlan(createdDocumentIds: string[]): RollbackInfo;
|
|
187
|
-
/**
|
|
188
|
-
* Parse a field path that may contain array key selectors
|
|
189
|
-
* e.g., "article.footnotes[_key == \"c82437b14d71\"].footnote"
|
|
190
|
-
*
|
|
191
|
-
* @param fieldPath - The field path (may be from the field key or from the path property)
|
|
192
|
-
* @returns Array of path segments with type information
|
|
193
|
-
*/
|
|
194
|
-
private parseFieldPath;
|
|
195
|
-
/**
|
|
196
|
-
* Unflatten fields with complex paths back into nested objects
|
|
197
|
-
* Handles both simple dotted paths and GROQ-style array key paths:
|
|
198
|
-
* - "metadata.version" → { metadata: { version: ... } }
|
|
199
|
-
* - "article.footnotes[_key == \"abc\"].footnote" → { article: { footnotes: [{ _key: "abc", footnote: ... }] } }
|
|
200
|
-
*
|
|
201
|
-
* @param fields - Flattened fields with path keys
|
|
202
|
-
* @param originalDocument - Original document for preserving array structure
|
|
203
|
-
* @returns Unflattened nested object structure
|
|
204
|
-
*/
|
|
205
|
-
private unflattenFields;
|
|
206
|
-
/**
|
|
207
|
-
* Get the original nested value from the original document using a dotted path
|
|
208
|
-
*
|
|
209
|
-
* @param document - The original document
|
|
210
|
-
* @param fieldPath - The dotted path to the field
|
|
211
|
-
* @returns The original value at the path, or undefined
|
|
212
|
-
*/
|
|
213
|
-
private getOriginalValueByPath;
|
|
214
|
-
/**
|
|
215
|
-
* Merge translated content back into original document structure
|
|
216
|
-
* Requirements: 1.2, 3.2, 3.4
|
|
217
|
-
*/
|
|
218
|
-
private mergeTranslatedContent;
|
|
219
|
-
/**
|
|
220
|
-
* Process a translated field value and convert it to the appropriate format
|
|
221
|
-
* based on the original document's structure
|
|
222
|
-
*/
|
|
223
|
-
private processTranslatedField;
|
|
224
|
-
/**
|
|
225
|
-
* Convert HTML content back to Sanity portable text format
|
|
226
|
-
* Requirements: 3.2, 3.4
|
|
227
|
-
*/
|
|
228
|
-
private convertHtmlToPortableText;
|
|
229
|
-
/**
|
|
230
|
-
* Parse inline content and handle formatting
|
|
231
|
-
*/
|
|
232
|
-
private parseInlineContent;
|
|
233
|
-
/**
|
|
234
|
-
* Get block style from HTML tag name
|
|
235
|
-
*/
|
|
236
|
-
private getBlockStyle;
|
|
237
|
-
/**
|
|
238
|
-
* Check if content appears to be HTML
|
|
239
|
-
*/
|
|
240
|
-
private isHtmlContent;
|
|
241
|
-
/**
|
|
242
|
-
* Generate a new document ID based on original ID and target language
|
|
243
|
-
*/
|
|
244
|
-
private generateNewDocumentId;
|
|
245
|
-
/**
|
|
246
|
-
* Generate a unique key for portable text blocks
|
|
247
|
-
*/
|
|
248
|
-
private generateBlockKey;
|
|
249
|
-
/**
|
|
250
|
-
* Generate a unique key for spans
|
|
251
|
-
*/
|
|
252
|
-
private generateSpanKey;
|
|
253
|
-
/**
|
|
254
|
-
* Validate document structure before creation
|
|
255
|
-
* Requirements: 3.4
|
|
256
|
-
*/
|
|
257
|
-
private validateDocumentStructure;
|
|
258
|
-
/**
|
|
259
|
-
* Validate portable text array structure
|
|
260
|
-
*/
|
|
261
|
-
private validatePortableTextArray;
|
|
262
|
-
}
|
|
@@ -1,159 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Locale configuration management service
|
|
3
|
-
* Requirements: 1.1, 1.4, 1.5, 5.4, 5.5, 5.6
|
|
4
|
-
*
|
|
5
|
-
* Provides CRUD operations for locale configuration management with validation,
|
|
6
|
-
* persistence, and error handling capabilities.
|
|
7
|
-
*/
|
|
8
|
-
import { LocaleConfig, LocaleDefinition, LocaleValidationResult } from '../types/locale';
|
|
9
|
-
/**
|
|
10
|
-
* Storage interface for locale configuration persistence
|
|
11
|
-
* This allows for different storage implementations (localStorage, Sanity config, etc.)
|
|
12
|
-
*/
|
|
13
|
-
export interface LocaleStorageAdapter {
|
|
14
|
-
load(): Promise<LocaleConfig | null>;
|
|
15
|
-
save(config: LocaleConfig): Promise<void>;
|
|
16
|
-
}
|
|
17
|
-
/**
|
|
18
|
-
* Error types for locale service operations
|
|
19
|
-
*/
|
|
20
|
-
export declare class LocaleServiceError extends Error {
|
|
21
|
-
code: string;
|
|
22
|
-
details?: unknown | undefined;
|
|
23
|
-
constructor(message: string, code: string, details?: unknown | undefined);
|
|
24
|
-
}
|
|
25
|
-
/**
|
|
26
|
-
* Service for managing locale configuration with CRUD operations
|
|
27
|
-
* Requirements: 1.1, 1.4, 1.5, 5.4, 5.5, 5.6
|
|
28
|
-
*/
|
|
29
|
-
export declare class LocaleService {
|
|
30
|
-
private config;
|
|
31
|
-
private storageAdapter;
|
|
32
|
-
/**
|
|
33
|
-
* Creates a new LocaleService instance
|
|
34
|
-
*
|
|
35
|
-
* @param storageAdapter - Optional storage adapter for persistence
|
|
36
|
-
* @param initialConfig - Optional initial configuration (defaults to empty config)
|
|
37
|
-
*/
|
|
38
|
-
constructor(storageAdapter?: LocaleStorageAdapter | null, initialConfig?: LocaleConfig);
|
|
39
|
-
/**
|
|
40
|
-
* Loads locale configuration from storage
|
|
41
|
-
* Requirements: 1.4, 5.4
|
|
42
|
-
*
|
|
43
|
-
* @returns Promise resolving to the loaded configuration
|
|
44
|
-
* @throws LocaleServiceError if loading fails
|
|
45
|
-
*/
|
|
46
|
-
loadConfig(): Promise<LocaleConfig>;
|
|
47
|
-
/**
|
|
48
|
-
* Saves locale configuration to storage
|
|
49
|
-
* Requirements: 1.5, 5.5
|
|
50
|
-
*
|
|
51
|
-
* @param config - Optional configuration to save (defaults to current config)
|
|
52
|
-
* @returns Promise resolving when save is complete
|
|
53
|
-
* @throws LocaleServiceError if saving fails
|
|
54
|
-
*/
|
|
55
|
-
saveConfig(config?: LocaleConfig): Promise<void>;
|
|
56
|
-
/**
|
|
57
|
-
* Gets the current locale configuration
|
|
58
|
-
*
|
|
59
|
-
* @returns Current locale configuration
|
|
60
|
-
*/
|
|
61
|
-
getConfig(): LocaleConfig;
|
|
62
|
-
/**
|
|
63
|
-
* Gets all locales from the configuration
|
|
64
|
-
*
|
|
65
|
-
* @returns Array of all locale definitions
|
|
66
|
-
*/
|
|
67
|
-
getAllLocales(): LocaleDefinition[];
|
|
68
|
-
/**
|
|
69
|
-
* Gets all enabled locales from the configuration
|
|
70
|
-
*
|
|
71
|
-
* @returns Array of enabled locale definitions
|
|
72
|
-
*/
|
|
73
|
-
getEnabledLocales(): LocaleDefinition[];
|
|
74
|
-
/**
|
|
75
|
-
* Gets a locale by its code
|
|
76
|
-
*
|
|
77
|
-
* @param code - Locale code to find
|
|
78
|
-
* @returns Locale definition or undefined if not found
|
|
79
|
-
*/
|
|
80
|
-
getLocaleByCode(code: string): LocaleDefinition | undefined;
|
|
81
|
-
/**
|
|
82
|
-
* Checks if a locale code exists in the configuration
|
|
83
|
-
*
|
|
84
|
-
* @param code - Locale code to check
|
|
85
|
-
* @returns True if the locale exists
|
|
86
|
-
*/
|
|
87
|
-
hasLocale(code: string): boolean;
|
|
88
|
-
/**
|
|
89
|
-
* Adds a new locale to the configuration
|
|
90
|
-
* Requirements: 1.1, 1.2, 1.3
|
|
91
|
-
*
|
|
92
|
-
* @param locale - Locale definition to add
|
|
93
|
-
* @returns Promise resolving to validation result
|
|
94
|
-
* @throws LocaleServiceError if locale is invalid or already exists
|
|
95
|
-
*/
|
|
96
|
-
addLocale(locale: Omit<LocaleDefinition, 'createdAt' | 'updatedAt'>): Promise<LocaleValidationResult>;
|
|
97
|
-
/**
|
|
98
|
-
* Updates an existing locale in the configuration
|
|
99
|
-
* Requirements: 1.6, 1.7
|
|
100
|
-
*
|
|
101
|
-
* @param code - Code of the locale to update
|
|
102
|
-
* @param updates - Partial locale definition with updates
|
|
103
|
-
* @returns Promise resolving to validation result
|
|
104
|
-
* @throws LocaleServiceError if locale not found or updates are invalid
|
|
105
|
-
*/
|
|
106
|
-
updateLocale(code: string, updates: Partial<Omit<LocaleDefinition, 'code' | 'createdAt' | 'updatedAt'>>): Promise<LocaleValidationResult>;
|
|
107
|
-
/**
|
|
108
|
-
* Removes a locale from the configuration
|
|
109
|
-
* Requirements: 1.6
|
|
110
|
-
*
|
|
111
|
-
* @param code - Code of the locale to remove
|
|
112
|
-
* @returns Promise resolving when removal is complete
|
|
113
|
-
* @throws LocaleServiceError if locale not found
|
|
114
|
-
*/
|
|
115
|
-
removeLocale(code: string): Promise<void>;
|
|
116
|
-
/**
|
|
117
|
-
* Sets the default locale
|
|
118
|
-
*
|
|
119
|
-
* @param code - Code of the locale to set as default
|
|
120
|
-
* @returns Promise resolving when update is complete
|
|
121
|
-
* @throws LocaleServiceError if locale not found
|
|
122
|
-
*/
|
|
123
|
-
setDefaultLocale(code: string): Promise<void>;
|
|
124
|
-
/**
|
|
125
|
-
* Clears the default locale
|
|
126
|
-
*
|
|
127
|
-
* @returns Promise resolving when update is complete
|
|
128
|
-
*/
|
|
129
|
-
clearDefaultLocale(): Promise<void>;
|
|
130
|
-
/**
|
|
131
|
-
* Validates the current configuration
|
|
132
|
-
* Requirements: 5.6
|
|
133
|
-
*
|
|
134
|
-
* @returns Validation result
|
|
135
|
-
*/
|
|
136
|
-
validateCurrentConfig(): LocaleValidationResult;
|
|
137
|
-
/**
|
|
138
|
-
* Resets configuration to default state
|
|
139
|
-
* Requirements: 5.6
|
|
140
|
-
*
|
|
141
|
-
* @returns Promise resolving when reset is complete
|
|
142
|
-
*/
|
|
143
|
-
resetToDefault(): Promise<void>;
|
|
144
|
-
/**
|
|
145
|
-
* Imports a locale configuration
|
|
146
|
-
* Useful for bulk import or migration scenarios
|
|
147
|
-
*
|
|
148
|
-
* @param config - Configuration to import
|
|
149
|
-
* @returns Promise resolving to validation result
|
|
150
|
-
* @throws LocaleServiceError if configuration is invalid
|
|
151
|
-
*/
|
|
152
|
-
importConfig(config: LocaleConfig): Promise<LocaleValidationResult>;
|
|
153
|
-
/**
|
|
154
|
-
* Exports the current locale configuration
|
|
155
|
-
*
|
|
156
|
-
* @returns Current configuration as a plain object
|
|
157
|
-
*/
|
|
158
|
-
exportConfig(): LocaleConfig;
|
|
159
|
-
}
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Locale Storage Adapter for Sanity Configuration
|
|
3
|
-
* Requirements: 5.1, 5.2, 5.3, 5.7
|
|
4
|
-
*
|
|
5
|
-
* Now delegates to UnifiedConfigStorage for centralized configuration management.
|
|
6
|
-
* Locale settings are stored in the EL_PluginConfiguration document alongside
|
|
7
|
-
* OAuth and DNT configurations.
|
|
8
|
-
*/
|
|
9
|
-
import { SanityClient } from 'sanity';
|
|
10
|
-
import { LocaleConfig } from '../types/locale';
|
|
11
|
-
import { LocaleStorageAdapter } from './localeService';
|
|
12
|
-
/**
|
|
13
|
-
* Locale configuration storage adapter
|
|
14
|
-
* Now uses UnifiedConfigStorage for centralized management
|
|
15
|
-
* Requirements: 5.1, 5.2, 5.3, 5.7
|
|
16
|
-
*/
|
|
17
|
-
export declare class SanityLocaleStorageAdapter implements LocaleStorageAdapter {
|
|
18
|
-
private unifiedStorage;
|
|
19
|
-
private client;
|
|
20
|
-
constructor(client: SanityClient);
|
|
21
|
-
/**
|
|
22
|
-
* Load locale configuration from unified storage
|
|
23
|
-
* Requirements: 5.2, 5.4
|
|
24
|
-
*/
|
|
25
|
-
load(): Promise<LocaleConfig | null>;
|
|
26
|
-
/**
|
|
27
|
-
* Save locale configuration to unified storage
|
|
28
|
-
* Requirements: 5.3, 5.5
|
|
29
|
-
*/
|
|
30
|
-
save(config: LocaleConfig): Promise<void>;
|
|
31
|
-
/**
|
|
32
|
-
* Load from legacy locale-specific document
|
|
33
|
-
* @private
|
|
34
|
-
*/
|
|
35
|
-
private loadLegacy;
|
|
36
|
-
/**
|
|
37
|
-
* Delete legacy locale document after migration
|
|
38
|
-
* @private
|
|
39
|
-
*/
|
|
40
|
-
private deleteLegacy;
|
|
41
|
-
}
|
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* OAuth Configuration Storage Adapter
|
|
3
|
-
* Requirements: 9.1, 9.4
|
|
4
|
-
*
|
|
5
|
-
* Now delegates to UnifiedConfigStorage for centralized configuration management.
|
|
6
|
-
* OAuth settings are stored in the EL_PluginConfiguration document alongside
|
|
7
|
-
* locale and DNT configurations.
|
|
8
|
-
*/
|
|
9
|
-
import { SanityClient } from 'sanity';
|
|
10
|
-
import { OAuthConfig } from '../types/oauth';
|
|
11
|
-
/**
|
|
12
|
-
* OAuth configuration storage adapter
|
|
13
|
-
* Now uses UnifiedConfigStorage for centralized management
|
|
14
|
-
* Requirements: 9.1, 9.4
|
|
15
|
-
*/
|
|
16
|
-
export declare class OAuthConfigStorage {
|
|
17
|
-
private unifiedStorage;
|
|
18
|
-
private client;
|
|
19
|
-
constructor(client: SanityClient);
|
|
20
|
-
/**
|
|
21
|
-
* Load OAuth configuration from unified storage
|
|
22
|
-
* Requirements: 9.1, 9.4
|
|
23
|
-
*/
|
|
24
|
-
load(): Promise<OAuthConfig | null>;
|
|
25
|
-
/**
|
|
26
|
-
* Save OAuth configuration to unified storage
|
|
27
|
-
* Requirements: 9.1, 9.4
|
|
28
|
-
*/
|
|
29
|
-
save(config: OAuthConfig): Promise<void>;
|
|
30
|
-
/**
|
|
31
|
-
* Delete OAuth configuration
|
|
32
|
-
* Only clears OAuth fields, preserves other configuration
|
|
33
|
-
*/
|
|
34
|
-
delete(): Promise<void>;
|
|
35
|
-
/**
|
|
36
|
-
* Load from legacy OAuth-specific document
|
|
37
|
-
* @private
|
|
38
|
-
*/
|
|
39
|
-
private loadLegacy;
|
|
40
|
-
/**
|
|
41
|
-
* Delete legacy OAuth document after migration
|
|
42
|
-
* @private
|
|
43
|
-
*/
|
|
44
|
-
private deleteLegacy;
|
|
45
|
-
}
|
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Easyling Authentication Service
|
|
3
|
-
*
|
|
4
|
-
* Manages Easyling authentication configuration for the Sanity Translation Plugin.
|
|
5
|
-
* Handles validation and storage of access tokens and project IDs.
|
|
6
|
-
*/
|
|
7
|
-
import { OAuthConfig } from '../types/oauth';
|
|
8
|
-
/**
|
|
9
|
-
* Easyling Authentication Service
|
|
10
|
-
*
|
|
11
|
-
* Provides methods for managing Easyling authentication configuration.
|
|
12
|
-
*/
|
|
13
|
-
export declare class OAuthService {
|
|
14
|
-
private config;
|
|
15
|
-
/**
|
|
16
|
-
* Create a new Easyling Authentication Service instance
|
|
17
|
-
*
|
|
18
|
-
* @param config - Easyling configuration (access token and project ID)
|
|
19
|
-
* @throws {OAuthError} If configuration is invalid
|
|
20
|
-
*/
|
|
21
|
-
constructor(config: OAuthConfig);
|
|
22
|
-
/**
|
|
23
|
-
* Validate configuration
|
|
24
|
-
*
|
|
25
|
-
* @param config - Configuration to validate
|
|
26
|
-
* @throws {OAuthError} If configuration is invalid
|
|
27
|
-
*/
|
|
28
|
-
private validateConfig;
|
|
29
|
-
/**
|
|
30
|
-
* Get the access token
|
|
31
|
-
*
|
|
32
|
-
* @returns The configured access token
|
|
33
|
-
*/
|
|
34
|
-
getAccessToken(): string;
|
|
35
|
-
/**
|
|
36
|
-
* Get the project ID
|
|
37
|
-
*
|
|
38
|
-
* @returns The configured project ID
|
|
39
|
-
*/
|
|
40
|
-
getProjectId(): string;
|
|
41
|
-
/**
|
|
42
|
-
* Get the complete configuration
|
|
43
|
-
*
|
|
44
|
-
* @returns The complete OAuth configuration
|
|
45
|
-
*/
|
|
46
|
-
getConfig(): OAuthConfig;
|
|
47
|
-
}
|