node_modules ignore

This commit is contained in:
2025-05-08 23:43:47 +02:00
parent e19d52f172
commit 4574544c9f
65041 changed files with 10593536 additions and 0 deletions

53
server/node_modules/purest/CHANGELOG.md generated vendored Normal file
View File

@@ -0,0 +1,53 @@
# Change Log
## v4.0.2 (2022/03/12)
- **Fix:** Bump deps
## v4.0.1 (2021/03/15)
- **Change:** Update type definitions
## v4.0.0 (2021/02/08)
- **New:** Complete rewrite of the module
## v3.1.0 (2016/12/21)
- **New:** defer option
## v3.0.1 (2016/07/17)
- **Fix:** absolute url detection
## v3.0.0 (2016/07/17)
- **New:** [Breaking Changes](https://simov.gitbooks.io/purest/content/)
- **Change:** The `request` module is no longer an internal dependency of Purest, it should be installed separately and passed to Purest.
- **Change:** The provider's configuration is no longer part of the module, it should be installed separately and passed through the `config` option.
- **Change:** The `new` keyword is no longer used when creating a new provider instance.
- **Change:** The `api` constructor option is now called `alias`.
- **Change:** The `api` option for the *Basic API* is now also called `alias`.
- **Change:** By default the constructor now returns an instance of the *Chain API*.
- **Change:** The *Basic API* can be enabled explicitly through the `api: 'basic'` options of the constructor.
- **Change:** The `query()` method of the *Chain API* is no longer required to initiate the *Chain API*, use it only if you need to specify the path alias to use.
- **Change:** The Promise implementation have to be passed as dependency when initializing Purest.
- **Change:** The `debug` option is no longer available for the constructor.
- **Change:** The `defaults` options passed in the constructor are being extended in Purest instead of in request.
- **Change:** The default *Chain API* method aliases were removed, for example: post-update and so on.
- **Change:** The before hook methods and the `hooks` options in the constructor are no longer available.
- **Change:** Versions of Node below version 4.0 LTS are no longer supported.
- **Change:** - **Change:** Version 3.0 of Purest is licensed under the Apache 2.0 license.
## v2.0.1 (2016/03/02)
- **Fix:** support for Bluebird 3
## v2.0.0 (2015/08/06)
- **Fix:** before request hooks
- **Fix:** user defined method aliases
- **Fix:** support for Promises
- **Fix:** official support of 40+ more providers
- **Change:** renamed the *domain* path modifier to *subdomain*
- **Change:** removed the `__provider` key from the configuration
## v1.2.0 (2015/06/16)
- **Change:** the `refresh` method and config are no longer available - use the Query API instead
- **Change:** `__provider` and `__domain` meta keys are no longer required
## v1.0.0 (2014/06/23)
- Initial Release

69
server/node_modules/purest/LICENSE generated vendored Normal file
View File

@@ -0,0 +1,69 @@
Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
Copyright (c) 2013-present, Simeon Velichkov <simeonvelichkov@gmail.com> (https://github.com/simov/purest)
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
1. Definitions.
"License" shall mean the terms and conditions for use, reproduction, and distribution as defined by Sections 1 through 9 of this document.
"Licensor" shall mean the copyright owner or entity authorized by the copyright owner that is granting the License.
"Legal Entity" shall mean the union of the acting entity and all other entities that control, are controlled by, or are under common control with that entity. For the purposes of this definition, "control" means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity.
"You" (or "Your") shall mean an individual or Legal Entity exercising permissions granted by this License.
"Source" form shall mean the preferred form for making modifications, including but not limited to software source code, documentation source, and configuration files.
"Object" form shall mean any form resulting from mechanical transformation or translation of a Source form, including but not limited to compiled object code, generated documentation, and conversions to other media types.
"Work" shall mean the work of authorship, whether in Source or Object form, made available under the License, as indicated by a copyright notice that is included in or attached to the work (an example is provided in the Appendix below).
"Derivative Works" shall mean any work, whether in Source or Object form, that is based on (or derived from) the Work and for which the editorial revisions, annotations, elaborations, or other modifications represent, as a whole, an original work of authorship. For the purposes of this License, Derivative Works shall not include works that remain separable from, or merely link (or bind by name) to the interfaces of, the Work and Derivative Works thereof.
"Contribution" shall mean any work of authorship, including the original version of the Work and any modifications or additions to that Work or Derivative Works thereof, that is intentionally submitted to Licensor for inclusion in the Work by the copyright owner or by an individual or Legal Entity authorized to submit on behalf of the copyright owner. For the purposes of this definition, "submitted" means any form of electronic, verbal, or written communication sent to the Licensor or its representatives, including but not limited to communication on electronic mailing lists, source code control systems, and issue tracking systems that are managed by, or on behalf of, the Licensor for the purpose of discussing and improving the Work, but excluding communication that is conspicuously marked or otherwise designated in writing by the copyright owner as "Not a Contribution."
"Contributor" shall mean Licensor and any individual or Legal Entity on behalf of whom a Contribution has been received by Licensor and subsequently incorporated within the Work.
2. Grant of Copyright License.
Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable copyright license to reproduce, prepare Derivative Works of, publicly display, publicly perform, sublicense, and distribute the Work and such Derivative Works in Source or Object form.
3. Grant of Patent License.
Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable (except as stated in this section) patent license to make, have made, use, offer to sell, sell, import, and otherwise transfer the Work, where such license applies only to those patent claims licensable by such Contributor that are necessarily infringed by their Contribution(s) alone or by combination of their Contribution(s) with the Work to which such Contribution(s) was submitted. If You institute patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Work or a Contribution incorporated within the Work constitutes direct or contributory patent infringement, then any patent licenses granted to You under this License for that Work shall terminate as of the date such litigation is filed.
4. Redistribution.
You may reproduce and distribute copies of the Work or Derivative Works thereof in any medium, with or without modifications, and in Source or Object form, provided that You meet the following conditions:
You must give any other recipients of the Work or Derivative Works a copy of this License; and
You must cause any modified files to carry prominent notices stating that You changed the files; and
You must retain, in the Source form of any Derivative Works that You distribute, all copyright, patent, trademark, and attribution notices from the Source form of the Work, excluding those notices that do not pertain to any part of the Derivative Works; and
If the Work includes a "NOTICE" text file as part of its distribution, then any Derivative Works that You distribute must include a readable copy of the attribution notices contained within such NOTICE file, excluding those notices that do not pertain to any part of the Derivative Works, in at least one of the following places: within a NOTICE text file distributed as part of the Derivative Works; within the Source form or documentation, if provided along with the Derivative Works; or, within a display generated by the Derivative Works, if and wherever such third-party notices normally appear. The contents of the NOTICE file are for informational purposes only and do not modify the License. You may add Your own attribution notices within Derivative Works that You distribute, alongside or as an addendum to the NOTICE text from the Work, provided that such additional attribution notices cannot be construed as modifying the License.
You may add Your own copyright statement to Your modifications and may provide additional or different license terms and conditions for use, reproduction, or distribution of Your modifications, or for any such Derivative Works as a whole, provided Your use, reproduction, and distribution of the Work otherwise complies with the conditions stated in this License.
5. Submission of Contributions.
Unless You explicitly state otherwise, any Contribution intentionally submitted for inclusion in the Work by You to the Licensor shall be under the terms and conditions of this License, without any additional terms or conditions. Notwithstanding the above, nothing herein shall supersede or modify the terms of any separate license agreement you may have executed with Licensor regarding such Contributions.
6. Trademarks.
This License does not grant permission to use the trade names, trademarks, service marks, or product names of the Licensor, except as required for reasonable and customary use in describing the origin of the Work and reproducing the content of the NOTICE file.
7. Disclaimer of Warranty.
Unless required by applicable law or agreed to in writing, Licensor provides the Work (and each Contributor provides its Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are solely responsible for determining the appropriateness of using or redistributing the Work and assume any risks associated with Your exercise of permissions under this License.
8. Limitation of Liability.
In no event and under no legal theory, whether in tort (including negligence), contract, or otherwise, unless required by applicable law (such as deliberate and grossly negligent acts) or agreed to in writing, shall any Contributor be liable to You for damages, including any direct, indirect, special, incidental, or consequential damages of any character arising as a result of this License or out of the use or inability to use the Work (including but not limited to damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses), even if such Contributor has been advised of the possibility of such damages.
9. Accepting Warranty or Additional Liability.
While redistributing the Work or Derivative Works thereof, You may choose to offer, and charge a fee for, acceptance of support, warranty, indemnity, or other liability obligations and/or rights consistent with this License. However, in accepting such obligations, You may act only on Your own behalf and on Your sole responsibility, not on behalf of any other Contributor, and only if You agree to indemnify, defend, and hold each Contributor harmless for any liability incurred by, or claims asserted against, such Contributor by reason of your accepting any such warranty or additional liability.
END OF TERMS AND CONDITIONS

307
server/node_modules/purest/README.md generated vendored Normal file
View File

@@ -0,0 +1,307 @@
# Purest
[![npm-version]][npm] [![test-ci-img]][test-ci-url] [![test-cov-img]][test-cov-url] [![snyk-vulnerabilities]][snyk]
> _REST API Client Library_
```js
var purest = require('purest')
var google = purest({provider: 'google'})
await google
.query('youtube')
.select('channels')
.where({forUsername: 'GitHub'})
.auth(token)
.request()
```
## Table of Contents
> _This is Purest **v4**, for older releases take a look at [v3] and [v2]_
- **[Introduction](#introduction)**
- **[Purest Options](#purest-options)**
- **[Request Options](#request-options)**
- **[Examples](#examples)**
- **[Article]**
---
## Introduction
> _**Purest** is a tool for building **expressive** REST API clients_
### Default Endpoint
Here is a basic configuration for Google:
```json
{
"google": {
"default": {
"origin": "https://www.googleapis.com",
"path": "{path}",
"headers": {
"authorization": "Bearer {auth}"
}
}
}
}
```
Our configuration can be used to instantiate that provider:
```js
var google = purest({provider: 'google', config})
```
Finally we can request some data from YouTube:
```js
var {res, body} = await google
.get('youtube/v3/channels')
.qs({forUsername: 'GitHub'})
.auth(token)
.request()
```
### Explicit Endpoint
We can define explicit endpoint for accessing the YouTube API:
```json
{
"google": {
"default": {
"origin": "https://www.googleapis.com",
"path": "{path}",
"headers": {
"authorization": "Bearer {auth}"
}
},
"youtube": {
"origin": "https://www.googleapis.com",
"path": "youtube/{version}/{path}",
"version": "v3",
"headers": {
"authorization": "Bearer {auth}"
}
}
}
}
```
And then request the same data:
```js
var {res, body} = await google('youtube')
.get('channels')
.qs({forUsername: 'GitHub'})
.auth(token)
.request()
```
### Defaults
Every method in Purest can also be preconfigured with a static value:
```js
var google = purest({provider: 'google', config,
defaults: {auth: token}
})
```
Then we no longer need to set the access token on every request:
```js
var {res, body} = await google('youtube')
.get('channels')
.qs({forUsername: 'GitHub'})
.request()
```
### Method Aliases
But what if we want to make our API more expressive? What if we want to make it our own:
```js
var google = purest({provider: 'google', config,
defaults: {auth: token},
methods: {get: ['select'], qs: ['where']}
})
```
Yes we can:
```js
var {res, body} = await google('youtube')
.select('channels')
.where({forUsername: 'GitHub'})
.request()
```
---
## Purest Options
> _**Purest** is a flexible tool for **abstracting** out REST APIs_
```js
var google = purest({config: {}, provider: 'google', defaults: {}, methods: {}})
```
| Key | Type | Description
| :- | :-: | :-
| **`provider`** | `''` | Provider name to initialize from the list of providers found in `config`
| **`config`** | `{}` | Providers configuration to use
| **`defaults`** | `{}` | Any supported configuration option set by default, see below
| **`methods`** | `{}` | List of methods and their aliases to use with this instance
---
## Request Options
> _**Purest** is built on top of a **[powerful HTTP Client][request-compose]**_
### URL Options
| Option | Description
| :- | :-
| `origin` | The protocol and domain part of the URL, can contain `{subdomain}` token
| `path` | The path part of the URL, can contain `{version}`, `{path}` and `{type}` tokens
| `subdomain` | Subdomain part of the URL to replace in `origin`
| `version` | Version string to replace in `path`
| `type` | Type string to replace in `path`, typically `json` or `xml`
### HTTP Methods
All HTTP methods `get` `head` `post` `put` `patch` `options` `delete` `trace` `connect` accept a string to replace the `{path}` configuration token with, or absolute URL to replace the entire `url`.
### Request Options
| Option | Type | Description
| :-- | :-- | :--
| `method` | `'string'` | Request method, implicitly set if one of the above HTTP Methods is used
| `url` | `'string'` [`url object`][url-parse] | Absolute URL, automatically constructed if the URL Options above are being used, or absolute URL is passed to any of the HTTP Methods above
| `proxy` | `'string'` [`url object`][url-parse] | Proxy URL; for HTTPS you have to use [tunneling][tunnel-agent] [agent][proxy-agent] instead
| `qs` | `{object}` `'string'` | URL querystring
| `headers` | `{object}` | Request headers
| `form` | `{object}` `'string'` | `application/x-www-form-urlencoded` request body
| `json` | `{object}` `'string'` | JSON encoded request body
| `multipart`| `{object}` `[array]` | `multipart/form-data` as object or `multipart/related` as array request body using [request-multipart]
| `body` | `'string'` [`Buffer`][buffer] [`Stream`][stream-readable] | Raw request body
| `auth` | `'string'` `['string', 'string']` `{user, pass}` | String or array of strings to replace the `{auth}` configuration token with, or Basic authorization as object
| `oauth` | `{object}` | OAuth 1.0a authorization using [request-oauth]
| `encoding` | [`'string'`][buffer-encoding] | Response body encoding
| `redirect` | `{object}` | HTTP redirect [configuration][redirect-config]
| `timeout` | `number` | Request timeout in milliseconds
| `agent` | [`Agent`][agent] | HTTP agent
### Response Options
`request`
- buffers the response body
- decompresses `gzip` and `deflate` encoded bodies with valid `content-encoding` header
- converts the response body to string using `utf8` encoding by default
- tries to parse `JSON` and `querystring` encoded bodies with valid `content-type` header
Returns either String or Object.
`buffer`
- buffers the response body
- decompresses `gzip` and `deflate` encoded bodies with valid `content-encoding` header
Returns [Buffer][buffer].
`stream`
Returns the response [Stream][stream-incoming-message].
### Node Core Options
Any other HTTP request option not explicitly exposed in Purest can be set using any of the response methods:
```js
await google.request({socketPath: ''})
await google.buffer({socketPath: ''})
await google.stream({socketPath: ''})
```
### Endpoint
The explicit `endpoint` configuration can be accessed in various ways:
```js
// as argument to the Purest instance
await google('youtube')
// using the option name
await google.endpoint('youtube')
// or the default method alias defined for it
await google.query('youtube')
```
---
## Examples
> _**Purest** comes with a **[fancy logger][request-logs]**_
```bash
npm i --save-dev request-logs
```
```bash
DEBUG=req,res,body,json node examples/file-name.js 'example name'
```
| Category | Topics | Providers | Examples
| :- | :- | :- | :-
| **OAuth 2.0** | _Refresh Access Tokens_ | `box` `google` `twitch` | [Refresh access tokens][refresh-token]
| **OpenID Connect** | *Verify id_token* | `auth0` `google` `microsoft` | [Discover public keys and verify id_token signature][openid-connect]
| **OAuth 1.0a** | _OAuth 1.0a_ | `flickr` `trello` `twitter` | [Get user profile][oauth-1]
| **Storage** | _Multipart, Streams_ | `box` `dropbox` `drive` | [Upload files][file-stream]
| **Storage** | _HTTP Streams_ | `box` `dropbox` | [Stream file from DropBox to Box][http-stream]
> _Get access tokens using **[Grant]**_
[npm-version]: https://img.shields.io/npm/v/purest.svg?style=flat-square (NPM Version)
[test-ci-img]: https://img.shields.io/travis/simov/purest/master.svg?style=flat-square (Build Status)
[test-cov-img]: https://img.shields.io/coveralls/simov/purest.svg?style=flat-square (Test Coverage)
[snyk-vulnerabilities]: https://img.shields.io/snyk/vulnerabilities/npm/purest.svg?style=flat-square (Vulnerabilities)
[npm]: https://www.npmjs.com/package/purest
[test-ci-url]: https://github.com/simov/purest/actions/workflows/test.yml
[test-cov-url]: https://coveralls.io/r/simov/purest?branch=master
[snyk]: https://snyk.io/test/npm/purest
[v3]: https://github.com/simov/purest/tree/3.x
[v2]: https://github.com/simov/purest/tree/2.x
[article]: https://dev.to/simov/purest-53k0
[request-compose]: https://github.com/simov/request-compose
[request-oauth]: https://github.com/simov/request-oauth
[request-multipart]: https://github.com/simov/request-multipart
[request-cookie]: https://github.com/simov/request-cookie
[request-logs]: https://github.com/simov/request-logs
[grant]: https://github.com/simov/grant
[redirect-config]: https://github.com/simov/request-compose#redirect
[tunnel-agent]: https://github.com/simov/request-compose/blob/master/examples/misc-tunnel-agent.js
[proxy-agent]: https://github.com/simov/request-compose/blob/master/examples/misc-proxy-agent.js
[methods.json]: https://github.com/simov/purest/blob/master/config/methods.json
[refresh-token]: https://github.com/simov/purest/blob/master/examples/refresh-token.js
[openid-connect]: https://github.com/simov/purest/blob/master/examples/openid-connect.js
[oauth-1]: https://github.com/simov/purest/blob/master/examples/oauth-1.js
[file-stream]: https://github.com/simov/purest/blob/master/examples/file-stream.js
[http-stream]: https://github.com/simov/purest/blob/master/examples/http-stream.js
[url-parse]: https://nodejs.org/dist/latest-v10.x/docs/api/url.html#url_url_parse_urlstring_parsequerystring_slashesdenotehost
[buffer]: https://nodejs.org/dist/latest-v10.x/docs/api/buffer.html
[buffer-encoding]: https://nodejs.org/dist/latest-v10.x/docs/api/buffer.html#buffer_buffers_and_character_encodings
[stream-readable]: https://nodejs.org/dist/latest-v10.x/docs/api/stream.html#stream_class_stream_readable
[stream-incoming-message]: https://nodejs.org/dist/latest-v10.x/docs/api/http.html#http_class_http_incomingmessage
[agent]: https://nodejs.org/docs/latest-v10.x/api/http.html#http_class_http_agent

47
server/node_modules/purest/config/methods.json generated vendored Normal file
View File

@@ -0,0 +1,47 @@
{
"methods": {
"get" : ["select"],
"head" : [],
"post" : ["update", "refresh"],
"put" : [],
"patch" : [],
"options" : [],
"delete" : [],
"trace" : [],
"connect" : []
},
"http": {
"method" : [],
"headers" : [],
"timeout" : [],
"agent" : [],
"url" : [],
"proxy" : [],
"qs" : ["where"],
"form" : [],
"json" : [],
"body" : [],
"multipart": [],
"auth" : [],
"oauth" : [],
"encoding" : [],
"cookie" : [],
"redirect" : [],
"request" : ["submit"],
"buffer" : [],
"stream" : []
},
"url": {
"origin" : [],
"path" : [],
"subdomain": [],
"version" : [],
"type" : []
},
"purest": {
"endpoint" : ["query"],
"auth" : ["token"]
}
}

2788
server/node_modules/purest/config/providers.json generated vendored Normal file

File diff suppressed because it is too large Load Diff

16
server/node_modules/purest/lib/alias.js generated vendored Normal file
View File

@@ -0,0 +1,16 @@
module.exports = ({options, methods}) => {
Object.keys(methods).forEach((key) => {
if (!options[key]) {
var alias = methods[key].find((alias) => Object.keys(options).includes(alias))
if (alias) {
options[key] = options[alias]
delete options[alias]
}
}
})
return options
}

50
server/node_modules/purest/lib/auth.js generated vendored Normal file
View File

@@ -0,0 +1,50 @@
var cache = []
var replacer = () => {
return (key, value) => {
if (typeof value === 'object' && value.constructor.name !== 'Object') {
cache.push(value)
return '$token'
}
else {
return value
}
}
}
var reviver = () => {
var index = 0
return (key, value) => {
if (value === '$token') {
return cache[index++]
}
else {
return value
}
}
}
module.exports = (options) => {
cache = []
if (typeof options.auth === 'string' || options.auth instanceof Array) {
var index = 0
var auth = [].concat(options.auth)
options = JSON.parse(
JSON.stringify(options, replacer())
.replace(/{auth}/g, (match, offset, string) => auth[index++]),
reviver())
if (options._auth) {
options.auth = options._auth
}
else {
// conflicts with request-compose auth
delete options.auth
}
}
return options
}

45
server/node_modules/purest/lib/client.js generated vendored Normal file
View File

@@ -0,0 +1,45 @@
var compose = require('request-compose')
var oauth = require('request-oauth')
var multipart = require('request-multipart')
var qs = require('qs')
var parse = () => ({options, res, res: {headers}, body, raw}) => {
raw = body
var header = Object.keys(headers)
.find((name) => name.toLowerCase() === 'content-type')
if (/json|javascript/.test(headers[header])) {
try {
body = JSON.parse(body)
}
catch (err) {}
}
else if (/application\/x-www-form-urlencoded/.test(headers[header])) {
try {
body = qs.parse(body) // use qs instead of querystring for nested objects
}
catch (err) {}
}
log({parse: {res, body}})
return {options, res, body, raw}
}
var log = (data) => {
if (process.env.DEBUG) {
try {
require('request-logs')(data)
}
catch (err) {}
}
}
module.exports = compose.extend({
Request: {oauth, multipart},
Response: {parse}
})

27
server/node_modules/purest/lib/endpoint.js generated vendored Normal file
View File

@@ -0,0 +1,27 @@
var extend = require('@simov/deep-extend')
var def = require('../config/methods')
module.exports = (ctor, req) => {
var endpoint = (() => {
var all = extend({}, ctor.defaults || {}, req)
var aliases = (ctor.methods || {}).endpoint || def.purest.endpoint
var alias = ['endpoint'].concat(aliases).find((key) => all[key] !== undefined)
return all[alias] || 'default'
})()
var options = (ctor.config[ctor.provider] || {})[endpoint] || {}
if (options.auth) {
options._auth = options.auth
}
options = extend({}, options, ctor.defaults || {}, req)
var methods = Object.assign({}, def.methods, def.http, def.url, def.purest, ctor.methods || {})
return {options, methods}
}

15
server/node_modules/purest/lib/method.js generated vendored Normal file
View File

@@ -0,0 +1,15 @@
var def = require('../config/methods')
module.exports = (options) => {
options.method = options.method ||
Object.keys(options).find((key) => Object.keys(def.methods).includes(key))
if (options.method) {
options.method = options.method.toUpperCase()
}
return options
}

26
server/node_modules/purest/lib/url.js generated vendored Normal file
View File

@@ -0,0 +1,26 @@
var def = require('../config/methods')
module.exports = (options) => {
if (options.url) {
return options
}
var method = Object.keys(options)
.find((key) => Object.keys(def.methods).includes(key))
if (/^https?/.test(options[method])) {
options.url = options[method]
return options
}
options.url = `${options.origin}/${options.path}`
.replace('{path}', options[method] || '')
.replace('{subdomain}', options.subdomain || '')
.replace('{version}', options.version || '')
.replace('{type}', options.type || '')
return options
}

52
server/node_modules/purest/package.json generated vendored Normal file
View File

@@ -0,0 +1,52 @@
{
"name": "purest",
"version": "4.0.2",
"description": "REST API Client Library",
"keywords": [
"rest",
"restful",
"api",
"http",
"https",
"client"
],
"license": "Apache-2.0",
"homepage": "https://github.com/simov/purest",
"author": "Simeon Velichkov <simeonvelichkov@gmail.com> (https://simov.github.io)",
"repository": {
"type": "git",
"url": "https://github.com/simov/purest.git"
},
"dependencies": {
"@simov/deep-extend": "^1.0.0",
"qs": "^6.10.3",
"request-compose": "^2.1.4",
"request-multipart": "^1.0.0",
"request-oauth": "^1.0.1"
},
"devDependencies": {
"mocha": "^9.2.2",
"nyc": "^15.1.0",
"request-logs": "^2.1.4"
},
"main": "./purest.js",
"files": [
"config/",
"lib/",
"purest.js",
"purest.d.ts",
"CHANGELOG.md",
"LICENSE",
"README.md",
"package.json"
],
"types": "purest.d.ts",
"scripts": {
"test": "npm run test:ci",
"test:ci": "npx mocha --recursive",
"test:cov": "npx nyc --reporter=lcov --reporter=text-summary mocha -- --recursive"
},
"engines": {
"node": ">=12.0.0"
}
}

439
server/node_modules/purest/purest.d.ts generated vendored Normal file
View File

@@ -0,0 +1,439 @@
import {
RequestOptions as RequestComposeOptions,
AuthOptions,
ClientResponse,
BufferResponse,
StreamResponse,
} from 'request-compose'
// ----------------------------------------------------------------------------
/**
* Purest instance config
*/
export interface PurestInstanceConfig {
/**
* Purest providers config
*/
config?: PurestConfig
/**
* Provider name
*/
provider?: string
/**
* Instance defaults
*/
defaults?: PurestOptions
/**
* Method aliases
*/
methods?: PurestMethods
}
/**
* Purest config
*/
export interface PurestConfig {
/**
* Provider name
*/
[provider: string]: {
[endpoint: string]: PurestOptions | undefined
} | undefined
}
/**
* Request options
*/
export interface PurestOptions extends RequestComposeOptions {
/**
* Path part to replace the {path} with, or absolute URL
*/
get?: string
/**
* Path part to replace the {path} with, or absolute URL
*/
head?: string
/**
* Path part to replace the {path} with, or absolute URL
*/
post?: string
/**
* Path part to replace the {path} with, or absolute URL
*/
put?: string
/**
* Path part to replace the {path} with, or absolute URL
*/
patch?: string
/**
* Path part to replace the {path} with, or absolute URL
*/
options?: string
/**
* Path part to replace the {path} with, or absolute URL
*/
delete?: string
/**
* Path part to replace the {path} with, or absolute URL
*/
trace?: string
/**
* Path part to replace the {path} with, or absolute URL
*/
connect?: string
/**
* Return the response body as buffer
*/
buffer?: boolean
/**
* Return the response stream
*/
stream?: boolean
/**
* Origin part of the URL
*/
origin?: string
/**
* Path part of the URL; to be used with origin
*/
path?: string
/**
* {subdomain} part of the URL to replace in origin
*/
subdomain?: string
/**
* {version} part of the URL to replace in path
*/
version?: string
/**
* {type} part of the URL to replace in path; usually json or xml
*/
type?: string
/**
* Endpoint name to use
*/
endpoint?: string
/**
* List of values to replace {auth} with, or basic auth
*/
auth?: string | [] | AuthOptions
}
/**
* Method Overrides
*/
export interface PurestMethods {
/**
* get method aliases
*/
get?: string[]
/**
* head method aliases
*/
head?: string[]
/**
* post method aliases
*/
post?: string[]
/**
* put method aliases
*/
put?: string[]
/**
* patch method aliases
*/
patch?: string[]
/**
* options method aliases
*/
options?: string[]
/**
* delete method aliases
*/
delete?: string[]
/**
* trace method aliases
*/
trace?: string[]
/**
* connect method aliases
*/
connect?: string[]
/**
* method method aliases
*/
method?: string[]
/**
* headers method aliases
*/
headers?: string[]
/**
* timeout method aliases
*/
timeout?: string[]
/**
* agent method aliases
*/
agent?: string[]
/**
* url method aliases
*/
url?: string[]
/**
* proxy method aliases
*/
proxy?: string[]
/**
* qs method aliases
*/
qs?: string[]
/**
* form method aliases
*/
form?: string[]
/**
* json method aliases
*/
json?: string[]
/**
* body method aliases
*/
body?: string[]
/**
* multipart method aliases
*/
multipart?: string[]
/**
* oauth method aliases
*/
oauth?: string[]
/**
* encoding method aliases
*/
encoding?: string[]
/**
* redirect method aliases
*/
redirect?: string[]
/**
* request method aliases
*/
request?: string[]
/**
* buffer method aliases
*/
buffer?: string[]
/**
* stream method aliases
*/
stream?: string[]
/**
* origin method aliases
*/
origin?: string[]
/**
* path method aliases
*/
path?: string[]
/**
* subdomain method aliases
*/
subdomain?: string[]
/**
* version method aliases
*/
version?: string[]
/**
* type method aliases
*/
type?: string[]
/**
* endpoint method aliases
*/
endpoint?: string[]
/**
* auth method aliases
*/
auth?: string[]
}
// ----------------------------------------------------------------------------
/**
* Purest request instance
*/
export type PurestRequest = (options: PurestOptions) => Promise<PurestResponse>
/**
* Purest endpoint instance
*/
export type PurestEndpoint = (endpoint?: string) => PurestAPI
/**
* Purest chain instance
*/
export interface PurestAPI {
/**
* Path part to replace the {path} with, or absolute URL
*/
get(path?: string): PurestAPI
/**
* Path part to replace the {path} with, or absolute URL
*/
head(path?: string): PurestAPI
/**
* Path part to replace the {path} with, or absolute URL
*/
post(path?: string): PurestAPI
/**
* Path part to replace the {path} with, or absolute URL
*/
put(path?: string): PurestAPI
/**
* Path part to replace the {path} with, or absolute URL
*/
patch(path?: string): PurestAPI
/**
* Path part to replace the {path} with, or absolute URL
*/
options(path?: string): PurestAPI
/**
* Path part to replace the {path} with, or absolute URL
*/
delete(path?: string): PurestAPI
/**
* Path part to replace the {path} with, or absolute URL
*/
trace(path?: string): PurestAPI
/**
* Path part to replace the {path} with, or absolute URL
*/
connect(path?: string): PurestAPI
/**
* HTTP method name
*/
method(name: string): PurestAPI
/**
* HTTP headers
*/
headers(headers: object): PurestAPI
/**
* Request timeout in milliseconds, defaults to 3000
*/
timeout(timeout: number): PurestAPI
/**
* HTTP agent
*/
agent(agent: object): PurestAPI
/**
* Absolute URL
*/
url(url: string): PurestAPI
/**
* Proxy URL; for HTTP use Agent instead
*/
proxy(proxy: string): PurestAPI
/**
* URL querystring
*/
qs(querystring: object | string): PurestAPI
/**
* application/x-www-form-urlencoded request body
*/
form(form: object | string): PurestAPI
/**
* JSON encoded request body
*/
json(json: object | string): PurestAPI
/**
* Raw request body
*/
body(body: string | Buffer | object): PurestAPI
/**
* multipart/form-data as object or multipart/related as array
*/
multipart(body: object | []): PurestAPI
/**
* OAuth 1.0a authentication
*/
oauth(oauth: object): PurestAPI
/**
* Response encoding
*/
encoding(name: string): PurestAPI
/**
* Redirect options
*/
redirect(options: object): PurestAPI
/**
* Parsed response body
*/
request(options?: PurestOptions): Promise<ClientResponse>
/**
* Response body as buffer
*/
buffer(options?: PurestOptions): Promise<BufferResponse>
/**
* Response stream
*/
stream(options?: PurestOptions): Promise<StreamResponse>
/**
* Origin part of the URL
*/
origin(origin: string): PurestAPI
/**
* Path part of the URL; to be used with origin
*/
path(path: string): PurestAPI
/**
* {subdomain} part of the URL to replace in origin
*/
subdomain(subdomain: string): PurestAPI
/**
* {version} part of the URL to replace in path
*/
version(version: string): PurestAPI
/**
* {type} part of the URL to replace in path; usually json or xml
*/
type(type: string): PurestAPI
/**
* Endpoint name to use
*/
endpoint(name: string): PurestAPI
/**
* List of values to replace {auth} with
*/
auth(...values: string[]): PurestAPI
/**
* Array of values to replace {auth} with
*/
auth(value: string[]): PurestAPI
/**
* Basic auth
*/
auth(basic: {user: string, pass: string}): PurestAPI
}
// ----------------------------------------------------------------------------
/**
* Purest response
*/
export type PurestResponse = ClientResponse & BufferResponse & StreamResponse
// ----------------------------------------------------------------------------
/**
* Purest
*/
declare function purest (config?: PurestInstanceConfig): PurestRequest & PurestEndpoint & PurestAPI
/**
* Purest
*/
declare module purest {}
export default purest

73
server/node_modules/purest/purest.js generated vendored Normal file
View File

@@ -0,0 +1,73 @@
var extend = require('@simov/deep-extend')
var compose = require('./lib/client')
var def = require('./config/methods')
var transform = {
endpoint: require('./lib/endpoint'),
alias: require('./lib/alias'),
method: require('./lib/method'),
url: require('./lib/url'),
auth: require('./lib/auth'),
}
module.exports = function purest (ctor = {}) {
ctor.config = ctor.config || require('./config/providers')
var client = (arg) =>
arg === undefined ? client :
typeof arg === 'string' ? client.endpoint(arg) :
compose(
(req) => transform.endpoint(ctor, req),
transform.alias,
transform.method,
transform.url,
transform.auth,
(req) =>
req.buffer ? compose.buffer(req) :
req.stream ? compose.stream(req) :
compose.client(req),
)(arg)
// same in lib/endpoint.js - probably move it here ..
var methods = Object.assign(
{}, def.methods, def.http, def.url, def.purest, ctor.methods || {})
var exec = ['request', 'buffer', 'stream']
.concat(methods.request)
.concat(methods.buffer)
.concat(methods.stream)
var wrap = (name) => (value, ...rest) => {
if (exec.includes(name)) {
var main = ['request', 'buffer', 'stream']
if (main.includes(name)) {
client._options[name] = true
}
else {
var index = main.findIndex((key) => methods[key].includes(key))
client._options[main[index]] = true
}
var options = extend({}, client._options, value || {})
client._options = {}
return client(options)
}
else if (['auth'].concat(methods.auth).includes(name)) {
client._options.auth = [].concat(value).concat(rest)
return client
}
else {
client._options[name] = value
return client
}
}
client._options = {}
var all = Object.keys(methods).concat(Object.values(methods).reduce((all, aliases) => all.concat(aliases)))
all.forEach((name) => client[name] = wrap(name))
return client
}