@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,158 +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
|
-
import { CollisionResolutionMode, ExistingDocumentHandling } from '../types/pluginConfig';
|
|
16
|
-
/**
|
|
17
|
-
* Unified plugin configuration structure
|
|
18
|
-
*/
|
|
19
|
-
export interface UnifiedPluginConfig {
|
|
20
|
-
/** OAuth/authentication settings */
|
|
21
|
-
projectId?: string;
|
|
22
|
-
accessToken?: string;
|
|
23
|
-
/** Translation settings */
|
|
24
|
-
translationApiEndpoint?: string;
|
|
25
|
-
requestContentType?: 'application/json' | 'application/x-protobuf';
|
|
26
|
-
responseAcceptHeader?: 'application/json' | 'application/x-protobuf';
|
|
27
|
-
defaultDocumentCreationMode?: 'draft' | 'published';
|
|
28
|
-
/** Collision resolution settings */
|
|
29
|
-
collisionResolutionMode?: CollisionResolutionMode;
|
|
30
|
-
existingDocumentHandling?: ExistingDocumentHandling;
|
|
31
|
-
/** Locale configuration */
|
|
32
|
-
locales?: LocaleConfig['locales'];
|
|
33
|
-
defaultLocale?: string;
|
|
34
|
-
/** DNT field map: { [documentType]: { [fieldPath]: boolean } } */
|
|
35
|
-
dntFieldMap?: Record<string, Record<string, boolean>>;
|
|
36
|
-
/** Debug mode - when enabled, shows additional DNT badges on all fields */
|
|
37
|
-
debugMode?: boolean;
|
|
38
|
-
/** Configuration version for migrations */
|
|
39
|
-
version?: string;
|
|
40
|
-
/** Last updated timestamp */
|
|
41
|
-
lastUpdated?: string;
|
|
42
|
-
}
|
|
43
|
-
/**
|
|
44
|
-
* Unified configuration storage adapter for Sanity
|
|
45
|
-
*/
|
|
46
|
-
export declare class UnifiedConfigStorage {
|
|
47
|
-
private client;
|
|
48
|
-
constructor(client: SanityClient);
|
|
49
|
-
/**
|
|
50
|
-
* Convert array-based DNT configuration (schema format) to map format (internal use)
|
|
51
|
-
*/
|
|
52
|
-
private convertDNTArrayToMap;
|
|
53
|
-
/**
|
|
54
|
-
* Convert map-based DNT configuration (internal format) to array format (schema format)
|
|
55
|
-
*/
|
|
56
|
-
private convertDNTMapToArray;
|
|
57
|
-
/**
|
|
58
|
-
* Load complete unified configuration from Sanity
|
|
59
|
-
*/
|
|
60
|
-
load(): Promise<UnifiedPluginConfig | null>;
|
|
61
|
-
/**
|
|
62
|
-
* Save complete unified configuration to Sanity
|
|
63
|
-
*/
|
|
64
|
-
save(config: UnifiedPluginConfig): Promise<void>;
|
|
65
|
-
/**
|
|
66
|
-
* Update only specific fields without overwriting entire config
|
|
67
|
-
*/
|
|
68
|
-
update(updates: Partial<UnifiedPluginConfig>): Promise<void>;
|
|
69
|
-
/**
|
|
70
|
-
* Delete the unified configuration document
|
|
71
|
-
*/
|
|
72
|
-
delete(): Promise<void>;
|
|
73
|
-
/**
|
|
74
|
-
* Load only OAuth configuration
|
|
75
|
-
*/
|
|
76
|
-
loadOAuth(): Promise<OAuthConfig | null>;
|
|
77
|
-
/**
|
|
78
|
-
* Save OAuth configuration
|
|
79
|
-
*/
|
|
80
|
-
saveOAuth(oauthConfig: OAuthConfig): Promise<void>;
|
|
81
|
-
/**
|
|
82
|
-
* Load only locale configuration
|
|
83
|
-
*/
|
|
84
|
-
loadLocale(): Promise<LocaleConfig | null>;
|
|
85
|
-
/**
|
|
86
|
-
* Save locale configuration
|
|
87
|
-
*/
|
|
88
|
-
saveLocale(localeConfig: LocaleConfig): Promise<void>;
|
|
89
|
-
/**
|
|
90
|
-
* Get DNT field map for a specific document type
|
|
91
|
-
*/
|
|
92
|
-
getDNTFieldsForType(documentType: string): Promise<Record<string, boolean>>;
|
|
93
|
-
/**
|
|
94
|
-
* Set DNT status for a field in a document type
|
|
95
|
-
*/
|
|
96
|
-
setDNTField(documentType: string, fieldPath: string, dnt: boolean): Promise<void>;
|
|
97
|
-
/**
|
|
98
|
-
* Toggle DNT status for a field in a document type
|
|
99
|
-
*/
|
|
100
|
-
toggleDNTField(documentType: string, fieldPath: string): Promise<boolean>;
|
|
101
|
-
/**
|
|
102
|
-
* Get DNT status for a specific field in a document type
|
|
103
|
-
*/
|
|
104
|
-
getDNTFieldStatus(documentType: string, fieldPath: string): Promise<boolean>;
|
|
105
|
-
/**
|
|
106
|
-
* Clear all DNT fields for a document type
|
|
107
|
-
*/
|
|
108
|
-
clearDNTFieldsForType(documentType: string): Promise<void>;
|
|
109
|
-
/**
|
|
110
|
-
* Get all DNT field mappings
|
|
111
|
-
*/
|
|
112
|
-
getAllDNTFields(): Promise<Record<string, Record<string, boolean>>>;
|
|
113
|
-
/**
|
|
114
|
-
* Get translation API endpoint with fallback to default
|
|
115
|
-
*/
|
|
116
|
-
getTranslationEndpoint(): Promise<string>;
|
|
117
|
-
/**
|
|
118
|
-
* Get request content type with fallback to default
|
|
119
|
-
*/
|
|
120
|
-
getRequestContentType(): Promise<'application/json' | 'application/x-protobuf'>;
|
|
121
|
-
/**
|
|
122
|
-
* Get response accept header with fallback to default
|
|
123
|
-
*/
|
|
124
|
-
getResponseAcceptHeader(): Promise<'application/json' | 'application/x-protobuf'>;
|
|
125
|
-
/**
|
|
126
|
-
* Get default document creation mode with fallback to default
|
|
127
|
-
*/
|
|
128
|
-
getDefaultDocumentCreationMode(): Promise<'draft' | 'published'>;
|
|
129
|
-
/**
|
|
130
|
-
* Get collision resolution mode with fallback to default ('replace')
|
|
131
|
-
*/
|
|
132
|
-
getCollisionResolutionMode(): Promise<CollisionResolutionMode>;
|
|
133
|
-
/**
|
|
134
|
-
* Get existing document handling mode with fallback to default ('draft')
|
|
135
|
-
* Only applicable when collision resolution mode is 'create'
|
|
136
|
-
*/
|
|
137
|
-
getExistingDocumentHandling(): Promise<ExistingDocumentHandling>;
|
|
138
|
-
/**
|
|
139
|
-
* Get complete collision resolution configuration
|
|
140
|
-
* Returns both the resolution mode and existing document handling settings
|
|
141
|
-
*/
|
|
142
|
-
getCollisionResolutionConfig(): Promise<{
|
|
143
|
-
collisionResolutionMode: CollisionResolutionMode;
|
|
144
|
-
existingDocumentHandling: ExistingDocumentHandling;
|
|
145
|
-
}>;
|
|
146
|
-
/**
|
|
147
|
-
* Set collision resolution configuration
|
|
148
|
-
*/
|
|
149
|
-
setCollisionResolutionConfig(mode: CollisionResolutionMode, handling?: ExistingDocumentHandling): Promise<void>;
|
|
150
|
-
/**
|
|
151
|
-
* Get debug mode status
|
|
152
|
-
*/
|
|
153
|
-
getDebugMode(): Promise<boolean>;
|
|
154
|
-
/**
|
|
155
|
-
* Set debug mode status
|
|
156
|
-
*/
|
|
157
|
-
setDebugMode(enabled: boolean): Promise<void>;
|
|
158
|
-
}
|
|
@@ -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,118 +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
|
-
/** Whether to show collision resolution override options */
|
|
72
|
-
showCollisionResolutionOverride?: boolean;
|
|
73
|
-
/** Default collision resolution mode from config */
|
|
74
|
-
defaultCollisionResolutionMode?: CollisionResolutionMode;
|
|
75
|
-
/** Default existing document handling from config */
|
|
76
|
-
defaultExistingDocumentHandling?: ExistingDocumentHandling;
|
|
77
|
-
}
|
|
78
|
-
/**
|
|
79
|
-
* Locale selection result
|
|
80
|
-
*/
|
|
81
|
-
export interface LocaleSelectionResult {
|
|
82
|
-
/** Selected locale codes */
|
|
83
|
-
locales: string[];
|
|
84
|
-
/** Selected creation mode (if showCreationModeOption was true) */
|
|
85
|
-
creationMode?: 'draft' | 'published';
|
|
86
|
-
/** Collision resolution mode (if override was enabled) */
|
|
87
|
-
collisionResolutionMode?: CollisionResolutionMode;
|
|
88
|
-
/** Existing document handling (if override was enabled) */
|
|
89
|
-
existingDocumentHandling?: ExistingDocumentHandling;
|
|
90
|
-
}
|
|
91
|
-
/**
|
|
92
|
-
* Dialog result types
|
|
93
|
-
*/
|
|
94
|
-
export type DialogResult<T = unknown> = {
|
|
95
|
-
/** Whether the dialog was confirmed or cancelled */
|
|
96
|
-
confirmed: boolean;
|
|
97
|
-
/** Result data from the dialog */
|
|
98
|
-
data?: T;
|
|
99
|
-
};
|
|
100
|
-
/**
|
|
101
|
-
* Dialog manager interface for centralized dialog handling
|
|
102
|
-
*/
|
|
103
|
-
export interface DialogManager {
|
|
104
|
-
/** Show a confirmation dialog */
|
|
105
|
-
showConfirmation(options: ConfirmationDialogOptions): Promise<boolean>;
|
|
106
|
-
/** Show a locale selection dialog */
|
|
107
|
-
showLocaleSelection(options: LocaleSelectionDialogOptions): Promise<LocaleSelectionResult>;
|
|
108
|
-
/** Show a success notification */
|
|
109
|
-
showSuccess(options: SuccessDialogOptions): void;
|
|
110
|
-
/** Show an error dialog */
|
|
111
|
-
showError(options: ErrorDialogOptions): Promise<boolean>;
|
|
112
|
-
/** Close all open dialogs */
|
|
113
|
-
closeAll(): void;
|
|
114
|
-
}
|
|
115
|
-
import type { LocaleDefinition } from './locale';
|
|
116
|
-
import type { CollisionResolutionMode, ExistingDocumentHandling } from './pluginConfig';
|
|
117
|
-
export type { LocaleDefinition } from './locale';
|
|
118
|
-
export type { CollisionResolutionMode, ExistingDocumentHandling } from './pluginConfig';
|
|
@@ -1,83 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* DNT (Do Not Translate) field preferences types
|
|
3
|
-
*/
|
|
4
|
-
export interface DNTFieldPreference {
|
|
5
|
-
/** Field path (e.g., 'title', 'content.description') */
|
|
6
|
-
fieldPath: string;
|
|
7
|
-
/** Whether this field should not be translated */
|
|
8
|
-
dnt: boolean;
|
|
9
|
-
/** Timestamp when preference was set */
|
|
10
|
-
updatedAt?: string;
|
|
11
|
-
}
|
|
12
|
-
/**
|
|
13
|
-
* Legacy document-specific DNT preferences (deprecated)
|
|
14
|
-
* @deprecated Use document-type-based DNT configuration instead
|
|
15
|
-
*/
|
|
16
|
-
export interface DNTPreferences {
|
|
17
|
-
/** Document ID these preferences apply to */
|
|
18
|
-
documentId: string;
|
|
19
|
-
/** Document type */
|
|
20
|
-
documentType: string;
|
|
21
|
-
/** Field-level DNT preferences */
|
|
22
|
-
fields: Record<string, boolean>;
|
|
23
|
-
/** Last updated timestamp */
|
|
24
|
-
updatedAt: string;
|
|
25
|
-
}
|
|
26
|
-
/**
|
|
27
|
-
* Document-type-based DNT field configuration
|
|
28
|
-
* When a field is marked DNT for a document type, it applies to ALL documents of that type
|
|
29
|
-
*/
|
|
30
|
-
export interface DNTTypeConfig {
|
|
31
|
-
/** Document type (e.g., 'product', 'article', 'page') */
|
|
32
|
-
documentType: string;
|
|
33
|
-
/** Field-level DNT preferences: { [fieldPath]: dnt } */
|
|
34
|
-
fields: Record<string, boolean>;
|
|
35
|
-
}
|
|
36
|
-
/**
|
|
37
|
-
* DNT Storage interface - supports document-type-based configuration
|
|
38
|
-
*/
|
|
39
|
-
export interface DNTStorage {
|
|
40
|
-
/**
|
|
41
|
-
* Get DNT field configuration for a document type
|
|
42
|
-
* @param documentType - The type of document (e.g., 'product', 'article')
|
|
43
|
-
* @returns Map of field paths to DNT status
|
|
44
|
-
*/
|
|
45
|
-
getFieldsForType(documentType: string): Promise<Record<string, boolean>>;
|
|
46
|
-
/**
|
|
47
|
-
* Set DNT status for a specific field in a document type
|
|
48
|
-
* @param documentType - The type of document
|
|
49
|
-
* @param fieldPath - The field path
|
|
50
|
-
* @param dnt - Whether the field should not be translated
|
|
51
|
-
*/
|
|
52
|
-
setFieldDNT(documentType: string, fieldPath: string, dnt: boolean): Promise<void>;
|
|
53
|
-
/**
|
|
54
|
-
* Toggle DNT status for a field in a document type
|
|
55
|
-
* @param documentType - The type of document
|
|
56
|
-
* @param fieldPath - The field path
|
|
57
|
-
* @returns The new DNT status
|
|
58
|
-
*/
|
|
59
|
-
toggleFieldDNT(documentType: string, fieldPath: string): Promise<boolean>;
|
|
60
|
-
/**
|
|
61
|
-
* Get DNT status for a specific field in a document type
|
|
62
|
-
* @param documentType - The type of document
|
|
63
|
-
* @param fieldPath - The field path
|
|
64
|
-
* @returns Whether the field is marked as DNT
|
|
65
|
-
*/
|
|
66
|
-
getFieldDNT(documentType: string, fieldPath: string): Promise<boolean>;
|
|
67
|
-
/**
|
|
68
|
-
* Clear all DNT fields for a document type
|
|
69
|
-
* @param documentType - The type of document
|
|
70
|
-
*/
|
|
71
|
-
clearFieldsForType(documentType: string): Promise<void>;
|
|
72
|
-
/**
|
|
73
|
-
* Get all DNT configurations (all document types)
|
|
74
|
-
* @returns Map of document types to their field DNT configurations
|
|
75
|
-
*/
|
|
76
|
-
getAllDNTFields(): Promise<Record<string, Record<string, boolean>>>;
|
|
77
|
-
/** @deprecated Use getFieldsForType instead */
|
|
78
|
-
getPreferences?(documentId: string): Promise<DNTPreferences | null>;
|
|
79
|
-
/** @deprecated Use setFieldDNT instead */
|
|
80
|
-
savePreferences?(preferences: DNTPreferences): Promise<void>;
|
|
81
|
-
/** @deprecated Use clearFieldsForType instead */
|
|
82
|
-
clearPreferences?(documentId: string): Promise<void>;
|
|
83
|
-
}
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Type definitions index
|
|
3
|
-
* Centralized exports for all plugin types
|
|
4
|
-
*/
|
|
5
|
-
export type { LocaleDefinition, LocaleConfig, LocaleValidationResult, LocaleSelectionOptions } from './locale';
|
|
6
|
-
export type { BaseDialogOptions, ConfirmationDialogOptions, SuccessDialogOptions, ErrorDialogOptions, LocaleSelectionDialogOptions, DialogResult, DialogManager } from './dialog';
|
|
7
|
-
export type { EnhancedTranslationRequest, EnhancedTranslationResponse, TranslationProgress, BulkTranslationRequest, EnhancedBulkTranslationSummary, TranslationRequestPayload, TranslationResponse, TranslatableField } from './translation';
|
|
8
|
-
export type { OAuthConfig, AuthenticationResult, StoredAuthData, AuthState, AuthStateData } from './oauth';
|
|
9
|
-
export { OAuthErrorType, OAuthError } from './oauth';
|
|
10
|
-
export type { DNTFieldPreference, DNTPreferences, DNTTypeConfig, DNTStorage } from './dnt';
|
|
11
|
-
export type { PluginConfiguration, DocumentCreationMode, ContentType } from './pluginConfig';
|
|
@@ -1,115 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Locale configuration type definitions
|
|
3
|
-
* Requirements: 5.1, 5.2, 5.3
|
|
4
|
-
*/
|
|
5
|
-
/**
|
|
6
|
-
* Individual locale definition with metadata
|
|
7
|
-
*/
|
|
8
|
-
export interface LocaleDefinition {
|
|
9
|
-
/** Locale code in ISO 639-1 + ISO 3166-1 format (e.g., "en-US", "fr-FR") */
|
|
10
|
-
code: string;
|
|
11
|
-
/** Human-readable display name (e.g., "English (United States)") */
|
|
12
|
-
displayName: string;
|
|
13
|
-
/** Whether this locale is enabled for translation */
|
|
14
|
-
enabled: boolean;
|
|
15
|
-
/** Timestamp when this locale was created */
|
|
16
|
-
createdAt: string;
|
|
17
|
-
/** Timestamp when this locale was last updated */
|
|
18
|
-
updatedAt: string;
|
|
19
|
-
}
|
|
20
|
-
/**
|
|
21
|
-
* Complete locale configuration for the plugin
|
|
22
|
-
*/
|
|
23
|
-
export interface LocaleConfig {
|
|
24
|
-
/** Array of configured locales */
|
|
25
|
-
locales: LocaleDefinition[];
|
|
26
|
-
/** Optional default locale code */
|
|
27
|
-
defaultLocale?: string;
|
|
28
|
-
/** Timestamp when configuration was last updated */
|
|
29
|
-
lastUpdated: string;
|
|
30
|
-
/** Configuration version for migration purposes */
|
|
31
|
-
version: string;
|
|
32
|
-
}
|
|
33
|
-
/**
|
|
34
|
-
* Validation result for locale operations
|
|
35
|
-
*/
|
|
36
|
-
export interface LocaleValidationResult {
|
|
37
|
-
/** Whether the validation passed */
|
|
38
|
-
isValid: boolean;
|
|
39
|
-
/** Array of validation error messages */
|
|
40
|
-
errors: string[];
|
|
41
|
-
/** Array of validation warning messages */
|
|
42
|
-
warnings: string[];
|
|
43
|
-
}
|
|
44
|
-
/**
|
|
45
|
-
* Options for locale selection operations
|
|
46
|
-
*/
|
|
47
|
-
export interface LocaleSelectionOptions {
|
|
48
|
-
/** Available locales to choose from */
|
|
49
|
-
availableLocales: LocaleDefinition[];
|
|
50
|
-
/** Currently selected locale codes */
|
|
51
|
-
selectedLocales: string[];
|
|
52
|
-
/** Whether multiple locales can be selected */
|
|
53
|
-
allowMultiple: boolean;
|
|
54
|
-
/** Whether selection is required (cannot be empty) */
|
|
55
|
-
required: boolean;
|
|
56
|
-
}
|
|
57
|
-
/**
|
|
58
|
-
* Locale code validation regex (ISO 639-1 + ISO 3166-1 format)
|
|
59
|
-
* Format: two lowercase letters, hyphen, two uppercase letters (e.g., en-US, fr-FR)
|
|
60
|
-
*/
|
|
61
|
-
export declare const LOCALE_CODE_REGEX: RegExp;
|
|
62
|
-
/**
|
|
63
|
-
* Validates a locale code format
|
|
64
|
-
* Requirements: 1.2, 1.3
|
|
65
|
-
*
|
|
66
|
-
* @param code - The locale code to validate
|
|
67
|
-
* @returns True if the code matches ISO 639-1 + ISO 3166-1 format
|
|
68
|
-
*
|
|
69
|
-
* @example
|
|
70
|
-
* validateLocaleCode('en-US') // true
|
|
71
|
-
* validateLocaleCode('fr-FR') // true
|
|
72
|
-
* validateLocaleCode('en_US') // false
|
|
73
|
-
* validateLocaleCode('EN-US') // false
|
|
74
|
-
* validateLocaleCode('e-US') // false
|
|
75
|
-
*/
|
|
76
|
-
export declare function validateLocaleCode(code: string): boolean;
|
|
77
|
-
/**
|
|
78
|
-
* Validates a locale definition object
|
|
79
|
-
* Requirements: 1.2, 1.3
|
|
80
|
-
*
|
|
81
|
-
* @param locale - The locale definition to validate
|
|
82
|
-
* @returns Validation result with errors and warnings
|
|
83
|
-
*/
|
|
84
|
-
export declare function validateLocaleDefinition(locale: Partial<LocaleDefinition>): LocaleValidationResult;
|
|
85
|
-
/**
|
|
86
|
-
* Validates a locale configuration object
|
|
87
|
-
* Requirements: 1.2, 1.3
|
|
88
|
-
*
|
|
89
|
-
* @param config - The locale configuration to validate
|
|
90
|
-
* @returns Validation result with errors and warnings
|
|
91
|
-
*/
|
|
92
|
-
export declare function validateLocaleConfig(config: Partial<LocaleConfig>): LocaleValidationResult;
|
|
93
|
-
/**
|
|
94
|
-
* Checks if a locale code exists in a locale configuration
|
|
95
|
-
*
|
|
96
|
-
* @param config - The locale configuration to search
|
|
97
|
-
* @param code - The locale code to find
|
|
98
|
-
* @returns True if the locale code exists in the configuration
|
|
99
|
-
*/
|
|
100
|
-
export declare function localeExists(config: LocaleConfig, code: string): boolean;
|
|
101
|
-
/**
|
|
102
|
-
* Gets enabled locales from a configuration
|
|
103
|
-
*
|
|
104
|
-
* @param config - The locale configuration
|
|
105
|
-
* @returns Array of enabled locale definitions
|
|
106
|
-
*/
|
|
107
|
-
export declare function getEnabledLocales(config: LocaleConfig): LocaleDefinition[];
|
|
108
|
-
/**
|
|
109
|
-
* Finds a locale definition by code
|
|
110
|
-
*
|
|
111
|
-
* @param config - The locale configuration to search
|
|
112
|
-
* @param code - The locale code to find
|
|
113
|
-
* @returns The locale definition or undefined if not found
|
|
114
|
-
*/
|
|
115
|
-
export declare function findLocaleByCode(config: LocaleConfig, code: string): LocaleDefinition | undefined;
|
|
@@ -1,89 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Easyling Authentication Type Definitions
|
|
3
|
-
*
|
|
4
|
-
* This file contains all TypeScript interfaces, types, and enums
|
|
5
|
-
* for Easyling authentication implementation in the Sanity Translation Plugin.
|
|
6
|
-
*/
|
|
7
|
-
/**
|
|
8
|
-
* Easyling configuration for connecting to the translation service
|
|
9
|
-
*/
|
|
10
|
-
export interface OAuthConfig {
|
|
11
|
-
/** Project ID for the Easyling project */
|
|
12
|
-
projectId: string;
|
|
13
|
-
/** Long-lived access token provided by Easyling */
|
|
14
|
-
accessToken: string;
|
|
15
|
-
}
|
|
16
|
-
/**
|
|
17
|
-
* Result of the authentication process
|
|
18
|
-
*/
|
|
19
|
-
export interface AuthenticationResult {
|
|
20
|
-
/** Whether authentication was successful */
|
|
21
|
-
success: boolean;
|
|
22
|
-
/** Access token if authentication succeeded */
|
|
23
|
-
accessToken?: string;
|
|
24
|
-
/** Selected project ID if authentication succeeded */
|
|
25
|
-
projectId?: string;
|
|
26
|
-
/** Error message if authentication failed */
|
|
27
|
-
error?: string;
|
|
28
|
-
}
|
|
29
|
-
/**
|
|
30
|
-
* Stored authentication data persisted in storage
|
|
31
|
-
*/
|
|
32
|
-
export interface StoredAuthData {
|
|
33
|
-
/** Access token for API requests */
|
|
34
|
-
accessToken: string;
|
|
35
|
-
/** Selected project ID */
|
|
36
|
-
projectId: string;
|
|
37
|
-
/** Optional project name for display purposes */
|
|
38
|
-
projectName?: string;
|
|
39
|
-
/** Timestamp when data was stored (Unix timestamp in milliseconds) */
|
|
40
|
-
storedAt: number;
|
|
41
|
-
}
|
|
42
|
-
/**
|
|
43
|
-
* Authentication state enumeration
|
|
44
|
-
*/
|
|
45
|
-
export type AuthState = 'unauthenticated' | 'authenticated' | 'error';
|
|
46
|
-
/**
|
|
47
|
-
* Authentication state data with additional context
|
|
48
|
-
*/
|
|
49
|
-
export interface AuthStateData {
|
|
50
|
-
/** Current authentication state */
|
|
51
|
-
state: AuthState;
|
|
52
|
-
/** Selected project ID if authenticated */
|
|
53
|
-
projectId?: string;
|
|
54
|
-
/** Project name for display if available */
|
|
55
|
-
projectName?: string;
|
|
56
|
-
/** Error message if state is 'error' */
|
|
57
|
-
error?: string;
|
|
58
|
-
}
|
|
59
|
-
/**
|
|
60
|
-
* Authentication error types for categorizing failures
|
|
61
|
-
*/
|
|
62
|
-
export declare enum OAuthErrorType {
|
|
63
|
-
/** Invalid configuration */
|
|
64
|
-
INVALID_CONFIG = "invalid_config",
|
|
65
|
-
/** Network error during API request */
|
|
66
|
-
NETWORK_ERROR = "network_error",
|
|
67
|
-
/** Authentication failed */
|
|
68
|
-
AUTH_FAILED = "auth_failed",
|
|
69
|
-
/** Storage operation failed */
|
|
70
|
-
STORAGE_ERROR = "storage_error"
|
|
71
|
-
}
|
|
72
|
-
/**
|
|
73
|
-
* Custom error class for OAuth-related errors
|
|
74
|
-
*/
|
|
75
|
-
export declare class OAuthError extends Error {
|
|
76
|
-
/** Error type for categorization */
|
|
77
|
-
readonly type: OAuthErrorType;
|
|
78
|
-
/** Additional error details */
|
|
79
|
-
readonly details?: unknown;
|
|
80
|
-
constructor(type: OAuthErrorType, message: string, details?: unknown);
|
|
81
|
-
/**
|
|
82
|
-
* Get a user-friendly error message based on error type
|
|
83
|
-
*/
|
|
84
|
-
getUserMessage(): string;
|
|
85
|
-
/**
|
|
86
|
-
* Check if this error is recoverable (user can retry)
|
|
87
|
-
*/
|
|
88
|
-
isRecoverable(): boolean;
|
|
89
|
-
}
|
|
@@ -1,64 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Plugin configuration type definitions
|
|
3
|
-
* Requirements: 1.1, 1.5, 2.3, 3.3, 4.2
|
|
4
|
-
*/
|
|
5
|
-
import { LocaleDefinition } from './locale';
|
|
6
|
-
import { DNTTypeConfig } from './dnt';
|
|
7
|
-
/**
|
|
8
|
-
* Document creation mode options
|
|
9
|
-
* Determines whether translated documents are created as drafts or published
|
|
10
|
-
*/
|
|
11
|
-
export type DocumentCreationMode = 'draft' | 'published';
|
|
12
|
-
/**
|
|
13
|
-
* Content type options for requests/responses
|
|
14
|
-
* Specifies the serialization format for translation API communication
|
|
15
|
-
*/
|
|
16
|
-
export type ContentType = 'application/json' | 'application/x-protobuf';
|
|
17
|
-
/**
|
|
18
|
-
* Collision resolution mode options
|
|
19
|
-
* Determines how to handle existing translated documents when a collision is detected
|
|
20
|
-
* - 'replace': Overwrite the existing translated document with new translations
|
|
21
|
-
* - 'create': Create a new translated document alongside the existing one
|
|
22
|
-
*/
|
|
23
|
-
export type CollisionResolutionMode = 'replace' | 'create';
|
|
24
|
-
/**
|
|
25
|
-
* Existing document handling options (only applicable when CollisionResolutionMode is 'create')
|
|
26
|
-
* Determines what happens to the existing translated document when creating a new one
|
|
27
|
-
* - 'draft': Set the existing document to draft state
|
|
28
|
-
* - 'delete': Delete the existing document
|
|
29
|
-
*/
|
|
30
|
-
export type ExistingDocumentHandling = 'draft' | 'delete';
|
|
31
|
-
/**
|
|
32
|
-
* Complete plugin configuration interface
|
|
33
|
-
* Represents all configurable settings for the Easyling Translation Plugin
|
|
34
|
-
*/
|
|
35
|
-
export interface PluginConfiguration {
|
|
36
|
-
/** Easyling project ID */
|
|
37
|
-
projectId?: string;
|
|
38
|
-
/** Long-lived access token for API authentication */
|
|
39
|
-
accessToken?: string;
|
|
40
|
-
/** URL endpoint where translation requests are sent */
|
|
41
|
-
translationApiEndpoint?: string;
|
|
42
|
-
/** Content-Type header for translation request payloads */
|
|
43
|
-
requestContentType?: ContentType;
|
|
44
|
-
/** Accept header for translation response format negotiation */
|
|
45
|
-
responseAcceptHeader?: ContentType;
|
|
46
|
-
/** Default mode for creating translated documents (draft or published) */
|
|
47
|
-
defaultDocumentCreationMode?: DocumentCreationMode;
|
|
48
|
-
/** How to handle collisions when a translated document already exists for the same source and locale */
|
|
49
|
-
collisionResolutionMode?: CollisionResolutionMode;
|
|
50
|
-
/** How to handle existing documents when creating new translations (only applicable when mode is 'create') */
|
|
51
|
-
existingDocumentHandling?: ExistingDocumentHandling;
|
|
52
|
-
/** Array of configured locales for translation */
|
|
53
|
-
locales?: LocaleDefinition[];
|
|
54
|
-
/** Default source locale code */
|
|
55
|
-
defaultLocale?: string;
|
|
56
|
-
/** Document-type-based DNT field configurations */
|
|
57
|
-
dntFieldConfigurations?: DNTTypeConfig[];
|
|
58
|
-
/** When enabled, displays additional DNT status badges on all fields */
|
|
59
|
-
debugMode?: boolean;
|
|
60
|
-
/** Configuration schema version for migration purposes */
|
|
61
|
-
version?: string;
|
|
62
|
-
/** ISO 8601 timestamp of last configuration update */
|
|
63
|
-
lastUpdated?: string;
|
|
64
|
-
}
|