├── LICENSE ├── README.md ├── node_modules ├── .package-lock.json ├── asynckit │ ├── LICENSE │ ├── README.md │ ├── bench.js │ ├── index.js │ ├── lib │ │ ├── abort.js │ │ ├── async.js │ │ ├── defer.js │ │ ├── iterate.js │ │ ├── readable_asynckit.js │ │ ├── readable_parallel.js │ │ ├── readable_serial.js │ │ ├── readable_serial_ordered.js │ │ ├── state.js │ │ ├── streamify.js │ │ └── terminator.js │ ├── package.json │ ├── parallel.js │ ├── serial.js │ ├── serialOrdered.js │ └── stream.js ├── axios │ ├── CHANGELOG.md │ ├── LICENSE │ ├── README.md │ ├── SECURITY.md │ ├── UPGRADE_GUIDE.md │ ├── dist │ │ ├── axios.js │ │ ├── axios.map │ │ ├── axios.min.js │ │ └── axios.min.map │ ├── index.d.ts │ ├── index.js │ ├── lib │ │ ├── adapters │ │ │ ├── README.md │ │ │ ├── http.js │ │ │ └── xhr.js │ │ ├── axios.js │ │ ├── cancel │ │ │ ├── Cancel.js │ │ │ ├── CancelToken.js │ │ │ └── isCancel.js │ │ ├── core │ │ │ ├── Axios.js │ │ │ ├── InterceptorManager.js │ │ │ ├── README.md │ │ │ ├── buildFullPath.js │ │ │ ├── createError.js │ │ │ ├── dispatchRequest.js │ │ │ ├── enhanceError.js │ │ │ ├── mergeConfig.js │ │ │ ├── settle.js │ │ │ └── transformData.js │ │ ├── defaults │ │ │ ├── index.js │ │ │ └── transitional.js │ │ ├── env │ │ │ ├── README.md │ │ │ └── data.js │ │ ├── helpers │ │ │ ├── README.md │ │ │ ├── bind.js │ │ │ ├── buildURL.js │ │ │ ├── combineURLs.js │ │ │ ├── cookies.js │ │ │ ├── deprecatedMethod.js │ │ │ ├── isAbsoluteURL.js │ │ │ ├── isAxiosError.js │ │ │ ├── isURLSameOrigin.js │ │ │ ├── normalizeHeaderName.js │ │ │ ├── parseHeaders.js │ │ │ ├── spread.js │ │ │ ├── toFormData.js │ │ │ └── validator.js │ │ └── utils.js │ ├── package.json │ ├── tsconfig.json │ └── tslint.json ├── combined-stream │ ├── License │ ├── Readme.md │ ├── lib │ │ └── combined_stream.js │ ├── package.json │ └── yarn.lock ├── delayed-stream │ ├── .npmignore │ ├── License │ ├── Makefile │ ├── Readme.md │ ├── lib │ │ └── delayed_stream.js │ └── package.json ├── follow-redirects │ ├── LICENSE │ ├── README.md │ ├── debug.js │ ├── http.js │ ├── https.js │ ├── index.js │ └── package.json ├── form-data │ ├── License │ ├── README.md.bak │ ├── Readme.md │ ├── index.d.ts │ ├── lib │ │ ├── browser.js │ │ ├── form_data.js │ │ └── populate.js │ └── package.json ├── fs │ ├── README.md │ └── package.json ├── mime-db │ ├── HISTORY.md │ ├── LICENSE │ ├── README.md │ ├── db.json │ ├── index.js │ └── package.json ├── mime-types │ ├── HISTORY.md │ ├── LICENSE │ ├── README.md │ ├── index.js │ └── package.json ├── openai │ ├── .github │ │ ├── ISSUE_TEMPLATE │ │ │ ├── bug_report.yml │ │ │ ├── config.yml │ │ │ └── feature_request.yml │ │ └── workflows │ │ │ └── test.yml │ ├── .openapi-generator-ignore │ ├── .openapi-generator │ │ ├── FILES │ │ └── VERSION │ ├── LICENSE │ ├── README.md │ ├── api.ts │ ├── base.ts │ ├── common.ts │ ├── configuration.ts │ ├── dist │ │ ├── api.d.ts │ │ ├── api.js │ │ ├── base.d.ts │ │ ├── base.js │ │ ├── common.d.ts │ │ ├── common.js │ │ ├── configuration.d.ts │ │ ├── configuration.js │ │ ├── index.d.ts │ │ └── index.js │ ├── index.ts │ ├── package.json │ └── tsconfig.json ├── python-shell │ ├── CHANGELOG.md │ ├── README.md │ ├── a.d.ts │ ├── a.js │ ├── a.js.map │ ├── index.d.ts │ ├── index.js │ ├── index.js.map │ ├── package.json │ ├── test.d.ts │ ├── test.js │ ├── test.js.map │ ├── testShould.d.ts │ ├── testShould.js │ └── testShould.js.map └── threading │ ├── .babelrc │ ├── .npmignore │ ├── README.md │ ├── index.js │ ├── package.json │ ├── src │ ├── index.js │ ├── test │ │ ├── threadFirst_spec.js │ │ └── threadLast_spec.js │ ├── threadFirst.js │ └── threadLast.js │ └── webpack.config.js ├── package-lock.json ├── package.json ├── run_pipeline.sh └── scripts ├── cleaner.py ├── prompt_completion_gen.py ├── transcript_scraper.py └── youtube_scraper.ts /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2023 Emmet Halm 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # AutoFinetune 2 | 3 | Fine-tune an OpenAI model in one command line. 4 | 5 | TuneAI provides an effortless way to fine-tune OpenAI models using YouTube video transcripts or text input. The project automates the process of transcript cleaning, prompt-completion pair generation, and training, making it easier to refine AI models for specific tasks. 6 | 7 | ## Features 8 | 9 | - Automatically clean YouTube video transcripts 10 | - Generate prompt-completion pairs from cleaned transcripts 11 | - Fine-tune OpenAI models based on generated prompt-completion pairs 12 | - Support for both YouTube video links and text input 13 | 14 | ## Installation 15 | 16 | ### Prerequisites 17 | 18 | - Python 3.7 or later 19 | - An OpenAI API key 20 | 21 | ### Steps 22 | 23 | 1. Clone the repository: 24 | git clone https://github.com/emmethalm/tuneAI.git 25 | 26 | 2. Change to the project directory: 27 | cd tuneAI 28 | 29 | 3. Install the required packages: 30 | 31 | npm install 32 | 33 | npm install openai 34 | 35 | npm install python3 36 | 37 | 4. Create a .env file in the project root directory and add your OpenAI API key OR just add your API key to cleaner.py and prompt_completion_gen.py: 38 | echo "OPENAI_API_KEY=your_api_key_here" > .env 39 | 40 | ## Usage 41 | 42 | ### Fine-tuning with a YouTube video transcript 43 | ./run_pipeline.sh https://www.youtube.com/watch?v=your_video_id_here 44 | 45 | ### Fine-tuning with a text file 46 | ./run_pipeline.sh --text-file path/to/your/text_file.txt 47 | 48 | ### Additional options 49 | 50 | - --epochs: Specify the number of training epochs (default: 1) 51 | - --batch-size: Specify the training batch size (default: 8) 52 | - --prompt-length: Specify the maximum prompt length (default: 150) 53 | - --response-length: Specify the maximum response length (default: 150) 54 | 55 | ## Best Practices 56 | 57 | While you can run the fine-tuning process in one line by running the pipeline, for more precise results run each script individually, check the outputs at each step, and tweak the context sentence in the prompt in prompt_completion_gen.py. 58 | 59 | To run step by step: 60 | 61 | (install dependencies) 62 | 63 | 1. tsc youtube_scraper.ts 64 | 2. node youtube_scraper.js 65 | 3. python3 cleaner.py 66 | 4. python3 prompt_comnpletion_gen.py 67 | 5. export OPENAI_API_KEY=$OPENAI_API_KEY 68 | 6. openai api fine_tunes.create -t prompt_completion_pairs.jsonl -m davinci 69 | 70 | The quality of your fine-tuning is fully dependent on the quality of your data. 71 | 72 | Happy building! 73 | 74 | ### Share what you build with me on Twitter [@ehalm_](https://twitter.com/ehalm_) 👋 75 | 76 | ## License 77 | 78 | This project is licensed under the MIT License - see the LICENSE.md file for details. 79 | 80 | -------------------------------------------------------------------------------- /node_modules/.package-lock.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "autofinetune", 3 | "lockfileVersion": 3, 4 | "requires": true, 5 | "packages": { 6 | "node_modules/asynckit": { 7 | "version": "0.4.0", 8 | "resolved": "https://registry.npmjs.org/asynckit/-/asynckit-0.4.0.tgz", 9 | "integrity": "sha512-Oei9OH4tRh0YqU3GxhX79dM/mwVgvbZJaSNaRk+bshkj0S5cfHcgYakreBjrHwatXKbz+IoIdYLxrKim2MjW0Q==" 10 | }, 11 | "node_modules/axios": { 12 | "version": "0.26.1", 13 | "resolved": "https://registry.npmjs.org/axios/-/axios-0.26.1.tgz", 14 | "integrity": "sha512-fPwcX4EvnSHuInCMItEhAGnaSEXRBjtzh9fOtsE6E1G6p7vl7edEeZe11QHf18+6+9gR5PbKV/sGKNaD8YaMeA==", 15 | "dependencies": { 16 | "follow-redirects": "^1.14.8" 17 | } 18 | }, 19 | "node_modules/combined-stream": { 20 | "version": "1.0.8", 21 | "resolved": "https://registry.npmjs.org/combined-stream/-/combined-stream-1.0.8.tgz", 22 | "integrity": "sha512-FQN4MRfuJeHf7cBbBMJFXhKSDq+2kAArBlmRBvcvFE5BB1HZKXtSFASDhdlz9zOYwxh8lDdnvmMOe/+5cdoEdg==", 23 | "dependencies": { 24 | "delayed-stream": "~1.0.0" 25 | }, 26 | "engines": { 27 | "node": ">= 0.8" 28 | } 29 | }, 30 | "node_modules/delayed-stream": { 31 | "version": "1.0.0", 32 | "resolved": "https://registry.npmjs.org/delayed-stream/-/delayed-stream-1.0.0.tgz", 33 | "integrity": "sha512-ZySD7Nf91aLB0RxL4KGrKHBXl7Eds1DAmEdcoVawXnLD7SDhpNgtuII2aAkg7a7QS41jxPSZ17p4VdGnMHk3MQ==", 34 | "engines": { 35 | "node": ">=0.4.0" 36 | } 37 | }, 38 | "node_modules/follow-redirects": { 39 | "version": "1.15.2", 40 | "resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.15.2.tgz", 41 | "integrity": "sha512-VQLG33o04KaQ8uYi2tVNbdrWp1QWxNNea+nmIB4EVM28v0hmP17z7aG1+wAkNzVq4KeXTq3221ye5qTJP91JwA==", 42 | "funding": [ 43 | { 44 | "type": "individual", 45 | "url": "https://github.com/sponsors/RubenVerborgh" 46 | } 47 | ], 48 | "engines": { 49 | "node": ">=4.0" 50 | }, 51 | "peerDependenciesMeta": { 52 | "debug": { 53 | "optional": true 54 | } 55 | } 56 | }, 57 | "node_modules/form-data": { 58 | "version": "4.0.0", 59 | "resolved": "https://registry.npmjs.org/form-data/-/form-data-4.0.0.tgz", 60 | "integrity": "sha512-ETEklSGi5t0QMZuiXoA/Q6vcnxcLQP5vdugSpuAyi6SVGi2clPPp+xgEhuMaHC+zGgn31Kd235W35f7Hykkaww==", 61 | "dependencies": { 62 | "asynckit": "^0.4.0", 63 | "combined-stream": "^1.0.8", 64 | "mime-types": "^2.1.12" 65 | }, 66 | "engines": { 67 | "node": ">= 6" 68 | } 69 | }, 70 | "node_modules/fs": { 71 | "version": "0.0.1-security", 72 | "resolved": "https://registry.npmjs.org/fs/-/fs-0.0.1-security.tgz", 73 | "integrity": "sha512-3XY9e1pP0CVEUCdj5BmfIZxRBTSDycnbqhIOGec9QYtmVH2fbLpj86CFWkrNOkt/Fvty4KZG5lTglL9j/gJ87w==" 74 | }, 75 | "node_modules/mime-db": { 76 | "version": "1.52.0", 77 | "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.52.0.tgz", 78 | "integrity": "sha512-sPU4uV7dYlvtWJxwwxHD0PuihVNiE7TyAbQ5SWxDCB9mUYvOgroQOwYQQOKPJ8CIbE+1ETVlOoK1UC2nU3gYvg==", 79 | "engines": { 80 | "node": ">= 0.6" 81 | } 82 | }, 83 | "node_modules/mime-types": { 84 | "version": "2.1.35", 85 | "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.35.tgz", 86 | "integrity": "sha512-ZDY+bPm5zTTF+YpCrAU9nK0UgICYPT0QtT1NZWFv4s++TNkcgVaT0g6+4R2uI4MjQjzysHB1zxuWL50hzaeXiw==", 87 | "dependencies": { 88 | "mime-db": "1.52.0" 89 | }, 90 | "engines": { 91 | "node": ">= 0.6" 92 | } 93 | }, 94 | "node_modules/openai": { 95 | "version": "3.2.1", 96 | "resolved": "https://registry.npmjs.org/openai/-/openai-3.2.1.tgz", 97 | "integrity": "sha512-762C9BNlJPbjjlWZi4WYK9iM2tAVAv0uUp1UmI34vb0CN5T2mjB/qM6RYBmNKMh/dN9fC+bxqPwWJZUTWW052A==", 98 | "dependencies": { 99 | "axios": "^0.26.0", 100 | "form-data": "^4.0.0" 101 | } 102 | }, 103 | "node_modules/python-shell": { 104 | "version": "5.0.0", 105 | "resolved": "https://registry.npmjs.org/python-shell/-/python-shell-5.0.0.tgz", 106 | "integrity": "sha512-RUOOOjHLhgR1MIQrCtnEqz/HJ1RMZBIN+REnpSUrfft2bXqXy69fwJASVziWExfFXsR1bCY0TznnHooNsCo0/w==", 107 | "engines": { 108 | "node": ">=0.10" 109 | } 110 | }, 111 | "node_modules/threading": { 112 | "version": "0.0.2", 113 | "resolved": "https://registry.npmjs.org/threading/-/threading-0.0.2.tgz", 114 | "integrity": "sha512-ULRaud4+64DVoJtARH0ui/xYRPQumtHP/rSuvgm2jy4dYkslege5i1vp7tjt+mwgIlE8090LKyHU7M/zkWXZMQ==" 115 | } 116 | } 117 | } 118 | -------------------------------------------------------------------------------- /node_modules/asynckit/LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2016 Alex Indigo 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /node_modules/asynckit/bench.js: -------------------------------------------------------------------------------- 1 | /* eslint no-console: "off" */ 2 | 3 | var asynckit = require('./') 4 | , async = require('async') 5 | , assert = require('assert') 6 | , expected = 0 7 | ; 8 | 9 | var Benchmark = require('benchmark'); 10 | var suite = new Benchmark.Suite; 11 | 12 | var source = []; 13 | for (var z = 1; z < 100; z++) 14 | { 15 | source.push(z); 16 | expected += z; 17 | } 18 | 19 | suite 20 | // add tests 21 | 22 | .add('async.map', function(deferred) 23 | { 24 | var total = 0; 25 | 26 | async.map(source, 27 | function(i, cb) 28 | { 29 | setImmediate(function() 30 | { 31 | total += i; 32 | cb(null, total); 33 | }); 34 | }, 35 | function(err, result) 36 | { 37 | assert.ifError(err); 38 | assert.equal(result[result.length - 1], expected); 39 | deferred.resolve(); 40 | }); 41 | }, {'defer': true}) 42 | 43 | 44 | .add('asynckit.parallel', function(deferred) 45 | { 46 | var total = 0; 47 | 48 | asynckit.parallel(source, 49 | function(i, cb) 50 | { 51 | setImmediate(function() 52 | { 53 | total += i; 54 | cb(null, total); 55 | }); 56 | }, 57 | function(err, result) 58 | { 59 | assert.ifError(err); 60 | assert.equal(result[result.length - 1], expected); 61 | deferred.resolve(); 62 | }); 63 | }, {'defer': true}) 64 | 65 | 66 | // add listeners 67 | .on('cycle', function(ev) 68 | { 69 | console.log(String(ev.target)); 70 | }) 71 | .on('complete', function() 72 | { 73 | console.log('Fastest is ' + this.filter('fastest').map('name')); 74 | }) 75 | // run async 76 | .run({ 'async': true }); 77 | -------------------------------------------------------------------------------- /node_modules/asynckit/index.js: -------------------------------------------------------------------------------- 1 | module.exports = 2 | { 3 | parallel : require('./parallel.js'), 4 | serial : require('./serial.js'), 5 | serialOrdered : require('./serialOrdered.js') 6 | }; 7 | -------------------------------------------------------------------------------- /node_modules/asynckit/lib/abort.js: -------------------------------------------------------------------------------- 1 | // API 2 | module.exports = abort; 3 | 4 | /** 5 | * Aborts leftover active jobs 6 | * 7 | * @param {object} state - current state object 8 | */ 9 | function abort(state) 10 | { 11 | Object.keys(state.jobs).forEach(clean.bind(state)); 12 | 13 | // reset leftover jobs 14 | state.jobs = {}; 15 | } 16 | 17 | /** 18 | * Cleans up leftover job by invoking abort function for the provided job id 19 | * 20 | * @this state 21 | * @param {string|number} key - job id to abort 22 | */ 23 | function clean(key) 24 | { 25 | if (typeof this.jobs[key] == 'function') 26 | { 27 | this.jobs[key](); 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /node_modules/asynckit/lib/async.js: -------------------------------------------------------------------------------- 1 | var defer = require('./defer.js'); 2 | 3 | // API 4 | module.exports = async; 5 | 6 | /** 7 | * Runs provided callback asynchronously 8 | * even if callback itself is not 9 | * 10 | * @param {function} callback - callback to invoke 11 | * @returns {function} - augmented callback 12 | */ 13 | function async(callback) 14 | { 15 | var isAsync = false; 16 | 17 | // check if async happened 18 | defer(function() { isAsync = true; }); 19 | 20 | return function async_callback(err, result) 21 | { 22 | if (isAsync) 23 | { 24 | callback(err, result); 25 | } 26 | else 27 | { 28 | defer(function nextTick_callback() 29 | { 30 | callback(err, result); 31 | }); 32 | } 33 | }; 34 | } 35 | -------------------------------------------------------------------------------- /node_modules/asynckit/lib/defer.js: -------------------------------------------------------------------------------- 1 | module.exports = defer; 2 | 3 | /** 4 | * Runs provided function on next iteration of the event loop 5 | * 6 | * @param {function} fn - function to run 7 | */ 8 | function defer(fn) 9 | { 10 | var nextTick = typeof setImmediate == 'function' 11 | ? setImmediate 12 | : ( 13 | typeof process == 'object' && typeof process.nextTick == 'function' 14 | ? process.nextTick 15 | : null 16 | ); 17 | 18 | if (nextTick) 19 | { 20 | nextTick(fn); 21 | } 22 | else 23 | { 24 | setTimeout(fn, 0); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /node_modules/asynckit/lib/iterate.js: -------------------------------------------------------------------------------- 1 | var async = require('./async.js') 2 | , abort = require('./abort.js') 3 | ; 4 | 5 | // API 6 | module.exports = iterate; 7 | 8 | /** 9 | * Iterates over each job object 10 | * 11 | * @param {array|object} list - array or object (named list) to iterate over 12 | * @param {function} iterator - iterator to run 13 | * @param {object} state - current job status 14 | * @param {function} callback - invoked when all elements processed 15 | */ 16 | function iterate(list, iterator, state, callback) 17 | { 18 | // store current index 19 | var key = state['keyedList'] ? state['keyedList'][state.index] : state.index; 20 | 21 | state.jobs[key] = runJob(iterator, key, list[key], function(error, output) 22 | { 23 | // don't repeat yourself 24 | // skip secondary callbacks 25 | if (!(key in state.jobs)) 26 | { 27 | return; 28 | } 29 | 30 | // clean up jobs 31 | delete state.jobs[key]; 32 | 33 | if (error) 34 | { 35 | // don't process rest of the results 36 | // stop still active jobs 37 | // and reset the list 38 | abort(state); 39 | } 40 | else 41 | { 42 | state.results[key] = output; 43 | } 44 | 45 | // return salvaged results 46 | callback(error, state.results); 47 | }); 48 | } 49 | 50 | /** 51 | * Runs iterator over provided job element 52 | * 53 | * @param {function} iterator - iterator to invoke 54 | * @param {string|number} key - key/index of the element in the list of jobs 55 | * @param {mixed} item - job description 56 | * @param {function} callback - invoked after iterator is done with the job 57 | * @returns {function|mixed} - job abort function or something else 58 | */ 59 | function runJob(iterator, key, item, callback) 60 | { 61 | var aborter; 62 | 63 | // allow shortcut if iterator expects only two arguments 64 | if (iterator.length == 2) 65 | { 66 | aborter = iterator(item, async(callback)); 67 | } 68 | // otherwise go with full three arguments 69 | else 70 | { 71 | aborter = iterator(item, key, async(callback)); 72 | } 73 | 74 | return aborter; 75 | } 76 | -------------------------------------------------------------------------------- /node_modules/asynckit/lib/readable_asynckit.js: -------------------------------------------------------------------------------- 1 | var streamify = require('./streamify.js') 2 | , defer = require('./defer.js') 3 | ; 4 | 5 | // API 6 | module.exports = ReadableAsyncKit; 7 | 8 | /** 9 | * Base constructor for all streams 10 | * used to hold properties/methods 11 | */ 12 | function ReadableAsyncKit() 13 | { 14 | ReadableAsyncKit.super_.apply(this, arguments); 15 | 16 | // list of active jobs 17 | this.jobs = {}; 18 | 19 | // add stream methods 20 | this.destroy = destroy; 21 | this._start = _start; 22 | this._read = _read; 23 | } 24 | 25 | /** 26 | * Destroys readable stream, 27 | * by aborting outstanding jobs 28 | * 29 | * @returns {void} 30 | */ 31 | function destroy() 32 | { 33 | if (this.destroyed) 34 | { 35 | return; 36 | } 37 | 38 | this.destroyed = true; 39 | 40 | if (typeof this.terminator == 'function') 41 | { 42 | this.terminator(); 43 | } 44 | } 45 | 46 | /** 47 | * Starts provided jobs in async manner 48 | * 49 | * @private 50 | */ 51 | function _start() 52 | { 53 | // first argument – runner function 54 | var runner = arguments[0] 55 | // take away first argument 56 | , args = Array.prototype.slice.call(arguments, 1) 57 | // second argument - input data 58 | , input = args[0] 59 | // last argument - result callback 60 | , endCb = streamify.callback.call(this, args[args.length - 1]) 61 | ; 62 | 63 | args[args.length - 1] = endCb; 64 | // third argument - iterator 65 | args[1] = streamify.iterator.call(this, args[1]); 66 | 67 | // allow time for proper setup 68 | defer(function() 69 | { 70 | if (!this.destroyed) 71 | { 72 | this.terminator = runner.apply(null, args); 73 | } 74 | else 75 | { 76 | endCb(null, Array.isArray(input) ? [] : {}); 77 | } 78 | }.bind(this)); 79 | } 80 | 81 | 82 | /** 83 | * Implement _read to comply with Readable streams 84 | * Doesn't really make sense for flowing object mode 85 | * 86 | * @private 87 | */ 88 | function _read() 89 | { 90 | 91 | } 92 | -------------------------------------------------------------------------------- /node_modules/asynckit/lib/readable_parallel.js: -------------------------------------------------------------------------------- 1 | var parallel = require('../parallel.js'); 2 | 3 | // API 4 | module.exports = ReadableParallel; 5 | 6 | /** 7 | * Streaming wrapper to `asynckit.parallel` 8 | * 9 | * @param {array|object} list - array or object (named list) to iterate over 10 | * @param {function} iterator - iterator to run 11 | * @param {function} callback - invoked when all elements processed 12 | * @returns {stream.Readable#} 13 | */ 14 | function ReadableParallel(list, iterator, callback) 15 | { 16 | if (!(this instanceof ReadableParallel)) 17 | { 18 | return new ReadableParallel(list, iterator, callback); 19 | } 20 | 21 | // turn on object mode 22 | ReadableParallel.super_.call(this, {objectMode: true}); 23 | 24 | this._start(parallel, list, iterator, callback); 25 | } 26 | -------------------------------------------------------------------------------- /node_modules/asynckit/lib/readable_serial.js: -------------------------------------------------------------------------------- 1 | var serial = require('../serial.js'); 2 | 3 | // API 4 | module.exports = ReadableSerial; 5 | 6 | /** 7 | * Streaming wrapper to `asynckit.serial` 8 | * 9 | * @param {array|object} list - array or object (named list) to iterate over 10 | * @param {function} iterator - iterator to run 11 | * @param {function} callback - invoked when all elements processed 12 | * @returns {stream.Readable#} 13 | */ 14 | function ReadableSerial(list, iterator, callback) 15 | { 16 | if (!(this instanceof ReadableSerial)) 17 | { 18 | return new ReadableSerial(list, iterator, callback); 19 | } 20 | 21 | // turn on object mode 22 | ReadableSerial.super_.call(this, {objectMode: true}); 23 | 24 | this._start(serial, list, iterator, callback); 25 | } 26 | -------------------------------------------------------------------------------- /node_modules/asynckit/lib/readable_serial_ordered.js: -------------------------------------------------------------------------------- 1 | var serialOrdered = require('../serialOrdered.js'); 2 | 3 | // API 4 | module.exports = ReadableSerialOrdered; 5 | // expose sort helpers 6 | module.exports.ascending = serialOrdered.ascending; 7 | module.exports.descending = serialOrdered.descending; 8 | 9 | /** 10 | * Streaming wrapper to `asynckit.serialOrdered` 11 | * 12 | * @param {array|object} list - array or object (named list) to iterate over 13 | * @param {function} iterator - iterator to run 14 | * @param {function} sortMethod - custom sort function 15 | * @param {function} callback - invoked when all elements processed 16 | * @returns {stream.Readable#} 17 | */ 18 | function ReadableSerialOrdered(list, iterator, sortMethod, callback) 19 | { 20 | if (!(this instanceof ReadableSerialOrdered)) 21 | { 22 | return new ReadableSerialOrdered(list, iterator, sortMethod, callback); 23 | } 24 | 25 | // turn on object mode 26 | ReadableSerialOrdered.super_.call(this, {objectMode: true}); 27 | 28 | this._start(serialOrdered, list, iterator, sortMethod, callback); 29 | } 30 | -------------------------------------------------------------------------------- /node_modules/asynckit/lib/state.js: -------------------------------------------------------------------------------- 1 | // API 2 | module.exports = state; 3 | 4 | /** 5 | * Creates initial state object 6 | * for iteration over list 7 | * 8 | * @param {array|object} list - list to iterate over 9 | * @param {function|null} sortMethod - function to use for keys sort, 10 | * or `null` to keep them as is 11 | * @returns {object} - initial state object 12 | */ 13 | function state(list, sortMethod) 14 | { 15 | var isNamedList = !Array.isArray(list) 16 | , initState = 17 | { 18 | index : 0, 19 | keyedList: isNamedList || sortMethod ? Object.keys(list) : null, 20 | jobs : {}, 21 | results : isNamedList ? {} : [], 22 | size : isNamedList ? Object.keys(list).length : list.length 23 | } 24 | ; 25 | 26 | if (sortMethod) 27 | { 28 | // sort array keys based on it's values 29 | // sort object's keys just on own merit 30 | initState.keyedList.sort(isNamedList ? sortMethod : function(a, b) 31 | { 32 | return sortMethod(list[a], list[b]); 33 | }); 34 | } 35 | 36 | return initState; 37 | } 38 | -------------------------------------------------------------------------------- /node_modules/asynckit/lib/streamify.js: -------------------------------------------------------------------------------- 1 | var async = require('./async.js'); 2 | 3 | // API 4 | module.exports = { 5 | iterator: wrapIterator, 6 | callback: wrapCallback 7 | }; 8 | 9 | /** 10 | * Wraps iterators with long signature 11 | * 12 | * @this ReadableAsyncKit# 13 | * @param {function} iterator - function to wrap 14 | * @returns {function} - wrapped function 15 | */ 16 | function wrapIterator(iterator) 17 | { 18 | var stream = this; 19 | 20 | return function(item, key, cb) 21 | { 22 | var aborter 23 | , wrappedCb = async(wrapIteratorCallback.call(stream, cb, key)) 24 | ; 25 | 26 | stream.jobs[key] = wrappedCb; 27 | 28 | // it's either shortcut (item, cb) 29 | if (iterator.length == 2) 30 | { 31 | aborter = iterator(item, wrappedCb); 32 | } 33 | // or long format (item, key, cb) 34 | else 35 | { 36 | aborter = iterator(item, key, wrappedCb); 37 | } 38 | 39 | return aborter; 40 | }; 41 | } 42 | 43 | /** 44 | * Wraps provided callback function 45 | * allowing to execute snitch function before 46 | * real callback 47 | * 48 | * @this ReadableAsyncKit# 49 | * @param {function} callback - function to wrap 50 | * @returns {function} - wrapped function 51 | */ 52 | function wrapCallback(callback) 53 | { 54 | var stream = this; 55 | 56 | var wrapped = function(error, result) 57 | { 58 | return finisher.call(stream, error, result, callback); 59 | }; 60 | 61 | return wrapped; 62 | } 63 | 64 | /** 65 | * Wraps provided iterator callback function 66 | * makes sure snitch only called once, 67 | * but passes secondary calls to the original callback 68 | * 69 | * @this ReadableAsyncKit# 70 | * @param {function} callback - callback to wrap 71 | * @param {number|string} key - iteration key 72 | * @returns {function} wrapped callback 73 | */ 74 | function wrapIteratorCallback(callback, key) 75 | { 76 | var stream = this; 77 | 78 | return function(error, output) 79 | { 80 | // don't repeat yourself 81 | if (!(key in stream.jobs)) 82 | { 83 | callback(error, output); 84 | return; 85 | } 86 | 87 | // clean up jobs 88 | delete stream.jobs[key]; 89 | 90 | return streamer.call(stream, error, {key: key, value: output}, callback); 91 | }; 92 | } 93 | 94 | /** 95 | * Stream wrapper for iterator callback 96 | * 97 | * @this ReadableAsyncKit# 98 | * @param {mixed} error - error response 99 | * @param {mixed} output - iterator output 100 | * @param {function} callback - callback that expects iterator results 101 | */ 102 | function streamer(error, output, callback) 103 | { 104 | if (error && !this.error) 105 | { 106 | this.error = error; 107 | this.pause(); 108 | this.emit('error', error); 109 | // send back value only, as expected 110 | callback(error, output && output.value); 111 | return; 112 | } 113 | 114 | // stream stuff 115 | this.push(output); 116 | 117 | // back to original track 118 | // send back value only, as expected 119 | callback(error, output && output.value); 120 | } 121 | 122 | /** 123 | * Stream wrapper for finishing callback 124 | * 125 | * @this ReadableAsyncKit# 126 | * @param {mixed} error - error response 127 | * @param {mixed} output - iterator output 128 | * @param {function} callback - callback that expects final results 129 | */ 130 | function finisher(error, output, callback) 131 | { 132 | // signal end of the stream 133 | // only for successfully finished streams 134 | if (!error) 135 | { 136 | this.push(null); 137 | } 138 | 139 | // back to original track 140 | callback(error, output); 141 | } 142 | -------------------------------------------------------------------------------- /node_modules/asynckit/lib/terminator.js: -------------------------------------------------------------------------------- 1 | var abort = require('./abort.js') 2 | , async = require('./async.js') 3 | ; 4 | 5 | // API 6 | module.exports = terminator; 7 | 8 | /** 9 | * Terminates jobs in the attached state context 10 | * 11 | * @this AsyncKitState# 12 | * @param {function} callback - final callback to invoke after termination 13 | */ 14 | function terminator(callback) 15 | { 16 | if (!Object.keys(this.jobs).length) 17 | { 18 | return; 19 | } 20 | 21 | // fast forward iteration index 22 | this.index = this.size; 23 | 24 | // abort jobs 25 | abort(this); 26 | 27 | // send back results we have so far 28 | async(callback)(null, this.results); 29 | } 30 | -------------------------------------------------------------------------------- /node_modules/asynckit/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "asynckit", 3 | "version": "0.4.0", 4 | "description": "Minimal async jobs utility library, with streams support", 5 | "main": "index.js", 6 | "scripts": { 7 | "clean": "rimraf coverage", 8 | "lint": "eslint *.js lib/*.js test/*.js", 9 | "test": "istanbul cover --reporter=json tape -- 'test/test-*.js' | tap-spec", 10 | "win-test": "tape test/test-*.js", 11 | "browser": "browserify -t browserify-istanbul test/lib/browserify_adjustment.js test/test-*.js | obake --coverage | tap-spec", 12 | "report": "istanbul report", 13 | "size": "browserify index.js | size-table asynckit", 14 | "debug": "tape test/test-*.js" 15 | }, 16 | "pre-commit": [ 17 | "clean", 18 | "lint", 19 | "test", 20 | "browser", 21 | "report", 22 | "size" 23 | ], 24 | "repository": { 25 | "type": "git", 26 | "url": "git+https://github.com/alexindigo/asynckit.git" 27 | }, 28 | "keywords": [ 29 | "async", 30 | "jobs", 31 | "parallel", 32 | "serial", 33 | "iterator", 34 | "array", 35 | "object", 36 | "stream", 37 | "destroy", 38 | "terminate", 39 | "abort" 40 | ], 41 | "author": "Alex Indigo ", 42 | "license": "MIT", 43 | "bugs": { 44 | "url": "https://github.com/alexindigo/asynckit/issues" 45 | }, 46 | "homepage": "https://github.com/alexindigo/asynckit#readme", 47 | "devDependencies": { 48 | "browserify": "^13.0.0", 49 | "browserify-istanbul": "^2.0.0", 50 | "coveralls": "^2.11.9", 51 | "eslint": "^2.9.0", 52 | "istanbul": "^0.4.3", 53 | "obake": "^0.1.2", 54 | "phantomjs-prebuilt": "^2.1.7", 55 | "pre-commit": "^1.1.3", 56 | "reamde": "^1.1.0", 57 | "rimraf": "^2.5.2", 58 | "size-table": "^0.2.0", 59 | "tap-spec": "^4.1.1", 60 | "tape": "^4.5.1" 61 | }, 62 | "dependencies": {} 63 | } 64 | -------------------------------------------------------------------------------- /node_modules/asynckit/parallel.js: -------------------------------------------------------------------------------- 1 | var iterate = require('./lib/iterate.js') 2 | , initState = require('./lib/state.js') 3 | , terminator = require('./lib/terminator.js') 4 | ; 5 | 6 | // Public API 7 | module.exports = parallel; 8 | 9 | /** 10 | * Runs iterator over provided array elements in parallel 11 | * 12 | * @param {array|object} list - array or object (named list) to iterate over 13 | * @param {function} iterator - iterator to run 14 | * @param {function} callback - invoked when all elements processed 15 | * @returns {function} - jobs terminator 16 | */ 17 | function parallel(list, iterator, callback) 18 | { 19 | var state = initState(list); 20 | 21 | while (state.index < (state['keyedList'] || list).length) 22 | { 23 | iterate(list, iterator, state, function(error, result) 24 | { 25 | if (error) 26 | { 27 | callback(error, result); 28 | return; 29 | } 30 | 31 | // looks like it's the last one 32 | if (Object.keys(state.jobs).length === 0) 33 | { 34 | callback(null, state.results); 35 | return; 36 | } 37 | }); 38 | 39 | state.index++; 40 | } 41 | 42 | return terminator.bind(state, callback); 43 | } 44 | -------------------------------------------------------------------------------- /node_modules/asynckit/serial.js: -------------------------------------------------------------------------------- 1 | var serialOrdered = require('./serialOrdered.js'); 2 | 3 | // Public API 4 | module.exports = serial; 5 | 6 | /** 7 | * Runs iterator over provided array elements in series 8 | * 9 | * @param {array|object} list - array or object (named list) to iterate over 10 | * @param {function} iterator - iterator to run 11 | * @param {function} callback - invoked when all elements processed 12 | * @returns {function} - jobs terminator 13 | */ 14 | function serial(list, iterator, callback) 15 | { 16 | return serialOrdered(list, iterator, null, callback); 17 | } 18 | -------------------------------------------------------------------------------- /node_modules/asynckit/serialOrdered.js: -------------------------------------------------------------------------------- 1 | var iterate = require('./lib/iterate.js') 2 | , initState = require('./lib/state.js') 3 | , terminator = require('./lib/terminator.js') 4 | ; 5 | 6 | // Public API 7 | module.exports = serialOrdered; 8 | // sorting helpers 9 | module.exports.ascending = ascending; 10 | module.exports.descending = descending; 11 | 12 | /** 13 | * Runs iterator over provided sorted array elements in series 14 | * 15 | * @param {array|object} list - array or object (named list) to iterate over 16 | * @param {function} iterator - iterator to run 17 | * @param {function} sortMethod - custom sort function 18 | * @param {function} callback - invoked when all elements processed 19 | * @returns {function} - jobs terminator 20 | */ 21 | function serialOrdered(list, iterator, sortMethod, callback) 22 | { 23 | var state = initState(list, sortMethod); 24 | 25 | iterate(list, iterator, state, function iteratorHandler(error, result) 26 | { 27 | if (error) 28 | { 29 | callback(error, result); 30 | return; 31 | } 32 | 33 | state.index++; 34 | 35 | // are we there yet? 36 | if (state.index < (state['keyedList'] || list).length) 37 | { 38 | iterate(list, iterator, state, iteratorHandler); 39 | return; 40 | } 41 | 42 | // done here 43 | callback(null, state.results); 44 | }); 45 | 46 | return terminator.bind(state, callback); 47 | } 48 | 49 | /* 50 | * -- Sort methods 51 | */ 52 | 53 | /** 54 | * sort helper to sort array elements in ascending order 55 | * 56 | * @param {mixed} a - an item to compare 57 | * @param {mixed} b - an item to compare 58 | * @returns {number} - comparison result 59 | */ 60 | function ascending(a, b) 61 | { 62 | return a < b ? -1 : a > b ? 1 : 0; 63 | } 64 | 65 | /** 66 | * sort helper to sort array elements in descending order 67 | * 68 | * @param {mixed} a - an item to compare 69 | * @param {mixed} b - an item to compare 70 | * @returns {number} - comparison result 71 | */ 72 | function descending(a, b) 73 | { 74 | return -1 * ascending(a, b); 75 | } 76 | -------------------------------------------------------------------------------- /node_modules/asynckit/stream.js: -------------------------------------------------------------------------------- 1 | var inherits = require('util').inherits 2 | , Readable = require('stream').Readable 3 | , ReadableAsyncKit = require('./lib/readable_asynckit.js') 4 | , ReadableParallel = require('./lib/readable_parallel.js') 5 | , ReadableSerial = require('./lib/readable_serial.js') 6 | , ReadableSerialOrdered = require('./lib/readable_serial_ordered.js') 7 | ; 8 | 9 | // API 10 | module.exports = 11 | { 12 | parallel : ReadableParallel, 13 | serial : ReadableSerial, 14 | serialOrdered : ReadableSerialOrdered, 15 | }; 16 | 17 | inherits(ReadableAsyncKit, Readable); 18 | 19 | inherits(ReadableParallel, ReadableAsyncKit); 20 | inherits(ReadableSerial, ReadableAsyncKit); 21 | inherits(ReadableSerialOrdered, ReadableAsyncKit); 22 | -------------------------------------------------------------------------------- /node_modules/axios/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2014-present Matt Zabriskie 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining a copy 4 | of this software and associated documentation files (the "Software"), to deal 5 | in the Software without restriction, including without limitation the rights 6 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | copies of the Software, and to permit persons to whom the Software is 8 | furnished to do so, subject to the following conditions: 9 | 10 | The above copyright notice and this permission notice shall be included in 11 | all copies or substantial portions of the Software. 12 | 13 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 19 | THE SOFTWARE. 20 | -------------------------------------------------------------------------------- /node_modules/axios/SECURITY.md: -------------------------------------------------------------------------------- 1 | # Security Policy 2 | 3 | ## Reporting a Vulnerability 4 | 5 | Please report security issues to jasonsaayman@gmail.com 6 | -------------------------------------------------------------------------------- /node_modules/axios/UPGRADE_GUIDE.md: -------------------------------------------------------------------------------- 1 | # Upgrade Guide 2 | 3 | ### 0.18.x -> 0.19.0 4 | 5 | #### HTTPS Proxies 6 | 7 | Routing through an https proxy now requires setting the `protocol` attribute of the proxy configuration to `https` 8 | 9 | ### 0.15.x -> 0.16.0 10 | 11 | #### `Promise` Type Declarations 12 | 13 | The `Promise` type declarations have been removed from the axios typings in favor of the built-in type declarations. If you use axios in a TypeScript project that targets `ES5`, please make sure to include the `es2015.promise` lib. Please see [this post](https://blog.mariusschulz.com/2016/11/25/typescript-2-0-built-in-type-declarations) for details. 14 | 15 | ### 0.13.x -> 0.14.0 16 | 17 | #### TypeScript Definitions 18 | 19 | The axios TypeScript definitions have been updated to match the axios API and use the ES2015 module syntax. 20 | 21 | Please use the following `import` statement to import axios in TypeScript: 22 | 23 | ```typescript 24 | import axios from 'axios'; 25 | 26 | axios.get('/foo') 27 | .then(response => console.log(response)) 28 | .catch(error => console.log(error)); 29 | ``` 30 | 31 | #### `agent` Config Option 32 | 33 | The `agent` config option has been replaced with two new options: `httpAgent` and `httpsAgent`. Please use them instead. 34 | 35 | ```js 36 | { 37 | // Define a custom agent for HTTP 38 | httpAgent: new http.Agent({ keepAlive: true }), 39 | // Define a custom agent for HTTPS 40 | httpsAgent: new https.Agent({ keepAlive: true }) 41 | } 42 | ``` 43 | 44 | #### `progress` Config Option 45 | 46 | The `progress` config option has been replaced with the `onUploadProgress` and `onDownloadProgress` options. 47 | 48 | ```js 49 | { 50 | // Define a handler for upload progress events 51 | onUploadProgress: function (progressEvent) { 52 | // ... 53 | }, 54 | 55 | // Define a handler for download progress events 56 | onDownloadProgress: function (progressEvent) { 57 | // ... 58 | } 59 | } 60 | ``` 61 | 62 | ### 0.12.x -> 0.13.0 63 | 64 | The `0.13.0` release contains several changes to custom adapters and error handling. 65 | 66 | #### Error Handling 67 | 68 | Previous to this release an error could either be a server response with bad status code or an actual `Error`. With this release Promise will always reject with an `Error`. In the case that a response was received, the `Error` will also include the response. 69 | 70 | ```js 71 | axios.get('/user/12345') 72 | .catch((error) => { 73 | console.log(error.message); 74 | console.log(error.code); // Not always specified 75 | console.log(error.config); // The config that was used to make the request 76 | console.log(error.response); // Only available if response was received from the server 77 | }); 78 | ``` 79 | 80 | #### Request Adapters 81 | 82 | This release changes a few things about how request adapters work. Please take note if you are using your own custom adapter. 83 | 84 | 1. Response transformer is now called outside of adapter. 85 | 2. Request adapter returns a `Promise`. 86 | 87 | This means that you no longer need to invoke `transformData` on response data. You will also no longer receive `resolve` and `reject` as arguments in your adapter. 88 | 89 | Previous code: 90 | 91 | ```js 92 | function myAdapter(resolve, reject, config) { 93 | var response = { 94 | data: transformData( 95 | responseData, 96 | responseHeaders, 97 | config.transformResponse 98 | ), 99 | status: request.status, 100 | statusText: request.statusText, 101 | headers: responseHeaders 102 | }; 103 | settle(resolve, reject, response); 104 | } 105 | ``` 106 | 107 | New code: 108 | 109 | ```js 110 | function myAdapter(config) { 111 | return new Promise(function (resolve, reject) { 112 | var response = { 113 | data: responseData, 114 | status: request.status, 115 | statusText: request.statusText, 116 | headers: responseHeaders 117 | }; 118 | settle(resolve, reject, response); 119 | }); 120 | } 121 | ``` 122 | 123 | See the related commits for more details: 124 | - [Response transformers](https://github.com/axios/axios/commit/10eb23865101f9347570552c04e9d6211376e25e) 125 | - [Request adapter Promise](https://github.com/axios/axios/commit/157efd5615890301824e3121cc6c9d2f9b21f94a) 126 | 127 | ### 0.5.x -> 0.6.0 128 | 129 | The `0.6.0` release contains mostly bug fixes, but there are a couple things to be aware of when upgrading. 130 | 131 | #### ES6 Promise Polyfill 132 | 133 | Up until the `0.6.0` release ES6 `Promise` was being polyfilled using [es6-promise](https://github.com/jakearchibald/es6-promise). With this release, the polyfill has been removed, and you will need to supply it yourself if your environment needs it. 134 | 135 | ```js 136 | require('es6-promise').polyfill(); 137 | var axios = require('axios'); 138 | ``` 139 | 140 | This will polyfill the global environment, and only needs to be done once. 141 | 142 | #### `axios.success`/`axios.error` 143 | 144 | The `success`, and `error` aliases were deprecated in [0.4.0](https://github.com/axios/axios/blob/master/CHANGELOG.md#040-oct-03-2014). As of this release they have been removed entirely. Instead please use `axios.then`, and `axios.catch` respectively. 145 | 146 | ```js 147 | axios.get('some/url') 148 | .then(function (res) { 149 | /* ... */ 150 | }) 151 | .catch(function (err) { 152 | /* ... */ 153 | }); 154 | ``` 155 | 156 | #### UMD 157 | 158 | Previous versions of axios shipped with an AMD, CommonJS, and Global build. This has all been rolled into a single UMD build. 159 | 160 | ```js 161 | // AMD 162 | require(['bower_components/axios/dist/axios'], function (axios) { 163 | /* ... */ 164 | }); 165 | 166 | // CommonJS 167 | var axios = require('axios/dist/axios'); 168 | ``` 169 | -------------------------------------------------------------------------------- /node_modules/axios/index.js: -------------------------------------------------------------------------------- 1 | module.exports = require('./lib/axios'); -------------------------------------------------------------------------------- /node_modules/axios/lib/adapters/README.md: -------------------------------------------------------------------------------- 1 | # axios // adapters 2 | 3 | The modules under `adapters/` are modules that handle dispatching a request and settling a returned `Promise` once a response is received. 4 | 5 | ## Example 6 | 7 | ```js 8 | var settle = require('./../core/settle'); 9 | 10 | module.exports = function myAdapter(config) { 11 | // At this point: 12 | // - config has been merged with defaults 13 | // - request transformers have already run 14 | // - request interceptors have already run 15 | 16 | // Make the request using config provided 17 | // Upon response settle the Promise 18 | 19 | return new Promise(function(resolve, reject) { 20 | 21 | var response = { 22 | data: responseData, 23 | status: request.status, 24 | statusText: request.statusText, 25 | headers: responseHeaders, 26 | config: config, 27 | request: request 28 | }; 29 | 30 | settle(resolve, reject, response); 31 | 32 | // From here: 33 | // - response transformers will run 34 | // - response interceptors will run 35 | }); 36 | } 37 | ``` 38 | -------------------------------------------------------------------------------- /node_modules/axios/lib/axios.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | var utils = require('./utils'); 4 | var bind = require('./helpers/bind'); 5 | var Axios = require('./core/Axios'); 6 | var mergeConfig = require('./core/mergeConfig'); 7 | var defaults = require('./defaults'); 8 | 9 | /** 10 | * Create an instance of Axios 11 | * 12 | * @param {Object} defaultConfig The default config for the instance 13 | * @return {Axios} A new instance of Axios 14 | */ 15 | function createInstance(defaultConfig) { 16 | var context = new Axios(defaultConfig); 17 | var instance = bind(Axios.prototype.request, context); 18 | 19 | // Copy axios.prototype to instance 20 | utils.extend(instance, Axios.prototype, context); 21 | 22 | // Copy context to instance 23 | utils.extend(instance, context); 24 | 25 | // Factory for creating new instances 26 | instance.create = function create(instanceConfig) { 27 | return createInstance(mergeConfig(defaultConfig, instanceConfig)); 28 | }; 29 | 30 | return instance; 31 | } 32 | 33 | // Create the default instance to be exported 34 | var axios = createInstance(defaults); 35 | 36 | // Expose Axios class to allow class inheritance 37 | axios.Axios = Axios; 38 | 39 | // Expose Cancel & CancelToken 40 | axios.Cancel = require('./cancel/Cancel'); 41 | axios.CancelToken = require('./cancel/CancelToken'); 42 | axios.isCancel = require('./cancel/isCancel'); 43 | axios.VERSION = require('./env/data').version; 44 | 45 | // Expose all/spread 46 | axios.all = function all(promises) { 47 | return Promise.all(promises); 48 | }; 49 | axios.spread = require('./helpers/spread'); 50 | 51 | // Expose isAxiosError 52 | axios.isAxiosError = require('./helpers/isAxiosError'); 53 | 54 | module.exports = axios; 55 | 56 | // Allow use of default import syntax in TypeScript 57 | module.exports.default = axios; 58 | -------------------------------------------------------------------------------- /node_modules/axios/lib/cancel/Cancel.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | /** 4 | * A `Cancel` is an object that is thrown when an operation is canceled. 5 | * 6 | * @class 7 | * @param {string=} message The message. 8 | */ 9 | function Cancel(message) { 10 | this.message = message; 11 | } 12 | 13 | Cancel.prototype.toString = function toString() { 14 | return 'Cancel' + (this.message ? ': ' + this.message : ''); 15 | }; 16 | 17 | Cancel.prototype.__CANCEL__ = true; 18 | 19 | module.exports = Cancel; 20 | -------------------------------------------------------------------------------- /node_modules/axios/lib/cancel/CancelToken.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | var Cancel = require('./Cancel'); 4 | 5 | /** 6 | * A `CancelToken` is an object that can be used to request cancellation of an operation. 7 | * 8 | * @class 9 | * @param {Function} executor The executor function. 10 | */ 11 | function CancelToken(executor) { 12 | if (typeof executor !== 'function') { 13 | throw new TypeError('executor must be a function.'); 14 | } 15 | 16 | var resolvePromise; 17 | 18 | this.promise = new Promise(function promiseExecutor(resolve) { 19 | resolvePromise = resolve; 20 | }); 21 | 22 | var token = this; 23 | 24 | // eslint-disable-next-line func-names 25 | this.promise.then(function(cancel) { 26 | if (!token._listeners) return; 27 | 28 | var i; 29 | var l = token._listeners.length; 30 | 31 | for (i = 0; i < l; i++) { 32 | token._listeners[i](cancel); 33 | } 34 | token._listeners = null; 35 | }); 36 | 37 | // eslint-disable-next-line func-names 38 | this.promise.then = function(onfulfilled) { 39 | var _resolve; 40 | // eslint-disable-next-line func-names 41 | var promise = new Promise(function(resolve) { 42 | token.subscribe(resolve); 43 | _resolve = resolve; 44 | }).then(onfulfilled); 45 | 46 | promise.cancel = function reject() { 47 | token.unsubscribe(_resolve); 48 | }; 49 | 50 | return promise; 51 | }; 52 | 53 | executor(function cancel(message) { 54 | if (token.reason) { 55 | // Cancellation has already been requested 56 | return; 57 | } 58 | 59 | token.reason = new Cancel(message); 60 | resolvePromise(token.reason); 61 | }); 62 | } 63 | 64 | /** 65 | * Throws a `Cancel` if cancellation has been requested. 66 | */ 67 | CancelToken.prototype.throwIfRequested = function throwIfRequested() { 68 | if (this.reason) { 69 | throw this.reason; 70 | } 71 | }; 72 | 73 | /** 74 | * Subscribe to the cancel signal 75 | */ 76 | 77 | CancelToken.prototype.subscribe = function subscribe(listener) { 78 | if (this.reason) { 79 | listener(this.reason); 80 | return; 81 | } 82 | 83 | if (this._listeners) { 84 | this._listeners.push(listener); 85 | } else { 86 | this._listeners = [listener]; 87 | } 88 | }; 89 | 90 | /** 91 | * Unsubscribe from the cancel signal 92 | */ 93 | 94 | CancelToken.prototype.unsubscribe = function unsubscribe(listener) { 95 | if (!this._listeners) { 96 | return; 97 | } 98 | var index = this._listeners.indexOf(listener); 99 | if (index !== -1) { 100 | this._listeners.splice(index, 1); 101 | } 102 | }; 103 | 104 | /** 105 | * Returns an object that contains a new `CancelToken` and a function that, when called, 106 | * cancels the `CancelToken`. 107 | */ 108 | CancelToken.source = function source() { 109 | var cancel; 110 | var token = new CancelToken(function executor(c) { 111 | cancel = c; 112 | }); 113 | return { 114 | token: token, 115 | cancel: cancel 116 | }; 117 | }; 118 | 119 | module.exports = CancelToken; 120 | -------------------------------------------------------------------------------- /node_modules/axios/lib/cancel/isCancel.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | module.exports = function isCancel(value) { 4 | return !!(value && value.__CANCEL__); 5 | }; 6 | -------------------------------------------------------------------------------- /node_modules/axios/lib/core/Axios.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | var utils = require('./../utils'); 4 | var buildURL = require('../helpers/buildURL'); 5 | var InterceptorManager = require('./InterceptorManager'); 6 | var dispatchRequest = require('./dispatchRequest'); 7 | var mergeConfig = require('./mergeConfig'); 8 | var validator = require('../helpers/validator'); 9 | 10 | var validators = validator.validators; 11 | /** 12 | * Create a new instance of Axios 13 | * 14 | * @param {Object} instanceConfig The default config for the instance 15 | */ 16 | function Axios(instanceConfig) { 17 | this.defaults = instanceConfig; 18 | this.interceptors = { 19 | request: new InterceptorManager(), 20 | response: new InterceptorManager() 21 | }; 22 | } 23 | 24 | /** 25 | * Dispatch a request 26 | * 27 | * @param {Object} config The config specific for this request (merged with this.defaults) 28 | */ 29 | Axios.prototype.request = function request(configOrUrl, config) { 30 | /*eslint no-param-reassign:0*/ 31 | // Allow for axios('example/url'[, config]) a la fetch API 32 | if (typeof configOrUrl === 'string') { 33 | config = config || {}; 34 | config.url = configOrUrl; 35 | } else { 36 | config = configOrUrl || {}; 37 | } 38 | 39 | config = mergeConfig(this.defaults, config); 40 | 41 | // Set config.method 42 | if (config.method) { 43 | config.method = config.method.toLowerCase(); 44 | } else if (this.defaults.method) { 45 | config.method = this.defaults.method.toLowerCase(); 46 | } else { 47 | config.method = 'get'; 48 | } 49 | 50 | var transitional = config.transitional; 51 | 52 | if (transitional !== undefined) { 53 | validator.assertOptions(transitional, { 54 | silentJSONParsing: validators.transitional(validators.boolean), 55 | forcedJSONParsing: validators.transitional(validators.boolean), 56 | clarifyTimeoutError: validators.transitional(validators.boolean) 57 | }, false); 58 | } 59 | 60 | // filter out skipped interceptors 61 | var requestInterceptorChain = []; 62 | var synchronousRequestInterceptors = true; 63 | this.interceptors.request.forEach(function unshiftRequestInterceptors(interceptor) { 64 | if (typeof interceptor.runWhen === 'function' && interceptor.runWhen(config) === false) { 65 | return; 66 | } 67 | 68 | synchronousRequestInterceptors = synchronousRequestInterceptors && interceptor.synchronous; 69 | 70 | requestInterceptorChain.unshift(interceptor.fulfilled, interceptor.rejected); 71 | }); 72 | 73 | var responseInterceptorChain = []; 74 | this.interceptors.response.forEach(function pushResponseInterceptors(interceptor) { 75 | responseInterceptorChain.push(interceptor.fulfilled, interceptor.rejected); 76 | }); 77 | 78 | var promise; 79 | 80 | if (!synchronousRequestInterceptors) { 81 | var chain = [dispatchRequest, undefined]; 82 | 83 | Array.prototype.unshift.apply(chain, requestInterceptorChain); 84 | chain = chain.concat(responseInterceptorChain); 85 | 86 | promise = Promise.resolve(config); 87 | while (chain.length) { 88 | promise = promise.then(chain.shift(), chain.shift()); 89 | } 90 | 91 | return promise; 92 | } 93 | 94 | 95 | var newConfig = config; 96 | while (requestInterceptorChain.length) { 97 | var onFulfilled = requestInterceptorChain.shift(); 98 | var onRejected = requestInterceptorChain.shift(); 99 | try { 100 | newConfig = onFulfilled(newConfig); 101 | } catch (error) { 102 | onRejected(error); 103 | break; 104 | } 105 | } 106 | 107 | try { 108 | promise = dispatchRequest(newConfig); 109 | } catch (error) { 110 | return Promise.reject(error); 111 | } 112 | 113 | while (responseInterceptorChain.length) { 114 | promise = promise.then(responseInterceptorChain.shift(), responseInterceptorChain.shift()); 115 | } 116 | 117 | return promise; 118 | }; 119 | 120 | Axios.prototype.getUri = function getUri(config) { 121 | config = mergeConfig(this.defaults, config); 122 | return buildURL(config.url, config.params, config.paramsSerializer).replace(/^\?/, ''); 123 | }; 124 | 125 | // Provide aliases for supported request methods 126 | utils.forEach(['delete', 'get', 'head', 'options'], function forEachMethodNoData(method) { 127 | /*eslint func-names:0*/ 128 | Axios.prototype[method] = function(url, config) { 129 | return this.request(mergeConfig(config || {}, { 130 | method: method, 131 | url: url, 132 | data: (config || {}).data 133 | })); 134 | }; 135 | }); 136 | 137 | utils.forEach(['post', 'put', 'patch'], function forEachMethodWithData(method) { 138 | /*eslint func-names:0*/ 139 | Axios.prototype[method] = function(url, data, config) { 140 | return this.request(mergeConfig(config || {}, { 141 | method: method, 142 | url: url, 143 | data: data 144 | })); 145 | }; 146 | }); 147 | 148 | module.exports = Axios; 149 | -------------------------------------------------------------------------------- /node_modules/axios/lib/core/InterceptorManager.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | var utils = require('./../utils'); 4 | 5 | function InterceptorManager() { 6 | this.handlers = []; 7 | } 8 | 9 | /** 10 | * Add a new interceptor to the stack 11 | * 12 | * @param {Function} fulfilled The function to handle `then` for a `Promise` 13 | * @param {Function} rejected The function to handle `reject` for a `Promise` 14 | * 15 | * @return {Number} An ID used to remove interceptor later 16 | */ 17 | InterceptorManager.prototype.use = function use(fulfilled, rejected, options) { 18 | this.handlers.push({ 19 | fulfilled: fulfilled, 20 | rejected: rejected, 21 | synchronous: options ? options.synchronous : false, 22 | runWhen: options ? options.runWhen : null 23 | }); 24 | return this.handlers.length - 1; 25 | }; 26 | 27 | /** 28 | * Remove an interceptor from the stack 29 | * 30 | * @param {Number} id The ID that was returned by `use` 31 | */ 32 | InterceptorManager.prototype.eject = function eject(id) { 33 | if (this.handlers[id]) { 34 | this.handlers[id] = null; 35 | } 36 | }; 37 | 38 | /** 39 | * Iterate over all the registered interceptors 40 | * 41 | * This method is particularly useful for skipping over any 42 | * interceptors that may have become `null` calling `eject`. 43 | * 44 | * @param {Function} fn The function to call for each interceptor 45 | */ 46 | InterceptorManager.prototype.forEach = function forEach(fn) { 47 | utils.forEach(this.handlers, function forEachHandler(h) { 48 | if (h !== null) { 49 | fn(h); 50 | } 51 | }); 52 | }; 53 | 54 | module.exports = InterceptorManager; 55 | -------------------------------------------------------------------------------- /node_modules/axios/lib/core/README.md: -------------------------------------------------------------------------------- 1 | # axios // core 2 | 3 | The modules found in `core/` should be modules that are specific to the domain logic of axios. These modules would most likely not make sense to be consumed outside of the axios module, as their logic is too specific. Some examples of core modules are: 4 | 5 | - Dispatching requests 6 | - Requests sent via `adapters/` (see lib/adapters/README.md) 7 | - Managing interceptors 8 | - Handling config 9 | -------------------------------------------------------------------------------- /node_modules/axios/lib/core/buildFullPath.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | var isAbsoluteURL = require('../helpers/isAbsoluteURL'); 4 | var combineURLs = require('../helpers/combineURLs'); 5 | 6 | /** 7 | * Creates a new URL by combining the baseURL with the requestedURL, 8 | * only when the requestedURL is not already an absolute URL. 9 | * If the requestURL is absolute, this function returns the requestedURL untouched. 10 | * 11 | * @param {string} baseURL The base URL 12 | * @param {string} requestedURL Absolute or relative URL to combine 13 | * @returns {string} The combined full path 14 | */ 15 | module.exports = function buildFullPath(baseURL, requestedURL) { 16 | if (baseURL && !isAbsoluteURL(requestedURL)) { 17 | return combineURLs(baseURL, requestedURL); 18 | } 19 | return requestedURL; 20 | }; 21 | -------------------------------------------------------------------------------- /node_modules/axios/lib/core/createError.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | var enhanceError = require('./enhanceError'); 4 | 5 | /** 6 | * Create an Error with the specified message, config, error code, request and response. 7 | * 8 | * @param {string} message The error message. 9 | * @param {Object} config The config. 10 | * @param {string} [code] The error code (for example, 'ECONNABORTED'). 11 | * @param {Object} [request] The request. 12 | * @param {Object} [response] The response. 13 | * @returns {Error} The created error. 14 | */ 15 | module.exports = function createError(message, config, code, request, response) { 16 | var error = new Error(message); 17 | return enhanceError(error, config, code, request, response); 18 | }; 19 | -------------------------------------------------------------------------------- /node_modules/axios/lib/core/dispatchRequest.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | var utils = require('./../utils'); 4 | var transformData = require('./transformData'); 5 | var isCancel = require('../cancel/isCancel'); 6 | var defaults = require('../defaults'); 7 | var Cancel = require('../cancel/Cancel'); 8 | 9 | /** 10 | * Throws a `Cancel` if cancellation has been requested. 11 | */ 12 | function throwIfCancellationRequested(config) { 13 | if (config.cancelToken) { 14 | config.cancelToken.throwIfRequested(); 15 | } 16 | 17 | if (config.signal && config.signal.aborted) { 18 | throw new Cancel('canceled'); 19 | } 20 | } 21 | 22 | /** 23 | * Dispatch a request to the server using the configured adapter. 24 | * 25 | * @param {object} config The config that is to be used for the request 26 | * @returns {Promise} The Promise to be fulfilled 27 | */ 28 | module.exports = function dispatchRequest(config) { 29 | throwIfCancellationRequested(config); 30 | 31 | // Ensure headers exist 32 | config.headers = config.headers || {}; 33 | 34 | // Transform request data 35 | config.data = transformData.call( 36 | config, 37 | config.data, 38 | config.headers, 39 | config.transformRequest 40 | ); 41 | 42 | // Flatten headers 43 | config.headers = utils.merge( 44 | config.headers.common || {}, 45 | config.headers[config.method] || {}, 46 | config.headers 47 | ); 48 | 49 | utils.forEach( 50 | ['delete', 'get', 'head', 'post', 'put', 'patch', 'common'], 51 | function cleanHeaderConfig(method) { 52 | delete config.headers[method]; 53 | } 54 | ); 55 | 56 | var adapter = config.adapter || defaults.adapter; 57 | 58 | return adapter(config).then(function onAdapterResolution(response) { 59 | throwIfCancellationRequested(config); 60 | 61 | // Transform response data 62 | response.data = transformData.call( 63 | config, 64 | response.data, 65 | response.headers, 66 | config.transformResponse 67 | ); 68 | 69 | return response; 70 | }, function onAdapterRejection(reason) { 71 | if (!isCancel(reason)) { 72 | throwIfCancellationRequested(config); 73 | 74 | // Transform response data 75 | if (reason && reason.response) { 76 | reason.response.data = transformData.call( 77 | config, 78 | reason.response.data, 79 | reason.response.headers, 80 | config.transformResponse 81 | ); 82 | } 83 | } 84 | 85 | return Promise.reject(reason); 86 | }); 87 | }; 88 | -------------------------------------------------------------------------------- /node_modules/axios/lib/core/enhanceError.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | /** 4 | * Update an Error with the specified config, error code, and response. 5 | * 6 | * @param {Error} error The error to update. 7 | * @param {Object} config The config. 8 | * @param {string} [code] The error code (for example, 'ECONNABORTED'). 9 | * @param {Object} [request] The request. 10 | * @param {Object} [response] The response. 11 | * @returns {Error} The error. 12 | */ 13 | module.exports = function enhanceError(error, config, code, request, response) { 14 | error.config = config; 15 | if (code) { 16 | error.code = code; 17 | } 18 | 19 | error.request = request; 20 | error.response = response; 21 | error.isAxiosError = true; 22 | 23 | error.toJSON = function toJSON() { 24 | return { 25 | // Standard 26 | message: this.message, 27 | name: this.name, 28 | // Microsoft 29 | description: this.description, 30 | number: this.number, 31 | // Mozilla 32 | fileName: this.fileName, 33 | lineNumber: this.lineNumber, 34 | columnNumber: this.columnNumber, 35 | stack: this.stack, 36 | // Axios 37 | config: this.config, 38 | code: this.code, 39 | status: this.response && this.response.status ? this.response.status : null 40 | }; 41 | }; 42 | return error; 43 | }; 44 | -------------------------------------------------------------------------------- /node_modules/axios/lib/core/mergeConfig.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | var utils = require('../utils'); 4 | 5 | /** 6 | * Config-specific merge-function which creates a new config-object 7 | * by merging two configuration objects together. 8 | * 9 | * @param {Object} config1 10 | * @param {Object} config2 11 | * @returns {Object} New object resulting from merging config2 to config1 12 | */ 13 | module.exports = function mergeConfig(config1, config2) { 14 | // eslint-disable-next-line no-param-reassign 15 | config2 = config2 || {}; 16 | var config = {}; 17 | 18 | function getMergedValue(target, source) { 19 | if (utils.isPlainObject(target) && utils.isPlainObject(source)) { 20 | return utils.merge(target, source); 21 | } else if (utils.isPlainObject(source)) { 22 | return utils.merge({}, source); 23 | } else if (utils.isArray(source)) { 24 | return source.slice(); 25 | } 26 | return source; 27 | } 28 | 29 | // eslint-disable-next-line consistent-return 30 | function mergeDeepProperties(prop) { 31 | if (!utils.isUndefined(config2[prop])) { 32 | return getMergedValue(config1[prop], config2[prop]); 33 | } else if (!utils.isUndefined(config1[prop])) { 34 | return getMergedValue(undefined, config1[prop]); 35 | } 36 | } 37 | 38 | // eslint-disable-next-line consistent-return 39 | function valueFromConfig2(prop) { 40 | if (!utils.isUndefined(config2[prop])) { 41 | return getMergedValue(undefined, config2[prop]); 42 | } 43 | } 44 | 45 | // eslint-disable-next-line consistent-return 46 | function defaultToConfig2(prop) { 47 | if (!utils.isUndefined(config2[prop])) { 48 | return getMergedValue(undefined, config2[prop]); 49 | } else if (!utils.isUndefined(config1[prop])) { 50 | return getMergedValue(undefined, config1[prop]); 51 | } 52 | } 53 | 54 | // eslint-disable-next-line consistent-return 55 | function mergeDirectKeys(prop) { 56 | if (prop in config2) { 57 | return getMergedValue(config1[prop], config2[prop]); 58 | } else if (prop in config1) { 59 | return getMergedValue(undefined, config1[prop]); 60 | } 61 | } 62 | 63 | var mergeMap = { 64 | 'url': valueFromConfig2, 65 | 'method': valueFromConfig2, 66 | 'data': valueFromConfig2, 67 | 'baseURL': defaultToConfig2, 68 | 'transformRequest': defaultToConfig2, 69 | 'transformResponse': defaultToConfig2, 70 | 'paramsSerializer': defaultToConfig2, 71 | 'timeout': defaultToConfig2, 72 | 'timeoutMessage': defaultToConfig2, 73 | 'withCredentials': defaultToConfig2, 74 | 'adapter': defaultToConfig2, 75 | 'responseType': defaultToConfig2, 76 | 'xsrfCookieName': defaultToConfig2, 77 | 'xsrfHeaderName': defaultToConfig2, 78 | 'onUploadProgress': defaultToConfig2, 79 | 'onDownloadProgress': defaultToConfig2, 80 | 'decompress': defaultToConfig2, 81 | 'maxContentLength': defaultToConfig2, 82 | 'maxBodyLength': defaultToConfig2, 83 | 'transport': defaultToConfig2, 84 | 'httpAgent': defaultToConfig2, 85 | 'httpsAgent': defaultToConfig2, 86 | 'cancelToken': defaultToConfig2, 87 | 'socketPath': defaultToConfig2, 88 | 'responseEncoding': defaultToConfig2, 89 | 'validateStatus': mergeDirectKeys 90 | }; 91 | 92 | utils.forEach(Object.keys(config1).concat(Object.keys(config2)), function computeConfigValue(prop) { 93 | var merge = mergeMap[prop] || mergeDeepProperties; 94 | var configValue = merge(prop); 95 | (utils.isUndefined(configValue) && merge !== mergeDirectKeys) || (config[prop] = configValue); 96 | }); 97 | 98 | return config; 99 | }; 100 | -------------------------------------------------------------------------------- /node_modules/axios/lib/core/settle.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | var createError = require('./createError'); 4 | 5 | /** 6 | * Resolve or reject a Promise based on response status. 7 | * 8 | * @param {Function} resolve A function that resolves the promise. 9 | * @param {Function} reject A function that rejects the promise. 10 | * @param {object} response The response. 11 | */ 12 | module.exports = function settle(resolve, reject, response) { 13 | var validateStatus = response.config.validateStatus; 14 | if (!response.status || !validateStatus || validateStatus(response.status)) { 15 | resolve(response); 16 | } else { 17 | reject(createError( 18 | 'Request failed with status code ' + response.status, 19 | response.config, 20 | null, 21 | response.request, 22 | response 23 | )); 24 | } 25 | }; 26 | -------------------------------------------------------------------------------- /node_modules/axios/lib/core/transformData.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | var utils = require('./../utils'); 4 | var defaults = require('../defaults'); 5 | 6 | /** 7 | * Transform the data for a request or a response 8 | * 9 | * @param {Object|String} data The data to be transformed 10 | * @param {Array} headers The headers for the request or response 11 | * @param {Array|Function} fns A single function or Array of functions 12 | * @returns {*} The resulting transformed data 13 | */ 14 | module.exports = function transformData(data, headers, fns) { 15 | var context = this || defaults; 16 | /*eslint no-param-reassign:0*/ 17 | utils.forEach(fns, function transform(fn) { 18 | data = fn.call(context, data, headers); 19 | }); 20 | 21 | return data; 22 | }; 23 | -------------------------------------------------------------------------------- /node_modules/axios/lib/defaults/index.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | var utils = require('../utils'); 4 | var normalizeHeaderName = require('../helpers/normalizeHeaderName'); 5 | var enhanceError = require('../core/enhanceError'); 6 | var transitionalDefaults = require('./transitional'); 7 | 8 | var DEFAULT_CONTENT_TYPE = { 9 | 'Content-Type': 'application/x-www-form-urlencoded' 10 | }; 11 | 12 | function setContentTypeIfUnset(headers, value) { 13 | if (!utils.isUndefined(headers) && utils.isUndefined(headers['Content-Type'])) { 14 | headers['Content-Type'] = value; 15 | } 16 | } 17 | 18 | function getDefaultAdapter() { 19 | var adapter; 20 | if (typeof XMLHttpRequest !== 'undefined') { 21 | // For browsers use XHR adapter 22 | adapter = require('../adapters/xhr'); 23 | } else if (typeof process !== 'undefined' && Object.prototype.toString.call(process) === '[object process]') { 24 | // For node use HTTP adapter 25 | adapter = require('../adapters/http'); 26 | } 27 | return adapter; 28 | } 29 | 30 | function stringifySafely(rawValue, parser, encoder) { 31 | if (utils.isString(rawValue)) { 32 | try { 33 | (parser || JSON.parse)(rawValue); 34 | return utils.trim(rawValue); 35 | } catch (e) { 36 | if (e.name !== 'SyntaxError') { 37 | throw e; 38 | } 39 | } 40 | } 41 | 42 | return (encoder || JSON.stringify)(rawValue); 43 | } 44 | 45 | var defaults = { 46 | 47 | transitional: transitionalDefaults, 48 | 49 | adapter: getDefaultAdapter(), 50 | 51 | transformRequest: [function transformRequest(data, headers) { 52 | normalizeHeaderName(headers, 'Accept'); 53 | normalizeHeaderName(headers, 'Content-Type'); 54 | 55 | if (utils.isFormData(data) || 56 | utils.isArrayBuffer(data) || 57 | utils.isBuffer(data) || 58 | utils.isStream(data) || 59 | utils.isFile(data) || 60 | utils.isBlob(data) 61 | ) { 62 | return data; 63 | } 64 | if (utils.isArrayBufferView(data)) { 65 | return data.buffer; 66 | } 67 | if (utils.isURLSearchParams(data)) { 68 | setContentTypeIfUnset(headers, 'application/x-www-form-urlencoded;charset=utf-8'); 69 | return data.toString(); 70 | } 71 | if (utils.isObject(data) || (headers && headers['Content-Type'] === 'application/json')) { 72 | setContentTypeIfUnset(headers, 'application/json'); 73 | return stringifySafely(data); 74 | } 75 | return data; 76 | }], 77 | 78 | transformResponse: [function transformResponse(data) { 79 | var transitional = this.transitional || defaults.transitional; 80 | var silentJSONParsing = transitional && transitional.silentJSONParsing; 81 | var forcedJSONParsing = transitional && transitional.forcedJSONParsing; 82 | var strictJSONParsing = !silentJSONParsing && this.responseType === 'json'; 83 | 84 | if (strictJSONParsing || (forcedJSONParsing && utils.isString(data) && data.length)) { 85 | try { 86 | return JSON.parse(data); 87 | } catch (e) { 88 | if (strictJSONParsing) { 89 | if (e.name === 'SyntaxError') { 90 | throw enhanceError(e, this, 'E_JSON_PARSE'); 91 | } 92 | throw e; 93 | } 94 | } 95 | } 96 | 97 | return data; 98 | }], 99 | 100 | /** 101 | * A timeout in milliseconds to abort a request. If set to 0 (default) a 102 | * timeout is not created. 103 | */ 104 | timeout: 0, 105 | 106 | xsrfCookieName: 'XSRF-TOKEN', 107 | xsrfHeaderName: 'X-XSRF-TOKEN', 108 | 109 | maxContentLength: -1, 110 | maxBodyLength: -1, 111 | 112 | validateStatus: function validateStatus(status) { 113 | return status >= 200 && status < 300; 114 | }, 115 | 116 | headers: { 117 | common: { 118 | 'Accept': 'application/json, text/plain, */*' 119 | } 120 | } 121 | }; 122 | 123 | utils.forEach(['delete', 'get', 'head'], function forEachMethodNoData(method) { 124 | defaults.headers[method] = {}; 125 | }); 126 | 127 | utils.forEach(['post', 'put', 'patch'], function forEachMethodWithData(method) { 128 | defaults.headers[method] = utils.merge(DEFAULT_CONTENT_TYPE); 129 | }); 130 | 131 | module.exports = defaults; 132 | -------------------------------------------------------------------------------- /node_modules/axios/lib/defaults/transitional.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | module.exports = { 4 | silentJSONParsing: true, 5 | forcedJSONParsing: true, 6 | clarifyTimeoutError: false 7 | }; 8 | -------------------------------------------------------------------------------- /node_modules/axios/lib/env/README.md: -------------------------------------------------------------------------------- 1 | # axios // env 2 | 3 | The `data.js` file is updated automatically when the package version is upgrading. Please do not edit it manually. 4 | -------------------------------------------------------------------------------- /node_modules/axios/lib/env/data.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | "version": "0.26.1" 3 | }; -------------------------------------------------------------------------------- /node_modules/axios/lib/helpers/README.md: -------------------------------------------------------------------------------- 1 | # axios // helpers 2 | 3 | The modules found in `helpers/` should be generic modules that are _not_ specific to the domain logic of axios. These modules could theoretically be published to npm on their own and consumed by other modules or apps. Some examples of generic modules are things like: 4 | 5 | - Browser polyfills 6 | - Managing cookies 7 | - Parsing HTTP headers 8 | -------------------------------------------------------------------------------- /node_modules/axios/lib/helpers/bind.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | module.exports = function bind(fn, thisArg) { 4 | return function wrap() { 5 | var args = new Array(arguments.length); 6 | for (var i = 0; i < args.length; i++) { 7 | args[i] = arguments[i]; 8 | } 9 | return fn.apply(thisArg, args); 10 | }; 11 | }; 12 | -------------------------------------------------------------------------------- /node_modules/axios/lib/helpers/buildURL.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | var utils = require('./../utils'); 4 | 5 | function encode(val) { 6 | return encodeURIComponent(val). 7 | replace(/%3A/gi, ':'). 8 | replace(/%24/g, '$'). 9 | replace(/%2C/gi, ','). 10 | replace(/%20/g, '+'). 11 | replace(/%5B/gi, '['). 12 | replace(/%5D/gi, ']'); 13 | } 14 | 15 | /** 16 | * Build a URL by appending params to the end 17 | * 18 | * @param {string} url The base of the url (e.g., http://www.google.com) 19 | * @param {object} [params] The params to be appended 20 | * @returns {string} The formatted url 21 | */ 22 | module.exports = function buildURL(url, params, paramsSerializer) { 23 | /*eslint no-param-reassign:0*/ 24 | if (!params) { 25 | return url; 26 | } 27 | 28 | var serializedParams; 29 | if (paramsSerializer) { 30 | serializedParams = paramsSerializer(params); 31 | } else if (utils.isURLSearchParams(params)) { 32 | serializedParams = params.toString(); 33 | } else { 34 | var parts = []; 35 | 36 | utils.forEach(params, function serialize(val, key) { 37 | if (val === null || typeof val === 'undefined') { 38 | return; 39 | } 40 | 41 | if (utils.isArray(val)) { 42 | key = key + '[]'; 43 | } else { 44 | val = [val]; 45 | } 46 | 47 | utils.forEach(val, function parseValue(v) { 48 | if (utils.isDate(v)) { 49 | v = v.toISOString(); 50 | } else if (utils.isObject(v)) { 51 | v = JSON.stringify(v); 52 | } 53 | parts.push(encode(key) + '=' + encode(v)); 54 | }); 55 | }); 56 | 57 | serializedParams = parts.join('&'); 58 | } 59 | 60 | if (serializedParams) { 61 | var hashmarkIndex = url.indexOf('#'); 62 | if (hashmarkIndex !== -1) { 63 | url = url.slice(0, hashmarkIndex); 64 | } 65 | 66 | url += (url.indexOf('?') === -1 ? '?' : '&') + serializedParams; 67 | } 68 | 69 | return url; 70 | }; 71 | -------------------------------------------------------------------------------- /node_modules/axios/lib/helpers/combineURLs.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | /** 4 | * Creates a new URL by combining the specified URLs 5 | * 6 | * @param {string} baseURL The base URL 7 | * @param {string} relativeURL The relative URL 8 | * @returns {string} The combined URL 9 | */ 10 | module.exports = function combineURLs(baseURL, relativeURL) { 11 | return relativeURL 12 | ? baseURL.replace(/\/+$/, '') + '/' + relativeURL.replace(/^\/+/, '') 13 | : baseURL; 14 | }; 15 | -------------------------------------------------------------------------------- /node_modules/axios/lib/helpers/cookies.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | var utils = require('./../utils'); 4 | 5 | module.exports = ( 6 | utils.isStandardBrowserEnv() ? 7 | 8 | // Standard browser envs support document.cookie 9 | (function standardBrowserEnv() { 10 | return { 11 | write: function write(name, value, expires, path, domain, secure) { 12 | var cookie = []; 13 | cookie.push(name + '=' + encodeURIComponent(value)); 14 | 15 | if (utils.isNumber(expires)) { 16 | cookie.push('expires=' + new Date(expires).toGMTString()); 17 | } 18 | 19 | if (utils.isString(path)) { 20 | cookie.push('path=' + path); 21 | } 22 | 23 | if (utils.isString(domain)) { 24 | cookie.push('domain=' + domain); 25 | } 26 | 27 | if (secure === true) { 28 | cookie.push('secure'); 29 | } 30 | 31 | document.cookie = cookie.join('; '); 32 | }, 33 | 34 | read: function read(name) { 35 | var match = document.cookie.match(new RegExp('(^|;\\s*)(' + name + ')=([^;]*)')); 36 | return (match ? decodeURIComponent(match[3]) : null); 37 | }, 38 | 39 | remove: function remove(name) { 40 | this.write(name, '', Date.now() - 86400000); 41 | } 42 | }; 43 | })() : 44 | 45 | // Non standard browser env (web workers, react-native) lack needed support. 46 | (function nonStandardBrowserEnv() { 47 | return { 48 | write: function write() {}, 49 | read: function read() { return null; }, 50 | remove: function remove() {} 51 | }; 52 | })() 53 | ); 54 | -------------------------------------------------------------------------------- /node_modules/axios/lib/helpers/deprecatedMethod.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | /*eslint no-console:0*/ 4 | 5 | /** 6 | * Supply a warning to the developer that a method they are using 7 | * has been deprecated. 8 | * 9 | * @param {string} method The name of the deprecated method 10 | * @param {string} [instead] The alternate method to use if applicable 11 | * @param {string} [docs] The documentation URL to get further details 12 | */ 13 | module.exports = function deprecatedMethod(method, instead, docs) { 14 | try { 15 | console.warn( 16 | 'DEPRECATED method `' + method + '`.' + 17 | (instead ? ' Use `' + instead + '` instead.' : '') + 18 | ' This method will be removed in a future release.'); 19 | 20 | if (docs) { 21 | console.warn('For more information about usage see ' + docs); 22 | } 23 | } catch (e) { /* Ignore */ } 24 | }; 25 | -------------------------------------------------------------------------------- /node_modules/axios/lib/helpers/isAbsoluteURL.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | /** 4 | * Determines whether the specified URL is absolute 5 | * 6 | * @param {string} url The URL to test 7 | * @returns {boolean} True if the specified URL is absolute, otherwise false 8 | */ 9 | module.exports = function isAbsoluteURL(url) { 10 | // A URL is considered absolute if it begins with "://" or "//" (protocol-relative URL). 11 | // RFC 3986 defines scheme name as a sequence of characters beginning with a letter and followed 12 | // by any combination of letters, digits, plus, period, or hyphen. 13 | return /^([a-z][a-z\d+\-.]*:)?\/\//i.test(url); 14 | }; 15 | -------------------------------------------------------------------------------- /node_modules/axios/lib/helpers/isAxiosError.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | var utils = require('./../utils'); 4 | 5 | /** 6 | * Determines whether the payload is an error thrown by Axios 7 | * 8 | * @param {*} payload The value to test 9 | * @returns {boolean} True if the payload is an error thrown by Axios, otherwise false 10 | */ 11 | module.exports = function isAxiosError(payload) { 12 | return utils.isObject(payload) && (payload.isAxiosError === true); 13 | }; 14 | -------------------------------------------------------------------------------- /node_modules/axios/lib/helpers/isURLSameOrigin.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | var utils = require('./../utils'); 4 | 5 | module.exports = ( 6 | utils.isStandardBrowserEnv() ? 7 | 8 | // Standard browser envs have full support of the APIs needed to test 9 | // whether the request URL is of the same origin as current location. 10 | (function standardBrowserEnv() { 11 | var msie = /(msie|trident)/i.test(navigator.userAgent); 12 | var urlParsingNode = document.createElement('a'); 13 | var originURL; 14 | 15 | /** 16 | * Parse a URL to discover it's components 17 | * 18 | * @param {String} url The URL to be parsed 19 | * @returns {Object} 20 | */ 21 | function resolveURL(url) { 22 | var href = url; 23 | 24 | if (msie) { 25 | // IE needs attribute set twice to normalize properties 26 | urlParsingNode.setAttribute('href', href); 27 | href = urlParsingNode.href; 28 | } 29 | 30 | urlParsingNode.setAttribute('href', href); 31 | 32 | // urlParsingNode provides the UrlUtils interface - http://url.spec.whatwg.org/#urlutils 33 | return { 34 | href: urlParsingNode.href, 35 | protocol: urlParsingNode.protocol ? urlParsingNode.protocol.replace(/:$/, '') : '', 36 | host: urlParsingNode.host, 37 | search: urlParsingNode.search ? urlParsingNode.search.replace(/^\?/, '') : '', 38 | hash: urlParsingNode.hash ? urlParsingNode.hash.replace(/^#/, '') : '', 39 | hostname: urlParsingNode.hostname, 40 | port: urlParsingNode.port, 41 | pathname: (urlParsingNode.pathname.charAt(0) === '/') ? 42 | urlParsingNode.pathname : 43 | '/' + urlParsingNode.pathname 44 | }; 45 | } 46 | 47 | originURL = resolveURL(window.location.href); 48 | 49 | /** 50 | * Determine if a URL shares the same origin as the current location 51 | * 52 | * @param {String} requestURL The URL to test 53 | * @returns {boolean} True if URL shares the same origin, otherwise false 54 | */ 55 | return function isURLSameOrigin(requestURL) { 56 | var parsed = (utils.isString(requestURL)) ? resolveURL(requestURL) : requestURL; 57 | return (parsed.protocol === originURL.protocol && 58 | parsed.host === originURL.host); 59 | }; 60 | })() : 61 | 62 | // Non standard browser envs (web workers, react-native) lack needed support. 63 | (function nonStandardBrowserEnv() { 64 | return function isURLSameOrigin() { 65 | return true; 66 | }; 67 | })() 68 | ); 69 | -------------------------------------------------------------------------------- /node_modules/axios/lib/helpers/normalizeHeaderName.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | var utils = require('../utils'); 4 | 5 | module.exports = function normalizeHeaderName(headers, normalizedName) { 6 | utils.forEach(headers, function processHeader(value, name) { 7 | if (name !== normalizedName && name.toUpperCase() === normalizedName.toUpperCase()) { 8 | headers[normalizedName] = value; 9 | delete headers[name]; 10 | } 11 | }); 12 | }; 13 | -------------------------------------------------------------------------------- /node_modules/axios/lib/helpers/parseHeaders.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | var utils = require('./../utils'); 4 | 5 | // Headers whose duplicates are ignored by node 6 | // c.f. https://nodejs.org/api/http.html#http_message_headers 7 | var ignoreDuplicateOf = [ 8 | 'age', 'authorization', 'content-length', 'content-type', 'etag', 9 | 'expires', 'from', 'host', 'if-modified-since', 'if-unmodified-since', 10 | 'last-modified', 'location', 'max-forwards', 'proxy-authorization', 11 | 'referer', 'retry-after', 'user-agent' 12 | ]; 13 | 14 | /** 15 | * Parse headers into an object 16 | * 17 | * ``` 18 | * Date: Wed, 27 Aug 2014 08:58:49 GMT 19 | * Content-Type: application/json 20 | * Connection: keep-alive 21 | * Transfer-Encoding: chunked 22 | * ``` 23 | * 24 | * @param {String} headers Headers needing to be parsed 25 | * @returns {Object} Headers parsed into an object 26 | */ 27 | module.exports = function parseHeaders(headers) { 28 | var parsed = {}; 29 | var key; 30 | var val; 31 | var i; 32 | 33 | if (!headers) { return parsed; } 34 | 35 | utils.forEach(headers.split('\n'), function parser(line) { 36 | i = line.indexOf(':'); 37 | key = utils.trim(line.substr(0, i)).toLowerCase(); 38 | val = utils.trim(line.substr(i + 1)); 39 | 40 | if (key) { 41 | if (parsed[key] && ignoreDuplicateOf.indexOf(key) >= 0) { 42 | return; 43 | } 44 | if (key === 'set-cookie') { 45 | parsed[key] = (parsed[key] ? parsed[key] : []).concat([val]); 46 | } else { 47 | parsed[key] = parsed[key] ? parsed[key] + ', ' + val : val; 48 | } 49 | } 50 | }); 51 | 52 | return parsed; 53 | }; 54 | -------------------------------------------------------------------------------- /node_modules/axios/lib/helpers/spread.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | /** 4 | * Syntactic sugar for invoking a function and expanding an array for arguments. 5 | * 6 | * Common use case would be to use `Function.prototype.apply`. 7 | * 8 | * ```js 9 | * function f(x, y, z) {} 10 | * var args = [1, 2, 3]; 11 | * f.apply(null, args); 12 | * ``` 13 | * 14 | * With `spread` this example can be re-written. 15 | * 16 | * ```js 17 | * spread(function(x, y, z) {})([1, 2, 3]); 18 | * ``` 19 | * 20 | * @param {Function} callback 21 | * @returns {Function} 22 | */ 23 | module.exports = function spread(callback) { 24 | return function wrap(arr) { 25 | return callback.apply(null, arr); 26 | }; 27 | }; 28 | -------------------------------------------------------------------------------- /node_modules/axios/lib/helpers/toFormData.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | function combinedKey(parentKey, elKey) { 4 | return parentKey + '.' + elKey; 5 | } 6 | 7 | function buildFormData(formData, data, parentKey) { 8 | if (Array.isArray(data)) { 9 | data.forEach(function buildArray(el, i) { 10 | buildFormData(formData, el, combinedKey(parentKey, i)); 11 | }); 12 | } else if ( 13 | typeof data === 'object' && 14 | !(data instanceof File || data === null) 15 | ) { 16 | Object.keys(data).forEach(function buildObject(key) { 17 | buildFormData( 18 | formData, 19 | data[key], 20 | parentKey ? combinedKey(parentKey, key) : key 21 | ); 22 | }); 23 | } else { 24 | if (data === undefined) { 25 | return; 26 | } 27 | 28 | var value = 29 | typeof data === 'boolean' || typeof data === 'number' 30 | ? data.toString() 31 | : data; 32 | formData.append(parentKey, value); 33 | } 34 | } 35 | 36 | /** 37 | * convert a data object to FormData 38 | * 39 | * type FormDataPrimitive = string | Blob | number | boolean 40 | * interface FormDataNest { 41 | * [x: string]: FormVal 42 | * } 43 | * 44 | * type FormVal = FormDataNest | FormDataPrimitive 45 | * 46 | * @param {FormVal} data 47 | */ 48 | 49 | module.exports = function getFormData(data) { 50 | var formData = new FormData(); 51 | 52 | buildFormData(formData, data); 53 | 54 | return formData; 55 | }; 56 | -------------------------------------------------------------------------------- /node_modules/axios/lib/helpers/validator.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | var VERSION = require('../env/data').version; 4 | 5 | var validators = {}; 6 | 7 | // eslint-disable-next-line func-names 8 | ['object', 'boolean', 'number', 'function', 'string', 'symbol'].forEach(function(type, i) { 9 | validators[type] = function validator(thing) { 10 | return typeof thing === type || 'a' + (i < 1 ? 'n ' : ' ') + type; 11 | }; 12 | }); 13 | 14 | var deprecatedWarnings = {}; 15 | 16 | /** 17 | * Transitional option validator 18 | * @param {function|boolean?} validator - set to false if the transitional option has been removed 19 | * @param {string?} version - deprecated version / removed since version 20 | * @param {string?} message - some message with additional info 21 | * @returns {function} 22 | */ 23 | validators.transitional = function transitional(validator, version, message) { 24 | function formatMessage(opt, desc) { 25 | return '[Axios v' + VERSION + '] Transitional option \'' + opt + '\'' + desc + (message ? '. ' + message : ''); 26 | } 27 | 28 | // eslint-disable-next-line func-names 29 | return function(value, opt, opts) { 30 | if (validator === false) { 31 | throw new Error(formatMessage(opt, ' has been removed' + (version ? ' in ' + version : ''))); 32 | } 33 | 34 | if (version && !deprecatedWarnings[opt]) { 35 | deprecatedWarnings[opt] = true; 36 | // eslint-disable-next-line no-console 37 | console.warn( 38 | formatMessage( 39 | opt, 40 | ' has been deprecated since v' + version + ' and will be removed in the near future' 41 | ) 42 | ); 43 | } 44 | 45 | return validator ? validator(value, opt, opts) : true; 46 | }; 47 | }; 48 | 49 | /** 50 | * Assert object's properties type 51 | * @param {object} options 52 | * @param {object} schema 53 | * @param {boolean?} allowUnknown 54 | */ 55 | 56 | function assertOptions(options, schema, allowUnknown) { 57 | if (typeof options !== 'object') { 58 | throw new TypeError('options must be an object'); 59 | } 60 | var keys = Object.keys(options); 61 | var i = keys.length; 62 | while (i-- > 0) { 63 | var opt = keys[i]; 64 | var validator = schema[opt]; 65 | if (validator) { 66 | var value = options[opt]; 67 | var result = value === undefined || validator(value, opt, options); 68 | if (result !== true) { 69 | throw new TypeError('option ' + opt + ' must be ' + result); 70 | } 71 | continue; 72 | } 73 | if (allowUnknown !== true) { 74 | throw Error('Unknown option ' + opt); 75 | } 76 | } 77 | } 78 | 79 | module.exports = { 80 | assertOptions: assertOptions, 81 | validators: validators 82 | }; 83 | -------------------------------------------------------------------------------- /node_modules/axios/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "axios", 3 | "version": "0.26.1", 4 | "description": "Promise based HTTP client for the browser and node.js", 5 | "main": "index.js", 6 | "types": "index.d.ts", 7 | "scripts": { 8 | "test": "grunt test && dtslint", 9 | "start": "node ./sandbox/server.js", 10 | "build": "NODE_ENV=production grunt build", 11 | "preversion": "grunt version && npm test", 12 | "version": "npm run build && git add -A dist && git add CHANGELOG.md bower.json package.json", 13 | "postversion": "git push && git push --tags", 14 | "examples": "node ./examples/server.js", 15 | "coveralls": "cat coverage/lcov.info | ./node_modules/coveralls/bin/coveralls.js", 16 | "fix": "eslint --fix lib/**/*.js" 17 | }, 18 | "repository": { 19 | "type": "git", 20 | "url": "https://github.com/axios/axios.git" 21 | }, 22 | "keywords": [ 23 | "xhr", 24 | "http", 25 | "ajax", 26 | "promise", 27 | "node" 28 | ], 29 | "author": "Matt Zabriskie", 30 | "license": "MIT", 31 | "bugs": { 32 | "url": "https://github.com/axios/axios/issues" 33 | }, 34 | "homepage": "https://axios-http.com", 35 | "devDependencies": { 36 | "abortcontroller-polyfill": "^1.5.0", 37 | "coveralls": "^3.0.0", 38 | "dtslint": "^4.1.6", 39 | "es6-promise": "^4.2.4", 40 | "grunt": "^1.3.0", 41 | "grunt-banner": "^0.6.0", 42 | "grunt-cli": "^1.2.0", 43 | "grunt-contrib-clean": "^1.1.0", 44 | "grunt-contrib-watch": "^1.0.0", 45 | "grunt-eslint": "^23.0.0", 46 | "grunt-karma": "^4.0.0", 47 | "grunt-mocha-test": "^0.13.3", 48 | "grunt-webpack": "^4.0.2", 49 | "istanbul-instrumenter-loader": "^1.0.0", 50 | "jasmine-core": "^2.4.1", 51 | "karma": "^6.3.2", 52 | "karma-chrome-launcher": "^3.1.0", 53 | "karma-firefox-launcher": "^2.1.0", 54 | "karma-jasmine": "^1.1.1", 55 | "karma-jasmine-ajax": "^0.1.13", 56 | "karma-safari-launcher": "^1.0.0", 57 | "karma-sauce-launcher": "^4.3.6", 58 | "karma-sinon": "^1.0.5", 59 | "karma-sourcemap-loader": "^0.3.8", 60 | "karma-webpack": "^4.0.2", 61 | "load-grunt-tasks": "^3.5.2", 62 | "minimist": "^1.2.0", 63 | "mocha": "^8.2.1", 64 | "sinon": "^4.5.0", 65 | "terser-webpack-plugin": "^4.2.3", 66 | "typescript": "^4.0.5", 67 | "url-search-params": "^0.10.0", 68 | "webpack": "^4.44.2", 69 | "webpack-dev-server": "^3.11.0" 70 | }, 71 | "browser": { 72 | "./lib/adapters/http.js": "./lib/adapters/xhr.js" 73 | }, 74 | "jsdelivr": "dist/axios.min.js", 75 | "unpkg": "dist/axios.min.js", 76 | "typings": "./index.d.ts", 77 | "dependencies": { 78 | "follow-redirects": "^1.14.8" 79 | }, 80 | "bundlesize": [ 81 | { 82 | "path": "./dist/axios.min.js", 83 | "threshold": "5kB" 84 | } 85 | ] 86 | } 87 | -------------------------------------------------------------------------------- /node_modules/axios/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "module": "es2015", 4 | "lib": ["dom", "es2015"], 5 | "types": [], 6 | "moduleResolution": "node", 7 | "strict": true, 8 | "noEmit": true, 9 | "baseUrl": ".", 10 | "paths": { 11 | "axios": ["."] 12 | } 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /node_modules/axios/tslint.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "dtslint/dtslint.json", 3 | "rules": { 4 | "no-unnecessary-generics": false 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /node_modules/combined-stream/License: -------------------------------------------------------------------------------- 1 | Copyright (c) 2011 Debuggable Limited 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining a copy 4 | of this software and associated documentation files (the "Software"), to deal 5 | in the Software without restriction, including without limitation the rights 6 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | copies of the Software, and to permit persons to whom the Software is 8 | furnished to do so, subject to the following conditions: 9 | 10 | The above copyright notice and this permission notice shall be included in 11 | all copies or substantial portions of the Software. 12 | 13 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 19 | THE SOFTWARE. 20 | -------------------------------------------------------------------------------- /node_modules/combined-stream/Readme.md: -------------------------------------------------------------------------------- 1 | # combined-stream 2 | 3 | A stream that emits multiple other streams one after another. 4 | 5 | **NB** Currently `combined-stream` works with streams version 1 only. There is ongoing effort to switch this library to streams version 2. Any help is welcome. :) Meanwhile you can explore other libraries that provide streams2 support with more or less compatibility with `combined-stream`. 6 | 7 | - [combined-stream2](https://www.npmjs.com/package/combined-stream2): A drop-in streams2-compatible replacement for the combined-stream module. 8 | 9 | - [multistream](https://www.npmjs.com/package/multistream): A stream that emits multiple other streams one after another. 10 | 11 | ## Installation 12 | 13 | ``` bash 14 | npm install combined-stream 15 | ``` 16 | 17 | ## Usage 18 | 19 | Here is a simple example that shows how you can use combined-stream to combine 20 | two files into one: 21 | 22 | ``` javascript 23 | var CombinedStream = require('combined-stream'); 24 | var fs = require('fs'); 25 | 26 | var combinedStream = CombinedStream.create(); 27 | combinedStream.append(fs.createReadStream('file1.txt')); 28 | combinedStream.append(fs.createReadStream('file2.txt')); 29 | 30 | combinedStream.pipe(fs.createWriteStream('combined.txt')); 31 | ``` 32 | 33 | While the example above works great, it will pause all source streams until 34 | they are needed. If you don't want that to happen, you can set `pauseStreams` 35 | to `false`: 36 | 37 | ``` javascript 38 | var CombinedStream = require('combined-stream'); 39 | var fs = require('fs'); 40 | 41 | var combinedStream = CombinedStream.create({pauseStreams: false}); 42 | combinedStream.append(fs.createReadStream('file1.txt')); 43 | combinedStream.append(fs.createReadStream('file2.txt')); 44 | 45 | combinedStream.pipe(fs.createWriteStream('combined.txt')); 46 | ``` 47 | 48 | However, what if you don't have all the source streams yet, or you don't want 49 | to allocate the resources (file descriptors, memory, etc.) for them right away? 50 | Well, in that case you can simply provide a callback that supplies the stream 51 | by calling a `next()` function: 52 | 53 | ``` javascript 54 | var CombinedStream = require('combined-stream'); 55 | var fs = require('fs'); 56 | 57 | var combinedStream = CombinedStream.create(); 58 | combinedStream.append(function(next) { 59 | next(fs.createReadStream('file1.txt')); 60 | }); 61 | combinedStream.append(function(next) { 62 | next(fs.createReadStream('file2.txt')); 63 | }); 64 | 65 | combinedStream.pipe(fs.createWriteStream('combined.txt')); 66 | ``` 67 | 68 | ## API 69 | 70 | ### CombinedStream.create([options]) 71 | 72 | Returns a new combined stream object. Available options are: 73 | 74 | * `maxDataSize` 75 | * `pauseStreams` 76 | 77 | The effect of those options is described below. 78 | 79 | ### combinedStream.pauseStreams = `true` 80 | 81 | Whether to apply back pressure to the underlaying streams. If set to `false`, 82 | the underlaying streams will never be paused. If set to `true`, the 83 | underlaying streams will be paused right after being appended, as well as when 84 | `delayedStream.pipe()` wants to throttle. 85 | 86 | ### combinedStream.maxDataSize = `2 * 1024 * 1024` 87 | 88 | The maximum amount of bytes (or characters) to buffer for all source streams. 89 | If this value is exceeded, `combinedStream` emits an `'error'` event. 90 | 91 | ### combinedStream.dataSize = `0` 92 | 93 | The amount of bytes (or characters) currently buffered by `combinedStream`. 94 | 95 | ### combinedStream.append(stream) 96 | 97 | Appends the given `stream` to the combinedStream object. If `pauseStreams` is 98 | set to `true, this stream will also be paused right away. 99 | 100 | `streams` can also be a function that takes one parameter called `next`. `next` 101 | is a function that must be invoked in order to provide the `next` stream, see 102 | example above. 103 | 104 | Regardless of how the `stream` is appended, combined-stream always attaches an 105 | `'error'` listener to it, so you don't have to do that manually. 106 | 107 | Special case: `stream` can also be a String or Buffer. 108 | 109 | ### combinedStream.write(data) 110 | 111 | You should not call this, `combinedStream` takes care of piping the appended 112 | streams into itself for you. 113 | 114 | ### combinedStream.resume() 115 | 116 | Causes `combinedStream` to start drain the streams it manages. The function is 117 | idempotent, and also emits a `'resume'` event each time which usually goes to 118 | the stream that is currently being drained. 119 | 120 | ### combinedStream.pause(); 121 | 122 | If `combinedStream.pauseStreams` is set to `false`, this does nothing. 123 | Otherwise a `'pause'` event is emitted, this goes to the stream that is 124 | currently being drained, so you can use it to apply back pressure. 125 | 126 | ### combinedStream.end(); 127 | 128 | Sets `combinedStream.writable` to false, emits an `'end'` event, and removes 129 | all streams from the queue. 130 | 131 | ### combinedStream.destroy(); 132 | 133 | Same as `combinedStream.end()`, except it emits a `'close'` event instead of 134 | `'end'`. 135 | 136 | ## License 137 | 138 | combined-stream is licensed under the MIT license. 139 | -------------------------------------------------------------------------------- /node_modules/combined-stream/lib/combined_stream.js: -------------------------------------------------------------------------------- 1 | var util = require('util'); 2 | var Stream = require('stream').Stream; 3 | var DelayedStream = require('delayed-stream'); 4 | 5 | module.exports = CombinedStream; 6 | function CombinedStream() { 7 | this.writable = false; 8 | this.readable = true; 9 | this.dataSize = 0; 10 | this.maxDataSize = 2 * 1024 * 1024; 11 | this.pauseStreams = true; 12 | 13 | this._released = false; 14 | this._streams = []; 15 | this._currentStream = null; 16 | this._insideLoop = false; 17 | this._pendingNext = false; 18 | } 19 | util.inherits(CombinedStream, Stream); 20 | 21 | CombinedStream.create = function(options) { 22 | var combinedStream = new this(); 23 | 24 | options = options || {}; 25 | for (var option in options) { 26 | combinedStream[option] = options[option]; 27 | } 28 | 29 | return combinedStream; 30 | }; 31 | 32 | CombinedStream.isStreamLike = function(stream) { 33 | return (typeof stream !== 'function') 34 | && (typeof stream !== 'string') 35 | && (typeof stream !== 'boolean') 36 | && (typeof stream !== 'number') 37 | && (!Buffer.isBuffer(stream)); 38 | }; 39 | 40 | CombinedStream.prototype.append = function(stream) { 41 | var isStreamLike = CombinedStream.isStreamLike(stream); 42 | 43 | if (isStreamLike) { 44 | if (!(stream instanceof DelayedStream)) { 45 | var newStream = DelayedStream.create(stream, { 46 | maxDataSize: Infinity, 47 | pauseStream: this.pauseStreams, 48 | }); 49 | stream.on('data', this._checkDataSize.bind(this)); 50 | stream = newStream; 51 | } 52 | 53 | this._handleErrors(stream); 54 | 55 | if (this.pauseStreams) { 56 | stream.pause(); 57 | } 58 | } 59 | 60 | this._streams.push(stream); 61 | return this; 62 | }; 63 | 64 | CombinedStream.prototype.pipe = function(dest, options) { 65 | Stream.prototype.pipe.call(this, dest, options); 66 | this.resume(); 67 | return dest; 68 | }; 69 | 70 | CombinedStream.prototype._getNext = function() { 71 | this._currentStream = null; 72 | 73 | if (this._insideLoop) { 74 | this._pendingNext = true; 75 | return; // defer call 76 | } 77 | 78 | this._insideLoop = true; 79 | try { 80 | do { 81 | this._pendingNext = false; 82 | this._realGetNext(); 83 | } while (this._pendingNext); 84 | } finally { 85 | this._insideLoop = false; 86 | } 87 | }; 88 | 89 | CombinedStream.prototype._realGetNext = function() { 90 | var stream = this._streams.shift(); 91 | 92 | 93 | if (typeof stream == 'undefined') { 94 | this.end(); 95 | return; 96 | } 97 | 98 | if (typeof stream !== 'function') { 99 | this._pipeNext(stream); 100 | return; 101 | } 102 | 103 | var getStream = stream; 104 | getStream(function(stream) { 105 | var isStreamLike = CombinedStream.isStreamLike(stream); 106 | if (isStreamLike) { 107 | stream.on('data', this._checkDataSize.bind(this)); 108 | this._handleErrors(stream); 109 | } 110 | 111 | this._pipeNext(stream); 112 | }.bind(this)); 113 | }; 114 | 115 | CombinedStream.prototype._pipeNext = function(stream) { 116 | this._currentStream = stream; 117 | 118 | var isStreamLike = CombinedStream.isStreamLike(stream); 119 | if (isStreamLike) { 120 | stream.on('end', this._getNext.bind(this)); 121 | stream.pipe(this, {end: false}); 122 | return; 123 | } 124 | 125 | var value = stream; 126 | this.write(value); 127 | this._getNext(); 128 | }; 129 | 130 | CombinedStream.prototype._handleErrors = function(stream) { 131 | var self = this; 132 | stream.on('error', function(err) { 133 | self._emitError(err); 134 | }); 135 | }; 136 | 137 | CombinedStream.prototype.write = function(data) { 138 | this.emit('data', data); 139 | }; 140 | 141 | CombinedStream.prototype.pause = function() { 142 | if (!this.pauseStreams) { 143 | return; 144 | } 145 | 146 | if(this.pauseStreams && this._currentStream && typeof(this._currentStream.pause) == 'function') this._currentStream.pause(); 147 | this.emit('pause'); 148 | }; 149 | 150 | CombinedStream.prototype.resume = function() { 151 | if (!this._released) { 152 | this._released = true; 153 | this.writable = true; 154 | this._getNext(); 155 | } 156 | 157 | if(this.pauseStreams && this._currentStream && typeof(this._currentStream.resume) == 'function') this._currentStream.resume(); 158 | this.emit('resume'); 159 | }; 160 | 161 | CombinedStream.prototype.end = function() { 162 | this._reset(); 163 | this.emit('end'); 164 | }; 165 | 166 | CombinedStream.prototype.destroy = function() { 167 | this._reset(); 168 | this.emit('close'); 169 | }; 170 | 171 | CombinedStream.prototype._reset = function() { 172 | this.writable = false; 173 | this._streams = []; 174 | this._currentStream = null; 175 | }; 176 | 177 | CombinedStream.prototype._checkDataSize = function() { 178 | this._updateDataSize(); 179 | if (this.dataSize <= this.maxDataSize) { 180 | return; 181 | } 182 | 183 | var message = 184 | 'DelayedStream#maxDataSize of ' + this.maxDataSize + ' bytes exceeded.'; 185 | this._emitError(new Error(message)); 186 | }; 187 | 188 | CombinedStream.prototype._updateDataSize = function() { 189 | this.dataSize = 0; 190 | 191 | var self = this; 192 | this._streams.forEach(function(stream) { 193 | if (!stream.dataSize) { 194 | return; 195 | } 196 | 197 | self.dataSize += stream.dataSize; 198 | }); 199 | 200 | if (this._currentStream && this._currentStream.dataSize) { 201 | this.dataSize += this._currentStream.dataSize; 202 | } 203 | }; 204 | 205 | CombinedStream.prototype._emitError = function(err) { 206 | this._reset(); 207 | this.emit('error', err); 208 | }; 209 | -------------------------------------------------------------------------------- /node_modules/combined-stream/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "author": "Felix Geisendörfer (http://debuggable.com/)", 3 | "name": "combined-stream", 4 | "description": "A stream that emits multiple other streams one after another.", 5 | "version": "1.0.8", 6 | "homepage": "https://github.com/felixge/node-combined-stream", 7 | "repository": { 8 | "type": "git", 9 | "url": "git://github.com/felixge/node-combined-stream.git" 10 | }, 11 | "main": "./lib/combined_stream", 12 | "scripts": { 13 | "test": "node test/run.js" 14 | }, 15 | "engines": { 16 | "node": ">= 0.8" 17 | }, 18 | "dependencies": { 19 | "delayed-stream": "~1.0.0" 20 | }, 21 | "devDependencies": { 22 | "far": "~0.0.7" 23 | }, 24 | "license": "MIT" 25 | } 26 | -------------------------------------------------------------------------------- /node_modules/combined-stream/yarn.lock: -------------------------------------------------------------------------------- 1 | # THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. 2 | # yarn lockfile v1 3 | 4 | 5 | delayed-stream@~1.0.0: 6 | version "1.0.0" 7 | resolved "https://registry.yarnpkg.com/delayed-stream/-/delayed-stream-1.0.0.tgz#df3ae199acadfb7d440aaae0b29e2272b24ec619" 8 | 9 | far@~0.0.7: 10 | version "0.0.7" 11 | resolved "https://registry.yarnpkg.com/far/-/far-0.0.7.tgz#01c1fd362bcd26ce9cf161af3938aa34619f79a7" 12 | dependencies: 13 | oop "0.0.3" 14 | 15 | oop@0.0.3: 16 | version "0.0.3" 17 | resolved "https://registry.yarnpkg.com/oop/-/oop-0.0.3.tgz#70fa405a5650891a194fdc82ca68dad6dabf4401" 18 | -------------------------------------------------------------------------------- /node_modules/delayed-stream/.npmignore: -------------------------------------------------------------------------------- 1 | test 2 | -------------------------------------------------------------------------------- /node_modules/delayed-stream/License: -------------------------------------------------------------------------------- 1 | Copyright (c) 2011 Debuggable Limited 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining a copy 4 | of this software and associated documentation files (the "Software"), to deal 5 | in the Software without restriction, including without limitation the rights 6 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | copies of the Software, and to permit persons to whom the Software is 8 | furnished to do so, subject to the following conditions: 9 | 10 | The above copyright notice and this permission notice shall be included in 11 | all copies or substantial portions of the Software. 12 | 13 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 19 | THE SOFTWARE. 20 | -------------------------------------------------------------------------------- /node_modules/delayed-stream/Makefile: -------------------------------------------------------------------------------- 1 | SHELL := /bin/bash 2 | 3 | test: 4 | @./test/run.js 5 | 6 | .PHONY: test 7 | 8 | -------------------------------------------------------------------------------- /node_modules/delayed-stream/Readme.md: -------------------------------------------------------------------------------- 1 | # delayed-stream 2 | 3 | Buffers events from a stream until you are ready to handle them. 4 | 5 | ## Installation 6 | 7 | ``` bash 8 | npm install delayed-stream 9 | ``` 10 | 11 | ## Usage 12 | 13 | The following example shows how to write a http echo server that delays its 14 | response by 1000 ms. 15 | 16 | ``` javascript 17 | var DelayedStream = require('delayed-stream'); 18 | var http = require('http'); 19 | 20 | http.createServer(function(req, res) { 21 | var delayed = DelayedStream.create(req); 22 | 23 | setTimeout(function() { 24 | res.writeHead(200); 25 | delayed.pipe(res); 26 | }, 1000); 27 | }); 28 | ``` 29 | 30 | If you are not using `Stream#pipe`, you can also manually release the buffered 31 | events by calling `delayedStream.resume()`: 32 | 33 | ``` javascript 34 | var delayed = DelayedStream.create(req); 35 | 36 | setTimeout(function() { 37 | // Emit all buffered events and resume underlaying source 38 | delayed.resume(); 39 | }, 1000); 40 | ``` 41 | 42 | ## Implementation 43 | 44 | In order to use this meta stream properly, here are a few things you should 45 | know about the implementation. 46 | 47 | ### Event Buffering / Proxying 48 | 49 | All events of the `source` stream are hijacked by overwriting the `source.emit` 50 | method. Until node implements a catch-all event listener, this is the only way. 51 | 52 | However, delayed-stream still continues to emit all events it captures on the 53 | `source`, regardless of whether you have released the delayed stream yet or 54 | not. 55 | 56 | Upon creation, delayed-stream captures all `source` events and stores them in 57 | an internal event buffer. Once `delayedStream.release()` is called, all 58 | buffered events are emitted on the `delayedStream`, and the event buffer is 59 | cleared. After that, delayed-stream merely acts as a proxy for the underlaying 60 | source. 61 | 62 | ### Error handling 63 | 64 | Error events on `source` are buffered / proxied just like any other events. 65 | However, `delayedStream.create` attaches a no-op `'error'` listener to the 66 | `source`. This way you only have to handle errors on the `delayedStream` 67 | object, rather than in two places. 68 | 69 | ### Buffer limits 70 | 71 | delayed-stream provides a `maxDataSize` property that can be used to limit 72 | the amount of data being buffered. In order to protect you from bad `source` 73 | streams that don't react to `source.pause()`, this feature is enabled by 74 | default. 75 | 76 | ## API 77 | 78 | ### DelayedStream.create(source, [options]) 79 | 80 | Returns a new `delayedStream`. Available options are: 81 | 82 | * `pauseStream` 83 | * `maxDataSize` 84 | 85 | The description for those properties can be found below. 86 | 87 | ### delayedStream.source 88 | 89 | The `source` stream managed by this object. This is useful if you are 90 | passing your `delayedStream` around, and you still want to access properties 91 | on the `source` object. 92 | 93 | ### delayedStream.pauseStream = true 94 | 95 | Whether to pause the underlaying `source` when calling 96 | `DelayedStream.create()`. Modifying this property afterwards has no effect. 97 | 98 | ### delayedStream.maxDataSize = 1024 * 1024 99 | 100 | The amount of data to buffer before emitting an `error`. 101 | 102 | If the underlaying source is emitting `Buffer` objects, the `maxDataSize` 103 | refers to bytes. 104 | 105 | If the underlaying source is emitting JavaScript strings, the size refers to 106 | characters. 107 | 108 | If you know what you are doing, you can set this property to `Infinity` to 109 | disable this feature. You can also modify this property during runtime. 110 | 111 | ### delayedStream.dataSize = 0 112 | 113 | The amount of data buffered so far. 114 | 115 | ### delayedStream.readable 116 | 117 | An ECMA5 getter that returns the value of `source.readable`. 118 | 119 | ### delayedStream.resume() 120 | 121 | If the `delayedStream` has not been released so far, `delayedStream.release()` 122 | is called. 123 | 124 | In either case, `source.resume()` is called. 125 | 126 | ### delayedStream.pause() 127 | 128 | Calls `source.pause()`. 129 | 130 | ### delayedStream.pipe(dest) 131 | 132 | Calls `delayedStream.resume()` and then proxies the arguments to `source.pipe`. 133 | 134 | ### delayedStream.release() 135 | 136 | Emits and clears all events that have been buffered up so far. This does not 137 | resume the underlaying source, use `delayedStream.resume()` instead. 138 | 139 | ## License 140 | 141 | delayed-stream is licensed under the MIT license. 142 | -------------------------------------------------------------------------------- /node_modules/delayed-stream/lib/delayed_stream.js: -------------------------------------------------------------------------------- 1 | var Stream = require('stream').Stream; 2 | var util = require('util'); 3 | 4 | module.exports = DelayedStream; 5 | function DelayedStream() { 6 | this.source = null; 7 | this.dataSize = 0; 8 | this.maxDataSize = 1024 * 1024; 9 | this.pauseStream = true; 10 | 11 | this._maxDataSizeExceeded = false; 12 | this._released = false; 13 | this._bufferedEvents = []; 14 | } 15 | util.inherits(DelayedStream, Stream); 16 | 17 | DelayedStream.create = function(source, options) { 18 | var delayedStream = new this(); 19 | 20 | options = options || {}; 21 | for (var option in options) { 22 | delayedStream[option] = options[option]; 23 | } 24 | 25 | delayedStream.source = source; 26 | 27 | var realEmit = source.emit; 28 | source.emit = function() { 29 | delayedStream._handleEmit(arguments); 30 | return realEmit.apply(source, arguments); 31 | }; 32 | 33 | source.on('error', function() {}); 34 | if (delayedStream.pauseStream) { 35 | source.pause(); 36 | } 37 | 38 | return delayedStream; 39 | }; 40 | 41 | Object.defineProperty(DelayedStream.prototype, 'readable', { 42 | configurable: true, 43 | enumerable: true, 44 | get: function() { 45 | return this.source.readable; 46 | } 47 | }); 48 | 49 | DelayedStream.prototype.setEncoding = function() { 50 | return this.source.setEncoding.apply(this.source, arguments); 51 | }; 52 | 53 | DelayedStream.prototype.resume = function() { 54 | if (!this._released) { 55 | this.release(); 56 | } 57 | 58 | this.source.resume(); 59 | }; 60 | 61 | DelayedStream.prototype.pause = function() { 62 | this.source.pause(); 63 | }; 64 | 65 | DelayedStream.prototype.release = function() { 66 | this._released = true; 67 | 68 | this._bufferedEvents.forEach(function(args) { 69 | this.emit.apply(this, args); 70 | }.bind(this)); 71 | this._bufferedEvents = []; 72 | }; 73 | 74 | DelayedStream.prototype.pipe = function() { 75 | var r = Stream.prototype.pipe.apply(this, arguments); 76 | this.resume(); 77 | return r; 78 | }; 79 | 80 | DelayedStream.prototype._handleEmit = function(args) { 81 | if (this._released) { 82 | this.emit.apply(this, args); 83 | return; 84 | } 85 | 86 | if (args[0] === 'data') { 87 | this.dataSize += args[1].length; 88 | this._checkIfMaxDataSizeExceeded(); 89 | } 90 | 91 | this._bufferedEvents.push(args); 92 | }; 93 | 94 | DelayedStream.prototype._checkIfMaxDataSizeExceeded = function() { 95 | if (this._maxDataSizeExceeded) { 96 | return; 97 | } 98 | 99 | if (this.dataSize <= this.maxDataSize) { 100 | return; 101 | } 102 | 103 | this._maxDataSizeExceeded = true; 104 | var message = 105 | 'DelayedStream#maxDataSize of ' + this.maxDataSize + ' bytes exceeded.' 106 | this.emit('error', new Error(message)); 107 | }; 108 | -------------------------------------------------------------------------------- /node_modules/delayed-stream/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "author": "Felix Geisendörfer (http://debuggable.com/)", 3 | "contributors": [ 4 | "Mike Atkins " 5 | ], 6 | "name": "delayed-stream", 7 | "description": "Buffers events from a stream until you are ready to handle them.", 8 | "license": "MIT", 9 | "version": "1.0.0", 10 | "homepage": "https://github.com/felixge/node-delayed-stream", 11 | "repository": { 12 | "type": "git", 13 | "url": "git://github.com/felixge/node-delayed-stream.git" 14 | }, 15 | "main": "./lib/delayed_stream", 16 | "engines": { 17 | "node": ">=0.4.0" 18 | }, 19 | "scripts": { 20 | "test": "make test" 21 | }, 22 | "dependencies": {}, 23 | "devDependencies": { 24 | "fake": "0.2.0", 25 | "far": "0.0.1" 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /node_modules/follow-redirects/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright 2014–present Olivier Lalonde , James Talmage , Ruben Verborgh 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining a copy of 4 | this software and associated documentation files (the "Software"), to deal in 5 | the Software without restriction, including without limitation the rights to 6 | use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies 7 | of the Software, and to permit persons to whom the Software is furnished to do 8 | so, subject to the following conditions: 9 | 10 | The above copyright notice and this permission notice shall be included in all 11 | copies or substantial portions of the Software. 12 | 13 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 17 | WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR 18 | IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 19 | -------------------------------------------------------------------------------- /node_modules/follow-redirects/debug.js: -------------------------------------------------------------------------------- 1 | var debug; 2 | 3 | module.exports = function () { 4 | if (!debug) { 5 | try { 6 | /* eslint global-require: off */ 7 | debug = require("debug")("follow-redirects"); 8 | } 9 | catch (error) { /* */ } 10 | if (typeof debug !== "function") { 11 | debug = function () { /* */ }; 12 | } 13 | } 14 | debug.apply(null, arguments); 15 | }; 16 | -------------------------------------------------------------------------------- /node_modules/follow-redirects/http.js: -------------------------------------------------------------------------------- 1 | module.exports = require("./").http; 2 | -------------------------------------------------------------------------------- /node_modules/follow-redirects/https.js: -------------------------------------------------------------------------------- 1 | module.exports = require("./").https; 2 | -------------------------------------------------------------------------------- /node_modules/follow-redirects/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "follow-redirects", 3 | "version": "1.15.2", 4 | "description": "HTTP and HTTPS modules that follow redirects.", 5 | "license": "MIT", 6 | "main": "index.js", 7 | "files": [ 8 | "*.js" 9 | ], 10 | "engines": { 11 | "node": ">=4.0" 12 | }, 13 | "scripts": { 14 | "test": "npm run lint && npm run mocha", 15 | "lint": "eslint *.js test", 16 | "mocha": "nyc mocha" 17 | }, 18 | "repository": { 19 | "type": "git", 20 | "url": "git@github.com:follow-redirects/follow-redirects.git" 21 | }, 22 | "homepage": "https://github.com/follow-redirects/follow-redirects", 23 | "bugs": { 24 | "url": "https://github.com/follow-redirects/follow-redirects/issues" 25 | }, 26 | "keywords": [ 27 | "http", 28 | "https", 29 | "url", 30 | "redirect", 31 | "client", 32 | "location", 33 | "utility" 34 | ], 35 | "author": "Ruben Verborgh (https://ruben.verborgh.org/)", 36 | "contributors": [ 37 | "Olivier Lalonde (http://www.syskall.com)", 38 | "James Talmage " 39 | ], 40 | "funding": [ 41 | { 42 | "type": "individual", 43 | "url": "https://github.com/sponsors/RubenVerborgh" 44 | } 45 | ], 46 | "peerDependenciesMeta": { 47 | "debug": { 48 | "optional": true 49 | } 50 | }, 51 | "devDependencies": { 52 | "concat-stream": "^2.0.0", 53 | "eslint": "^5.16.0", 54 | "express": "^4.16.4", 55 | "lolex": "^3.1.0", 56 | "mocha": "^6.0.2", 57 | "nyc": "^14.1.1" 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /node_modules/form-data/License: -------------------------------------------------------------------------------- 1 | Copyright (c) 2012 Felix Geisendörfer (felix@debuggable.com) and contributors 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining a copy 4 | of this software and associated documentation files (the "Software"), to deal 5 | in the Software without restriction, including without limitation the rights 6 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | copies of the Software, and to permit persons to whom the Software is 8 | furnished to do so, subject to the following conditions: 9 | 10 | The above copyright notice and this permission notice shall be included in 11 | all copies or substantial portions of the Software. 12 | 13 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 19 | THE SOFTWARE. 20 | -------------------------------------------------------------------------------- /node_modules/form-data/index.d.ts: -------------------------------------------------------------------------------- 1 | // Definitions by: Carlos Ballesteros Velasco 2 | // Leon Yu 3 | // BendingBender 4 | // Maple Miao 5 | 6 | /// 7 | import * as stream from 'stream'; 8 | import * as http from 'http'; 9 | 10 | export = FormData; 11 | 12 | // Extracted because @types/node doesn't export interfaces. 13 | interface ReadableOptions { 14 | highWaterMark?: number; 15 | encoding?: string; 16 | objectMode?: boolean; 17 | read?(this: stream.Readable, size: number): void; 18 | destroy?(this: stream.Readable, error: Error | null, callback: (error: Error | null) => void): void; 19 | autoDestroy?: boolean; 20 | } 21 | 22 | interface Options extends ReadableOptions { 23 | writable?: boolean; 24 | readable?: boolean; 25 | dataSize?: number; 26 | maxDataSize?: number; 27 | pauseStreams?: boolean; 28 | } 29 | 30 | declare class FormData extends stream.Readable { 31 | constructor(options?: Options); 32 | append(key: string, value: any, options?: FormData.AppendOptions | string): void; 33 | getHeaders(userHeaders?: FormData.Headers): FormData.Headers; 34 | submit( 35 | params: string | FormData.SubmitOptions, 36 | callback?: (error: Error | null, response: http.IncomingMessage) => void 37 | ): http.ClientRequest; 38 | getBuffer(): Buffer; 39 | setBoundary(boundary: string): void; 40 | getBoundary(): string; 41 | getLength(callback: (err: Error | null, length: number) => void): void; 42 | getLengthSync(): number; 43 | hasKnownLength(): boolean; 44 | } 45 | 46 | declare namespace FormData { 47 | interface Headers { 48 | [key: string]: any; 49 | } 50 | 51 | interface AppendOptions { 52 | header?: string | Headers; 53 | knownLength?: number; 54 | filename?: string; 55 | filepath?: string; 56 | contentType?: string; 57 | } 58 | 59 | interface SubmitOptions extends http.RequestOptions { 60 | protocol?: 'https:' | 'http:'; 61 | } 62 | } 63 | -------------------------------------------------------------------------------- /node_modules/form-data/lib/browser.js: -------------------------------------------------------------------------------- 1 | /* eslint-env browser */ 2 | module.exports = typeof self == 'object' ? self.FormData : window.FormData; 3 | -------------------------------------------------------------------------------- /node_modules/form-data/lib/populate.js: -------------------------------------------------------------------------------- 1 | // populates missing values 2 | module.exports = function(dst, src) { 3 | 4 | Object.keys(src).forEach(function(prop) 5 | { 6 | dst[prop] = dst[prop] || src[prop]; 7 | }); 8 | 9 | return dst; 10 | }; 11 | -------------------------------------------------------------------------------- /node_modules/form-data/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "author": "Felix Geisendörfer (http://debuggable.com/)", 3 | "name": "form-data", 4 | "description": "A library to create readable \"multipart/form-data\" streams. Can be used to submit forms and file uploads to other web applications.", 5 | "version": "4.0.0", 6 | "repository": { 7 | "type": "git", 8 | "url": "git://github.com/form-data/form-data.git" 9 | }, 10 | "main": "./lib/form_data", 11 | "browser": "./lib/browser", 12 | "typings": "./index.d.ts", 13 | "scripts": { 14 | "pretest": "rimraf coverage test/tmp", 15 | "test": "istanbul cover test/run.js", 16 | "posttest": "istanbul report lcov text", 17 | "lint": "eslint lib/*.js test/*.js test/integration/*.js", 18 | "report": "istanbul report lcov text", 19 | "ci-lint": "is-node-modern 8 && npm run lint || is-node-not-modern 8", 20 | "ci-test": "npm run test && npm run browser && npm run report", 21 | "predebug": "rimraf coverage test/tmp", 22 | "debug": "verbose=1 ./test/run.js", 23 | "browser": "browserify -t browserify-istanbul test/run-browser.js | obake --coverage", 24 | "check": "istanbul check-coverage coverage/coverage*.json", 25 | "files": "pkgfiles --sort=name", 26 | "get-version": "node -e \"console.log(require('./package.json').version)\"", 27 | "update-readme": "sed -i.bak 's/\\/master\\.svg/\\/v'$(npm --silent run get-version)'.svg/g' README.md", 28 | "restore-readme": "mv README.md.bak README.md", 29 | "prepublish": "in-publish && npm run update-readme || not-in-publish", 30 | "postpublish": "npm run restore-readme" 31 | }, 32 | "pre-commit": [ 33 | "lint", 34 | "ci-test", 35 | "check" 36 | ], 37 | "engines": { 38 | "node": ">= 6" 39 | }, 40 | "dependencies": { 41 | "asynckit": "^0.4.0", 42 | "combined-stream": "^1.0.8", 43 | "mime-types": "^2.1.12" 44 | }, 45 | "devDependencies": { 46 | "@types/node": "^12.0.10", 47 | "browserify": "^13.1.1", 48 | "browserify-istanbul": "^2.0.0", 49 | "coveralls": "^3.0.4", 50 | "cross-spawn": "^6.0.5", 51 | "eslint": "^6.0.1", 52 | "fake": "^0.2.2", 53 | "far": "^0.0.7", 54 | "formidable": "^1.0.17", 55 | "in-publish": "^2.0.0", 56 | "is-node-modern": "^1.0.0", 57 | "istanbul": "^0.4.5", 58 | "obake": "^0.1.2", 59 | "puppeteer": "^1.19.0", 60 | "pkgfiles": "^2.3.0", 61 | "pre-commit": "^1.1.3", 62 | "request": "^2.88.0", 63 | "rimraf": "^2.7.1", 64 | "tape": "^4.6.2", 65 | "typescript": "^3.5.2" 66 | }, 67 | "license": "MIT" 68 | } 69 | -------------------------------------------------------------------------------- /node_modules/fs/README.md: -------------------------------------------------------------------------------- 1 | # Security holding package 2 | 3 | This package name is not currently in use, but was formerly occupied 4 | by another package. To avoid malicious use, npm is hanging on to the 5 | package name, but loosely, and we'll probably give it to you if you 6 | want it. 7 | 8 | You may adopt this package by contacting support@npmjs.com and 9 | requesting the name. 10 | -------------------------------------------------------------------------------- /node_modules/fs/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "fs", 3 | "version": "0.0.1-security", 4 | "description": "", 5 | "main": "index.js", 6 | "scripts": { 7 | "test": "echo \"Error: no test specified\" && exit 1" 8 | }, 9 | "repository": { 10 | "type": "git", 11 | "url": "git+https://github.com/npm/security-holder.git" 12 | }, 13 | "keywords": [], 14 | "author": "", 15 | "license": "ISC", 16 | "bugs": { 17 | "url": "https://github.com/npm/security-holder/issues" 18 | }, 19 | "homepage": "https://github.com/npm/security-holder#readme" 20 | } 21 | -------------------------------------------------------------------------------- /node_modules/mime-db/LICENSE: -------------------------------------------------------------------------------- 1 | (The MIT License) 2 | 3 | Copyright (c) 2014 Jonathan Ong 4 | Copyright (c) 2015-2022 Douglas Christopher Wilson 5 | 6 | Permission is hereby granted, free of charge, to any person obtaining 7 | a copy of this software and associated documentation files (the 8 | 'Software'), to deal in the Software without restriction, including 9 | without limitation the rights to use, copy, modify, merge, publish, 10 | distribute, sublicense, and/or sell copies of the Software, and to 11 | permit persons to whom the Software is furnished to do so, subject to 12 | the following conditions: 13 | 14 | The above copyright notice and this permission notice shall be 15 | included in all copies or substantial portions of the Software. 16 | 17 | THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, 18 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 19 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 20 | IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY 21 | CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, 22 | TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE 23 | SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 24 | -------------------------------------------------------------------------------- /node_modules/mime-db/README.md: -------------------------------------------------------------------------------- 1 | # mime-db 2 | 3 | [![NPM Version][npm-version-image]][npm-url] 4 | [![NPM Downloads][npm-downloads-image]][npm-url] 5 | [![Node.js Version][node-image]][node-url] 6 | [![Build Status][ci-image]][ci-url] 7 | [![Coverage Status][coveralls-image]][coveralls-url] 8 | 9 | This is a large database of mime types and information about them. 10 | It consists of a single, public JSON file and does not include any logic, 11 | allowing it to remain as un-opinionated as possible with an API. 12 | It aggregates data from the following sources: 13 | 14 | - http://www.iana.org/assignments/media-types/media-types.xhtml 15 | - http://svn.apache.org/repos/asf/httpd/httpd/trunk/docs/conf/mime.types 16 | - http://hg.nginx.org/nginx/raw-file/default/conf/mime.types 17 | 18 | ## Installation 19 | 20 | ```bash 21 | npm install mime-db 22 | ``` 23 | 24 | ### Database Download 25 | 26 | If you're crazy enough to use this in the browser, you can just grab the 27 | JSON file using [jsDelivr](https://www.jsdelivr.com/). It is recommended to 28 | replace `master` with [a release tag](https://github.com/jshttp/mime-db/tags) 29 | as the JSON format may change in the future. 30 | 31 | ``` 32 | https://cdn.jsdelivr.net/gh/jshttp/mime-db@master/db.json 33 | ``` 34 | 35 | ## Usage 36 | 37 | ```js 38 | var db = require('mime-db') 39 | 40 | // grab data on .js files 41 | var data = db['application/javascript'] 42 | ``` 43 | 44 | ## Data Structure 45 | 46 | The JSON file is a map lookup for lowercased mime types. 47 | Each mime type has the following properties: 48 | 49 | - `.source` - where the mime type is defined. 50 | If not set, it's probably a custom media type. 51 | - `apache` - [Apache common media types](http://svn.apache.org/repos/asf/httpd/httpd/trunk/docs/conf/mime.types) 52 | - `iana` - [IANA-defined media types](http://www.iana.org/assignments/media-types/media-types.xhtml) 53 | - `nginx` - [nginx media types](http://hg.nginx.org/nginx/raw-file/default/conf/mime.types) 54 | - `.extensions[]` - known extensions associated with this mime type. 55 | - `.compressible` - whether a file of this type can be gzipped. 56 | - `.charset` - the default charset associated with this type, if any. 57 | 58 | If unknown, every property could be `undefined`. 59 | 60 | ## Contributing 61 | 62 | To edit the database, only make PRs against `src/custom-types.json` or 63 | `src/custom-suffix.json`. 64 | 65 | The `src/custom-types.json` file is a JSON object with the MIME type as the 66 | keys and the values being an object with the following keys: 67 | 68 | - `compressible` - leave out if you don't know, otherwise `true`/`false` to 69 | indicate whether the data represented by the type is typically compressible. 70 | - `extensions` - include an array of file extensions that are associated with 71 | the type. 72 | - `notes` - human-readable notes about the type, typically what the type is. 73 | - `sources` - include an array of URLs of where the MIME type and the associated 74 | extensions are sourced from. This needs to be a [primary source](https://en.wikipedia.org/wiki/Primary_source); 75 | links to type aggregating sites and Wikipedia are _not acceptable_. 76 | 77 | To update the build, run `npm run build`. 78 | 79 | ### Adding Custom Media Types 80 | 81 | The best way to get new media types included in this library is to register 82 | them with the IANA. The community registration procedure is outlined in 83 | [RFC 6838 section 5](http://tools.ietf.org/html/rfc6838#section-5). Types 84 | registered with the IANA are automatically pulled into this library. 85 | 86 | If that is not possible / feasible, they can be added directly here as a 87 | "custom" type. To do this, it is required to have a primary source that 88 | definitively lists the media type. If an extension is going to be listed as 89 | associateed with this media type, the source must definitively link the 90 | media type and extension as well. 91 | 92 | [ci-image]: https://badgen.net/github/checks/jshttp/mime-db/master?label=ci 93 | [ci-url]: https://github.com/jshttp/mime-db/actions?query=workflow%3Aci 94 | [coveralls-image]: https://badgen.net/coveralls/c/github/jshttp/mime-db/master 95 | [coveralls-url]: https://coveralls.io/r/jshttp/mime-db?branch=master 96 | [node-image]: https://badgen.net/npm/node/mime-db 97 | [node-url]: https://nodejs.org/en/download 98 | [npm-downloads-image]: https://badgen.net/npm/dm/mime-db 99 | [npm-url]: https://npmjs.org/package/mime-db 100 | [npm-version-image]: https://badgen.net/npm/v/mime-db 101 | -------------------------------------------------------------------------------- /node_modules/mime-db/index.js: -------------------------------------------------------------------------------- 1 | /*! 2 | * mime-db 3 | * Copyright(c) 2014 Jonathan Ong 4 | * Copyright(c) 2015-2022 Douglas Christopher Wilson 5 | * MIT Licensed 6 | */ 7 | 8 | /** 9 | * Module exports. 10 | */ 11 | 12 | module.exports = require('./db.json') 13 | -------------------------------------------------------------------------------- /node_modules/mime-db/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "mime-db", 3 | "description": "Media Type Database", 4 | "version": "1.52.0", 5 | "contributors": [ 6 | "Douglas Christopher Wilson ", 7 | "Jonathan Ong (http://jongleberry.com)", 8 | "Robert Kieffer (http://github.com/broofa)" 9 | ], 10 | "license": "MIT", 11 | "keywords": [ 12 | "mime", 13 | "db", 14 | "type", 15 | "types", 16 | "database", 17 | "charset", 18 | "charsets" 19 | ], 20 | "repository": "jshttp/mime-db", 21 | "devDependencies": { 22 | "bluebird": "3.7.2", 23 | "co": "4.6.0", 24 | "cogent": "1.0.1", 25 | "csv-parse": "4.16.3", 26 | "eslint": "7.32.0", 27 | "eslint-config-standard": "15.0.1", 28 | "eslint-plugin-import": "2.25.4", 29 | "eslint-plugin-markdown": "2.2.1", 30 | "eslint-plugin-node": "11.1.0", 31 | "eslint-plugin-promise": "5.1.1", 32 | "eslint-plugin-standard": "4.1.0", 33 | "gnode": "0.1.2", 34 | "media-typer": "1.1.0", 35 | "mocha": "9.2.1", 36 | "nyc": "15.1.0", 37 | "raw-body": "2.5.0", 38 | "stream-to-array": "2.3.0" 39 | }, 40 | "files": [ 41 | "HISTORY.md", 42 | "LICENSE", 43 | "README.md", 44 | "db.json", 45 | "index.js" 46 | ], 47 | "engines": { 48 | "node": ">= 0.6" 49 | }, 50 | "scripts": { 51 | "build": "node scripts/build", 52 | "fetch": "node scripts/fetch-apache && gnode scripts/fetch-iana && node scripts/fetch-nginx", 53 | "lint": "eslint .", 54 | "test": "mocha --reporter spec --bail --check-leaks test/", 55 | "test-ci": "nyc --reporter=lcov --reporter=text npm test", 56 | "test-cov": "nyc --reporter=html --reporter=text npm test", 57 | "update": "npm run fetch && npm run build", 58 | "version": "node scripts/version-history.js && git add HISTORY.md" 59 | } 60 | } 61 | -------------------------------------------------------------------------------- /node_modules/mime-types/LICENSE: -------------------------------------------------------------------------------- 1 | (The MIT License) 2 | 3 | Copyright (c) 2014 Jonathan Ong 4 | Copyright (c) 2015 Douglas Christopher Wilson 5 | 6 | Permission is hereby granted, free of charge, to any person obtaining 7 | a copy of this software and associated documentation files (the 8 | 'Software'), to deal in the Software without restriction, including 9 | without limitation the rights to use, copy, modify, merge, publish, 10 | distribute, sublicense, and/or sell copies of the Software, and to 11 | permit persons to whom the Software is furnished to do so, subject to 12 | the following conditions: 13 | 14 | The above copyright notice and this permission notice shall be 15 | included in all copies or substantial portions of the Software. 16 | 17 | THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, 18 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 19 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 20 | IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY 21 | CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, 22 | TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE 23 | SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 24 | -------------------------------------------------------------------------------- /node_modules/mime-types/README.md: -------------------------------------------------------------------------------- 1 | # mime-types 2 | 3 | [![NPM Version][npm-version-image]][npm-url] 4 | [![NPM Downloads][npm-downloads-image]][npm-url] 5 | [![Node.js Version][node-version-image]][node-version-url] 6 | [![Build Status][ci-image]][ci-url] 7 | [![Test Coverage][coveralls-image]][coveralls-url] 8 | 9 | The ultimate javascript content-type utility. 10 | 11 | Similar to [the `mime@1.x` module](https://www.npmjs.com/package/mime), except: 12 | 13 | - __No fallbacks.__ Instead of naively returning the first available type, 14 | `mime-types` simply returns `false`, so do 15 | `var type = mime.lookup('unrecognized') || 'application/octet-stream'`. 16 | - No `new Mime()` business, so you could do `var lookup = require('mime-types').lookup`. 17 | - No `.define()` functionality 18 | - Bug fixes for `.lookup(path)` 19 | 20 | Otherwise, the API is compatible with `mime` 1.x. 21 | 22 | ## Install 23 | 24 | This is a [Node.js](https://nodejs.org/en/) module available through the 25 | [npm registry](https://www.npmjs.com/). Installation is done using the 26 | [`npm install` command](https://docs.npmjs.com/getting-started/installing-npm-packages-locally): 27 | 28 | ```sh 29 | $ npm install mime-types 30 | ``` 31 | 32 | ## Adding Types 33 | 34 | All mime types are based on [mime-db](https://www.npmjs.com/package/mime-db), 35 | so open a PR there if you'd like to add mime types. 36 | 37 | ## API 38 | 39 | ```js 40 | var mime = require('mime-types') 41 | ``` 42 | 43 | All functions return `false` if input is invalid or not found. 44 | 45 | ### mime.lookup(path) 46 | 47 | Lookup the content-type associated with a file. 48 | 49 | ```js 50 | mime.lookup('json') // 'application/json' 51 | mime.lookup('.md') // 'text/markdown' 52 | mime.lookup('file.html') // 'text/html' 53 | mime.lookup('folder/file.js') // 'application/javascript' 54 | mime.lookup('folder/.htaccess') // false 55 | 56 | mime.lookup('cats') // false 57 | ``` 58 | 59 | ### mime.contentType(type) 60 | 61 | Create a full content-type header given a content-type or extension. 62 | When given an extension, `mime.lookup` is used to get the matching 63 | content-type, otherwise the given content-type is used. Then if the 64 | content-type does not already have a `charset` parameter, `mime.charset` 65 | is used to get the default charset and add to the returned content-type. 66 | 67 | ```js 68 | mime.contentType('markdown') // 'text/x-markdown; charset=utf-8' 69 | mime.contentType('file.json') // 'application/json; charset=utf-8' 70 | mime.contentType('text/html') // 'text/html; charset=utf-8' 71 | mime.contentType('text/html; charset=iso-8859-1') // 'text/html; charset=iso-8859-1' 72 | 73 | // from a full path 74 | mime.contentType(path.extname('/path/to/file.json')) // 'application/json; charset=utf-8' 75 | ``` 76 | 77 | ### mime.extension(type) 78 | 79 | Get the default extension for a content-type. 80 | 81 | ```js 82 | mime.extension('application/octet-stream') // 'bin' 83 | ``` 84 | 85 | ### mime.charset(type) 86 | 87 | Lookup the implied default charset of a content-type. 88 | 89 | ```js 90 | mime.charset('text/markdown') // 'UTF-8' 91 | ``` 92 | 93 | ### var type = mime.types[extension] 94 | 95 | A map of content-types by extension. 96 | 97 | ### [extensions...] = mime.extensions[type] 98 | 99 | A map of extensions by content-type. 100 | 101 | ## License 102 | 103 | [MIT](LICENSE) 104 | 105 | [ci-image]: https://badgen.net/github/checks/jshttp/mime-types/master?label=ci 106 | [ci-url]: https://github.com/jshttp/mime-types/actions/workflows/ci.yml 107 | [coveralls-image]: https://badgen.net/coveralls/c/github/jshttp/mime-types/master 108 | [coveralls-url]: https://coveralls.io/r/jshttp/mime-types?branch=master 109 | [node-version-image]: https://badgen.net/npm/node/mime-types 110 | [node-version-url]: https://nodejs.org/en/download 111 | [npm-downloads-image]: https://badgen.net/npm/dm/mime-types 112 | [npm-url]: https://npmjs.org/package/mime-types 113 | [npm-version-image]: https://badgen.net/npm/v/mime-types 114 | -------------------------------------------------------------------------------- /node_modules/mime-types/index.js: -------------------------------------------------------------------------------- 1 | /*! 2 | * mime-types 3 | * Copyright(c) 2014 Jonathan Ong 4 | * Copyright(c) 2015 Douglas Christopher Wilson 5 | * MIT Licensed 6 | */ 7 | 8 | 'use strict' 9 | 10 | /** 11 | * Module dependencies. 12 | * @private 13 | */ 14 | 15 | var db = require('mime-db') 16 | var extname = require('path').extname 17 | 18 | /** 19 | * Module variables. 20 | * @private 21 | */ 22 | 23 | var EXTRACT_TYPE_REGEXP = /^\s*([^;\s]*)(?:;|\s|$)/ 24 | var TEXT_TYPE_REGEXP = /^text\//i 25 | 26 | /** 27 | * Module exports. 28 | * @public 29 | */ 30 | 31 | exports.charset = charset 32 | exports.charsets = { lookup: charset } 33 | exports.contentType = contentType 34 | exports.extension = extension 35 | exports.extensions = Object.create(null) 36 | exports.lookup = lookup 37 | exports.types = Object.create(null) 38 | 39 | // Populate the extensions/types maps 40 | populateMaps(exports.extensions, exports.types) 41 | 42 | /** 43 | * Get the default charset for a MIME type. 44 | * 45 | * @param {string} type 46 | * @return {boolean|string} 47 | */ 48 | 49 | function charset (type) { 50 | if (!type || typeof type !== 'string') { 51 | return false 52 | } 53 | 54 | // TODO: use media-typer 55 | var match = EXTRACT_TYPE_REGEXP.exec(type) 56 | var mime = match && db[match[1].toLowerCase()] 57 | 58 | if (mime && mime.charset) { 59 | return mime.charset 60 | } 61 | 62 | // default text/* to utf-8 63 | if (match && TEXT_TYPE_REGEXP.test(match[1])) { 64 | return 'UTF-8' 65 | } 66 | 67 | return false 68 | } 69 | 70 | /** 71 | * Create a full Content-Type header given a MIME type or extension. 72 | * 73 | * @param {string} str 74 | * @return {boolean|string} 75 | */ 76 | 77 | function contentType (str) { 78 | // TODO: should this even be in this module? 79 | if (!str || typeof str !== 'string') { 80 | return false 81 | } 82 | 83 | var mime = str.indexOf('/') === -1 84 | ? exports.lookup(str) 85 | : str 86 | 87 | if (!mime) { 88 | return false 89 | } 90 | 91 | // TODO: use content-type or other module 92 | if (mime.indexOf('charset') === -1) { 93 | var charset = exports.charset(mime) 94 | if (charset) mime += '; charset=' + charset.toLowerCase() 95 | } 96 | 97 | return mime 98 | } 99 | 100 | /** 101 | * Get the default extension for a MIME type. 102 | * 103 | * @param {string} type 104 | * @return {boolean|string} 105 | */ 106 | 107 | function extension (type) { 108 | if (!type || typeof type !== 'string') { 109 | return false 110 | } 111 | 112 | // TODO: use media-typer 113 | var match = EXTRACT_TYPE_REGEXP.exec(type) 114 | 115 | // get extensions 116 | var exts = match && exports.extensions[match[1].toLowerCase()] 117 | 118 | if (!exts || !exts.length) { 119 | return false 120 | } 121 | 122 | return exts[0] 123 | } 124 | 125 | /** 126 | * Lookup the MIME type for a file path/extension. 127 | * 128 | * @param {string} path 129 | * @return {boolean|string} 130 | */ 131 | 132 | function lookup (path) { 133 | if (!path || typeof path !== 'string') { 134 | return false 135 | } 136 | 137 | // get the extension ("ext" or ".ext" or full path) 138 | var extension = extname('x.' + path) 139 | .toLowerCase() 140 | .substr(1) 141 | 142 | if (!extension) { 143 | return false 144 | } 145 | 146 | return exports.types[extension] || false 147 | } 148 | 149 | /** 150 | * Populate the extensions and types maps. 151 | * @private 152 | */ 153 | 154 | function populateMaps (extensions, types) { 155 | // source preference (least -> most) 156 | var preference = ['nginx', 'apache', undefined, 'iana'] 157 | 158 | Object.keys(db).forEach(function forEachMimeType (type) { 159 | var mime = db[type] 160 | var exts = mime.extensions 161 | 162 | if (!exts || !exts.length) { 163 | return 164 | } 165 | 166 | // mime -> extensions 167 | extensions[type] = exts 168 | 169 | // extension -> mime 170 | for (var i = 0; i < exts.length; i++) { 171 | var extension = exts[i] 172 | 173 | if (types[extension]) { 174 | var from = preference.indexOf(db[types[extension]].source) 175 | var to = preference.indexOf(mime.source) 176 | 177 | if (types[extension] !== 'application/octet-stream' && 178 | (from > to || (from === to && types[extension].substr(0, 12) === 'application/'))) { 179 | // skip the remapping 180 | continue 181 | } 182 | } 183 | 184 | // set the extension -> mime 185 | types[extension] = type 186 | } 187 | }) 188 | } 189 | -------------------------------------------------------------------------------- /node_modules/mime-types/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "mime-types", 3 | "description": "The ultimate javascript content-type utility.", 4 | "version": "2.1.35", 5 | "contributors": [ 6 | "Douglas Christopher Wilson ", 7 | "Jeremiah Senkpiel (https://searchbeam.jit.su)", 8 | "Jonathan Ong (http://jongleberry.com)" 9 | ], 10 | "license": "MIT", 11 | "keywords": [ 12 | "mime", 13 | "types" 14 | ], 15 | "repository": "jshttp/mime-types", 16 | "dependencies": { 17 | "mime-db": "1.52.0" 18 | }, 19 | "devDependencies": { 20 | "eslint": "7.32.0", 21 | "eslint-config-standard": "14.1.1", 22 | "eslint-plugin-import": "2.25.4", 23 | "eslint-plugin-markdown": "2.2.1", 24 | "eslint-plugin-node": "11.1.0", 25 | "eslint-plugin-promise": "5.2.0", 26 | "eslint-plugin-standard": "4.1.0", 27 | "mocha": "9.2.2", 28 | "nyc": "15.1.0" 29 | }, 30 | "files": [ 31 | "HISTORY.md", 32 | "LICENSE", 33 | "index.js" 34 | ], 35 | "engines": { 36 | "node": ">= 0.6" 37 | }, 38 | "scripts": { 39 | "lint": "eslint .", 40 | "test": "mocha --reporter spec test/test.js", 41 | "test-ci": "nyc --reporter=lcov --reporter=text npm test", 42 | "test-cov": "nyc --reporter=html --reporter=text npm test" 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /node_modules/openai/.github/ISSUE_TEMPLATE/bug_report.yml: -------------------------------------------------------------------------------- 1 | name: Bug report 2 | description: Create a report to help us improve 3 | labels: ["bug"] 4 | body: 5 | - type: markdown 6 | attributes: 7 | value: | 8 | Thanks for taking the time to fill out this bug report! 9 | - type: textarea 10 | id: what-happened 11 | attributes: 12 | label: Describe the bug 13 | description: A clear and concise description of what the bug is, and any additional context. 14 | placeholder: Tell us what you see! 15 | validations: 16 | required: true 17 | - type: textarea 18 | id: repro-steps 19 | attributes: 20 | label: To Reproduce 21 | description: Steps to reproduce the behavior. 22 | placeholder: | 23 | 1. Fetch a '...' 24 | 2. Update the '....' 25 | 3. See error 26 | validations: 27 | required: true 28 | - type: textarea 29 | id: code-snippets 30 | attributes: 31 | label: Code snippets 32 | description: If applicable, add code snippets to help explain your problem. 33 | render: JavaScript 34 | validations: 35 | required: false 36 | - type: input 37 | id: os 38 | attributes: 39 | label: OS 40 | placeholder: macOS 41 | validations: 42 | required: true 43 | - type: input 44 | id: language-version 45 | attributes: 46 | label: Node version 47 | placeholder: Node v16.14.2 48 | validations: 49 | required: true 50 | - type: input 51 | id: lib-version 52 | attributes: 53 | label: Library version 54 | placeholder: openai v3.0.1 55 | validations: 56 | required: true -------------------------------------------------------------------------------- /node_modules/openai/.github/ISSUE_TEMPLATE/config.yml: -------------------------------------------------------------------------------- 1 | blank_issues_enabled: false 2 | contact_links: 3 | - name: OpenAI support 4 | url: https://help.openai.com/ 5 | about: | 6 | Please only file issues here that you believe represent actual bugs or feature requests for the OpenAI Node library. 7 | If you're having general trouble with the OpenAI API, please visit our help center to get support. -------------------------------------------------------------------------------- /node_modules/openai/.github/ISSUE_TEMPLATE/feature_request.yml: -------------------------------------------------------------------------------- 1 | name: Feature request 2 | description: Suggest an idea for this library 3 | labels: ["feature-request"] 4 | body: 5 | - type: markdown 6 | attributes: 7 | value: | 8 | Thanks for taking the time to fill out this feature request! 9 | - type: textarea 10 | id: feature 11 | attributes: 12 | label: Describe the feature or improvement you're requesting 13 | description: A clear and concise description of what you want to happen. 14 | validations: 15 | required: true 16 | - type: textarea 17 | id: context 18 | attributes: 19 | label: Additional context 20 | description: Add any other context about the feature request here. -------------------------------------------------------------------------------- /node_modules/openai/.github/workflows/test.yml: -------------------------------------------------------------------------------- 1 | name: Node.js CI 2 | 3 | on: 4 | push: 5 | branches: [ master ] 6 | pull_request: 7 | branches: [ master ] 8 | 9 | jobs: 10 | build: 11 | 12 | runs-on: ubuntu-latest 13 | 14 | strategy: 15 | matrix: 16 | node-version: [16.x, 18.x] 17 | steps: 18 | - uses: actions/checkout@v3 19 | - name: Use Node.js ${{ matrix.node-version }} 20 | uses: actions/setup-node@v3 21 | with: 22 | node-version: ${{ matrix.node-version }} 23 | cache: 'npm' 24 | - run: npm ci 25 | - run: npm run build 26 | -------------------------------------------------------------------------------- /node_modules/openai/.openapi-generator-ignore: -------------------------------------------------------------------------------- 1 | .gitignore 2 | README.md 3 | git_push.sh 4 | package.json 5 | package-lock.json -------------------------------------------------------------------------------- /node_modules/openai/.openapi-generator/FILES: -------------------------------------------------------------------------------- 1 | .npmignore 2 | api.ts 3 | base.ts 4 | common.ts 5 | configuration.ts 6 | index.ts 7 | -------------------------------------------------------------------------------- /node_modules/openai/.openapi-generator/VERSION: -------------------------------------------------------------------------------- 1 | 6.4.0 -------------------------------------------------------------------------------- /node_modules/openai/LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License 2 | 3 | Copyright (c) OpenAI (https://openai.com) 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in 13 | all copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | THE SOFTWARE. 22 | -------------------------------------------------------------------------------- /node_modules/openai/README.md: -------------------------------------------------------------------------------- 1 | # OpenAI Node.js Library 2 | 3 | The OpenAI Node.js library provides convenient access to the OpenAI API from Node.js applications. Most of the code in this library is generated from our [OpenAPI specification](https://github.com/openai/openai-openapi). 4 | 5 | **Important note: this library is meant for server-side usage only, as using it in client-side browser code will expose your secret API key. [See here](https://beta.openai.com/docs/api-reference/authentication) for more details.** 6 | 7 | ## Installation 8 | 9 | ```bash 10 | $ npm install openai 11 | ``` 12 | 13 | ## Usage 14 | 15 | The library needs to be configured with your account's secret key, which is available on the [website](https://beta.openai.com/account/api-keys). We recommend setting it as an environment variable. Here's an example of initializing the library with the API key loaded from an environment variable and creating a completion: 16 | 17 | ```javascript 18 | const { Configuration, OpenAIApi } = require("openai"); 19 | 20 | const configuration = new Configuration({ 21 | apiKey: process.env.OPENAI_API_KEY, 22 | }); 23 | const openai = new OpenAIApi(configuration); 24 | 25 | const completion = await openai.createCompletion({ 26 | model: "text-davinci-003", 27 | prompt: "Hello world", 28 | }); 29 | console.log(completion.data.choices[0].text); 30 | ``` 31 | 32 | Check out the [full API documentation](https://beta.openai.com/docs/api-reference?lang=node.js) for examples of all the available functions. 33 | 34 | ### Request options 35 | 36 | All of the available API request functions additionally contain an optional final parameter where you can pass custom [axios request options](https://axios-http.com/docs/req_config), for example: 37 | 38 | 39 | ```javascript 40 | const completion = await openai.createCompletion( 41 | { 42 | model: "text-davinci-003", 43 | prompt: "Hello world", 44 | }, 45 | { 46 | timeout: 1000, 47 | headers: { 48 | "Example-Header": "example", 49 | }, 50 | } 51 | ); 52 | ``` 53 | 54 | ### Error handling 55 | 56 | API requests can potentially return errors due to invalid inputs or other issues. These errors can be handled with a `try...catch` statement, and the error details can be found in either `error.response` or `error.message`: 57 | 58 | ```javascript 59 | try { 60 | const completion = await openai.createCompletion({ 61 | model: "text-davinci-003", 62 | prompt: "Hello world", 63 | }); 64 | console.log(completion.data.choices[0].text); 65 | } catch (error) { 66 | if (error.response) { 67 | console.log(error.response.status); 68 | console.log(error.response.data); 69 | } else { 70 | console.log(error.message); 71 | } 72 | } 73 | ``` 74 | 75 | ### Streaming completions 76 | 77 | Streaming completions (`stream=true`) are not natively supported in this package yet, but [a workaround exists](https://github.com/openai/openai-node/issues/18#issuecomment-1369996933) if needed. 78 | 79 | ## Upgrade guide 80 | 81 | All breaking changes for major version releases are listed below. 82 | 83 | ### 3.0.0 84 | 85 | - The function signature of `createCompletion(engineId, params)` changed to `createCompletion(params)`. The value previously passed in as the `engineId` argument should now be passed in as `model` in the params object (e.g. `createCompletion({ model: "text-davinci-003", ... })`) 86 | - Replace any `createCompletionFromModel(params)` calls with `createCompletion(params)` 87 | 88 | ## Thanks 89 | 90 | Thank you to [ceifa](https://github.com/ceifa) for creating and maintaining the original unofficial `openai` npm package before we released this official library! ceifa's original package has been renamed to [gpt-x](https://www.npmjs.com/package/gpt-x). 91 | -------------------------------------------------------------------------------- /node_modules/openai/base.ts: -------------------------------------------------------------------------------- 1 | /* tslint:disable */ 2 | /* eslint-disable */ 3 | /** 4 | * OpenAI API 5 | * APIs for sampling from and fine-tuning language models 6 | * 7 | * The version of the OpenAPI document: 1.2.0 8 | * 9 | * 10 | * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). 11 | * https://openapi-generator.tech 12 | * Do not edit the class manually. 13 | */ 14 | 15 | 16 | import type { Configuration } from './configuration'; 17 | // Some imports not used depending on template conditions 18 | // @ts-ignore 19 | import type { AxiosPromise, AxiosInstance, AxiosRequestConfig } from 'axios'; 20 | import globalAxios from 'axios'; 21 | 22 | export const BASE_PATH = "https://api.openai.com/v1".replace(/\/+$/, ""); 23 | 24 | /** 25 | * 26 | * @export 27 | */ 28 | export const COLLECTION_FORMATS = { 29 | csv: ",", 30 | ssv: " ", 31 | tsv: "\t", 32 | pipes: "|", 33 | }; 34 | 35 | /** 36 | * 37 | * @export 38 | * @interface RequestArgs 39 | */ 40 | export interface RequestArgs { 41 | url: string; 42 | options: AxiosRequestConfig; 43 | } 44 | 45 | /** 46 | * 47 | * @export 48 | * @class BaseAPI 49 | */ 50 | export class BaseAPI { 51 | protected configuration: Configuration | undefined; 52 | 53 | constructor(configuration?: Configuration, protected basePath: string = BASE_PATH, protected axios: AxiosInstance = globalAxios) { 54 | if (configuration) { 55 | this.configuration = configuration; 56 | this.basePath = configuration.basePath || this.basePath; 57 | } 58 | } 59 | }; 60 | 61 | /** 62 | * 63 | * @export 64 | * @class RequiredError 65 | * @extends {Error} 66 | */ 67 | export class RequiredError extends Error { 68 | constructor(public field: string, msg?: string) { 69 | super(msg); 70 | this.name = "RequiredError" 71 | } 72 | } 73 | -------------------------------------------------------------------------------- /node_modules/openai/common.ts: -------------------------------------------------------------------------------- 1 | /* tslint:disable */ 2 | /* eslint-disable */ 3 | /** 4 | * OpenAI API 5 | * APIs for sampling from and fine-tuning language models 6 | * 7 | * The version of the OpenAPI document: 1.2.0 8 | * 9 | * 10 | * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). 11 | * https://openapi-generator.tech 12 | * Do not edit the class manually. 13 | */ 14 | 15 | 16 | import type { Configuration } from "./configuration"; 17 | import type { RequestArgs } from "./base"; 18 | import type { AxiosInstance, AxiosResponse } from 'axios'; 19 | import { RequiredError } from "./base"; 20 | 21 | /** 22 | * 23 | * @export 24 | */ 25 | export const DUMMY_BASE_URL = 'https://example.com' 26 | 27 | /** 28 | * 29 | * @throws {RequiredError} 30 | * @export 31 | */ 32 | export const assertParamExists = function (functionName: string, paramName: string, paramValue: unknown) { 33 | if (paramValue === null || paramValue === undefined) { 34 | throw new RequiredError(paramName, `Required parameter ${paramName} was null or undefined when calling ${functionName}.`); 35 | } 36 | } 37 | 38 | /** 39 | * 40 | * @export 41 | */ 42 | export const setApiKeyToObject = async function (object: any, keyParamName: string, configuration?: Configuration) { 43 | if (configuration && configuration.apiKey) { 44 | const localVarApiKeyValue = typeof configuration.apiKey === 'function' 45 | ? await configuration.apiKey(keyParamName) 46 | : await configuration.apiKey; 47 | object[keyParamName] = localVarApiKeyValue; 48 | } 49 | } 50 | 51 | /** 52 | * 53 | * @export 54 | */ 55 | export const setBasicAuthToObject = function (object: any, configuration?: Configuration) { 56 | if (configuration && (configuration.username || configuration.password)) { 57 | object["auth"] = { username: configuration.username, password: configuration.password }; 58 | } 59 | } 60 | 61 | /** 62 | * 63 | * @export 64 | */ 65 | export const setBearerAuthToObject = async function (object: any, configuration?: Configuration) { 66 | if (configuration && configuration.accessToken) { 67 | const accessToken = typeof configuration.accessToken === 'function' 68 | ? await configuration.accessToken() 69 | : await configuration.accessToken; 70 | object["Authorization"] = "Bearer " + accessToken; 71 | } 72 | } 73 | 74 | /** 75 | * 76 | * @export 77 | */ 78 | export const setOAuthToObject = async function (object: any, name: string, scopes: string[], configuration?: Configuration) { 79 | if (configuration && configuration.accessToken) { 80 | const localVarAccessTokenValue = typeof configuration.accessToken === 'function' 81 | ? await configuration.accessToken(name, scopes) 82 | : await configuration.accessToken; 83 | object["Authorization"] = "Bearer " + localVarAccessTokenValue; 84 | } 85 | } 86 | 87 | function setFlattenedQueryParams(urlSearchParams: URLSearchParams, parameter: any, key: string = ""): void { 88 | if (parameter == null) return; 89 | if (typeof parameter === "object") { 90 | if (Array.isArray(parameter)) { 91 | (parameter as any[]).forEach(item => setFlattenedQueryParams(urlSearchParams, item, key)); 92 | } 93 | else { 94 | Object.keys(parameter).forEach(currentKey => 95 | setFlattenedQueryParams(urlSearchParams, parameter[currentKey], `${key}${key !== '' ? '.' : ''}${currentKey}`) 96 | ); 97 | } 98 | } 99 | else { 100 | if (urlSearchParams.has(key)) { 101 | urlSearchParams.append(key, parameter); 102 | } 103 | else { 104 | urlSearchParams.set(key, parameter); 105 | } 106 | } 107 | } 108 | 109 | /** 110 | * 111 | * @export 112 | */ 113 | export const setSearchParams = function (url: URL, ...objects: any[]) { 114 | const searchParams = new URLSearchParams(url.search); 115 | setFlattenedQueryParams(searchParams, objects); 116 | url.search = searchParams.toString(); 117 | } 118 | 119 | /** 120 | * 121 | * @export 122 | */ 123 | export const serializeDataIfNeeded = function (value: any, requestOptions: any, configuration?: Configuration) { 124 | const nonString = typeof value !== 'string'; 125 | const needsSerialization = nonString && configuration && configuration.isJsonMime 126 | ? configuration.isJsonMime(requestOptions.headers['Content-Type']) 127 | : nonString; 128 | return needsSerialization 129 | ? JSON.stringify(value !== undefined ? value : {}) 130 | : (value || ""); 131 | } 132 | 133 | /** 134 | * 135 | * @export 136 | */ 137 | export const toPathString = function (url: URL) { 138 | return url.pathname + url.search + url.hash 139 | } 140 | 141 | /** 142 | * 143 | * @export 144 | */ 145 | export const createRequestFunction = function (axiosArgs: RequestArgs, globalAxios: AxiosInstance, BASE_PATH: string, configuration?: Configuration) { 146 | return >(axios: AxiosInstance = globalAxios, basePath: string = BASE_PATH) => { 147 | const axiosRequestArgs = {...axiosArgs.options, url: (configuration?.basePath || basePath) + axiosArgs.url}; 148 | return axios.request(axiosRequestArgs); 149 | }; 150 | } 151 | -------------------------------------------------------------------------------- /node_modules/openai/configuration.ts: -------------------------------------------------------------------------------- 1 | /* tslint:disable */ 2 | /* eslint-disable */ 3 | /** 4 | * OpenAI API 5 | * APIs for sampling from and fine-tuning language models 6 | * 7 | * The version of the OpenAPI document: 1.2.0 8 | * 9 | * 10 | * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). 11 | * https://openapi-generator.tech 12 | * Do not edit the class manually. 13 | */ 14 | 15 | 16 | const packageJson = require("../package.json"); 17 | 18 | export interface ConfigurationParameters { 19 | apiKey?: string | Promise | ((name: string) => string) | ((name: string) => Promise); 20 | organization?: string; 21 | username?: string; 22 | password?: string; 23 | accessToken?: string | Promise | ((name?: string, scopes?: string[]) => string) | ((name?: string, scopes?: string[]) => Promise); 24 | basePath?: string; 25 | baseOptions?: any; 26 | formDataCtor?: new () => any; 27 | } 28 | 29 | export class Configuration { 30 | /** 31 | * parameter for apiKey security 32 | * @param name security name 33 | * @memberof Configuration 34 | */ 35 | apiKey?: string | Promise | ((name: string) => string) | ((name: string) => Promise); 36 | /** 37 | * OpenAI organization id 38 | * 39 | * @type {string} 40 | * @memberof Configuration 41 | */ 42 | organization?: string; 43 | /** 44 | * parameter for basic security 45 | * 46 | * @type {string} 47 | * @memberof Configuration 48 | */ 49 | username?: string; 50 | /** 51 | * parameter for basic security 52 | * 53 | * @type {string} 54 | * @memberof Configuration 55 | */ 56 | password?: string; 57 | /** 58 | * parameter for oauth2 security 59 | * @param name security name 60 | * @param scopes oauth2 scope 61 | * @memberof Configuration 62 | */ 63 | accessToken?: string | Promise | ((name?: string, scopes?: string[]) => string) | ((name?: string, scopes?: string[]) => Promise); 64 | /** 65 | * override base path 66 | * 67 | * @type {string} 68 | * @memberof Configuration 69 | */ 70 | basePath?: string; 71 | /** 72 | * base options for axios calls 73 | * 74 | * @type {any} 75 | * @memberof Configuration 76 | */ 77 | baseOptions?: any; 78 | /** 79 | * The FormData constructor that will be used to create multipart form data 80 | * requests. You can inject this here so that execution environments that 81 | * do not support the FormData class can still run the generated client. 82 | * 83 | * @type {new () => FormData} 84 | */ 85 | formDataCtor?: new () => any; 86 | 87 | constructor(param: ConfigurationParameters = {}) { 88 | this.apiKey = param.apiKey; 89 | this.organization = param.organization; 90 | this.username = param.username; 91 | this.password = param.password; 92 | this.accessToken = param.accessToken; 93 | this.basePath = param.basePath; 94 | this.baseOptions = param.baseOptions; 95 | this.formDataCtor = param.formDataCtor; 96 | 97 | if (!this.baseOptions) { 98 | this.baseOptions = {}; 99 | } 100 | this.baseOptions.headers = { 101 | 'User-Agent': `OpenAI/NodeJS/${packageJson.version}`, 102 | 'Authorization': `Bearer ${this.apiKey}`, 103 | ...this.baseOptions.headers, 104 | } 105 | if (this.organization) { 106 | this.baseOptions.headers['OpenAI-Organization'] = this.organization; 107 | } 108 | if (!this.formDataCtor) { 109 | this.formDataCtor = require("form-data"); 110 | } 111 | } 112 | 113 | /** 114 | * Check if the given MIME is a JSON MIME. 115 | * JSON MIME examples: 116 | * application/json 117 | * application/json; charset=UTF8 118 | * APPLICATION/JSON 119 | * application/vnd.company+json 120 | * @param mime - MIME (Multipurpose Internet Mail Extensions) 121 | * @return True if the given MIME is JSON, false otherwise. 122 | */ 123 | public isJsonMime(mime: string): boolean { 124 | const jsonMime: RegExp = new RegExp('^(application\/json|[^;/ \t]+\/[^;/ \t]+[+]json)[ \t]*(;.*)?$', 'i'); 125 | return mime !== null && (jsonMime.test(mime) || mime.toLowerCase() === 'application/json-patch+json'); 126 | } 127 | } -------------------------------------------------------------------------------- /node_modules/openai/dist/base.d.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * OpenAI API 3 | * APIs for sampling from and fine-tuning language models 4 | * 5 | * The version of the OpenAPI document: 1.2.0 6 | * 7 | * 8 | * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). 9 | * https://openapi-generator.tech 10 | * Do not edit the class manually. 11 | */ 12 | import type { Configuration } from './configuration'; 13 | import type { AxiosInstance, AxiosRequestConfig } from 'axios'; 14 | export declare const BASE_PATH: string; 15 | /** 16 | * 17 | * @export 18 | */ 19 | export declare const COLLECTION_FORMATS: { 20 | csv: string; 21 | ssv: string; 22 | tsv: string; 23 | pipes: string; 24 | }; 25 | /** 26 | * 27 | * @export 28 | * @interface RequestArgs 29 | */ 30 | export interface RequestArgs { 31 | url: string; 32 | options: AxiosRequestConfig; 33 | } 34 | /** 35 | * 36 | * @export 37 | * @class BaseAPI 38 | */ 39 | export declare class BaseAPI { 40 | protected basePath: string; 41 | protected axios: AxiosInstance; 42 | protected configuration: Configuration | undefined; 43 | constructor(configuration?: Configuration, basePath?: string, axios?: AxiosInstance); 44 | } 45 | /** 46 | * 47 | * @export 48 | * @class RequiredError 49 | * @extends {Error} 50 | */ 51 | export declare class RequiredError extends Error { 52 | field: string; 53 | constructor(field: string, msg?: string); 54 | } 55 | -------------------------------------------------------------------------------- /node_modules/openai/dist/base.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | /* tslint:disable */ 3 | /* eslint-disable */ 4 | /** 5 | * OpenAI API 6 | * APIs for sampling from and fine-tuning language models 7 | * 8 | * The version of the OpenAPI document: 1.2.0 9 | * 10 | * 11 | * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). 12 | * https://openapi-generator.tech 13 | * Do not edit the class manually. 14 | */ 15 | Object.defineProperty(exports, "__esModule", { value: true }); 16 | exports.RequiredError = exports.BaseAPI = exports.COLLECTION_FORMATS = exports.BASE_PATH = void 0; 17 | const axios_1 = require("axios"); 18 | exports.BASE_PATH = "https://api.openai.com/v1".replace(/\/+$/, ""); 19 | /** 20 | * 21 | * @export 22 | */ 23 | exports.COLLECTION_FORMATS = { 24 | csv: ",", 25 | ssv: " ", 26 | tsv: "\t", 27 | pipes: "|", 28 | }; 29 | /** 30 | * 31 | * @export 32 | * @class BaseAPI 33 | */ 34 | class BaseAPI { 35 | constructor(configuration, basePath = exports.BASE_PATH, axios = axios_1.default) { 36 | this.basePath = basePath; 37 | this.axios = axios; 38 | if (configuration) { 39 | this.configuration = configuration; 40 | this.basePath = configuration.basePath || this.basePath; 41 | } 42 | } 43 | } 44 | exports.BaseAPI = BaseAPI; 45 | ; 46 | /** 47 | * 48 | * @export 49 | * @class RequiredError 50 | * @extends {Error} 51 | */ 52 | class RequiredError extends Error { 53 | constructor(field, msg) { 54 | super(msg); 55 | this.field = field; 56 | this.name = "RequiredError"; 57 | } 58 | } 59 | exports.RequiredError = RequiredError; 60 | -------------------------------------------------------------------------------- /node_modules/openai/dist/common.d.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * OpenAI API 3 | * APIs for sampling from and fine-tuning language models 4 | * 5 | * The version of the OpenAPI document: 1.2.0 6 | * 7 | * 8 | * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). 9 | * https://openapi-generator.tech 10 | * Do not edit the class manually. 11 | */ 12 | import type { Configuration } from "./configuration"; 13 | import type { RequestArgs } from "./base"; 14 | import type { AxiosInstance, AxiosResponse } from 'axios'; 15 | /** 16 | * 17 | * @export 18 | */ 19 | export declare const DUMMY_BASE_URL = "https://example.com"; 20 | /** 21 | * 22 | * @throws {RequiredError} 23 | * @export 24 | */ 25 | export declare const assertParamExists: (functionName: string, paramName: string, paramValue: unknown) => void; 26 | /** 27 | * 28 | * @export 29 | */ 30 | export declare const setApiKeyToObject: (object: any, keyParamName: string, configuration?: Configuration) => Promise; 31 | /** 32 | * 33 | * @export 34 | */ 35 | export declare const setBasicAuthToObject: (object: any, configuration?: Configuration) => void; 36 | /** 37 | * 38 | * @export 39 | */ 40 | export declare const setBearerAuthToObject: (object: any, configuration?: Configuration) => Promise; 41 | /** 42 | * 43 | * @export 44 | */ 45 | export declare const setOAuthToObject: (object: any, name: string, scopes: string[], configuration?: Configuration) => Promise; 46 | /** 47 | * 48 | * @export 49 | */ 50 | export declare const setSearchParams: (url: URL, ...objects: any[]) => void; 51 | /** 52 | * 53 | * @export 54 | */ 55 | export declare const serializeDataIfNeeded: (value: any, requestOptions: any, configuration?: Configuration) => any; 56 | /** 57 | * 58 | * @export 59 | */ 60 | export declare const toPathString: (url: URL) => string; 61 | /** 62 | * 63 | * @export 64 | */ 65 | export declare const createRequestFunction: (axiosArgs: RequestArgs, globalAxios: AxiosInstance, BASE_PATH: string, configuration?: Configuration) => >(axios?: AxiosInstance, basePath?: string) => Promise; 66 | -------------------------------------------------------------------------------- /node_modules/openai/dist/common.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | /* tslint:disable */ 3 | /* eslint-disable */ 4 | /** 5 | * OpenAI API 6 | * APIs for sampling from and fine-tuning language models 7 | * 8 | * The version of the OpenAPI document: 1.2.0 9 | * 10 | * 11 | * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). 12 | * https://openapi-generator.tech 13 | * Do not edit the class manually. 14 | */ 15 | var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { 16 | function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } 17 | return new (P || (P = Promise))(function (resolve, reject) { 18 | function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } 19 | function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } 20 | function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } 21 | step((generator = generator.apply(thisArg, _arguments || [])).next()); 22 | }); 23 | }; 24 | Object.defineProperty(exports, "__esModule", { value: true }); 25 | exports.createRequestFunction = exports.toPathString = exports.serializeDataIfNeeded = exports.setSearchParams = exports.setOAuthToObject = exports.setBearerAuthToObject = exports.setBasicAuthToObject = exports.setApiKeyToObject = exports.assertParamExists = exports.DUMMY_BASE_URL = void 0; 26 | const base_1 = require("./base"); 27 | /** 28 | * 29 | * @export 30 | */ 31 | exports.DUMMY_BASE_URL = 'https://example.com'; 32 | /** 33 | * 34 | * @throws {RequiredError} 35 | * @export 36 | */ 37 | exports.assertParamExists = function (functionName, paramName, paramValue) { 38 | if (paramValue === null || paramValue === undefined) { 39 | throw new base_1.RequiredError(paramName, `Required parameter ${paramName} was null or undefined when calling ${functionName}.`); 40 | } 41 | }; 42 | /** 43 | * 44 | * @export 45 | */ 46 | exports.setApiKeyToObject = function (object, keyParamName, configuration) { 47 | return __awaiter(this, void 0, void 0, function* () { 48 | if (configuration && configuration.apiKey) { 49 | const localVarApiKeyValue = typeof configuration.apiKey === 'function' 50 | ? yield configuration.apiKey(keyParamName) 51 | : yield configuration.apiKey; 52 | object[keyParamName] = localVarApiKeyValue; 53 | } 54 | }); 55 | }; 56 | /** 57 | * 58 | * @export 59 | */ 60 | exports.setBasicAuthToObject = function (object, configuration) { 61 | if (configuration && (configuration.username || configuration.password)) { 62 | object["auth"] = { username: configuration.username, password: configuration.password }; 63 | } 64 | }; 65 | /** 66 | * 67 | * @export 68 | */ 69 | exports.setBearerAuthToObject = function (object, configuration) { 70 | return __awaiter(this, void 0, void 0, function* () { 71 | if (configuration && configuration.accessToken) { 72 | const accessToken = typeof configuration.accessToken === 'function' 73 | ? yield configuration.accessToken() 74 | : yield configuration.accessToken; 75 | object["Authorization"] = "Bearer " + accessToken; 76 | } 77 | }); 78 | }; 79 | /** 80 | * 81 | * @export 82 | */ 83 | exports.setOAuthToObject = function (object, name, scopes, configuration) { 84 | return __awaiter(this, void 0, void 0, function* () { 85 | if (configuration && configuration.accessToken) { 86 | const localVarAccessTokenValue = typeof configuration.accessToken === 'function' 87 | ? yield configuration.accessToken(name, scopes) 88 | : yield configuration.accessToken; 89 | object["Authorization"] = "Bearer " + localVarAccessTokenValue; 90 | } 91 | }); 92 | }; 93 | function setFlattenedQueryParams(urlSearchParams, parameter, key = "") { 94 | if (parameter == null) 95 | return; 96 | if (typeof parameter === "object") { 97 | if (Array.isArray(parameter)) { 98 | parameter.forEach(item => setFlattenedQueryParams(urlSearchParams, item, key)); 99 | } 100 | else { 101 | Object.keys(parameter).forEach(currentKey => setFlattenedQueryParams(urlSearchParams, parameter[currentKey], `${key}${key !== '' ? '.' : ''}${currentKey}`)); 102 | } 103 | } 104 | else { 105 | if (urlSearchParams.has(key)) { 106 | urlSearchParams.append(key, parameter); 107 | } 108 | else { 109 | urlSearchParams.set(key, parameter); 110 | } 111 | } 112 | } 113 | /** 114 | * 115 | * @export 116 | */ 117 | exports.setSearchParams = function (url, ...objects) { 118 | const searchParams = new URLSearchParams(url.search); 119 | setFlattenedQueryParams(searchParams, objects); 120 | url.search = searchParams.toString(); 121 | }; 122 | /** 123 | * 124 | * @export 125 | */ 126 | exports.serializeDataIfNeeded = function (value, requestOptions, configuration) { 127 | const nonString = typeof value !== 'string'; 128 | const needsSerialization = nonString && configuration && configuration.isJsonMime 129 | ? configuration.isJsonMime(requestOptions.headers['Content-Type']) 130 | : nonString; 131 | return needsSerialization 132 | ? JSON.stringify(value !== undefined ? value : {}) 133 | : (value || ""); 134 | }; 135 | /** 136 | * 137 | * @export 138 | */ 139 | exports.toPathString = function (url) { 140 | return url.pathname + url.search + url.hash; 141 | }; 142 | /** 143 | * 144 | * @export 145 | */ 146 | exports.createRequestFunction = function (axiosArgs, globalAxios, BASE_PATH, configuration) { 147 | return (axios = globalAxios, basePath = BASE_PATH) => { 148 | const axiosRequestArgs = Object.assign(Object.assign({}, axiosArgs.options), { url: ((configuration === null || configuration === void 0 ? void 0 : configuration.basePath) || basePath) + axiosArgs.url }); 149 | return axios.request(axiosRequestArgs); 150 | }; 151 | }; 152 | -------------------------------------------------------------------------------- /node_modules/openai/dist/configuration.d.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * OpenAI API 3 | * APIs for sampling from and fine-tuning language models 4 | * 5 | * The version of the OpenAPI document: 1.2.0 6 | * 7 | * 8 | * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). 9 | * https://openapi-generator.tech 10 | * Do not edit the class manually. 11 | */ 12 | export interface ConfigurationParameters { 13 | apiKey?: string | Promise | ((name: string) => string) | ((name: string) => Promise); 14 | organization?: string; 15 | username?: string; 16 | password?: string; 17 | accessToken?: string | Promise | ((name?: string, scopes?: string[]) => string) | ((name?: string, scopes?: string[]) => Promise); 18 | basePath?: string; 19 | baseOptions?: any; 20 | formDataCtor?: new () => any; 21 | } 22 | export declare class Configuration { 23 | /** 24 | * parameter for apiKey security 25 | * @param name security name 26 | * @memberof Configuration 27 | */ 28 | apiKey?: string | Promise | ((name: string) => string) | ((name: string) => Promise); 29 | /** 30 | * OpenAI organization id 31 | * 32 | * @type {string} 33 | * @memberof Configuration 34 | */ 35 | organization?: string; 36 | /** 37 | * parameter for basic security 38 | * 39 | * @type {string} 40 | * @memberof Configuration 41 | */ 42 | username?: string; 43 | /** 44 | * parameter for basic security 45 | * 46 | * @type {string} 47 | * @memberof Configuration 48 | */ 49 | password?: string; 50 | /** 51 | * parameter for oauth2 security 52 | * @param name security name 53 | * @param scopes oauth2 scope 54 | * @memberof Configuration 55 | */ 56 | accessToken?: string | Promise | ((name?: string, scopes?: string[]) => string) | ((name?: string, scopes?: string[]) => Promise); 57 | /** 58 | * override base path 59 | * 60 | * @type {string} 61 | * @memberof Configuration 62 | */ 63 | basePath?: string; 64 | /** 65 | * base options for axios calls 66 | * 67 | * @type {any} 68 | * @memberof Configuration 69 | */ 70 | baseOptions?: any; 71 | /** 72 | * The FormData constructor that will be used to create multipart form data 73 | * requests. You can inject this here so that execution environments that 74 | * do not support the FormData class can still run the generated client. 75 | * 76 | * @type {new () => FormData} 77 | */ 78 | formDataCtor?: new () => any; 79 | constructor(param?: ConfigurationParameters); 80 | /** 81 | * Check if the given MIME is a JSON MIME. 82 | * JSON MIME examples: 83 | * application/json 84 | * application/json; charset=UTF8 85 | * APPLICATION/JSON 86 | * application/vnd.company+json 87 | * @param mime - MIME (Multipurpose Internet Mail Extensions) 88 | * @return True if the given MIME is JSON, false otherwise. 89 | */ 90 | isJsonMime(mime: string): boolean; 91 | } 92 | -------------------------------------------------------------------------------- /node_modules/openai/dist/configuration.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | /* tslint:disable */ 3 | /* eslint-disable */ 4 | /** 5 | * OpenAI API 6 | * APIs for sampling from and fine-tuning language models 7 | * 8 | * The version of the OpenAPI document: 1.2.0 9 | * 10 | * 11 | * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). 12 | * https://openapi-generator.tech 13 | * Do not edit the class manually. 14 | */ 15 | Object.defineProperty(exports, "__esModule", { value: true }); 16 | exports.Configuration = void 0; 17 | const packageJson = require("../package.json"); 18 | class Configuration { 19 | constructor(param = {}) { 20 | this.apiKey = param.apiKey; 21 | this.organization = param.organization; 22 | this.username = param.username; 23 | this.password = param.password; 24 | this.accessToken = param.accessToken; 25 | this.basePath = param.basePath; 26 | this.baseOptions = param.baseOptions; 27 | this.formDataCtor = param.formDataCtor; 28 | if (!this.baseOptions) { 29 | this.baseOptions = {}; 30 | } 31 | this.baseOptions.headers = Object.assign({ 'User-Agent': `OpenAI/NodeJS/${packageJson.version}`, 'Authorization': `Bearer ${this.apiKey}` }, this.baseOptions.headers); 32 | if (this.organization) { 33 | this.baseOptions.headers['OpenAI-Organization'] = this.organization; 34 | } 35 | if (!this.formDataCtor) { 36 | this.formDataCtor = require("form-data"); 37 | } 38 | } 39 | /** 40 | * Check if the given MIME is a JSON MIME. 41 | * JSON MIME examples: 42 | * application/json 43 | * application/json; charset=UTF8 44 | * APPLICATION/JSON 45 | * application/vnd.company+json 46 | * @param mime - MIME (Multipurpose Internet Mail Extensions) 47 | * @return True if the given MIME is JSON, false otherwise. 48 | */ 49 | isJsonMime(mime) { 50 | const jsonMime = new RegExp('^(application\/json|[^;/ \t]+\/[^;/ \t]+[+]json)[ \t]*(;.*)?$', 'i'); 51 | return mime !== null && (jsonMime.test(mime) || mime.toLowerCase() === 'application/json-patch+json'); 52 | } 53 | } 54 | exports.Configuration = Configuration; 55 | -------------------------------------------------------------------------------- /node_modules/openai/dist/index.d.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * OpenAI API 3 | * APIs for sampling from and fine-tuning language models 4 | * 5 | * The version of the OpenAPI document: 1.2.0 6 | * 7 | * 8 | * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). 9 | * https://openapi-generator.tech 10 | * Do not edit the class manually. 11 | */ 12 | export * from "./api"; 13 | export * from "./configuration"; 14 | -------------------------------------------------------------------------------- /node_modules/openai/dist/index.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | /* tslint:disable */ 3 | /* eslint-disable */ 4 | /** 5 | * OpenAI API 6 | * APIs for sampling from and fine-tuning language models 7 | * 8 | * The version of the OpenAPI document: 1.2.0 9 | * 10 | * 11 | * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). 12 | * https://openapi-generator.tech 13 | * Do not edit the class manually. 14 | */ 15 | var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { 16 | if (k2 === undefined) k2 = k; 17 | Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } }); 18 | }) : (function(o, m, k, k2) { 19 | if (k2 === undefined) k2 = k; 20 | o[k2] = m[k]; 21 | })); 22 | var __exportStar = (this && this.__exportStar) || function(m, exports) { 23 | for (var p in m) if (p !== "default" && !exports.hasOwnProperty(p)) __createBinding(exports, m, p); 24 | }; 25 | Object.defineProperty(exports, "__esModule", { value: true }); 26 | __exportStar(require("./api"), exports); 27 | __exportStar(require("./configuration"), exports); 28 | -------------------------------------------------------------------------------- /node_modules/openai/index.ts: -------------------------------------------------------------------------------- 1 | /* tslint:disable */ 2 | /* eslint-disable */ 3 | /** 4 | * OpenAI API 5 | * APIs for sampling from and fine-tuning language models 6 | * 7 | * The version of the OpenAPI document: 1.2.0 8 | * 9 | * 10 | * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). 11 | * https://openapi-generator.tech 12 | * Do not edit the class manually. 13 | */ 14 | 15 | 16 | export * from "./api"; 17 | export * from "./configuration"; 18 | 19 | -------------------------------------------------------------------------------- /node_modules/openai/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "openai", 3 | "version": "3.2.1", 4 | "description": "Node.js library for the OpenAI API", 5 | "repository": { 6 | "type": "git", 7 | "url": "git@github.com:openai/openai-node.git" 8 | }, 9 | "keywords": [ 10 | "openai", 11 | "open", 12 | "ai", 13 | "gpt-3", 14 | "gpt3" 15 | ], 16 | "author": "OpenAI", 17 | "license": "MIT", 18 | "main": "./dist/index.js", 19 | "types": "./dist/index.d.ts", 20 | "scripts": { 21 | "build": "tsc --outDir dist/" 22 | }, 23 | "dependencies": { 24 | "axios": "^0.26.0", 25 | "form-data": "^4.0.0" 26 | }, 27 | "devDependencies": { 28 | "@types/node": "^12.11.5", 29 | "typescript": "^3.6.4" 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /node_modules/openai/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "declaration": true, 4 | "target": "es6", 5 | "module": "commonjs", 6 | "noImplicitAny": true, 7 | "outDir": "dist", 8 | "rootDir": ".", 9 | "typeRoots": [ 10 | "node_modules/@types" 11 | ] 12 | }, 13 | "exclude": [ 14 | "dist", 15 | "node_modules" 16 | ] 17 | } 18 | -------------------------------------------------------------------------------- /node_modules/python-shell/CHANGELOG.md: -------------------------------------------------------------------------------- 1 | ## [5.0.0] - 2023-02-10 2 | ### BREAKING CHANGES 3 | - run and runString now return a promise instead of a using a callback. 4 | - You will need to 1) check the return value, 2) remove the callback argument, and 3) change to a promise 5 | - see readme for usage examples 6 | 7 | ### Other notes 8 | - I confirmed that python-shell works with python 3.11 and node v18. 9 | 10 | ## [4.0.0] - 2023-02-10 11 | ### Changed 12 | - run and runString now return a promise instead of a using a callback. 13 | - This is somewhat backwards compatible with previous behavior 14 | 15 | ## [3.0.1] - 2021-10-09 16 | ### Fixed 17 | - Previously when you called the kill method the terminated attribute was always set to true, regardless of whether the process was actually killed. Now the terminated boolean is set to true if kill succeeds, false otherwise. [#255](https://github.com/extrabacon/python-shell/issues/255) 18 | 19 | ## [3.0.0] - 2021-03-07 20 | ### Changed 21 | - **BREAKING** Default python path changed back to `python` on Windows. [#237](https://github.com/extrabacon/python-shell/issues/237) 22 | - **BREAKING** `error` event renamed to `pythonError` event. [#118](https://github.com/extrabacon/python-shell/issues/118) 23 | - **BREAKING** `receive` methods removed in favor of `splitter` arguments in the constructor. This lets the default splitting logic reside in a reuseable stream transformer. Now if you have extra pipes you can reuse `newlineTransformer` to split incoming data into newline-seperated lines. 24 | 25 | ### Added 26 | - `error` event that is fired upon failure to launch process, among other things. [#118](https://github.com/extrabacon/python-shell/issues/118) 27 | 28 | ## [1.0.8] 29 | ### Fixed 30 | - @joaoe fixed a bug with pythonshell not working with unset std streams 31 | - https://github.com/extrabacon/python-shell/milestone/9 32 | 33 | ## [1.0.7] 34 | ### Changed 35 | - default python path updated to py on windows 36 | 37 | ## [1.0.4] 38 | ### Added 39 | - added getVersionSync 40 | 41 | ## [0.0.3] 42 | ### Fixed 43 | - fixed buffering in `PythonShell.receive`, fixing [#1](https://github.com/extrabacon/python-shell/issues/1) 44 | 45 | ## [0.0.2] 46 | ### Changed 47 | - improved documentation 48 | 49 | ## [0.0.1] 50 | ### Added 51 | - initial version 52 | - independent module moved from [extrabacon/pyspreadsheet](https://github.com/extrabacon/pyspreadsheet) 53 | 54 | -------------------------------------------------------------------------------- /node_modules/python-shell/a.d.ts: -------------------------------------------------------------------------------- 1 | export {}; 2 | -------------------------------------------------------------------------------- /node_modules/python-shell/a.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | Object.defineProperty(exports, "__esModule", { value: true }); 3 | const index_1 = require("./index"); 4 | const options = { 5 | scriptPath: 'C:\\dev\\python-shell', 6 | env: { PYTHONIOENCODING: 'utf8' }, 7 | }; 8 | const pyTeste = new index_1.PythonShell('a.py', options); 9 | pyTeste 10 | .on('message', (line) => { 11 | console.log(line); 12 | }) 13 | .on('stderr', (std) => { 14 | console.log(std); 15 | }) 16 | .on('error', err => { 17 | console.log('err'); 18 | console.log(err); 19 | }) 20 | .on('close', () => { 21 | console.log('Programa finalizado'); 22 | }); 23 | //# sourceMappingURL=a.js.map -------------------------------------------------------------------------------- /node_modules/python-shell/a.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"a.js","sourceRoot":"","sources":["a.ts"],"names":[],"mappings":";;AAAA,mCAA8C;AAE9C,MAAM,OAAO,GAAY;IACrB,UAAU,EAAE,uBAAuB;IACnC,GAAG,EAAE,EAAE,gBAAgB,EAAE,MAAM,EAAE;CACpC,CAAC;AAEF,MAAM,OAAO,GAAG,IAAI,mBAAW,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;AAEjD,OAAO;KACF,EAAE,CAAC,SAAS,EAAE,CAAC,IAAY,EAAE,EAAE;IAC5B,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;AACtB,CAAC,CAAC;KACD,EAAE,CAAC,QAAQ,EAAE,CAAC,GAAW,EAAE,EAAE;IAC1B,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;AACrB,CAAC,CAAC;KACD,EAAE,CAAC,OAAO,EAAE,GAAG,CAAC,EAAE;IACf,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;IACnB,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;AACrB,CAAC,CAAC;KACD,EAAE,CAAC,OAAO,EAAE,GAAG,EAAE;IACd,OAAO,CAAC,GAAG,CAAC,qBAAqB,CAAC,CAAC;AACvC,CAAC,CAAC,CAAC"} -------------------------------------------------------------------------------- /node_modules/python-shell/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "python-shell", 3 | "version": "5.0.0", 4 | "description": "Run Python scripts from Node.js with simple (but efficient) inter-process communication through stdio", 5 | "keywords": [ 6 | "python" 7 | ], 8 | "scripts": { 9 | "test": "tsc -p ./ && mocha -r ts-node/register", 10 | "appveyorTest": "tsc -p ./ && nyc mocha --reporter mocha-appveyor-reporter test/*.js", 11 | "compile": "tsc -watch -p ./", 12 | "compileOnce": "tsc -p ./" 13 | }, 14 | "devDependencies": { 15 | "@types/mocha": "^8.2.1", 16 | "@types/node": "^14.17.21", 17 | "@types/should": "^13.0.0", 18 | "mocha": "^8.2.1", 19 | "mocha-appveyor-reporter": "^0.4.0", 20 | "should": "^13.2.1", 21 | "ts-node": "^9.0.0", 22 | "typescript": "^4.4.3" 23 | }, 24 | "files": [ 25 | "*.d.ts", 26 | "*.js", 27 | "*.js.map", 28 | "CHANGELOG.md", 29 | "README.md" 30 | ], 31 | "repository": { 32 | "type": "git", 33 | "url": "http://github.com/extrabacon/python-shell" 34 | }, 35 | "homepage": "http://github.com/extrabacon/python-shell", 36 | "bugs": "http://github.com/extrabacon/python-shell/issues", 37 | "author": { 38 | "name": "Nicolas Mercier", 39 | "email": "nicolas@extrabacon.net" 40 | }, 41 | "engines": { 42 | "node": ">=0.10" 43 | }, 44 | "license": "MIT" 45 | } 46 | -------------------------------------------------------------------------------- /node_modules/python-shell/test.d.ts: -------------------------------------------------------------------------------- 1 | export {}; 2 | -------------------------------------------------------------------------------- /node_modules/python-shell/test.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | Object.defineProperty(exports, "__esModule", { value: true }); 3 | const _1 = require("."); 4 | const input = `print("aa\\n\\n\\nbb\\n\\ncc\\ndd")`; 5 | const options = {}; 6 | _1.PythonShell.runString(input, options, function (err, results) { 7 | //console.warn(err) 8 | console.log(results); 9 | }); 10 | //# sourceMappingURL=test.js.map -------------------------------------------------------------------------------- /node_modules/python-shell/test.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"test.js","sourceRoot":"","sources":["test.ts"],"names":[],"mappings":";;AAAA,wBAAgC;AAEhC,MAAM,KAAK,GAAG,qCAAqC,CAAA;AAEnD,MAAM,OAAO,GAAG,EAAE,CAAA;AAClB,cAAW,CAAC,SAAS,CAAC,KAAK,EAAE,OAAO,EAAE,UAAU,GAAG,EAAE,OAAO;IACxD,mBAAmB;IACnB,OAAO,CAAC,GAAG,CAAC,OAAO,CAAC,CAAA;AACxB,CAAC,CAAC,CAAA"} -------------------------------------------------------------------------------- /node_modules/python-shell/testShould.d.ts: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/emmethalm/tuneAI/597c28c9649489540bca4eec135fc675d00f6baf/node_modules/python-shell/testShould.d.ts -------------------------------------------------------------------------------- /node_modules/python-shell/testShould.js: -------------------------------------------------------------------------------- 1 | // import * as should from 'should'; 2 | // describe('PythonShell', function () { 3 | // describe('#ctor(script, options)', function () { 4 | // it('should spawn a Python process', function (done) { 5 | // class foo { 6 | // terminated: boolean; 7 | // } 8 | // let pyshell = new foo(); 9 | // pyshell.terminated = false; 10 | // pyshell.terminated.should.be.false; 11 | // }); 12 | // }) 13 | // }) 14 | //# sourceMappingURL=testShould.js.map -------------------------------------------------------------------------------- /node_modules/python-shell/testShould.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"testShould.js","sourceRoot":"","sources":["testShould.ts"],"names":[],"mappings":"AAAA,oCAAoC;AAEpC,wCAAwC;AAExC,uDAAuD;AACvD,gEAAgE;AAChE,0BAA0B;AAC1B,uCAAuC;AACvC,gBAAgB;AAChB,uCAAuC;AACvC,0CAA0C;AAC1C,kDAAkD;AAClD,cAAc;AACd,SAAS;AACT,KAAK"} -------------------------------------------------------------------------------- /node_modules/threading/.babelrc: -------------------------------------------------------------------------------- 1 | { "presets": ["es2015"] } 2 | -------------------------------------------------------------------------------- /node_modules/threading/.npmignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | .AppleDouble 3 | .LSOverride 4 | 5 | # Icon must end with two \r 6 | Icon 7 | 8 | 9 | # Thumbnails 10 | ._* 11 | 12 | # Files that might appear in the root of a volume 13 | .DocumentRevisions-V100 14 | .fseventsd 15 | .Spotlight-V100 16 | .TemporaryItems 17 | .Trashes 18 | .VolumeIcon.icns 19 | 20 | # Directories potentially created on remote AFP share 21 | .AppleDB 22 | .AppleDesktop 23 | Network Trash Folder 24 | Temporary Items 25 | .apdisk 26 | 27 | # Logs 28 | logs 29 | *.log 30 | npm-debug.log* 31 | 32 | # Runtime data 33 | pids 34 | *.pid 35 | *.seed 36 | 37 | # Directory for instrumented libs generated by jscoverage/JSCover 38 | lib-cov 39 | 40 | # Coverage directory used by tools like istanbul 41 | coverage 42 | 43 | # Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files) 44 | .grunt 45 | 46 | # node-waf configuration 47 | .lock-wscript 48 | 49 | # Compiled binary addons (http://nodejs.org/api/addons.html) 50 | build/Release 51 | 52 | # Dependency directory 53 | # https://docs.npmjs.com/misc/faq#should-i-check-my-node-modules-folder-into-git 54 | node_modules 55 | 56 | # Optional npm cache directory 57 | .npm 58 | 59 | # Optional REPL history 60 | .node_repl_history 61 | -------------------------------------------------------------------------------- /node_modules/threading/README.md: -------------------------------------------------------------------------------- 1 | # threading 2 | #### A clojure-inspired utility for threading arbitrary data into the first or last argument of a sequence of functions 3 | 4 | ### Motivation 5 | In order to compose function operations on arbitrary data, you have to nest functions 6 | ```javascript 7 | expect(subtract(add(3, 3) 3)).toBe(3); 8 | ``` 9 | The legibility of the example decreases as the number of functions increase. 10 | 11 | ### Example Usage 12 | 13 | #### Thread-first 14 | Apply the initial & resulting values of the function list to the first argument of the function. 15 | 16 | Simply provide an initial value then the functions you'd like to compose on the value. 17 | ```javascript 18 | import { threadFirst } from 'threading'; 19 | 20 | const value = threadFirst( 21 | 5, 22 | timesThree, 23 | plusOne 24 | ); 25 | 26 | expect(value).toBe(16); 27 | ``` 28 | 29 | To use with a function that should already have a value you can pass an array containing the function and the other arguments. 30 | ```javascript 31 | import { threadFirst } from 'threading'; 32 | 33 | const value = threadFirst( 34 | 5, 35 | [times 3], 36 | [divideby 5] 37 | ); 38 | 39 | expect(value).toBe(3); 40 | ``` 41 | 42 | #### Thread-last 43 | Apply the initial & resulting values of the function list to the last argument of the function. 44 | 45 | Simply provide an initial value then the functions you'd like to compose on the value. 46 | ```javascript 47 | import { threadLast } from 'threading'; 48 | 49 | const value = threadLast( 50 | 5, 51 | timesThree, 52 | plusOne 53 | ); 54 | 55 | expect(value).toBe(16); 56 | ``` 57 | 58 | To use with a function that should already have a value you can pass an array containing the function and the other arguments. 59 | ```javascript 60 | import { threadLast } from 'threading'; 61 | 62 | const value = threadFirst( 63 | 5, 64 | [times 2], 65 | [divideby 5] 66 | ); 67 | 68 | expect(value).toBe(0.5); 69 | ``` 70 | -------------------------------------------------------------------------------- /node_modules/threading/index.js: -------------------------------------------------------------------------------- 1 | (function webpackUniversalModuleDefinition(root, factory) { 2 | if(typeof exports === 'object' && typeof module === 'object') 3 | module.exports = factory(); 4 | else if(typeof define === 'function' && define.amd) 5 | define([], factory); 6 | else if(typeof exports === 'object') 7 | exports["threading"] = factory(); 8 | else 9 | root["threading"] = factory(); 10 | })(this, function() { 11 | return /******/ (function(modules) { // webpackBootstrap 12 | /******/ // The module cache 13 | /******/ var installedModules = {}; 14 | 15 | /******/ // The require function 16 | /******/ function __webpack_require__(moduleId) { 17 | 18 | /******/ // Check if module is in cache 19 | /******/ if(installedModules[moduleId]) 20 | /******/ return installedModules[moduleId].exports; 21 | 22 | /******/ // Create a new module (and put it into the cache) 23 | /******/ var module = installedModules[moduleId] = { 24 | /******/ exports: {}, 25 | /******/ id: moduleId, 26 | /******/ loaded: false 27 | /******/ }; 28 | 29 | /******/ // Execute the module function 30 | /******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__); 31 | 32 | /******/ // Flag the module as loaded 33 | /******/ module.loaded = true; 34 | 35 | /******/ // Return the exports of the module 36 | /******/ return module.exports; 37 | /******/ } 38 | 39 | 40 | /******/ // expose the modules object (__webpack_modules__) 41 | /******/ __webpack_require__.m = modules; 42 | 43 | /******/ // expose the module cache 44 | /******/ __webpack_require__.c = installedModules; 45 | 46 | /******/ // __webpack_public_path__ 47 | /******/ __webpack_require__.p = ""; 48 | 49 | /******/ // Load entry module and return exports 50 | /******/ return __webpack_require__(0); 51 | /******/ }) 52 | /************************************************************************/ 53 | /******/ ([ 54 | /* 0 */ 55 | /***/ function(module, exports, __webpack_require__) { 56 | 57 | 'use strict'; 58 | 59 | Object.defineProperty(exports, "__esModule", { 60 | value: true 61 | }); 62 | 63 | var _threadFirst = __webpack_require__(1); 64 | 65 | Object.defineProperty(exports, 'threadFirst', { 66 | enumerable: true, 67 | get: function get() { 68 | return _threadFirst.default; 69 | } 70 | }); 71 | 72 | var _threadLast = __webpack_require__(2); 73 | 74 | Object.defineProperty(exports, 'threadLast', { 75 | enumerable: true, 76 | get: function get() { 77 | return _threadLast.default; 78 | } 79 | }); 80 | 81 | /***/ }, 82 | /* 1 */ 83 | /***/ function(module, exports) { 84 | 85 | 'use strict'; 86 | 87 | Object.defineProperty(exports, "__esModule", { 88 | value: true 89 | }); 90 | 91 | exports.default = function (value) { 92 | for (var _len = arguments.length, operators = Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) { 93 | operators[_key - 1] = arguments[_key]; 94 | } 95 | 96 | if (typeof operators === 'undefined') { 97 | return value; 98 | } 99 | 100 | return operators.reduce(function (aggregate, operator) { 101 | if ((typeof operator === 'undefined' ? 'undefined' : _typeof(operator)) === 'object') { 102 | var operatorFn = operator.shift(); 103 | operator.unshift(aggregate); 104 | return operatorFn.apply(undefined, operator); 105 | } 106 | 107 | return operator.call(undefined, aggregate); 108 | }, value); 109 | }; 110 | 111 | function _typeof(obj) { return obj && typeof Symbol !== "undefined" && obj.constructor === Symbol ? "symbol" : typeof obj; } 112 | 113 | /***/ }, 114 | /* 2 */ 115 | /***/ function(module, exports) { 116 | 117 | 'use strict'; 118 | 119 | Object.defineProperty(exports, "__esModule", { 120 | value: true 121 | }); 122 | 123 | exports.default = function (value) { 124 | for (var _len = arguments.length, operators = Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) { 125 | operators[_key - 1] = arguments[_key]; 126 | } 127 | 128 | if (typeof operators === 'undefined') { 129 | return value; 130 | } 131 | 132 | return operators.reduce(function (aggregate, operator) { 133 | if ((typeof operator === 'undefined' ? 'undefined' : _typeof(operator)) === 'object') { 134 | var operatorFn = operator.shift(); 135 | operator.push(aggregate); 136 | return operatorFn.apply(undefined, operator); 137 | } 138 | 139 | return operator.call(undefined, aggregate); 140 | }, value); 141 | }; 142 | 143 | function _typeof(obj) { return obj && typeof Symbol !== "undefined" && obj.constructor === Symbol ? "symbol" : typeof obj; } 144 | 145 | /***/ } 146 | /******/ ]) 147 | }); 148 | ; -------------------------------------------------------------------------------- /node_modules/threading/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "threading", 3 | "version": "0.0.2", 4 | "description": "A clojure-inspired utility for threading arbitrary data into the first or last argument of a sequence of functions", 5 | "main": "index.js", 6 | "scripts": { 7 | "build": "./node_modules/webpack/bin/webpack.js", 8 | "test": "./node_modules/mocha/bin/mocha --compilers js:babel-core/register --recursive ./src", 9 | "test:watch": "npm run test -- --watch" 10 | }, 11 | "keywords": [ 12 | "threading", 13 | "threads" 14 | ], 15 | "author": "William Beard ", 16 | "license": "ISC", 17 | "devDependencies": { 18 | "babel-cli": "^6.2.0", 19 | "babel-core": "^6.2.1", 20 | "babel-loader": "^6.2.0", 21 | "babel-preset-es2015": "^6.1.18", 22 | "chai": "^3.4.1", 23 | "expect.js": "^0.3.1", 24 | "mocha": "^2.3.4", 25 | "webpack": "^1.12.9" 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /node_modules/threading/src/index.js: -------------------------------------------------------------------------------- 1 | export { default as threadFirst } from './threadFirst'; 2 | export { default as threadLast } from './threadLast'; 3 | -------------------------------------------------------------------------------- /node_modules/threading/src/test/threadFirst_spec.js: -------------------------------------------------------------------------------- 1 | import expect from 'expect.js'; 2 | import threadFirst from '../threadFirst'; 3 | 4 | function timesThree(val) { 5 | return val * 3; 6 | } 7 | 8 | function plusOne(val) { 9 | return val + 1; 10 | } 11 | 12 | function divideby(val, divisor) { 13 | return val / divisor; 14 | } 15 | 16 | function getWebhookState(val) { 17 | return val.webhooks; 18 | } 19 | 20 | function getValue(val) { 21 | return val.value; 22 | } 23 | 24 | describe('#threadFirst', () => { 25 | it('exists', () => { 26 | expect(threadFirst).not.to.be(undefined); 27 | }); 28 | 29 | it('returns the value if it is only passed one value', () => { 30 | expect(threadFirst(4)).to.be(4); 31 | }); 32 | 33 | it('returns the result of an operator', () => { 34 | expect(threadFirst(5, timesThree)).to.be(15); 35 | }); 36 | 37 | it('returns the result of multiple operators', () => { 38 | expect(threadFirst(5, timesThree, plusOne)).to.be(16); 39 | }); 40 | 41 | it('uses the value as the first argument in the function call', () => { 42 | const result = threadFirst( 43 | 5, 44 | [divideby, 10] 45 | ); 46 | 47 | expect(result).to.be(0.5); 48 | }); 49 | 50 | it('demonstrates data access', () => { 51 | const state = { 52 | webhooks: { 53 | value: 1 54 | } 55 | }; 56 | 57 | const value = threadFirst( 58 | state, 59 | getWebhookState, 60 | getValue 61 | ); 62 | 63 | expect(value).to.be(1); 64 | }); 65 | }); 66 | -------------------------------------------------------------------------------- /node_modules/threading/src/test/threadLast_spec.js: -------------------------------------------------------------------------------- 1 | import expect from 'expect.js'; 2 | import threadLast from '../threadLast'; 3 | 4 | function timesThree(val) { 5 | return val * 3; 6 | } 7 | 8 | function plusOne(val) { 9 | return val + 1; 10 | } 11 | 12 | function divideby(val, divisor) { 13 | return val / divisor; 14 | } 15 | 16 | describe('#threadLast', () => { 17 | it('exists', () => { 18 | expect(threadLast).not.to.be(undefined); 19 | }); 20 | 21 | it('returns the value if it is only passed one value', () => { 22 | expect(threadLast(4)).to.be(4); 23 | }); 24 | 25 | it('returns the result of an operator', () => { 26 | expect(threadLast(5, timesThree)).to.be(15); 27 | }); 28 | 29 | it('returns the result of multiple operators', () => { 30 | expect(threadLast(5, timesThree, plusOne)).to.be(16); 31 | }); 32 | 33 | it('uses the value as the first argument in the function call', () => { 34 | const result = threadLast(5, 35 | [divideby, 10]); 36 | expect(result).to.be(2); 37 | }); 38 | }); 39 | -------------------------------------------------------------------------------- /node_modules/threading/src/threadFirst.js: -------------------------------------------------------------------------------- 1 | export default function(value, ...operators) { 2 | if(typeof operators === 'undefined') { 3 | return value; 4 | } 5 | 6 | return operators.reduce((aggregate, operator) => { 7 | if (typeof operator === 'object') { 8 | const operatorFn = operator.shift(); 9 | operator.unshift(aggregate); 10 | return operatorFn.apply(undefined, operator); 11 | } 12 | 13 | return operator.call(undefined, aggregate); 14 | }, value); 15 | } 16 | -------------------------------------------------------------------------------- /node_modules/threading/src/threadLast.js: -------------------------------------------------------------------------------- 1 | export default function(value, ...operators) { 2 | if(typeof operators === 'undefined') { 3 | return value; 4 | } 5 | 6 | return operators.reduce((aggregate, operator) => { 7 | if (typeof operator === 'object') { 8 | const operatorFn = operator.shift(); 9 | operator.push(aggregate); 10 | return operatorFn.apply(undefined, operator); 11 | } 12 | 13 | return operator.call(undefined, aggregate); 14 | }, value); 15 | } 16 | -------------------------------------------------------------------------------- /node_modules/threading/webpack.config.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | context: __dirname + '/src', 3 | entry: './index', 4 | output: { 5 | path: __dirname, 6 | filename: 'index.js', 7 | library: 'threading', 8 | libraryTarget: 'umd' 9 | }, 10 | module: { 11 | loaders: [ 12 | { 13 | test: /\.js?$/, 14 | exclude: /(node_modules|bower_components)/, 15 | loader: 'babel' 16 | } 17 | ] 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /package-lock.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "autofinetune", 3 | "lockfileVersion": 3, 4 | "requires": true, 5 | "packages": { 6 | "": { 7 | "dependencies": { 8 | "fs": "^0.0.1-security", 9 | "openai": "^3.2.1", 10 | "python-shell": "^5.0.0", 11 | "threading": "^0.0.2" 12 | } 13 | }, 14 | "node_modules/asynckit": { 15 | "version": "0.4.0", 16 | "resolved": "https://registry.npmjs.org/asynckit/-/asynckit-0.4.0.tgz", 17 | "integrity": "sha512-Oei9OH4tRh0YqU3GxhX79dM/mwVgvbZJaSNaRk+bshkj0S5cfHcgYakreBjrHwatXKbz+IoIdYLxrKim2MjW0Q==" 18 | }, 19 | "node_modules/axios": { 20 | "version": "0.26.1", 21 | "resolved": "https://registry.npmjs.org/axios/-/axios-0.26.1.tgz", 22 | "integrity": "sha512-fPwcX4EvnSHuInCMItEhAGnaSEXRBjtzh9fOtsE6E1G6p7vl7edEeZe11QHf18+6+9gR5PbKV/sGKNaD8YaMeA==", 23 | "dependencies": { 24 | "follow-redirects": "^1.14.8" 25 | } 26 | }, 27 | "node_modules/combined-stream": { 28 | "version": "1.0.8", 29 | "resolved": "https://registry.npmjs.org/combined-stream/-/combined-stream-1.0.8.tgz", 30 | "integrity": "sha512-FQN4MRfuJeHf7cBbBMJFXhKSDq+2kAArBlmRBvcvFE5BB1HZKXtSFASDhdlz9zOYwxh8lDdnvmMOe/+5cdoEdg==", 31 | "dependencies": { 32 | "delayed-stream": "~1.0.0" 33 | }, 34 | "engines": { 35 | "node": ">= 0.8" 36 | } 37 | }, 38 | "node_modules/delayed-stream": { 39 | "version": "1.0.0", 40 | "resolved": "https://registry.npmjs.org/delayed-stream/-/delayed-stream-1.0.0.tgz", 41 | "integrity": "sha512-ZySD7Nf91aLB0RxL4KGrKHBXl7Eds1DAmEdcoVawXnLD7SDhpNgtuII2aAkg7a7QS41jxPSZ17p4VdGnMHk3MQ==", 42 | "engines": { 43 | "node": ">=0.4.0" 44 | } 45 | }, 46 | "node_modules/follow-redirects": { 47 | "version": "1.15.2", 48 | "resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.15.2.tgz", 49 | "integrity": "sha512-VQLG33o04KaQ8uYi2tVNbdrWp1QWxNNea+nmIB4EVM28v0hmP17z7aG1+wAkNzVq4KeXTq3221ye5qTJP91JwA==", 50 | "funding": [ 51 | { 52 | "type": "individual", 53 | "url": "https://github.com/sponsors/RubenVerborgh" 54 | } 55 | ], 56 | "engines": { 57 | "node": ">=4.0" 58 | }, 59 | "peerDependenciesMeta": { 60 | "debug": { 61 | "optional": true 62 | } 63 | } 64 | }, 65 | "node_modules/form-data": { 66 | "version": "4.0.0", 67 | "resolved": "https://registry.npmjs.org/form-data/-/form-data-4.0.0.tgz", 68 | "integrity": "sha512-ETEklSGi5t0QMZuiXoA/Q6vcnxcLQP5vdugSpuAyi6SVGi2clPPp+xgEhuMaHC+zGgn31Kd235W35f7Hykkaww==", 69 | "dependencies": { 70 | "asynckit": "^0.4.0", 71 | "combined-stream": "^1.0.8", 72 | "mime-types": "^2.1.12" 73 | }, 74 | "engines": { 75 | "node": ">= 6" 76 | } 77 | }, 78 | "node_modules/fs": { 79 | "version": "0.0.1-security", 80 | "resolved": "https://registry.npmjs.org/fs/-/fs-0.0.1-security.tgz", 81 | "integrity": "sha512-3XY9e1pP0CVEUCdj5BmfIZxRBTSDycnbqhIOGec9QYtmVH2fbLpj86CFWkrNOkt/Fvty4KZG5lTglL9j/gJ87w==" 82 | }, 83 | "node_modules/mime-db": { 84 | "version": "1.52.0", 85 | "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.52.0.tgz", 86 | "integrity": "sha512-sPU4uV7dYlvtWJxwwxHD0PuihVNiE7TyAbQ5SWxDCB9mUYvOgroQOwYQQOKPJ8CIbE+1ETVlOoK1UC2nU3gYvg==", 87 | "engines": { 88 | "node": ">= 0.6" 89 | } 90 | }, 91 | "node_modules/mime-types": { 92 | "version": "2.1.35", 93 | "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.35.tgz", 94 | "integrity": "sha512-ZDY+bPm5zTTF+YpCrAU9nK0UgICYPT0QtT1NZWFv4s++TNkcgVaT0g6+4R2uI4MjQjzysHB1zxuWL50hzaeXiw==", 95 | "dependencies": { 96 | "mime-db": "1.52.0" 97 | }, 98 | "engines": { 99 | "node": ">= 0.6" 100 | } 101 | }, 102 | "node_modules/openai": { 103 | "version": "3.2.1", 104 | "resolved": "https://registry.npmjs.org/openai/-/openai-3.2.1.tgz", 105 | "integrity": "sha512-762C9BNlJPbjjlWZi4WYK9iM2tAVAv0uUp1UmI34vb0CN5T2mjB/qM6RYBmNKMh/dN9fC+bxqPwWJZUTWW052A==", 106 | "dependencies": { 107 | "axios": "^0.26.0", 108 | "form-data": "^4.0.0" 109 | } 110 | }, 111 | "node_modules/python-shell": { 112 | "version": "5.0.0", 113 | "resolved": "https://registry.npmjs.org/python-shell/-/python-shell-5.0.0.tgz", 114 | "integrity": "sha512-RUOOOjHLhgR1MIQrCtnEqz/HJ1RMZBIN+REnpSUrfft2bXqXy69fwJASVziWExfFXsR1bCY0TznnHooNsCo0/w==", 115 | "engines": { 116 | "node": ">=0.10" 117 | } 118 | }, 119 | "node_modules/threading": { 120 | "version": "0.0.2", 121 | "resolved": "https://registry.npmjs.org/threading/-/threading-0.0.2.tgz", 122 | "integrity": "sha512-ULRaud4+64DVoJtARH0ui/xYRPQumtHP/rSuvgm2jy4dYkslege5i1vp7tjt+mwgIlE8090LKyHU7M/zkWXZMQ==" 123 | } 124 | } 125 | } 126 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "dependencies": { 3 | "fs": "^0.0.1-security", 4 | "openai": "^3.2.1", 5 | "python-shell": "^5.0.0", 6 | "threading": "^0.0.2" 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /run_pipeline.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # Replace the paths below with the actual paths of the respective files 4 | YOUTUBE_SCRAPER="scripts/youtube_scraper.ts" 5 | CLEANER="scripts/cleaner.py" 6 | PROMPT_COMPLETION_GEN="scripts/prompt_completion_gen.py" 7 | OPENAI_API_KEY="your_openai_api_key_here" # Paste in your own API key here 8 | 9 | # Check if a YouTube URL is provided as an argument 10 | if [ -z "$1" ]; then 11 | echo "Usage: ./run_pipeline.sh " 12 | exit 1 13 | fi 14 | 15 | # Run the YouTube scraper 16 | echo "Running YouTube scraper..." 17 | tsc $YOUTUBE_SCRAPER 18 | node "${YOUTUBE_SCRAPER%.*}.js" "$1" 19 | 20 | # Run the cleaner script 21 | echo "Running cleaner.py..." 22 | python $CLEANER 23 | 24 | # Run the prompt-completion generator script 25 | echo "Running prompt_completion_gen.py..." 26 | python $PROMPT_COMPLETION_GEN 27 | 28 | # Set the OpenAI API key 29 | echo "Setting OpenAI API key..." 30 | export OPENAI_API_KEY=$OPENAI_API_KEY 31 | 32 | # Run the fine-tuning command 33 | echo "Running OpenAI fine-tuning..." 34 | openai api fine_tunes.create -t prompt_completion_pairs.jsonl -m davinci 35 | 36 | echo "Pipeline complete. You did it, king." 37 | -------------------------------------------------------------------------------- /scripts/cleaner.py: -------------------------------------------------------------------------------- 1 | import openai 2 | from concurrent.futures import ThreadPoolExecutor 3 | 4 | openai.api_key = "sk-XXXXXXXXXXXXXXXXXXXXXXXXXX" 5 | 6 | def load_text(file_path): 7 | with open(file_path, 'r') as file: 8 | return file.read() 9 | 10 | def save_to_file(responses, output_file): 11 | with open(output_file, 'w') as file: 12 | for response in responses: 13 | file.write(response + '\n') 14 | 15 | def call_openai_api(chunk): 16 | response = openai.ChatCompletion.create( 17 | model="gpt-3.5-turbo", 18 | messages=[ 19 | {"role": "system", "content": "You are an assistant that cleans transcripts for grammatical mistakes, punctuation, and filler words. You are given a transcript between an interviewer and their guest. You must edit the transcript for grammatical correctness, add correct punctuation, identify the speakers, remove filler words like 'um' and 'like', and return it to the user. Use context to help you identify mistranscribed words, punctuation, and who is speaking."}, 20 | {"role": "user", "content": f"Please clean this transcript: {chunk}."}, 21 | ], 22 | max_tokens=1750, 23 | n=1, 24 | stop=None, 25 | temperature=0.5, 26 | ) 27 | return response.choices[0]['message']['content'].strip() 28 | 29 | def split_into_chunks(text, tokens=1500): 30 | words = text.split() 31 | chunks = [' '.join(words[i:i + tokens]) for i in range(0, len(words), tokens)] 32 | return chunks 33 | 34 | def process_chunks(input_file, output_file): 35 | text = load_text(input_file) 36 | chunks = split_into_chunks(text) 37 | 38 | # Use ThreadPoolExecutor to process chunks in parallel 39 | with ThreadPoolExecutor() as executor: 40 | responses = list(executor.map(call_openai_api, chunks)) 41 | 42 | save_to_file(responses, output_file) 43 | 44 | if __name__ == "__main__": 45 | input_file = "rough_transcript.txt" 46 | output_file = "clean_transcript.txt" 47 | process_chunks(input_file, output_file) 48 | -------------------------------------------------------------------------------- /scripts/prompt_completion_gen.py: -------------------------------------------------------------------------------- 1 | import openai 2 | from concurrent.futures import ThreadPoolExecutor 3 | 4 | openai.api_key = "sk-XXXXXXXXXXXXXXXXXX" 5 | 6 | def load_text(file_path): 7 | with open(file_path, 'r') as file: 8 | return file.read() 9 | 10 | def save_to_file(responses, output_file): 11 | with open(output_file, 'w') as file: 12 | for response in responses: 13 | file.write(response + '\n') 14 | 15 | def call_openai_api(chunk): 16 | response = openai.ChatCompletion.create( 17 | model="gpt-3.5-turbo", 18 | messages=[ 19 | { 20 | "role": "system", 21 | "content": 'I have the following text transcript that in need to put in JSONL prompt-completion pair format for fune tuning. Example format, "{\\"prompt\\": \\"Who are you?\\", \\"completion\\": \\"I am Lebron James, an American professional basketball player for the Los Angeles Lakers and an all around nice guy.\\"}" Please generate 10 to 15 appropriate questions for the following text and place the questions and text in JSONL format. The \'completion\' should come verbatim from the text. You must use the \'you\' form for all prompt questions, never say "the speaker". You must utilize the entire text in the completion. Always answer the completion from the first person:', 22 | }, 23 | {"role": "user", "content": f"Transcript: {chunk}."}, 24 | ], 25 | max_tokens=1750, 26 | n=1, 27 | stop=None, 28 | temperature=0.5, 29 | ) 30 | return response.choices[0]['message']['content'].strip() 31 | 32 | def split_into_chunks(text, tokens=1500): 33 | words = text.split() 34 | chunks = [' '.join(words[i:i + tokens]) for i in range(0, len(words), tokens)] 35 | return chunks 36 | 37 | def process_chunks(input_file, output_file): 38 | text = load_text(input_file) 39 | chunks = split_into_chunks(text) 40 | 41 | # Use ThreadPoolExecutor to process chunks in parallel 42 | with ThreadPoolExecutor() as executor: 43 | responses = list(executor.map(call_openai_api, chunks)) 44 | 45 | save_to_file(responses, output_file) 46 | 47 | if __name__ == "__main__": 48 | input_file = "clean_transcript.txt" 49 | output_file = "prompt_completion_pairs.jsonl" 50 | process_chunks(input_file, output_file) 51 | -------------------------------------------------------------------------------- /scripts/transcript_scraper.py: -------------------------------------------------------------------------------- 1 | import sys 2 | from youtube_transcript_api import YouTubeTranscriptApi 3 | 4 | def get_clean_transcript(video_id): 5 | try: 6 | transcript = YouTubeTranscriptApi.get_transcript(video_id) 7 | except Exception as e: 8 | print(f"Error: {str(e)}") 9 | sys.exit(1) 10 | 11 | clean_transcript = "" 12 | for line in transcript: 13 | clean_transcript += f"{line['text']} " 14 | 15 | return clean_transcript 16 | 17 | if __name__ == "__main__": 18 | video_id = sys.argv[1] 19 | clean_transcript = get_clean_transcript(video_id) 20 | print(clean_transcript) 21 | -------------------------------------------------------------------------------- /scripts/youtube_scraper.ts: -------------------------------------------------------------------------------- 1 | import { PythonShell } from 'python-shell'; 2 | import * as fs from 'fs'; 3 | 4 | async function getTranscript(videoId: string): Promise { 5 | return new Promise((resolve, reject) => { 6 | const pyShell = new PythonShell('transcript_scraper.py', { 7 | pythonOptions: ['-u'], 8 | scriptPath: './', 9 | args: [videoId] 10 | }); 11 | 12 | let transcript = ''; 13 | 14 | pyShell.on('message', (message: string) => { 15 | transcript += message; 16 | }); 17 | 18 | pyShell.end((err, _code, _signal) => { 19 | if (err) { 20 | reject(err); 21 | } else { 22 | resolve(transcript); 23 | } 24 | }); 25 | }); 26 | } 27 | 28 | async function main() { 29 | const videoUrl = 'https://www.youtube.com/watch?v=8JoTw_JuE78'; 30 | const videoId = new URL(videoUrl).searchParams.get('v'); 31 | const outputPath = 'rough_transcript.txt'; 32 | 33 | const transcript = await getTranscript(videoId); 34 | fs.writeFileSync(outputPath, transcript); 35 | console.log(`Transcript saved to ${outputPath}`); 36 | } 37 | 38 | main(); --------------------------------------------------------------------------------