@furystack/rest-service 6.2.1 → 6.2.3

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.
Files changed (40) hide show
  1. package/dist/actions/error-action.js +5 -5
  2. package/dist/actions/error-action.js.map +1 -1
  3. package/dist/actions/error-action.spec.js +0 -3
  4. package/dist/actions/error-action.spec.js.map +1 -1
  5. package/dist/api-manager.js +2 -2
  6. package/dist/api-manager.js.map +1 -1
  7. package/dist/endpoint-generators/create-delete-endpoint.spec.js +4 -7
  8. package/dist/endpoint-generators/create-delete-endpoint.spec.js.map +1 -1
  9. package/dist/endpoint-generators/create-get-collection-endpoint.spec.js +15 -14
  10. package/dist/endpoint-generators/create-get-collection-endpoint.spec.js.map +1 -1
  11. package/dist/endpoint-generators/create-get-entity-endpoint.spec.js +12 -18
  12. package/dist/endpoint-generators/create-get-entity-endpoint.spec.js.map +1 -1
  13. package/dist/endpoint-generators/create-patch-endpoint.spec.js +4 -7
  14. package/dist/endpoint-generators/create-patch-endpoint.spec.js.map +1 -1
  15. package/dist/endpoint-generators/create-post-endpoint.spec.js +5 -8
  16. package/dist/endpoint-generators/create-post-endpoint.spec.js.map +1 -1
  17. package/dist/rest-service.integration.spec.js +34 -24
  18. package/dist/rest-service.integration.spec.js.map +1 -1
  19. package/dist/rest.integration.test.js +11 -11
  20. package/dist/rest.integration.test.js.map +1 -1
  21. package/dist/static-server-manager.spec.js +32 -62
  22. package/dist/static-server-manager.spec.js.map +1 -1
  23. package/dist/validate.integration.spec.js +32 -37
  24. package/dist/validate.integration.spec.js.map +1 -1
  25. package/package.json +11 -12
  26. package/src/actions/error-action.spec.ts +0 -3
  27. package/src/actions/error-action.ts +6 -6
  28. package/src/api-manager.ts +2 -2
  29. package/src/endpoint-generators/create-delete-endpoint.spec.ts +4 -4
  30. package/src/endpoint-generators/create-get-collection-endpoint.spec.ts +17 -11
  31. package/src/endpoint-generators/create-get-entity-endpoint.spec.ts +12 -16
  32. package/src/endpoint-generators/create-patch-endpoint.spec.ts +4 -4
  33. package/src/endpoint-generators/create-post-endpoint.spec.ts +6 -6
  34. package/src/rest-service.integration.spec.ts +36 -29
  35. package/src/rest.integration.test.ts +10 -10
  36. package/src/static-server-manager.spec.ts +32 -39
  37. package/src/validate.integration.spec.ts +31 -36
  38. package/types/actions/error-action.d.ts +0 -2
  39. package/types/actions/error-action.d.ts.map +1 -1
  40. package/types/validate.integration.spec.d.ts.map +1 -1
@@ -1,7 +1,6 @@
1
1
  import { Injector } from '@furystack/inject'
2
- import { createClient } from '@furystack/rest-client-got'
2
+ import { createClient, ResponseError } from '@furystack/rest-client-fetch'
3
3
  import { usingAsync } from '@furystack/utils'
4
- import { RequestError } from 'got/dist/source'
5
4
  import { JsonResult } from './request-action-implementation'
6
5
  import { Validate } from './validate'
7
6
  import './helpers'
@@ -75,10 +74,10 @@ describe('Validation integration tests', () => {
75
74
  query: undefined as any,
76
75
  })
