@n1k1t/mock-server 0.1.7 → 0.1.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +200 -12
- package/lib/package.json +4 -1
- package/lib/src/client/helpers/expectations.d.ts +18 -18
- package/lib/src/client/helpers/expectations.d.ts.map +1 -1
- package/lib/src/client/helpers/expectations.js.map +1 -1
- package/lib/src/client/methods/expectations.create.method.d.ts +1 -1
- package/lib/src/client/methods/expectations.create.method.js +2 -2
- package/lib/src/client/methods/expectations.create.method.js.map +1 -1
- package/lib/src/client/methods/expectations.delete.method.js +2 -2
- package/lib/src/client/methods/expectations.delete.method.js.map +1 -1
- package/lib/src/client/methods/expectations.update.method.d.ts +1 -1
- package/lib/src/client/methods/expectations.update.method.js +4 -4
- package/lib/src/client/methods/expectations.update.method.js.map +1 -1
- package/lib/src/client/models/client.d.ts +13 -13
- package/lib/src/client/models/client.d.ts.map +1 -1
- package/lib/src/client/models/client.js.map +1 -1
- package/lib/src/config/model.d.ts +10 -1
- package/lib/src/config/model.d.ts.map +1 -1
- package/lib/src/config/model.js +11 -1
- package/lib/src/config/model.js.map +1 -1
- package/lib/src/expectations/__utils__/index.d.ts +1 -2
- package/lib/src/expectations/__utils__/index.d.ts.map +1 -1
- package/lib/src/expectations/__utils__/index.js +6 -0
- package/lib/src/expectations/__utils__/index.js.map +1 -1
- package/lib/src/expectations/models/expectation.d.ts +15 -9
- package/lib/src/expectations/models/expectation.d.ts.map +1 -1
- package/lib/src/expectations/models/expectation.js.map +1 -1
- package/lib/src/expectations/models/operator.d.ts +3 -3
- package/lib/src/expectations/models/operator.d.ts.map +1 -1
- package/lib/src/expectations/models/storage.d.ts +1 -2
- package/lib/src/expectations/models/storage.d.ts.map +1 -1
- package/lib/src/expectations/models/storage.js.map +1 -1
- package/lib/src/expectations/operators/and.operator.d.ts +1 -2
- package/lib/src/expectations/operators/and.operator.d.ts.map +1 -1
- package/lib/src/expectations/operators/and.operator.js.map +1 -1
- package/lib/src/expectations/operators/exec.operator.d.ts +2 -2
- package/lib/src/expectations/operators/exec.operator.d.ts.map +1 -1
- package/lib/src/expectations/operators/exec.operator.js.map +1 -1
- package/lib/src/expectations/operators/exec.operator.spec.js.map +1 -1
- package/lib/src/expectations/operators/has.operator.d.ts +1 -1
- package/lib/src/expectations/operators/has.operator.d.ts.map +1 -1
- package/lib/src/expectations/operators/has.operator.spec.js.map +1 -1
- package/lib/src/expectations/operators/if.operator.d.ts +1 -2
- package/lib/src/expectations/operators/if.operator.d.ts.map +1 -1
- package/lib/src/expectations/operators/if.operator.js.map +1 -1
- package/lib/src/expectations/operators/merge.operator.d.ts +3 -3
- package/lib/src/expectations/operators/merge.operator.d.ts.map +1 -1
- package/lib/src/expectations/operators/merge.operator.js +2 -2
- package/lib/src/expectations/operators/merge.operator.js.map +1 -1
- package/lib/src/expectations/operators/merge.operator.spec.js.map +1 -1
- package/lib/src/expectations/operators/not.operator.d.ts +1 -2
- package/lib/src/expectations/operators/not.operator.d.ts.map +1 -1
- package/lib/src/expectations/operators/not.operator.js.map +1 -1
- package/lib/src/expectations/operators/or.operator.d.ts +1 -2
- package/lib/src/expectations/operators/or.operator.d.ts.map +1 -1
- package/lib/src/expectations/operators/or.operator.js.map +1 -1
- package/lib/src/expectations/operators/remove.operator.d.ts +1 -2
- package/lib/src/expectations/operators/remove.operator.d.ts.map +1 -1
- package/lib/src/expectations/operators/remove.operator.js.map +1 -1
- package/lib/src/expectations/operators/remove.operator.spec.js.map +1 -1
- package/lib/src/expectations/operators/root.operator.d.ts +1 -2
- package/lib/src/expectations/operators/root.operator.d.ts.map +1 -1
- package/lib/src/expectations/operators/root.operator.js.map +1 -1
- package/lib/src/expectations/operators/set.operator.d.ts +2 -2
- package/lib/src/expectations/operators/set.operator.d.ts.map +1 -1
- package/lib/src/expectations/operators/set.operator.js.map +1 -1
- package/lib/src/expectations/operators/switch.operator.d.ts +2 -2
- package/lib/src/expectations/operators/switch.operator.d.ts.map +1 -1
- package/lib/src/expectations/types.d.ts +28 -14
- package/lib/src/expectations/types.d.ts.map +1 -1
- package/lib/src/expectations/types.js +4 -2
- package/lib/src/expectations/types.js.map +1 -1
- package/lib/src/expectations/utils.d.ts +3 -4
- package/lib/src/expectations/utils.d.ts.map +1 -1
- package/lib/src/expectations/utils.js +12 -0
- package/lib/src/expectations/utils.js.map +1 -1
- package/lib/src/server/endpoints/config.get.endpoint.d.ts +12 -0
- package/lib/src/server/endpoints/config.get.endpoint.d.ts.map +1 -1
- package/lib/src/server/endpoints/expectations.create.endpoint.d.ts +2 -2
- package/lib/src/server/endpoints/expectations.get-list.endpoint.d.ts +2 -2
- package/lib/src/server/endpoints/expectations.get-list.endpoint.js +1 -1
- package/lib/src/server/endpoints/expectations.get-list.endpoint.js.map +1 -1
- package/lib/src/server/endpoints/expectations.update.endpoint.d.ts +2 -2
- package/lib/src/server/endpoints/history.get-list.endpoint.d.ts +6 -3
- package/lib/src/server/endpoints/history.get-list.endpoint.d.ts.map +1 -1
- package/lib/src/server/endpoints/history.get-list.endpoint.js +1 -1
- package/lib/src/server/endpoints/history.get-list.endpoint.js.map +1 -1
- package/lib/src/server/history/index.d.ts +0 -1
- package/lib/src/server/history/index.d.ts.map +1 -1
- package/lib/src/server/history/index.js +0 -1
- package/lib/src/server/history/index.js.map +1 -1
- package/lib/src/server/history/model.d.ts +12 -12
- package/lib/src/server/history/model.d.ts.map +1 -1
- package/lib/src/server/history/model.js +8 -23
- package/lib/src/server/history/model.js.map +1 -1
- package/lib/src/server/history/storage.d.ts +1 -1
- package/lib/src/server/history/storage.d.ts.map +1 -1
- package/lib/src/server/history/storage.js.map +1 -1
- package/lib/src/server/index.d.ts.map +1 -1
- package/lib/src/server/index.js +7 -0
- package/lib/src/server/index.js.map +1 -1
- package/lib/src/server/middlewares/delay.middleware.d.ts +7 -13
- package/lib/src/server/middlewares/delay.middleware.d.ts.map +1 -1
- package/lib/src/server/middlewares/delay.middleware.js +4 -4
- package/lib/src/server/middlewares/delay.middleware.js.map +1 -1
- package/lib/src/server/middlewares/destroy.midleware.d.ts +7 -13
- package/lib/src/server/middlewares/destroy.midleware.d.ts.map +1 -1
- package/lib/src/server/middlewares/destroy.midleware.js +7 -8
- package/lib/src/server/middlewares/destroy.midleware.js.map +1 -1
- package/lib/src/server/middlewares/forward.middleware.d.ts +8 -14
- package/lib/src/server/middlewares/forward.middleware.d.ts.map +1 -1
- package/lib/src/server/middlewares/forward.middleware.js +60 -20
- package/lib/src/server/middlewares/forward.middleware.js.map +1 -1
- package/lib/src/server/middlewares/history.middleware.d.ts +4 -10
- package/lib/src/server/middlewares/history.middleware.d.ts.map +1 -1
- package/lib/src/server/middlewares/history.middleware.js +3 -3
- package/lib/src/server/middlewares/history.middleware.js.map +1 -1
- package/lib/src/server/middlewares/internal.middleware.d.ts +4 -10
- package/lib/src/server/middlewares/internal.middleware.d.ts.map +1 -1
- package/lib/src/server/middlewares/manipulate-expectation.middleware.d.ts +4 -10
- package/lib/src/server/middlewares/manipulate-expectation.middleware.d.ts.map +1 -1
- package/lib/src/server/middlewares/manipulate-expectation.middleware.js +1 -7
- package/lib/src/server/middlewares/manipulate-expectation.middleware.js.map +1 -1
- package/lib/src/server/middlewares/match-expectation.middleware.d.ts +4 -10
- package/lib/src/server/middlewares/match-expectation.middleware.d.ts.map +1 -1
- package/lib/src/server/middlewares/match-expectation.middleware.js +7 -8
- package/lib/src/server/middlewares/match-expectation.middleware.js.map +1 -1
- package/lib/src/server/middlewares/public.middleware.d.ts +4 -10
- package/lib/src/server/middlewares/public.middleware.d.ts.map +1 -1
- package/lib/src/server/middlewares/reply.middleware.d.ts +9 -15
- package/lib/src/server/middlewares/reply.middleware.d.ts.map +1 -1
- package/lib/src/server/middlewares/reply.middleware.js +43 -29
- package/lib/src/server/middlewares/reply.middleware.js.map +1 -1
- package/lib/src/server/models/containers/index.d.ts +3 -0
- package/lib/src/server/models/containers/index.d.ts.map +1 -0
- package/lib/src/server/models/containers/index.js +19 -0
- package/lib/src/server/models/containers/index.js.map +1 -0
- package/lib/src/server/models/containers/model.d.ts +36 -0
- package/lib/src/server/models/containers/model.d.ts.map +1 -0
- package/lib/src/server/models/containers/model.js +46 -0
- package/lib/src/server/models/containers/model.js.map +1 -0
- package/lib/src/server/models/containers/storage.d.ts +19 -0
- package/lib/src/server/models/containers/storage.d.ts.map +1 -0
- package/lib/src/server/models/containers/storage.js +44 -0
- package/lib/src/server/models/containers/storage.js.map +1 -0
- package/lib/src/server/models/containers/utils.d.ts +2 -0
- package/lib/src/server/models/containers/utils.d.ts.map +1 -0
- package/lib/src/server/models/containers/utils.js +7 -0
- package/lib/src/server/models/containers/utils.js.map +1 -0
- package/lib/src/server/models/index.d.ts +1 -0
- package/lib/src/server/models/index.d.ts.map +1 -1
- package/lib/src/server/models/index.js +1 -0
- package/lib/src/server/models/index.js.map +1 -1
- package/lib/src/server/models/middleware.d.ts +2 -5
- package/lib/src/server/models/middleware.d.ts.map +1 -1
- package/lib/src/server/models/plugins.d.ts +7 -2
- package/lib/src/server/models/plugins.d.ts.map +1 -1
- package/lib/src/server/models/plugins.js.map +1 -1
- package/lib/src/server/models/request-context/http.d.ts +20 -15
- package/lib/src/server/models/request-context/http.d.ts.map +1 -1
- package/lib/src/server/models/request-context/http.js +23 -31
- package/lib/src/server/models/request-context/http.js.map +1 -1
- package/lib/src/server/models/request-context/index.d.ts +1 -0
- package/lib/src/server/models/request-context/index.d.ts.map +1 -1
- package/lib/src/server/models/request-context/index.js +1 -0
- package/lib/src/server/models/request-context/index.js.map +1 -1
- package/lib/src/server/models/request-context/snapshot.d.ts +30 -0
- package/lib/src/server/models/request-context/snapshot.d.ts.map +1 -0
- package/lib/src/server/models/request-context/snapshot.js +59 -0
- package/lib/src/server/models/request-context/snapshot.js.map +1 -0
- package/lib/src/server/models/request-context/types.d.ts +10 -0
- package/lib/src/server/models/request-context/types.d.ts.map +1 -1
- package/lib/src/server/models/request-context/utils.d.ts +1 -0
- package/lib/src/server/models/request-context/utils.d.ts.map +1 -1
- package/lib/src/server/models/request-context/utils.js +1 -1
- package/lib/src/server/models/request-context/utils.js.map +1 -1
- package/lib/src/server/models/server-context.d.ts +7 -2
- package/lib/src/server/models/server-context.d.ts.map +1 -1
- package/lib/src/server/models/server-context.js +17 -3
- package/lib/src/server/models/server-context.js.map +1 -1
- package/lib/src/server/ws-exchange/types.d.ts +2 -2
- package/lib/src/server/ws-exchange/types.d.ts.map +1 -1
- package/lib/tsconfig.tsbuildinfo +1 -1
- package/package.json +4 -1
- package/public/index.html +0 -1
- package/public/scripts/main.js +34 -25
- package/public/styles/main.css +268 -1
- package/lib/src/server/history/types.d.ts +0 -14
- package/lib/src/server/history/types.d.ts.map +0 -1
- package/lib/src/server/history/types.js +0 -3
- package/lib/src/server/history/types.js.map +0 -1
- package/public/styles/json-highlighter.css +0 -259
package/README.md
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
|
|
2
2
|
|
|
3
|
+
|
|
3
4
|
# Mock server
|
|
4
5
|
|
|
5
6
|
Mock, match, modify and manipulate a HTTP request/response payload using flexible expectations with types
|
|
@@ -16,10 +17,14 @@ Mock, match, modify and manipulate a HTTP request/response payload using flexibl
|
|
|
16
17
|
- [Mock](#mock)
|
|
17
18
|
- [Expectations](#expectations)
|
|
18
19
|
- [Schema](#schema)
|
|
20
|
+
- [Forwarding](#forwarding)
|
|
19
21
|
- [Context](#context)
|
|
20
22
|
- [Utils](#utils)
|
|
21
23
|
- [Operators](#operators)
|
|
22
24
|
- [Typings](#typings)
|
|
25
|
+
- [Storage](#storage)
|
|
26
|
+
- [Containers](#containers)
|
|
27
|
+
- [Cache](#cache)
|
|
23
28
|
- [State](#state)
|
|
24
29
|
- [Seeds](#seeds)
|
|
25
30
|
- [XML](#xml)
|
|
@@ -113,9 +118,7 @@ An expectation schema can contain some rules to handle `request`, `response` and
|
|
|
113
118
|
|--|--|--|--|--|
|
|
114
119
|
| request | [Operators](#operators) | `object` | * | Describes a way to catch by request and how to manipulate it |
|
|
115
120
|
| response | [Operators](#operators) | `object` | * | Describes how to manipulate response. Also can be used to catch response in case of forwarding |
|
|
116
|
-
| forward | | `object` | * | Describes configuration to forward a request to another host |
|
|
117
|
-
| | url | `string` | * | Absolute URL to target |
|
|
118
|
-
| | baseUrl | `string` | * | Base URL to target. The path will be provided from request |
|
|
121
|
+
| forward | [Forwarding](#forwarding) | `object` | * | Describes configuration to forward a request to another host |
|
|
119
122
|
|
|
120
123
|
**Example**
|
|
121
124
|
|
|
@@ -136,12 +139,33 @@ await server.client.createExpectation({
|
|
|
136
139
|
});
|
|
137
140
|
```
|
|
138
141
|
|
|
142
|
+
## Forwarding
|
|
143
|
+
|
|
144
|
+
| Property | Nested | Type | Optional | Description |
|
|
145
|
+
|--|--|--|--|--|
|
|
146
|
+
| url | | `string` | * | Absolute URL to target |
|
|
147
|
+
| baseUrl | | `string` | * | Base URL to target. The path will be provided from request |
|
|
148
|
+
| options | | `string` | * | Forwarding options |
|
|
149
|
+
| | host | `origin` | * | Provides `Host` header as same as mock server host (if not specified). If specified to `origin` then value for `Host` header will be taken from url |
|
|
150
|
+
| cache | | `object` | * | [Cache](#cache) configuration for a payload of forwarded requests |
|
|
151
|
+
| | storage | `redis` | * | Storage to read/write a cache |
|
|
152
|
+
| | key | `string` | * | Key to get read/write access of cached payload |
|
|
153
|
+
| | prefix | `string` | * | Prefix of the `key` of cache |
|
|
154
|
+
| | ttl | `number` | * | Time to live of cache in seconds |
|
|
155
|
+
|
|
139
156
|
## Context
|
|
140
157
|
|
|
141
158
|
| Property | Nested | `$location` | Type | Optional | Description |
|
|
142
159
|
|--|--|--|--|--|--|
|
|
160
|
+
| storage | [Storage](#storage) | | `object` | | A storage of `container` entities |
|
|
161
|
+
| container | [Container](#containers) | `container` | `object` | | A temporary cell in `storage`. Should be useful to sync expectations between each other or store and use any data each request |
|
|
162
|
+
| state | | `state` | `object` | | An [object](#state) with custom data |
|
|
143
163
|
| seed | | `seed` | `string` | * | Incoming request [seed](#seeds) |
|
|
144
|
-
|
|
|
164
|
+
| cache | | `cache` | `object` | | [Cache](#cache) configuration |
|
|
165
|
+
| | isEnabled | | `boolean` | * | Toggle of cache usage |
|
|
166
|
+
| | key | | `string ∣ object` | * | Key to get read/write access of cached payload. Value provided as `object` will hashed using [FNV1A-64](https://en.wikipedia.org/wiki/Fowler%E2%80%93Noll%E2%80%93Vo_hash_function) algorithm |
|
|
167
|
+
| | prefix | | `string` | * | Prefix of the `key` of cache |
|
|
168
|
+
| | ttl | | `number` | * | Time to live of cache in seconds |
|
|
145
169
|
| incoming | | | `object` | | Payload with data of incoming request |
|
|
146
170
|
| | path | `path` | `string` | | Incoming request path |
|
|
147
171
|
| | method | `method` | `string` | | Incoming request method in **uppercase** |
|
|
@@ -691,6 +715,101 @@ await client.createExpectation<{
|
|
|
691
715
|
}));
|
|
692
716
|
```
|
|
693
717
|
|
|
718
|
+
## Storage
|
|
719
|
+
|
|
720
|
+
Storage is a temporary storage that provides an access to read/write [containers](#containers)
|
|
721
|
+
|
|
722
|
+
| Property | Type | Description |
|
|
723
|
+
|--|--|--|
|
|
724
|
+
| find | `(key: string ∣ object) => Container ∣ null` | Finds a container in storage. Every `key` provided as `object` will hashed using [FNV1A-64](https://en.wikipedia.org/wiki/Fowler%E2%80%93Noll%E2%80%93Vo_hash_function) algorithm |
|
|
725
|
+
| delete | `(key: string ∣ object) => Container ∣ null` | Deletes a container in storage. Every `key` provided as `object` will hashed using [FNV1A-64](https://en.wikipedia.org/wiki/Fowler%E2%80%93Noll%E2%80%93Vo_hash_function) algorithm |
|
|
726
|
+
| register | `(configuration: Container) => Container` | Registers a container in storage (overrides if existent) |
|
|
727
|
+
| provide | `(configuration: Container) => Container` | Finds or registers a container in storage |
|
|
728
|
+
|
|
729
|
+
As a temporary storage it has a job to garbage an expired containers. Use `containers.garbageInterval` to setup an interval of clearance in [configuration](#configuration)
|
|
730
|
+
|
|
731
|
+
> **!NOTE** See example of usage in [containers](#containers) section below
|
|
732
|
+
|
|
733
|
+
## Containers
|
|
734
|
+
|
|
735
|
+
| Property | Type | Description |
|
|
736
|
+
|--|--|--|
|
|
737
|
+
| key | `string` | A key of container |
|
|
738
|
+
| prefix | `string` | A prefix of container |
|
|
739
|
+
| payload | `object` | An object with custom data |
|
|
740
|
+
| ttl | `number` | Time to live of container in seconds **(default: 1h)** |
|
|
741
|
+
| expiresAt | `number` | An expiration date/time as unix timestamp with milliseconds |
|
|
742
|
+
| bind | `(key: string ∣ object) => Container` | Binds a container to one more key. Every `key` provided as `object` will hashed using [FNV1A-64](https://en.wikipedia.org/wiki/Fowler%E2%80%93Noll%E2%80%93Vo_hash_function) algorithm |
|
|
743
|
+
| unbind | `(key: string ∣ object) => Container` | Unbinds a container from key. Every `key` provided as `object` will hashed using [FNV1A-64](https://en.wikipedia.org/wiki/Fowler%E2%80%93Noll%E2%80%93Vo_hash_function) algorithm |
|
|
744
|
+
| assign | `(payload: object ∣ (payload: object) => object) => Container` | Uses as payload predicate to assign payload values to existent |
|
|
745
|
+
| merge | `(payload: object ∣ (payload: object) => object) => Container` | Uses as payload predicate to deep merge of payload values with existent |
|
|
746
|
+
|
|
747
|
+
|
|
748
|
+
**Example**
|
|
749
|
+
|
|
750
|
+
```ts
|
|
751
|
+
await client.createExpectation<{
|
|
752
|
+
container: {
|
|
753
|
+
counter: number;
|
|
754
|
+
};
|
|
755
|
+
}>(({ $ }) => ({
|
|
756
|
+
schema: {
|
|
757
|
+
request: $.set('container', {
|
|
758
|
+
$exec: (container, { context }) => context.storage
|
|
759
|
+
.provide({ key: 'foo', payload: { counter: 0 } })
|
|
760
|
+
.assign((payload) => ({ counter: payload.counter + 1 }))
|
|
761
|
+
}),
|
|
762
|
+
|
|
763
|
+
response: $.set('outgoing.data', {
|
|
764
|
+
$exec: (payload, { context }) => ({
|
|
765
|
+
count: context.container!.payload.counter,
|
|
766
|
+
}),
|
|
767
|
+
}),
|
|
768
|
+
},
|
|
769
|
+
}));
|
|
770
|
+
```
|
|
771
|
+
|
|
772
|
+
## Cache
|
|
773
|
+
|
|
774
|
+
> **!NOTE** Cache is usable **only** to store a payload of forwarded requests
|
|
775
|
+
|
|
776
|
+
To work with cache the mock server uses [ioredis](https://www.npmjs.com/package/ioredis) package. To configure it use `cache` in [configuration](#configuration)
|
|
777
|
+
|
|
778
|
+
**How it works in steps?**
|
|
779
|
+
|
|
780
|
+
0. [Expectation schema](#schema) should have `forward` configuration specified
|
|
781
|
+
1. Preparing incoming request...
|
|
782
|
+
2. Preparing [request schema](#schema) in expectation...
|
|
783
|
+
3. Setting up cache configuration from [context](#context) or [forward.cache](#forwarding)...
|
|
784
|
+
4. If `cache.isEnabled` is equals `true` the mock server checks a cache using provided configuration
|
|
785
|
+
5. If `key` was not provided a key for cache will calculated with `path`, `method`, `body` and `query` property values using [FNV1A-64](https://en.wikipedia.org/wiki/Fowler%E2%80%93Noll%E2%80%93Vo_hash_function) algorithm
|
|
786
|
+
6. If cache was found then step `7` is skipping
|
|
787
|
+
7. Forwarding a request....
|
|
788
|
+
8. Preparing [response schema](#schema) in expectation...
|
|
789
|
+
9. Setting up cache configuration from [context](#context)...
|
|
790
|
+
10. If `cache.isEnabled` is equals `true` the mock server will write a cache over provided `ttl`
|
|
791
|
+
11. Replying...
|
|
792
|
+
|
|
793
|
+
**Example**
|
|
794
|
+
|
|
795
|
+
```ts
|
|
796
|
+
await client.createExpectation(({ $ }) => ({
|
|
797
|
+
schema: {
|
|
798
|
+
response: $.set('cache', '$path', 'isEnabled', {
|
|
799
|
+
$exec: (payload, { context }) => context.outgoing.status < 400,
|
|
800
|
+
}),
|
|
801
|
+
|
|
802
|
+
forward: {
|
|
803
|
+
baseUrl: 'https://example.com',
|
|
804
|
+
|
|
805
|
+
cache: {
|
|
806
|
+
ttl: 30 * 24 * 60 * 60,
|
|
807
|
+
},
|
|
808
|
+
},
|
|
809
|
+
},
|
|
810
|
+
}));
|
|
811
|
+
```
|
|
812
|
+
|
|
694
813
|
## State
|
|
695
814
|
|
|
696
815
|
State is a unique storage of each request. It can be used to handle complex expectations
|
|
@@ -1031,6 +1150,8 @@ config.merge({
|
|
|
1031
1150
|
level: 'D', // Logger level (default: D)
|
|
1032
1151
|
},
|
|
1033
1152
|
|
|
1153
|
+
redis: <ioredis.RedisOptions>{...} // IO Redis configuration
|
|
1154
|
+
|
|
1034
1155
|
gui: {
|
|
1035
1156
|
title: 'My app', // Title for a GUI application page (default: Mock server)
|
|
1036
1157
|
},
|
|
@@ -1038,6 +1159,10 @@ config.merge({
|
|
|
1038
1159
|
history: {
|
|
1039
1160
|
limit: 100, // Limit for history of requests (default: 100)
|
|
1040
1161
|
},
|
|
1162
|
+
|
|
1163
|
+
containers: {
|
|
1164
|
+
garbageInterval: 60 * 60, // Containers clearance interval in seconds (default: 1h)
|
|
1165
|
+
},
|
|
1041
1166
|
});
|
|
1042
1167
|
```
|
|
1043
1168
|
|
|
@@ -1122,12 +1247,28 @@ await server.client.createExpectation({
|
|
|
1122
1247
|
|
|
1123
1248
|
| Plugin | Description |
|
|
1124
1249
|
|--|--|
|
|
1125
|
-
| `incoming.body` | Describes how to handle incoming body |
|
|
1126
|
-
| `outgoing.response` | Describes how to reply |
|
|
1127
|
-
| `forward.request` | Describes how provide an [axios](https://www.npmjs.com/package/axios) request config to forward a request |
|
|
1128
|
-
| `forward.response` | Describes how to parse [axios](https://www.npmjs.com/package/axios) response of a forwarded request |
|
|
1250
|
+
| [`incoming.body`](#incomingbody) | Describes how to handle incoming body |
|
|
1251
|
+
| [`outgoing.response`](#outgoingresponse) | Describes how to reply |
|
|
1252
|
+
| [`forward.request`](#forwardrequest) | Describes how provide an [axios](https://www.npmjs.com/package/axios) request config to forward a request |
|
|
1253
|
+
| [`forward.response`](#forwardresponse) | Describes how to parse [axios](https://www.npmjs.com/package/axios) response of a forwarded request |
|
|
1254
|
+
|
|
1255
|
+
### incoming.body
|
|
1256
|
+
|
|
1257
|
+
`INPUT`
|
|
1258
|
+
|
|
1259
|
+
| Argument | Type | Description |
|
|
1260
|
+
|--|--|--|
|
|
1261
|
+
| request | `http.IncomingMessage` | Raw HTTP request |
|
|
1262
|
+
|
|
1263
|
+
`OUTPUT`
|
|
1264
|
+
|
|
1265
|
+
| Property | Type | Optional | Description |
|
|
1266
|
+
|--|--|--|--|
|
|
1267
|
+
| raw | `string` | | Serialized incoming request body |
|
|
1268
|
+
| type | `xml ∣ json ∣ plain` | * | A type of `payload` |
|
|
1269
|
+
| payload | `object` | * | A payload object |
|
|
1129
1270
|
|
|
1130
|
-
**Example
|
|
1271
|
+
**Example**
|
|
1131
1272
|
|
|
1132
1273
|
```ts
|
|
1133
1274
|
server.context.plugins.register('incoming.body', async (request) => {
|
|
@@ -1140,7 +1281,22 @@ server.context.plugins.register('incoming.body', async (request) => {
|
|
|
1140
1281
|
});
|
|
1141
1282
|
```
|
|
1142
1283
|
|
|
1143
|
-
|
|
1284
|
+
### outgoing.response
|
|
1285
|
+
|
|
1286
|
+
`INPUT`
|
|
1287
|
+
|
|
1288
|
+
| Argument | Type | Description |
|
|
1289
|
+
|--|--|--|
|
|
1290
|
+
| response | `http.ServerResponse` | Raw HTTP response |
|
|
1291
|
+
| context | `object` | A request [context](#context) |
|
|
1292
|
+
|
|
1293
|
+
`OUTPUT`
|
|
1294
|
+
|
|
1295
|
+
| Type | Description |
|
|
1296
|
+
|--|--|
|
|
1297
|
+
| `unknown` | Result is not handing |
|
|
1298
|
+
|
|
1299
|
+
**Example**
|
|
1144
1300
|
|
|
1145
1301
|
```ts
|
|
1146
1302
|
server.context.plugins.register('outgoing.response', (response, context) => {
|
|
@@ -1150,7 +1306,22 @@ server.context.plugins.register('outgoing.response', (response, context) => {
|
|
|
1150
1306
|
});
|
|
1151
1307
|
```
|
|
1152
1308
|
|
|
1153
|
-
|
|
1309
|
+
### forward.request
|
|
1310
|
+
|
|
1311
|
+
`INPUT`
|
|
1312
|
+
|
|
1313
|
+
| Argument | Type | Description |
|
|
1314
|
+
|--|--|--|
|
|
1315
|
+
| config | `AxiosRequestConfig` | An [axios](https://www.npmjs.com/package/axios) request config |
|
|
1316
|
+
| context | `object` | A request [context](#context) |
|
|
1317
|
+
|
|
1318
|
+
`OUTPUT`
|
|
1319
|
+
|
|
1320
|
+
| Type | Description |
|
|
1321
|
+
|--|--|
|
|
1322
|
+
| `AxiosRequestConfig` | An [axios](https://www.npmjs.com/package/axios) request config |
|
|
1323
|
+
|
|
1324
|
+
**Example**
|
|
1154
1325
|
|
|
1155
1326
|
```ts
|
|
1156
1327
|
server.context.plugins.register('forward.request', (config) => ({
|
|
@@ -1159,7 +1330,24 @@ server.context.plugins.register('forward.request', (config) => ({
|
|
|
1159
1330
|
}));
|
|
1160
1331
|
```
|
|
1161
1332
|
|
|
1162
|
-
|
|
1333
|
+
### forward.response
|
|
1334
|
+
|
|
1335
|
+
`INPUT`
|
|
1336
|
+
|
|
1337
|
+
| Argument | Type | Description |
|
|
1338
|
+
|--|--|--|
|
|
1339
|
+
| config | `AxiosResponse` | An [axios](https://www.npmjs.com/package/axios) response |
|
|
1340
|
+
| context | `object` | A request [context](#context) |
|
|
1341
|
+
|
|
1342
|
+
`OUTPUT`
|
|
1343
|
+
|
|
1344
|
+
| Property | Type | Optional | Description |
|
|
1345
|
+
|--|--|--|--|
|
|
1346
|
+
| raw | `string` | | Serialized incoming request body |
|
|
1347
|
+
| type | `xml ∣ json ∣ plain` | * | A type of `payload` |
|
|
1348
|
+
| payload | `object` | * | A payload object |
|
|
1349
|
+
|
|
1350
|
+
**Example**
|
|
1163
1351
|
|
|
1164
1352
|
```ts
|
|
1165
1353
|
server.context.plugins.register('forward.response', async (response: AxiosResponse<Buffer>) => ({
|
package/lib/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@n1k1t/mock-server",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.10",
|
|
4
4
|
"description": "Powerful util to setup mocks over HTTP APIs",
|
|
5
5
|
"main": "lib/src/index.js",
|
|
6
6
|
"types": "lib/src/index.d.ts",
|
|
@@ -45,6 +45,7 @@
|
|
|
45
45
|
"@types/lodash": "4.14.184",
|
|
46
46
|
"@types/minimatch": "5.1.2",
|
|
47
47
|
"@types/node": "18.7.8",
|
|
48
|
+
"@types/node-gzip": "1.1.3",
|
|
48
49
|
"@types/uuid": "8.3.4",
|
|
49
50
|
"babelify": "10.0.0",
|
|
50
51
|
"dotenv": "16.0.3",
|
|
@@ -67,9 +68,11 @@
|
|
|
67
68
|
"fast-xml-parser": "4.5.0",
|
|
68
69
|
"http-proxy": "1.18.1",
|
|
69
70
|
"https-proxy-agent": "5.0.1",
|
|
71
|
+
"ioredis": "5.4.1",
|
|
70
72
|
"jsonpath-plus": "7.2.0",
|
|
71
73
|
"lodash": "4.17.21",
|
|
72
74
|
"minimatch": "5.1.0",
|
|
75
|
+
"node-gzip": "1.1.2",
|
|
73
76
|
"random-animal-name": "0.1.1",
|
|
74
77
|
"reflect-metadata": "0.2.1",
|
|
75
78
|
"rfdc": "1.3.0",
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import type { ExtractExpectationContextValue, IExpectationOperatorContext, TExpectationOperatorLocation, TExpectationOperatorObjectLocation } from '../../expectations';
|
|
1
|
+
import type { TFunction } from '../../types';
|
|
2
|
+
import type { ExtractExpectationContextValue, IExpectationOperatorContext, IExpectationOperatorContextInput, TExpectationOperatorLocation, TExpectationOperatorObjectLocation } from '../../expectations';
|
|
3
3
|
import type AndExpectationOperator from '../../expectations/operators/and.operator';
|
|
4
4
|
import type ExecExpectationOperator from '../../expectations/operators/exec.operator';
|
|
5
5
|
import type HasExpectationOperator from '../../expectations/operators/has.operator';
|
|
@@ -10,70 +10,70 @@ import type OrExpectationOperator from '../../expectations/operators/or.operator
|
|
|
10
10
|
import type RemoveExpectationOperator from '../../expectations/operators/remove.operator';
|
|
11
11
|
import type SetExpectationOperator from '../../expectations/operators/set.operator';
|
|
12
12
|
import type SwitchExpectationOperator from '../../expectations/operators/switch.operator';
|
|
13
|
-
export interface ICompiledExpectationOperators<
|
|
14
|
-
not<S extends NotExpectationOperator<
|
|
13
|
+
export interface ICompiledExpectationOperators<TInput extends IExpectationOperatorContextInput, TContext extends IExpectationOperatorContext<TInput> = IExpectationOperatorContext<TInput>> {
|
|
14
|
+
not<S extends NotExpectationOperator<TContext, TExpectationOperatorLocation, any>['TSchema']>(command: S): {
|
|
15
15
|
$not: S;
|
|
16
16
|
};
|
|
17
|
-
and<S extends AndExpectationOperator<
|
|
17
|
+
and<S extends AndExpectationOperator<TContext, TExpectationOperatorLocation, any>['TSchema']>(command: S): {
|
|
18
18
|
$and: S;
|
|
19
19
|
};
|
|
20
|
-
or<S extends OrExpectationOperator<
|
|
20
|
+
or<S extends OrExpectationOperator<TContext, TExpectationOperatorLocation, any>['TSchema']>(command: S): {
|
|
21
21
|
$or: S;
|
|
22
22
|
};
|
|
23
|
-
exec<S extends ExecExpectationOperator<
|
|
23
|
+
exec<S extends ExecExpectationOperator<TContext>['TSchema']>(command: S): {
|
|
24
24
|
$exec: S;
|
|
25
25
|
};
|
|
26
|
-
if<S extends IfExpectationOperator<
|
|
26
|
+
if<S extends IfExpectationOperator<TContext, TExpectationOperatorLocation, any>['TSchema']>(command: S): {
|
|
27
27
|
$if: S;
|
|
28
28
|
};
|
|
29
|
-
switch<K extends TExpectationOperatorLocation, S extends SwitchExpectationOperator<
|
|
29
|
+
switch<K extends TExpectationOperatorLocation, S extends SwitchExpectationOperator<TContext, TExpectationOperatorLocation, void, TExpectationOperatorLocation, any>['TSchema']>(location: K, command: Omit<S, '$location'>): {
|
|
30
30
|
$switch: S & {
|
|
31
31
|
$location: K;
|
|
32
32
|
};
|
|
33
33
|
};
|
|
34
|
-
switch<K extends TExpectationOperatorLocation, U extends '$path' | '$exec', Q extends U extends '$exec' ? NonNullable<SwitchExpectationOperator<
|
|
34
|
+
switch<K extends TExpectationOperatorLocation, U extends '$path' | '$exec', Q extends U extends '$exec' ? NonNullable<SwitchExpectationOperator<TContext, K>['TSchema']['$exec']> : string, V extends Q extends TFunction<infer R, any[]> ? NonNullable<R> extends (string | number) ? NonNullable<R> : void : Q extends string ? ExtractExpectationContextValue<TContext, K, Q> : void, S extends SwitchExpectationOperator<TContext, K, V, TExpectationOperatorLocation, any>['TSchema']>(location: K, using: U, value: Q, command: Omit<S, '$location' | '$path' | '$exec'>): {
|
|
35
35
|
$switch: S & {
|
|
36
36
|
$location: K;
|
|
37
37
|
$exec: Q;
|
|
38
38
|
};
|
|
39
39
|
};
|
|
40
|
-
has<K extends TExpectationOperatorLocation, S extends HasExpectationOperator<
|
|
40
|
+
has<K extends TExpectationOperatorLocation, S extends HasExpectationOperator<TContext, K>['TSchema']>(location: K, command: Omit<S, '$location'>): {
|
|
41
41
|
$has: S & {
|
|
42
42
|
$location: K;
|
|
43
43
|
};
|
|
44
44
|
};
|
|
45
|
-
has<K extends TExpectationOperatorLocation, U extends '$path' | '$jsonPath', Q extends string, V extends U extends '$path' ? ExtractExpectationContextValue<
|
|
45
|
+
has<K extends TExpectationOperatorLocation, U extends '$path' | '$jsonPath', Q extends string, V extends U extends '$path' ? ExtractExpectationContextValue<TContext, K, Q> : unknown, S extends HasExpectationOperator<TContext, K, V>['TSchema']>(location: K, using: U, value: Q, command?: Omit<S, '$location' | '$path' | '$jsonPath'>): {
|
|
46
46
|
$has: S & {
|
|
47
47
|
$location: any;
|
|
48
48
|
$path?: string;
|
|
49
49
|
$jsonPath?: string;
|
|
50
50
|
};
|
|
51
51
|
};
|
|
52
|
-
set<K extends TExpectationOperatorLocation, S extends SetExpectationOperator<
|
|
52
|
+
set<K extends TExpectationOperatorLocation, S extends SetExpectationOperator<TContext, K>['TSchema']>(location: K, command: Omit<S, '$location'>): {
|
|
53
53
|
$set: S & {
|
|
54
54
|
$location: K;
|
|
55
55
|
};
|
|
56
56
|
};
|
|
57
|
-
set<K extends TExpectationOperatorLocation, U extends '$path' | '$jsonPath', Q extends string, V extends U extends '$path' ? ExtractExpectationContextValue<
|
|
57
|
+
set<K extends TExpectationOperatorLocation, U extends '$path' | '$jsonPath', Q extends string, V extends U extends '$path' ? ExtractExpectationContextValue<TContext, K, Q> : unknown, S extends SetExpectationOperator<TContext, K, V>['TSchema']>(location: K, using: U, value: Q, command: Omit<S, '$location' | '$path' | '$jsonPath'>): {
|
|
58
58
|
$set: S & {
|
|
59
59
|
$location: K;
|
|
60
60
|
$path?: string;
|
|
61
61
|
$jsonPath?: string;
|
|
62
62
|
};
|
|
63
63
|
};
|
|
64
|
-
merge<K extends TExpectationOperatorObjectLocation, S extends MergeExpectationOperator<
|
|
64
|
+
merge<K extends TExpectationOperatorObjectLocation, S extends MergeExpectationOperator<TContext, K>['TSchema']>(location: K, command: Omit<S, '$location'>): {
|
|
65
65
|
$merge: S & {
|
|
66
66
|
$location: K;
|
|
67
67
|
};
|
|
68
68
|
};
|
|
69
|
-
merge<K extends TExpectationOperatorObjectLocation, U extends '$path' | '$jsonPath', Q extends string, V extends U extends '$path' ? ExtractExpectationContextValue<
|
|
69
|
+
merge<K extends TExpectationOperatorObjectLocation, U extends '$path' | '$jsonPath', Q extends string, V extends U extends '$path' ? ExtractExpectationContextValue<TContext, K, Q> : unknown, S extends MergeExpectationOperator<TContext, K, V>['TSchema']>(location: K, using: U, value: Q, command: Omit<S, '$location' | '$path' | '$jsonPath'>): {
|
|
70
70
|
$merge: S & {
|
|
71
71
|
$location: K;
|
|
72
72
|
$path?: string;
|
|
73
73
|
$jsonPath?: string;
|
|
74
74
|
};
|
|
75
75
|
};
|
|
76
|
-
remove<K extends TExpectationOperatorLocation, S extends RemoveExpectationOperator<
|
|
76
|
+
remove<K extends TExpectationOperatorLocation, S extends RemoveExpectationOperator<TContext, K>['TSchema']>(location: K, command: Omit<S, '$location'>): {
|
|
77
77
|
$remove: S & {
|
|
78
78
|
$location: K;
|
|
79
79
|
};
|
|
@@ -86,5 +86,5 @@ export interface ICompiledExpectationOperators<T extends PartialDeep<IExpectatio
|
|
|
86
86
|
};
|
|
87
87
|
};
|
|
88
88
|
}
|
|
89
|
-
export declare const compileExpectationOperators: <
|
|
89
|
+
export declare const compileExpectationOperators: <TInput extends IExpectationOperatorContextInput, TContext extends IExpectationOperatorContext<TInput> = IExpectationOperatorContext<TInput>>() => ICompiledExpectationOperators<TContext, IExpectationOperatorContext<TContext>>;
|
|
90
90
|
//# sourceMappingURL=expectations.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"expectations.d.ts","sourceRoot":"","sources":["../../../../src/client/helpers/expectations.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"expectations.d.ts","sourceRoot":"","sources":["../../../../src/client/helpers/expectations.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAC7C,OAAO,KAAK,EACV,8BAA8B,EAC9B,2BAA2B,EAC3B,gCAAgC,EAChC,4BAA4B,EAC5B,kCAAkC,EACnC,MAAM,oBAAoB,CAAC;AAE5B,OAAO,KAAK,sBAAsB,MAAM,2CAA2C,CAAC;AACpF,OAAO,KAAK,uBAAuB,MAAM,4CAA4C,CAAC;AACtF,OAAO,KAAK,sBAAsB,MAAM,2CAA2C,CAAC;AACpF,OAAO,KAAK,qBAAqB,MAAM,0CAA0C,CAAC;AAClF,OAAO,KAAK,wBAAwB,MAAM,6CAA6C,CAAC;AACxF,OAAO,KAAK,sBAAsB,MAAM,2CAA2C,CAAC;AACpF,OAAO,KAAK,qBAAqB,MAAM,0CAA0C,CAAC;AAClF,OAAO,KAAK,yBAAyB,MAAM,8CAA8C,CAAC;AAC1F,OAAO,KAAK,sBAAsB,MAAM,2CAA2C,CAAC;AACpF,OAAO,KAAK,yBAAyB,MAAM,8CAA8C,CAAC;AAE1F,MAAM,WAAW,6BAA6B,CAC5C,MAAM,SAAS,gCAAgC,EAC/C,QAAQ,SAAS,2BAA2B,CAAC,MAAM,CAAC,GAAG,2BAA2B,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E,IAAI,CAAC,CAAC,EAAE,WAAW,CAAC,GAAG;QAC7C,OAAO,EAAE,CAAC,GAAG;YAAE,SAAS,EAAE,CAAC,CAAA;SAAE,CAAC;KAC/B,CAAC;IAEF,MAAM,CACJ,CAAC,SAAS,4BAA4B,EACtC,CAAC,SAAS,OAAO,GAAG,WAAW,EAC/B,QAAQ,EAAE,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,KAAK,EAAE,MAAM,GAAG;QACvC,OAAO,EAAE;YAAE,SAAS,EAAE,CAAC,CAAC;YAAC,KAAK,CAAC,EAAE,MAAM,CAAC;YAAC,SAAS,CAAC,EAAE,MAAM,CAAA;SAAE,CAAA;KAC9D,CAAC;CACH;AAED,eAAO,MAAM,2BAA2B,GACtC,MAAM,SAAS,gCAAgC,EAC/C,QAAQ,SAAS,2BAA2B,CAAC,MAAM,CAAC,2HAsGT,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"expectations.js","sourceRoot":"","sources":["../../../../src/client/helpers/expectations.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"expectations.js","sourceRoot":"","sources":["../../../../src/client/helpers/expectations.ts"],"names":[],"mappings":";;;AA0HO,MAAM,2BAA2B,GAAG,GAGvC,EAAE,CAAC,CAAC;IACN,GAAG,EAAE,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;IACrC,GAAG,EAAE,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;IACrC,EAAE,EAAE,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC,EAAE,GAAG,EAAE,OAAO,EAAE,CAAC;IAEnC,IAAI,EAAE,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC,EAAE,KAAK,EAAE,OAAO,EAAE,CAAC;IACvC,EAAE,EAAE,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC,EAAE,GAAG,EAA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EAAE,KAAK,EAAE,CAAC;gBAC9C,GAAG,CAAC,SAAS,KAAK,WAAW,IAAI,EAAE,SAAS,EAAE,KAAK,EAAE,CAAC;aACvD,CAAC;YAEF,GAAG,CAAC,OAAO,IAAI,EAAE,CAAC;SACnB;KACF,CAAC;IAEF,KAAK,EAAE,CACL,SAAY,EACZ,SAAyC,EACzC,KAAe,EACf,OAAgB,EAChB,EAAE,CAAC,CAAC;QACJ,MAAM,EAAE;YACN,SAAS;YAET,GAAG,CAAC,OAAO,SAAS,KAAK,QAAQ,IAAI,SAAS,CAAC;YAC/C,GAAG,CAAC,OAAO,SAAS,KAAK,QAAQ,IAAI;gBACnC,GAAG,CAAC,SAAS,KAAK,OAAO,IAAI,EAAE,KAAK,EAAE,KAAK,EAAE,CAAC;gBAC9C,GAAG,CAAC,SAAS,KAAK,WAAW,IAAI,EAAE,SAAS,EAAE,KAAK,EAAE,CAAC;aACvD,CAAC;YAEF,GAAG,CAAC,OAAO,IAAI,EAAE,CAAC;SACnB;KACF,CAAC;IAEF,MAAM,EAAE,CACN,SAAY,EACZ,SAAyC,EACzC,KAAe,EACf,EAAE,CAAC,CAAC;QACJ,OAAO,EAAE;YACP,SAAS;YAET,GAAG,CAAC,OAAO,SAAS,KAAK,QAAQ,IAAI,SAAS,CAAC;YAC/C,GAAG,CAAC,OAAO,SAAS,KAAK,QAAQ,IAAI;gBACnC,GAAG,CAAC,SAAS,KAAK,OAAO,IAAI,EAAE,KAAK,EAAE,KAAK,EAAE,CAAC;gBAC9C,GAAG,CAAC,SAAS,KAAK,WAAW,IAAI,EAAE,SAAS,EAAE,KAAK,EAAE,CAAC;aACvD,CAAC;SACH;KACF,CAAC;CAGyC,CAAA,CAAC;AAxGjC,QAAA,2BAA2B,+BAwGM"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { ClientMethod } from '../models';
|
|
2
|
-
declare const _default: ClientMethod<Pick<import("../../expectations").Expectation<{}
|
|
2
|
+
declare const _default: ClientMethod<Pick<import("../../expectations").Expectation<{}, import("../../expectations").IExpectationOperatorContext<{}>>, "name" | "type" | "schema" | "isEnabled" | "id" | "meta">, import("../../expectations").TBuildExpectationConfiguration<any>>;
|
|
3
3
|
export default _default;
|
|
4
4
|
//# sourceMappingURL=expectations.create.method.d.ts.map
|
|
@@ -19,11 +19,11 @@ exports.default = models_1.ClientMethod
|
|
|
19
19
|
return response.data.data;
|
|
20
20
|
})
|
|
21
21
|
.provide('onsite', (context) => async (body) => {
|
|
22
|
-
const result = context.
|
|
22
|
+
const result = context.storages.expectations.register(body);
|
|
23
23
|
if (result.status === 'ERROR') {
|
|
24
24
|
throw new errors_1.ValidationError({}, result.reasons);
|
|
25
25
|
}
|
|
26
|
-
context.
|
|
26
|
+
context.exchanges.ws.publish('expectation:added', result.expectation.toPlain());
|
|
27
27
|
return result.expectation.toPlain();
|
|
28
28
|
});
|
|
29
29
|
//# sourceMappingURL=expectations.create.method.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"expectations.create.method.js","sourceRoot":"","sources":["../../../../src/client/methods/expectations.create.method.ts"],"names":[],"mappings":";;AAAA,oCAA+E;AAC/E,sCAA4C;AAC5C,sCAAyC;AAEzC,uCAAmC;AAEnC,kBAAe,qBAAY;KACxB,KAAK,EAAsF;KAC3F,OAAO,CAAC,QAAQ,EAAE,CAAC,QAAQ,EAAE,EAAE,CAAC,KAAK,EAAE,IAAI,EAAE,EAAE;IAC9C,MAAM,QAAQ,GAAG,MAAM,QAAQ;SAC5B,OAAO,CAA8C;QACpD,IAAI,EAAE,IAAA,uCAA+B,EAAC,IAAI,CAAC;QAE3C,GAAG,IAAA,YAAI,EAA8C;YACnD,GAAG,EAAE,qBAAqB;YAC1B,MAAM,EAAE,MAAM;SACf,CAAC;KACH,CAAC;SACD,KAAK,CAAC,0BAAkB,CAAC,CAAC;IAE7B,OAAO,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC;AAC5B,CAAC,CAAC;KACD,OAAO,CAA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AC,CAAC,CAAC"}
|
|
@@ -19,8 +19,8 @@ exports.default = models_1.ClientMethod
|
|
|
19
19
|
})
|
|
20
20
|
.provide('onsite', (context) => async (body) => {
|
|
21
21
|
body?.ids
|
|
22
|
-
? body.ids.forEach((id) => context.
|
|
23
|
-
: context.
|
|
22
|
+
? body.ids.forEach((id) => context.storages.expectations.delete(id))
|
|
23
|
+
: context.storages.expectations.clear();
|
|
24
24
|
return null;
|
|
25
25
|
});
|
|
26
26
|
//# sourceMappingURL=expectations.delete.method.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"expectations.delete.method.js","sourceRoot":"","sources":["../../../../src/client/methods/expectations.delete.method.ts"],"names":[],"mappings":";;AAAA,oCAA8C;AAC9C,sCAAyC;AAEzC,uCAAmC;AAEnC,kBAAe,qBAAY;KACxB,KAAK,EAAsF;KAC3F,OAAO,CAAC,QAAQ,EAAE,CAAC,QAAQ,EAAE,EAAE,CAAC,KAAK,EAAE,IAAI,EAAE,EAAE;IAC9C,MAAM,QAAQ;SACX,OAAO,CAA8C;QACpD,IAAI,EAAE,IAAI;QAEV,GAAG,IAAA,YAAI,EAA8C;YACnD,GAAG,EAAE,qBAAqB;YAC1B,MAAM,EAAE,QAAQ;SACjB,CAAC;KACH,CAAC;SACD,KAAK,CAAC,0BAAkB,CAAC,CAAC;IAE7B,OAAO,IAAI,CAAC;AACd,CAAC,CAAC;KACD,OAAO,CAAC,QAAQ,EAAE,CAAC,OAAO,EAAE,EAAE,CAAC,KAAK,EAAE,IAAI,EAAE,EAAE;IAC7C,IAAI,EAAE,GAAG;QACP,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,OAAO,CAAC,
|
|
1
|
+
{"version":3,"file":"expectations.delete.method.js","sourceRoot":"","sources":["../../../../src/client/methods/expectations.delete.method.ts"],"names":[],"mappings":";;AAAA,oCAA8C;AAC9C,sCAAyC;AAEzC,uCAAmC;AAEnC,kBAAe,qBAAY;KACxB,KAAK,EAAsF;KAC3F,OAAO,CAAC,QAAQ,EAAE,CAAC,QAAQ,EAAE,EAAE,CAAC,KAAK,EAAE,IAAI,EAAE,EAAE;IAC9C,MAAM,QAAQ;SACX,OAAO,CAA8C;QACpD,IAAI,EAAE,IAAI;QAEV,GAAG,IAAA,YAAI,EAA8C;YACnD,GAAG,EAAE,qBAAqB;YAC1B,MAAM,EAAE,QAAQ;SACjB,CAAC;KACH,CAAC;SACD,KAAK,CAAC,0BAAkB,CAAC,CAAC;IAE7B,OAAO,IAAI,CAAC;AACd,CAAC,CAAC;KACD,OAAO,CAAC,QAAQ,EAAE,CAAC,OAAO,EAAE,EAAE,CAAC,KAAK,EAAE,IAAI,EAAE,EAAE;IAC7C,IAAI,EAAE,GAAG;QACP,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,OAAO,CAAC,QAAQ,CAAC,YAAY,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC;QACpE,CAAC,CAAC,OAAO,CAAC,QAAQ,CAAC,YAAY,CAAC,KAAK,EAAE,CAAC;IAE1C,OAAO,IAAI,CAAC;AACd,CAAC,CAAC,CAAC"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ClientMethod } from '../models';
|
|
2
2
|
import { Expectation } from '../../expectations';
|
|
3
|
-
declare const _default: ClientMethod<Pick<Expectation<{}
|
|
3
|
+
declare const _default: ClientMethod<Pick<Expectation<{}, import("../../expectations").IExpectationOperatorContext<{}>>, "name" | "type" | "schema" | "isEnabled" | "id" | "meta"> | null, {
|
|
4
4
|
id: string;
|
|
5
5
|
set: Partial<Omit<import("../../expectations").TBuildExpectationConfiguration<any>, "type">>;
|
|
6
6
|
}>;
|
|
@@ -28,17 +28,17 @@ exports.default = models_1.ClientMethod
|
|
|
28
28
|
return response.data.data;
|
|
29
29
|
})
|
|
30
30
|
.provide('onsite', (context) => async (body) => {
|
|
31
|
-
const found = context.
|
|
31
|
+
const found = context.storages.expectations.get(body.id);
|
|
32
32
|
if (!found) {
|
|
33
33
|
return null;
|
|
34
34
|
}
|
|
35
|
-
const updated = expectations_1.Expectation.build((0, deepmerge_1.default)(found.toPlain(), body.set ?? {}));
|
|
35
|
+
const updated = expectations_1.Expectation.build((0, deepmerge_1.default)(found.toPlain(), body.set ?? {}, { arrayMerge: (target, source) => source }));
|
|
36
36
|
const errors = updated.validate();
|
|
37
37
|
if (errors.length) {
|
|
38
38
|
throw new errors_1.ValidationError({}, errors);
|
|
39
39
|
}
|
|
40
|
-
context.
|
|
41
|
-
context.
|
|
40
|
+
context.storages.expectations.set(body.id, updated);
|
|
41
|
+
context.exchanges.ws.publish('expectation:updated', updated.toPlain());
|
|
42
42
|
return updated.toPlain();
|
|
43
43
|
});
|
|
44
44
|
//# sourceMappingURL=expectations.update.method.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"expectations.update.method.js","sourceRoot":"","sources":["../../../../src/client/methods/expectations.update.method.ts"],"names":[],"mappings":";;;;;AAAA,0DAA8B;AAE9B,oCAA2D;AAC3D,oCAA8C;AAC9C,sCAA4C;AAC5C,sCAAyC;AACzC,qDAAiD;AAEjD,uCAAmC;AAEnC,kBAAe,qBAAY;KACxB,KAAK,EAA6F;KAClG,OAAO,CAAC,QAAQ,EAAE,CAAC,QAAQ,EAAE,EAAE,CAAC,KAAK,EAAE,IAAI,EAAE,EAAE;IAC9C,MAAM,QAAQ,GAAG,MAAM,QAAQ;SAC5B,OAAO,CAA8C;QACpD,IAAI,EAAE;YACJ,EAAE,EAAE,IAAI,CAAC,EAAE;YACX,IAAI,EAAE,IAAA,uCAA+B,EAAC,IAAI,CAAC,GAAG,CAAC;SAChD;QAED,GAAG,IAAA,YAAI,EAA8C;YACnD,GAAG,EAAE,qBAAqB;YAC1B,MAAM,EAAE,KAAK;SACd,CAAC;KACH,CAAC;SACD,KAAK,CAAC,0BAAkB,CAAC,CAAC;IAE7B,OAAO,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC;AAC5B,CAAC,CAAC;KACD,OAAO,CAAC,QAAQ,EAAE,CAAC,OAAO,EAAE,EAAE,CAAC,KAAK,EAAE,IAAI,EAAE,EAAE;IAC7C,MAAM,KAAK,GAAG,OAAO,CAAC,
|
|
1
|
+
{"version":3,"file":"expectations.update.method.js","sourceRoot":"","sources":["../../../../src/client/methods/expectations.update.method.ts"],"names":[],"mappings":";;;;;AAAA,0DAA8B;AAE9B,oCAA2D;AAC3D,oCAA8C;AAC9C,sCAA4C;AAC5C,sCAAyC;AACzC,qDAAiD;AAEjD,uCAAmC;AAEnC,kBAAe,qBAAY;KACxB,KAAK,EAA6F;KAClG,OAAO,CAAC,QAAQ,EAAE,CAAC,QAAQ,EAAE,EAAE,CAAC,KAAK,EAAE,IAAI,EAAE,EAAE;IAC9C,MAAM,QAAQ,GAAG,MAAM,QAAQ;SAC5B,OAAO,CAA8C;QACpD,IAAI,EAAE;YACJ,EAAE,EAAE,IAAI,CAAC,EAAE;YACX,IAAI,EAAE,IAAA,uCAA+B,EAAC,IAAI,CAAC,GAAG,CAAC;SAChD;QAED,GAAG,IAAA,YAAI,EAA8C;YACnD,GAAG,EAAE,qBAAqB;YAC1B,MAAM,EAAE,KAAK;SACd,CAAC;KACH,CAAC;SACD,KAAK,CAAC,0BAAkB,CAAC,CAAC;IAE7B,OAAO,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC;AAC5B,CAAC,CAAC;KACD,OAAO,CAAC,QAAQ,EAAE,CAAC,OAAO,EAAE,EAAE,CAAC,KAAK,EAAE,IAAI,EAAE,EAAE;IAC7C,MAAM,KAAK,GAAG,OAAO,CAAC,QAAQ,CAAC,YAAY,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;IACzD,IAAI,CAAC,KAAK,EAAE,CAAC;QACX,OAAO,IAAI,CAAC;IACd,CAAC;IAED,MAAM,OAAO,GAAG,0BAAW,CAAC,KAAK,CAAC,IAAA,mBAAK,EAAC,KAAK,CAAC,OAAO,EAAE,EAAE,IAAI,CAAC,GAAG,IAAI,EAAE,EAAE,EAAE,UAAU,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,EAAE,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC;IAEtH,MAAM,MAAM,GAAG,OAAO,CAAC,QAAQ,EAAE,CAAC;IAClC,IAAI,MAAM,CAAC,MAAM,EAAE,CAAC;QAClB,MAAM,IAAI,wBAAe,CAAC,EAAE,EAAE,MAAM,CAAC,CAAC;IACxC,CAAC;IAED,OAAO,CAAC,QAAQ,CAAC,YAAY,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,EAAE,OAAO,CAAC,CAAC;IACpD,OAAO,CAAC,SAAS,CAAC,EAAE,CAAC,OAAO,CAAC,qBAAqB,EAAE,OAAO,CAAC,OAAO,EAAE,CAAC,CAAC;IAEvE,OAAO,OAAO,CAAC,OAAO,EAAE,CAAC;AAC3B,CAAC,CAAC,CAAC"}
|
|
@@ -1,22 +1,22 @@
|
|
|
1
|
-
import type { IExpectationOperatorContext, TBuildExpectationConfiguration } from '../../expectations';
|
|
2
|
-
import type { PartialDeep, TFunction } from '../../types';
|
|
3
1
|
import type { TMethodsSchema } from '../types';
|
|
2
|
+
import type { TFunction } from '../../types';
|
|
3
|
+
import type { IExpectationOperatorContext, IExpectationOperatorContextInput, TBuildExpectationConfiguration } from '../../expectations';
|
|
4
4
|
import { ICompiledExpectationOperators } from '../helpers';
|
|
5
|
-
interface IExpectationHandlerContext<
|
|
6
|
-
$: ICompiledExpectationOperators<
|
|
5
|
+
interface IExpectationHandlerContext<TInput extends IExpectationOperatorContextInput> {
|
|
6
|
+
$: ICompiledExpectationOperators<TInput>;
|
|
7
7
|
T: <T>(payload: T) => T extends TFunction<any, any[]> ? TFunction<any, any[]> : T;
|
|
8
8
|
}
|
|
9
|
-
|
|
10
|
-
incoming:
|
|
9
|
+
type TUnknownExpectationContext = IExpectationOperatorContext<{
|
|
10
|
+
incoming: {
|
|
11
11
|
headers: any;
|
|
12
12
|
query: any;
|
|
13
13
|
body: any;
|
|
14
14
|
};
|
|
15
|
-
outgoing?:
|
|
15
|
+
outgoing?: {
|
|
16
16
|
headers: any;
|
|
17
17
|
data: any;
|
|
18
18
|
};
|
|
19
|
-
}
|
|
19
|
+
}>;
|
|
20
20
|
export declare class Client {
|
|
21
21
|
protected methods: TMethodsSchema;
|
|
22
22
|
constructor(methods: TMethodsSchema);
|
|
@@ -24,17 +24,17 @@ export declare class Client {
|
|
|
24
24
|
get deleteExpectations(): TFunction<Promise<null>, [void | {
|
|
25
25
|
ids?: string[];
|
|
26
26
|
}]>;
|
|
27
|
-
createExpectation<
|
|
28
|
-
IExpectationHandlerContext<
|
|
27
|
+
createExpectation<TInput extends IExpectationOperatorContextInput = {}>(predicate: TBuildExpectationConfiguration<TUnknownExpectationContext> | TFunction<TBuildExpectationConfiguration<any>, [
|
|
28
|
+
IExpectationHandlerContext<TInput>
|
|
29
29
|
]>): ReturnType<TMethodsSchema['createExpectation']>;
|
|
30
|
-
updateExpectation<
|
|
30
|
+
updateExpectation<TInput extends IExpectationOperatorContextInput = {}>(predicate: {
|
|
31
31
|
id: string;
|
|
32
|
-
set: Partial<Omit<TBuildExpectationConfiguration
|
|
32
|
+
set: Partial<Omit<TBuildExpectationConfiguration<TUnknownExpectationContext>, 'type'>>;
|
|
33
33
|
} | TFunction<{
|
|
34
34
|
id: string;
|
|
35
35
|
set: Partial<Omit<TBuildExpectationConfiguration<any>, 'type'>>;
|
|
36
36
|
}, [
|
|
37
|
-
IExpectationHandlerContext<
|
|
37
|
+
IExpectationHandlerContext<TInput>
|
|
38
38
|
]>): ReturnType<TMethodsSchema['updateExpectation']>;
|
|
39
39
|
}
|
|
40
40
|
export {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../../../src/client/models/client.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK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