@flusys/nestjs-auth 9.1.0 → 9.1.1
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/README.md +18 -0
- package/config/message-keys.d.ts +2 -0
- package/controllers/company-selection.controller.d.ts +5 -3
- package/controllers/user-permission.controller.d.ts +3 -3
- package/dtos/authentication.dto.d.ts +5 -0
- package/dtos/user-permission.dto.d.ts +3 -0
- package/fesm/118.js +30 -0
- package/fesm/120.js +27 -23
- package/fesm/24.js +361 -134
- package/fesm/360.js +719 -0
- package/fesm/370.js +50 -0
- package/fesm/config/index.js +3 -1
- package/fesm/docs/index.js +8 -2
- package/fesm/helpers/index.js +139 -33
- package/fesm/index.js +26 -550
- package/fesm/interceptors/index.js +6 -2
- package/fesm/modules/index.js +4 -529
- package/fesm/services/index.js +209 -27
- package/helpers/branch-ancestry.helper.d.ts +4 -0
- package/helpers/index.d.ts +1 -0
- package/helpers/token.helper.d.ts +2 -0
- package/interfaces/authentication.interface.d.ts +3 -0
- package/package.json +5 -5
- package/services/authentication.service.d.ts +3 -1
- package/services/branch-hierarchy-resolver.adapter.d.ts +15 -0
- package/services/branch.service.d.ts +7 -0
- package/services/company-access-resolver.adapter.d.ts +8 -0
- package/services/index.d.ts +2 -0
- package/services/user-permission.service.d.ts +1 -0
package/fesm/services/index.js
CHANGED
|
@@ -1,18 +1,211 @@
|
|
|
1
1
|
export const __rspack_esm_id = 995;
|
|
2
2
|
export const __rspack_esm_ids = [995];
|
|
3
3
|
export const __webpack_modules__ = {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
/*
|
|
9
|
-
/*
|
|
10
|
-
/*
|
|
11
|
-
/*
|
|
12
|
-
|
|
13
|
-
/*
|
|
14
|
-
|
|
15
|
-
/*
|
|
4
|
+
8230(__unused_rspack_module, __webpack_exports__, __webpack_require__) {
|
|
5
|
+
|
|
6
|
+
// EXPORTS
|
|
7
|
+
__webpack_require__.d(__webpack_exports__, {
|
|
8
|
+
WE: () => (/* reexport */ auth_config_service/* .AuthConfigService */.W),
|
|
9
|
+
vS: () => (/* reexport */ auth_datasource_provider/* .AuthDataSourceProvider */.v),
|
|
10
|
+
Gw: () => (/* reexport */ auth_email_service/* .AuthEmailService */.G),
|
|
11
|
+
kX: () => (/* reexport */ authentication_service/* .AuthenticationService */.k),
|
|
12
|
+
XR: () => (/* reexport */ BranchHierarchyResolverAdapter),
|
|
13
|
+
O_: () => (/* reexport */ branch_service/* .BranchService */.O),
|
|
14
|
+
ht: () => (/* reexport */ CompanyAccessResolverAdapter),
|
|
15
|
+
vB: () => (/* reexport */ company_selection_session_service/* .CompanySelectionSessionService */.v),
|
|
16
|
+
Bl: () => (/* reexport */ company_service/* .CompanyService */.B),
|
|
17
|
+
t_: () => (/* reexport */ social_auth_config_service/* .SocialAuthConfigService */.t),
|
|
18
|
+
Jn: () => (/* reexport */ social_auth_service/* .SocialAuthService */.J),
|
|
19
|
+
OE: () => (/* reexport */ user_permission_service/* .UserPermissionService */.O),
|
|
20
|
+
DL: () => (/* reexport */ user_service/* .UserService */.D)
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
// EXTERNAL MODULE: ./projects/nestjs-auth/src/services/authentication.service.ts + 1 modules
|
|
24
|
+
var authentication_service = __webpack_require__(4722);
|
|
25
|
+
// EXTERNAL MODULE: ./projects/nestjs-auth/src/services/auth-email.service.ts
|
|
26
|
+
var auth_email_service = __webpack_require__(3221);
|
|
27
|
+
// EXTERNAL MODULE: ./projects/nestjs-auth/src/services/company-selection-session.service.ts
|
|
28
|
+
var company_selection_session_service = __webpack_require__(5811);
|
|
29
|
+
// EXTERNAL MODULE: ./projects/nestjs-auth/src/services/social-auth.service.ts
|
|
30
|
+
var social_auth_service = __webpack_require__(2786);
|
|
31
|
+
// EXTERNAL MODULE: ./projects/nestjs-auth/src/services/social-auth-config.service.ts
|
|
32
|
+
var social_auth_config_service = __webpack_require__(8275);
|
|
33
|
+
// EXTERNAL MODULE: ./projects/nestjs-auth/src/services/user.service.ts
|
|
34
|
+
var user_service = __webpack_require__(7229);
|
|
35
|
+
// EXTERNAL MODULE: ./projects/nestjs-auth/src/services/company.service.ts
|
|
36
|
+
var company_service = __webpack_require__(9201);
|
|
37
|
+
// EXTERNAL MODULE: ./projects/nestjs-auth/src/services/branch.service.ts
|
|
38
|
+
var branch_service = __webpack_require__(5402);
|
|
39
|
+
// EXTERNAL MODULE: ./projects/nestjs-auth/src/services/user-permission.service.ts
|
|
40
|
+
var user_permission_service = __webpack_require__(5291);
|
|
41
|
+
// EXTERNAL MODULE: ./projects/nestjs-auth/src/services/auth-config.service.ts + 1 modules
|
|
42
|
+
var auth_config_service = __webpack_require__(6514);
|
|
43
|
+
// EXTERNAL MODULE: ./projects/nestjs-auth/src/services/auth-datasource.provider.ts
|
|
44
|
+
var auth_datasource_provider = __webpack_require__(2732);
|
|
45
|
+
// EXTERNAL MODULE: external "@flusys/nestjs-shared/interfaces"
|
|
46
|
+
var interfaces_ = __webpack_require__(5103);
|
|
47
|
+
// EXTERNAL MODULE: external "@nestjs/common"
|
|
48
|
+
var common_ = __webpack_require__(6157);
|
|
49
|
+
// EXTERNAL MODULE: external "@nestjs/core"
|
|
50
|
+
var core_ = __webpack_require__(3075);
|
|
51
|
+
;// CONCATENATED MODULE: ./projects/nestjs-auth/src/services/branch-hierarchy-resolver.adapter.ts
|
|
52
|
+
function _ts_decorate(decorators, target, key, desc) {
|
|
53
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
54
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
|
|
55
|
+
r = Reflect.decorate(decorators, target, key, desc);
|
|
56
|
+
} else {
|
|
57
|
+
for(var i = decorators.length - 1; i >= 0; i--){
|
|
58
|
+
if (d = decorators[i]) {
|
|
59
|
+
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
64
|
+
}
|
|
65
|
+
function _ts_metadata(metadataKey, metadataValue) {
|
|
66
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") {
|
|
67
|
+
return Reflect.metadata(metadataKey, metadataValue);
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
function _ts_param(paramIndex, decorator) {
|
|
71
|
+
return function(target, key) {
|
|
72
|
+
decorator(target, key, paramIndex);
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
|
|
77
|
+
|
|
78
|
+
|
|
79
|
+
class BranchHierarchyResolverAdapter {
|
|
80
|
+
moduleRef;
|
|
81
|
+
companyAccess;
|
|
82
|
+
constructor(moduleRef, companyAccess){
|
|
83
|
+
this.moduleRef = moduleRef;
|
|
84
|
+
this.companyAccess = companyAccess;
|
|
85
|
+
}
|
|
86
|
+
async getDescendantIds(branchIds, options) {
|
|
87
|
+
return (await this.resolve(branch_service/* .BranchService */.O)).getDescendantIds(branchIds, options);
|
|
88
|
+
}
|
|
89
|
+
async getAncestorIds(branchId, options) {
|
|
90
|
+
return (await this.resolve(branch_service/* .BranchService */.O)).getAncestorIds(branchId, options);
|
|
91
|
+
}
|
|
92
|
+
async isWithinBranch(branchId, ancestorId) {
|
|
93
|
+
return (await this.resolve(branch_service/* .BranchService */.O)).isWithinBranch(branchId, ancestorId);
|
|
94
|
+
}
|
|
95
|
+
async getGrantedBranchIds(userId, companyId) {
|
|
96
|
+
if (!userId) return [];
|
|
97
|
+
const { branches } = await this.companyAccess.getUserAccess(userId);
|
|
98
|
+
return branches.filter((branch)=>!companyId || branch.companyId === companyId).map((branch)=>branch.id);
|
|
99
|
+
}
|
|
100
|
+
async getGrantedDescendantIds(userId, branchIds, options) {
|
|
101
|
+
const granted = new Set(await this.getGrantedBranchIds(userId));
|
|
102
|
+
if (!granted.size) return [];
|
|
103
|
+
return (await this.getDescendantIds(branchIds, options)).filter((id)=>granted.has(id));
|
|
104
|
+
}
|
|
105
|
+
async hasBranchAccess(userId, branchId) {
|
|
106
|
+
if (!branchId) return false;
|
|
107
|
+
return (await this.getGrantedBranchIds(userId)).includes(branchId);
|
|
108
|
+
}
|
|
109
|
+
resolve(type) {
|
|
110
|
+
return this.moduleRef.resolve(type, core_.ContextIdFactory.create(), {
|
|
111
|
+
strict: false
|
|
112
|
+
});
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
BranchHierarchyResolverAdapter = _ts_decorate([
|
|
116
|
+
(0,common_.Injectable)(),
|
|
117
|
+
_ts_param(0, (0,common_.Inject)(core_.ModuleRef)),
|
|
118
|
+
_ts_param(1, (0,common_.Inject)(interfaces_.COMPANY_ACCESS_RESOLVER)),
|
|
119
|
+
_ts_metadata("design:type", Function),
|
|
120
|
+
_ts_metadata("design:paramtypes", [
|
|
121
|
+
typeof core_.ModuleRef === "undefined" ? Object : core_.ModuleRef,
|
|
122
|
+
typeof ICompanyAccessResolver === "undefined" ? Object : ICompanyAccessResolver
|
|
123
|
+
])
|
|
124
|
+
], BranchHierarchyResolverAdapter);
|
|
125
|
+
|
|
126
|
+
;// CONCATENATED MODULE: ./projects/nestjs-auth/src/services/company-access-resolver.adapter.ts
|
|
127
|
+
function company_access_resolver_adapter_ts_decorate(decorators, target, key, desc) {
|
|
128
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
129
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
|
|
130
|
+
r = Reflect.decorate(decorators, target, key, desc);
|
|
131
|
+
} else {
|
|
132
|
+
for(var i = decorators.length - 1; i >= 0; i--){
|
|
133
|
+
if (d = decorators[i]) {
|
|
134
|
+
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
139
|
+
}
|
|
140
|
+
function company_access_resolver_adapter_ts_metadata(metadataKey, metadataValue) {
|
|
141
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") {
|
|
142
|
+
return Reflect.metadata(metadataKey, metadataValue);
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
function company_access_resolver_adapter_ts_param(paramIndex, decorator) {
|
|
146
|
+
return function(target, key) {
|
|
147
|
+
decorator(target, key, paramIndex);
|
|
148
|
+
};
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
|
|
152
|
+
|
|
153
|
+
const byName = (a, b)=>a.name.localeCompare(b.name);
|
|
154
|
+
/** Users of grants that still count: the grant is active and its user is active and not deleted. */ const activeUserIds = (grants)=>grants.filter((grant)=>grant.isActive && grant.user?.isActive && !grant.user.deletedAt).map((grant)=>grant.userId);
|
|
155
|
+
class CompanyAccessResolverAdapter {
|
|
156
|
+
moduleRef;
|
|
157
|
+
constructor(moduleRef){
|
|
158
|
+
this.moduleRef = moduleRef;
|
|
159
|
+
}
|
|
160
|
+
async getUserAccess(userId) {
|
|
161
|
+
const permissions = await this.moduleRef.resolve(user_permission_service/* .UserPermissionService */.O, core_.ContextIdFactory.create(), {
|
|
162
|
+
strict: false
|
|
163
|
+
});
|
|
164
|
+
const [companyGrants, branchGrants] = await Promise.all([
|
|
165
|
+
permissions.findUserCompanies(userId),
|
|
166
|
+
permissions.findUserBranches(userId)
|
|
167
|
+
]);
|
|
168
|
+
const companies = companyGrants.filter((grant)=>grant.isActive).map((grant)=>grant.company).filter((company)=>!!company?.isActive).toSorted(byName);
|
|
169
|
+
const companyIds = new Set(companies.map((company)=>company.id));
|
|
170
|
+
const branches = branchGrants.map((grant)=>grant.branch).filter((branch)=>!!branch?.isActive && companyIds.has(branch.companyId)).toSorted((a, b)=>(a.serial ?? 0) - (b.serial ?? 0) || byName(a, b));
|
|
171
|
+
return {
|
|
172
|
+
companies: companies.map(({ id, name })=>({
|
|
173
|
+
id,
|
|
174
|
+
name
|
|
175
|
+
})),
|
|
176
|
+
branches: branches.map(({ id, companyId, parentId, name })=>({
|
|
177
|
+
id,
|
|
178
|
+
companyId,
|
|
179
|
+
parentId: parentId ?? null,
|
|
180
|
+
name
|
|
181
|
+
}))
|
|
182
|
+
};
|
|
183
|
+
}
|
|
184
|
+
async getCompanyMembers(companyId, branchIds = []) {
|
|
185
|
+
const permissions = await this.moduleRef.resolve(user_permission_service/* .UserPermissionService */.O, core_.ContextIdFactory.create(), {
|
|
186
|
+
strict: false
|
|
187
|
+
});
|
|
188
|
+
const members = activeUserIds(await permissions.findUsersForCompany(companyId));
|
|
189
|
+
if (!branchIds.length) return [
|
|
190
|
+
...new Set(members)
|
|
191
|
+
];
|
|
192
|
+
const inBranches = new Set(activeUserIds((await Promise.all(branchIds.map((branchId)=>permissions.findUsersForBranch(branchId)))).flat()));
|
|
193
|
+
return [
|
|
194
|
+
...new Set(members.filter((userId)=>inBranches.has(userId)))
|
|
195
|
+
];
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
CompanyAccessResolverAdapter = company_access_resolver_adapter_ts_decorate([
|
|
199
|
+
(0,common_.Injectable)(),
|
|
200
|
+
company_access_resolver_adapter_ts_param(0, (0,common_.Inject)(core_.ModuleRef)),
|
|
201
|
+
company_access_resolver_adapter_ts_metadata("design:type", Function),
|
|
202
|
+
company_access_resolver_adapter_ts_metadata("design:paramtypes", [
|
|
203
|
+
typeof core_.ModuleRef === "undefined" ? Object : core_.ModuleRef
|
|
204
|
+
])
|
|
205
|
+
], CompanyAccessResolverAdapter);
|
|
206
|
+
|
|
207
|
+
;// CONCATENATED MODULE: ./projects/nestjs-auth/src/services/index.ts
|
|
208
|
+
|
|
16
209
|
|
|
17
210
|
|
|
18
211
|
|
|
@@ -25,19 +218,6 @@ export const __webpack_modules__ = {
|
|
|
25
218
|
|
|
26
219
|
|
|
27
220
|
|
|
28
|
-
__webpack_require__.d(__webpack_exports__, {
|
|
29
|
-
Bl: () => (/* reexport safe */ _company_service_js__rspack_import_6.B),
|
|
30
|
-
DL: () => (/* reexport safe */ _user_service_js__rspack_import_5.D),
|
|
31
|
-
Gw: () => (/* reexport safe */ _auth_email_service_js__rspack_import_1.G),
|
|
32
|
-
Jn: () => (/* reexport safe */ _social_auth_service_js__rspack_import_3.J),
|
|
33
|
-
OE: () => (/* reexport safe */ _user_permission_service_js__rspack_import_8.O),
|
|
34
|
-
O_: () => (/* reexport safe */ _branch_service_js__rspack_import_7.O),
|
|
35
|
-
WE: () => (/* reexport safe */ _auth_config_service_js__rspack_import_9.W),
|
|
36
|
-
kX: () => (/* reexport safe */ _authentication_service_js__rspack_import_0.k),
|
|
37
|
-
t_: () => (/* reexport safe */ _social_auth_config_service_js__rspack_import_4.t),
|
|
38
|
-
vB: () => (/* reexport safe */ _company_selection_session_service_js__rspack_import_2.v),
|
|
39
|
-
vS: () => (/* reexport safe */ _auth_datasource_provider_js__rspack_import_10.v)
|
|
40
|
-
});
|
|
41
221
|
|
|
42
222
|
|
|
43
223
|
},
|
|
@@ -53,15 +233,17 @@ import * as __rspack_chunk_3 from '../24.js';
|
|
|
53
233
|
__webpack_require__.C(__rspack_chunk_3);
|
|
54
234
|
import * as __rspack_chunk_4 from './index.js';
|
|
55
235
|
__webpack_require__.C(__rspack_chunk_4);
|
|
56
|
-
var __webpack_exports__ = __webpack_exec__(
|
|
236
|
+
var __webpack_exports__ = __webpack_exec__(8230);var __webpack_exports__AuthConfigService = __webpack_exports__.WE;
|
|
57
237
|
var __webpack_exports__AuthDataSourceProvider = __webpack_exports__.vS;
|
|
58
238
|
var __webpack_exports__AuthEmailService = __webpack_exports__.Gw;
|
|
59
239
|
var __webpack_exports__AuthenticationService = __webpack_exports__.kX;
|
|
240
|
+
var __webpack_exports__BranchHierarchyResolverAdapter = __webpack_exports__.XR;
|
|
60
241
|
var __webpack_exports__BranchService = __webpack_exports__.O_;
|
|
242
|
+
var __webpack_exports__CompanyAccessResolverAdapter = __webpack_exports__.ht;
|
|
61
243
|
var __webpack_exports__CompanySelectionSessionService = __webpack_exports__.vB;
|
|
62
244
|
var __webpack_exports__CompanyService = __webpack_exports__.Bl;
|
|
63
245
|
var __webpack_exports__SocialAuthConfigService = __webpack_exports__.t_;
|
|
64
246
|
var __webpack_exports__SocialAuthService = __webpack_exports__.Jn;
|
|
65
247
|
var __webpack_exports__UserPermissionService = __webpack_exports__.OE;
|
|
66
248
|
var __webpack_exports__UserService = __webpack_exports__.DL;
|
|
67
|
-
export { __webpack_exports__AuthConfigService as AuthConfigService, __webpack_exports__AuthDataSourceProvider as AuthDataSourceProvider, __webpack_exports__AuthEmailService as AuthEmailService, __webpack_exports__AuthenticationService as AuthenticationService, __webpack_exports__BranchService as BranchService, __webpack_exports__CompanySelectionSessionService as CompanySelectionSessionService, __webpack_exports__CompanyService as CompanyService, __webpack_exports__SocialAuthConfigService as SocialAuthConfigService, __webpack_exports__SocialAuthService as SocialAuthService, __webpack_exports__UserPermissionService as UserPermissionService, __webpack_exports__UserService as UserService };
|
|
249
|
+
export { __webpack_exports__AuthConfigService as AuthConfigService, __webpack_exports__AuthDataSourceProvider as AuthDataSourceProvider, __webpack_exports__AuthEmailService as AuthEmailService, __webpack_exports__AuthenticationService as AuthenticationService, __webpack_exports__BranchHierarchyResolverAdapter as BranchHierarchyResolverAdapter, __webpack_exports__BranchService as BranchService, __webpack_exports__CompanyAccessResolverAdapter as CompanyAccessResolverAdapter, __webpack_exports__CompanySelectionSessionService as CompanySelectionSessionService, __webpack_exports__CompanyService as CompanyService, __webpack_exports__SocialAuthConfigService as SocialAuthConfigService, __webpack_exports__SocialAuthService as SocialAuthService, __webpack_exports__UserPermissionService as UserPermissionService, __webpack_exports__UserService as UserService };
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { type Repository } from 'typeorm';
|
|
2
|
+
import { CompanyBranch } from '../entities/company-branch.entity.js';
|
|
3
|
+
export declare function loadCompanyBranchNodes(repo: Repository<CompanyBranch>, branchIds: readonly string[], withDeleted?: boolean): Promise<CompanyBranch[]>;
|
|
4
|
+
export declare function loadDisplayParentIds(repo: Repository<CompanyBranch>, branchIds: readonly string[]): Promise<Map<string, string | null>>;
|
package/helpers/index.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { type HybridCache } from '@flusys/nestjs-shared/classes';
|
|
1
2
|
import { JwtService } from '@nestjs/jwt';
|
|
2
3
|
import { type TokenPayload, type TokenPayloadWithCompany } from '../interfaces/authentication.interface.js';
|
|
3
4
|
import { AuthConfigService } from '../services/auth-config.service.js';
|
|
@@ -7,3 +8,4 @@ export declare function generateTokens(jwtService: JwtService, authConfig: AuthC
|
|
|
7
8
|
refreshToken: string;
|
|
8
9
|
};
|
|
9
10
|
export declare function parseExpiryToMs(expiry: string): number;
|
|
11
|
+
export declare function revokeUserSessions(cache: Pick<HybridCache, 'set'>, authConfig: Pick<AuthConfigService, 'getRefreshTokenExpiration'>, userId: string): Promise<void>;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@flusys/nestjs-auth",
|
|
3
|
-
"version": "9.1.
|
|
3
|
+
"version": "9.1.1",
|
|
4
4
|
"description": "Authentication and authorization infrastructure for NestJS applications",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./fesm/index.js",
|
|
@@ -83,16 +83,16 @@
|
|
|
83
83
|
"bcrypt": "^6.0.0",
|
|
84
84
|
"class-transformer": "^0.5.1",
|
|
85
85
|
"class-validator": "^0.15.0",
|
|
86
|
-
"nodemailer": "^
|
|
86
|
+
"nodemailer": "^10.0.13",
|
|
87
87
|
"passport": "^0.7.0",
|
|
88
88
|
"passport-jwt": "^4.0.0",
|
|
89
89
|
"passport-local": "^1.0.0",
|
|
90
|
-
"typeorm": "^0.3.
|
|
90
|
+
"typeorm": "^0.3.31",
|
|
91
91
|
"express": "^5.0.0",
|
|
92
92
|
"rxjs": "^7.8.0"
|
|
93
93
|
},
|
|
94
94
|
"dependencies": {
|
|
95
|
-
"@flusys/nestjs-core": "9.1.
|
|
96
|
-
"@flusys/nestjs-shared": "9.1.
|
|
95
|
+
"@flusys/nestjs-core": "9.1.1",
|
|
96
|
+
"@flusys/nestjs-shared": "9.1.1"
|
|
97
97
|
}
|
|
98
98
|
}
|
|
@@ -52,7 +52,9 @@ export declare class AuthenticationService {
|
|
|
52
52
|
logout(userId: string): Promise<void>;
|
|
53
53
|
isTokenRevoked(userId: string, tokenIssuedAt?: number): Promise<boolean>;
|
|
54
54
|
getUserCompanies(userId: string): Promise<Company[]>;
|
|
55
|
-
getUserBranches(userId: string, companyId: string): Promise<CompanyBranch
|
|
55
|
+
getUserBranches(userId: string, companyId: string): Promise<Array<CompanyBranch & {
|
|
56
|
+
displayParentId: string | null;
|
|
57
|
+
}>>;
|
|
56
58
|
getCompanyById(companyId: string): Promise<Company | null>;
|
|
57
59
|
getBranchById(branchId: string): Promise<CompanyBranch | null>;
|
|
58
60
|
getUserInfo(userId: string, companyId?: string, branchId?: string): Promise<MeResponse>;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { type IBranchHierarchyResolver, type ICompanyAccessResolver } from '@flusys/nestjs-shared/interfaces';
|
|
2
|
+
import { type IBranchHierarchyOptions } from '@flusys/nestjs-shared/utils';
|
|
3
|
+
import { ModuleRef } from '@nestjs/core';
|
|
4
|
+
export declare class BranchHierarchyResolverAdapter implements IBranchHierarchyResolver {
|
|
5
|
+
private readonly moduleRef;
|
|
6
|
+
private readonly companyAccess;
|
|
7
|
+
constructor(moduleRef: ModuleRef, companyAccess: ICompanyAccessResolver);
|
|
8
|
+
getDescendantIds(branchIds: string | string[], options?: IBranchHierarchyOptions): Promise<string[]>;
|
|
9
|
+
getAncestorIds(branchId: string, options?: IBranchHierarchyOptions): Promise<string[]>;
|
|
10
|
+
isWithinBranch(branchId: string, ancestorId: string): Promise<boolean>;
|
|
11
|
+
getGrantedBranchIds(userId: string, companyId?: string): Promise<string[]>;
|
|
12
|
+
getGrantedDescendantIds(userId: string, branchIds: string | string[], options?: IBranchHierarchyOptions): Promise<string[]>;
|
|
13
|
+
hasBranchAccess(userId: string, branchId: string): Promise<boolean>;
|
|
14
|
+
private resolve;
|
|
15
|
+
}
|
|
@@ -2,6 +2,7 @@ import { ApiService, HybridCache } from '@flusys/nestjs-shared/classes';
|
|
|
2
2
|
import { DeleteDto, FilterAndPaginationDto } from '@flusys/nestjs-shared/dtos';
|
|
3
3
|
import { type ILoggedUserInfo, type IPermissionSyncAdapter } from '@flusys/nestjs-shared/interfaces';
|
|
4
4
|
import { UtilsService } from '@flusys/nestjs-shared/modules';
|
|
5
|
+
import { type IBranchHierarchyOptions } from '@flusys/nestjs-shared/utils';
|
|
5
6
|
import { type QueryRunner, SelectQueryBuilder } from 'typeorm';
|
|
6
7
|
import { CreateCompanyBranchDto, UpdateCompanyBranchDto } from '../dtos/company-branch.dto.js';
|
|
7
8
|
import { CompanyBranch } from '../entities/company-branch.entity.js';
|
|
@@ -14,7 +15,13 @@ export declare class BranchService extends ApiService<CreateCompanyBranchDto, Up
|
|
|
14
15
|
private readonly authConfig;
|
|
15
16
|
private readonly permissionSyncAdapter?;
|
|
16
17
|
constructor(cacheManager: HybridCache, utilsService: UtilsService, dataSourceProvider: AuthDataSourceProvider, authConfig: AuthConfigService, permissionSyncAdapter?: IPermissionSyncAdapter | undefined);
|
|
18
|
+
protected beforeInsertOperation(dto: CreateCompanyBranchDto | CreateCompanyBranchDto[], _user: ILoggedUserInfo | null, queryRunner: QueryRunner): Promise<void>;
|
|
19
|
+
protected beforeUpdateOperation(dto: UpdateCompanyBranchDto | UpdateCompanyBranchDto[], _user: ILoggedUserInfo | null, queryRunner: QueryRunner): Promise<void>;
|
|
20
|
+
private validateParent;
|
|
17
21
|
protected beforeDeleteOperation(dto: DeleteDto, user: ILoggedUserInfo | null, queryRunner: QueryRunner): Promise<void>;
|
|
22
|
+
getDescendantIds(branchIds: string | string[], options?: IBranchHierarchyOptions): Promise<string[]>;
|
|
23
|
+
getAncestorIds(branchId: string, options?: IBranchHierarchyOptions): Promise<string[]>;
|
|
24
|
+
isWithinBranch(branchId: string, ancestorId: string): Promise<boolean>;
|
|
18
25
|
getSelectQuery(query: SelectQueryBuilder<CompanyBranch>, _user: ILoggedUserInfo | null, select?: string[]): Promise<{
|
|
19
26
|
query: SelectQueryBuilder<CompanyBranch>;
|
|
20
27
|
isRaw: boolean;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { type ICompanyAccessResolver, type IUserCompanyAccess } from '@flusys/nestjs-shared/interfaces';
|
|
2
|
+
import { ModuleRef } from '@nestjs/core';
|
|
3
|
+
export declare class CompanyAccessResolverAdapter implements ICompanyAccessResolver {
|
|
4
|
+
private readonly moduleRef;
|
|
5
|
+
constructor(moduleRef: ModuleRef);
|
|
6
|
+
getUserAccess(userId: string): Promise<IUserCompanyAccess>;
|
|
7
|
+
getCompanyMembers(companyId: string, branchIds?: string[]): Promise<string[]>;
|
|
8
|
+
}
|
package/services/index.d.ts
CHANGED
|
@@ -9,3 +9,5 @@ export * from './branch.service.js';
|
|
|
9
9
|
export * from './user-permission.service.js';
|
|
10
10
|
export * from './auth-config.service.js';
|
|
11
11
|
export * from './auth-datasource.provider.js';
|
|
12
|
+
export * from './branch-hierarchy-resolver.adapter.js';
|
|
13
|
+
export * from './company-access-resolver.adapter.js';
|
|
@@ -16,6 +16,7 @@ export declare class UserPermissionService {
|
|
|
16
16
|
private revokeBranchPermissionsForCompany;
|
|
17
17
|
findUserCompanies: (userId: string) => Promise<UserCompanyPermission[]>;
|
|
18
18
|
findUserBranches(userId: string, companyId?: string): Promise<UserCompanyPermission[]>;
|
|
19
|
+
findDisplayParentIds(branchIds: string[]): Promise<Map<string, string | null>>;
|
|
19
20
|
findUsersForCompany(companyId: string): Promise<UserCompanyPermission[]>;
|
|
20
21
|
findUsersForBranch(branchId: string): Promise<UserCompanyPermission[]>;
|
|
21
22
|
}
|