├── .eslintignore ├── jest.config.js ├── index.js ├── src ├── constants.js ├── __snapshots__ │ └── index.test.js.snap ├── index.js └── index.test.js ├── .eslintrc.json ├── package.json ├── .gitignore ├── README.md └── LICENSE /.eslintignore: -------------------------------------------------------------------------------- 1 | !.* 2 | 3 | /node_modules -------------------------------------------------------------------------------- /jest.config.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | verbose: true, 3 | }; 4 | -------------------------------------------------------------------------------- /index.js: -------------------------------------------------------------------------------- 1 | const {search} = require('./src'); 2 | 3 | module.exports = { 4 | search, 5 | }; 6 | -------------------------------------------------------------------------------- /src/constants.js: -------------------------------------------------------------------------------- 1 | const PREFIXES = { 2 | ALL: 'all', 3 | TI: 'ti', // Title 4 | AU: 'au', // Author 5 | ABS: 'abs', // Abstract 6 | CO: 'co', // Comment 7 | JR: 'jr', // Journal Reference 8 | CAT: 'cat', // Subject Category 9 | RN: 'rn', // Report Number 10 | }; 11 | 12 | const SEPARATORS = { 13 | AND: '+AND+', 14 | OR: '+OR+', 15 | ANDNOT: '+ANDNOT+', 16 | }; 17 | 18 | const SORT_BY = { 19 | RELEVANCE: 'relevance', 20 | LAST_UPDATED_DATE: 'lastUpdatedDate', 21 | SUBMITTED_DATE: 'submittedDate', 22 | }; 23 | 24 | const SORT_ORDER = { 25 | ASCENDING: 'ascending', 26 | DESCENDING: 'descending', 27 | }; 28 | 29 | module.exports = { 30 | PREFIXES, 31 | SEPARATORS, 32 | SORT_BY, 33 | SORT_ORDER, 34 | }; 35 | -------------------------------------------------------------------------------- /.eslintrc.json: -------------------------------------------------------------------------------- 1 | { 2 | "plugins": ["jest", "node", "prettier"], 3 | "extends": [ 4 | "eslint:recommended", 5 | "plugin:prettier/recommended", 6 | "prettier/standard", 7 | "plugin:node/recommended", 8 | "plugin:jest/all" 9 | ], 10 | "parserOptions": { 11 | "ecmaVersion": 2020 12 | }, 13 | "rules": { 14 | "prettier/prettier": ["error", { 15 | "singleQuote": true, 16 | "bracketSpacing": false, 17 | "trailingComma": "es5", 18 | "useTabs": true, 19 | "printWidth": 120, 20 | "endOfLine":"auto" 21 | } 22 | ], 23 | "jest/prefer-expect-assertions": "off", 24 | "jest/expect-expect": "off", 25 | "jest/no-hooks": "off", 26 | "jest/prefer-inline-snapshots": "off" 27 | } 28 | } -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "arxiv-api", 3 | "version": "1.1.0", 4 | "description": "node wrapper for arXiv api", 5 | "main": "index.js", 6 | "scripts": { 7 | "test": "jest -u ./src/index.test.js", 8 | "test:coverage": "jest ./src/index.test.js --coverage", 9 | "lint": "eslint '**/*.js' --quiet" 10 | }, 11 | "repository": { 12 | "type": "git", 13 | "url": "git+https://github.com/eliorav/arXiv-api.git" 14 | }, 15 | "keywords": [ 16 | "arxiv", 17 | "node", 18 | "javascript" 19 | ], 20 | "author": "elior avraham", 21 | "license": "ISC", 22 | "bugs": { 23 | "url": "https://github.com/eliorav/arXiv-api/issues" 24 | }, 25 | "homepage": "https://github.com/eliorav/arXiv-api#readme", 26 | "dependencies": { 27 | "axios": "^0.21.1", 28 | "lodash": "^4.17.21", 29 | "xml2js": "^0.4.23" 30 | }, 31 | "devDependencies": { 32 | "eslint": "6.8.0", 33 | "eslint-config-prettier": "6.10.1", 34 | "eslint-plugin-jest": "23.8.2", 35 | "eslint-plugin-node": "11.0.0", 36 | "eslint-plugin-prettier": "^2.6.0", 37 | "jest": "25.2.2", 38 | "prettier": "1.16.4" 39 | }, 40 | "engines": { 41 | "node": ">=8.10.0" 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Logs 2 | logs 3 | *.log 4 | npm-debug.log* 5 | yarn-debug.log* 6 | yarn-error.log* 7 | lerna-debug.log* 8 | 9 | # Diagnostic reports (https://nodejs.org/api/report.html) 10 | report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json 11 | 12 | # Runtime data 13 | pids 14 | *.pid 15 | *.seed 16 | *.pid.lock 17 | 18 | # Directory for instrumented libs generated by jscoverage/JSCover 19 | lib-cov 20 | 21 | # Coverage directory used by tools like istanbul 22 | coverage 23 | *.lcov 24 | 25 | # nyc test coverage 26 | .nyc_output 27 | 28 | # Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files) 29 | .grunt 30 | 31 | # Bower dependency directory (https://bower.io/) 32 | bower_components 33 | 34 | # node-waf configuration 35 | .lock-wscript 36 | 37 | # Compiled binary addons (https://nodejs.org/api/addons.html) 38 | build/Release 39 | 40 | # Dependency directories 41 | node_modules/ 42 | jspm_packages/ 43 | 44 | # TypeScript v1 declaration files 45 | typings/ 46 | 47 | # TypeScript cache 48 | *.tsbuildinfo 49 | 50 | # Optional npm cache directory 51 | .npm 52 | 53 | # Optional eslint cache 54 | .eslintcache 55 | 56 | # Microbundle cache 57 | .rpt2_cache/ 58 | .rts2_cache_cjs/ 59 | .rts2_cache_es/ 60 | .rts2_cache_umd/ 61 | 62 | # Optional REPL history 63 | .node_repl_history 64 | 65 | # Output of 'npm pack' 66 | *.tgz 67 | 68 | # Yarn Integrity file 69 | .yarn-integrity 70 | 71 | # dotenv environment variables file 72 | .env 73 | .env.test 74 | 75 | # parcel-bundler cache (https://parceljs.org/) 76 | .cache 77 | 78 | # Next.js build output 79 | .next 80 | 81 | # Nuxt.js build / generate output 82 | .nuxt 83 | dist 84 | 85 | # Gatsby files 86 | .cache/ 87 | # Comment in the public line in if your project uses Gatsby and *not* Next.js 88 | # https://nextjs.org/blog/next-9-1#public-directory-support 89 | # public 90 | 91 | # vuepress build output 92 | .vuepress/dist 93 | 94 | # Serverless directories 95 | .serverless/ 96 | 97 | # FuseBox cache 98 | .fusebox/ 99 | 100 | # DynamoDB Local files 101 | .dynamodb/ 102 | 103 | # TernJS port file 104 | .tern-port 105 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 |
2 |
5 | A Javascript wrapper of arxiv api. 6 |
7 | 8 | 9 | ## Getting Started 10 | ### Installation 11 | 12 | ```sh 13 | npm i arxiv-api 14 | ``` 15 | 16 | ### Usage example 17 | 18 | #### Using async/await 19 | ```js 20 | const arxiv = require('arxiv-api'); 21 | 22 | const papers = await arxiv.search({ 23 | searchQueryParams: [ 24 | { 25 | include: [{name: 'RNN'}, {name: 'Deep learning'}], 26 | exclude: [{name: 'LSTM'}], 27 | }, 28 | { 29 | include: [{name: 'GAN'}], 30 | }, 31 | ], 32 | start: 0, 33 | maxResults: 10, 34 | }); 35 | 36 | console.log(papers); 37 | ``` 38 | 39 | #### Using Promise 40 | ```js 41 | const arxiv = require('arxiv-api'); 42 | 43 | const papers = arxiv 44 | .search({ 45 | searchQueryParams: [ 46 | { 47 | include: [{name: 'RNN'}, {name: 'Deep learning'}], 48 | exclude: [{name: 'LSTM'}], 49 | }, 50 | { 51 | include: [{name: 'GAN'}], 52 | }, 53 | ], 54 | start: 0, 55 | maxResults: 10, 56 | }) 57 | .then((papers) => console.log(papers)) 58 | .catch((error) => console.log(error)); 59 | ``` 60 | ## Documentation 61 | ### search - ARXIV-API.search({searchQueryParams, sortBy, sortOrder, start = 0, maxResults = 10}) 62 | * searchQueryParams [{include, exclude}] - An array of search temp. Every object in the array represent different search, and the result will be a logical OR between the objects. 63 | * include [{name, prefix}] - Which tags to include in the search. The result will be a logical AND between the objects. 64 | * name - The name of the tag. 65 | * prefix - one of the [arXiv supporting prefixes](https://arxiv.org/help/api/user-manual#51-details-of-query-construction) 66 | * exclude [{name, prefix}] - Which tags to exclude from the search. The result will be a logical AND NOT between the objects. the name and the prefix are the same as in the include fiels. 67 | * start - The index of the first returned result. 68 | * maxResults - The number of results returned by the query. 69 | * sortBy - Can be "relevance", "lastUpdatedDate", "submittedDate". 70 | * sortOrder - Can be either "ascending" or "descending". 71 | 72 | ## Contact 73 | Elior Avraham – elior.av@gmail.com 74 | 75 | -------------------------------------------------------------------------------- /src/__snapshots__/index.test.js.snap: -------------------------------------------------------------------------------- 1 | // Jest Snapshot v1, https://goo.gl/fbAQLP 2 | 3 | exports[`arXiv search tests should return results as expected - default values 1`] = ` 4 | Array [ 5 | Object { 6 | "authors": Array [ 7 | Array [ 8 | "AUTHOR1", 9 | ], 10 | Array [ 11 | "AUTHOR2", 12 | ], 13 | ], 14 | "categories": Array [ 15 | "CATEGORY", 16 | ], 17 | "id": "PAPER_ID", 18 | "links": Array [ 19 | Object { 20 | "href": "URL", 21 | "rel": "REL", 22 | "title": "TITLE", 23 | "type": "TYPE", 24 | }, 25 | ], 26 | "published": "PUBLISHED", 27 | "summary": "SUMMARY", 28 | "title": "TITLE", 29 | "updated": "UPDATED", 30 | }, 31 | ] 32 | `; 33 | 34 | exports[`arXiv search tests should return results as expected - with sortBy and sortOrder 1`] = ` 35 | Array [ 36 | Object { 37 | "authors": Array [ 38 | Array [ 39 | "AUTHOR1", 40 | ], 41 | Array [ 42 | "AUTHOR2", 43 | ], 44 | ], 45 | "categories": Array [ 46 | "CATEGORY", 47 | ], 48 | "id": "PAPER_ID", 49 | "links": Array [ 50 | Object { 51 | "href": "URL", 52 | "rel": "REL", 53 | "title": "TITLE", 54 | "type": "TYPE", 55 | }, 56 | ], 57 | "published": "PUBLISHED", 58 | "summary": "SUMMARY", 59 | "title": "TITLE", 60 | "updated": "UPDATED", 61 | }, 62 | ] 63 | `; 64 | 65 | exports[`arXiv search tests should return results as expected 1`] = ` 66 | Array [ 67 | Object { 68 | "authors": Array [ 69 | Array [ 70 | "AUTHOR1", 71 | ], 72 | Array [ 73 | "AUTHOR2", 74 | ], 75 | ], 76 | "categories": Array [ 77 | "CATEGORY", 78 | ], 79 | "id": "PAPER_ID", 80 | "links": Array [ 81 | Object { 82 | "href": "URL", 83 | "rel": "REL", 84 | "title": "TITLE", 85 | "type": "TYPE", 86 | }, 87 | ], 88 | "published": "PUBLISHED", 89 | "summary": "SUMMARY", 90 | "title": "TITLE", 91 | "updated": "UPDATED", 92 | }, 93 | ] 94 | `; 95 | 96 | exports[`arXiv search tests should throw error - exclude tags is not an array 1`] = `[Error: include and exclude must be arrays]`; 97 | 98 | exports[`arXiv search tests should throw error - include tags empty 1`] = `[Error: include is a mandatory field]`; 99 | 100 | exports[`arXiv search tests should throw error - include tags is not an array 1`] = `[Error: include and exclude must be arrays]`; 101 | 102 | exports[`arXiv search tests should throw error - searchQueryParams is not an array 1`] = `[Error: query param must be an array]`; 103 | 104 | exports[`arXiv search tests should throw error - tag name is empty 1`] = `[Error: you must specify tag name]`; 105 | 106 | exports[`arXiv search tests should throw error - tag name is not string 1`] = `[Error: you must specify tag name]`; 107 | 108 | exports[`arXiv search tests should throw error - unsupported sortBy 1`] = `[Error: unsupported sort by option. should be one of: relevance lastUpdatedDate submittedDate]`; 109 | 110 | exports[`arXiv search tests should throw error - unsupported sortOrder 1`] = `[Error: unsupported sort order option. should be one of: ascending descending]`; 111 | 112 | exports[`arXiv search tests should throw error - unsupported tag prefix 1`] = `[Error: unsupported prefix: pre]`; 113 | -------------------------------------------------------------------------------- /src/index.js: -------------------------------------------------------------------------------- 1 | const axios = require('axios'); 2 | const _ = require('lodash'); 3 | const {PREFIXES, SEPARATORS, SORT_BY, SORT_ORDER} = require('./constants'); 4 | const util = require('util'); 5 | const {parseString} = require('xml2js'); 6 | const parseStringPromisified = util.promisify(parseString); 7 | 8 | const get_arxiv_url = ({searchQuery, sortBy, sortOrder, start, maxResults}) => 9 | `http://export.arxiv.org/api/query?search_query=${searchQuery}&start=${start}&max_results=${maxResults}${ 10 | sortBy ? `&sortBy=${sortBy}` : '' 11 | }${sortOrder ? `&sortOrder=${sortOrder}` : ''}`; 12 | 13 | /** 14 | * Parse arXiv entry object. 15 | * @param {Object} entry. 16 | * @returns {Object} formatted arXiv entry object. 17 | */ 18 | function parseArxivObject(entry) { 19 | return { 20 | id: _.get(entry, 'id[0]', ''), 21 | title: _.get(entry, 'title[0]', ''), 22 | summary: _.get(entry, 'summary[0]', '').trim(), 23 | authors: _.get(entry, 'author', []).map(author => author.name), 24 | links: _.get(entry, 'link', []).map(link => link.$), 25 | published: _.get(entry, 'published[0]', ''), 26 | updated: _.get(entry, 'updated[0]', ''), 27 | categories: _.get(entry, 'category', []).map(category => category.$), 28 | }; 29 | } 30 | 31 | /** 32 | * Parse a tag to a query string. 33 | * @param {{name: string, prefix: string}} tag 34 | * @param {string} name - the name of the tag - mandatory. 35 | * @param {string} prefix - one of PREFIXES - default to ALL. 36 | * @returns {string} query string of a tag. 37 | */ 38 | function parseTag({name, prefix = PREFIXES.ALL}) { 39 | if (!_.isString(name) || _.isEmpty(name)) { 40 | throw new Error('you must specify tag name'); 41 | } 42 | if (!Object.values(PREFIXES).includes(prefix)) { 43 | throw new Error(`unsupported prefix: ${prefix}`); 44 | } 45 | return `${prefix}:${name}`; 46 | } 47 | 48 | /** 49 | * Parse include tags and exclude tags to a query string. 50 | * @param {Array.<{include: Array, exclude: Array}>} tags 51 | * @returns {string} query string between tags. 52 | */ 53 | function parseTags({include, exclude = []}) { 54 | if (!Array.isArray(include) || !Array.isArray(exclude)) { 55 | throw new Error('include and exclude must be arrays'); 56 | } 57 | if (include.length === 0) { 58 | throw new Error('include is a mandatory field'); 59 | } 60 | return `${include.map(parseTag).join(SEPARATORS.AND)}${exclude.length > 0 ? SEPARATORS.ANDNOT : ''}${exclude 61 | .map(parseTag) 62 | .join(SEPARATORS.ANDNOT)}`; 63 | } 64 | 65 | /** 66 | * Fetch data from arXiv API 67 | * @async 68 | * @param {{searchQueryParams: Array.<{include: Array, exclude: Array}>, start: number, maxResults: number}} args 69 | * @param {Array} searchQueryParams - array of search query. 70 | * @param {string} sortBy - can be "relevance", "lastUpdatedDate", "submittedDate". 71 | * @param {string} sortOrder - can be either "ascending" or "descending". 72 | * @param {number} start - the index of the first returned result. 73 | * @param {number} maxResults - the number of results returned by the query. 74 | * @returns {Promise} 75 | */ 76 | async function search({searchQueryParams, sortBy, sortOrder, start = 0, maxResults = 10}) { 77 | if (!Array.isArray(searchQueryParams)) { 78 | throw new Error('query param must be an array'); 79 | } 80 | if (sortBy && !Object.values(SORT_BY).includes(sortBy)) { 81 | throw new Error(`unsupported sort by option. should be one of: ${Object.values(SORT_BY).join(' ')}`); 82 | } 83 | if (sortOrder && !Object.values(SORT_ORDER).includes(sortOrder)) { 84 | throw new Error(`unsupported sort order option. should be one of: ${Object.values(SORT_ORDER).join(' ')}`); 85 | } 86 | const searchQuery = searchQueryParams.map(parseTags).join(SEPARATORS.OR); 87 | const response = await axios.get(get_arxiv_url({searchQuery, sortBy, sortOrder, start, maxResults})); 88 | const parsedData = await parseStringPromisified(response.data); 89 | return _.get(parsedData, 'feed.entry', []).map(parseArxivObject); 90 | } 91 | 92 | module.exports = { 93 | search, 94 | }; 95 | -------------------------------------------------------------------------------- /src/index.test.js: -------------------------------------------------------------------------------- 1 | const {PREFIXES, SORT_BY, SORT_ORDER} = require('./constants'); 2 | 3 | const mockResponse = { 4 | feed: { 5 | entry: [ 6 | { 7 | id: ['PAPER_ID'], 8 | updated: ['UPDATED'], 9 | published: ['PUBLISHED'], 10 | title: ['TITLE'], 11 | summary: ['SUMMARY'], 12 | author: [{name: ['AUTHOR1']}, {name: ['AUTHOR2']}], 13 | link: [{$: {title: 'TITLE', href: 'URL', rel: 'REL', type: 'TYPE'}}], 14 | category: [{$: 'CATEGORY'}], 15 | }, 16 | ], 17 | }, 18 | }; 19 | 20 | const mockAxiosGet = jest.fn(() => Promise.resolve({data: 'XML'})); 21 | const mockXmlPromisify = jest.fn(() => Promise.resolve(mockResponse)); 22 | 23 | jest.mock('axios', () => ({ 24 | get: mockAxiosGet, 25 | })); 26 | jest.mock('xml2js'); 27 | jest.mock('util', () => ({ 28 | promisify: jest.fn(() => mockXmlPromisify), 29 | })); 30 | 31 | const {search} = require('./index.js'); 32 | 33 | describe('arXiv search tests', () => { 34 | beforeEach(() => { 35 | mockAxiosGet.mockClear(); 36 | }); 37 | it('should return results as expected - default values', async () => { 38 | const results = await search({ 39 | searchQueryParams: [ 40 | { 41 | include: [{name: 'RNN'}, {name: 'Deep learning'}], 42 | exclude: [{name: 'LSTM'}], 43 | }, 44 | { 45 | include: [{name: 'GAN'}], 46 | }, 47 | ], 48 | }); 49 | expect(mockAxiosGet).toHaveBeenCalledWith( 50 | 'http://export.arxiv.org/api/query?search_query=all:RNN+AND+all:Deep learning+ANDNOT+all:LSTM+OR+all:GAN&start=0&max_results=10' 51 | ); 52 | expect(results).toMatchSnapshot(); 53 | }); 54 | it('should return results as expected', async () => { 55 | const results = await search({ 56 | searchQueryParams: [ 57 | { 58 | include: [{name: 'RNN'}, {name: 'Deep learning'}], 59 | exclude: [{name: 'LSTM'}], 60 | }, 61 | { 62 | include: [{name: 'GAN', prefix: PREFIXES.CAT}], 63 | }, 64 | ], 65 | start: 10, 66 | maxResults: 50, 67 | }); 68 | expect(mockAxiosGet).toHaveBeenCalledWith( 69 | 'http://export.arxiv.org/api/query?search_query=all:RNN+AND+all:Deep learning+ANDNOT+all:LSTM+OR+cat:GAN&start=10&max_results=50' 70 | ); 71 | expect(results).toMatchSnapshot(); 72 | }); 73 | it('should return results as expected - with sortBy and sortOrder', async () => { 74 | const results = await search({ 75 | searchQueryParams: [ 76 | { 77 | include: [{name: 'RNN'}, {name: 'Deep learning'}], 78 | exclude: [{name: 'LSTM'}], 79 | }, 80 | { 81 | include: [{name: 'GAN'}], 82 | }, 83 | ], 84 | start: 10, 85 | maxResults: 50, 86 | sortBy: SORT_BY.RELEVANCE, 87 | sortOrder: SORT_ORDER.ASCENDING, 88 | }); 89 | expect(mockAxiosGet).toHaveBeenCalledWith( 90 | 'http://export.arxiv.org/api/query?search_query=all:RNN+AND+all:Deep learning+ANDNOT+all:LSTM+OR+all:GAN&start=10&max_results=50&sortBy=relevance&sortOrder=ascending' 91 | ); 92 | expect(results).toMatchSnapshot(); 93 | }); 94 | it('should throw error - unsupported sortBy', async () => { 95 | await expect( 96 | search({ 97 | searchQueryParams: [ 98 | { 99 | include: [{name: 'GAN'}], 100 | }, 101 | ], 102 | sortBy: 'SORT_BY', 103 | }) 104 | ).rejects.toMatchSnapshot(); 105 | }); 106 | it('should throw error - unsupported sortOrder', async () => { 107 | await expect( 108 | search({ 109 | searchQueryParams: [ 110 | { 111 | include: [{name: 'GAN'}], 112 | }, 113 | ], 114 | sortOrder: 'SORT_ORDER', 115 | }) 116 | ).rejects.toMatchSnapshot(); 117 | }); 118 | it('should throw error - searchQueryParams is not an array', async () => { 119 | await expect( 120 | search({ 121 | searchQueryParams: 'PARAMS', 122 | }) 123 | ).rejects.toMatchSnapshot(); 124 | }); 125 | it('should throw error - include tags is not an array', async () => { 126 | await expect( 127 | search({ 128 | searchQueryParams: [ 129 | { 130 | include: 'SOME_VALUE', 131 | }, 132 | ], 133 | }) 134 | ).rejects.toMatchSnapshot(); 135 | }); 136 | it('should throw error - exclude tags is not an array', async () => { 137 | await expect( 138 | search({ 139 | searchQueryParams: [ 140 | { 141 | include: [{name: 'GAN'}], 142 | exclude: 'SOME_VALUE', 143 | }, 144 | ], 145 | }) 146 | ).rejects.toMatchSnapshot(); 147 | }); 148 | it('should throw error - include tags empty', async () => { 149 | await expect( 150 | search({ 151 | searchQueryParams: [ 152 | { 153 | include: [], 154 | }, 155 | ], 156 | }) 157 | ).rejects.toMatchSnapshot(); 158 | }); 159 | it('should throw error - tag name is empty', async () => { 160 | await expect( 161 | search({ 162 | searchQueryParams: [ 163 | { 164 | include: [{name: ''}], 165 | }, 166 | ], 167 | }) 168 | ).rejects.toMatchSnapshot(); 169 | }); 170 | it('should throw error - tag name is not string', async () => { 171 | await expect( 172 | search({ 173 | searchQueryParams: [ 174 | { 175 | include: [{name: 123}], 176 | }, 177 | ], 178 | }) 179 | ).rejects.toMatchSnapshot(); 180 | }); 181 | it('should throw error - unsupported tag prefix', async () => { 182 | await expect( 183 | search({ 184 | searchQueryParams: [ 185 | { 186 | include: [{name: 'GAN', prefix: 'pre'}], 187 | }, 188 | ], 189 | }) 190 | ).rejects.toMatchSnapshot(); 191 | }); 192 | }); 193 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Apache License 2 | Version 2.0, January 2004 3 | http://www.apache.org/licenses/ 4 | 5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 6 | 7 | 1. Definitions. 8 | 9 | "License" shall mean the terms and conditions for use, reproduction, 10 | and distribution as defined by Sections 1 through 9 of this document. 11 | 12 | "Licensor" shall mean the copyright owner or entity authorized by 13 | the copyright owner that is granting the License. 14 | 15 | "Legal Entity" shall mean the union of the acting entity and all 16 | other entities that control, are controlled by, or are under common 17 | control with that entity. For the purposes of this definition, 18 | "control" means (i) the power, direct or indirect, to cause the 19 | direction or management of such entity, whether by contract or 20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 21 | outstanding shares, or (iii) beneficial ownership of such entity. 22 | 23 | "You" (or "Your") shall mean an individual or Legal Entity 24 | exercising permissions granted by this License. 25 | 26 | "Source" form shall mean the preferred form for making modifications, 27 | including but not limited to software source code, documentation 28 | source, and configuration files. 29 | 30 | "Object" form shall mean any form resulting from mechanical 31 | transformation or translation of a Source form, including but 32 | not limited to compiled object code, generated documentation, 33 | and conversions to other media types. 34 | 35 | "Work" shall mean the work of authorship, whether in Source or 36 | Object form, made available under the License, as indicated by a 37 | copyright notice that is included in or attached to the work 38 | (an example is provided in the Appendix below). 39 | 40 | "Derivative Works" shall mean any work, whether in Source or Object 41 | form, that is based on (or derived from) the Work and for which the 42 | editorial revisions, annotations, elaborations, or other modifications 43 | represent, as a whole, an original work of authorship. For the purposes 44 | of this License, Derivative Works shall not include works that remain 45 | separable from, or merely link (or bind by name) to the interfaces of, 46 | the Work and Derivative Works thereof. 47 | 48 | "Contribution" shall mean any work of authorship, including 49 | the original version of the Work and any modifications or additions 50 | to that Work or Derivative Works thereof, that is intentionally 51 | submitted to Licensor for inclusion in the Work by the copyright owner 52 | or by an individual or Legal Entity authorized to submit on behalf of 53 | the copyright owner. For the purposes of this definition, "submitted" 54 | means any form of electronic, verbal, or written communication sent 55 | to the Licensor or its representatives, including but not limited to 56 | communication on electronic mailing lists, source code control systems, 57 | and issue tracking systems that are managed by, or on behalf of, the 58 | Licensor for the purpose of discussing and improving the Work, but 59 | excluding communication that is conspicuously marked or otherwise 60 | designated in writing by the copyright owner as "Not a Contribution." 61 | 62 | "Contributor" shall mean Licensor and any individual or Legal Entity 63 | on behalf of whom a Contribution has been received by Licensor and 64 | subsequently incorporated within the Work. 65 | 66 | 2. Grant of Copyright License. Subject to the terms and conditions of 67 | this License, each Contributor hereby grants to You a perpetual, 68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 69 | copyright license to reproduce, prepare Derivative Works of, 70 | publicly display, publicly perform, sublicense, and distribute the 71 | Work and such Derivative Works in Source or Object form. 72 | 73 | 3. Grant of Patent License. Subject to the terms and conditions of 74 | this License, each Contributor hereby grants to You a perpetual, 75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 76 | (except as stated in this section) patent license to make, have made, 77 | use, offer to sell, sell, import, and otherwise transfer the Work, 78 | where such license applies only to those patent claims licensable 79 | by such Contributor that are necessarily infringed by their 80 | Contribution(s) alone or by combination of their Contribution(s) 81 | with the Work to which such Contribution(s) was submitted. If You 82 | institute patent litigation against any entity (including a 83 | cross-claim or counterclaim in a lawsuit) alleging that the Work 84 | or a Contribution incorporated within the Work constitutes direct 85 | or contributory patent infringement, then any patent licenses 86 | granted to You under this License for that Work shall terminate 87 | as of the date such litigation is filed. 88 | 89 | 4. Redistribution. You may reproduce and distribute copies of the 90 | Work or Derivative Works thereof in any medium, with or without 91 | modifications, and in Source or Object form, provided that You 92 | meet the following conditions: 93 | 94 | (a) You must give any other recipients of the Work or 95 | Derivative Works a copy of this License; and 96 | 97 | (b) You must cause any modified files to carry prominent notices 98 | stating that You changed the files; and 99 | 100 | (c) You must retain, in the Source form of any Derivative Works 101 | that You distribute, all copyright, patent, trademark, and 102 | attribution notices from the Source form of the Work, 103 | excluding those notices that do not pertain to any part of 104 | the Derivative Works; and 105 | 106 | (d) If the Work includes a "NOTICE" text file as part of its 107 | distribution, then any Derivative Works that You distribute must 108 | include a readable copy of the attribution notices contained 109 | within such NOTICE file, excluding those notices that do not 110 | pertain to any part of the Derivative Works, in at least one 111 | of the following places: within a NOTICE text file distributed 112 | as part of the Derivative Works; within the Source form or 113 | documentation, if provided along with the Derivative Works; or, 114 | within a display generated by the Derivative Works, if and 115 | wherever such third-party notices normally appear. The contents 116 | of the NOTICE file are for informational purposes only and 117 | do not modify the License. You may add Your own attribution 118 | notices within Derivative Works that You distribute, alongside 119 | or as an addendum to the NOTICE text from the Work, provided 120 | that such additional attribution notices cannot be construed 121 | as modifying the License. 122 | 123 | You may add Your own copyright statement to Your modifications and 124 | may provide additional or different license terms and conditions 125 | for use, reproduction, or distribution of Your modifications, or 126 | for any such Derivative Works as a whole, provided Your use, 127 | reproduction, and distribution of the Work otherwise complies with 128 | the conditions stated in this License. 129 | 130 | 5. Submission of Contributions. Unless You explicitly state otherwise, 131 | any Contribution intentionally submitted for inclusion in the Work 132 | by You to the Licensor shall be under the terms and conditions of 133 | this License, without any additional terms or conditions. 134 | Notwithstanding the above, nothing herein shall supersede or modify 135 | the terms of any separate license agreement you may have executed 136 | with Licensor regarding such Contributions. 137 | 138 | 6. Trademarks. This License does not grant permission to use the trade 139 | names, trademarks, service marks, or product names of the Licensor, 140 | except as required for reasonable and customary use in describing the 141 | origin of the Work and reproducing the content of the NOTICE file. 142 | 143 | 7. Disclaimer of Warranty. Unless required by applicable law or 144 | agreed to in writing, Licensor provides the Work (and each 145 | Contributor provides its Contributions) on an "AS IS" BASIS, 146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 147 | implied, including, without limitation, any warranties or conditions 148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 149 | PARTICULAR PURPOSE. You are solely responsible for determining the 150 | appropriateness of using or redistributing the Work and assume any 151 | risks associated with Your exercise of permissions under this License. 152 | 153 | 8. Limitation of Liability. In no event and under no legal theory, 154 | whether in tort (including negligence), contract, or otherwise, 155 | unless required by applicable law (such as deliberate and grossly 156 | negligent acts) or agreed to in writing, shall any Contributor be 157 | liable to You for damages, including any direct, indirect, special, 158 | incidental, or consequential damages of any character arising as a 159 | result of this License or out of the use or inability to use the 160 | Work (including but not limited to damages for loss of goodwill, 161 | work stoppage, computer failure or malfunction, or any and all 162 | other commercial damages or losses), even if such Contributor 163 | has been advised of the possibility of such damages. 164 | 165 | 9. Accepting Warranty or Additional Liability. While redistributing 166 | the Work or Derivative Works thereof, You may choose to offer, 167 | and charge a fee for, acceptance of support, warranty, indemnity, 168 | or other liability obligations and/or rights consistent with this 169 | License. However, in accepting such obligations, You may act only 170 | on Your own behalf and on Your sole responsibility, not on behalf 171 | of any other Contributor, and only if You agree to indemnify, 172 | defend, and hold each Contributor harmless for any liability 173 | incurred by, or claims asserted against, such Contributor by reason 174 | of your accepting any such warranty or additional liability. 175 | 176 | END OF TERMS AND CONDITIONS 177 | 178 | APPENDIX: How to apply the Apache License to your work. 179 | 180 | To apply the Apache License to your work, attach the following 181 | boilerplate notice, with the fields enclosed by brackets "[]" 182 | replaced with your own identifying information. (Don't include 183 | the brackets!) The text should be enclosed in the appropriate 184 | comment syntax for the file format. We also recommend that a 185 | file or class name and description of purpose be included on the 186 | same "printed page" as the copyright notice for easier 187 | identification within third-party archives. 188 | 189 | Copyright [yyyy] [name of copyright owner] 190 | 191 | Licensed under the Apache License, Version 2.0 (the "License"); 192 | you may not use this file except in compliance with the License. 193 | You may obtain a copy of the License at 194 | 195 | http://www.apache.org/licenses/LICENSE-2.0 196 | 197 | Unless required by applicable law or agreed to in writing, software 198 | distributed under the License is distributed on an "AS IS" BASIS, 199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 200 | See the License for the specific language governing permissions and 201 | limitations under the License. 202 | --------------------------------------------------------------------------------