Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

netlify

Package Overview
Dependencies
Maintainers
16
Versions
177
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

netlify - npm Package Compare versions

Comparing version 11.0.4 to 12.0.0

src/methods/params.js

6

package.json
{
"name": "netlify",
"description": "Netlify Node.js API client",
"version": "11.0.4",
"version": "12.0.0",
"type": "module",

@@ -64,7 +64,7 @@ "files": [

"devDependencies": {
"@netlify/eslint-config-node": "^6.0.0",
"@netlify/eslint-config-node": "^7.0.0",
"ava": "^4.0.0",
"c8": "^7.11.0",
"from2-string": "^1.1.0",
"husky": "^7.0.4",
"husky": "^8.0.0",
"nock": "^13.0.0",

@@ -71,0 +71,0 @@ "npm-run-all": "^4.1.5",

@@ -6,2 +6,3 @@ import fetch from 'node-fetch'

import { addBody } from './body.js'
import { getRequestParams } from './params.js'
import { parseResponse, getFetchError } from './response.js'

@@ -36,10 +37,21 @@ import { shouldRetry, waitForRetry, MAX_RETRY } from './retry.js'

const getOpts = function ({ method: { verb, parameters }, defaultHeaders, agent, requestParams: { body }, opts }) {
const getOpts = function ({ method: { verb, parameters }, defaultHeaders, agent, requestParams, opts }) {
const { body } = requestParams
const optsA = addHttpMethod(verb, opts)
const optsB = addDefaultHeaders(defaultHeaders, optsA)
const optsC = addBody(body, parameters, optsB)
const optsD = addAgent(agent, optsC)
return optsD
const optsB = addHeaderParams(parameters, requestParams, optsA)
const optsC = addDefaultHeaders(defaultHeaders, optsB)
const optsD = addBody(body, parameters, optsC)
const optsE = addAgent(agent, optsD)
return optsE
}
// Add header parameters
const addHeaderParams = function (parameters, requestParams, opts) {
if (parameters.header === undefined) {
return opts
}
return { ...opts, headers: getRequestParams(parameters.header, requestParams, 'header parameter') }
}
// Add the HTTP method based on the OpenAPI definition

@@ -69,3 +81,3 @@ const addHttpMethod = function (verb, opts) {

if (shouldRetry({ response, error }) && index !== MAX_RETRY) {
if (shouldRetry({ response, error, method }) && index !== MAX_RETRY) {
await waitForRetry(response)

@@ -72,0 +84,0 @@ continue

// We retry:
// - when receiving a rate limiting response
// - on network failures due to timeouts
export const shouldRetry = function ({ response = {}, error = {} }) {
return isRetryStatus(response) || RETRY_ERROR_CODES.has(error.code)
}
export const shouldRetry = function ({ response = {}, error = {}, method = {} }) {
if (response.status === RATE_LIMIT_STATUS || RETRY_ERROR_CODES.has(error.code)) {
return true
}
const isRetryStatus = function ({ status }) {
return typeof status === 'number' && (status === RATE_LIMIT_STATUS || String(status).startsWith('5'))
// Special case for the `getLatestPluginRuns` endpoint.
// See https://github.com/netlify/bitballoon/issues/9616.
if (method.operationId === 'getLatestPluginRuns' && response.status === 500) {
return true
}
return false
}

@@ -11,0 +17,0 @@

@@ -1,4 +0,5 @@

import camelCase from 'lodash.camelcase'
import queryString from 'qs'
import { getRequestParams } from './params.js'
// Replace path parameters and query parameters in the URI, using the OpenAPI

@@ -31,18 +32,1 @@ // definition

}
const getRequestParams = function (params, requestParams, name) {
const entries = Object.values(params).map((param) => getRequestParam(param, requestParams, name))
return Object.assign({}, ...entries)
}
const getRequestParam = function (param, requestParams, name) {
const value = requestParams[param.name] || requestParams[camelCase(param.name)]
if (value !== undefined) {
return { [param.name]: value }
}
if (param.required) {
throw new Error(`Missing required ${name} '${param.name}'`)
}
}
SocketSocket SOC 2 Logo

Product

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

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc