@flusys/ng-auth 8.1.2 → 8.1.3
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.
|
@@ -1465,6 +1465,24 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.1.5", ngImpor
|
|
|
1465
1465
|
* import { provideAuthProviders } from '@flusys/ng-auth';
|
|
1466
1466
|
* providers: [...provideAuthProviders()]
|
|
1467
1467
|
*/
|
|
1468
|
+
function emptyListResponse() {
|
|
1469
|
+
return {
|
|
1470
|
+
success: true,
|
|
1471
|
+
message: '',
|
|
1472
|
+
data: [],
|
|
1473
|
+
meta: { total: 0, page: 0, pageSize: 0, count: 0 },
|
|
1474
|
+
};
|
|
1475
|
+
}
|
|
1476
|
+
function mapListResponse(response, mapper) {
|
|
1477
|
+
return {
|
|
1478
|
+
success: response.success,
|
|
1479
|
+
message: response.message,
|
|
1480
|
+
messageKey: response.messageKey,
|
|
1481
|
+
messageVariables: response.messageVariables,
|
|
1482
|
+
data: (response.data ?? []).map(mapper),
|
|
1483
|
+
meta: response.meta,
|
|
1484
|
+
};
|
|
1485
|
+
}
|
|
1468
1486
|
// =============================================================================
|
|
1469
1487
|
// User Provider Adapter
|
|
1470
1488
|
// =============================================================================
|
|
@@ -1484,41 +1502,21 @@ class AuthUserProviderAdapter {
|
|
|
1484
1502
|
},
|
|
1485
1503
|
sort: { name: 'ASC' },
|
|
1486
1504
|
};
|
|
1487
|
-
return this.userApi.lookup(apiFilter, search ?? '').pipe(map((response) => ({
|
|
1488
|
-
|
|
1489
|
-
|
|
1490
|
-
|
|
1491
|
-
|
|
1492
|
-
data: (response.data ?? []).map((user) => ({
|
|
1493
|
-
id: user.id,
|
|
1494
|
-
name: user.name || user.email,
|
|
1495
|
-
email: user.email,
|
|
1496
|
-
})),
|
|
1497
|
-
meta: response.meta,
|
|
1498
|
-
})));
|
|
1505
|
+
return this.userApi.lookup(apiFilter, search ?? '').pipe(map((response) => mapListResponse(response, (user) => ({
|
|
1506
|
+
id: user.id,
|
|
1507
|
+
name: user.name || user.email,
|
|
1508
|
+
email: user.email,
|
|
1509
|
+
}))));
|
|
1499
1510
|
}
|
|
1500
1511
|
getUsersByIds(ids) {
|
|
1501
1512
|
if (ids.length === 0) {
|
|
1502
|
-
|
|
1503
|
-
success: true,
|
|
1504
|
-
message: '',
|
|
1505
|
-
data: [],
|
|
1506
|
-
meta: { total: 0, page: 0, pageSize: 0, count: 0 },
|
|
1507
|
-
};
|
|
1508
|
-
return from(Promise.resolve(empty));
|
|
1513
|
+
return from(Promise.resolve(emptyListResponse()));
|
|
1509
1514
|
}
|
|
1510
|
-
return from(this.userApi.findByIds(ids, ['id', 'name', 'email'])).pipe(map((response) => ({
|
|
1511
|
-
|
|
1512
|
-
|
|
1513
|
-
|
|
1514
|
-
|
|
1515
|
-
data: (response.data ?? []).map((user) => ({
|
|
1516
|
-
id: user.id,
|
|
1517
|
-
name: user.name || user.email,
|
|
1518
|
-
email: user.email,
|
|
1519
|
-
})),
|
|
1520
|
-
meta: response.meta,
|
|
1521
|
-
})));
|
|
1515
|
+
return from(this.userApi.findByIds(ids, ['id', 'name', 'email'])).pipe(map((response) => mapListResponse(response, (user) => ({
|
|
1516
|
+
id: user.id,
|
|
1517
|
+
name: user.name || user.email,
|
|
1518
|
+
email: user.email,
|
|
1519
|
+
}))));
|
|
1522
1520
|
}
|
|
1523
1521
|
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.1.5", ngImport: i0, type: AuthUserProviderAdapter, deps: [], target: i0.ɵɵFactoryTarget.Service });
|
|
1524
1522
|
static ɵprov = i0.ɵɵngDeclareService({ minVersion: "22.0.0", version: "22.1.5", ngImport: i0, type: AuthUserProviderAdapter, autoProvided: false });
|
|
@@ -1532,6 +1530,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.1.5", ngImpor
|
|
|
1532
1530
|
// =============================================================================
|
|
1533
1531
|
class AuthCompanyApiProviderAdapter {
|
|
1534
1532
|
companyApi = inject(CompanyApiService);
|
|
1533
|
+
branchApi = inject(BranchApiService);
|
|
1535
1534
|
getCompanies(filter) {
|
|
1536
1535
|
const apiFilter = {
|
|
1537
1536
|
pagination: {
|
|
@@ -1540,18 +1539,27 @@ class AuthCompanyApiProviderAdapter {
|
|
|
1540
1539
|
},
|
|
1541
1540
|
sort: { name: 'ASC' },
|
|
1542
1541
|
};
|
|
1543
|
-
return from(this.companyApi.getAll(apiFilter, filter?.search ?? '')).pipe(map((response) => ({
|
|
1544
|
-
|
|
1545
|
-
|
|
1546
|
-
|
|
1547
|
-
|
|
1548
|
-
|
|
1549
|
-
|
|
1550
|
-
|
|
1551
|
-
|
|
1552
|
-
|
|
1553
|
-
|
|
1554
|
-
|
|
1542
|
+
return from(this.companyApi.getAll(apiFilter, filter?.search ?? '')).pipe(map((response) => mapListResponse(response, (company) => ({
|
|
1543
|
+
id: company.id,
|
|
1544
|
+
name: company.name,
|
|
1545
|
+
slug: company.slug,
|
|
1546
|
+
}))));
|
|
1547
|
+
}
|
|
1548
|
+
getCompaniesByIds(ids) {
|
|
1549
|
+
if (ids.length === 0) {
|
|
1550
|
+
return from(Promise.resolve(emptyListResponse()));
|
|
1551
|
+
}
|
|
1552
|
+
return from(this.companyApi.findByIds(ids, ['id', 'name', 'slug'])).pipe(map((response) => mapListResponse(response, (company) => ({
|
|
1553
|
+
id: company.id,
|
|
1554
|
+
name: company.name,
|
|
1555
|
+
slug: company.slug,
|
|
1556
|
+
}))));
|
|
1557
|
+
}
|
|
1558
|
+
getBranchesByIds(ids) {
|
|
1559
|
+
if (ids.length === 0) {
|
|
1560
|
+
return from(Promise.resolve(emptyListResponse()));
|
|
1561
|
+
}
|
|
1562
|
+
return from(this.branchApi.findByIds(ids, ['id', 'name'])).pipe(map((response) => mapListResponse(response, (branch) => ({ id: branch.id, name: branch.name }))));
|
|
1555
1563
|
}
|
|
1556
1564
|
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.1.5", ngImport: i0, type: AuthCompanyApiProviderAdapter, deps: [], target: i0.ɵɵFactoryTarget.Service });
|
|
1557
1565
|
static ɵprov = i0.ɵɵngDeclareService({ minVersion: "22.0.0", version: "22.1.5", ngImport: i0, type: AuthCompanyApiProviderAdapter, autoProvided: false });
|