-
3a3c092: # Add support for abort signals
The AbortSignal interface represents a signal object that allows you to communicate with an asynchronous operation (such as a fetch request) and abort it if required via an AbortController object. All gateway APIs (Fetch, HTTP and XHR) support this interface via the
signal
parameter:const abortController = new AbortController() // Start a long running task... client.Bitcoin.mine({ signal: abortController.signal }) // This takes too long, abort! abortController.abort()
The return value of some functions on
Request
have been updated to highlight that they might return undefined:Request#body()
Request#auth()
Request#timeout()
The reasoning behind this change is that if you didn't pass them (and no middleware set them) they might simply be undefined. So the types were simply wrong before. If you experience a "breaking change" due to this change, then it means you have a potential bug that you didn't properly handle before.
- 7356e30: Expose deep imports for backwards compatibility
- 404f7ba: Exporting client-builder
- 0b832ab: Fix ESM build to output correct code as per ESM spec
- 0177911: Fixes
middlewares
import path
-
6e94f97: Bundle with ESM exports.
- The recommended way to use mappersmith in ESM projects is to do
import { forge } from 'mappersmith'
rather than the oldimport forge from 'mappersmith'
. The reason is because test runners like jest and vitest might get confused when mixing named/default exports together with ESM, even though tsc and node has no problems with it. - A similar recommendation change goes for importing middleware: do
import { EncodeJsonMiddleware } from 'mappersmith/middleware'
(note themappersmith/middleware
folder) rather than deep importimport EncodeJsonMiddleware from 'mappersmith/middleware/encode-json'
. We still support the old import, but it will be deprecated in the future. - The same recommendation goes for importing gateway: do
import { FetchGateway } from 'mappersmith/gateway'
(note themappersmith/gateway
folder) rather than deep importimport FetchGateway from 'mappersmith/gateway/fetch'
. We still support the old import, but it will be deprecated in the future.
- The recommended way to use mappersmith in ESM projects is to do
-
9da82f6: Fixes memory leak when using http(s) agent with keep-alive
- e01114f: Fixed missing type declaration for
unusedMocks
mappersmith
:EncodeJSON
middleware now properly serializes+json
family of content-types #362
Fixed:
mappersmith
: Allow path to be empty string in manifest #327mappersmith
:Response.errors
should only be allowed to containError
orstring
#325
Added:
mappersmith
: Acceptpath
as a resource method param #328mappersmith
: A forged client now optionally accepts request context as its second argument #330mappersmith
: Add support for accessing the final request object in middleware response phase #321
Fixed:
mappersmith/test
: Properly merge headers when one of the sides is a mock matcher #316
Added:
mappersmith
: Add support for passing transient contexts between middleware #320
Fixed:
mappersmith
: Typo in basic auth import no longer causes build errors #313
Added:
mappersmith
: Added service workers support with default gatewayfetch
#311
Refactored:
mappersmith
: Migratedmiddleware
to typescript #306
Fixed:
mappersmith
: PreserverawData
as empty string instead of converting it to null #297mappersmith/test
: AllowBuffer
(and similar) as valid response data formockRequest
#299mappersmith
: Ensure references toregeneratorRuntime
is not part of compiled bundle #303
Added:
mappersmith/test
:mockClient
responses are now clones of the fixture instead of references to them #158mappersmith/*
: Move typings into src folder next to each file it describes #291mappersmith
: Convert Gateway to typescript #287mappersmith
: Add the possibility to update the default encoding function for query params #296
Fixed:
- (internal) Fixed bad release folder of 2.37.0
Fixed:
mappersmith/test
: Fix bug in mockRequest/mockClient where body params did not match independent of order #268
Added:
mappersmith
: Make Response accept a generic type that specifies the form of the data returned #265mappersmith/test
: AddresponseFactory
andrequestFactory
helpers tomappersmith/test
#265mappersmith/test
: Ifbody
is not provided to a mock, it will match on any body. #229 #152
Fixed:
- (internal) Fixed bad release folder of 2.36.4
mappersmith
: Fix unintended new query string behaviour introduced in 2.36 #281
Fixed:
- Fix missing retry-v2 typings in index.d.ts #261
Refactored:
- Migrated
ClientBuilder
to typescript #259
Fixed:
- Fix broken typings in index.d.ts #257
Added:
- Add option
parameterEncoder
which can optionally be used to override the encoding function for request params. Default isencodeURIComponent
#251
Fixed:
- Fix
x-started-at
header getting set to newDate.now()
during testing and failing header match #248 - Fix
Request.pathTemplate
to return result of the function instead of the function itself #249
Refactored:
- Migrated
Manifest
to typescript #254 - Migrated
MethodDescriptor
to typescript #245 - Migrated
Request
to typescript #245 - Migrated
Response
to typescript #249
Fixed:
- Respect
allowResourceHostOverride
configuration in middlewares #240 - A successful middleware should no longer overwriting a previous middleware's
error
#230
Added:
mappersmith
:Request.pathTemplate
- Returns the template path, without params, before interpolation #194mappersmith/test
:unusedMocks
- get count of unused mocks #227- The
+json
family of MIME types are parsed as json #223 - Add headers to mock matching strategy #168
Deprecated:
mappersmith
:setContext
- this is not safe for concurrent use #239
- Add json-encode middleware export
CONTENT_TYPE_JSON
to type definition #203 - Only accept host overrides if
allowResourceHostOverride=true
#204
- Fix
GatewayConfiguration
typings
- Add
enableHTTP408OnTimeouts
toHTTPGatewayConfiguration
typings
- Use latest request in response mock #191
- Add support for (Typescript) boolean as parameters #185
- Update typings for HTTPGateway configurations #182
- Accept a function as
MethodDescriptor.path
#186
- Bugfix: Only use param matchers on the attributes assigned to them #181
- New option on the HTTP gateway (
useSocketConnectionTimeout
) to include DNS and Socket connection on the timeout #179
- Bugfix: Preserve
timeElapsed
forresponse.enhance
#178
- Ignore
null
orundefined
values for dynamic segments #175
- Bugfix: Fetch gateway not using the right configs #161
- Bugfix: Regexp injection vulnerability #171
- Lazy-match body to not trigger body-matching callback unnecessarily #163
- Allow not sending a config in the Retry middleware #164
- Fix
mockRequest.url
type #166 - Fix MockClient types #170
- Add support for optional path parameters #171
- Replace multiple instances of same path parameter #174
- Remove type GlobalFetch from FetchGateway #155
- Add
ignoreGlobalMiddleware
to typescript type definitions #148 - Update
EncodeJson
middleware to not override pre-existing content-type #149 - Accept host as a resource method param #151
- Bugfix: Encode dynamic section params #141
- Add
clear
andm
TypeScript definitions
- Add
mockRequest
TypeScript definitions
- Ability to define middleware on resource level #134
- Add TypeScript definitions #136
- Add socket and response callbacks to the HTTP Gateway to allow for timing request stages #127
- Allow use of
mockRequest
andmockClient
with params/body that are independent of order #121
- Bugfix: Fix "ReferenceError: regeneratorRuntime is not defined" when importing "mappersmith/test" #131
- Bugfix:
mockRequest
would attempt to run the old request phase without considering async definitions #130
- Add
prepareRequest
phase to middleware #129
- Bugfix: Extra query string when path already contains query string #128
- Add async middleware requests support to mocked clients #122
- Allow setting of some resource configs at manifest level #114
- Bugfix: Reject the promise when using the retry middleware and another middleware on the stack throws an error #118
- Returns HTTP 408 (instead of 400) when request times out #88
- Bugfix: Plain object response data is not stringified on subsequent mock requests #107
- Add response callback support to
mockClient
#91 - Add status callback support to
mockClient
#105
- Add a way to rename queryparams (
queryParamAlias
) #102
- Cache some RegExp to improve overall performance
- Bugfix: Abort requests on timeout (http gateway)
- Improve "network error" handling #99
- Send error instance to
gateway#dispatchClientError
#99
- Throw errors when the middleware request phase fails
- If the request phase throws an error (e.g.:
[Mappersmith] middleware "MyMiddleware" failed in the request phase: <Original error message>
) - If the request phase returns something different than a mappersmith Request object (e.g.:
[Mappersmith] middleware "MyMiddleware" should return "Request" but returned "boolean"
)
- If the request phase throws an error (e.g.:
- Allow retries on successful calls
- Add the ability to re-run the middleware stack from the response phase (renew)
- Add Request#header to get a single header value by name
- Add support for HEAD HTTP method #90
- Bugfix: Calculate
Ended-At
after evaluatingnext
in the duration middleware
- Add support to binary payloads when using fetch gateway #89
- Add support to async middleware request phase #86
- Ensures all middleware expose name #83
- Bugfix: Use uppercase HTTP methods with XHR. CORS preflight requests will fail if the method name doesn't match #80
- Add Retry middleware v2 which doesn't use a global retry configuration #79
- Retry middleware: by default don't retry requests with statuses < 500 #78
- Add option to ignore global middleware
- Bugfix: Ignore Node.js files when bundling the client
- Bugfix: fix issue when mocking clients with middleware that use context #77
- Bugfix: fix IE binary request by configuring responseType after open #76
- Enable Windows integration tests via Appveyor #75
- Add current version to main module
- Add
clientId
to help identify different clients #73 - Add global context to help with request life cycle #73
- Add a retry validation callback to the Retry Middleware #72
- Renames middlewares folder to middleware, but keep importable files
- Add globally defined middleware
- Bugfix: fix CSRF middleware cookie parser #69
- Add
uuid4
matcher to the test library
This version was removed from NPM because the test library wasn't included to the final bundle
This version was removed from NPM because the test library wasn't included to the final bundle
- Adds CSRF middleware #68
- bugfix: Fix param matchers for mockClient
- bugfix: Auth mask was mutating the auth config #65
- Add support to binary payloads #64
- Switch tests to chrome-headless #63
- Mask auth password in the Response object #60
- Scope
gatewayConfigs
to allow different instances of mappersmith clients to use different configurations
- bugfix: HTTP Gateway was calculating
content-length
wrongly #59
- Remove
performance.now
polyfill to allow the use with web workers #55
- Change the HTTP gateway to use the built-in request#setTimeout
- Accept a matcher function as an URL in
mockRequest
- Add a
configure
callback to thehttp
gateway
- Adds Duration middleware #50
- bugfix: eval('process') causes some problems in strict mode on PhantomJS #51
- Allow
mockClient
andmockRequest
to use match functions to check body #49 - Add match functions to the test module #49
- bugfix: body, auth and timeout were always being replaced by
request#enhance
- Add support to basic auth for all gateways #46
- Add
BasicAuthMiddleware
to configure a default basic auth #46 - Add support to timeout for all gateways #47
- Add
TimeoutMiddleware
to configure a default timeout #47
- Add a retry middleware with exponential retry time #38
- Add a new gateway backed by
fetch
#42 - Add
Response#header
to get a single header value by name
- bugfix: Send
resourceName
andresourceMethod
when running the test lib - Add flag (
mockRequest
) when executing the middlewares from the test lib
- Expose
resourceName
andresourceMethod
to middlewares - Features from 2.0.0-rc1 to 2.0.0-rc7
- bugfix: EncodeJSON middleware was only returning requests if the original request had a body or caused an error
- Prevent method clear from the test lib to expose the internal store
- Normalize
responseData
to be alwaysnull
when not defined - Make
mockClient
independent of theresponse
call
- bugfix:
MockClient
should use the same middlewares configured in the client #37
- bugfix:
ClientBuilder
isn't using the new configured gateway whenconfig.gateway
changes #36
- Fix regression introduced in rc3, disable gateway http when transpiling for browser
- Publish only
lib
to NPM
- Add
content-length
only for gateway http #35 - Eval
process
to avoid webpack polyfills
- New API
- New test library
- Middlewares
- Add yarn.lock
- bugfix: duplicated
content-type
on vanilla gateway #32
- Included beforeSend callback, this should be configured through Global configurations and URL matching. It will follow the same behavior as the processor callback
- bugfix: some body parsers are super strict and will fail if charset has a “;” termination. PR #26 introduced this bug trying to solve issue #27
- bugfix: prioritizes user-defined content-type header even for post/put/patch/delete methods.
application/x-www-form-urlencoded
is not forced if Content-Type header is defined.
- bugfix: wrong
content-type
on vanilla gateway, a semicolon was missing oncharset=UTF-8
- Included status code for success calls
withCredentials
option forVanillaGateway
andJQueryGateway
- Method to configure a global success handler per client
- bugfix: rules matcher now uses full URL instead of descriptor path
- Optional callback parameter when passing options to gateway. Check the section "Specifics of each gateway" for more info
- Included request and response headers into stats object
- Included a way to assign headers directly from method calls
- Method to configure a global error handler per client
- Included status code in the error request object
- Bult-in fixture support
- Holding error stack for better debugging
- Allows Promise implementation to be configured, defaults to global Promise
- Headers option for all gateways
- bugfix: support for https in
NodeVanillaGateway
- Support for Promises
- bugfix: made headers from options higher priority than built-in headers
- Fail callback now receives the requested resource (url, host, path and params). This change breaks the API for fail callback, the original error objects will be available from the second argument and beyond
- Included host and path into stats object
- Improved package size
- Included url and params into stats object
- Support for alternative hosts for each resource method
- Ability to disable host resolution
- Measure of the time elapsed between the request and the callback invocation
- Stats object for success callbacks
- bugfix: VanillaGateway doesn't parse JSON responses
- Support for Node vanilla gateway
- Ability to configure default parameters for resources
- bugfix: fixed typo
- Support for emulateHTTP
- Support for global configurations and per url match configurations
- Support for POST, PUT, PATCH and DELETE methods
- Exposed body value to gateway
- Option to change the bodyAttr name
- Processor functions for resources
- Exposed request params to the gateway to allow o POST, PUT, etc
- Compact syntax (syntatic sugar for GET methods)
- bugfix: fixed reference of Mapper and VanillaGateway in index.js
- Basic structure with Jquery and Vanilla gateways
- Support for GET method