@api-client/core 0.12.9 → 0.12.11
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/build/src/browser.d.ts +1 -2
- package/build/src/browser.d.ts.map +1 -1
- package/build/src/browser.js +0 -1
- package/build/src/browser.js.map +1 -1
- package/build/src/exceptions/exception.d.ts +29 -1
- package/build/src/exceptions/exception.d.ts.map +1 -1
- package/build/src/exceptions/exception.js +37 -1
- package/build/src/exceptions/exception.js.map +1 -1
- package/build/src/index.d.ts +1 -2
- package/build/src/index.d.ts.map +1 -1
- package/build/src/index.js +0 -1
- package/build/src/index.js.map +1 -1
- package/build/src/mocking/lib/User.d.ts.map +1 -1
- package/build/src/mocking/lib/User.js +1 -0
- package/build/src/mocking/lib/User.js.map +1 -1
- package/build/src/models/store/User.d.ts +14 -0
- package/build/src/models/store/User.d.ts.map +1 -1
- package/build/src/models/store/User.js.map +1 -1
- package/build/src/proxy/HttpProjectProxy.d.ts.map +1 -1
- package/build/src/proxy/HttpProjectProxy.js +39 -43
- package/build/src/proxy/HttpProjectProxy.js.map +1 -1
- package/build/src/proxy/RequestProxy.d.ts.map +1 -1
- package/build/src/proxy/RequestProxy.js +11 -11
- package/build/src/proxy/RequestProxy.js.map +1 -1
- package/build/src/runtime/store/DataCatalogSdk.d.ts.map +1 -1
- package/build/src/runtime/store/DataCatalogSdk.js +49 -109
- package/build/src/runtime/store/DataCatalogSdk.js.map +1 -1
- package/build/src/runtime/store/FilesSdk.d.ts.map +1 -1
- package/build/src/runtime/store/FilesSdk.js +51 -115
- package/build/src/runtime/store/FilesSdk.js.map +1 -1
- package/build/src/runtime/store/HistorySdk.d.ts.map +1 -1
- package/build/src/runtime/store/HistorySdk.js +25 -70
- package/build/src/runtime/store/HistorySdk.js.map +1 -1
- package/build/src/runtime/store/OrganizationsSdk.d.ts +20 -1
- package/build/src/runtime/store/OrganizationsSdk.d.ts.map +1 -1
- package/build/src/runtime/store/OrganizationsSdk.js +103 -43
- package/build/src/runtime/store/OrganizationsSdk.js.map +1 -1
- package/build/src/runtime/store/RevisionsSdk.d.ts.map +1 -1
- package/build/src/runtime/store/RevisionsSdk.js +5 -10
- package/build/src/runtime/store/RevisionsSdk.js.map +1 -1
- package/build/src/runtime/store/RouteBuilder.d.ts +8 -0
- package/build/src/runtime/store/RouteBuilder.d.ts.map +1 -1
- package/build/src/runtime/store/RouteBuilder.js +12 -0
- package/build/src/runtime/store/RouteBuilder.js.map +1 -1
- package/build/src/runtime/store/SdkBase.d.ts +7 -5
- package/build/src/runtime/store/SdkBase.d.ts.map +1 -1
- package/build/src/runtime/store/SdkBase.js +45 -63
- package/build/src/runtime/store/SdkBase.js.map +1 -1
- package/build/src/runtime/store/SharedSdk.d.ts.map +1 -1
- package/build/src/runtime/store/SharedSdk.js +5 -14
- package/build/src/runtime/store/SharedSdk.js.map +1 -1
- package/build/src/runtime/store/TrashSdk.d.ts.map +1 -1
- package/build/src/runtime/store/TrashSdk.js +8 -28
- package/build/src/runtime/store/TrashSdk.js.map +1 -1
- package/build/src/runtime/store/UsersSdk.d.ts +2 -0
- package/build/src/runtime/store/UsersSdk.d.ts.map +1 -1
- package/build/src/runtime/store/UsersSdk.js +18 -11
- package/build/src/runtime/store/UsersSdk.js.map +1 -1
- package/package.json +1 -1
- package/src/exceptions/exception.ts +51 -4
- package/src/mocking/lib/User.ts +1 -0
- package/src/models/store/User.ts +16 -0
- package/src/proxy/HttpProjectProxy.ts +39 -43
- package/src/proxy/RequestProxy.ts +11 -11
- package/src/runtime/store/DataCatalogSdk.ts +49 -109
- package/src/runtime/store/FilesSdk.ts +51 -115
- package/src/runtime/store/HistorySdk.ts +25 -70
- package/src/runtime/store/OrganizationsSdk.ts +109 -44
- package/src/runtime/store/RevisionsSdk.ts +5 -10
- package/src/runtime/store/RouteBuilder.ts +14 -0
- package/src/runtime/store/SdkBase.ts +46 -65
- package/src/runtime/store/SharedSdk.ts +5 -14
- package/src/runtime/store/TrashSdk.ts +8 -28
- package/src/runtime/store/UsersSdk.ts +18 -11
- package/tests/unit/runtime/proxy/HttpProjectProxy.spec.ts +42 -40
- package/tests/unit/runtime/proxy/RequestProxy.spec.ts +11 -11
- package/build/src/runtime/store/Errors.d.ts +0 -51
- package/build/src/runtime/store/Errors.d.ts.map +0 -1
- package/build/src/runtime/store/Errors.js +0 -61
- package/build/src/runtime/store/Errors.js.map +0 -1
- package/src/runtime/store/Errors.ts +0 -98
|
@@ -8,8 +8,8 @@ import {
|
|
|
8
8
|
} from './SdkBase.js'
|
|
9
9
|
import { RouteBuilder } from './RouteBuilder.js'
|
|
10
10
|
import type { ContextListOptions, ContextListResult } from '../../events/BaseEvents.js'
|
|
11
|
-
import { SdkError } from './Errors.js'
|
|
12
11
|
import type { TrashEntry } from '../../models/TrashEntry.js'
|
|
12
|
+
import { Exception } from '../../exceptions/exception.js'
|
|
13
13
|
|
|
14
14
|
export class TrashSdk extends SdkBase {
|
|
15
15
|
/**
|
|
@@ -29,24 +29,19 @@ export class TrashSdk extends SdkBase {
|
|
|
29
29
|
const E_PREFIX = 'Unable to list trash. '
|
|
30
30
|
if (result.status !== 200) {
|
|
31
31
|
this.logInvalidResponse(result)
|
|
32
|
-
|
|
33
|
-
if (!e) {
|
|
34
|
-
e = new SdkError(`${E_PREFIX}${E_RESPONSE_STATUS}${result.status}`, result.status)
|
|
35
|
-
e.response = result.body
|
|
36
|
-
}
|
|
37
|
-
throw e
|
|
32
|
+
throw this.createApiError(`${E_PREFIX}${E_RESPONSE_STATUS}${result.status}`, result.body)
|
|
38
33
|
}
|
|
39
34
|
if (!result.body) {
|
|
40
|
-
throw new
|
|
35
|
+
throw new Exception(`${E_PREFIX}${E_RESPONSE_NO_VALUE}`, { code: 'E_RESPONSE_NO_VALUE', status: result.status })
|
|
41
36
|
}
|
|
42
37
|
let data: ContextListResult<TrashEntry>
|
|
43
38
|
try {
|
|
44
39
|
data = JSON.parse(result.body)
|
|
45
40
|
} catch {
|
|
46
|
-
throw new
|
|
41
|
+
throw new Exception(`${E_PREFIX}${E_INVALID_JSON}`, { code: 'E_INVALID_JSON', status: result.status })
|
|
47
42
|
}
|
|
48
43
|
if (!Array.isArray(data.items)) {
|
|
49
|
-
throw new
|
|
44
|
+
throw new Exception(`${E_PREFIX}${E_RESPONSE_UNKNOWN}`, { code: 'E_RESPONSE_UNKNOWN', status: result.status })
|
|
50
45
|
}
|
|
51
46
|
return data
|
|
52
47
|
}
|
|
@@ -67,12 +62,7 @@ export class TrashSdk extends SdkBase {
|
|
|
67
62
|
const E_PREFIX = 'Unable to delete trash. '
|
|
68
63
|
if (result.status !== 204) {
|
|
69
64
|
this.logInvalidResponse(result)
|
|
70
|
-
|
|
71
|
-
if (!e) {
|
|
72
|
-
e = new SdkError(`${E_PREFIX}${E_RESPONSE_STATUS}${result.status}`, result.status)
|
|
73
|
-
e.response = result.body
|
|
74
|
-
}
|
|
75
|
-
throw e
|
|
65
|
+
throw this.createApiError(`${E_PREFIX}${E_RESPONSE_STATUS}${result.status}`, result.body)
|
|
76
66
|
}
|
|
77
67
|
}
|
|
78
68
|
|
|
@@ -84,12 +74,7 @@ export class TrashSdk extends SdkBase {
|
|
|
84
74
|
const E_PREFIX = 'Unable to restore from trash. '
|
|
85
75
|
if (result.status !== 204) {
|
|
86
76
|
this.logInvalidResponse(result)
|
|
87
|
-
|
|
88
|
-
if (!e) {
|
|
89
|
-
e = new SdkError(`${E_PREFIX}${E_RESPONSE_STATUS}${result.status}`, result.status)
|
|
90
|
-
e.response = result.body
|
|
91
|
-
}
|
|
92
|
-
throw e
|
|
77
|
+
throw this.createApiError(`${E_PREFIX}${E_RESPONSE_STATUS}${result.status}`, result.body)
|
|
93
78
|
}
|
|
94
79
|
}
|
|
95
80
|
|
|
@@ -105,12 +90,7 @@ export class TrashSdk extends SdkBase {
|
|
|
105
90
|
const E_PREFIX = 'Unable to empty trash. '
|
|
106
91
|
if (result.status !== 204) {
|
|
107
92
|
this.logInvalidResponse(result)
|
|
108
|
-
|
|
109
|
-
if (!e) {
|
|
110
|
-
e = new SdkError(`${E_PREFIX}${E_RESPONSE_STATUS}${result.status}`, result.status)
|
|
111
|
-
e.response = result.body
|
|
112
|
-
}
|
|
113
|
-
throw e
|
|
93
|
+
throw this.createApiError(`${E_PREFIX}${E_RESPONSE_STATUS}${result.status}`, result.body)
|
|
114
94
|
}
|
|
115
95
|
}
|
|
116
96
|
}
|
|
@@ -9,6 +9,7 @@ import {
|
|
|
9
9
|
import { RouteBuilder } from './RouteBuilder.js'
|
|
10
10
|
import { IUser } from '../../models/store/User.js'
|
|
11
11
|
import { ContextListResult, ContextListOptions } from '../../events/BaseEvents.js'
|
|
12
|
+
import { Exception } from '../../exceptions/exception.js'
|
|
12
13
|
|
|
13
14
|
export interface IJwtInfo {
|
|
14
15
|
/**
|
|
@@ -93,19 +94,19 @@ export class UsersSdk extends SdkBase {
|
|
|
93
94
|
const E_PREFIX = 'Unable to read a user. '
|
|
94
95
|
if (result.status !== 200) {
|
|
95
96
|
this.logInvalidResponse(result)
|
|
96
|
-
throw
|
|
97
|
+
throw this.createApiError(`${E_PREFIX}${E_RESPONSE_STATUS}${result.status}`, result.body)
|
|
97
98
|
}
|
|
98
99
|
if (!result.body) {
|
|
99
|
-
throw new
|
|
100
|
+
throw new Exception(`${E_PREFIX}${E_RESPONSE_NO_VALUE}`, { code: 'E_RESPONSE_NO_VALUE', status: result.status })
|
|
100
101
|
}
|
|
101
102
|
let data: IUser
|
|
102
103
|
try {
|
|
103
104
|
data = JSON.parse(result.body)
|
|
104
105
|
} catch {
|
|
105
|
-
throw new
|
|
106
|
+
throw new Exception(`${E_PREFIX}${E_INVALID_JSON}`, { code: 'E_INVALID_JSON', status: result.status })
|
|
106
107
|
}
|
|
107
108
|
if (!data.key) {
|
|
108
|
-
throw new
|
|
109
|
+
throw new Exception(`${E_PREFIX}${E_RESPONSE_UNKNOWN}`, { code: 'E_RESPONSE_UNKNOWN', status: result.status })
|
|
109
110
|
}
|
|
110
111
|
return data
|
|
111
112
|
}
|
|
@@ -116,12 +117,15 @@ export class UsersSdk extends SdkBase {
|
|
|
116
117
|
* @param organizationId The key of the organization we want to read the user from.
|
|
117
118
|
* @param options Optional query options.
|
|
118
119
|
* @param request Optional request options.
|
|
120
|
+
* @deprecated Use `organizations.listUsers()` instead.
|
|
119
121
|
*/
|
|
120
122
|
async list(
|
|
121
123
|
organizationId: string,
|
|
122
124
|
options?: ContextListOptions,
|
|
123
125
|
request: SdkOptions = {}
|
|
124
126
|
): Promise<ContextListResult<IUser>> {
|
|
127
|
+
// eslint-disable-next-line no-console
|
|
128
|
+
console.warn('The `users.list` method is deprecated. Use `organizations.listUsers()` instead.')
|
|
125
129
|
const { token } = request
|
|
126
130
|
const url = this.sdk.getUrl(RouteBuilder.users(organizationId))
|
|
127
131
|
this.sdk.appendListOptions(url, options)
|
|
@@ -130,19 +134,19 @@ export class UsersSdk extends SdkBase {
|
|
|
130
134
|
const E_PREFIX = 'Unable to list projects. '
|
|
131
135
|
if (result.status !== 200) {
|
|
132
136
|
this.logInvalidResponse(result)
|
|
133
|
-
throw
|
|
137
|
+
throw this.createApiError(`${E_PREFIX}${E_RESPONSE_STATUS}${result.status}`, result.body)
|
|
134
138
|
}
|
|
135
139
|
if (!result.body) {
|
|
136
|
-
throw new
|
|
140
|
+
throw new Exception(`${E_PREFIX}${E_RESPONSE_NO_VALUE}`, { code: 'E_RESPONSE_NO_VALUE', status: result.status })
|
|
137
141
|
}
|
|
138
142
|
let data: ContextListResult<IUser>
|
|
139
143
|
try {
|
|
140
144
|
data = JSON.parse(result.body)
|
|
141
145
|
} catch {
|
|
142
|
-
throw new
|
|
146
|
+
throw new Exception(`${E_PREFIX}${E_INVALID_JSON}`, { code: 'E_INVALID_JSON', status: result.status })
|
|
143
147
|
}
|
|
144
148
|
if (!Array.isArray(data.items)) {
|
|
145
|
-
throw new
|
|
149
|
+
throw new Exception(`${E_PREFIX}${E_RESPONSE_UNKNOWN}`, { code: 'E_RESPONSE_UNKNOWN', status: result.status })
|
|
146
150
|
}
|
|
147
151
|
return data
|
|
148
152
|
}
|
|
@@ -154,8 +158,11 @@ export class UsersSdk extends SdkBase {
|
|
|
154
158
|
* @param key The user key.
|
|
155
159
|
* @param request Optional request options.
|
|
156
160
|
* @returns The user object
|
|
161
|
+
* @deprecated Use `organizations.getUser()` instead.
|
|
157
162
|
*/
|
|
158
163
|
async read(organizationId: string, key: string, request: SdkOptions = {}): Promise<IUser> {
|
|
164
|
+
// eslint-disable-next-line no-console
|
|
165
|
+
console.warn('The `users.read` method is deprecated. Use `organizations.getUser()` instead.')
|
|
159
166
|
const { token } = request
|
|
160
167
|
const url = this.sdk.getUrl(RouteBuilder.user(organizationId, key))
|
|
161
168
|
const result = await this.sdk.http.get(url.toString(), { token })
|
|
@@ -163,16 +170,16 @@ export class UsersSdk extends SdkBase {
|
|
|
163
170
|
const E_PREFIX = 'Unable to read the user info. '
|
|
164
171
|
if (result.status !== 200) {
|
|
165
172
|
this.logInvalidResponse(result)
|
|
166
|
-
throw
|
|
173
|
+
throw this.createApiError(`${E_PREFIX}${E_RESPONSE_STATUS}${result.status}`, result.body)
|
|
167
174
|
}
|
|
168
175
|
if (!result.body) {
|
|
169
|
-
throw new
|
|
176
|
+
throw new Exception(`${E_PREFIX}${E_RESPONSE_NO_VALUE}`, { code: 'E_RESPONSE_NO_VALUE', status: result.status })
|
|
170
177
|
}
|
|
171
178
|
let data: IUser
|
|
172
179
|
try {
|
|
173
180
|
data = JSON.parse(result.body)
|
|
174
181
|
} catch {
|
|
175
|
-
throw new
|
|
182
|
+
throw new Exception(`${E_PREFIX}${E_INVALID_JSON}`, { code: 'E_INVALID_JSON', status: result.status })
|
|
176
183
|
}
|
|
177
184
|
return data
|
|
178
185
|
}
|
|
@@ -7,7 +7,7 @@ import {
|
|
|
7
7
|
IHttpProjectStoreProxyInit,
|
|
8
8
|
IHttpProjectProxyInit,
|
|
9
9
|
ProxyService,
|
|
10
|
-
|
|
10
|
+
Exception,
|
|
11
11
|
RouteBuilder,
|
|
12
12
|
} from '../../../../src/index.js'
|
|
13
13
|
|
|
@@ -43,16 +43,16 @@ test.group('net-store project', (group) => {
|
|
|
43
43
|
const path = RouteBuilder.fileMedia(message.organization, project.key)
|
|
44
44
|
const scope = nock(storeHostname).get(path).reply(200, project.toJSON())
|
|
45
45
|
const service = new ProxyService()
|
|
46
|
-
let error:
|
|
46
|
+
let error: Exception
|
|
47
47
|
try {
|
|
48
48
|
await service.proxyHttpProject(message, token, storeUri)
|
|
49
|
-
error = new
|
|
49
|
+
error = new Exception('Not thrown', { status: 0 })
|
|
50
50
|
} catch (e) {
|
|
51
|
-
error = e as
|
|
51
|
+
error = e as Exception
|
|
52
52
|
}
|
|
53
|
-
assert.equal(error.
|
|
53
|
+
assert.equal(error.status, 400, 'has the error code')
|
|
54
54
|
assert.equal(error.message, 'Invalid request', 'has the message')
|
|
55
|
-
assert.equal(error.
|
|
55
|
+
assert.equal(error.help, 'The "pid" parameter is required.', 'has the detail')
|
|
56
56
|
assert.isFalse(scope.isDone(), 'did not call the store')
|
|
57
57
|
})
|
|
58
58
|
|
|
@@ -66,16 +66,16 @@ test.group('net-store project', (group) => {
|
|
|
66
66
|
const path = RouteBuilder.fileMedia(message.organization, project.key)
|
|
67
67
|
const scope = nock(storeHostname).get(path).reply(200, project.toJSON())
|
|
68
68
|
const service = new ProxyService()
|
|
69
|
-
let error:
|
|
69
|
+
let error: Exception
|
|
70
70
|
try {
|
|
71
71
|
await service.proxyHttpProject(message, token, storeUri)
|
|
72
|
-
error = new
|
|
72
|
+
error = new Exception('Not thrown', { status: 0 })
|
|
73
73
|
} catch (e) {
|
|
74
|
-
error = e as
|
|
74
|
+
error = e as Exception
|
|
75
75
|
}
|
|
76
|
-
assert.equal(error.
|
|
76
|
+
assert.equal(error.status, 400, 'has the error code')
|
|
77
77
|
assert.equal(error.message, 'Invalid request', 'has the message')
|
|
78
|
-
assert.equal(error.
|
|
78
|
+
assert.equal(error.help, 'The "options" parameter is required.', 'has the detail')
|
|
79
79
|
assert.isFalse(scope.isDone(), 'did not call the store')
|
|
80
80
|
})
|
|
81
81
|
|
|
@@ -89,15 +89,15 @@ test.group('net-store project', (group) => {
|
|
|
89
89
|
const path = RouteBuilder.fileMedia(message.organization, project.key)
|
|
90
90
|
const scope = nock(storeHostname).get(path).reply(200, project.toJSON())
|
|
91
91
|
const service = new ProxyService()
|
|
92
|
-
let error:
|
|
92
|
+
let error: Exception
|
|
93
93
|
try {
|
|
94
94
|
await service.proxyHttpProject(message, '', storeUri)
|
|
95
|
-
error = new
|
|
95
|
+
error = new Exception('Not thrown', { status: 0 })
|
|
96
96
|
} catch (e) {
|
|
97
|
-
error = e as
|
|
97
|
+
error = e as Exception
|
|
98
98
|
}
|
|
99
99
|
assert.equal(error.message, 'Invalid request', 'has the message')
|
|
100
|
-
assert.equal(error.
|
|
100
|
+
assert.equal(error.help, 'Set the authentication credentials.', 'has the detail')
|
|
101
101
|
assert.isFalse(scope.isDone(), 'did not call the store')
|
|
102
102
|
})
|
|
103
103
|
|
|
@@ -111,16 +111,16 @@ test.group('net-store project', (group) => {
|
|
|
111
111
|
const path = RouteBuilder.fileMedia(message.organization, project.key)
|
|
112
112
|
const scope = nock(storeHostname).get(path).reply(200, project.toJSON())
|
|
113
113
|
const service = new ProxyService()
|
|
114
|
-
let error:
|
|
114
|
+
let error: Exception
|
|
115
115
|
try {
|
|
116
116
|
await service.proxyHttpProject(message, token, '')
|
|
117
|
-
error = new
|
|
117
|
+
error = new Exception('Not thrown', { status: 0 })
|
|
118
118
|
} catch (e) {
|
|
119
|
-
error = e as
|
|
119
|
+
error = e as Exception
|
|
120
120
|
}
|
|
121
|
-
assert.equal(error.
|
|
121
|
+
assert.equal(error.status, 400, 'has the error code')
|
|
122
122
|
assert.equal(error.message, 'Invalid request', 'has the message')
|
|
123
|
-
assert.equal(error.
|
|
123
|
+
assert.equal(error.help, 'The store uri is missing.', 'has the detail')
|
|
124
124
|
assert.isFalse(scope.isDone(), 'did not call the store')
|
|
125
125
|
})
|
|
126
126
|
|
|
@@ -134,16 +134,16 @@ test.group('net-store project', (group) => {
|
|
|
134
134
|
const path = RouteBuilder.fileMedia(message.organization, project.key)
|
|
135
135
|
const scope = nock(storeHostname).get(path).reply(200, project.toJSON())
|
|
136
136
|
const service = new ProxyService()
|
|
137
|
-
let error:
|
|
137
|
+
let error: Exception
|
|
138
138
|
try {
|
|
139
139
|
await service.proxyHttpProject(message, token, 'test')
|
|
140
|
-
error = new
|
|
140
|
+
error = new Exception('Not thrown', { status: 0 })
|
|
141
141
|
} catch (e) {
|
|
142
|
-
error = e as
|
|
142
|
+
error = e as Exception
|
|
143
143
|
}
|
|
144
|
-
assert.equal(error.
|
|
144
|
+
assert.equal(error.status, 400, 'has the error code')
|
|
145
145
|
assert.equal(error.message, 'Invalid request', 'has the message')
|
|
146
|
-
assert.equal(error.
|
|
146
|
+
assert.equal(error.help, 'The store uri is invalid.', 'has the detail')
|
|
147
147
|
assert.isFalse(scope.isDone(), 'did not call the store')
|
|
148
148
|
})
|
|
149
149
|
|
|
@@ -155,16 +155,18 @@ test.group('net-store project', (group) => {
|
|
|
155
155
|
organization: nanoid(),
|
|
156
156
|
}
|
|
157
157
|
const path = RouteBuilder.fileMedia(message.organization, project.key)
|
|
158
|
-
nock(storeHostname)
|
|
158
|
+
nock(storeHostname)
|
|
159
|
+
.get(path)
|
|
160
|
+
.reply(404, new Exception('Not found', { status: 404 }).toJSON())
|
|
159
161
|
const service = new ProxyService()
|
|
160
|
-
let error:
|
|
162
|
+
let error: Exception
|
|
161
163
|
try {
|
|
162
164
|
await service.proxyHttpProject(message, token, storeUri)
|
|
163
|
-
error = new
|
|
165
|
+
error = new Exception('Not thrown', { status: 0 })
|
|
164
166
|
} catch (e) {
|
|
165
|
-
error = e as
|
|
167
|
+
error = e as Exception
|
|
166
168
|
}
|
|
167
|
-
assert.equal(error.
|
|
169
|
+
assert.equal(error.status, 400, 'has the error code')
|
|
168
170
|
assert.equal(error.message, 'Not found', 'has the message')
|
|
169
171
|
})
|
|
170
172
|
|
|
@@ -214,16 +216,16 @@ test.group('local project', (group) => {
|
|
|
214
216
|
project: project.toJSON(),
|
|
215
217
|
} as IHttpProjectProxyInit
|
|
216
218
|
const service = new ProxyService()
|
|
217
|
-
let error:
|
|
219
|
+
let error: Exception
|
|
218
220
|
try {
|
|
219
221
|
await service.proxyHttpProject(message)
|
|
220
|
-
error = new
|
|
222
|
+
error = new Exception('Not thrown', { status: 0 })
|
|
221
223
|
} catch (e) {
|
|
222
|
-
error = e as
|
|
224
|
+
error = e as Exception
|
|
223
225
|
}
|
|
224
|
-
assert.equal(error.
|
|
226
|
+
assert.equal(error.status, 400, 'has the error code')
|
|
225
227
|
assert.equal(error.message, 'Invalid request', 'has the message')
|
|
226
|
-
assert.equal(error.
|
|
228
|
+
assert.equal(error.help, 'The "options" parameter is required.', 'has the detail')
|
|
227
229
|
})
|
|
228
230
|
|
|
229
231
|
test('returns an error when no project', async ({ assert }) => {
|
|
@@ -232,15 +234,15 @@ test.group('local project', (group) => {
|
|
|
232
234
|
options: {},
|
|
233
235
|
} as IHttpProjectProxyInit
|
|
234
236
|
const service = new ProxyService()
|
|
235
|
-
let error:
|
|
237
|
+
let error: Exception
|
|
236
238
|
try {
|
|
237
239
|
await service.proxyHttpProject(message)
|
|
238
|
-
error = new
|
|
240
|
+
error = new Exception('Not thrown', { status: 0 })
|
|
239
241
|
} catch (e) {
|
|
240
|
-
error = e as
|
|
242
|
+
error = e as Exception
|
|
241
243
|
}
|
|
242
|
-
assert.equal(error.
|
|
244
|
+
assert.equal(error.status, 400, 'has the error code')
|
|
243
245
|
assert.equal(error.message, 'Invalid request', 'has the message')
|
|
244
|
-
assert.equal(error.
|
|
246
|
+
assert.equal(error.help, 'The "project" parameter is required.', 'has the detail')
|
|
245
247
|
})
|
|
246
248
|
})
|
|
@@ -5,7 +5,7 @@ import {
|
|
|
5
5
|
RequestLog,
|
|
6
6
|
IBasicAuthorization,
|
|
7
7
|
ProxyService,
|
|
8
|
-
|
|
8
|
+
Exception,
|
|
9
9
|
SetDataStep,
|
|
10
10
|
SetVariableStep,
|
|
11
11
|
} from '../../../../src/index.js'
|
|
@@ -28,34 +28,34 @@ test.group('RequestProxy', (group) => {
|
|
|
28
28
|
// @ts-expect-error Used in testing
|
|
29
29
|
delete message.request
|
|
30
30
|
const service = new ProxyService()
|
|
31
|
-
let error:
|
|
31
|
+
let error: Exception
|
|
32
32
|
try {
|
|
33
33
|
await service.proxyRequest(message)
|
|
34
|
-
error = new
|
|
34
|
+
error = new Exception('Not thrown', { status: 0 })
|
|
35
35
|
} catch (e) {
|
|
36
|
-
error = e as
|
|
36
|
+
error = e as Exception
|
|
37
37
|
}
|
|
38
38
|
assert.ok(error, 'has the error')
|
|
39
|
-
assert.equal(error.
|
|
39
|
+
assert.equal(error.status, 400, 'has the error code')
|
|
40
40
|
assert.equal(error.message, 'Invalid request', 'has the message')
|
|
41
|
-
assert.equal(error.
|
|
41
|
+
assert.equal(error.help, 'The "request" parameter is required.')
|
|
42
42
|
})
|
|
43
43
|
|
|
44
44
|
test('returns an error when the request has no URL', async ({ assert }) => {
|
|
45
45
|
// @ts-expect-error Used in testing
|
|
46
46
|
delete message.request.url
|
|
47
|
-
let error:
|
|
47
|
+
let error: Exception
|
|
48
48
|
const service = new ProxyService()
|
|
49
49
|
try {
|
|
50
50
|
await service.proxyRequest(message)
|
|
51
|
-
error = new
|
|
51
|
+
error = new Exception('Not thrown', { status: 0 })
|
|
52
52
|
} catch (e) {
|
|
53
|
-
error = e as
|
|
53
|
+
error = e as Exception
|
|
54
54
|
}
|
|
55
55
|
assert.ok(error, 'has the error')
|
|
56
|
-
assert.equal(error.
|
|
56
|
+
assert.equal(error.status, 400, 'has the error code')
|
|
57
57
|
assert.equal(error.message, 'Invalid request', 'has the message')
|
|
58
|
-
assert.equal(error.
|
|
58
|
+
assert.equal(error.help, 'The "request.url" parameter is required.')
|
|
59
59
|
})
|
|
60
60
|
|
|
61
61
|
test('proxies a GET request', async ({ assert }) => {
|
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
import { SerializableError, ISerializedError } from '../../models/SerializableError.js';
|
|
2
|
-
export interface IApiError {
|
|
3
|
-
/**
|
|
4
|
-
* Indicates the response is an error.
|
|
5
|
-
*/
|
|
6
|
-
error: boolean;
|
|
7
|
-
/**
|
|
8
|
-
* The same as the status code but returned with the body.
|
|
9
|
-
*/
|
|
10
|
-
code: number;
|
|
11
|
-
/**
|
|
12
|
-
* The human-readable error message
|
|
13
|
-
*/
|
|
14
|
-
message: string;
|
|
15
|
-
/**
|
|
16
|
-
* The detailed message about the error, if any.
|
|
17
|
-
*/
|
|
18
|
-
detail?: string;
|
|
19
|
-
}
|
|
20
|
-
export declare class ApiError {
|
|
21
|
-
readonly name = "ApiError";
|
|
22
|
-
code: number;
|
|
23
|
-
message: string;
|
|
24
|
-
detail?: string;
|
|
25
|
-
constructor(message: string, code: number);
|
|
26
|
-
constructor(init: IApiError);
|
|
27
|
-
toJSON(): IApiError;
|
|
28
|
-
toString(): string;
|
|
29
|
-
}
|
|
30
|
-
export interface ISdkError extends ISerializedError {
|
|
31
|
-
/**
|
|
32
|
-
* The raw response from the server.
|
|
33
|
-
*/
|
|
34
|
-
response?: string;
|
|
35
|
-
/**
|
|
36
|
-
* Optional detailed message returned by the server.
|
|
37
|
-
*/
|
|
38
|
-
detail?: string;
|
|
39
|
-
}
|
|
40
|
-
export declare class SdkError extends SerializableError {
|
|
41
|
-
/**
|
|
42
|
-
* The raw response from the server.
|
|
43
|
-
*/
|
|
44
|
-
response?: string;
|
|
45
|
-
/**
|
|
46
|
-
* Optional detailed message returned by the server.
|
|
47
|
-
*/
|
|
48
|
-
detail?: string;
|
|
49
|
-
toJSON(): ISdkError;
|
|
50
|
-
}
|
|
51
|
-
//# sourceMappingURL=Errors.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"Errors.d.ts","sourceRoot":"","sources":["../../../../src/runtime/store/Errors.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,gBAAgB,EAAE,MAAM,mCAAmC,CAAA;AAEvF,MAAM,WAAW,SAAS;IACxB;;OAEG;IACH,KAAK,EAAE,OAAO,CAAA;IACd;;OAEG;IACH,IAAI,EAAE,MAAM,CAAA;IACZ;;OAEG;IACH,OAAO,EAAE,MAAM,CAAA;IACf;;OAEG;IACH,MAAM,CAAC,EAAE,MAAM,CAAA;CAChB;AAED,qBAAa,QAAQ;IACnB,QAAQ,CAAC,IAAI,cAAa;IAE1B,IAAI,EAAE,MAAM,CAAA;IACZ,OAAO,EAAE,MAAM,CAAA;IACf,MAAM,CAAC,EAAE,MAAM,CAAA;gBAEH,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM;gBAC7B,IAAI,EAAE,SAAS;IAmB3B,MAAM,IAAI,SAAS;IAanB,QAAQ,IAAI,MAAM;CAGnB;AAED,MAAM,WAAW,SAAU,SAAQ,gBAAgB;IACjD;;OAEG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB;;OAEG;IACH,MAAM,CAAC,EAAE,MAAM,CAAA;CAChB;AAED,qBAAa,QAAS,SAAQ,iBAAiB;IAC7C;;OAEG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB;;OAEG;IACH,MAAM,CAAC,EAAE,MAAM,CAAA;IAEN,MAAM,IAAI,SAAS;CAU7B"}
|
|
@@ -1,61 +0,0 @@
|
|
|
1
|
-
import { SerializableError } from '../../models/SerializableError.js';
|
|
2
|
-
export class ApiError {
|
|
3
|
-
name = 'ApiError';
|
|
4
|
-
code;
|
|
5
|
-
message;
|
|
6
|
-
detail;
|
|
7
|
-
constructor(messageOrInit, code) {
|
|
8
|
-
if (typeof messageOrInit === 'string') {
|
|
9
|
-
if (typeof code === 'number') {
|
|
10
|
-
this.code = code;
|
|
11
|
-
}
|
|
12
|
-
else {
|
|
13
|
-
this.code = 0;
|
|
14
|
-
}
|
|
15
|
-
this.message = messageOrInit;
|
|
16
|
-
}
|
|
17
|
-
else {
|
|
18
|
-
this.message = messageOrInit.message;
|
|
19
|
-
this.code = messageOrInit.code;
|
|
20
|
-
if (messageOrInit.detail) {
|
|
21
|
-
this.detail = messageOrInit.detail;
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
toJSON() {
|
|
26
|
-
const { message, code, detail } = this;
|
|
27
|
-
const result = {
|
|
28
|
-
error: true,
|
|
29
|
-
message,
|
|
30
|
-
code,
|
|
31
|
-
};
|
|
32
|
-
if (detail) {
|
|
33
|
-
result.detail = detail;
|
|
34
|
-
}
|
|
35
|
-
return result;
|
|
36
|
-
}
|
|
37
|
-
toString() {
|
|
38
|
-
return this.message;
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
export class SdkError extends SerializableError {
|
|
42
|
-
/**
|
|
43
|
-
* The raw response from the server.
|
|
44
|
-
*/
|
|
45
|
-
response;
|
|
46
|
-
/**
|
|
47
|
-
* Optional detailed message returned by the server.
|
|
48
|
-
*/
|
|
49
|
-
detail;
|
|
50
|
-
toJSON() {
|
|
51
|
-
const result = super.toJSON();
|
|
52
|
-
if (this.response) {
|
|
53
|
-
result.response = this.response;
|
|
54
|
-
}
|
|
55
|
-
if (this.detail) {
|
|
56
|
-
result.detail = this.detail;
|
|
57
|
-
}
|
|
58
|
-
return result;
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
//# sourceMappingURL=Errors.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"Errors.js","sourceRoot":"","sources":["../../../../src/runtime/store/Errors.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAoB,MAAM,mCAAmC,CAAA;AAqBvF,MAAM,OAAO,QAAQ;IACV,IAAI,GAAG,UAAU,CAAA;IAE1B,IAAI,CAAQ;IACZ,OAAO,CAAQ;IACf,MAAM,CAAS;IAKf,YAAY,aAAiC,EAAE,IAAa;QAC1D,IAAI,OAAO,aAAa,KAAK,QAAQ,EAAE,CAAC;YACtC,IAAI,OAAO,IAAI,KAAK,QAAQ,EAAE,CAAC;gBAC7B,IAAI,CAAC,IAAI,GAAG,IAAI,CAAA;YAClB,CAAC;iBAAM,CAAC;gBACN,IAAI,CAAC,IAAI,GAAG,CAAC,CAAA;YACf,CAAC;YACD,IAAI,CAAC,OAAO,GAAG,aAAa,CAAA;QAC9B,CAAC;aAAM,CAAC;YACN,IAAI,CAAC,OAAO,GAAG,aAAa,CAAC,OAAO,CAAA;YACpC,IAAI,CAAC,IAAI,GAAG,aAAa,CAAC,IAAI,CAAA;YAC9B,IAAI,aAAa,CAAC,MAAM,EAAE,CAAC;gBACzB,IAAI,CAAC,MAAM,GAAG,aAAa,CAAC,MAAM,CAAA;YACpC,CAAC;QACH,CAAC;IACH,CAAC;IAED,MAAM;QACJ,MAAM,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,GAAG,IAAI,CAAA;QACtC,MAAM,MAAM,GAAc;YACxB,KAAK,EAAE,IAAI;YACX,OAAO;YACP,IAAI;SACL,CAAA;QACD,IAAI,MAAM,EAAE,CAAC;YACX,MAAM,CAAC,MAAM,GAAG,MAAM,CAAA;QACxB,CAAC;QACD,OAAO,MAAM,CAAA;IACf,CAAC;IAED,QAAQ;QACN,OAAO,IAAI,CAAC,OAAO,CAAA;IACrB,CAAC;CACF;AAaD,MAAM,OAAO,QAAS,SAAQ,iBAAiB;IAC7C;;OAEG;IACH,QAAQ,CAAS;IACjB;;OAEG;IACH,MAAM,CAAS;IAEN,MAAM;QACb,MAAM,MAAM,GAAG,KAAK,CAAC,MAAM,EAAE,CAAA;QAC7B,IAAI,IAAI,CAAC,QAAQ,EAAE,CAAC;YAClB,MAAM,CAAC,QAAQ,GAAG,IAAI,CAAC,QAAQ,CAAA;QACjC,CAAC;QACD,IAAI,IAAI,CAAC,MAAM,EAAE,CAAC;YAChB,MAAM,CAAC,MAAM,GAAG,IAAI,CAAC,MAAM,CAAA;QAC7B,CAAC;QACD,OAAO,MAAM,CAAA;IACf,CAAC;CACF","sourcesContent":["import { SerializableError, ISerializedError } from '../../models/SerializableError.js'\n\nexport interface IApiError {\n /**\n * Indicates the response is an error.\n */\n error: boolean\n /**\n * The same as the status code but returned with the body.\n */\n code: number\n /**\n * The human-readable error message\n */\n message: string\n /**\n * The detailed message about the error, if any.\n */\n detail?: string\n}\n\nexport class ApiError {\n readonly name = 'ApiError'\n\n code: number\n message: string\n detail?: string\n\n constructor(message: string, code: number)\n constructor(init: IApiError)\n\n constructor(messageOrInit: string | IApiError, code?: number) {\n if (typeof messageOrInit === 'string') {\n if (typeof code === 'number') {\n this.code = code\n } else {\n this.code = 0\n }\n this.message = messageOrInit\n } else {\n this.message = messageOrInit.message\n this.code = messageOrInit.code\n if (messageOrInit.detail) {\n this.detail = messageOrInit.detail\n }\n }\n }\n\n toJSON(): IApiError {\n const { message, code, detail } = this\n const result: IApiError = {\n error: true,\n message,\n code,\n }\n if (detail) {\n result.detail = detail\n }\n return result\n }\n\n toString(): string {\n return this.message\n }\n}\n\nexport interface ISdkError extends ISerializedError {\n /**\n * The raw response from the server.\n */\n response?: string\n /**\n * Optional detailed message returned by the server.\n */\n detail?: string\n}\n\nexport class SdkError extends SerializableError {\n /**\n * The raw response from the server.\n */\n response?: string\n /**\n * Optional detailed message returned by the server.\n */\n detail?: string\n\n override toJSON(): ISdkError {\n const result = super.toJSON()\n if (this.response) {\n result.response = this.response\n }\n if (this.detail) {\n result.detail = this.detail\n }\n return result\n }\n}\n"]}
|
|
@@ -1,98 +0,0 @@
|
|
|
1
|
-
import { SerializableError, ISerializedError } from '../../models/SerializableError.js'
|
|
2
|
-
|
|
3
|
-
export interface IApiError {
|
|
4
|
-
/**
|
|
5
|
-
* Indicates the response is an error.
|
|
6
|
-
*/
|
|
7
|
-
error: boolean
|
|
8
|
-
/**
|
|
9
|
-
* The same as the status code but returned with the body.
|
|
10
|
-
*/
|
|
11
|
-
code: number
|
|
12
|
-
/**
|
|
13
|
-
* The human-readable error message
|
|
14
|
-
*/
|
|
15
|
-
message: string
|
|
16
|
-
/**
|
|
17
|
-
* The detailed message about the error, if any.
|
|
18
|
-
*/
|
|
19
|
-
detail?: string
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
export class ApiError {
|
|
23
|
-
readonly name = 'ApiError'
|
|
24
|
-
|
|
25
|
-
code: number
|
|
26
|
-
message: string
|
|
27
|
-
detail?: string
|
|
28
|
-
|
|
29
|
-
constructor(message: string, code: number)
|
|
30
|
-
constructor(init: IApiError)
|
|
31
|
-
|
|
32
|
-
constructor(messageOrInit: string | IApiError, code?: number) {
|
|
33
|
-
if (typeof messageOrInit === 'string') {
|
|
34
|
-
if (typeof code === 'number') {
|
|
35
|
-
this.code = code
|
|
36
|
-
} else {
|
|
37
|
-
this.code = 0
|
|
38
|
-
}
|
|
39
|
-
this.message = messageOrInit
|
|
40
|
-
} else {
|
|
41
|
-
this.message = messageOrInit.message
|
|
42
|
-
this.code = messageOrInit.code
|
|
43
|
-
if (messageOrInit.detail) {
|
|
44
|
-
this.detail = messageOrInit.detail
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
toJSON(): IApiError {
|
|
50
|
-
const { message, code, detail } = this
|
|
51
|
-
const result: IApiError = {
|
|
52
|
-
error: true,
|
|
53
|
-
message,
|
|
54
|
-
code,
|
|
55
|
-
}
|
|
56
|
-
if (detail) {
|
|
57
|
-
result.detail = detail
|
|
58
|
-
}
|
|
59
|
-
return result
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
toString(): string {
|
|
63
|
-
return this.message
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
export interface ISdkError extends ISerializedError {
|
|
68
|
-
/**
|
|
69
|
-
* The raw response from the server.
|
|
70
|
-
*/
|
|
71
|
-
response?: string
|
|
72
|
-
/**
|
|
73
|
-
* Optional detailed message returned by the server.
|
|
74
|
-
*/
|
|
75
|
-
detail?: string
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
export class SdkError extends SerializableError {
|
|
79
|
-
/**
|
|
80
|
-
* The raw response from the server.
|
|
81
|
-
*/
|
|
82
|
-
response?: string
|
|
83
|
-
/**
|
|
84
|
-
* Optional detailed message returned by the server.
|
|
85
|
-
*/
|
|
86
|
-
detail?: string
|
|
87
|
-
|
|
88
|
-
override toJSON(): ISdkError {
|
|
89
|
-
const result = super.toJSON()
|
|
90
|
-
if (this.response) {
|
|
91
|
-
result.response = this.response
|
|
92
|
-
}
|
|
93
|
-
if (this.detail) {
|
|
94
|
-
result.detail = this.detail
|
|
95
|
-
}
|
|
96
|
-
return result
|
|
97
|
-
}
|
|
98
|
-
}
|