@n1k1t/mock-server 0.1.6 → 0.1.9
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 +229 -35
- 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/client/utils.d.ts.map +1 -1
- package/lib/src/client/utils.js +3 -0
- package/lib/src/client/utils.js.map +1 -1
- package/lib/src/config/model.d.ts +4 -1
- package/lib/src/config/model.d.ts.map +1 -1
- package/lib/src/config/model.js +5 -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 +8 -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 +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 +11 -4
- package/lib/src/expectations/operators/merge.operator.d.ts.map +1 -1
- package/lib/src/expectations/operators/merge.operator.js +21 -4
- 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 +2 -0
- 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 +3 -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 +1 -0
- package/lib/src/server/index.d.ts.map +1 -1
- package/lib/src/server/index.js +10 -1
- 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 +7 -13
- package/lib/src/server/middlewares/forward.middleware.d.ts.map +1 -1
- package/lib/src/server/middlewares/forward.middleware.js +81 -27
- 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 +7 -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 +23 -28
- 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 +44 -0
- package/lib/src/server/models/containers/model.d.ts.map +1 -0
- package/lib/src/server/models/containers/model.js +43 -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 +42 -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 +25 -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 +28 -0
- package/lib/src/server/models/request-context/snapshot.d.ts.map +1 -0
- package/lib/src/server/models/request-context/snapshot.js +49 -0
- package/lib/src/server/models/request-context/snapshot.js.map +1 -0
- package/lib/src/server/models/request-context/types.d.ts +12 -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/scripts/main.js +18 -17
- package/public/styles/main.css +4 -0
- 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/README.md
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
|
|
2
|
+
|
|
2
3
|
# Mock server
|
|
3
4
|
|
|
4
5
|
Mock, match, modify and manipulate a HTTP request/response payload using flexible expectations with types
|
|
@@ -19,6 +20,9 @@ Mock, match, modify and manipulate a HTTP request/response payload using flexibl
|
|
|
19
20
|
- [Utils](#utils)
|
|
20
21
|
- [Operators](#operators)
|
|
21
22
|
- [Typings](#typings)
|
|
23
|
+
- [State](#state)
|
|
24
|
+
- [Seeds](#seeds)
|
|
25
|
+
- [XML](#xml)
|
|
22
26
|
- [API](#api)
|
|
23
27
|
- [Ping](#ping)
|
|
24
28
|
- [Create expectation](#create-expectation)
|
|
@@ -60,7 +64,7 @@ According on the picture above, main idea is to generate or modify response from
|
|
|
60
64
|
## Install
|
|
61
65
|
|
|
62
66
|
```bash
|
|
63
|
-
npm i
|
|
67
|
+
npm i @n1k1t/mock-server
|
|
64
68
|
```
|
|
65
69
|
|
|
66
70
|
## Start
|
|
@@ -93,7 +97,7 @@ By default it can be found on `/_mock/gui` of a host of mock server. Example: `l
|
|
|
93
97
|
|
|
94
98
|
Also it provides convenient util to navigate through payload of expectations and requests payload
|
|
95
99
|
|
|
96
|
-

|
|
97
101
|
|
|
98
102
|
## Mock
|
|
99
103
|
|
|
@@ -211,6 +215,8 @@ await server.client.createExpectation({
|
|
|
211
215
|
|
|
212
216
|
### $has
|
|
213
217
|
|
|
218
|
+
> **!NOTE** `$exec` operators [have restrictions](#api) when it defined over `HTTP API` or `RemoteClient`
|
|
219
|
+
|
|
214
220
|
| Property | Type (application) | Type (cURL) | Optional | Description |
|
|
215
221
|
|--|--|--|--|--|
|
|
216
222
|
| $location | `string` [enum](#context) | `string` [enum](#context) | | Location that describes what [context](#context) entity is selecting for operator to work with |
|
|
@@ -220,8 +226,8 @@ await server.client.createExpectation({
|
|
|
220
226
|
| $valueAnyOf | `any[]` | `any[]` | * | Checks by any of value equality in [context](#context) using `$location` (and `$path`, `$jsonPath` if it was specified) |
|
|
221
227
|
| $regExp | `RegExp` | `{ source: string, flags?: string }` | * | Checks by regular expression in context using `$location` (and `$path`, `$jsonPath` if it was specified) |
|
|
222
228
|
| $regExpAnyOf | `RegExp[]` | `{ source: string, flags?: string }[]` | * | Checks by any of regular expression in [context](#context) using `$location` (and `$path`, `$jsonPath` if it was specified) |
|
|
223
|
-
| $match | `string
|
|
224
|
-
| $matchAnyOf | `(string
|
|
229
|
+
| $match | `string ∣ object` | `string ∣ object` | * | Checks by minimatch for `string` and `number` (example `/foo/*/bar` or `2**`) or similar `object` by passing object payload in [context](#context) using `$location` (and `$path`, `$jsonPath` if it was specified) |
|
|
230
|
+
| $matchAnyOf | `(string ∣ object)[]` | `(string ∣ object)[]` | * | Checks by any of minimatch for `string` and `number` (example `/foo/*/bar` or `2**`) or similar `object` by passing object payload in [context](#context) using `$location` (and `$path`, `$jsonPath` if it was specified) |
|
|
225
231
|
| $exec | `(payload, utils) => boolean` | `string` | * | Checks payload in [context](#context) by function with arguments where `payload` is selected entity using `$location` (and `$path`, `$jsonPath` if it was specified) and `utils` is [utils](#utils) |
|
|
226
232
|
|
|
227
233
|
**Example using application**
|
|
@@ -258,6 +264,8 @@ EOF
|
|
|
258
264
|
|
|
259
265
|
### $set
|
|
260
266
|
|
|
267
|
+
> **!NOTE** `$exec` operators [have restrictions](#api) when it defined over `HTTP API` or `RemoteClient`
|
|
268
|
+
|
|
261
269
|
| Property | Type (application) | Type (cURL) | Optional | Description |
|
|
262
270
|
|--|--|--|--|--|
|
|
263
271
|
| $location | `string` [enum](#context) | `string` [enum](#context) | | Location that describes what [context](#context) entity is selecting for operator to work with |
|
|
@@ -302,12 +310,15 @@ EOF
|
|
|
302
310
|
|
|
303
311
|
### $merge
|
|
304
312
|
|
|
313
|
+
> **!NOTE** `$exec` operators [have restrictions](#api) when it defined over `HTTP API` or `RemoteClient`
|
|
314
|
+
|
|
305
315
|
| Property | Type (application) | Type (cURL) | Optional | Description |
|
|
306
316
|
|--|--|--|--|--|
|
|
307
317
|
| $location | `string` [enum](#context) | `string` [enum](#context) | | Location that describes what [context](#context) entity is selecting for operator to work with |
|
|
308
318
|
| $path | `string` | `string` | * | Specifies a path to payload using [lodash get](https://lodash.com/docs/4.17.15#get) |
|
|
309
319
|
| $jsonPath | `string` | `string` | * | Specifies a path to payload using [JSON path](https://www.npmjs.com/package/jsonpath-plus) |
|
|
310
|
-
| $value | `
|
|
320
|
+
| $value | `object` | `object` | * | Merges value in [context](#context) using `$location` (and `$path`, `$jsonPath` if it was specified) |
|
|
321
|
+
| $exec | `(payload, utils) => any` | `string` | * | Merges payload in [context](#context) by function with arguments where `payload` is selected entity using `$location` (and `$path`, `$jsonPath` if it was specified) and `utils` is [utils](#utils) |
|
|
311
322
|
|
|
312
323
|
**Example using application**
|
|
313
324
|
|
|
@@ -377,9 +388,11 @@ EOF
|
|
|
377
388
|
|
|
378
389
|
### $exec
|
|
379
390
|
|
|
391
|
+
> **!NOTE** `$exec` operators [have restrictions](#api) when it defined over `HTTP API` or `RemoteClient`
|
|
392
|
+
|
|
380
393
|
| Type (application) | Type (cURL) | Description |
|
|
381
|
-
|
|
382
|
-
| `(utils) => boolean
|
|
394
|
+
|--|--|--|
|
|
395
|
+
| `(utils) => boolean ∣ unknown` | `string` | Does something you want or catch request/response payload in [context](#context) by function with arguments where `utils` is [utils](#utils) |
|
|
383
396
|
|
|
384
397
|
**Example using application**
|
|
385
398
|
|
|
@@ -413,7 +426,7 @@ EOF
|
|
|
413
426
|
### $and
|
|
414
427
|
|
|
415
428
|
| Type (application) | Type (cURL) | Description |
|
|
416
|
-
|
|
429
|
+
|--|--|--|
|
|
417
430
|
| `object[]` | `object[]` | Provides [operators](#operators) schemas |
|
|
418
431
|
|
|
419
432
|
**Example using application**
|
|
@@ -423,7 +436,7 @@ await server.client.createExpectation({
|
|
|
423
436
|
schema: {
|
|
424
437
|
request: {
|
|
425
438
|
$and: [
|
|
426
|
-
|
|
439
|
+
{ $has: { $location: 'path', $match: 'foo/*' } },
|
|
427
440
|
{ $has: { $location: 'method', $valueAnyOf: ['GET', 'POST'] } },
|
|
428
441
|
],
|
|
429
442
|
},
|
|
@@ -451,7 +464,7 @@ EOF
|
|
|
451
464
|
### $or
|
|
452
465
|
|
|
453
466
|
| Type (application) | Type (cURL) | Description |
|
|
454
|
-
|
|
467
|
+
|--|--|--|
|
|
455
468
|
| `object[]` | `object[]` | Provides [operators](#operators) schemas |
|
|
456
469
|
|
|
457
470
|
**Example using application**
|
|
@@ -461,7 +474,7 @@ await server.client.createExpectation({
|
|
|
461
474
|
schema: {
|
|
462
475
|
request: {
|
|
463
476
|
$or: [
|
|
464
|
-
|
|
477
|
+
{ $has: { $location: 'path', $match: 'foo/*' } },
|
|
465
478
|
{ $has: { $location: 'method', $valueAnyOf: ['GET', 'POST'] } },
|
|
466
479
|
],
|
|
467
480
|
},
|
|
@@ -489,7 +502,7 @@ EOF
|
|
|
489
502
|
### $not
|
|
490
503
|
|
|
491
504
|
| Type (application) | Type (cURL) | Description |
|
|
492
|
-
|
|
505
|
+
|--|--|--|
|
|
493
506
|
| `object` | `object` | Provides an [operators](#operators) schema |
|
|
494
507
|
|
|
495
508
|
**Example using application**
|
|
@@ -562,11 +575,13 @@ EOF
|
|
|
562
575
|
|
|
563
576
|
### $switch
|
|
564
577
|
|
|
578
|
+
> **!NOTE** `$exec` operators [have restrictions](#api) when it defined over `HTTP API` or `RemoteClient`
|
|
579
|
+
|
|
565
580
|
| Property | Type (application) | Type (cURL) | Optional | Description |
|
|
566
581
|
|--|--|--|--|--|
|
|
567
582
|
| $location | `string` [enum](#context) | `string` [enum](#context) | | Location that describes what [context](#context) entity is selecting for operator to work with |
|
|
568
|
-
| $cases | `Record<string
|
|
569
|
-
| $default | `
|
|
583
|
+
| $cases | `Record<string ∣ number, object>` | `Record<string ∣ number, object>` | | An object where `key` is an extracted value from [enum](#context) using `$location` (and `$path`, `$exec` if it was specified) and `value` is an [operators](#operators) schema |
|
|
584
|
+
| $default | `object` | `object` | * | Default behavior as an [operators](#operators) schema |
|
|
570
585
|
| $path | `string` | `string` | * | Specifies a path to payload using [lodash get](https://lodash.com/docs/4.17.15#get) |
|
|
571
586
|
| $exec | `(payload, utils) => any` | `string` | * | Sets payload in [context](#context) by function with arguments where `payload` is selected entity using `$location` and `utils` is [utils](#utils) |
|
|
572
587
|
|
|
@@ -676,9 +691,125 @@ await client.createExpectation<{
|
|
|
676
691
|
}));
|
|
677
692
|
```
|
|
678
693
|
|
|
694
|
+
## State
|
|
695
|
+
|
|
696
|
+
State is a unique storage of each request. It can be used to handle complex expectations
|
|
697
|
+
|
|
698
|
+
By default an object of state extracts from `X-Use-Mock-State` in `incoming.headers` (as serialized json in **base64 encoding**) or creates an empty object
|
|
699
|
+
|
|
700
|
+
**Example**
|
|
701
|
+
|
|
702
|
+
```ts
|
|
703
|
+
await client.createExpectation<{
|
|
704
|
+
state: {
|
|
705
|
+
id?: number;
|
|
706
|
+
};
|
|
707
|
+
incoming: {
|
|
708
|
+
query: {
|
|
709
|
+
foo: 'a' | 'b' | 'c';
|
|
710
|
+
};
|
|
711
|
+
};
|
|
712
|
+
outgoing: {
|
|
713
|
+
data: {
|
|
714
|
+
id: number;
|
|
715
|
+
};
|
|
716
|
+
};
|
|
717
|
+
}>(({ $ }) => ({
|
|
718
|
+
schema: {
|
|
719
|
+
request: $.and([
|
|
720
|
+
$.switch('incoming.query', '$exec', (payload) => payload.foo, {
|
|
721
|
+
$cases: {
|
|
722
|
+
'a': $.set('state', '$path', 'id', { $value: 1 }),
|
|
723
|
+
'b': $.set('state', '$path', 'id', { $value: 2 }),
|
|
724
|
+
},
|
|
725
|
+
}),
|
|
726
|
+
]),
|
|
727
|
+
response: $.set('outgoing.data', {
|
|
728
|
+
$exec: (payload, { state }) => ({ id: state.id ?? 0 }),
|
|
729
|
+
}),
|
|
730
|
+
},
|
|
731
|
+
}));
|
|
732
|
+
```
|
|
733
|
+
|
|
734
|
+
## Seeds
|
|
735
|
+
|
|
736
|
+
Seeds can help to generate content with the same values each request using [faker](https://www.npmjs.com/package/@faker-js/faker)
|
|
737
|
+
|
|
738
|
+
By default a number of seed takes from `X-Use-Mock-Seed` in `incoming.headers`
|
|
739
|
+
|
|
740
|
+
**Example**
|
|
741
|
+
|
|
742
|
+
```ts
|
|
743
|
+
await client.createExpectation(({ $ }) => ({
|
|
744
|
+
schema: {
|
|
745
|
+
request: $.and([
|
|
746
|
+
$.set('seed', { $exec: (seed) => seed ?? 123 }),
|
|
747
|
+
]),
|
|
748
|
+
response: $.set('outgoing.data', {
|
|
749
|
+
$exec: (payload, { faker }) => ({
|
|
750
|
+
id: faker.number.int({ max: 1000, min: 500 }),
|
|
751
|
+
first_name: faker.person.firstName('male'),
|
|
752
|
+
last_name: faker.person.lastName('male'),
|
|
753
|
+
}),
|
|
754
|
+
}),
|
|
755
|
+
},
|
|
756
|
+
}));
|
|
757
|
+
```
|
|
758
|
+
|
|
759
|
+
## XML
|
|
760
|
+
|
|
761
|
+
The mock server uses the [fast-xml-parser](https://www.npmjs.com/package/fast-xml-parser) package to parse and serialize XML payload with options:
|
|
762
|
+
|
|
763
|
+
```ts
|
|
764
|
+
{
|
|
765
|
+
ignoreAttributes: false,
|
|
766
|
+
}
|
|
767
|
+
```
|
|
768
|
+
|
|
769
|
+
To define a `incoming.data` as XML in incoming request `incoming.headers` should have `Content-Type: application/xml`.
|
|
770
|
+
|
|
771
|
+
The same with `outgoing.data` and `outgoing.headers`
|
|
772
|
+
|
|
773
|
+
**Example of serialized XML**
|
|
774
|
+
|
|
775
|
+
```xml
|
|
776
|
+
<tag type="default">
|
|
777
|
+
<nested type="nested">456</nested>
|
|
778
|
+
123
|
|
779
|
+
</tag>
|
|
780
|
+
```
|
|
781
|
+
|
|
782
|
+
**Example of parsed XML**
|
|
783
|
+
|
|
784
|
+
```json
|
|
785
|
+
{
|
|
786
|
+
"tag":{
|
|
787
|
+
"nested":{
|
|
788
|
+
"#text":456,
|
|
789
|
+
"@_type":"nested"
|
|
790
|
+
},
|
|
791
|
+
"#text":123,
|
|
792
|
+
"@_type":"default"
|
|
793
|
+
}
|
|
794
|
+
}
|
|
795
|
+
```
|
|
796
|
+
|
|
797
|
+
To parse an XML manually the application lib provides utils:
|
|
798
|
+
|
|
799
|
+
```ts
|
|
800
|
+
import { parsePayload, serializePayload } from '@n1k1t/mock-server';
|
|
801
|
+
|
|
802
|
+
const parsed = parsePayload('xml', '<tag>123</tag>'); // { tag: 123 }
|
|
803
|
+
const serialized = serializePayload('xml', parsed); // '<tag>123</tag>'
|
|
804
|
+
```
|
|
805
|
+
|
|
679
806
|
# API
|
|
680
807
|
|
|
681
|
-
|
|
808
|
+
The mock server provides 3 different ways to work with. There are: `HTTP API` (eg using cURL), `RemoteClient` provided by application lib to connect and work with existent mock server on another host and `MockServer.client` on the same host (application script)
|
|
809
|
+
|
|
810
|
+
The `HTTP API` and `RemoteClient` have some usage restrictions like:
|
|
811
|
+
- Every `$exec` operator **cannot have an access to variables outside the function**. If you need to use some extra variables or modules that implemented in outer scope you have to use the `MockServer.client` to setup everything on the mock server side host
|
|
812
|
+
- Plugins are not supported
|
|
682
813
|
|
|
683
814
|
## Ping
|
|
684
815
|
|
|
@@ -690,13 +821,13 @@ In general, there are 3 ways to register a mock expectation. Using cURL (or any
|
|
|
690
821
|
|--|--|
|
|
691
822
|
| `string` | A `pong` message |
|
|
692
823
|
|
|
693
|
-
|
|
824
|
+
**Using cURL**
|
|
694
825
|
|
|
695
826
|
```bash
|
|
696
827
|
curl -H "Content-type: application/json" --location "localhost:8080/_mock/ping"
|
|
697
828
|
```
|
|
698
829
|
|
|
699
|
-
|
|
830
|
+
**Using application lib on server side**
|
|
700
831
|
|
|
701
832
|
```ts
|
|
702
833
|
import { MockServer } from '@n1k1t/mock-server';
|
|
@@ -705,7 +836,7 @@ const server = await MockServer.start({ host: 'localhost', port: 8080 });
|
|
|
705
836
|
await server.client.ping();
|
|
706
837
|
```
|
|
707
838
|
|
|
708
|
-
|
|
839
|
+
**Using application lib on remotely**
|
|
709
840
|
|
|
710
841
|
```ts
|
|
711
842
|
import { RemoteClient } from '@n1k1t/mock-server';
|
|
@@ -731,7 +862,7 @@ await client.ping();
|
|
|
731
862
|
| name | | `string` | | An expectation name |
|
|
732
863
|
| schema | [Schema](#schema) | `object` | | Provided schema |
|
|
733
864
|
|
|
734
|
-
|
|
865
|
+
**Using cURL**
|
|
735
866
|
|
|
736
867
|
```bash
|
|
737
868
|
curl -H "Content-type: application/json" -X POST --location "localhost:8080/_mock/expectations" --data-binary @- << EOF
|
|
@@ -748,7 +879,7 @@ curl -H "Content-type: application/json" -X POST --location "localhost:8080/_moc
|
|
|
748
879
|
EOF
|
|
749
880
|
```
|
|
750
881
|
|
|
751
|
-
|
|
882
|
+
**Using application lib on server side**
|
|
752
883
|
|
|
753
884
|
```ts
|
|
754
885
|
import { MockServer } from '@n1k1t/mock-server';
|
|
@@ -768,7 +899,7 @@ const expectation = await server.client.createExpectation({
|
|
|
768
899
|
console.log('Mock expectation has created', expectation.id);
|
|
769
900
|
```
|
|
770
901
|
|
|
771
|
-
|
|
902
|
+
**Using application lib on remotely**
|
|
772
903
|
|
|
773
904
|
```ts
|
|
774
905
|
import { RemoteClient } from '@n1k1t/mock-server';
|
|
@@ -807,7 +938,7 @@ console.log('Mock expectation has created', expectation.id);
|
|
|
807
938
|
| name | | `string` | | An expectation name |
|
|
808
939
|
| schema | [Schema](#schema) | `object` | | Provided schema |
|
|
809
940
|
|
|
810
|
-
|
|
941
|
+
**Using cURL**
|
|
811
942
|
|
|
812
943
|
```bash
|
|
813
944
|
curl -H "Content-type: application/json" -X PUT --location "localhost:8080/_mock/expectations" --data-binary @- << EOF
|
|
@@ -818,7 +949,7 @@ curl -H "Content-type: application/json" -X PUT --location "localhost:8080/_mock
|
|
|
818
949
|
EOF
|
|
819
950
|
```
|
|
820
951
|
|
|
821
|
-
|
|
952
|
+
**Using application lib on server side**
|
|
822
953
|
|
|
823
954
|
```ts
|
|
824
955
|
import { MockServer } from '@n1k1t/mock-server';
|
|
@@ -832,7 +963,7 @@ const expectation = await server.client.updateExpectation({
|
|
|
832
963
|
console.log('Mock expectation has updated', expectation);
|
|
833
964
|
```
|
|
834
965
|
|
|
835
|
-
|
|
966
|
+
**Using application lib on remotely**
|
|
836
967
|
|
|
837
968
|
```ts
|
|
838
969
|
import { RemoteClient } from '@n1k1t/mock-server';
|
|
@@ -854,7 +985,7 @@ console.log('Mock expectation has updated', expectation);
|
|
|
854
985
|
|--|--|--|--|--|
|
|
855
986
|
| ids | | `string[]` | * | An expectation IDs list to delete. Or **delete all expectations** if not provided |
|
|
856
987
|
|
|
857
|
-
|
|
988
|
+
**Using cURL**
|
|
858
989
|
|
|
859
990
|
```bash
|
|
860
991
|
curl -H "Content-type: application/json" -X DELETE --location "localhost:8080/_mock/expectations" --data-binary @- << EOF
|
|
@@ -864,7 +995,7 @@ curl -H "Content-type: application/json" -X DELETE --location "localhost:8080/_m
|
|
|
864
995
|
EOF
|
|
865
996
|
```
|
|
866
997
|
|
|
867
|
-
|
|
998
|
+
**Using application lib on server side**
|
|
868
999
|
|
|
869
1000
|
```ts
|
|
870
1001
|
import { MockServer } from '@n1k1t/mock-server';
|
|
@@ -875,7 +1006,7 @@ await server.client.deleteExpectations({
|
|
|
875
1006
|
});
|
|
876
1007
|
```
|
|
877
1008
|
|
|
878
|
-
|
|
1009
|
+
**Using application lib on remotely**
|
|
879
1010
|
|
|
880
1011
|
```ts
|
|
881
1012
|
import { RemoteClient } from '@n1k1t/mock-server';
|
|
@@ -991,12 +1122,28 @@ await server.client.createExpectation({
|
|
|
991
1122
|
|
|
992
1123
|
| Plugin | Description |
|
|
993
1124
|
|--|--|
|
|
994
|
-
| `incoming.body` | Describes how to handle incoming body |
|
|
995
|
-
| `outgoing.response` | Describes how to reply |
|
|
996
|
-
| `forward.request` | Describes how provide an [axios](https://www.npmjs.com/package/axios) request config to forward a request |
|
|
997
|
-
| `forward.response` | Describes how to parse [axios](https://www.npmjs.com/package/axios) response of a forwarded request |
|
|
1125
|
+
| [`incoming.body`](#incomingbody) | Describes how to handle incoming body |
|
|
1126
|
+
| [`outgoing.response`](#outgoingresponse) | Describes how to reply |
|
|
1127
|
+
| [`forward.request`](#forwardrequest) | Describes how provide an [axios](https://www.npmjs.com/package/axios) request config to forward a request |
|
|
1128
|
+
| [`forward.response`](#forwardresponse) | Describes how to parse [axios](https://www.npmjs.com/package/axios) response of a forwarded request |
|
|
1129
|
+
|
|
1130
|
+
### incoming.body
|
|
998
1131
|
|
|
999
|
-
|
|
1132
|
+
`INPUT`
|
|
1133
|
+
|
|
1134
|
+
| Argument | Type | Description |
|
|
1135
|
+
|--|--|--|
|
|
1136
|
+
| request | `http.IncomingMessage` | Raw HTTP request |
|
|
1137
|
+
|
|
1138
|
+
`OUTPUT`
|
|
1139
|
+
|
|
1140
|
+
| Property | Type | Optional | Description |
|
|
1141
|
+
|--|--|--|--|
|
|
1142
|
+
| raw | `string` | | Serialized incoming request body |
|
|
1143
|
+
| type | `xml ∣ json ∣ plain` | * | A type of `payload` |
|
|
1144
|
+
| payload | `object` | * | A payload object |
|
|
1145
|
+
|
|
1146
|
+
**Example**
|
|
1000
1147
|
|
|
1001
1148
|
```ts
|
|
1002
1149
|
server.context.plugins.register('incoming.body', async (request) => {
|
|
@@ -1009,7 +1156,22 @@ server.context.plugins.register('incoming.body', async (request) => {
|
|
|
1009
1156
|
});
|
|
1010
1157
|
```
|
|
1011
1158
|
|
|
1012
|
-
|
|
1159
|
+
### outgoing.response
|
|
1160
|
+
|
|
1161
|
+
`INPUT`
|
|
1162
|
+
|
|
1163
|
+
| Argument | Type | Description |
|
|
1164
|
+
|--|--|--|
|
|
1165
|
+
| response | `http.ServerResponse` | Raw HTTP response |
|
|
1166
|
+
| context | `object` | A request [context](#context) |
|
|
1167
|
+
|
|
1168
|
+
`OUTPUT`
|
|
1169
|
+
|
|
1170
|
+
| Type | Description |
|
|
1171
|
+
|--|--|
|
|
1172
|
+
| `unknown` | Result is not handing |
|
|
1173
|
+
|
|
1174
|
+
**Example**
|
|
1013
1175
|
|
|
1014
1176
|
```ts
|
|
1015
1177
|
server.context.plugins.register('outgoing.response', (response, context) => {
|
|
@@ -1019,7 +1181,22 @@ server.context.plugins.register('outgoing.response', (response, context) => {
|
|
|
1019
1181
|
});
|
|
1020
1182
|
```
|
|
1021
1183
|
|
|
1022
|
-
|
|
1184
|
+
### forward.request
|
|
1185
|
+
|
|
1186
|
+
`INPUT`
|
|
1187
|
+
|
|
1188
|
+
| Argument | Type | Description |
|
|
1189
|
+
|--|--|--|
|
|
1190
|
+
| config | `AxiosRequestConfig` | An [axios](https://www.npmjs.com/package/axios) request config |
|
|
1191
|
+
| context | `object` | A request [context](#context) |
|
|
1192
|
+
|
|
1193
|
+
`OUTPUT`
|
|
1194
|
+
|
|
1195
|
+
| Type | Description |
|
|
1196
|
+
|--|--|
|
|
1197
|
+
| `AxiosRequestConfig` | An [axios](https://www.npmjs.com/package/axios) request config |
|
|
1198
|
+
|
|
1199
|
+
**Example**
|
|
1023
1200
|
|
|
1024
1201
|
```ts
|
|
1025
1202
|
server.context.plugins.register('forward.request', (config) => ({
|
|
@@ -1028,7 +1205,24 @@ server.context.plugins.register('forward.request', (config) => ({
|
|
|
1028
1205
|
}));
|
|
1029
1206
|
```
|
|
1030
1207
|
|
|
1031
|
-
|
|
1208
|
+
### forward.response
|
|
1209
|
+
|
|
1210
|
+
`INPUT`
|
|
1211
|
+
|
|
1212
|
+
| Argument | Type | Description |
|
|
1213
|
+
|--|--|--|
|
|
1214
|
+
| config | `AxiosResponse` | An [axios](https://www.npmjs.com/package/axios) response |
|
|
1215
|
+
| context | `object` | A request [context](#context) |
|
|
1216
|
+
|
|
1217
|
+
`OUTPUT`
|
|
1218
|
+
|
|
1219
|
+
| Property | Type | Optional | Description |
|
|
1220
|
+
|--|--|--|--|
|
|
1221
|
+
| raw | `string` | | Serialized incoming request body |
|
|
1222
|
+
| type | `xml ∣ json ∣ plain` | * | A type of `payload` |
|
|
1223
|
+
| payload | `object` | * | A payload object |
|
|
1224
|
+
|
|
1225
|
+
**Example**
|
|
1032
1226
|
|
|
1033
1227
|
```ts
|
|
1034
1228
|
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.9",
|
|
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,CAAC,MAAM,CAAC;IAE1F,GAAG,CAAC,CAAC,SAAS,sBAAsB,CAAC,QAAQ,EAAE,4BAA4B,EAAE,GAAG,CAAC,CAAC,SAAS,CAAC,EAAE,OAAO,EAAE,CAAC,GAAG;QAAE,IAAI,EAAE,CAAC,CAAA;KAAE,CAAC;IACvH,GAAG,CAAC,CAAC,SAAS,sBAA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AC,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,EAAE,OAAO,EAAE,CAAC;IAEnC,MAAM,EAAE,CACN,SAAY,EACZ,SAAqC,EACrC,KAAe,EACf,OAAgB,EAChB,EAAE,CAAC,CAAC;QACJ,OAAO,EAAE;YACP,SAAS;YAET,GAAG,CAAC,OAAO,SAAS,KAAK,QAAQ,IAAI,SAAS,CAAC;YAC/C,GAAG,CAAC,OAAO,SA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