@nomalism-com/types 0.34.13 → 0.34.15
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/dist/index.cjs +133 -162
- package/dist/index.js +133 -162
- package/dist/modules/user/storeOperator/interface.d.ts +11 -53
- package/dist/modules/user/storeOperator/route.schema.d.ts +1 -4
- package/dist/shared/interface.d.ts +2 -14
- package/package-lock.json +340 -276
- package/package.json +1 -1
- package/src/modules/user/storeOperator/interface.ts +13 -86
- package/src/modules/user/storeOperator/route.schema.ts +13 -64
- package/src/shared/interface.ts +2 -6
package/package.json
CHANGED
|
@@ -1,87 +1,24 @@
|
|
|
1
|
-
import * as IShared from '../../../shared/interface';
|
|
2
|
-
import {
|
|
3
|
-
StoreOperator,
|
|
4
|
-
Users,
|
|
5
|
-
ReasonForExemption,
|
|
6
|
-
UserPositions,
|
|
7
|
-
Language,
|
|
8
|
-
type Persona,
|
|
9
|
-
type Country,
|
|
10
|
-
} from '../../../shared/entities/user';
|
|
11
|
-
import type { IChatType } from '../../stock/chat/interfaces';
|
|
1
|
+
import type * as IShared from '../../../shared/interface';
|
|
2
|
+
import type { StoreOperator, Users, Persona } from '../../../shared/entities/user';
|
|
12
3
|
|
|
13
4
|
export type Entity = StoreOperator;
|
|
14
5
|
export const Route = 'store_operator';
|
|
15
6
|
export const UpperName = 'StoreOperator';
|
|
16
7
|
export const LowerName = UpperName[0].toLowerCase() + UpperName.substring(1);
|
|
17
8
|
|
|
18
|
-
interface
|
|
19
|
-
|
|
20
|
-
|
|
9
|
+
export interface IFindResponse extends Pick<Entity, 'id'> {
|
|
10
|
+
user: Pick<Users, 'id' | 'account'>;
|
|
11
|
+
main_persona: Pick<Persona, 'name' | 'email'>;
|
|
21
12
|
}
|
|
22
13
|
|
|
23
|
-
interface IFindDetailedResponse extends Entity {
|
|
24
|
-
user: Users;
|
|
25
|
-
support_language: Language | null;
|
|
26
|
-
user_position: UserPositions | null;
|
|
27
|
-
main_persona: IMainPersona;
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
// omit any unnecessary fields
|
|
31
|
-
export type IFindByIdResponse = Omit<IFindDetailedResponse, ''>;
|
|
32
|
-
|
|
33
|
-
// omit any unnecessary fields
|
|
34
|
-
export type IFindByOwnerIdResponse = Omit<
|
|
35
|
-
IFindDetailedResponse,
|
|
36
|
-
'user' | 'support_language' | 'user_position' | 'main_persona'
|
|
37
|
-
>;
|
|
38
|
-
|
|
39
|
-
export type IFindRequest = Record<string, unknown>;
|
|
40
|
-
|
|
41
|
-
// omit any unnecessary fields
|
|
42
|
-
export type IFindResponse = Omit<IFindDetailedResponse, ''>;
|
|
43
|
-
|
|
44
|
-
export interface IFindPaginatedRequest extends IFindRequest, IShared.IPaginationRequest {}
|
|
45
|
-
|
|
46
|
-
export type IFindWithPaginationResponse = IShared.IPaginationResponse<
|
|
47
|
-
Omit<IFindDetailedResponse, ''>
|
|
48
|
-
>;
|
|
49
|
-
|
|
50
14
|
export type ICreateMainPersona = Pick<Persona, 'nif' | 'name' | 'email' | 'telephone'>;
|
|
51
15
|
|
|
52
16
|
export interface ICreateRequest {
|
|
53
|
-
// create fields
|
|
54
17
|
user_id: string;
|
|
55
|
-
user_position_id?: string | null;
|
|
56
|
-
location_id: string;
|
|
57
|
-
internal_email?: string | null;
|
|
58
|
-
support_language_id?: string | null;
|
|
59
18
|
main_persona: ICreateMainPersona;
|
|
60
19
|
}
|
|
61
20
|
|
|
62
21
|
export interface IUpdateRequest {
|
|
63
|
-
// updatable fields
|
|
64
|
-
chat_type?: IChatType;
|
|
65
|
-
inactive?: boolean;
|
|
66
|
-
pin?: string;
|
|
67
|
-
old_pin?: string;
|
|
68
|
-
user_position_id?: string;
|
|
69
|
-
location_id?: string;
|
|
70
|
-
internal_email?: string | null;
|
|
71
|
-
support_language_id?: string | null;
|
|
72
|
-
main_persona_id?: string;
|
|
73
|
-
contact_persona_id?: string;
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
export interface ICheckPinRequest {
|
|
77
|
-
conference_pin: string;
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
export interface IFindUnique {
|
|
81
|
-
user_id: string;
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
export interface IStoreOperatorUpdateRequest {
|
|
85
22
|
name: string | null;
|
|
86
23
|
account: string | null;
|
|
87
24
|
email: string | null;
|
|
@@ -89,25 +26,15 @@ export interface IStoreOperatorUpdateRequest {
|
|
|
89
26
|
inactive: boolean;
|
|
90
27
|
}
|
|
91
28
|
export interface IRepository {
|
|
92
|
-
|
|
93
|
-
checkPin(data: ICheckPinRequest): Promise<IFindResponse | null>;
|
|
94
|
-
findUnique(data: IFindUnique): Promise<IFindResponse | null>;
|
|
95
|
-
|
|
96
|
-
findByOwnerId(params: IShared.IFindByOwnerIdRequest): Promise<IFindByOwnerIdResponse[]>;
|
|
29
|
+
findByOwnerId(params: IShared.IFindByOwnerIdRequest): Promise<IFindResponse[]>;
|
|
97
30
|
findMinified(params?: IShared.IFindMinifiedRequest): Promise<IShared.IFindMinifiedResponse[]>;
|
|
98
|
-
find(
|
|
99
|
-
findPaginated(
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
updateStoreOperator(
|
|
106
|
-
selector: IShared.IFindByIdRequest,
|
|
107
|
-
data: IStoreOperatorUpdateRequest,
|
|
108
|
-
): Promise<void>;
|
|
31
|
+
find(): Promise<IFindResponse[]>;
|
|
32
|
+
findPaginated(
|
|
33
|
+
selector: IShared.IPaginationRequest,
|
|
34
|
+
): Promise<IShared.IPaginationResponse<IFindResponse>>;
|
|
35
|
+
create(data: ICreateRequest): Promise<string>;
|
|
36
|
+
update(selector: IShared.IFindByIdRequest, data: IUpdateRequest): Promise<void>;
|
|
37
|
+
deleteOne(selector: IShared.IFindByIdRequest): Promise<void>;
|
|
109
38
|
}
|
|
110
39
|
|
|
111
40
|
export type IController = IShared.IEntityWithUserToken<IRepository>;
|
|
112
|
-
|
|
113
|
-
export type IApi = Omit<IRepository, 'findUnique'>;
|
|
@@ -1,16 +1,7 @@
|
|
|
1
1
|
import joi from 'joi';
|
|
2
2
|
import { messages } from '../../../shared/messages';
|
|
3
|
-
import * as IShared from '../../../shared/interface';
|
|
4
|
-
import {
|
|
5
|
-
IFindRequest,
|
|
6
|
-
IFindPaginatedRequest,
|
|
7
|
-
ICreateRequest,
|
|
8
|
-
IUpdateRequest,
|
|
9
|
-
ICheckPinRequest,
|
|
10
|
-
type ICreateMainPersona,
|
|
11
|
-
IStoreOperatorUpdateRequest,
|
|
12
|
-
} from './interface';
|
|
13
|
-
import { chatTypes } from '../../stock/chat/interfaces';
|
|
3
|
+
import type * as IShared from '../../../shared/interface';
|
|
4
|
+
import type { ICreateRequest, ICreateMainPersona, IUpdateRequest } from './interface';
|
|
14
5
|
|
|
15
6
|
const createMainPersonaKeys: IShared.IRouteRequest<ICreateMainPersona> = {
|
|
16
7
|
name: joi.string().optional(),
|
|
@@ -26,64 +17,12 @@ const createMainPersonaKeys: IShared.IRouteRequest<ICreateMainPersona> = {
|
|
|
26
17
|
// create body validation
|
|
27
18
|
const createBodyKeys: IShared.IRouteRequest<ICreateRequest> = {
|
|
28
19
|
user_id: joi.string().uuid().required(),
|
|
29
|
-
user_position_id: joi.string().uuid().allow(null).optional(),
|
|
30
|
-
location_id: joi.string().uuid().required(),
|
|
31
|
-
internal_email: joi
|
|
32
|
-
.string()
|
|
33
|
-
.email({ tlds: { allow: false } })
|
|
34
|
-
.optional(),
|
|
35
|
-
support_language_id: joi.string().uuid().allow(null).optional(),
|
|
36
20
|
main_persona: joi.object().keys(createMainPersonaKeys).required(),
|
|
37
21
|
};
|
|
38
22
|
export const createBody = joi.object().keys(createBodyKeys).messages(messages);
|
|
39
23
|
|
|
40
|
-
// update body validation
|
|
41
|
-
const updateBodyKeys: IShared.IRouteRequest<IUpdateRequest> = {
|
|
42
|
-
chat_type: joi
|
|
43
|
-
.string()
|
|
44
|
-
.valid(...chatTypes)
|
|
45
|
-
.optional(),
|
|
46
|
-
old_pin: joi.string().optional(),
|
|
47
|
-
pin: joi
|
|
48
|
-
.when('old_pin', {
|
|
49
|
-
is: joi.exist(),
|
|
50
|
-
then: joi.required(),
|
|
51
|
-
})
|
|
52
|
-
.optional(),
|
|
53
|
-
inactive: joi.boolean().optional(),
|
|
54
|
-
internal_email: joi
|
|
55
|
-
.string()
|
|
56
|
-
.email({ tlds: { allow: false } })
|
|
57
|
-
.optional(),
|
|
58
|
-
location_id: joi.string().uuid().optional(),
|
|
59
|
-
user_position_id: joi.string().uuid().allow(null).optional(),
|
|
60
|
-
support_language_id: joi.string().uuid().allow(null).optional(),
|
|
61
|
-
main_persona_id: joi.string().uuid().optional(),
|
|
62
|
-
contact_persona_id: joi.string().uuid().optional(),
|
|
63
|
-
};
|
|
64
|
-
export const updateBody = joi.object().keys(updateBodyKeys).messages(messages);
|
|
65
|
-
|
|
66
|
-
const checkPinBodyKeys: IShared.IRouteRequest<Omit<ICheckPinRequest, 'logged_user_id'>> = {
|
|
67
|
-
conference_pin: joi.string().required(),
|
|
68
|
-
};
|
|
69
|
-
|
|
70
|
-
export const checkPinBody = joi.object().keys(checkPinBodyKeys).messages(messages);
|
|
71
|
-
|
|
72
|
-
const findQueryKeys: IShared.IRouteRequest<IFindRequest> = {};
|
|
73
|
-
export const findQuery = joi.object().keys(findQueryKeys).messages(messages);
|
|
74
|
-
|
|
75
|
-
// find with pagination query validation
|
|
76
|
-
const findWithPaginationQueryKeys: IShared.IRouteRequest<IFindPaginatedRequest> = {
|
|
77
|
-
per_page: joi.number().integer().positive().default(10).optional(),
|
|
78
|
-
current_page: joi.number().integer().positive().default(1).optional(),
|
|
79
|
-
};
|
|
80
|
-
export const findWithPaginationQuery = joi
|
|
81
|
-
.object()
|
|
82
|
-
.keys(findWithPaginationQueryKeys)
|
|
83
|
-
.messages(messages);
|
|
84
|
-
|
|
85
24
|
// update store operator query validation
|
|
86
|
-
const updateStoreOperatorQueryKeys: IShared.IRouteRequest<
|
|
25
|
+
const updateStoreOperatorQueryKeys: IShared.IRouteRequest<IUpdateRequest> = {
|
|
87
26
|
name: joi.string().allow(null, '').optional(),
|
|
88
27
|
account: joi.string().allow(null, '').optional(),
|
|
89
28
|
email: joi
|
|
@@ -102,3 +41,13 @@ export const updateStoreOperatorQuery = joi
|
|
|
102
41
|
.object()
|
|
103
42
|
.keys(updateStoreOperatorQueryKeys)
|
|
104
43
|
.messages(messages);
|
|
44
|
+
|
|
45
|
+
// find with pagination query validation
|
|
46
|
+
const findWithPaginationQueryKeys: IShared.IRouteRequest<IShared.IPaginationRequest> = {
|
|
47
|
+
per_page: joi.number().integer().positive().default(10).optional(),
|
|
48
|
+
current_page: joi.number().integer().positive().default(1).optional(),
|
|
49
|
+
};
|
|
50
|
+
export const findWithPaginationQuery = joi
|
|
51
|
+
.object()
|
|
52
|
+
.keys(findWithPaginationQueryKeys)
|
|
53
|
+
.messages(messages);
|
package/src/shared/interface.ts
CHANGED
|
@@ -24,6 +24,7 @@ import type {
|
|
|
24
24
|
IStock,
|
|
25
25
|
ITask,
|
|
26
26
|
} from '../modules/view/adminPanel/interfaces';
|
|
27
|
+
import type * as ErrorLog from '../modules/view/errorLog/interfaces';
|
|
27
28
|
|
|
28
29
|
export { messages };
|
|
29
30
|
|
|
@@ -467,12 +468,7 @@ export type IBrokerTopicPayload = {
|
|
|
467
468
|
output?: unknown;
|
|
468
469
|
done: boolean;
|
|
469
470
|
};
|
|
470
|
-
[IBrokerTopic.error_log]:
|
|
471
|
-
service: string;
|
|
472
|
-
type: 'prisma' | 'unhandled' | 'axios' | 'webapp' | 'moloni';
|
|
473
|
-
error: { name: string; message: string; stack?: string };
|
|
474
|
-
request?: { body?: unknown; query?: unknown; params?: unknown };
|
|
475
|
-
};
|
|
471
|
+
[IBrokerTopic.error_log]: ErrorLog.ICreateRequest;
|
|
476
472
|
[IBrokerTopic.express_log]: {
|
|
477
473
|
id: string;
|
|
478
474
|
service: string;
|