@anvilco/anvil
Advanced tools
Comparing version 2.11.1 to 2.12.0
@@ -10,6 +10,18 @@ # Changelog | ||
## [v2.11.1](https://github.com/anvilco/node-anvil/compare/v2.11.0...v2.11.1) | ||
## [v2.12.0](https://github.com/anvilco/node-anvil/compare/v2.11.1...v2.12.0) | ||
### Merged | ||
- Improve TypeScript types [`#153`](https://github.com/anvilco/node-anvil/pull/153) | ||
### Commits | ||
- Bump nodemon from 2.0.16 to 2.0.19 [`d4c7b2a`](https://github.com/anvilco/node-anvil/commit/d4c7b2ab418f610321edd20c194f3715a04cc981) | ||
- More response types [`0d3c332`](https://github.com/anvilco/node-anvil/commit/0d3c332f557e716ad6633922ae33f4fa5ea5cb91) | ||
- Improve optional arguments [`19f6365`](https://github.com/anvilco/node-anvil/commit/19f6365e1a8fb865d291ff6eb2c754f09c237b88) | ||
## [v2.11.1](https://github.com/anvilco/node-anvil/compare/v2.11.0...v2.11.1) - 2022-05-25 | ||
### Merged | ||
- Upgrade the babel deps [`#129`](https://github.com/anvilco/node-anvil/pull/129) | ||
@@ -16,0 +28,0 @@ - Upgrade dependencies [`#126`](https://github.com/anvilco/node-anvil/pull/126) |
{ | ||
"name": "@anvilco/anvil", | ||
"version": "2.11.1", | ||
"version": "2.12.0", | ||
"description": "Anvil API Client", | ||
@@ -5,0 +5,0 @@ "main": "src/index.js", |
109
src/index.js
@@ -13,2 +13,4 @@ const fs = require('fs') | ||
// We are only importing this for the type.. | ||
const { Stream } = require('stream') // eslint-disable-line no-unused-vars | ||
@@ -18,2 +20,4 @@ /** | ||
* @type {Object} | ||
* @property {string} [apiKey] | ||
* @property {string} [accessToken] | ||
* @property {string} [baseURL] | ||
@@ -23,6 +27,39 @@ * @property {string} [userAgent] | ||
* @property {number} [requestLimitMS] | ||
* @property {string} [apiKey] | ||
* @property {string} [accessToken] | ||
*/ | ||
/** | ||
* @typedef GraphQLResponse | ||
* @type {Object} | ||
* @property {number} statusCode | ||
* @property {GraphQLResponseData} [data] | ||
* @property {Array<ResponseError>} [errors] | ||
*/ | ||
/** @typedef {{ | ||
data: {[ key: string]: any } | ||
}} GraphQLResponseData */ | ||
/** | ||
* @typedef RESTResponse | ||
* @type {Object} | ||
* @property {number} statusCode | ||
* @property {Buffer|Stream|Object} [data] | ||
* @property {Array<ResponseError>} [errors] | ||
* @property {any} [response] node-fetch Response | ||
*/ | ||
/** @typedef {{ | ||
message: string, | ||
status?: number, | ||
name?: string, | ||
fields?: Array<ResponseErrorField> | ||
[key: string]: any | ||
}} ResponseError */ | ||
/** @typedef {{ | ||
message: string, | ||
property?: string, | ||
[key: string]: any | ||
}} ResponseErrorField */ | ||
// Ignoring the below since they are dynamically created depepending on what's | ||
@@ -158,3 +195,3 @@ // inside the `src/graphql` directory. | ||
* a Buffer, or a Stream-like thing that is compatible with form-data as an append. | ||
* @param {object} formDataAppendOptions - User can specify options to be passed to the form-data.append | ||
* @param {Object} [formDataAppendOptions] - User can specify options to be passed to the form-data.append | ||
* call. This should be done if a stream-like thing is not one of the common types that | ||
@@ -179,5 +216,5 @@ * form-data can figure out on its own. | ||
* @param {Object} data.variables | ||
* @param {string} data.responseQuery | ||
* @param {any} data.mutation | ||
* @returns {Promise<{data: *, errors: *, statusCode: *}>} | ||
* @param {string} [data.responseQuery] | ||
* @param {string} [data.mutation] | ||
* @returns {Promise<GraphQLResponse>} | ||
*/ | ||
@@ -196,4 +233,4 @@ createEtchPacket ({ variables, responseQuery, mutation }) { | ||
* @param {string} documentGroupEid | ||
* @param {Object?} clientOptions | ||
* @returns {Promise<{data: *, response: *, errors: *, statusCode: *}>} | ||
* @param {Object} [clientOptions] | ||
* @returns {Promise<RESTResponse>} | ||
*/ | ||
@@ -219,4 +256,4 @@ downloadDocuments (documentGroupEid, clientOptions = {}) { | ||
* @param {Object} payload | ||
* @param {Object?} clientOptions | ||
* @returns {Promise<{data: *, response: *, errors: *, statusCode: *}>} | ||
* @param {Object} [clientOptions] | ||
* @returns {Promise<RESTResponse>} | ||
*/ | ||
@@ -249,5 +286,5 @@ fillPDF (pdfTemplateID, payload, clientOptions = {}) { | ||
* @param {Object} data.variables | ||
* @param {string} data.responseQuery | ||
* @param {any} data.mutation | ||
* @returns {Promise<{data: *, errors: *, statusCode: *}>} | ||
* @param {string} [data.responseQuery] | ||
* @param {string} [data.mutation] | ||
* @returns {Promise<GraphQLResponse>} | ||
*/ | ||
@@ -266,4 +303,4 @@ forgeSubmit ({ variables, responseQuery, mutation }) { | ||
* @param {Object} payload | ||
* @param {Object?} clientOptions | ||
* @returns {Promise<{data: *, response: *, errors: *, statusCode: *}>} | ||
* @param {Object} [clientOptions] | ||
* @returns {Promise<RESTResponse>} | ||
*/ | ||
@@ -296,4 +333,4 @@ generatePDF (payload, clientOptions = {}) { | ||
* @param {Object} data.variables | ||
* @param {string} data.responseQuery | ||
* @returns {Promise<{data: *, errors: *, statusCode: *}>} | ||
* @param {string} [data.responseQuery] | ||
* @returns {Promise<GraphQLResponse>} | ||
*/ | ||
@@ -313,3 +350,3 @@ getEtchPacket ({ variables, responseQuery }) { | ||
* @param {Object} data.variables | ||
* @returns {Promise<{url: (*|string), errors: *, statusCode: *}>} | ||
* @returns {Promise<{url?: string, errors?: Array<ResponseError>, statusCode: number}>} | ||
*/ | ||
@@ -335,4 +372,4 @@ async generateEtchSignUrl ({ variables }) { | ||
* @param {Object} data.variables | ||
* @param {any} data.mutation | ||
* @returns {Promise<{data: *, errors: *, statusCode: *}>} | ||
* @param {string} [data.mutation] | ||
* @returns {Promise<GraphQLResponse>} | ||
*/ | ||
@@ -351,6 +388,6 @@ removeWeldData ({ variables, mutation }) { | ||
* @param {Object} data | ||
* @param {any} data.query | ||
* @param {Object?} data.variables | ||
* @param {Object} clientOptions | ||
* @returns {Promise<{data: *, errors: *, statusCode: *}>} | ||
* @param {string} data.query | ||
* @param {Object} [data.variables] | ||
* @param {Object} [clientOptions] | ||
* @returns {Promise<GraphQLResponse>} | ||
*/ | ||
@@ -444,4 +481,4 @@ async requestGraphQL ({ query, variables = {} }, clientOptions) { | ||
* @param {Object} fetchOptions | ||
* @param {Object} clientOptions | ||
* @returns {Promise<{data: *, response: *, errors: *, statusCode: *}>} | ||
* @param {Object} [clientOptions] | ||
* @returns {Promise<RESTResponse>} | ||
*/ | ||
@@ -493,3 +530,3 @@ async requestREST (url, fetchOptions, clientOptions) { | ||
* @param {CallableFunction} retryableRequestFn | ||
* @param {Object?} clientOptions | ||
* @param {Object} [clientOptions] | ||
* @returns {Promise<*>} | ||
@@ -592,3 +629,3 @@ * @private | ||
* @param {Object} headerObject.headers | ||
* @param {Object?} internalOptions | ||
* @param {Object} [internalOptions] | ||
* @returns {*&{headers: {}}} | ||
@@ -601,9 +638,11 @@ * @private | ||
newHeaders = defaults ? newHeaders : Object.entries(newHeaders).reduce((acc, [key, val]) => { | ||
if (val != null) { | ||
acc[key] = val | ||
} | ||
newHeaders = defaults | ||
? newHeaders | ||
: Object.entries(newHeaders).reduce((acc, [key, val]) => { | ||
if (val != null) { | ||
acc[key] = val | ||
} | ||
return acc | ||
}, {}) | ||
return acc | ||
}, {}) | ||
@@ -672,2 +711,4 @@ return { | ||
Anvil.UploadWithOptions = UploadWithOptions | ||
/** | ||
@@ -674,0 +715,0 @@ * @param {string} retryAfterSeconds |
@@ -9,3 +9,3 @@ export = Anvil; | ||
* a Buffer, or a Stream-like thing that is compatible with form-data as an append. | ||
* @param {object} formDataAppendOptions - User can specify options to be passed to the form-data.append | ||
* @param {Object} [formDataAppendOptions] - User can specify options to be passed to the form-data.append | ||
* call. This should be done if a stream-like thing is not one of the common types that | ||
@@ -17,3 +17,3 @@ * form-data can figure out on its own. | ||
*/ | ||
static prepareGraphQLFile(pathOrStreamLikeThing: string | Buffer, formDataAppendOptions: object): UploadWithOptions; | ||
static prepareGraphQLFile(pathOrStreamLikeThing: string | Buffer, formDataAppendOptions?: any): UploadWithOptions; | ||
/** | ||
@@ -24,2 +24,4 @@ * @param {AnvilOptions?} options | ||
options: { | ||
apiKey?: string; | ||
accessToken?: string; | ||
baseURL: string; | ||
@@ -29,4 +31,2 @@ userAgent: string; | ||
requestLimitMS: number; | ||
apiKey?: string; | ||
accessToken?: string; | ||
}; | ||
@@ -52,83 +52,56 @@ authHeader: string; | ||
* @param {Object} data.variables | ||
* @param {string} data.responseQuery | ||
* @param {any} data.mutation | ||
* @returns {Promise<{data: *, errors: *, statusCode: *}>} | ||
* @param {string} [data.responseQuery] | ||
* @param {string} [data.mutation] | ||
* @returns {Promise<GraphQLResponse>} | ||
*/ | ||
createEtchPacket({ variables, responseQuery, mutation }: { | ||
variables: any; | ||
responseQuery: string; | ||
mutation: any; | ||
}): Promise<{ | ||
data: any; | ||
errors: any; | ||
statusCode: any; | ||
}>; | ||
responseQuery?: string; | ||
mutation?: string; | ||
}): Promise<GraphQLResponse>; | ||
/** | ||
* @param {string} documentGroupEid | ||
* @param {Object?} clientOptions | ||
* @returns {Promise<{data: *, response: *, errors: *, statusCode: *}>} | ||
* @param {Object} [clientOptions] | ||
* @returns {Promise<RESTResponse>} | ||
*/ | ||
downloadDocuments(documentGroupEid: string, clientOptions?: any | null): Promise<{ | ||
data: any; | ||
response: any; | ||
errors: any; | ||
statusCode: any; | ||
}>; | ||
downloadDocuments(documentGroupEid: string, clientOptions?: any): Promise<RESTResponse>; | ||
/** | ||
* @param {string} pdfTemplateID | ||
* @param {Object} payload | ||
* @param {Object?} clientOptions | ||
* @returns {Promise<{data: *, response: *, errors: *, statusCode: *}>} | ||
* @param {Object} [clientOptions] | ||
* @returns {Promise<RESTResponse>} | ||
*/ | ||
fillPDF(pdfTemplateID: string, payload: any, clientOptions?: any | null): Promise<{ | ||
data: any; | ||
response: any; | ||
errors: any; | ||
statusCode: any; | ||
}>; | ||
fillPDF(pdfTemplateID: string, payload: any, clientOptions?: any): Promise<RESTResponse>; | ||
/** | ||
* @param {Object} data | ||
* @param {Object} data.variables | ||
* @param {string} data.responseQuery | ||
* @param {any} data.mutation | ||
* @returns {Promise<{data: *, errors: *, statusCode: *}>} | ||
* @param {string} [data.responseQuery] | ||
* @param {string} [data.mutation] | ||
* @returns {Promise<GraphQLResponse>} | ||
*/ | ||
forgeSubmit({ variables, responseQuery, mutation }: { | ||
variables: any; | ||
responseQuery: string; | ||
mutation: any; | ||
}): Promise<{ | ||
data: any; | ||
errors: any; | ||
statusCode: any; | ||
}>; | ||
responseQuery?: string; | ||
mutation?: string; | ||
}): Promise<GraphQLResponse>; | ||
/** | ||
* @param {Object} payload | ||
* @param {Object?} clientOptions | ||
* @returns {Promise<{data: *, response: *, errors: *, statusCode: *}>} | ||
* @param {Object} [clientOptions] | ||
* @returns {Promise<RESTResponse>} | ||
*/ | ||
generatePDF(payload: any, clientOptions?: any | null): Promise<{ | ||
data: any; | ||
response: any; | ||
errors: any; | ||
statusCode: any; | ||
}>; | ||
generatePDF(payload: any, clientOptions?: any): Promise<RESTResponse>; | ||
/** | ||
* @param {Object} data | ||
* @param {Object} data.variables | ||
* @param {string} data.responseQuery | ||
* @returns {Promise<{data: *, errors: *, statusCode: *}>} | ||
* @param {string} [data.responseQuery] | ||
* @returns {Promise<GraphQLResponse>} | ||
*/ | ||
getEtchPacket({ variables, responseQuery }: { | ||
variables: any; | ||
responseQuery: string; | ||
}): Promise<{ | ||
data: any; | ||
errors: any; | ||
statusCode: any; | ||
}>; | ||
responseQuery?: string; | ||
}): Promise<GraphQLResponse>; | ||
/** | ||
* @param {Object} data | ||
* @param {Object} data.variables | ||
* @returns {Promise<{url: (*|string), errors: *, statusCode: *}>} | ||
* @returns {Promise<{url?: string, errors?: Array<ResponseError>, statusCode: number}>} | ||
*/ | ||
@@ -138,5 +111,5 @@ generateEtchSignUrl({ variables }: { | ||
}): Promise<{ | ||
url: (any | string); | ||
errors: any; | ||
statusCode: any; | ||
url?: string; | ||
errors?: Array<ResponseError>; | ||
statusCode: number; | ||
}>; | ||
@@ -146,40 +119,27 @@ /** | ||
* @param {Object} data.variables | ||
* @param {any} data.mutation | ||
* @returns {Promise<{data: *, errors: *, statusCode: *}>} | ||
* @param {string} [data.mutation] | ||
* @returns {Promise<GraphQLResponse>} | ||
*/ | ||
removeWeldData({ variables, mutation }: { | ||
variables: any; | ||
mutation: any; | ||
}): Promise<{ | ||
data: any; | ||
errors: any; | ||
statusCode: any; | ||
}>; | ||
mutation?: string; | ||
}): Promise<GraphQLResponse>; | ||
/** | ||
* @param {Object} data | ||
* @param {any} data.query | ||
* @param {Object?} data.variables | ||
* @param {Object} clientOptions | ||
* @returns {Promise<{data: *, errors: *, statusCode: *}>} | ||
* @param {string} data.query | ||
* @param {Object} [data.variables] | ||
* @param {Object} [clientOptions] | ||
* @returns {Promise<GraphQLResponse>} | ||
*/ | ||
requestGraphQL({ query, variables }: { | ||
query: any; | ||
variables: any | null; | ||
}, clientOptions: any): Promise<{ | ||
data: any; | ||
errors: any; | ||
statusCode: any; | ||
}>; | ||
query: string; | ||
variables?: any; | ||
}, clientOptions?: any): Promise<GraphQLResponse>; | ||
/** | ||
* @param {string} url | ||
* @param {Object} fetchOptions | ||
* @param {Object} clientOptions | ||
* @returns {Promise<{data: *, response: *, errors: *, statusCode: *}>} | ||
* @param {Object} [clientOptions] | ||
* @returns {Promise<RESTResponse>} | ||
*/ | ||
requestREST(url: string, fetchOptions: any, clientOptions: any): Promise<{ | ||
data: any; | ||
response: any; | ||
errors: any; | ||
statusCode: any; | ||
}>; | ||
requestREST(url: string, fetchOptions: any, clientOptions?: any): Promise<RESTResponse>; | ||
/** | ||
@@ -194,3 +154,3 @@ * @param {string} url | ||
* @param {CallableFunction} retryableRequestFn | ||
* @param {Object?} clientOptions | ||
* @param {Object} [clientOptions] | ||
* @returns {Promise<*>} | ||
@@ -210,3 +170,3 @@ * @private | ||
* @param {Object} headerObject.headers | ||
* @param {Object?} internalOptions | ||
* @param {Object} [internalOptions] | ||
* @returns {*&{headers: {}}} | ||
@@ -230,7 +190,30 @@ * @private | ||
declare namespace Anvil { | ||
export { AnvilOptions }; | ||
export { UploadWithOptions, AnvilOptions, GraphQLResponse, GraphQLResponseData, RESTResponse, ResponseError, ResponseErrorField }; | ||
} | ||
import { RateLimiter } from "limiter/dist/cjs/RateLimiter"; | ||
type GraphQLResponse = { | ||
statusCode: number; | ||
data?: GraphQLResponseData; | ||
errors?: Array<ResponseError>; | ||
}; | ||
type RESTResponse = { | ||
statusCode: number; | ||
data?: Buffer | Stream | any; | ||
errors?: Array<ResponseError>; | ||
/** | ||
* node-fetch Response | ||
*/ | ||
response?: any; | ||
}; | ||
type ResponseError = { | ||
[key: string]: any; | ||
message: string; | ||
status?: number; | ||
name?: string; | ||
fields?: Array<ResponseErrorField>; | ||
}; | ||
import UploadWithOptions = require("./UploadWithOptions"); | ||
type AnvilOptions = { | ||
apiKey?: string; | ||
accessToken?: string; | ||
baseURL?: string; | ||
@@ -240,5 +223,14 @@ userAgent?: string; | ||
requestLimitMS?: number; | ||
apiKey?: string; | ||
accessToken?: string; | ||
}; | ||
type GraphQLResponseData = { | ||
data: { | ||
[key: string]: any; | ||
}; | ||
}; | ||
type ResponseErrorField = { | ||
[key: string]: any; | ||
message: string; | ||
property?: string; | ||
}; | ||
import { Stream } from "stream"; | ||
//# sourceMappingURL=index.d.ts.map |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
72002
1188