@kravc/dos 1.11.12 → 1.11.14
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/package.json +1 -1
- package/src/Service.spec.js +4 -3
- package/src/index.d.ts +37 -0
- package/src/index.js +23 -16
package/package.json
CHANGED
package/src/Service.spec.js
CHANGED
|
@@ -12,10 +12,11 @@ const IndexProfiles = require('examples/IndexProfiles')
|
|
|
12
12
|
|
|
13
13
|
const test = require('src/test')
|
|
14
14
|
const {
|
|
15
|
-
errors,
|
|
16
15
|
Create,
|
|
17
16
|
Service,
|
|
18
17
|
Component,
|
|
18
|
+
InvalidParametersError,
|
|
19
|
+
UnprocessibleConditionError,
|
|
19
20
|
} = require('src')
|
|
20
21
|
|
|
21
22
|
const testSchema = new Schema({
|
|
@@ -145,7 +146,7 @@ describe('Service', () => {
|
|
|
145
146
|
it('returns "InvalidParametersError / 400" if invalid parameters', async () => {
|
|
146
147
|
class InvalidIndexProfiles extends IndexProfiles {
|
|
147
148
|
action() {
|
|
148
|
-
throw new
|
|
149
|
+
throw new InvalidParametersError()
|
|
149
150
|
}
|
|
150
151
|
}
|
|
151
152
|
|
|
@@ -166,7 +167,7 @@ describe('Service', () => {
|
|
|
166
167
|
it('returns "UnprocessibleConditionError / 422" if unprocessible condition', async () => {
|
|
167
168
|
class InvalidIndexProfiles extends IndexProfiles {
|
|
168
169
|
action() {
|
|
169
|
-
throw new
|
|
170
|
+
throw new UnprocessibleConditionError()
|
|
170
171
|
}
|
|
171
172
|
}
|
|
172
173
|
|
package/src/index.d.ts
CHANGED
|
@@ -283,3 +283,40 @@ export declare function execute(service: Service, extraContext?: Record<string,
|
|
|
283
283
|
errorName: string
|
|
284
284
|
) => Promise<OperationError>;
|
|
285
285
|
}
|
|
286
|
+
|
|
287
|
+
export declare class CommonError extends Error {
|
|
288
|
+
constructor(code: string, message: string);
|
|
289
|
+
get code(): string;
|
|
290
|
+
get isCommonError(): boolean;
|
|
291
|
+
};
|
|
292
|
+
|
|
293
|
+
export declare class UnauthorizedError extends CommonError {
|
|
294
|
+
constructor(message: string);
|
|
295
|
+
};
|
|
296
|
+
|
|
297
|
+
export declare class AccessDeniedError extends CommonError {
|
|
298
|
+
constructor(message: string);
|
|
299
|
+
};
|
|
300
|
+
|
|
301
|
+
export declare class InvalidParametersError extends CommonError {
|
|
302
|
+
constructor(message: string)
|
|
303
|
+
};
|
|
304
|
+
|
|
305
|
+
export declare class UnprocessibleConditionError extends CommonError {
|
|
306
|
+
constructor(message: string)
|
|
307
|
+
};
|
|
308
|
+
|
|
309
|
+
export declare class DocumentExistsError extends CommonError {
|
|
310
|
+
constructor(Document: { name: string }, parameters: Record<string, unknown>);
|
|
311
|
+
};
|
|
312
|
+
|
|
313
|
+
export declare class DocumentNotFoundError extends CommonError {
|
|
314
|
+
constructor(Document: { name: string }, parameters: Record<string, unknown>);
|
|
315
|
+
};
|
|
316
|
+
|
|
317
|
+
interface Identity {
|
|
318
|
+
sub: string;
|
|
319
|
+
email: string;
|
|
320
|
+
}
|
|
321
|
+
|
|
322
|
+
export declare function authorize(Operation, Context): Promise<Identity>;
|
package/src/index.js
CHANGED
|
@@ -3,22 +3,29 @@
|
|
|
3
3
|
const { wait, execute, createAccessToken } = require('./test')
|
|
4
4
|
|
|
5
5
|
module.exports = {
|
|
6
|
-
Document:
|
|
7
|
-
Operation:
|
|
8
|
-
Service:
|
|
9
|
-
Read:
|
|
10
|
-
Index:
|
|
11
|
-
Create:
|
|
12
|
-
Update:
|
|
13
|
-
Delete:
|
|
14
|
-
Component:
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
verifyToken:
|
|
20
|
-
JwtAuthorization:
|
|
21
|
-
SystemAuthorization:
|
|
6
|
+
Document: require('./Document'),
|
|
7
|
+
Operation: require('./Operation'),
|
|
8
|
+
Service: require('./Service'),
|
|
9
|
+
Read: require('./operations/Read'),
|
|
10
|
+
Index: require('./operations/Index'),
|
|
11
|
+
Create: require('./operations/Create'),
|
|
12
|
+
Update: require('./operations/Update'),
|
|
13
|
+
Delete: require('./operations/Delete'),
|
|
14
|
+
Component: require('./Component'),
|
|
15
|
+
handler: require('./helpers/handler'),
|
|
16
|
+
getOrFail: require('./helpers/getOrFail'),
|
|
17
|
+
authorize: require('./helpers/authorize'),
|
|
18
|
+
security: require('./security'),
|
|
19
|
+
verifyToken: require('./security/verifyToken'),
|
|
20
|
+
JwtAuthorization: require('./security/JwtAuthorization'),
|
|
21
|
+
SystemAuthorization: require('./security/SystemAuthorization'),
|
|
22
|
+
CommonError: require('./errors/CommonError'),
|
|
23
|
+
UnauthorizedError: require('./errors/UnauthorizedError'),
|
|
24
|
+
AccessDeniedError: require('./errors/AccessDeniedError'),
|
|
25
|
+
DocumentExistsError: require('./errors/DocumentExistsError'),
|
|
26
|
+
DocumentNotFoundError: require('./errors/DocumentNotFoundError'),
|
|
27
|
+
InvalidParametersError: require('./errors/InvalidParametersError'),
|
|
28
|
+
UnprocessibleConditionError: require('./errors/UnprocessibleConditionError'),
|
|
22
29
|
wait,
|
|
23
30
|
execute,
|
|
24
31
|
createAccessToken,
|