Socket
Socket
Sign inDemoInstall

@uppy/core

Package Overview
Dependencies
Maintainers
0
Versions
139
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@uppy/core - npm Package Compare versions

Comparing version 4.0.0-beta.10 to 4.0.0-beta.11

6

lib/Restricter.js

@@ -103,5 +103,6 @@ /* eslint-disable @typescript-eslint/ban-ts-comment */

if (maxFileSize && file.size != null && file.size > maxFileSize) {
var _file$name;
throw new RestrictionError(this.getI18n()('exceedsSize', {
size: prettierBytes(maxFileSize),
file: file.name
file: (_file$name = file.name) != null ? _file$name : this.getI18n()('unnamed')
}), {

@@ -138,4 +139,5 @@ file

getMissingRequiredMetaFields(file) {
var _file$name2;
const error = new RestrictionError(this.getI18n()('missingRequiredMetaFieldOnFile', {
fileName: file.name
fileName: (_file$name2 = file.name) != null ? _file$name2 : this.getI18n()('unnamed')
}));

@@ -142,0 +144,0 @@ const {

@@ -11,3 +11,2 @@ /// <reference types="lodash" />

import { debugLogger } from './loggers.ts';
import { RestrictionError } from './Restricter.ts';
import type BasePlugin from './BasePlugin.js';

@@ -18,21 +17,74 @@ import type { Restrictions, ValidateableFile } from './Restricter.js';

export type UnknownPlugin<M extends Meta, B extends Body, PluginState extends Record<string, unknown> = Record<string, unknown>> = BasePlugin<any, M, B, PluginState>;
type OmitFirstArg<T> = T extends [any, ...infer U] ? U : never;
/**
* ids are always `string`s, except the root folder's id can be `null`
*/
export type PartialTreeId = string | null;
export type PartialTreeStatusFile = 'checked' | 'unchecked';
export type PartialTreeStatus = PartialTreeStatusFile | 'partial';
export type PartialTreeFile = {
type: 'file';
id: string;
/**
* There exist two types of restrictions:
* - individual restrictions (`allowedFileTypes`, `minFileSize`, `maxFileSize`), and
* - aggregate restrictions (`maxNumberOfFiles`, `maxTotalFileSize`).
*
* `.restrictionError` reports whether this file passes individual restrictions.
*
*/
restrictionError: string | null;
status: PartialTreeStatusFile;
parentId: PartialTreeId;
data: CompanionFile;
};
export type PartialTreeFolderNode = {
type: 'folder';
id: string;
/**
* Consider `(.nextPagePath, .cached)` a composite key that can represent 4 states:
* - `{ cached: true, nextPagePath: null }` - we fetched all pages in this folder
* - `{ cached: true, nextPagePath: 'smth' }` - we fetched 1st page, and there are still pages left to fetch in this folder
* - `{ cached: false, nextPagePath: null }` - we didn't fetch the 1st page in this folder
* - `{ cached: false, nextPagePath: 'someString' }` - ❌ CAN'T HAPPEN ❌
*/
cached: boolean;
nextPagePath: PartialTreeId;
status: PartialTreeStatus;
parentId: PartialTreeId;
data: CompanionFile;
};
export type PartialTreeFolderRoot = {
type: 'root';
id: PartialTreeId;
cached: boolean;
nextPagePath: PartialTreeId;
};
export type PartialTreeFolder = PartialTreeFolderNode | PartialTreeFolderRoot;
/**
* PartialTree has the following structure.
*
* FolderRoot
* ┌─────┴─────┐
* FolderNode File
* ┌─────┴────┐
* File File
*
* Root folder is called `PartialTreeFolderRoot`,
* all other folders are called `PartialTreeFolderNode`, because they are "internal nodes".
*
* It's possible for `PartialTreeFolderNode` to be a leaf node if it doesn't contain any files.
*/
export type PartialTree = (PartialTreeFile | PartialTreeFolder)[];
export type UnknownProviderPluginState = {
authenticated: boolean | undefined;
breadcrumbs: {
requestPath?: string;
name?: string;
id?: string;
}[];
didFirstRender: boolean;
currentSelection: CompanionFile[];
filterInput: string;
searchString: string;
loading: boolean | string;
folders: CompanionFile[];
files: CompanionFile[];
isSearchVisible: boolean;
partialTree: PartialTree;
currentFolderId: PartialTreeId;
username: string | null;
};
export type UnknownProviderPlugin<M extends Meta, B extends Body> = UnknownPlugin<M, B, UnknownProviderPluginState> & {
title: string;
rootFolderId: string | null;
title: string;
files: UppyFile<M, B>[];

@@ -48,5 +100,4 @@ icon: () => h.JSX.Element;

export type UnknownSearchProviderPluginState = {
isInputMode?: boolean;
searchTerm?: string | null;
} & Pick<UnknownProviderPluginState, 'loading' | 'files' | 'folders' | 'currentSelection' | 'filterInput' | 'didFirstRender'>;
isInputMode: boolean;
} & Pick<UnknownProviderPluginState, 'loading' | 'searchString' | 'partialTree' | 'currentFolderId'>;
export type UnknownSearchProviderPlugin<M extends Meta, B extends Body> = UnknownPlugin<M, B, UnknownSearchProviderPluginState> & {

@@ -178,2 +229,4 @@ title: string;

}
/** `OmitFirstArg<typeof someArray>` is the type of the returned value of `someArray.slice(1)`. */
type OmitFirstArg<T> = T extends [any, ...infer U] ? U : never;
/**

@@ -261,3 +314,4 @@ * Uppy Core module.

};
validateRestrictions(file: ValidateableFile<M, B>, files?: ValidateableFile<M, B>[]): RestrictionError<M, B> | null;
validateSingleFile(file: ValidateableFile<M, B>): string | null;
validateAggregateRestrictions(files: ValidateableFile<M, B>[]): string | null;
checkIfFileAlreadyExists(fileID: string): boolean;

@@ -264,0 +318,0 @@ /**

@@ -24,8 +24,25 @@ function _classPrivateFieldLooseBase(e, t) { if (!{}.hasOwnProperty.call(e, t)) throw new TypeError("attempted to use private field on non-instance"); return e; }

const packageJson = {
"version": "4.0.0-beta.10"
"version": "4.0.0-beta.11"
};
import locale from "./locale.js";
// `OmitFirstArg<typeof someArray>` is the type of the returned value of `someArray.slice(1)`.
/**
* ids are always `string`s, except the root folder's id can be `null`
*/
/**
* PartialTree has the following structure.
*
* FolderRoot
* ┌─────┴─────┐
* FolderNode File
* ┌─────┴────┐
* File File
*
* Root folder is called `PartialTreeFolderRoot`,
* all other folders are called `PartialTreeFolderNode`, because they are "internal nodes".
*
* It's possible for `PartialTreeFolderNode` to be a leaf node if it doesn't contain any files.
*/
/*

@@ -56,2 +73,4 @@ * UnknownProviderPlugin can be any Companion plugin (such as Google Drive).

/** `OmitFirstArg<typeof someArray>` is the type of the returned value of `someArray.slice(1)`. */
const defaultUploadState = {

@@ -562,10 +581,16 @@ totalProgress: 0,

}
validateRestrictions(file, files) {
if (files === void 0) {
files = this.getFiles();
validateSingleFile(file) {
try {
_classPrivateFieldLooseBase(this, _restricter)[_restricter].validateSingleFile(file);
} catch (err) {
return err.message;
}
return null;
}
validateAggregateRestrictions(files) {
const existingFiles = this.getFiles();
try {
_classPrivateFieldLooseBase(this, _restricter)[_restricter].validate(files, [file]);
_classPrivateFieldLooseBase(this, _restricter)[_restricter].validateAggregateRestrictions(existingFiles, files);
} catch (err) {
return err;
return err.message;
}

@@ -1349,4 +1374,5 @@ return null;

if (!onBeforeFileAddedResult && this.checkIfFileAlreadyExists(newFile.id)) {
var _newFile$name;
throw new RestrictionError(this.i18n('noDuplicates', {
fileName: newFile.name
fileName: (_newFile$name = newFile.name) != null ? _newFile$name : this.i18n('unnamed')
}), {

@@ -1353,0 +1379,0 @@ file: fileToAdd

{
"name": "@uppy/core",
"description": "Core module for the extensible JavaScript file upload widget with support for drag&drop, resumable uploads, previews, restrictions, file processing/encoding, remote providers like Instagram, Dropbox, Google Drive, S3 and more :dog:",
"version": "4.0.0-beta.10",
"version": "4.0.0-beta.11",
"license": "MIT",

@@ -28,3 +28,3 @@ "main": "lib/index.js",

"@uppy/store-default": "^4.0.0-beta.2",
"@uppy/utils": "^6.0.0-beta.8",
"@uppy/utils": "^6.0.0-beta.9",
"lodash": "^4.17.21",

@@ -31,0 +31,0 @@ "mime-match": "^1.0.2",

@@ -151,3 +151,3 @@ /* eslint-disable @typescript-eslint/ban-ts-comment */

size: prettierBytes(maxFileSize),
file: file.name,
file: file.name ?? this.getI18n()('unnamed'),
}),

@@ -195,3 +195,5 @@ { file } as { file: UppyFile<M, B> },

const error = new RestrictionError<M, B>(
this.getI18n()('missingRequiredMetaFieldOnFile', { fileName: file.name }),
this.getI18n()('missingRequiredMetaFieldOnFile', {
fileName: file.name ?? this.getI18n()('unnamed'),
}),
)

@@ -198,0 +200,0 @@ const { requiredMetaFields } = this.getOpts().restrictions

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc