datacenter-lib-common-ts 1.0.0

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 (99) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +4 -0
  3. package/dist/cjs/api/index.js +7 -0
  4. package/dist/cjs/api/index.js.map +1 -0
  5. package/dist/cjs/api/routes.js +19 -0
  6. package/dist/cjs/api/routes.js.map +1 -0
  7. package/dist/cjs/apiClient/authentications.js +22 -0
  8. package/dist/cjs/apiClient/authentications.js.map +1 -0
  9. package/dist/cjs/apiClient/authorizations.js +15 -0
  10. package/dist/cjs/apiClient/authorizations.js.map +1 -0
  11. package/dist/cjs/apiClient/legalPersons.js +15 -0
  12. package/dist/cjs/apiClient/legalPersons.js.map +1 -0
  13. package/dist/cjs/apiClient/users.js +15 -0
  14. package/dist/cjs/apiClient/users.js.map +1 -0
  15. package/dist/cjs/apiClient/usersGroups.js +15 -0
  16. package/dist/cjs/apiClient/usersGroups.js.map +1 -0
  17. package/dist/cjs/apiClient/usersGroups_invites.js +22 -0
  18. package/dist/cjs/apiClient/usersGroups_invites.js.map +1 -0
  19. package/dist/cjs/apiClient/usersSharedData.js +25 -0
  20. package/dist/cjs/apiClient/usersSharedData.js.map +1 -0
  21. package/dist/cjs/apiClient/users_groups.js +15 -0
  22. package/dist/cjs/apiClient/users_groups.js.map +1 -0
  23. package/dist/cjs/apiClient/workgroupUnits.js +15 -0
  24. package/dist/cjs/apiClient/workgroupUnits.js.map +1 -0
  25. package/dist/cjs/apiClient/workgroupUnitsTypes.js +15 -0
  26. package/dist/cjs/apiClient/workgroupUnitsTypes.js.map +1 -0
  27. package/dist/cjs/apiClient/workgroups.js +15 -0
  28. package/dist/cjs/apiClient/workgroups.js.map +1 -0
  29. package/dist/cjs/index.js +38 -0
  30. package/dist/cjs/index.js.map +1 -0
  31. package/dist/cjs/models/authorizations.js +12 -0
  32. package/dist/cjs/models/authorizations.js.map +1 -0
  33. package/dist/cjs/models/index.js +90 -0
  34. package/dist/cjs/models/index.js.map +1 -0
  35. package/dist/esm/api/index.js +4 -0
  36. package/dist/esm/api/index.js.map +1 -0
  37. package/dist/esm/api/routes.js +16 -0
  38. package/dist/esm/api/routes.js.map +1 -0
  39. package/dist/esm/apiClient/authentications.js +17 -0
  40. package/dist/esm/apiClient/authentications.js.map +1 -0
  41. package/dist/esm/apiClient/authorizations.js +11 -0
  42. package/dist/esm/apiClient/authorizations.js.map +1 -0
  43. package/dist/esm/apiClient/legalPersons.js +11 -0
  44. package/dist/esm/apiClient/legalPersons.js.map +1 -0
  45. package/dist/esm/apiClient/users.js +11 -0
  46. package/dist/esm/apiClient/users.js.map +1 -0
  47. package/dist/esm/apiClient/usersGroups.js +11 -0
  48. package/dist/esm/apiClient/usersGroups.js.map +1 -0
  49. package/dist/esm/apiClient/usersGroups_invites.js +18 -0
  50. package/dist/esm/apiClient/usersGroups_invites.js.map +1 -0
  51. package/dist/esm/apiClient/usersSharedData.js +20 -0
  52. package/dist/esm/apiClient/usersSharedData.js.map +1 -0
  53. package/dist/esm/apiClient/users_groups.js +11 -0
  54. package/dist/esm/apiClient/users_groups.js.map +1 -0
  55. package/dist/esm/apiClient/workgroupUnits.js +11 -0
  56. package/dist/esm/apiClient/workgroupUnits.js.map +1 -0
  57. package/dist/esm/apiClient/workgroupUnitsTypes.js +11 -0
  58. package/dist/esm/apiClient/workgroupUnitsTypes.js.map +1 -0
  59. package/dist/esm/apiClient/workgroups.js +11 -0
  60. package/dist/esm/apiClient/workgroups.js.map +1 -0
  61. package/dist/esm/index.js +22 -0
  62. package/dist/esm/index.js.map +1 -0
  63. package/dist/esm/models/authorizations.js +9 -0
  64. package/dist/esm/models/authorizations.js.map +1 -0
  65. package/dist/esm/models/index.js +85 -0
  66. package/dist/esm/models/index.js.map +1 -0
  67. package/dist/types/api/index.d.ts +10 -0
  68. package/dist/types/api/routes.d.ts +15 -0
  69. package/dist/types/apiClient/authentications.d.ts +15 -0
  70. package/dist/types/apiClient/authorizations.d.ts +10 -0
  71. package/dist/types/apiClient/legalPersons.d.ts +10 -0
  72. package/dist/types/apiClient/users.d.ts +10 -0
  73. package/dist/types/apiClient/usersGroups.d.ts +9 -0
  74. package/dist/types/apiClient/usersGroups_invites.d.ts +14 -0
  75. package/dist/types/apiClient/usersSharedData.d.ts +15 -0
  76. package/dist/types/apiClient/users_groups.d.ts +10 -0
  77. package/dist/types/apiClient/workgroupUnits.d.ts +10 -0
  78. package/dist/types/apiClient/workgroupUnitsTypes.d.ts +10 -0
  79. package/dist/types/apiClient/workgroups.d.ts +10 -0
  80. package/dist/types/index.d.ts +16 -0
  81. package/dist/types/models/authorizations.d.ts +9 -0
  82. package/dist/types/models/index.d.ts +173 -0
  83. package/package.json +46 -0
  84. package/src/api/index.ts +13 -0
  85. package/src/api/routes.ts +15 -0
  86. package/src/apiClient/authentications.ts +31 -0
  87. package/src/apiClient/authorizations.ts +19 -0
  88. package/src/apiClient/legalPersons.ts +19 -0
  89. package/src/apiClient/users.ts +18 -0
  90. package/src/apiClient/usersGroups.ts +17 -0
  91. package/src/apiClient/usersGroups_invites.ts +29 -0
  92. package/src/apiClient/usersSharedData.ts +33 -0
  93. package/src/apiClient/users_groups.ts +18 -0
  94. package/src/apiClient/workgroupUnits.ts +18 -0
  95. package/src/apiClient/workgroupUnitsTypes.ts +18 -0
  96. package/src/apiClient/workgroups.ts +18 -0
  97. package/src/index.ts +51 -0
  98. package/src/models/authorizations.ts +10 -0
  99. package/src/models/index.ts +287 -0
