-
Notifications
You must be signed in to change notification settings - Fork 81
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor(uploads) Move to new upload system with application/json pay…
…loads * test(jest): move intagration tests to other repo and add unit test with jest * refactor(request): move superagent to axios * refactor(tests): add more unit tests * test(network): Add tests to uplaod start * test(network): Add unit tests for complete method * test(store): update store test for cancel method * fix(cloud): Add cancel method to clouds using token * fix(resolveHostFix): Fix iteration object in resolveHost * refactor(uploads): refactor uploads, update build script * refactor(upload/fallbac): Add multipart true when fallback is enabled * refactor(uploads): Update progress method * refactor(upload): Cleanup upload class * refactor(uploads): Fix fallback mode for files below 5mb * refactor(uploads): Add better cleanup after upload * refactor(uploads): Do not store chunks in memory * refactor(uploads): lower p-queue version, fix file library get slice method * refactor(fix intelligent size header): * refactor(uploads): cleanup * test(file_utils): add file utils test, split test to envs * fix(api/file): Fix params in file reuqests * test(uploads): Add tests to main upload class * test(uploaders/s3): add basic tests * test(uploader/s3): Add tests to uplaoders/s3 class (wip) * test(Uploaders/s3): Refactor tests, Add ii tests * test(uploader/s3): Add more units * test(uploader/s3): Fix store/workflows option * test(request): add request units, update request to support application/json format instead of multi * test(uploads): Add missing units, replace error with FilestackError * refactor(pickeropiotns): remove preferlinkoverstorage option * refactor(cloudClient): remove link option * build(codecov): add code cov to repo * docs(README): Add codecov badge to readme * docs(README): Update readme file * refactor(uploads): Move uploads to new backend * feat(SRI): Add sri manifest.json and update README * docs(README): Update readme -> sri description * refactor(uploads): change multipart to ffi param * ci(codeconv): add codeconv config to repo * refactor(trace-id): comment for now * fix(uploads/fii): send fii field in upload * test(upload/fii): Update tests with fii support * refactor(uploads, validation): update uploads response, move security and storeOptions to json schem * refactor(validation): replace tcomb params validation with jsonschema * refactor(tcomb-validation): remove tcomb-validation and replace it with json schema * refactor(uploads/validation): add validation to uploads and tests for it * fix(uploadSchema): add missing filename * fix(pickerSchema): add filename to picker schema * test(pickerSchema): add tests to picker schema * fix(sanitizer): fix sanitizer "\" in regexp * test(utils): remove only keyword * test(all): Update tests for filelink, uploader/s3 * fix(uploader/s3): do not change oryginal store options/ copy it befre removing filenmae * docs(cleanup): cleanup docs in new files * refactor(upload/s3): change copy function to obj.assign * refactor(validator): Update html element validator * test(FilestackError): add tests for filestack error * refactor(uploads): move store options under store param * refactor(utils): update base64 function to work in both envs * refactor(pr): fixes from pr * test(security): add tests for security * refactor(upload): change name from get/set host to url * feat(filestack/debug): add debug for filestack headers * fix(file_tools): Fix isSvg in browser * refactor(cleanup): cleanup methods, change codeconv percent * docs(releases): Add detailed releases description * docs(README.md): add information about releases * docs(releases_notes): fix typo, move examples to correct pleace * test(cleanup): remove only from tests * fix(sanitizeOptions): pass sanitize options to uploader * docs(release-notes): refactor sanitize section * docs(release-notes): add line break * test(sanitizer): add tests to sanitizer * fix(schema): move sanitizer to correct schema * refactor(schema): remove sanitizer from upload schema * test(upload): add sanitizer check * refactor(ie): Fix require in ie * test(utils): add tests to requireNode * refactor(utils): add one more safety condition to requireNode * fix(memoryleak): Fix memory leak in cancel token (axios) * fix(uploader/s3): move cleaning cancelToken to last promise * refactor(upload/s3): Standarize errors * feat(eventemmiter): add event emmiter with error to upload stack * feat(FilestackError): Add error types * test(cloud): refactor cloud units * refactor(upload/s3): change complete method call * refactor(upload/s3): revert complete request after each file * refactor(types): remove retry event * feat(picker): add imageMinMaxBlock option * feat(picker): add force param to picker transformations * refactor(filelink): add "," to escape chars in filelink * feat(picker): Add viewType option to schema, update picker types * test(cloud): fix wrong promise * docs(release-notes): Add info about escaping , in storeUrl * docs(release-notes): Update release notes - add picker fixed issues * docs(readme): update readme polyfils seciton * feat(picker): bump picker version
- Loading branch information
Showing
113 changed files
with
15,220 additions
and
13,289 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
codecov: | ||
notify: | ||
require_ci_to_pass: yes | ||
|
||
coverage: | ||
precision: 2 | ||
round: down | ||
range: "99...100" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,8 +6,9 @@ coverage | |
*.log | ||
.env | ||
.nyc_output | ||
.stats.json | ||
.DS_Store | ||
|
||
# VS Code | ||
.vscode | ||
!.vscode/tasks.js | ||
!.vscode/tasks.js |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,6 +5,8 @@ tsconfig.json | |
tslint.json | ||
.travis.yml | ||
.github | ||
.codecov.yml | ||
.stats.json | ||
build/temp | ||
build/docs | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
{ | ||
"trailingComma": "all", | ||
"tabWidth": 2, | ||
"semi": true, | ||
"singleQuote": true, | ||
"printWidth" : 180, | ||
"parser": "typescript", | ||
"useTabs": false, | ||
"bracketSpacing": true, | ||
"arrowParens": "avoid" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,15 @@ | ||
/* | ||
* Copyright (c) ${year} by Filestack. | ||
* Some rights reserved. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
* | ||
*/ | ||
Copyright (c) ${year} by Filestack. | ||
Some rights reserved. | ||
|
||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
|
||
http://www.apache.org/licenses/LICENSE-2.0 | ||
|
||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,71 +4,129 @@ | |
<p align="center"> | ||
<strong>Javascript SDK for the Filestack API and content management system.</strong> | ||
</p> | ||
<p align="center"> | ||
<a href="https://codecov.io/gh/filestack/filestack-js"> | ||
<img src="https://codecov.io/gh/filestack/filestack-js/branch/master/graph/badge.svg" /> | ||
</a> | ||
|
||
<a href="https://travis-ci.org/filestack/filestack-js"> | ||
<img src="https://travis-ci.org/filestack/filestack-js.svg?branch=master" /> | ||
</a> | ||
</p> | ||
<p align="center"> | ||
<a href="https://npmjs.com/package/filestack-js"><img src="https://img.shields.io/npm/v/filestack-js.svg" /></a> | ||
<a href="https://static.filestackapi.com/filestack-js/2.x.x/filestack.min.js"><img src="https://img.badgesize.io/https://static.filestackapi.com/filestack-js/2.x.x/filestack.min.js?compression=gzip&color=green" /></a> | ||
<a href="https://static.filestackapi.com/filestack-js/2.x.x/filestack.min.js"><img src="https://img.badgesize.io/https://static.filestackapi.com/filestack-js/2.x.x/filestack.min.js?color=green" /></a> | ||
<a href="https://static.filestackapi.com/filestack-js/3.x.x/filestack.min.js"><img src="https://img.badgesize.io/https://static.filestackapi.com/filestack-js/3.x.x/filestack.min.js?compression=gzip&color=green" /></a> | ||
<a href="https://static.filestackapi.com/filestack-js/3.x.x/filestack.min.js"><img src="https://img.badgesize.io/https://static.filestackapi.com/filestack-js/3.x.x/filestack.min.js?color=green" /></a> | ||
<img src="https://img.shields.io/badge/module%20formats-umd%2C%20esm%2C%20cjs-green.svg" /> | ||
<br/> | ||
<img src="https://badges.herokuapp.com/browsers?labels=none&googlechrome=latest&firefox=latestµsoftedge=latest&iexplore=11&safari=latest&iphone=latest" /> | ||
</p> | ||
<hr/> | ||
|
||
**Table of Contents** | ||
|
||
<!-- toc --> | ||
- [What's in the box?](#whats-in-the-box) | ||
- [Installation](#installation) | ||
- [API Documentation](#api-documentation) | ||
- [Usage](#usage) | ||
- [Browsers](#browsers) | ||
- [ES module](#es-module) | ||
- [UMD module](#umd-module) | ||
- [GZIP support](#gzip-support) | ||
- [SRI](#sri) | ||
- [Node](#node) | ||
- [CommonJS module](#commonjs-module) | ||
- [Module Overview](#module-overview) | ||
- [Releases Info](#releases-info) | ||
- [Live examples (JSFiddle)](#live-examples-jsfiddle) | ||
- [Picker Quick Start](#picker-quick-start) | ||
- [Promises](#promises) | ||
- [Development](#development) | ||
- [Debugging](#debugging) | ||
- [Node](#node-1) | ||
- [Browser](#browser) | ||
- [Versioning](#versioning) | ||
- [Contributing](#contributing) | ||
|
||
|
||
## What's in the box? | ||
|
||
* A multi-part uploader powered on the backend by the [Filestack CIN](https://www.filestack.com/products/content-ingestion-network). | ||
* An interface to the [Filestack Processing Engine](https://www.filestack.com/docs/image-transformations) for transforming assets via URLs. | ||
* The Filestack Picker - an upload widget for the web that integrates over a dozen cloud providers and provides pre-upload image editing. | ||
|
||
|
||
## Installation | ||
|
||
```sh | ||
npm install filestack-js | ||
``` | ||
|
||
## API Documentation | ||
|
||
[https://filestack.github.io/filestack-js/](https://filestack.github.io/filestack-js/) | ||
|
||
## Usage | ||
|
||
### Browsers | ||
|
||
**ES module**: | ||
#### ES module | ||
```js | ||
import * as filestack from 'filestack-js'; | ||
const client = filestack.init('apikey'); | ||
``` | ||
|
||
**UMD module**: | ||
#### UMD module | ||
```HTML | ||
<script src="//static.filestackapi.com/filestack-js/{MAJOR_VERSION}.x.x/filestack.min.js"></script> | ||
<script src="//static.filestackapi.com/filestack-js/{MAJOR_VERSION}.x.x/filestack.min.js" crossorigin="anonymous"></script> | ||
<script> | ||
const client = filestack.init('apikey'); | ||
</script> | ||
``` | ||
|
||
where VERSION is one of the MAJOR versions of the filestack-js ie: | ||
where ```{MAJOR_VERSION}``` is one of the MAJOR versions of the filestack-js ie: | ||
```HTML | ||
<script src="//static.filestackapi.com/filestack-js/2.x.x/filestack.min.js"></script> | ||
<script src="//static.filestackapi.com/filestack-js/3.x.x/filestack.min.js" crossorigin="anonymous"></script> | ||
<script> | ||
const client = filestack.init('apikey'); | ||
</script> | ||
``` | ||
|
||
**GZIP support** | ||
#### GZIP support | ||
To speed up library loading you can use gzipped file available after adding gz to file extension | ||
```HTML | ||
To speed up library loading you can use gzipped file available after adding gz before the file extension | ||
|
||
<script src="//static.filestackapi.com/filestack-js/{MAJOR_VERSION}.x.x/filestack.min.gz.js"></script> | ||
<script src="//static.filestackapi.com/filestack-js/{MAJOR_VERSION}.x.x/filestack.min.js.gz" crossorigin="anonymous"></script> | ||
<script> | ||
const client = filestack.init('apikey'); | ||
</script> | ||
``` | ||
|
||
#### SRI | ||
Subresource Integrity (SRI) is a security feature that enables browsers to verify that files they fetch (for example, from a CDN) are delivered without unexpected manipulation. It works by allowing you to provide a cryptographic hash that a fetched file must match | ||
|
||
To obtain sri hashes for filestack-js library check manifest.json file on CDN: | ||
|
||
``` | ||
https://static.filestackapi.com/filestack-js/{LIBRARY_VERSION}/manifest.json | ||
``` | ||
|
||
```HTML | ||
<script src="//static.filestackapi.com/filestack-js/{LIBRARY_VERSION}/filestack.min.js.gz" integrity="{FILE_HASH}" crossorigin="anonymous"></script> | ||
``` | ||
|
||
Where ```{LIBRARY_VERSION}``` is currently used library version and ```{FILE_HASH}``` is one of the hashes from integrity field in manifest.json file | ||
|
||
|
||
### Node | ||
|
||
**CommonJS module**: | ||
#### CommonJS module | ||
```js | ||
const client = require('filestack-js').init('apikey'); | ||
``` | ||
|
||
### Module Overview | ||
|
||
## Module Overview | ||
|
||
The `package.json` specifies two separate modules: | ||
|
||
|
@@ -79,8 +137,13 @@ Node projects which depend on filestack-js will follow the `main` field in `pack | |
|
||
The pre-bundled browser module is also available in UMD format. This is useful if you are using script tags on a web page instead of bundling your application. It can be retrieved from both the Filestack CDN and the unpkg CDN: | ||
|
||
* [Filestack CDN](https://static.filestackapi.com/filestack-js/1.x.x/filestack.min.js) | ||
* [unpkg](https://unpkg.com/[email protected]) | ||
* [Filestack CDN](https://static.filestackapi.com/filestack-js/3.x.x/filestack.min.js) | ||
* [unpkg](https://unpkg.com/[email protected]) | ||
|
||
## Releases Info | ||
|
||
Major releases will bo listed (with detailed examples) in releases folder starting from version 3.0.0 | ||
|
||
|
||
## Live examples (JSFiddle) | ||
|
||
|
@@ -114,58 +177,52 @@ The picker instance returned from `client.picker` can be controlled with a few m | |
|
||
Please see our examples above to learn more about customizing the picker for your use case. | ||
|
||
## API Documentation | ||
|
||
[https://filestack.github.io/filestack-js/](https://filestack.github.io/filestack-js/) | ||
|
||
### Promises | ||
## Promises | ||
|
||
This library requires an environment that implements the [`Promise`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise) object spec. | ||
If you target IE11 or iOS before 8.0 you will need to add a `Promise` polyfill to your page or application. | ||
If you target IE11 or iOS before 8.0 you will need to add a `Promise` and `Symbol` polyfill to your page or application. | ||
|
||
**Polyfills we recommend:** | ||
Polyfills we recommend:** | ||
|
||
Module (for bundling): | ||
* https://github.com/taylorhakes/promise-polyfill | ||
* https://babeljs.io/docs/en/babel-polyfill | ||
|
||
Script (for script tag): | ||
* https://cdn.polyfill.io/v2/polyfill.min.js?features=Promise | ||
* https://polyfill.io/v3/polyfill.min.js?features=Promise%2CPromise.prototype.finally%2CSymbol | ||
|
||
## Development | ||
|
||
Most tests in this library are expected to interface with actual backend services. Because we like to run tests during development, these services are mocked | ||
during unit testing. | ||
Most tests in this library are expected to interface with actual backend services. Because we like to run tests during development, these services are mocked during unit testing. | ||
|
||
All tests are using Mocha. Browser tests are run with Karma. | ||
All tests are using Jest. | ||
|
||
To run units: | ||
|
||
``` | ||
npm test | ||
``` | ||
|
||
To run integration tests: | ||
## Debugging | ||
|
||
``` | ||
npm run test:integration | ||
Filestack-js uses [`debug`](https://github.com/visionmedia/debug), so just run with environmental variable `DEBUG` set to `fs.*`. | ||
|
||
### Node | ||
```js | ||
DEBUG=fs.* node example_upload.js | ||
``` | ||
|
||
Integration tests require a `.env` file in the root of your project with the following fields: | ||
### Browser | ||
Debug's enable state is persisted by localStorage | ||
|
||
```js | ||
localStorage.debug = 'fs:*' | ||
``` | ||
BROWSERSTACK_USERNAME= | ||
BROWSERSTACK_ACCESS_KEY= | ||
TEST_APIKEY= | ||
TEST_CLOUD_APIKEY= | ||
TEST_INTELLIGENT_APIKEY= | ||
TEST_SECURE_APIKEY= | ||
TEST_SIGNATURE= | ||
TEST_POLICY= | ||
TEST_FILELINK= | ||
TEST_SECURE_FILELINK= | ||
``` | ||
|
||
You will need to acquire this data from a Filestack developer if you plan on running the integration suite. | ||
And then refresh the page. | ||
|
||
## Versioning | ||
|
||
We use [SemVer](http://semver.org/) for versioning. For the versions available, see the [tags](https://github.com/filestack/filestack-js/tags) on this repository. | ||
|
||
## Contributing | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
module.exports = { | ||
name: 'filestack-js', | ||
collectCoverage: true, | ||
clearMocks: true, | ||
projects: [{ | ||
displayName: 'Common', | ||
clearMocks: true, | ||
testMatch: ['<rootDir>/src/**/*.spec.ts'], | ||
testEnvironment: 'node', | ||
moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx', 'json', 'node'], | ||
transform: { | ||
'^.+\\.tsx?$': 'ts-jest' | ||
}, | ||
}, { | ||
displayName: 'Node', | ||
clearMocks: true, | ||
testMatch: ['<rootDir>/src/**/*.spec.ts'], | ||
moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx', 'json', 'node'], | ||
testMatch: ['<rootDir>/src/**/*.spec.node.ts'], | ||
testEnvironment: 'node', | ||
transform: { | ||
'^.+\\.tsx?$': 'ts-jest' | ||
}, | ||
}, { | ||
displayName: 'Browser', | ||
testMatch: ['<rootDir>/src/**/*.browser.spec.ts'], | ||
clearMocks: true, | ||
testEnvironment: 'jsdom', | ||
setupFiles: ['jest-localstorage-mock'], | ||
testMatch: ['<rootDir>/src/**/*.spec.browser.ts'], | ||
moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx', 'json', 'node'], | ||
transform: { | ||
'^.+\\.tsx?$': 'ts-jest' | ||
}, | ||
}] | ||
}; |
Oops, something went wrong.