@shipstatic/drop 0.2.16 → 0.2.17

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.cts CHANGED
@@ -1,5 +1,5 @@
1
- import { P as ProcessedFile } from './useDrop-CRUVkVzW.cjs';
2
- export { C as ClientError, D as DropOptions, a as DropReturn, b as DropState, c as DropStateValue, d as DropStatus, e as DropzonePropsOptions, F as FILE_STATUSES, f as FileStatus, g as FileWithPath, u as useDrop } from './useDrop-CRUVkVzW.cjs';
1
+ import { P as ProcessedFile } from './useDrop-DbGbhh56.cjs';
2
+ export { C as ClientError, D as DropOptions, a as DropReturn, b as DropState, c as DropStateValue, d as DropStatus, e as DropzonePropsOptions, F as FILE_STATUSES, f as FileStatus, g as FileWithPath, u as useDrop } from './useDrop-DbGbhh56.cjs';
3
3
  import { formatFileSize as formatFileSize$1 } from '@shipstatic/ship';
4
4
  import '@shipstatic/types';
5
5
 
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { P as ProcessedFile } from './useDrop-CRUVkVzW.js';
2
- export { C as ClientError, D as DropOptions, a as DropReturn, b as DropState, c as DropStateValue, d as DropStatus, e as DropzonePropsOptions, F as FILE_STATUSES, f as FileStatus, g as FileWithPath, u as useDrop } from './useDrop-CRUVkVzW.js';
1
+ import { P as ProcessedFile } from './useDrop-DbGbhh56.js';
2
+ export { C as ClientError, D as DropOptions, a as DropReturn, b as DropState, c as DropStateValue, d as DropStatus, e as DropzonePropsOptions, F as FILE_STATUSES, f as FileStatus, g as FileWithPath, u as useDrop } from './useDrop-DbGbhh56.js';
3
3
  import { formatFileSize as formatFileSize$1 } from '@shipstatic/ship';
4
4
  import '@shipstatic/types';
5
5
 
package/dist/index.js CHANGED
@@ -11700,7 +11700,7 @@ var require_mime_db = __commonJS({
11700
11700
  }
11701
11701
  });
11702
11702
 
11703
- // node_modules/.pnpm/@shipstatic+types@0.4.23/node_modules/@shipstatic/types/dist/index.js
11703
+ // node_modules/.pnpm/@shipstatic+types@0.4.25/node_modules/@shipstatic/types/dist/index.js
11704
11704
  var ErrorType;
11705
11705
  (function(ErrorType2) {
11706
11706
  ErrorType2["Validation"] = "validation_failed";
@@ -11720,10 +11720,15 @@ var ErrorType;
11720
11720
  auth: /* @__PURE__ */ new Set([ErrorType.Authentication])
11721
11721
  });
11722
11722
  var FileValidationStatus = {
11723
+ /** File is pending validation */
11723
11724
  PENDING: "pending",
11725
+ /** File failed during processing (before validation) */
11724
11726
  PROCESSING_ERROR: "processing_error",
11725
- EMPTY_FILE: "empty_file",
11727
+ /** File was excluded by validation warning (not an error) */
11728
+ EXCLUDED: "excluded",
11729
+ /** File failed validation (blocks deployment) */
11726
11730
  VALIDATION_FAILED: "validation_failed",
11731
+ /** File passed validation and is ready for deployment */
11727
11732
  READY: "ready"
11728
11733
  };
11729
11734
 
@@ -12017,40 +12022,72 @@ function useDrop(options) {
12017
12022
  status: validation.files[idx]?.status || processedFile.status,
12018
12023
  statusMessage: validation.files[idx]?.statusMessage || processedFile.statusMessage
12019
12024
  }));
12020
- if (validation.error) {
12025
+ if (!validation.canDeploy) {
12026
+ const errorMessages = validation.errors.map(
12027
+ (err) => `${err.file}: ${err.message}`
12028
+ );
12021
12029
  setState({
12022
12030
  value: "error",
12023
12031
  files: filesWithStatus,
12024
12032
  sourceName: detectedSourceName,
12025
12033
  status: {
12026
- title: validation.error.error,
12027
- details: validation.error.details,
12028
- errors: validation.error.errors
12034
+ title: "Validation Failed",
12035
+ details: `${validation.errors.length} file(s) failed validation`,
12036
+ errors: errorMessages
12029
12037
  }
12030
12038
  });
12031
- onValidationError?.(validation.error);
12039
+ onValidationError?.({
12040
+ error: "Validation Failed",
12041
+ details: `${validation.errors.length} error(s)`,
12042
+ errors: errorMessages,
12043
+ isClientError: true
12044
+ });
12032
12045
  } else if (validation.validFiles.length > 0) {
12046
+ let details = `${validation.validFiles.length} file(s) ready`;
12047
+ if (validation.warnings.length > 0) {
12048
+ details += ` (${validation.warnings.length} empty file(s) excluded)`;
12049
+ }
12033
12050
  setState({
12034
12051
  value: "ready",
12035
12052
  files: filesWithStatus,
12036
12053
  sourceName: detectedSourceName,
12037
- status: { title: "Ready", details: `${validation.validFiles.length} file(s) are ready.` }
12054
+ status: {
12055
+ title: "Ready",
12056
+ details,
12057
+ warnings: validation.warnings.length > 0 ? validation.warnings.map((w) => `${w.file}: ${w.message}`) : void 0
12058
+ }
12038
12059
  });
12039
- onFilesReady?.(filesWithStatus.filter((f, idx) => validation.files[idx]?.status === "ready"));
12060
+ onFilesReady?.(filesWithStatus.filter(
12061
+ (f, idx) => validation.files[idx]?.status === "ready"
12062
+ ));
12040
12063
  } else {
12041
- const noValidError = {
12042
- error: "No Valid Files",
12043
- details: "None of the provided files could be processed.",
12044
- errors: [],
12045
- isClientError: true
12046
- };
12047
- setState({
12048
- value: "error",
12049
- files: filesWithStatus,
12050
- sourceName: detectedSourceName,
12051
- status: { title: noValidError.error, details: noValidError.details }
12052
- });
12053
- onValidationError?.(noValidError);
12064
+ const hasOnlyWarnings = validation.errors.length === 0 && validation.warnings.length > 0;
12065
+ if (hasOnlyWarnings) {
12066
+ setState({
12067
+ value: "ready",
12068
+ files: filesWithStatus,
12069
+ sourceName: detectedSourceName,
12070
+ status: {
12071
+ title: "All files excluded",
12072
+ details: `${validation.warnings.length} file(s) excluded (empty files cannot be deployed)`,
12073
+ warnings: validation.warnings.map((w) => `${w.file}: ${w.message}`)
12074
+ }
12075
+ });
12076
+ } else {
12077
+ const noValidError = {
12078
+ error: "No Valid Files",
12079
+ details: "None of the provided files could be processed.",
12080
+ errors: [],
12081
+ isClientError: true
12082
+ };
12083
+ setState({
12084
+ value: "error",
12085
+ files: filesWithStatus,
12086
+ sourceName: detectedSourceName,
12087
+ status: { title: noValidError.error, details: noValidError.details }
12088
+ });
12089
+ onValidationError?.(noValidError);
12090
+ }
12054
12091
  }
12055
12092
  } catch (error) {
12056
12093
  const processingError = {
@@ -12092,7 +12129,6 @@ function useDrop(options) {
12092
12129
  const errorStatuses = [
12093
12130
  FILE_STATUSES.VALIDATION_FAILED,
12094
12131
  FILE_STATUSES.PROCESSING_ERROR,
12095
- FILE_STATUSES.EMPTY_FILE,
12096
12132
  FILE_STATUSES.ERROR
12097
12133
  ];
12098
12134
  const hasErrors = prev.files.some((f) => errorStatuses.includes(f.status));