77
76
  } catch (error) {
78
- if (error instanceof RequestError) {
79
- expect(error.message).toBe('Response code 400 (Bad Request)')
80
- expect(error.response?.statusCode).toBe(400)
81
- const responseJson = JSON.parse(error.response?.body as string)
77
+ if (error instanceof ResponseError) {
78
+ expect(error.message).toBe('Bad Request')
79
+ expect(error.response?.status).toBe(400)
80
+ const responseJson = await error.response.json()
82
81
  expect(responseJson.errors[0].params.missingProperty).toEqual('foo')
83
82
  expect(responseJson.errors[1].params.missingProperty).toEqual('bar')
84
83
  expect(responseJson.errors[2].params.missingProperty).toEqual('baz')
@@ -96,10 +95,10 @@ describe('Validation integration tests', () => {
96
95
  url: undefined as any,
97
96
  })
98
97
  } catch (error) {
99
- if (error instanceof RequestError) {
100
- expect(error.message).toBe('Response code 400 (Bad Request)')
101
- expect(error.response?.statusCode).toBe(400)
102
- const responseJson = JSON.parse(error.response?.body as string)
98
+ if (error instanceof ResponseError) {
99
+ expect(error.message).toBe('Bad Request')
100
+ expect(error.response?.status).toBe(400)
101
+ const responseJson = await error.response.json()
103
102
  expect(responseJson.errors[0].params.type).toEqual('number')
104
103
  expect(responseJson.errors[0].instancePath).toEqual('/url/id')
105
104
  }
@@ -116,10 +115,10 @@ describe('Validation integration tests', () => {
116
115
  headers: undefined as any,
117
116
  })
118
117
  } catch (error) {
119
- if (error instanceof RequestError) {
120
- expect(error.message).toBe('Response code 400 (Bad Request)')
121
- expect(error.response?.statusCode).toBe(400)
122
- const responseJson = JSON.parse(error.response?.body as string)
118
+ if (error instanceof ResponseError) {
119
+ expect(error.message).toBe('Bad Request')
120
+ expect(error.response?.status).toBe(400)
121
+ const responseJson = await error.response.json()
123
122
  expect(
124
123
  responseJson.errors.find((e: any) => e.keyword === 'required' && e.message.includes('foo')),
125
124
  ).toBeDefined()
@@ -137,10 +136,10 @@ describe('Validation integration tests', () => {
137
136
  body: undefined as any,
138
137
  })
139
138
  } catch (error) {
140
- if (error instanceof RequestError) {
141
- expect(error.message).toBe('Response code 400 (Bad Request)')
142
- expect(error.response?.statusCode).toBe(400)
143
- const responseJson = JSON.parse(error.response?.body as string)
139
+ if (error instanceof ResponseError) {
140
+ expect(error.message).toBe('Bad Request')
141
+ expect(error.response?.status).toBe(400)
142
+ const responseJson = await error.response.json()
144
143
  expect(responseJson.errors[0].params.missingProperty).toEqual('body')
145
144
  }
146
145
  }
@@ -160,11 +159,10 @@ describe('Validation integration tests', () => {
160
159
  baz: false,
161
160
  },
162
161
  })
163
- expect(result.response.statusCode).toBe(200)
164
- const responseJson = result.getJson()
165
- expect(responseJson.foo).toBe('foo')
166
- expect(responseJson.bar).toBe(2)
167
- expect(responseJson.baz).toBe(false)
162
+ expect(result.response.status).toBe(200)
163
+ expect(result.result.foo).toBe('foo')
164
+ expect(result.result.bar).toBe(2)
165
+ expect(result.result.baz).toBe(false)
168
166
  })
169
167
  })
170
168
  it('Should validate url', async () => {
@@ -174,9 +172,8 @@ describe('Validation integration tests', () => {
174
172
  action: '/validate-url/:id',
175
173
  url: { id: 3 },
176
174
  })
177
- expect(result.response.statusCode).toBe(200)
178
- const responseJson = result.getJson()
179
- expect(responseJson.id).toBe(3)
175
+ expect(result.response.status).toBe(200)
176
+ expect(result.result.id).toBe(3)
180
177
  })
181
178
  })
182
179
  it('Should validate headers', async () => {
@@ -190,11 +187,10 @@ describe('Validation integration tests', () => {
190
187
  baz: true,
191
188
  },
192
189
  })
193
- expect(result.response.statusCode).toBe(200)
194
- const responseJson = result.getJson()
195
- expect(responseJson.foo).toBe('foo')
196
- expect(responseJson.bar).toBe(42)
197
- expect(responseJson.baz).toBe(true)
190
+ expect(result.response.status).toBe(200)
191
+ expect(result.result.foo).toBe('foo')
192
+ expect(result.result.bar).toBe(42)
193
+ expect(result.result.baz).toBe(true)
198
194
  })
199
195
  })
200
196
  it('Should validate body', async () => {
@@ -209,11 +205,10 @@ describe('Validation integration tests', () => {
209
205
  },
210
206
  })
211
207
 
212
- expect(result.response.statusCode).toBe(200)
213
- const responseJson = result.getJson()
214
- expect(responseJson.foo).toBe('foo')
215
- expect(responseJson.bar).toBe(42)
216
- expect(responseJson.baz).toBe(true)
208
+ expect(result.response.status).toBe(200)
209
+ expect(result.result.foo).toBe('foo')
210
+ expect(result.result.bar).toBe(42)
211
+ expect(result.result.baz).toBe(true)
217
212
  })
218
213
  })
219
214
  })
@@ -7,8 +7,6 @@ export declare const ErrorAction: RequestAction<{
7
7
  body: unknown;
8
8
  result: {
9
9
  message: string;
10
- url?: string;
11
- stack?: string;
12
10
  };
13
11
  }>;
14
12
  //# sourceMappingURL=error-action.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"error-action.d.ts","sourceRoot":"","sources":["../../src/actions/error-action.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,kCAAkC,CAAA;AAIrE;;;GAGG;AAEH,eAAO,MAAM,WAAW,EAAE,aAAa,CAAC;IACtC,IAAI,EAAE,OAAO,CAAA;IACb,MAAM,EAAE;QAAE,OAAO,EAAE,MAAM,CAAC;QAAC,GAAG,CAAC,EAAE,MAAM,CAAC;QAAC,KAAK,CAAC,EAAE,MAAM,CAAA;KAAE,CAAA;CAC1D,CAoBA,CAAA"}
1
+ {"version":3,"file":"error-action.d.ts","sourceRoot":"","sources":["../../src/actions/error-action.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,kCAAkC,CAAA;AAIrE;;;GAGG;AAEH,eAAO,MAAM,WAAW,EAAE,aAAa,CAAC;IACtC,IAAI,EAAE,OAAO,CAAA;IACb,MAAM,EAAE;QAAE,OAAO,EAAE,MAAM,CAAA;KAAE,CAAA;CAC5B,CAoBA,CAAA"}
@@ -1 +1 @@
1
- {"version":3,"file":"validate.integration.spec.d.ts","sourceRoot":"","sources":["../src/validate.integration.spec.ts"],"names":[],"mappings":"AAMA,OAAO,WAAW,CAAA"}
1
+ {"version":3,"file":"validate.integration.spec.d.ts","sourceRoot":"","sources":["../src/validate.integration.spec.ts"],"names":[],"mappings":"AAKA,OAAO,WAAW,CAAA"}