@@ -0,0 +1,13 @@
1
+ import { ApiRequestGetOptions } from "fwork-jsts-common"
2
+ import { Where } from "fwork-jsts-common"
3
+ import { IUser } from "../models"
4
+
5
+ export const ApiRequestHeaders = {
6
+ tokenProvider: 'token-provider'
7
+ } as const
8
+
9
+ export type ApiRequestHeaders = typeof ApiRequestHeaders[keyof typeof ApiRequestHeaders]
10
+
11
+ export type DatacenterApiRequestGetOptions<T, TWhere extends Where<T>> = ApiRequestGetOptions<T, TWhere> & {
12
+ user?: IUser
13
+ }
@@ -0,0 +1,15 @@
1
+ export const ApiRoutesNames = {
2
+ system: '/system',
3
+ authentications: '/authentications',
4
+ authorizations: '/authorizations',
5
+ workgroupUnitsTypes: '/workgroup-units-types',
6
+ workgroups: '/workgroups',
7
+ legalPersons: '/legal-persons',
8
+ users: '/users',
9
+ usersSharedData: '/users-sd',
10
+ workgroupUnits: '/workgroup-units',
11
+ usersGroups: '/users-groups',
12
+ usersGroups_authorizations: 'users-groups--authorizations',
13
+ users_groups: '/users--groups',
14
+ usersGroups_invites: '/users-groups--invites'
15
+ }
@@ -0,0 +1,31 @@
1
+ import axios, { AxiosInstance, AxiosRequestConfig, AxiosStatic } from 'axios'
2
+ import { ApiClientUtils, IApiClientResult } from 'fwork-jsts-common'
3
+ import { ApiRoutesNames } from '../api/routes'
4
+ import {
5
+ IAuthentication, IAuthenticationRequestBodyDefault,
6
+ IAuthenticationRequestBodyFromGoogleToken, IAuthenticationRequestBodyFromUuid
7
+ } from '../models'
8
+
9
+ export class AuthenticationsApiClient {
10
+ apiUrl: string
11
+ axios: AxiosStatic | AxiosInstance
12
+
13
+ constructor(args: {
14
+ baseApiUrl: string
15
+ axios?: AxiosStatic | AxiosInstance,
16
+ }) {
17
+ this.apiUrl = `${args.baseApiUrl}${ApiRoutesNames.authentications}`
18
+ this.axios = args.axios ?? axios
19
+ }
20
+
21
+ async post(args: {
22
+ data: IAuthenticationRequestBodyDefault | IAuthenticationRequestBodyFromUuid | IAuthenticationRequestBodyFromGoogleToken,
23
+ config?: AxiosRequestConfig<IAuthenticationRequestBodyDefault | IAuthenticationRequestBodyFromUuid | IAuthenticationRequestBodyFromGoogleToken> | undefined
24
+ }): Promise<IApiClientResult<IAuthentication> | undefined> {
25
+ return await ApiClientUtils.post({
26
+ apiUrl: this.apiUrl,
27
+ data: args.data,
28
+ config: args.config
29
+ })
30
+ }
31
+ }
@@ -0,0 +1,19 @@
1
+ import { AxiosInstance, AxiosStatic } from 'axios'
2
+ import { BaseApiClient } from 'fwork-jsts-common'
3
+ import { Where } from 'fwork-jsts-common'
4
+ import { IAuthorization } from '../models'
5
+ import { ApiRoutesNames } from '../api/routes'
6
+
7
+ export class AuthorizationsApiClient extends BaseApiClient<IAuthorization, any,
8
+ Where<IAuthorization>,
9
+ IAuthorization, IAuthorization> {
10
+ constructor(args: {
11
+ baseApiUrl: string
12
+ axios?: AxiosStatic | AxiosInstance,
13
+ }) {
14
+ super({
15
+ apiUrl: `${args.baseApiUrl}${ApiRoutesNames.authorizations}`,
16
+ axios: args.axios,
17
+ })
18
+ }
19
+ }
@@ -0,0 +1,19 @@
1
+ import { AxiosInstance, AxiosStatic } from 'axios'
2
+ import { BaseApiClient } from 'fwork-jsts-common'
3
+ import { Where } from 'fwork-jsts-common'
4
+ import { ILegalPerson } from '../models'
5
+ import { ApiRoutesNames } from '../api/routes'
6
+
7
+ export class LegalPersonsApiClient extends BaseApiClient<ILegalPerson, any,
8
+ Where<ILegalPerson>,
9
+ ILegalPerson, ILegalPerson> {
10
+ constructor(args: {
11
+ baseApiUrl: string
12
+ axios?: AxiosStatic | AxiosInstance,
13
+ }) {
14
+ super({
15
+ apiUrl: `${args.baseApiUrl}${ApiRoutesNames.legalPersons}`,
16
+ axios: args.axios,
17
+ })
18
+ }
19
+ }
@@ -0,0 +1,18 @@
1
+ import { AxiosInstance, AxiosStatic } from 'axios'
2
+ import { BaseApiClient } from 'fwork-jsts-common'
3
+ import { Where } from 'fwork-jsts-common'
4
+ import { IUser } from '../models'
5
+ import { ApiRoutesNames } from '../api/routes'
6
+
7
+ export class UsersApiClient extends BaseApiClient<IUser, any,
8
+ Where<IUser>, IUser, IUser> {
9
+ constructor(args: {
10
+ baseApiUrl: string
11
+ axios?: AxiosStatic | AxiosInstance,
12
+ }) {
13
+ super({
14
+ apiUrl: `${args.baseApiUrl}${ApiRoutesNames.users}`,
15
+ axios: args.axios,
16
+ })
17
+ }
18
+ }
@@ -0,0 +1,17 @@
1
+ import { AxiosInstance, AxiosStatic } from 'axios'
2
+ import { BaseApiClient, Where } from 'fwork-jsts-common'
3
+ import { IUserGroup } from '../models'
4
+ import { ApiRoutesNames } from '../api/routes'
5
+
6
+ export class UsersGroupsApiClient extends BaseApiClient<IUserGroup, any,
7
+ Where<IUserGroup>, IUserGroup, IUserGroup> {
8
+ constructor(args: {
9
+ baseApiUrl: string
10
+ axios?: AxiosStatic | AxiosInstance,
11
+ }) {
12
+ super({
13
+ apiUrl: `${args.baseApiUrl}${ApiRoutesNames.usersGroups}`,
14
+ axios: args.axios,
15
+ })
16
+ }
17
+ }
@@ -0,0 +1,29 @@
1
+ import { AxiosInstance, AxiosRequestConfig, AxiosStatic } from 'axios'
2
+ import { ApiResponsePostData, Where, ApiClientUtils, BaseApiClient, IApiClientResult } from 'fwork-jsts-common'
3
+ import { IUserGroup_Invite } from '../models'
4
+ import { ApiRoutesNames } from '../api/routes'
5
+
6
+ export class UsersGroups_invitesApiClient extends BaseApiClient<IUserGroup_Invite, any,
7
+ Where<IUserGroup_Invite>, IUserGroup_Invite, IUserGroup_Invite> {
8
+ constructor(args: {
9
+ baseApiUrl: string
10
+ axios?: AxiosStatic | AxiosInstance,
11
+ }) {
12
+ super({
13
+ apiUrl: `${args.baseApiUrl}${ApiRoutesNames.usersGroups_invites}`,
14
+ axios: args.axios,
15
+ })
16
+ }
17
+
18
+ async bulkPost(args: {
19
+ data: IUserGroup_Invite[],
20
+ status?: number[],
21
+ config?: AxiosRequestConfig<IUserGroup_Invite[]> | undefined
22
+ }): Promise<IApiClientResult<ApiResponsePostData<IUserGroup_Invite[]>>> {
23
+ return ApiClientUtils.post<IUserGroup_Invite[], ApiResponsePostData<IUserGroup_Invite[]>>({
24
+ apiUrl: this.apiUrl,
25
+ axios: this.axios,
26
+ ...args,
27
+ })
28
+ }
29
+ }
@@ -0,0 +1,33 @@
1
+ import axios, { AxiosInstance, AxiosStatic } from 'axios'
2
+ import { ApiResponseGetListData, Where, ApiClientGetOptions, ApiClientUtils, IApiClientResult } from 'fwork-jsts-common'
3
+ import { IUserSharedData } from '../models'
4
+ import { ApiRoutesNames } from '../api/routes'
5
+
6
+ export interface IUsers_SharedData_ApiClientGetOptions
7
+ extends ApiClientGetOptions<IUserSharedData, Where<IUserSharedData>> {
8
+ onlyRelated?: boolean
9
+ }
10
+
11
+ export class UsersSharedDataApiClient {
12
+ apiUrl: string
13
+ axios: AxiosStatic | AxiosInstance
14
+
15
+ constructor(args: {
16
+ baseApiUrl: string
17
+ axios?: AxiosStatic | AxiosInstance,
18
+ }) {
19
+ this.apiUrl = `${args.baseApiUrl}${ApiRoutesNames.usersSharedData}`
20
+ this.axios = args.axios ?? axios
21
+ }
22
+
23
+ async get(args?: IUsers_SharedData_ApiClientGetOptions): Promise<IApiClientResult<ApiResponseGetListData<IUserSharedData>>> {
24
+ return ApiClientUtils.get<IUserSharedData, Where<IUserSharedData>>({
25
+ apiUrl: this.apiUrl,
26
+ axios: this.axios,
27
+ ...args,
28
+ params: {
29
+ 'onlyRelated': args?.onlyRelated
30
+ }
31
+ })
32
+ }
33
+ }
@@ -0,0 +1,18 @@
1
+ import { AxiosInstance, AxiosStatic } from 'axios'
2
+ import { Where } from 'fwork-jsts-common'
3
+ import { BaseApiClient } from 'fwork-jsts-common'
4
+ import { IUser_Group } from '../models'
5
+ import { ApiRoutesNames } from '../api/routes'
6
+
7
+ export class Users_GroupsApiClient extends BaseApiClient<IUser_Group, any,
8
+ Where<IUser_Group>, IUser_Group, IUser_Group> {
9
+ constructor(args: {
10
+ baseApiUrl: string
11
+ axios?: AxiosStatic | AxiosInstance,
12
+ }) {
13
+ super({
14
+ apiUrl: `${args.baseApiUrl}${ApiRoutesNames.users_groups}`,
15
+ axios: args.axios,
16
+ })
17
+ }
18
+ }
@@ -0,0 +1,18 @@
1
+ import { AxiosInstance, AxiosStatic } from 'axios'
2
+ import { BaseApiClient } from 'fwork-jsts-common'
3
+ import { Where } from 'fwork-jsts-common'
4
+ import { IWorkgroupUnit } from '../models'
5
+ import { ApiRoutesNames } from '../api/routes'
6
+
7
+ export class WorkgroupUnitsApiClient extends BaseApiClient<IWorkgroupUnit, any,
8
+ Where<IWorkgroupUnit>, IWorkgroupUnit, IWorkgroupUnit> {
9
+ constructor(args: {
10
+ baseApiUrl: string
11
+ axios?: AxiosStatic | AxiosInstance,
12
+ }) {
13
+ super({
14
+ apiUrl: `${args.baseApiUrl}${ApiRoutesNames.workgroupUnits}`,
15
+ axios: args.axios,
16
+ })
17
+ }
18
+ }
@@ -0,0 +1,18 @@
1
+ import { AxiosInstance, AxiosStatic } from 'axios'
2
+ import { BaseApiClient } from 'fwork-jsts-common'
3
+ import { Where } from 'fwork-jsts-common'
4
+ import { ApiRoutesNames } from '../api/routes'
5
+ import { IWorkgroupUnitType } from '../models'
6
+
7
+ export class WorkgroupUnitsTypesApiClient extends BaseApiClient<IWorkgroupUnitType, any,
8
+ Where<IWorkgroupUnitType>, IWorkgroupUnitType, IWorkgroupUnitType> {
9
+ constructor(args: {
10
+ baseApiUrl: string
11
+ axios?: AxiosStatic | AxiosInstance,
12
+ }) {
13
+ super({
14
+ apiUrl: `${args.baseApiUrl}${ApiRoutesNames.workgroupUnitsTypes}`,
15
+ axios: args.axios,
16
+ })
17
+ }
18
+ }
@@ -0,0 +1,18 @@
1
+ import { AxiosInstance, AxiosStatic } from 'axios'
2
+ import { BaseApiClient } from 'fwork-jsts-common'
3
+ import { Where } from 'fwork-jsts-common'
4
+ import { IWorkgroup } from '../models'
5
+ import { ApiRoutesNames } from '../api/routes'
6
+
7
+ export class WorkgroupsApiClient extends BaseApiClient<IWorkgroup, any,
8
+ Where<IWorkgroup>, IWorkgroup, IWorkgroup> {
9
+ constructor(args: {
10
+ baseApiUrl: string
11
+ axios?: AxiosStatic | AxiosInstance,
12
+ }) {
13
+ super({
14
+ apiUrl: `${args.baseApiUrl}${ApiRoutesNames.workgroups}`,
15
+ axios: args.axios,
16
+ })
17
+ }
18
+ }
package/src/index.ts ADDED
@@ -0,0 +1,51 @@
1
+ import { ApiRequestHeaders, DatacenterApiRequestGetOptions, } from './api'
2
+ import { ApiRoutesNames, } from './api/routes'
3
+
4
+ import { AuthenticationsApiClient } from './apiClient/authentications'
5
+ import { AuthorizationsApiClient } from './apiClient/authorizations'
6
+ import { LegalPersonsApiClient } from './apiClient/legalPersons'
7
+ import { UsersApiClient } from './apiClient/users'
8
+ import { Users_GroupsApiClient } from './apiClient/users_groups'
9
+ import { UsersGroupsApiClient } from './apiClient/usersGroups'
10
+ import { UsersGroups_invitesApiClient } from './apiClient/usersGroups_invites'
11
+ import { IUsers_SharedData_ApiClientGetOptions } from './apiClient/usersSharedData'
12
+ import { WorkgroupsApiClient } from './apiClient/workgroups'
13
+ import { WorkgroupUnitsApiClient } from './apiClient/workgroupUnits'
14
+ import { WorkgroupUnitsTypesApiClient } from './apiClient/workgroupUnitsTypes'
15
+
16
+ import { AuthenticationTokenDataProviders, AuthenticationType, IAuthentication,
17
+ IAuthenticationRequestBody, IAuthenticationRequestBodyDefault, IAuthenticationRequestBodyFromGoogleToken, IAuthenticationRequestBodyFromUuid,
18
+ IAuthenticationTokenData, IAuthenticationTokenDataDefault, IAuthenticationTokenDataGoogle, IAuthorization, ILegalPerson,
19
+ IUser, IUserGroup, IUserGroup_Authorization, IUserGroup_Invite, IUserSharedData, IUser_Group, IWorkgroup, IWorkgroupUnit,
20
+ IWorkgroupUnitType, LegalPersonTypes, User, UserGroup_InviteStatus, UserGroup_InviteStatusUtils, legalPersonPropsNames,
21
+ } from './models'
22
+ import { AuthorizationKeys, AuthorizationsKeys, } from './models/authorizations'
23
+
24
+ export {
25
+ // api
26
+ ApiRequestHeaders, DatacenterApiRequestGetOptions,
27
+
28
+ ApiRoutesNames,
29
+
30
+ // apiClient
31
+ AuthenticationsApiClient,
32
+ AuthorizationsApiClient,
33
+ LegalPersonsApiClient,
34
+ UsersApiClient,
35
+ Users_GroupsApiClient,
36
+ UsersGroupsApiClient,
37
+ UsersGroups_invitesApiClient,
38
+ IUsers_SharedData_ApiClientGetOptions,
39
+ WorkgroupsApiClient,
40
+ WorkgroupUnitsApiClient,
41
+ WorkgroupUnitsTypesApiClient,
42
+
43
+ // models
44
+ AuthenticationTokenDataProviders, AuthenticationType, IAuthentication,
45
+ IAuthenticationRequestBody, IAuthenticationRequestBodyDefault, IAuthenticationRequestBodyFromGoogleToken, IAuthenticationRequestBodyFromUuid,
46
+ IAuthenticationTokenData, IAuthenticationTokenDataDefault, IAuthenticationTokenDataGoogle, IAuthorization, ILegalPerson,
47
+ IUser, IUserGroup, IUserGroup_Authorization, IUserGroup_Invite, IUserSharedData, IUser_Group, IWorkgroup, IWorkgroupUnit,
48
+ IWorkgroupUnitType, LegalPersonTypes, User, UserGroup_InviteStatus, UserGroup_InviteStatusUtils, legalPersonPropsNames,
49
+
50
+ AuthorizationKeys, AuthorizationsKeys,
51
+ }
@@ -0,0 +1,10 @@
1
+ export const AuthorizationKeys = {
2
+ sysAdm: 'sysAdm',
3
+ workgroupAdm: 'workgroupAdm',
4
+ workgroupUnitAdm: 'workgroupUnitAdm',
5
+
6
+ legalPersonsAdm: 'legalPersonsAdm',
7
+ usersGroupsAdm: 'usersGroupsAdm',
8
+ usersAdm: 'usersAdm',
9
+ } as const
10
+ export type AuthorizationsKeys = typeof AuthorizationKeys[keyof typeof AuthorizationKeys]
@@ -0,0 +1,287 @@
1
+ import { JwtPayload } from "jsonwebtoken"
2
+
3
+ // authentication...
4
+
5
+ export const AuthenticationType = {
6
+ default: 0,
7
+ uuid: 1,
8
+ google: 2,
9
+ } as const
10
+ export type AuthenticationType = typeof AuthenticationType[keyof typeof AuthenticationType]
11
+
12
+ export interface IAuthenticationRequestBody {
13
+ type: AuthenticationType
14
+ }
15
+
16
+ export interface IAuthenticationRequestBodyDefault extends IAuthenticationRequestBody {
17
+ login: string,
18
+ pwd: string,
19
+ }
20
+
21
+ export interface IAuthenticationRequestBodyFromUuid extends IAuthenticationRequestBody {
22
+ uuid: string,
23
+ }
24
+
25
+ export interface IAuthenticationRequestBodyFromGoogleToken extends IAuthenticationRequestBody {
26
+ idToken: string,
27
+ accessToken: string,
28
+ }
29
+
30
+ // AUTHENTICATION RESPONSE
31
+ export interface IAuthentication {
32
+ uuid: string,
33
+ userUuid: string,
34
+ user?: IUser,
35
+ token: string,
36
+ }
37
+
38
+ // USED IN TOKEN ON FIELD ISS OF JWT TOKEN
39
+ export const AuthenticationTokenDataProviders = {
40
+ default: 'default',
41
+ google: 'accounts.google.com',
42
+ } as const
43
+ export type AuthenticationTokenDataProviders = typeof AuthenticationTokenDataProviders[keyof typeof AuthenticationTokenDataProviders]
44
+
45
+ export interface IAuthenticationTokenData extends JwtPayload {
46
+
47
+ }
48
+
49
+ export interface IAuthenticationTokenDataDefault extends IAuthenticationTokenData {
50
+ authUuid: string,
51
+ user: IUserSharedData,
52
+ }
53
+
54
+ export interface IAuthenticationTokenDataGoogle extends IAuthenticationTokenData {
55
+ azp: string,
56
+ email: string,
57
+ email_verified: string,
58
+ at_hash: string,
59
+ }
60
+
61
+ // ...authentication
62
+
63
+ export interface IWorkgroupUnitType {
64
+ uuid: string,
65
+ name: string,
66
+ workgroupUnits?: IWorkgroupUnit[]
67
+ }
68
+
69
+ export interface IWorkgroup {
70
+ uuid: string,
71
+ name: string,
72
+ allowCreateUsersFreely?: boolean,
73
+
74
+ legalPersons?: ILegalPerson[]
75
+ }
76
+
77
+ export const legalPersonPropsNames = {
78
+ workgroupUuid: 'workgroupUuid'
79
+ }
80
+
81
+ export const LegalPersonTypes = {
82
+ person: 0,
83
+ company: 1,
84
+ } as const
85
+ export type LegalPersonTypes = typeof LegalPersonTypes[keyof typeof LegalPersonTypes]
86
+
87
+ export interface ILegalPerson {
88
+ uuid: string,
89
+ type: LegalPersonTypes,
90
+ name: string,
91
+
92
+ workgroupUuid: string,
93
+ workgroup?: IWorkgroup,
94
+
95
+ workgroupUnit?: IWorkgroupUnit,
96
+
97
+ users?: IUser[]
98
+ }
99
+
100
+ export interface IWorkgroupUnit {
101
+ workgroupUnitTypeUuid: string,
102
+ workgroupUnitType?: IWorkgroupUnitType,
103
+ legalPersonUuid: string,
104
+ legalPerson?: ILegalPerson,
105
+
106
+ usersGroups?: IUserGroup[]
107
+ }
108
+
109
+ export interface IUser {
110
+ uuid: string,
111
+ name: string,
112
+ login: string,
113
+ email: string,
114
+ pwd: string,
115
+ imageUrl?: string,
116
+
117
+ legalPersonUuid?: string,
118
+ legalPerson?: ILegalPerson,
119
+
120
+ groups?: IUser_Group[],
121
+ receivedInvites?: IUserGroup_Invite[],
122
+ sentInvites?: IUserGroup_Invite[],
123
+ authentications?: IAuthentication[],
124
+ }
125
+
126
+ export class User implements IUser {
127
+ uuid: any
128
+ name: string
129
+ login: string
130
+ email: string
131
+ pwd: string
132
+ imageUrl?: string | undefined
133
+ legalPersonUuid?: string | undefined
134
+ legalPerson?: ILegalPerson | undefined
135
+ groups?: IUser_Group[] | undefined
136
+
137
+ constructor(data: {
138
+ uuid: string,
139
+ name: string
140
+ login: string,
141
+ email: string,
142
+ pwd: string,
143
+ imageUrl?: string | undefined,
144
+ legalPersonUuid?: string | undefined,
145
+ legalPerson?: ILegalPerson | undefined,
146
+ groups?: IUser_Group[] | undefined,
147
+ }) {
148
+ this.uuid = data.uuid
149
+ this.name = data.name
150
+ this.login = data.login
151
+ this.email = data.email
152
+ this.pwd = data.pwd
153
+ this.imageUrl = data.imageUrl
154
+ this.legalPersonUuid = data.legalPersonUuid
155
+ this.legalPerson = data.legalPerson
156
+ this.groups = data.groups
157
+ }
158
+
159
+ toUserSharedData() {
160
+ const sharedDataKeys: (keyof IUserSharedData)[] = ['uuid', 'name', 'login', 'email', 'imageUrl']
161
+ const sharedData: Partial<IUserSharedData> = {};
162
+ sharedDataKeys.forEach(key => {
163
+ if (key in this) {
164
+ sharedData[key] = this[key];
165
+ }
166
+ });
167
+
168
+ return sharedData as IUserSharedData;
169
+ }
170
+
171
+ static toUserSharedData(input: any): any {
172
+ // Verifica se o objeto é um IUser
173
+ if (
174
+ input &&
175
+ typeof input === 'object' &&
176
+ 'uuid' in input &&
177
+ 'name' in input &&
178
+ 'login' in input &&
179
+ 'email' in input &&
180
+ 'pwd' in input
181
+ ) {
182
+ // Cria uma instância de User e converte para IUserSharedData
183
+ const userInstance = input instanceof User ? input : new User(input);
184
+ return userInstance.toUserSharedData();
185
+ }
186
+
187
+ if (typeof input === 'object' && input !== null) {
188
+ // Itera pelas propriedades do objeto ou elementos do array
189
+ if (Array.isArray(input)) {
190
+ return input.map(item => User.toUserSharedData(item));
191
+ } else {
192
+ const transformedObject: any = {};
193
+ for (const key of Object.keys(input)) {
194
+ transformedObject[key] = User.toUserSharedData(input[key]);
195
+ }
196
+ return transformedObject;
197
+ }
198
+ }
199
+
200
+ // Retorna o valor original se não for um objeto ou array
201
+ return input;
202
+ }
203
+ }
204
+
205
+ export interface IUserSharedData {
206
+ uuid: string,
207
+ name: string,
208
+ login: string,
209
+ email: string,
210
+ imageUrl?: string,
211
+ }
212
+
213
+ export interface IUserGroup {
214
+ uuid: string,
215
+ name: string,
216
+
217
+ workgroupUnitUuid: string,
218
+ workgroupUnit?: IWorkgroupUnit,
219
+
220
+ users?: IUser_Group[]
221
+ authorizations?: IUserGroup_Authorization[],
222
+ usersInvites?: IUserGroup_Invite[],
223
+ }
224
+
225
+ export interface IUser_Group {
226
+ uuid: string,
227
+
228
+ userUuid: string,
229
+ user?: IUser,
230
+ userGroupUuid: string,
231
+ userGroup?: IUserGroup
232
+ }
233
+
234
+ export const UserGroup_InviteStatus = {
235
+ pending: 0,
236
+ accepted: 1,
237
+ refused: 2,
238
+ } as const
239
+
240
+ export type UserGroup_InviteStatus = typeof UserGroup_InviteStatus[keyof typeof UserGroup_InviteStatus]
241
+
242
+ export class UserGroup_InviteStatusUtils {
243
+ static UserGroup_InviteStatusGetDescription = (status: UserGroup_InviteStatus) => {
244
+ return status == UserGroup_InviteStatus.pending ? 'Pendente' : status == UserGroup_InviteStatus.accepted ? 'Aceito' : 'Negado'
245
+ }
246
+ static UserGroup_InviteStatusGetUiMaterialChipColor = (status: UserGroup_InviteStatus) => {
247
+ return status == UserGroup_InviteStatus.pending ? 'warning' : status == UserGroup_InviteStatus.accepted ? 'success' : 'error'
248
+ }
249
+ }
250
+
251
+ export interface IUserGroup_Invite {
252
+ uuid: string,
253
+ userUuid: string,
254
+ user?: IUser,
255
+ targetUserUuid: string,
256
+ targetUser?: IUser,
257
+ userGroupUuid: string,
258
+ userGroup?: IUserGroup,
259
+ dtUnix: number,
260
+ status: UserGroup_InviteStatus,
261
+ }
262
+
263
+ // AUTHORIZATION...
264
+
265
+ // ESSE MODELO DEVE TER A COLECAO REIMPLEMENTADA NOS APPS QUE CONECTAM NO DCENTER
266
+ // EX. A DEFINICAO DAS AUTORIZACOES REFERENTES AO APP ESCOLAR DEVEM FICAR NA LIB DO ESCOLAR
267
+ // EX. A DEFINICAO DAS AUTORIZACOES REFERENTES AO APP MESSENGER DEVEM FICAR NA LIB DO MESSENGER
268
+ export interface IAuthorization {
269
+ key: string,
270
+ description: string,
271
+
272
+ usersGroups?: IUserGroup_Authorization[]
273
+ }
274
+
275
+ // ESSE MODELO DEVE TER A COLECAO REIMPLEMENTADA NOS APPS QUE CONECTAM NO DCENTER
276
+ // EX. A RELACAO ENTRE OS GRUPOS DE USUARIOS E AS AUTORIZACOES REFERENTES AO APP ESCOLAR DEVEM FICAR NA LIB DO ESCOLAR
277
+ // EX. A RELACAO ENTRE OS GRUPOS DE USUARIOS E AS AUTORIZACOES REFERENTES AO APP MESSENGER DEVEM FICAR NA LIB DO MESSENGER
278
+ export interface IUserGroup_Authorization {
279
+ uuid: string,
280
+
281
+ authorizationKey: string,
282
+ authorization?: IAuthorization,
283
+ userGroupUuid: string,
284
+ userGroup?: IUserGroup,
285
+ }
286
+
287
+ // ...AUTHORIZATION