@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,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,46 +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
- * Complete plugin configuration interface
19
- * Represents all configurable settings for the Easyling Translation Plugin
20
- */
21
- export interface PluginConfiguration {
22
- /** Easyling project ID */
23
- projectId?: string;
24
- /** Long-lived access token for API authentication */
25
- accessToken?: string;
26
- /** URL endpoint where translation requests are sent */
27
- translationApiEndpoint?: string;
28
- /** Content-Type header for translation request payloads */
29
- requestContentType?: ContentType;
30
- /** Accept header for translation response format negotiation */
31
- responseAcceptHeader?: ContentType;
32
- /** Default mode for creating translated documents (draft or published) */
33
- defaultDocumentCreationMode?: DocumentCreationMode;
34
- /** Array of configured locales for translation */
35
- locales?: LocaleDefinition[];
36
- /** Default source locale code */
37
- defaultLocale?: string;
38
- /** Document-type-based DNT field configurations */
39
- dntFieldConfigurations?: DNTTypeConfig[];
40
- /** When enabled, displays additional DNT status badges on all fields */
41
- debugMode?: boolean;
42
- /** Configuration schema version for migration purposes */
43
- version?: string;
44
- /** ISO 8601 timestamp of last configuration update */
45
- lastUpdated?: string;
46
- }
@@ -1,121 +0,0 @@
1
- /**
2
- * Enhanced translation request/response type definitions
3
- * Requirements: 5.1, 5.2, 5.3
4
- */
5
- /**
6
- * Enhanced translation request with locale support
7
- */
8
- export interface EnhancedTranslationRequest {
9
- /** Unique identifier for the document */
10
- documentId: string;
11
- /** Sanity document type */
12
- documentType: string;
13
- /** HTML content to translate */
14
- htmlContent: string;
15
- /** Array of target locale codes */
16
- targetLocales: string[];
17
- /** Optional source locale code */
18
- sourceLocale?: string;
19
- /** Request metadata */
20
- metadata: {
21
- /** Document title */
22
- title: string;
23
- /** Request timestamp */
24
- timestamp: string;
25
- /** Plugin version */
26
- pluginVersion: string;
27
- /** Unique request identifier */
28
- requestId: string;
29
- };
30
- }
31
- /**
32
- * Enhanced translation response with multi-locale support
33
- */
34
- export interface EnhancedTranslationResponse {
35
- /** Whether the overall request was successful */
36
- success: boolean;
37
- /** Unique request identifier */
38
- requestId: string;
39
- /** Source locale code */
40
- sourceLocale?: string;
41
- /** Translations for each requested locale */
42
- translations: {
43
- [localeCode: string]: {
44
- /** Translated content */
45
- content: string;
46
- /** Translation status */
47
- status: 'completed' | 'failed' | 'pending';
48
- /** Error message if translation failed */
49
- error?: string;
50
- };
51
- };
52
- /** Overall error message if request failed */
53
- error?: string;
54
- }
55
- /**
56
- * Translation progress information
57
- */
58
- export interface TranslationProgress {
59
- /** Total number of translations requested */
60
- total: number;
61
- /** Number of completed translations */
62
- completed: number;
63
- /** Number of failed translations */
64
- failed: number;
65
- /** Number of pending translations */
66
- pending: number;
67
- /** Current translation being processed */
68
- current?: {
69
- documentId: string;
70
- locale: string;
71
- };
72
- }
73
- /**
74
- * Bulk translation request with locale selection
75
- */
76
- export interface BulkTranslationRequest {
77
- /** Array of document IDs to translate */
78
- documentIds: string[];
79
- /** Array of target locale codes */
80
- targetLocales: string[];
81
- /** Optional source locale code */
82
- sourceLocale?: string;
83
- /** Request metadata */
84
- metadata: {
85
- /** Request timestamp */
86
- timestamp: string;
87
- /** Plugin version */
88
- pluginVersion: string;
89
- /** Unique request identifier */
90
- requestId: string;
91
- };
92
- }
93
- /**
94
- * Bulk translation summary with locale breakdown
95
- */
96
- export interface EnhancedBulkTranslationSummary {
97
- /** Total number of documents processed */
98
- totalDocuments: number;
99
- /** Total number of locale translations requested */
100
- totalTranslations: number;
101
- /** Number of successful translations */
102
- successfulTranslations: number;
103
- /** Number of failed translations */
104
- failedTranslations: number;
105
- /** Breakdown by locale */
106
- localeBreakdown: {
107
- [localeCode: string]: {
108
- /** Number of successful translations for this locale */
109
- successful: number;
110
- /** Number of failed translations for this locale */
111
- failed: number;
112
- /** Error messages for failed translations */
113
- errors: string[];
114
- };
115
- };
116
- /** Individual translation requests */
117
- requests: EnhancedTranslationRequest[];
118
- /** Individual translation responses */
119
- responses: EnhancedTranslationResponse[];
120
- }
121
- export type { TranslationRequestPayload, TranslationResponse, TranslatableField } from '../services/translationService';
@@ -1,101 +0,0 @@
1
- /**
2
- * DNT (Do Not Translate) Defaults Utility
3
- *
4
- * Determines whether a field should default to DNT based on:
5
- * - Field type (slug, date, datetime, reference, image, file, geopoint, number, boolean)
6
- * - Field name patterns (containing "author" or "contributor")
7
- * - Group/fieldset name patterns (containing "date" or "time")
8
- */
9
- /**
10
- * Field types that are inherently non-translatable
11
- * These fields contain data that should not be modified by translation
12
- */
13
- export declare const NON_TRANSLATABLE_TYPES: string[];
14
- /**
15
- * Field name patterns that indicate DNT by default (case-insensitive)
16
- * Fields with names containing these strings should not be translated
17
- */
18
- export declare const DNT_FIELD_NAME_PATTERNS: string[];
19
- /**
20
- * Group/fieldset name patterns that indicate all contained fields should be DNT (case-insensitive)
21
- */
22
- export declare const DNT_GROUP_NAME_PATTERNS: string[];
23
- /**
24
- * Context information about a field's location in the schema
25
- */
26
- export interface FieldContext {
27
- /** The field path (e.g., 'title', 'content.author') */
28
- fieldPath: string;
29
- /** The field name (last segment of path) */
30
- fieldName: string;
31
- /** The Sanity field type (e.g., 'string', 'date', 'slug') */
32
- fieldType?: string;
33
- /** Name of the group this field belongs to, if any */
34
- groupName?: string;
35
- /** Name of the fieldset this field belongs to, if any */
36
- fieldsetName?: string;
37
- }
38
- /**
39
- * Result of DNT default computation
40
- */
41
- export interface DNTDefaultResult {
42
- /** Whether the field should default to DNT */
43
- shouldBeDNT: boolean;
44
- /** Reason for the DNT default decision */
45
- reason: string;
46
- }
47
- /**
48
- * Check if a field type is inherently non-translatable
49
- *
50
- * @param fieldType - The Sanity field type
51
- * @returns True if the field type should not be translated
52
- */
53
- export declare function isNonTranslatableType(fieldType: string | undefined): boolean;
54
- /**
55
- * Check if a field name matches DNT patterns
56
- *
57
- * @param fieldName - The field name to check
58
- * @returns Object with match status and matched pattern
59
- */
60
- export declare function matchesDNTFieldNamePattern(fieldName: string): {
61
- matches: boolean;
62
- pattern?: string;
63
- };
64
- /**
65
- * Check if a group or fieldset name matches DNT patterns
66
- *
67
- * @param groupOrFieldsetName - The group or fieldset name to check
68
- * @returns Object with match status and matched pattern
69
- */
70
- export declare function matchesDNTGroupPattern(groupOrFieldsetName: string | undefined): {
71
- matches: boolean;
72
- pattern?: string;
73
- };
74
- /**
75
- * Compute the default DNT status for a field based on its context
76
- *
77
- * Priority order:
78
- * 1. Non-translatable field type (slug, date, etc.)
79
- * 2. Field name contains "author" or "contributor"
80
- * 3. Field is in a group/fieldset containing "date" or "time"
81
- *
82
- * @param context - Field context information
83
- * @returns DNT default result with reason
84
- */
85
- export declare function computeDNTDefault(context: FieldContext): DNTDefaultResult;
86
- /**
87
- * Determine if a field should show DNT badge based on translatability
88
- * Only translatable field types should show the badge
89
- *
90
- * @param fieldType - The Sanity field type
91
- * @returns True if the field should show a DNT badge
92
- */
93
- export declare function shouldShowDNTBadge(fieldType: string | undefined): boolean;
94
- /**
95
- * Get a human-readable description of the DNT status for debugging
96
- *
97
- * @param context - Field context information
98
- * @param storedDNT - The stored DNT status (if any)
99
- * @returns Debug description
100
- */
101
- export declare function getDNTDebugInfo(context: FieldContext, storedDNT?: boolean): string;
@@ -1,65 +0,0 @@
1
- /**
2
- * HTML formatting utilities for content processing
3
- * Requirements: 3.3, 3.4 - Proper HTML formatting and special character escaping
4
- */
5
- export interface HtmlFormattingOptions {
6
- preserveWhitespace?: boolean;
7
- escapeSpecialChars?: boolean;
8
- minifyOutput?: boolean;
9
- addLineBreaks?: boolean;
10
- }
11
- export declare class HtmlFormatter {
12
- /**
13
- * Escape HTML special characters for JSON transmission
14
- * Requirement 3.4: Properly escape special characters for JSON transmission
15
- */
16
- static escapeHtml(text: string): string;
17
- /**
18
- * Unescape HTML entities back to regular characters
19
- */
20
- static unescapeHtml(html: string): string;
21
- /**
22
- * Format HTML content with proper structure and indentation
23
- * Requirement 3.2: Preserve text structure including paragraphs, lists, and formatting
24
- */
25
- static formatHtml(html: string, options?: HtmlFormattingOptions): string;
26
- /**
27
- * Clean HTML content by removing unwanted tags and attributes
28
- */
29
- static cleanHtml(html: string, allowedTags?: string[]): string;
30
- /**
31
- * Wrap content in appropriate HTML structure
32
- * Requirement 3.3: Include HTML content in structured format
33
- */
34
- static wrapContent(content: string, wrapper?: string, className?: string): string;
35
- /**
36
- * Extract text content from HTML, removing all tags
37
- */
38
- static stripHtml(html: string): string;
39
- /**
40
- * Validate HTML structure and check for common issues
41
- */
42
- static validateHtml(html: string): {
43
- isValid: boolean;
44
- errors: string[];
45
- };
46
- /**
47
- * Convert line breaks to HTML paragraphs
48
- */
49
- static lineBreaksToParagraphs(text: string): string;
50
- /**
51
- * Truncate HTML content while preserving structure
52
- */
53
- static truncateHtml(html: string, maxLength: number, suffix?: string): string;
54
- }
55
- export declare const htmlFormatter: {
56
- escapeHtml: typeof HtmlFormatter.escapeHtml;
57
- unescapeHtml: typeof HtmlFormatter.unescapeHtml;
58
- formatHtml: typeof HtmlFormatter.formatHtml;
59
- cleanHtml: typeof HtmlFormatter.cleanHtml;
60
- wrapContent: typeof HtmlFormatter.wrapContent;
61
- stripHtml: typeof HtmlFormatter.stripHtml;
62
- validateHtml: typeof HtmlFormatter.validateHtml;
63
- lineBreaksToParagraphs: typeof HtmlFormatter.lineBreaksToParagraphs;
64
- truncateHtml: typeof HtmlFormatter.truncateHtml;
65
- };
@@ -1,16 +0,0 @@
1
- /**
2
- * Utility functions for the Sanity Translation Plugin
3
- * Requirements: 3.3, 3.4, 4.3
4
- */
5
- export * from './htmlFormatter';
6
- export * from './logger';
7
- export * from './validator';
8
- export * from './oauthLogger';
9
- export * from './oauthErrorFeedback';
10
- export * from './dntDefaults';
11
- export { HtmlFormatter } from './htmlFormatter';
12
- export { Logger, LogLevel, defaultLogger } from './logger';
13
- export { Validator } from './validator';
14
- export { OAuthLogger, createOAuthLogger } from './oauthLogger';
15
- export { OAuthErrorFeedback, createOAuthErrorFeedback } from './oauthErrorFeedback';
16
- export { computeDNTDefault, isNonTranslatableType, matchesDNTFieldNamePattern, matchesDNTGroupPattern, NON_TRANSLATABLE_TYPES, DNT_FIELD_NAME_PATTERNS, DNT_GROUP_NAME_PATTERNS } from './dntDefaults';