@shipstatic/types 0.4.22 → 0.4.24
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/dist/index.d.ts +59 -9
- package/dist/index.js +8 -2
- package/package.json +1 -1
- package/src/index.ts +80 -9
package/dist/index.d.ts
CHANGED
|
@@ -417,7 +417,7 @@ export interface ConfigResponse {
|
|
|
417
417
|
* - Explicit allowlist (only approved formats, reject unknown)
|
|
418
418
|
* ============================================================================
|
|
419
419
|
*/
|
|
420
|
-
export declare const ALLOWED_MIME_TYPES: readonly ["text/html", "text/css", "text/plain", "text/markdown", "text/xml", "text/csv", "text/yaml", "text/vtt", "text/calendar", "text/javascript", "text/typescript", "text/tsx", "text/jsx", "text/x-scss", "text/x-sass", "text/x-less", "text/stylus", "text/x-vue", "text/x-svelte", "image/", "audio/", "video/", "font/", "application/javascript", "application/ecmascript", "application/x-javascript", "application/wasm", "application/json", "application/ld+json", "application/manifest+json", "application/source-map", "application/xml", "application/xhtml+xml", "application/rss+xml", "application/atom+xml", "application/yaml", "application/toml", "application/pdf", "model/gltf+json", "model/gltf-binary", "application/mp4", "application/font-woff", "application/font-woff2", "application/x-font-woff", "application/x-woff", "application/vnd.ms-fontobject", "application/x-font-ttf", "application/x-font-truetype", "application/x-font-otf", "application/x-font-opentype"];
|
|
420
|
+
export declare const ALLOWED_MIME_TYPES: readonly ["text/html", "text/css", "text/plain", "text/markdown", "text/xml", "text/csv", "text/yaml", "text/vtt", "text/calendar", "text/javascript", "text/typescript", "text/tsx", "text/jsx", "text/x-scss", "text/x-sass", "text/less", "text/x-less", "text/stylus", "text/x-vue", "text/x-svelte", "image/", "audio/", "video/", "font/", "application/javascript", "application/ecmascript", "application/x-javascript", "application/wasm", "application/json", "application/ld+json", "application/manifest+json", "application/source-map", "application/xml", "application/xhtml+xml", "application/rss+xml", "application/atom+xml", "application/yaml", "application/toml", "application/pdf", "model/gltf+json", "model/gltf-binary", "application/mp4", "application/font-woff", "application/font-woff2", "application/x-font-woff", "application/x-woff", "application/vnd.ms-fontobject", "application/x-font-ttf", "application/x-font-truetype", "application/x-font-otf", "application/x-font-opentype"];
|
|
421
421
|
/**
|
|
422
422
|
* Check if a MIME type is allowed for upload.
|
|
423
423
|
*
|
|
@@ -759,15 +759,43 @@ export interface ActivityListResponse {
|
|
|
759
759
|
* File status constants for validation state tracking
|
|
760
760
|
*/
|
|
761
761
|
export declare const FileValidationStatus: {
|
|
762
|
+
/** File is pending validation */
|
|
762
763
|
readonly PENDING: "pending";
|
|
764
|
+
/** File failed during processing (before validation) */
|
|
763
765
|
readonly PROCESSING_ERROR: "processing_error";
|
|
764
|
-
|
|
766
|
+
/** File was excluded by validation warning (not an error) */
|
|
767
|
+
readonly EXCLUDED: "excluded";
|
|
768
|
+
/** File failed validation (blocks deployment) */
|
|
765
769
|
readonly VALIDATION_FAILED: "validation_failed";
|
|
770
|
+
/** File passed validation and is ready for deployment */
|
|
766
771
|
readonly READY: "ready";
|
|
767
772
|
};
|
|
768
773
|
export type FileValidationStatusType = typeof FileValidationStatus[keyof typeof FileValidationStatus];
|
|
769
774
|
/**
|
|
770
|
-
*
|
|
775
|
+
* Types of validation issues that can occur during file validation
|
|
776
|
+
*/
|
|
777
|
+
export type ValidationIssueType = 'empty_file' | 'file_too_large' | 'total_size_exceeded' | 'invalid_mime_type' | 'invalid_filename' | 'mime_extension_mismatch' | 'file_count_exceeded' | 'processing_error';
|
|
778
|
+
/**
|
|
779
|
+
* A validation issue with severity level
|
|
780
|
+
*
|
|
781
|
+
* Issues are categorized by severity:
|
|
782
|
+
* - **error**: Blocks deployment, user must fix
|
|
783
|
+
* - **warning**: Excludes file but allows deployment to proceed
|
|
784
|
+
*/
|
|
785
|
+
export interface ValidationIssue {
|
|
786
|
+
/** File path that triggered this issue */
|
|
787
|
+
file: string;
|
|
788
|
+
/** Severity level determines deployment behavior */
|
|
789
|
+
severity: 'error' | 'warning';
|
|
790
|
+
/** Issue type for programmatic handling */
|
|
791
|
+
type: ValidationIssueType;
|
|
792
|
+
/** Human-readable message explaining the issue */
|
|
793
|
+
message: string;
|
|
794
|
+
}
|
|
795
|
+
/**
|
|
796
|
+
* Legacy validation error structure
|
|
797
|
+
*
|
|
798
|
+
* @deprecated Use ValidationIssue[] from FileValidationResult instead
|
|
771
799
|
*/
|
|
772
800
|
export interface ValidationError {
|
|
773
801
|
error: string;
|
|
@@ -786,18 +814,40 @@ export interface ValidatableFile {
|
|
|
786
814
|
statusMessage?: string;
|
|
787
815
|
}
|
|
788
816
|
/**
|
|
789
|
-
* File validation result
|
|
817
|
+
* File validation result with severity-based issue reporting
|
|
818
|
+
*
|
|
819
|
+
* Validation checks files against constraints and categorizes issues by severity:
|
|
820
|
+
* - **Errors**: Block deployment (file too large, invalid type, etc.)
|
|
821
|
+
* - **Warnings**: Exclude files but allow deployment (empty files, etc.)
|
|
790
822
|
*
|
|
791
|
-
*
|
|
792
|
-
*
|
|
823
|
+
* @example
|
|
824
|
+
* ```typescript
|
|
825
|
+
* const result = validateFiles(files, config);
|
|
826
|
+
*
|
|
827
|
+
* if (!result.canDeploy) {
|
|
828
|
+
* // Has errors - must fix before deploying
|
|
829
|
+
* console.error('Deployment blocked:', result.errors);
|
|
830
|
+
* } else if (result.warnings.length > 0) {
|
|
831
|
+
* // Has warnings - deployment proceeds, some files excluded
|
|
832
|
+
* console.warn('Files excluded:', result.warnings);
|
|
833
|
+
* deploy(result.validFiles);
|
|
834
|
+
* } else {
|
|
835
|
+
* // All files valid
|
|
836
|
+
* deploy(result.validFiles);
|
|
837
|
+
* }
|
|
838
|
+
* ```
|
|
793
839
|
*/
|
|
794
840
|
export interface FileValidationResult<T extends ValidatableFile> {
|
|
795
841
|
/** All files with updated status */
|
|
796
842
|
files: T[];
|
|
797
|
-
/** Files
|
|
843
|
+
/** Files ready for deployment (status: 'ready') */
|
|
798
844
|
validFiles: T[];
|
|
799
|
-
/**
|
|
800
|
-
|
|
845
|
+
/** Blocking errors that prevent deployment */
|
|
846
|
+
errors: ValidationIssue[];
|
|
847
|
+
/** Non-blocking warnings (files excluded but deployment allowed) */
|
|
848
|
+
warnings: ValidationIssue[];
|
|
849
|
+
/** Whether deployment can proceed (true if errors.length === 0) */
|
|
850
|
+
canDeploy: boolean;
|
|
801
851
|
}
|
|
802
852
|
/**
|
|
803
853
|
* Represents a file that has been uploaded and stored
|
package/dist/index.js
CHANGED
|
@@ -289,7 +289,8 @@ export const ALLOWED_MIME_TYPES = [
|
|
|
289
289
|
'text/jsx', // React JSX (.jsx)
|
|
290
290
|
'text/x-scss', // SCSS preprocessor
|
|
291
291
|
'text/x-sass', // Sass preprocessor
|
|
292
|
-
'text/
|
|
292
|
+
'text/less', // Less preprocessor
|
|
293
|
+
'text/x-less', // Less preprocessor (alternative)
|
|
293
294
|
'text/stylus', // Stylus preprocessor
|
|
294
295
|
'text/x-vue', // Vue single-file components (.vue)
|
|
295
296
|
'text/x-svelte', // Svelte components (.svelte)
|
|
@@ -459,10 +460,15 @@ export const DEFAULT_API = 'https://api.shipstatic.com';
|
|
|
459
460
|
* File status constants for validation state tracking
|
|
460
461
|
*/
|
|
461
462
|
export const FileValidationStatus = {
|
|
463
|
+
/** File is pending validation */
|
|
462
464
|
PENDING: 'pending',
|
|
465
|
+
/** File failed during processing (before validation) */
|
|
463
466
|
PROCESSING_ERROR: 'processing_error',
|
|
464
|
-
|
|
467
|
+
/** File was excluded by validation warning (not an error) */
|
|
468
|
+
EXCLUDED: 'excluded',
|
|
469
|
+
/** File failed validation (blocks deployment) */
|
|
465
470
|
VALIDATION_FAILED: 'validation_failed',
|
|
471
|
+
/** File passed validation and is ready for deployment */
|
|
466
472
|
READY: 'ready',
|
|
467
473
|
};
|
|
468
474
|
// =============================================================================
|
package/package.json
CHANGED
package/src/index.ts
CHANGED
|
@@ -600,7 +600,8 @@ export const ALLOWED_MIME_TYPES = [
|
|
|
600
600
|
'text/jsx', // React JSX (.jsx)
|
|
601
601
|
'text/x-scss', // SCSS preprocessor
|
|
602
602
|
'text/x-sass', // Sass preprocessor
|
|
603
|
-
'text/
|
|
603
|
+
'text/less', // Less preprocessor
|
|
604
|
+
'text/x-less', // Less preprocessor (alternative)
|
|
604
605
|
'text/stylus', // Stylus preprocessor
|
|
605
606
|
'text/x-vue', // Vue single-file components (.vue)
|
|
606
607
|
'text/x-svelte', // Svelte components (.svelte)
|
|
@@ -1211,17 +1212,61 @@ export interface ActivityListResponse {
|
|
|
1211
1212
|
* File status constants for validation state tracking
|
|
1212
1213
|
*/
|
|
1213
1214
|
export const FileValidationStatus = {
|
|
1215
|
+
/** File is pending validation */
|
|
1214
1216
|
PENDING: 'pending',
|
|
1217
|
+
/** File failed during processing (before validation) */
|
|
1215
1218
|
PROCESSING_ERROR: 'processing_error',
|
|
1216
|
-
|
|
1219
|
+
/** File was excluded by validation warning (not an error) */
|
|
1220
|
+
EXCLUDED: 'excluded',
|
|
1221
|
+
/** File failed validation (blocks deployment) */
|
|
1217
1222
|
VALIDATION_FAILED: 'validation_failed',
|
|
1223
|
+
/** File passed validation and is ready for deployment */
|
|
1218
1224
|
READY: 'ready',
|
|
1219
1225
|
} as const;
|
|
1220
1226
|
|
|
1221
1227
|
export type FileValidationStatusType = typeof FileValidationStatus[keyof typeof FileValidationStatus];
|
|
1222
1228
|
|
|
1223
1229
|
/**
|
|
1224
|
-
*
|
|
1230
|
+
* Types of validation issues that can occur during file validation
|
|
1231
|
+
*/
|
|
1232
|
+
export type ValidationIssueType =
|
|
1233
|
+
// Warnings (exclude file but don't block deployment)
|
|
1234
|
+
| 'empty_file'
|
|
1235
|
+
|
|
1236
|
+
// Errors (block deployment)
|
|
1237
|
+
| 'file_too_large'
|
|
1238
|
+
| 'total_size_exceeded'
|
|
1239
|
+
| 'invalid_mime_type'
|
|
1240
|
+
| 'invalid_filename'
|
|
1241
|
+
| 'mime_extension_mismatch'
|
|
1242
|
+
| 'file_count_exceeded'
|
|
1243
|
+
| 'processing_error';
|
|
1244
|
+
|
|
1245
|
+
/**
|
|
1246
|
+
* A validation issue with severity level
|
|
1247
|
+
*
|
|
1248
|
+
* Issues are categorized by severity:
|
|
1249
|
+
* - **error**: Blocks deployment, user must fix
|
|
1250
|
+
* - **warning**: Excludes file but allows deployment to proceed
|
|
1251
|
+
*/
|
|
1252
|
+
export interface ValidationIssue {
|
|
1253
|
+
/** File path that triggered this issue */
|
|
1254
|
+
file: string;
|
|
1255
|
+
|
|
1256
|
+
/** Severity level determines deployment behavior */
|
|
1257
|
+
severity: 'error' | 'warning';
|
|
1258
|
+
|
|
1259
|
+
/** Issue type for programmatic handling */
|
|
1260
|
+
type: ValidationIssueType;
|
|
1261
|
+
|
|
1262
|
+
/** Human-readable message explaining the issue */
|
|
1263
|
+
message: string;
|
|
1264
|
+
}
|
|
1265
|
+
|
|
1266
|
+
/**
|
|
1267
|
+
* Legacy validation error structure
|
|
1268
|
+
*
|
|
1269
|
+
* @deprecated Use ValidationIssue[] from FileValidationResult instead
|
|
1225
1270
|
*/
|
|
1226
1271
|
export interface ValidationError {
|
|
1227
1272
|
error: string;
|
|
@@ -1242,18 +1287,44 @@ export interface ValidatableFile {
|
|
|
1242
1287
|
}
|
|
1243
1288
|
|
|
1244
1289
|
/**
|
|
1245
|
-
* File validation result
|
|
1290
|
+
* File validation result with severity-based issue reporting
|
|
1291
|
+
*
|
|
1292
|
+
* Validation checks files against constraints and categorizes issues by severity:
|
|
1293
|
+
* - **Errors**: Block deployment (file too large, invalid type, etc.)
|
|
1294
|
+
* - **Warnings**: Exclude files but allow deployment (empty files, etc.)
|
|
1295
|
+
*
|
|
1296
|
+
* @example
|
|
1297
|
+
* ```typescript
|
|
1298
|
+
* const result = validateFiles(files, config);
|
|
1246
1299
|
*
|
|
1247
|
-
*
|
|
1248
|
-
*
|
|
1300
|
+
* if (!result.canDeploy) {
|
|
1301
|
+
* // Has errors - must fix before deploying
|
|
1302
|
+
* console.error('Deployment blocked:', result.errors);
|
|
1303
|
+
* } else if (result.warnings.length > 0) {
|
|
1304
|
+
* // Has warnings - deployment proceeds, some files excluded
|
|
1305
|
+
* console.warn('Files excluded:', result.warnings);
|
|
1306
|
+
* deploy(result.validFiles);
|
|
1307
|
+
* } else {
|
|
1308
|
+
* // All files valid
|
|
1309
|
+
* deploy(result.validFiles);
|
|
1310
|
+
* }
|
|
1311
|
+
* ```
|
|
1249
1312
|
*/
|
|
1250
1313
|
export interface FileValidationResult<T extends ValidatableFile> {
|
|
1251
1314
|
/** All files with updated status */
|
|
1252
1315
|
files: T[];
|
|
1253
|
-
|
|
1316
|
+
|
|
1317
|
+
/** Files ready for deployment (status: 'ready') */
|
|
1254
1318
|
validFiles: T[];
|
|
1255
|
-
|
|
1256
|
-
|
|
1319
|
+
|
|
1320
|
+
/** Blocking errors that prevent deployment */
|
|
1321
|
+
errors: ValidationIssue[];
|
|
1322
|
+
|
|
1323
|
+
/** Non-blocking warnings (files excluded but deployment allowed) */
|
|
1324
|
+
warnings: ValidationIssue[];
|
|
1325
|
+
|
|
1326
|
+
/** Whether deployment can proceed (true if errors.length === 0) */
|
|
1327
|
+
canDeploy: boolean;
|
|
1257
1328
|
}
|
|
1258
1329
|
|
|
1259
1330
|
/**
|