@easyling/sanity-connector 0.0.1
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/LICENSE +21 -0
- package/README.md +482 -0
- package/dist/.tsbuildinfo +1 -0
- package/dist/actions/bulkTranslate.d.ts +7 -0
- package/dist/actions/bulkTranslate.d.ts.map +1 -0
- package/dist/actions/bulkTranslate.js +543 -0
- package/dist/actions/bulkTranslate.js.map +1 -0
- package/dist/actions/manageDNTFields.d.ts +12 -0
- package/dist/actions/manageDNTFields.d.ts.map +1 -0
- package/dist/actions/manageDNTFields.js +100 -0
- package/dist/actions/manageDNTFields.js.map +1 -0
- package/dist/actions/translateDocument.d.ts +7 -0
- package/dist/actions/translateDocument.d.ts.map +1 -0
- package/dist/actions/translateDocument.js +256 -0
- package/dist/actions/translateDocument.js.map +1 -0
- package/dist/components/RadioWithDefault.d.ts +17 -0
- package/dist/components/RadioWithDefault.d.ts.map +1 -0
- package/dist/components/RadioWithDefault.js +29 -0
- package/dist/components/RadioWithDefault.js.map +1 -0
- package/dist/components/auth/AuthNavbar.d.ts +18 -0
- package/dist/components/auth/AuthNavbar.d.ts.map +1 -0
- package/dist/components/auth/AuthNavbar.js +15 -0
- package/dist/components/auth/AuthNavbar.js.map +1 -0
- package/dist/components/auth/AuthStatus.d.ts +27 -0
- package/dist/components/auth/AuthStatus.d.ts.map +1 -0
- package/dist/components/auth/AuthStatus.js +82 -0
- package/dist/components/auth/AuthStatus.js.map +1 -0
- package/dist/components/auth/AuthStatusWrapper.d.ts +15 -0
- package/dist/components/auth/AuthStatusWrapper.d.ts.map +1 -0
- package/dist/components/auth/AuthStatusWrapper.js +39 -0
- package/dist/components/auth/AuthStatusWrapper.js.map +1 -0
- package/dist/components/auth/MigrationPrompt.d.ts +20 -0
- package/dist/components/auth/MigrationPrompt.d.ts.map +1 -0
- package/dist/components/auth/MigrationPrompt.js +16 -0
- package/dist/components/auth/MigrationPrompt.js.map +1 -0
- package/dist/components/auth/MigrationPromptWrapper.d.ts +14 -0
- package/dist/components/auth/MigrationPromptWrapper.d.ts.map +1 -0
- package/dist/components/auth/MigrationPromptWrapper.js +16 -0
- package/dist/components/auth/MigrationPromptWrapper.js.map +1 -0
- package/dist/components/auth/OAuthCallback.d.ts +20 -0
- package/dist/components/auth/OAuthCallback.d.ts.map +1 -0
- package/dist/components/auth/OAuthCallback.js +12 -0
- package/dist/components/auth/OAuthCallback.js.map +1 -0
- package/dist/components/auth/index.d.ts +15 -0
- package/dist/components/auth/index.d.ts.map +1 -0
- package/dist/components/auth/index.js +12 -0
- package/dist/components/auth/index.js.map +1 -0
- package/dist/components/config/LocaleConfigTool.d.ts +17 -0
- package/dist/components/config/LocaleConfigTool.d.ts.map +1 -0
- package/dist/components/config/LocaleConfigTool.js +186 -0
- package/dist/components/config/LocaleConfigTool.js.map +1 -0
- package/dist/components/config/LocaleConfigToolWrapper.d.ts +13 -0
- package/dist/components/config/LocaleConfigToolWrapper.d.ts.map +1 -0
- package/dist/components/config/LocaleConfigToolWrapper.js +26 -0
- package/dist/components/config/LocaleConfigToolWrapper.js.map +1 -0
- package/dist/components/config/OAuthConfig.d.ts +26 -0
- package/dist/components/config/OAuthConfig.d.ts.map +1 -0
- package/dist/components/config/OAuthConfig.js +152 -0
- package/dist/components/config/OAuthConfig.js.map +1 -0
- package/dist/components/config/OAuthConfigWrapper.d.ts +13 -0
- package/dist/components/config/OAuthConfigWrapper.d.ts.map +1 -0
- package/dist/components/config/OAuthConfigWrapper.js +41 -0
- package/dist/components/config/OAuthConfigWrapper.js.map +1 -0
- package/dist/components/config/PasswordInput.d.ts +14 -0
- package/dist/components/config/PasswordInput.d.ts.map +1 -0
- package/dist/components/config/PasswordInput.js +23 -0
- package/dist/components/config/PasswordInput.js.map +1 -0
- package/dist/components/config/index.d.ts +9 -0
- package/dist/components/config/index.d.ts.map +1 -0
- package/dist/components/config/index.js +8 -0
- package/dist/components/config/index.js.map +1 -0
- package/dist/components/config/localeConfigToolDefinition.d.ts +13 -0
- package/dist/components/config/localeConfigToolDefinition.d.ts.map +1 -0
- package/dist/components/config/localeConfigToolDefinition.js +19 -0
- package/dist/components/config/localeConfigToolDefinition.js.map +1 -0
- package/dist/components/config/oauthConfigToolDefinition.d.ts +13 -0
- package/dist/components/config/oauthConfigToolDefinition.d.ts.map +1 -0
- package/dist/components/config/oauthConfigToolDefinition.js +19 -0
- package/dist/components/config/oauthConfigToolDefinition.js.map +1 -0
- package/dist/components/dialogs/ConfirmationDialog.d.ts +21 -0
- package/dist/components/dialogs/ConfirmationDialog.d.ts.map +1 -0
- package/dist/components/dialogs/ConfirmationDialog.js +28 -0
- package/dist/components/dialogs/ConfirmationDialog.js.map +1 -0
- package/dist/components/dialogs/ErrorDialog.d.ts +21 -0
- package/dist/components/dialogs/ErrorDialog.d.ts.map +1 -0
- package/dist/components/dialogs/ErrorDialog.js +28 -0
- package/dist/components/dialogs/ErrorDialog.js.map +1 -0
- package/dist/components/dialogs/LocaleSelectionDialog.d.ts +41 -0
- package/dist/components/dialogs/LocaleSelectionDialog.d.ts.map +1 -0
- package/dist/components/dialogs/LocaleSelectionDialog.js +117 -0
- package/dist/components/dialogs/LocaleSelectionDialog.js.map +1 -0
- package/dist/components/dialogs/SuccessDialog.d.ts +19 -0
- package/dist/components/dialogs/SuccessDialog.d.ts.map +1 -0
- package/dist/components/dialogs/SuccessDialog.js +37 -0
- package/dist/components/dialogs/SuccessDialog.js.map +1 -0
- package/dist/components/dialogs/index.d.ts +12 -0
- package/dist/components/dialogs/index.d.ts.map +1 -0
- package/dist/components/dialogs/index.js +8 -0
- package/dist/components/dialogs/index.js.map +1 -0
- package/dist/components/dnt/DNTFieldBadge.d.ts +16 -0
- package/dist/components/dnt/DNTFieldBadge.d.ts.map +1 -0
- package/dist/components/dnt/DNTFieldBadge.js +56 -0
- package/dist/components/dnt/DNTFieldBadge.js.map +1 -0
- package/dist/components/dnt/DNTFieldComponent.d.ts +17 -0
- package/dist/components/dnt/DNTFieldComponent.d.ts.map +1 -0
- package/dist/components/dnt/DNTFieldComponent.js +21 -0
- package/dist/components/dnt/DNTFieldComponent.js.map +1 -0
- package/dist/components/dnt/DNTFieldInput.d.ts +14 -0
- package/dist/components/dnt/DNTFieldInput.d.ts.map +1 -0
- package/dist/components/dnt/DNTFieldInput.js +76 -0
- package/dist/components/dnt/DNTFieldInput.js.map +1 -0
- package/dist/components/dnt/index.d.ts +7 -0
- package/dist/components/dnt/index.d.ts.map +1 -0
- package/dist/components/dnt/index.js +7 -0
- package/dist/components/dnt/index.js.map +1 -0
- package/dist/config/index.d.ts +6 -0
- package/dist/config/index.d.ts.map +1 -0
- package/dist/config/index.js +6 -0
- package/dist/config/index.js.map +1 -0
- package/dist/config/pluginConfig.d.ts +163 -0
- package/dist/config/pluginConfig.d.ts.map +1 -0
- package/dist/config/pluginConfig.js +548 -0
- package/dist/config/pluginConfig.js.map +1 -0
- package/dist/index.d.ts +12 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +12 -0
- package/dist/index.js.map +1 -0
- package/dist/plugin.d.ts +3 -0
- package/dist/plugin.d.ts.map +1 -0
- package/dist/plugin.js +137 -0
- package/dist/plugin.js.map +1 -0
- package/dist/services/authStateManager.d.ts +94 -0
- package/dist/services/authStateManager.d.ts.map +1 -0
- package/dist/services/authStateManager.js +208 -0
- package/dist/services/authStateManager.js.map +1 -0
- package/dist/services/contentExtractor.d.ts +95 -0
- package/dist/services/contentExtractor.d.ts.map +1 -0
- package/dist/services/contentExtractor.js +516 -0
- package/dist/services/contentExtractor.js.map +1 -0
- package/dist/services/dialogService.d.ts +96 -0
- package/dist/services/dialogService.d.ts.map +1 -0
- package/dist/services/dialogService.js +244 -0
- package/dist/services/dialogService.js.map +1 -0
- package/dist/services/dntServiceManager.d.ts +44 -0
- package/dist/services/dntServiceManager.d.ts.map +1 -0
- package/dist/services/dntServiceManager.js +74 -0
- package/dist/services/dntServiceManager.js.map +1 -0
- package/dist/services/dntStorageAdapter.d.ts +73 -0
- package/dist/services/dntStorageAdapter.d.ts.map +1 -0
- package/dist/services/dntStorageAdapter.js +192 -0
- package/dist/services/dntStorageAdapter.js.map +1 -0
- package/dist/services/documentCreationService.d.ts +139 -0
- package/dist/services/documentCreationService.d.ts.map +1 -0
- package/dist/services/documentCreationService.js +938 -0
- package/dist/services/documentCreationService.js.map +1 -0
- package/dist/services/localeService.d.ts +160 -0
- package/dist/services/localeService.d.ts.map +1 -0
- package/dist/services/localeService.js +300 -0
- package/dist/services/localeService.js.map +1 -0
- package/dist/services/localeStorageAdapter.d.ts +42 -0
- package/dist/services/localeStorageAdapter.d.ts.map +1 -0
- package/dist/services/localeStorageAdapter.js +107 -0
- package/dist/services/localeStorageAdapter.js.map +1 -0
- package/dist/services/oauthConfigStorage.d.ts +46 -0
- package/dist/services/oauthConfigStorage.d.ts.map +1 -0
- package/dist/services/oauthConfigStorage.js +122 -0
- package/dist/services/oauthConfigStorage.js.map +1 -0
- package/dist/services/oauthService.d.ts +48 -0
- package/dist/services/oauthService.d.ts.map +1 -0
- package/dist/services/oauthService.js +71 -0
- package/dist/services/oauthService.js.map +1 -0
- package/dist/services/oauthServiceManager.d.ts +189 -0
- package/dist/services/oauthServiceManager.d.ts.map +1 -0
- package/dist/services/oauthServiceManager.js +380 -0
- package/dist/services/oauthServiceManager.js.map +1 -0
- package/dist/services/tokenStorage.d.ts +54 -0
- package/dist/services/tokenStorage.d.ts.map +1 -0
- package/dist/services/tokenStorage.js +140 -0
- package/dist/services/tokenStorage.js.map +1 -0
- package/dist/services/translationService.d.ts +374 -0
- package/dist/services/translationService.d.ts.map +1 -0
- package/dist/services/translationService.js +687 -0
- package/dist/services/translationService.js.map +1 -0
- package/dist/services/unifiedConfigStorage.d.ts +124 -0
- package/dist/services/unifiedConfigStorage.d.ts.map +1 -0
- package/dist/services/unifiedConfigStorage.js +304 -0
- package/dist/services/unifiedConfigStorage.js.map +1 -0
- package/dist/test-utils.d.ts +9 -0
- package/dist/test-utils.d.ts.map +1 -0
- package/dist/test-utils.js +13 -0
- package/dist/test-utils.js.map +1 -0
- package/dist/types/dialog.d.ts +107 -0
- package/dist/types/dialog.d.ts.map +1 -0
- package/dist/types/dialog.js +6 -0
- package/dist/types/dialog.js.map +1 -0
- package/dist/types/dnt.d.ts +84 -0
- package/dist/types/dnt.d.ts.map +1 -0
- package/dist/types/dnt.js +5 -0
- package/dist/types/dnt.js.map +1 -0
- package/dist/types/index.d.ts +12 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/index.js +6 -0
- package/dist/types/index.js.map +1 -0
- package/dist/types/locale.d.ts +116 -0
- package/dist/types/locale.d.ts.map +1 -0
- package/dist/types/locale.js +189 -0
- package/dist/types/locale.js.map +1 -0
- package/dist/types/oauth.d.ts +90 -0
- package/dist/types/oauth.d.ts.map +1 -0
- package/dist/types/oauth.js +62 -0
- package/dist/types/oauth.js.map +1 -0
- package/dist/types/pluginConfig.d.ts +45 -0
- package/dist/types/pluginConfig.d.ts.map +1 -0
- package/dist/types/pluginConfig.js +6 -0
- package/dist/types/pluginConfig.js.map +1 -0
- package/dist/types/translation.d.ts +122 -0
- package/dist/types/translation.d.ts.map +1 -0
- package/dist/types/translation.js +6 -0
- package/dist/types/translation.js.map +1 -0
- package/dist/utils/htmlFormatter.d.ts +66 -0
- package/dist/utils/htmlFormatter.d.ts.map +1 -0
- package/dist/utils/htmlFormatter.js +191 -0
- package/dist/utils/htmlFormatter.js.map +1 -0
- package/dist/utils/index.d.ts +15 -0
- package/dist/utils/index.d.ts.map +1 -0
- package/dist/utils/index.js +16 -0
- package/dist/utils/index.js.map +1 -0
- package/dist/utils/logger.d.ts +105 -0
- package/dist/utils/logger.d.ts.map +1 -0
- package/dist/utils/logger.js +229 -0
- package/dist/utils/logger.js.map +1 -0
- package/dist/utils/oauthErrorFeedback.d.ts +76 -0
- package/dist/utils/oauthErrorFeedback.d.ts.map +1 -0
- package/dist/utils/oauthErrorFeedback.js +134 -0
- package/dist/utils/oauthErrorFeedback.js.map +1 -0
- package/dist/utils/oauthLogger.d.ts +176 -0
- package/dist/utils/oauthLogger.d.ts.map +1 -0
- package/dist/utils/oauthLogger.js +282 -0
- package/dist/utils/oauthLogger.js.map +1 -0
- package/dist/utils/validator.d.ts +67 -0
- package/dist/utils/validator.d.ts.map +1 -0
- package/dist/utils/validator.js +390 -0
- package/dist/utils/validator.js.map +1 -0
- package/package.json +80 -0
|
@@ -0,0 +1,390 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Validation functions for document and payload structure
|
|
3
|
+
* Requirements: 3.4, 4.3 - Validate document structure and provide clear error messages
|
|
4
|
+
*/
|
|
5
|
+
export class Validator {
|
|
6
|
+
/**
|
|
7
|
+
* Validate Sanity document structure
|
|
8
|
+
* Requirement 3.4: Validate document structure
|
|
9
|
+
*/
|
|
10
|
+
static validateSanityDocument(document, options = {}) {
|
|
11
|
+
const errors = [];
|
|
12
|
+
const warnings = [];
|
|
13
|
+
const { requireTitle = false, requireContent = false, allowEmptyFields = true, maxContentLength = 1000000 // 1MB
|
|
14
|
+
} = options;
|
|
15
|
+
// Check if document exists
|
|
16
|
+
if (!document) {
|
|
17
|
+
errors.push('Document is null or undefined');
|
|
18
|
+
return { isValid: false, errors, warnings };
|
|
19
|
+
}
|
|
20
|
+
// Check for required Sanity document fields
|
|
21
|
+
if (!document._id) {
|
|
22
|
+
errors.push('Document missing required _id field');
|
|
23
|
+
}
|
|
24
|
+
if (!document._type) {
|
|
25
|
+
errors.push('Document missing required _type field');
|
|
26
|
+
}
|
|
27
|
+
// Validate _id format (basic Sanity ID validation)
|
|
28
|
+
if (document._id && typeof document._id === 'string') {
|
|
29
|
+
if (document._id.length === 0) {
|
|
30
|
+
errors.push('Document _id cannot be empty');
|
|
31
|
+
}
|
|
32
|
+
else if (!/^[a-zA-Z0-9._-]+$/.test(document._id)) {
|
|
33
|
+
warnings.push('Document _id contains unusual characters');
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
else if (document._id) {
|
|
37
|
+
errors.push('Document _id must be a string');
|
|
38
|
+
}
|
|
39
|
+
// Validate _type
|
|
40
|
+
if (document._type && typeof document._type !== 'string') {
|
|
41
|
+
errors.push('Document _type must be a string');
|
|
42
|
+
}
|
|
43
|
+
// Check for title if required
|
|
44
|
+
if (requireTitle) {
|
|
45
|
+
const titleFields = ['title', 'name', 'heading', 'label'];
|
|
46
|
+
const hasTitle = titleFields.some(field => document[field] && typeof document[field] === 'string' && document[field].trim());
|
|
47
|
+
if (!hasTitle) {
|
|
48
|
+
errors.push('Document missing required title field');
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
// Check for content if required
|
|
52
|
+
if (requireContent) {
|
|
53
|
+
const contentFields = ['body', 'content', 'text', 'description'];
|
|
54
|
+
const hasContent = contentFields.some(field => {
|
|
55
|
+
const value = document[field];
|
|
56
|
+
return value && ((typeof value === 'string' && value.trim()) ||
|
|
57
|
+
(Array.isArray(value) && value.length > 0) ||
|
|
58
|
+
(typeof value === 'object' && Object.keys(value).length > 0));
|
|
59
|
+
});
|
|
60
|
+
if (!hasContent) {
|
|
61
|
+
errors.push('Document missing required content fields');
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
// Check for empty fields if not allowed
|
|
65
|
+
if (!allowEmptyFields) {
|
|
66
|
+
for (const [key, value] of Object.entries(document)) {
|
|
67
|
+
if (!key.startsWith('_') && (value === null || value === undefined || value === '')) {
|
|
68
|
+
warnings.push(`Document field '${key}' is empty`);
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
// Estimate content size
|
|
73
|
+
const documentSize = JSON.stringify(document).length;
|
|
74
|
+
if (documentSize > maxContentLength) {
|
|
75
|
+
errors.push(`Document size (${documentSize} bytes) exceeds maximum allowed (${maxContentLength} bytes)`);
|
|
76
|
+
}
|
|
77
|
+
// Check for circular references (basic check)
|
|
78
|
+
try {
|
|
79
|
+
JSON.stringify(document);
|
|
80
|
+
}
|
|
81
|
+
catch (error) {
|
|
82
|
+
if (error instanceof Error && error.message.includes('circular')) {
|
|
83
|
+
errors.push('Document contains circular references');
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
return {
|
|
87
|
+
isValid: errors.length === 0,
|
|
88
|
+
errors,
|
|
89
|
+
warnings
|
|
90
|
+
};
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* Validate document content structure
|
|
94
|
+
* Requirement 3.4: Validate extracted content structure
|
|
95
|
+
*/
|
|
96
|
+
static validateDocumentContent(content) {
|
|
97
|
+
const errors = [];
|
|
98
|
+
const warnings = [];
|
|
99
|
+
if (!content) {
|
|
100
|
+
errors.push('Document content is null or undefined');
|
|
101
|
+
return { isValid: false, errors, warnings };
|
|
102
|
+
}
|
|
103
|
+
// Check required fields
|
|
104
|
+
if (!content.documentId) {
|
|
105
|
+
errors.push('Document content missing documentId');
|
|
106
|
+
}
|
|
107
|
+
else if (typeof content.documentId !== 'string') {
|
|
108
|
+
errors.push('Document content documentId must be a string');
|
|
109
|
+
}
|
|
110
|
+
if (!content.title) {
|
|
111
|
+
warnings.push('Document content missing title');
|
|
112
|
+
}
|
|
113
|
+
else if (typeof content.title !== 'string') {
|
|
114
|
+
errors.push('Document content title must be a string');
|
|
115
|
+
}
|
|
116
|
+
if (content.htmlContent === undefined || content.htmlContent === null) {
|
|
117
|
+
errors.push('Document content missing htmlContent');
|
|
118
|
+
}
|
|
119
|
+
else if (typeof content.htmlContent !== 'string') {
|
|
120
|
+
errors.push('Document content htmlContent must be a string');
|
|
121
|
+
}
|
|
122
|
+
else if (content.htmlContent.trim() === '') {
|
|
123
|
+
warnings.push('Document content htmlContent is empty');
|
|
124
|
+
}
|
|
125
|
+
return {
|
|
126
|
+
isValid: errors.length === 0,
|
|
127
|
+
errors,
|
|
128
|
+
warnings
|
|
129
|
+
};
|
|
130
|
+
}
|
|
131
|
+
/**
|
|
132
|
+
* Validate extended document content structure
|
|
133
|
+
*/
|
|
134
|
+
static validateExtendedDocumentContent(content) {
|
|
135
|
+
const errors = [];
|
|
136
|
+
const warnings = [];
|
|
137
|
+
// First validate as basic document content
|
|
138
|
+
const basicValidation = this.validateDocumentContent(content);
|
|
139
|
+
errors.push(...basicValidation.errors);
|
|
140
|
+
warnings.push(...basicValidation.warnings);
|
|
141
|
+
// Additional validation for extended fields
|
|
142
|
+
if (content.slug !== undefined && typeof content.slug !== 'string') {
|
|
143
|
+
errors.push('Extended document content slug must be a string');
|
|
144
|
+
}
|
|
145
|
+
if (content.fields !== undefined) {
|
|
146
|
+
if (typeof content.fields !== 'object' || content.fields === null) {
|
|
147
|
+
errors.push('Extended document content fields must be an object');
|
|
148
|
+
}
|
|
149
|
+
else if (Array.isArray(content.fields)) {
|
|
150
|
+
errors.push('Extended document content fields must be an object, not an array');
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
return {
|
|
154
|
+
isValid: errors.length === 0,
|
|
155
|
+
errors,
|
|
156
|
+
warnings
|
|
157
|
+
};
|
|
158
|
+
}
|
|
159
|
+
/**
|
|
160
|
+
* Validate translation request payload
|
|
161
|
+
* Requirement 3.4: Validate payload structure for JSON transmission
|
|
162
|
+
*/
|
|
163
|
+
static validateTranslationPayload(payload, options = {}) {
|
|
164
|
+
const errors = [];
|
|
165
|
+
const warnings = [];
|
|
166
|
+
const { requireMetadata = true, maxPayloadSize = 10000000, // 10MB
|
|
167
|
+
validateHtmlStructure = true } = options;
|
|
168
|
+
if (!payload) {
|
|
169
|
+
errors.push('Translation payload is null or undefined');
|
|
170
|
+
return { isValid: false, errors, warnings };
|
|
171
|
+
}
|
|
172
|
+
// Validate content structure
|
|
173
|
+
if (!payload.content) {
|
|
174
|
+
errors.push('Translation payload missing content field');
|
|
175
|
+
}
|
|
176
|
+
else {
|
|
177
|
+
if (typeof payload.content !== 'object') {
|
|
178
|
+
errors.push('Translation payload content must be an object');
|
|
179
|
+
}
|
|
180
|
+
else {
|
|
181
|
+
// Validate content fields
|
|
182
|
+
if (!payload.content.body) {
|
|
183
|
+
errors.push('Translation payload content missing body field');
|
|
184
|
+
}
|
|
185
|
+
else if (typeof payload.content.body !== 'string') {
|
|
186
|
+
errors.push('Translation payload content body must be a string');
|
|
187
|
+
}
|
|
188
|
+
if (!payload.content.title) {
|
|
189
|
+
warnings.push('Translation payload content missing title field');
|
|
190
|
+
}
|
|
191
|
+
else if (typeof payload.content.title !== 'string') {
|
|
192
|
+
errors.push('Translation payload content title must be a string');
|
|
193
|
+
}
|
|
194
|
+
if (payload.content.slug !== undefined && typeof payload.content.slug !== 'string') {
|
|
195
|
+
errors.push('Translation payload content slug must be a string');
|
|
196
|
+
}
|
|
197
|
+
if (payload.content.fields !== undefined) {
|
|
198
|
+
if (typeof payload.content.fields !== 'object' || payload.content.fields === null) {
|
|
199
|
+
errors.push('Translation payload content fields must be an object');
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
// Validate format
|
|
205
|
+
if (!payload.format) {
|
|
206
|
+
errors.push('Translation payload missing format field');
|
|
207
|
+
}
|
|
208
|
+
else if (payload.format !== 'html') {
|
|
209
|
+
errors.push('Translation payload format must be "html"');
|
|
210
|
+
}
|
|
211
|
+
// Validate metadata if required
|
|
212
|
+
if (requireMetadata) {
|
|
213
|
+
if (!payload.metadata) {
|
|
214
|
+
errors.push('Translation payload missing metadata field');
|
|
215
|
+
}
|
|
216
|
+
else {
|
|
217
|
+
if (typeof payload.metadata !== 'object') {
|
|
218
|
+
errors.push('Translation payload metadata must be an object');
|
|
219
|
+
}
|
|
220
|
+
else {
|
|
221
|
+
// Check required metadata fields
|
|
222
|
+
if (!payload.metadata.documentId) {
|
|
223
|
+
errors.push('Translation payload metadata missing documentId');
|
|
224
|
+
}
|
|
225
|
+
if (!payload.metadata.documentType) {
|
|
226
|
+
errors.push('Translation payload metadata missing documentType');
|
|
227
|
+
}
|
|
228
|
+
if (!payload.metadata.title) {
|
|
229
|
+
warnings.push('Translation payload metadata missing title');
|
|
230
|
+
}
|
|
231
|
+
// Validate optional language fields
|
|
232
|
+
if (payload.metadata.sourceLanguage && typeof payload.metadata.sourceLanguage !== 'string') {
|
|
233
|
+
errors.push('Translation payload metadata sourceLanguage must be a string');
|
|
234
|
+
}
|
|
235
|
+
if (payload.metadata.targetLanguage && typeof payload.metadata.targetLanguage !== 'string') {
|
|
236
|
+
errors.push('Translation payload metadata targetLanguage must be a string');
|
|
237
|
+
}
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
// Validate HTML structure if requested
|
|
242
|
+
if (validateHtmlStructure && payload.content?.body) {
|
|
243
|
+
const htmlValidation = this.validateHtmlContent(payload.content.body);
|
|
244
|
+
if (!htmlValidation.isValid) {
|
|
245
|
+
warnings.push(...htmlValidation.errors.map(error => `HTML validation: ${error}`));
|
|
246
|
+
}
|
|
247
|
+
}
|
|
248
|
+
// Check payload size
|
|
249
|
+
try {
|
|
250
|
+
const payloadSize = JSON.stringify(payload).length;
|
|
251
|
+
if (payloadSize > maxPayloadSize) {
|
|
252
|
+
errors.push(`Translation payload size (${payloadSize} bytes) exceeds maximum allowed (${maxPayloadSize} bytes)`);
|
|
253
|
+
}
|
|
254
|
+
}
|
|
255
|
+
catch (error) {
|
|
256
|
+
errors.push('Translation payload cannot be serialized to JSON');
|
|
257
|
+
}
|
|
258
|
+
return {
|
|
259
|
+
isValid: errors.length === 0,
|
|
260
|
+
errors,
|
|
261
|
+
warnings
|
|
262
|
+
};
|
|
263
|
+
}
|
|
264
|
+
/**
|
|
265
|
+
* Validate HTML content structure
|
|
266
|
+
* Requirement 3.2: Validate HTML structure preservation
|
|
267
|
+
*/
|
|
268
|
+
static validateHtmlContent(html) {
|
|
269
|
+
const errors = [];
|
|
270
|
+
const warnings = [];
|
|
271
|
+
if (typeof html !== 'string') {
|
|
272
|
+
errors.push('HTML content must be a string');
|
|
273
|
+
return { isValid: false, errors, warnings };
|
|
274
|
+
}
|
|
275
|
+
// For basic validation, we'll just check for obviously malformed tags
|
|
276
|
+
// More sophisticated validation would require a proper HTML parser
|
|
277
|
+
// Check for obviously malformed tags
|
|
278
|
+
if (html.includes('<>') || html.includes('</>')) {
|
|
279
|
+
errors.push('Malformed HTML tags detected');
|
|
280
|
+
}
|
|
281
|
+
// Check for unclosed angle brackets
|
|
282
|
+
const openBrackets = (html.match(/</g) || []).length;
|
|
283
|
+
const closeBrackets = (html.match(/>/g) || []).length;
|
|
284
|
+
if (openBrackets !== closeBrackets) {
|
|
285
|
+
warnings.push('Mismatched angle brackets detected');
|
|
286
|
+
}
|
|
287
|
+
// Check for unescaped special characters in text content (basic check)
|
|
288
|
+
const textContent = html.replace(/<[^>]*>/g, '');
|
|
289
|
+
const unescapedChars = textContent.match(/[<>]/g);
|
|
290
|
+
if (unescapedChars && unescapedChars.length > 0) {
|
|
291
|
+
warnings.push('Unescaped special characters found in HTML text content');
|
|
292
|
+
}
|
|
293
|
+
// Check for empty HTML
|
|
294
|
+
const strippedContent = html.replace(/<[^>]*>/g, '').trim();
|
|
295
|
+
if (strippedContent === '') {
|
|
296
|
+
warnings.push('HTML content appears to be empty after stripping tags');
|
|
297
|
+
}
|
|
298
|
+
return {
|
|
299
|
+
isValid: errors.length === 0,
|
|
300
|
+
errors,
|
|
301
|
+
warnings
|
|
302
|
+
};
|
|
303
|
+
}
|
|
304
|
+
/**
|
|
305
|
+
* Validate array of documents for bulk operations
|
|
306
|
+
* Requirement 2.1: Validate multiple documents for bulk processing
|
|
307
|
+
*/
|
|
308
|
+
static validateDocumentArray(documents, options = {}) {
|
|
309
|
+
const errors = [];
|
|
310
|
+
const warnings = [];
|
|
311
|
+
if (!Array.isArray(documents)) {
|
|
312
|
+
errors.push('Documents must be provided as an array');
|
|
313
|
+
return { isValid: false, errors, warnings };
|
|
314
|
+
}
|
|
315
|
+
if (documents.length === 0) {
|
|
316
|
+
warnings.push('Document array is empty');
|
|
317
|
+
return { isValid: true, errors, warnings };
|
|
318
|
+
}
|
|
319
|
+
// Validate each document
|
|
320
|
+
const documentIds = new Set();
|
|
321
|
+
documents.forEach((document, index) => {
|
|
322
|
+
const validation = this.validateSanityDocument(document, options);
|
|
323
|
+
// Add index to error messages for clarity
|
|
324
|
+
validation.errors.forEach(error => {
|
|
325
|
+
errors.push(`Document ${index}: ${error}`);
|
|
326
|
+
});
|
|
327
|
+
validation.warnings.forEach(warning => {
|
|
328
|
+
warnings.push(`Document ${index}: ${warning}`);
|
|
329
|
+
});
|
|
330
|
+
// Check for duplicate document IDs
|
|
331
|
+
if (document?._id) {
|
|
332
|
+
if (documentIds.has(document._id)) {
|
|
333
|
+
errors.push(`Duplicate document ID found: ${document._id}`);
|
|
334
|
+
}
|
|
335
|
+
else {
|
|
336
|
+
documentIds.add(document._id);
|
|
337
|
+
}
|
|
338
|
+
}
|
|
339
|
+
});
|
|
340
|
+
return {
|
|
341
|
+
isValid: errors.length === 0,
|
|
342
|
+
errors,
|
|
343
|
+
warnings
|
|
344
|
+
};
|
|
345
|
+
}
|
|
346
|
+
/**
|
|
347
|
+
* Validate endpoint URL
|
|
348
|
+
*/
|
|
349
|
+
static validateEndpoint(endpoint) {
|
|
350
|
+
const errors = [];
|
|
351
|
+
const warnings = [];
|
|
352
|
+
if (!endpoint) {
|
|
353
|
+
errors.push('Endpoint URL is required');
|
|
354
|
+
return { isValid: false, errors, warnings };
|
|
355
|
+
}
|
|
356
|
+
if (typeof endpoint !== 'string') {
|
|
357
|
+
errors.push('Endpoint URL must be a string');
|
|
358
|
+
return { isValid: false, errors, warnings };
|
|
359
|
+
}
|
|
360
|
+
// Basic URL validation
|
|
361
|
+
try {
|
|
362
|
+
const url = new URL(endpoint);
|
|
363
|
+
if (!['http:', 'https:'].includes(url.protocol)) {
|
|
364
|
+
errors.push('Endpoint URL must use HTTP or HTTPS protocol');
|
|
365
|
+
}
|
|
366
|
+
if (url.hostname === 'localhost' || url.hostname === '127.0.0.1') {
|
|
367
|
+
warnings.push('Using localhost endpoint - ensure this is intended for development');
|
|
368
|
+
}
|
|
369
|
+
}
|
|
370
|
+
catch (error) {
|
|
371
|
+
errors.push('Invalid endpoint URL format');
|
|
372
|
+
}
|
|
373
|
+
return {
|
|
374
|
+
isValid: errors.length === 0,
|
|
375
|
+
errors,
|
|
376
|
+
warnings
|
|
377
|
+
};
|
|
378
|
+
}
|
|
379
|
+
}
|
|
380
|
+
// Export convenience functions for backward compatibility
|
|
381
|
+
export const validator = {
|
|
382
|
+
validateSanityDocument: Validator.validateSanityDocument,
|
|
383
|
+
validateDocumentContent: Validator.validateDocumentContent,
|
|
384
|
+
validateExtendedDocumentContent: Validator.validateExtendedDocumentContent,
|
|
385
|
+
validateTranslationPayload: Validator.validateTranslationPayload,
|
|
386
|
+
validateHtmlContent: Validator.validateHtmlContent,
|
|
387
|
+
validateDocumentArray: Validator.validateDocumentArray,
|
|
388
|
+
validateEndpoint: Validator.validateEndpoint
|
|
389
|
+
};
|
|
390
|
+
//# sourceMappingURL=validator.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"validator.js","sourceRoot":"","sources":["../../src/utils/validator.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAyBH,MAAM,OAAO,SAAS;IACpB;;;OAGG;IACH,MAAM,CAAC,sBAAsB,CAC3B,QAAa,EACb,UAAqC,EAAE;QAEvC,MAAM,MAAM,GAAa,EAAE,CAAC;QAC5B,MAAM,QAAQ,GAAa,EAAE,CAAC;QAE9B,MAAM,EACJ,YAAY,GAAG,KAAK,EACpB,cAAc,GAAG,KAAK,EACtB,gBAAgB,GAAG,IAAI,EACvB,gBAAgB,GAAG,OAAO,CAAC,MAAM;UAClC,GAAG,OAAO,CAAC;QAEZ,2BAA2B;QAC3B,IAAI,CAAC,QAAQ,EAAE,CAAC;YACd,MAAM,CAAC,IAAI,CAAC,+BAA+B,CAAC,CAAC;YAC7C,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,CAAC;QAC9C,CAAC;QAED,4CAA4C;QAC5C,IAAI,CA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AAC,uBAAuB;IAC1D,+BAA+B,EAAE,SAAS,CAAC,+BAA+B;IAC1E,0BAA0B,EAAE,SAAS,CAAC,0BAA0B;IAChE,mBAAmB,EAAE,SAAS,CAAC,mBAAmB;IAClD,qBAAqB,EAAE,SAAS,CAAC,qBAAqB;IACtD,gBAAgB,EAAE,SAAS,CAAC,gBAAgB;CAC7C,CAAC"}
|
package/package.json
ADDED
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@easyling/sanity-connector",
|
|
3
|
+
"version": "0.0.1",
|
|
4
|
+
"description": "A Sanity Studio plugin that enables document translation with support for single and bulk operations. Extracts document content as HTML and prepares translation requests for external services.",
|
|
5
|
+
"main": "dist/index.js",
|
|
6
|
+
"module": "dist/index.js",
|
|
7
|
+
"types": "dist/index.d.ts",
|
|
8
|
+
"exports": {
|
|
9
|
+
".": {
|
|
10
|
+
"types": "./dist/index.d.ts",
|
|
11
|
+
"import": "./dist/index.js",
|
|
12
|
+
"require": "./dist/index.js"
|
|
13
|
+
}
|
|
14
|
+
},
|
|
15
|
+
"files": [
|
|
16
|
+
"dist",
|
|
17
|
+
"README.md",
|
|
18
|
+
"LICENSE"
|
|
19
|
+
],
|
|
20
|
+
"scripts": {
|
|
21
|
+
"build": "npm run clean && tsc",
|
|
22
|
+
"build:bundle": "npm run clean && webpack build && tsc --project tsconfig.bundle.json",
|
|
23
|
+
"build:watch": "tsc --watch",
|
|
24
|
+
"clean": "rimraf dist",
|
|
25
|
+
"dev": "npm run build:watch",
|
|
26
|
+
"test": "jest",
|
|
27
|
+
"test:watch": "jest --watch",
|
|
28
|
+
"test:coverage": "jest --coverage",
|
|
29
|
+
"lint": "eslint src --ext .ts,.tsx",
|
|
30
|
+
"lint:fix": "eslint src --ext .ts,.tsx --fix",
|
|
31
|
+
"typecheck": "tsc --noEmit",
|
|
32
|
+
"prepublishOnly": "npm run build && npm run test && npm run lint",
|
|
33
|
+
"prepare-publish": "node scripts/preparePublish.js"
|
|
34
|
+
},
|
|
35
|
+
"keywords": [
|
|
36
|
+
"sanity",
|
|
37
|
+
"sanity-plugin",
|
|
38
|
+
"translation",
|
|
39
|
+
"studio",
|
|
40
|
+
"i18n",
|
|
41
|
+
"localization",
|
|
42
|
+
"content-management",
|
|
43
|
+
"cms"
|
|
44
|
+
],
|
|
45
|
+
"author": "",
|
|
46
|
+
"license": "MIT",
|
|
47
|
+
"repository": {
|
|
48
|
+
"type": "git",
|
|
49
|
+
"url": ""
|
|
50
|
+
},
|
|
51
|
+
"bugs": {
|
|
52
|
+
"url": ""
|
|
53
|
+
},
|
|
54
|
+
"homepage": "",
|
|
55
|
+
"peerDependencies": {
|
|
56
|
+
"react": "^18.0.0",
|
|
57
|
+
"react-dom": "^18.0.0",
|
|
58
|
+
"sanity": "^3.0.0"
|
|
59
|
+
},
|
|
60
|
+
"devDependencies": {
|
|
61
|
+
"@testing-library/jest-dom": "^6.9.1",
|
|
62
|
+
"@testing-library/react": "^16.3.0",
|
|
63
|
+
"@types/jest": "^29.0.0",
|
|
64
|
+
"@types/react": "^18.0.0",
|
|
65
|
+
"@types/react-dom": "^18.0.0",
|
|
66
|
+
"@typescript-eslint/eslint-plugin": "^6.21.0",
|
|
67
|
+
"@typescript-eslint/parser": "^6.21.0",
|
|
68
|
+
"eslint": "^8.0.0",
|
|
69
|
+
"jest": "^29.0.0",
|
|
70
|
+
"jest-environment-jsdom": "^30.2.0",
|
|
71
|
+
"jsdom": "^27.1.0",
|
|
72
|
+
"rimraf": "^5.0.0",
|
|
73
|
+
"ts-jest": "^29.4.5",
|
|
74
|
+
"ts-loader": "^9.5.4",
|
|
75
|
+
"typescript": "^5.0.0",
|
|
76
|
+
"webpack": "^5.103.0",
|
|
77
|
+
"webpack-cli": "^6.0.1",
|
|
78
|
+
"@easyling/sanity": "^1.0.6"
|
|
79
|
+
}
|
|
80
|
+
}
|