@shipstatic/types 0.4.23 → 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 +58 -8
- package/dist/index.js +6 -1
- package/package.json +1 -1
- package/src/index.ts +78 -8
package/dist/index.d.ts
CHANGED
|
@@ -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
|
@@ -460,10 +460,15 @@ export const DEFAULT_API = 'https://api.shipstatic.com';
|
|
|
460
460
|
* File status constants for validation state tracking
|
|
461
461
|
*/
|
|
462
462
|
export const FileValidationStatus = {
|
|
463
|
+
/** File is pending validation */
|
|
463
464
|
PENDING: 'pending',
|
|
465
|
+
/** File failed during processing (before validation) */
|
|
464
466
|
PROCESSING_ERROR: 'processing_error',
|
|
465
|
-
|
|
467
|
+
/** File was excluded by validation warning (not an error) */
|
|
468
|
+
EXCLUDED: 'excluded',
|
|
469
|
+
/** File failed validation (blocks deployment) */
|
|
466
470
|
VALIDATION_FAILED: 'validation_failed',
|
|
471
|
+
/** File passed validation and is ready for deployment */
|
|
467
472
|
READY: 'ready',
|
|
468
473
|
};
|
|
469
474
|
// =============================================================================
|
package/package.json
CHANGED
package/src/index.ts
CHANGED
|
@@ -1212,17 +1212,61 @@ export interface ActivityListResponse {
|
|
|
1212
1212
|
* File status constants for validation state tracking
|
|
1213
1213
|
*/
|
|
1214
1214
|
export const FileValidationStatus = {
|
|
1215
|
+
/** File is pending validation */
|
|
1215
1216
|
PENDING: 'pending',
|
|
1217
|
+
/** File failed during processing (before validation) */
|
|
1216
1218
|
PROCESSING_ERROR: 'processing_error',
|
|
1217
|
-
|
|
1219
|
+
/** File was excluded by validation warning (not an error) */
|
|
1220
|
+
EXCLUDED: 'excluded',
|
|
1221
|
+
/** File failed validation (blocks deployment) */
|
|
1218
1222
|
VALIDATION_FAILED: 'validation_failed',
|
|
1223
|
+
/** File passed validation and is ready for deployment */
|
|
1219
1224
|
READY: 'ready',
|
|
1220
1225
|
} as const;
|
|
1221
1226
|
|
|
1222
1227
|
export type FileValidationStatusType = typeof FileValidationStatus[keyof typeof FileValidationStatus];
|
|
1223
1228
|
|
|
1224
1229
|
/**
|
|
1225
|
-
*
|
|
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
|
|
1226
1270
|
*/
|
|
1227
1271
|
export interface ValidationError {
|
|
1228
1272
|
error: string;
|
|
@@ -1243,18 +1287,44 @@ export interface ValidatableFile {
|
|
|
1243
1287
|
}
|
|
1244
1288
|
|
|
1245
1289
|
/**
|
|
1246
|
-
* 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);
|
|
1247
1299
|
*
|
|
1248
|
-
*
|
|
1249
|
-
*
|
|
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
|
+
* ```
|
|
1250
1312
|
*/
|
|
1251
1313
|
export interface FileValidationResult<T extends ValidatableFile> {
|
|
1252
1314
|
/** All files with updated status */
|
|
1253
1315
|
files: T[];
|
|
1254
|
-
|
|
1316
|
+
|
|
1317
|
+
/** Files ready for deployment (status: 'ready') */
|
|
1255
1318
|
validFiles: T[];
|
|
1256
|
-
|
|
1257
|
-
|
|
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;
|
|
1258
1328
|
}
|
|
1259
1329
|
|
|
1260
1330
|
/**
|