Skip to content

Commit 16f51b6

Browse files
daniel-almeida-konkconsultingtnotheisgithub-actions[bot]Dannyps
authored
Identities overview (#239)
* feat: create adminUi database users for sql server and postgres * feat: add identity overview infrastructure, migrations and api * test: add integration tests for identities overview * fix: update dockerfile * feat: add user interface for identity overview * fix: update dockerfile * refactor: rename Quotas SqlDatabaseConfiguration * feat: add support for cancellation tokens * test: change existing identities integrations tests to use identity overviews * fix: column order in overview page * test: fix route for identities * fix: casing in postgres user for admin ui * fix: only individual quotas should be deleteable from the edit identity page * test: update test to assert list of identities * refactor: prettier format * refactor: add deleteable property to quota to avoid code duplication * fix: datawallet version property type * test: adjust identity overview dto * fix: update postgres setup for case sensitive admin ui user * fix: update test docker compose file * fix: admin-ui not waiting for consumer-api Cannot create migration without consumer-api creating tables first --------- Co-authored-by: Timo Notheisen <[email protected]> Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> Co-authored-by: Daniel Silva <[email protected]>
1 parent 5b07407 commit 16f51b6

File tree

240 files changed

+52482
-52050
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

240 files changed

+52482
-52050
lines changed

.ci/aui/buildContainerImage.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
#!/usr/bin/env -S npx ts-node --esm -T
22

3-
import { $ } from 'zx';
4-
import { getRequiredEnvVar } from '../lib.js';
3+
import { $ } from "zx";
4+
import { getRequiredEnvVar } from "../lib.js";
55

6-
const tag = getRequiredEnvVar('TAG');
6+
const tag = getRequiredEnvVar("TAG");
77

88
await $`docker build --file ./AdminUi/src/AdminUi/Dockerfile --tag ghcr.io/nmshd/backbone-admin-ui:${tag} .`;

.ci/aui/pushContainerImage.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
#!/usr/bin/env -S npx ts-node --esm
22

3-
import { $ } from 'zx';
4-
import { getRequiredEnvVar } from '../lib.js';
3+
import { $ } from "zx";
4+
import { getRequiredEnvVar } from "../lib.js";
55

6-
const tag = getRequiredEnvVar('TAG');
6+
const tag = getRequiredEnvVar("TAG");
77

88
await $`docker push ghcr.io/nmshd/backbone-admin-ui:${tag}`;

.ci/lib.ts

+10-14
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,17 @@
11
import { chalk, $ } from "zx";
22

33
export function getRequiredEnvVar(envVarName: string) {
4-
var envVar = $.env[envVarName];
5-
if (!envVar) {
6-
console.error(
7-
chalk.red(
8-
`The environment variable '${envVarName}' is required, but was not set.`
9-
)
10-
);
11-
process.exit(1);
12-
}
13-
return envVar;
4+
var envVar = $.env[envVarName];
5+
if (!envVar) {
6+
console.error(chalk.red(`The environment variable '${envVarName}' is required, but was not set.`));
7+
process.exit(1);
8+
}
9+
return envVar;
1410
}
1511

1612
export function toCamelCase(input: string) {
17-
const first = input.charAt(0).toLowerCase();
18-
const remaining = input.substring(1);
19-
const result = first + remaining;
20-
return result;
13+
const first = input.charAt(0).toLowerCase();
14+
const remaining = input.substring(1);
15+
const result = first + remaining;
16+
return result;
2117
}

.ci/package.json

+6-6
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
{
2-
"type": "module",
3-
"devDependencies": {
4-
"zx": "^7.2.0",
5-
"ts-node": "^10.9.1",
6-
"typescript": "^4.9.5"
7-
}
2+
"type": "module",
3+
"devDependencies": {
4+
"zx": "^7.2.0",
5+
"ts-node": "^10.9.1",
6+
"typescript": "^4.9.5"
7+
}
88
}

.ci/sc/buildContainerImage.ts

+1-3
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,7 @@ import { getRequiredEnvVar, toCamelCase } from "../lib.js";
55

66
const tag = getRequiredEnvVar("TAG");
77
const moduleName = getRequiredEnvVar("MODULE");
8-
const projectSuffix = $.env["PROJECT_SUFFIX"]
9-
? `.${$.env["PROJECT_SUFFIX"]}`
10-
: "";
8+
const projectSuffix = $.env["PROJECT_SUFFIX"] ? `.${$.env["PROJECT_SUFFIX"]}` : "";
119

1210
const moduleNameCamelCase = toCamelCase(moduleName);
1311

.ci/tsconfig.json

+10-10
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
{
2-
"include": ["**/*.ts"],
3-
"compilerOptions": {
4-
"target": "ES2022",
5-
"module": "ESNext",
6-
"moduleResolution": "node",
7-
"esModuleInterop": true,
8-
"forceConsistentCasingInFileNames": true,
9-
"strict": true,
10-
"skipLibCheck": true
11-
}
2+
"include": ["**/*.ts"],
3+
"compilerOptions": {
4+
"target": "ES2022",
5+
"module": "ESNext",
6+
"moduleResolution": "node",
7+
"esModuleInterop": true,
8+
"forceConsistentCasingInFileNames": true,
9+
"strict": true,
10+
"skipLibCheck": true
11+
}
1212
}

.github/PULL_REQUEST_TEMPLATE.md

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Readiness checklist
22

3-
- [ ] I added/updated unit tests.
4-
- [ ] I added/updated integration tests.
5-
- [ ] I ensured that the PR title is good enough for the changelog.
6-
- [ ] I labeled the PR.
3+
- [ ] I added/updated unit tests.
4+
- [ ] I added/updated integration tests.
5+
- [ ] I ensured that the PR title is good enough for the changelog.
6+
- [ ] I labeled the PR.

.prettierignore

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
**/.angular
2+
**/node_modules
3+
**/obj
4+
**/bin
5+
**/wwwroot
6+
**/helm
7+
!**/helm/**/values.yaml

.prettierrc

+6
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,12 @@
1111
"options": {
1212
"tabWidth": 2
1313
}
14+
},
15+
{
16+
"files": ["*.html"],
17+
"options": {
18+
"bracketSameLine": true
19+
}
1420
}
1521
]
1622
}

.vscode/settings.json

+27
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,30 @@
11
{
2+
"[jsonc]": {
3+
"editor.defaultFormatter": "esbenp.prettier-vscode"
4+
},
5+
"[json]": {
6+
"editor.defaultFormatter": "esbenp.prettier-vscode"
7+
},
8+
"[javascript]": {
9+
"editor.defaultFormatter": "esbenp.prettier-vscode"
10+
},
11+
"[typescript]": {
12+
"editor.defaultFormatter": "esbenp.prettier-vscode"
13+
},
14+
"[yaml]": {
15+
"editor.defaultFormatter": "esbenp.prettier-vscode"
16+
},
17+
"[markdown]": {
18+
"editor.defaultFormatter": "esbenp.prettier-vscode"
19+
},
20+
"[html]": {
21+
"editor.defaultFormatter": "esbenp.prettier-vscode"
22+
},
23+
"editor.formatOnSave": true,
24+
"editor.formatOnPaste": true,
25+
"files.autoSave": "off",
26+
"editor.codeActionsOnSave": {
27+
"source.organizeImports": true
28+
},
229
"files.eol": "\n"
330
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
3+
<PropertyGroup>
4+
<TargetFramework>net7.0</TargetFramework>
5+
<ImplicitUsings>enable</ImplicitUsings>
6+
<Nullable>enable</Nullable>
7+
</PropertyGroup>
8+
9+
<ItemGroup>
10+
<ProjectReference Include="..\AdminUi.Infrastructure\AdminUi.Infrastructure.csproj" />
11+
</ItemGroup>
12+
13+
</Project>

AdminUi/src/AdminUi.Infrastructure.Database.Postgres/Migrations/20230801213931_IdentitiesOverview.Designer.cs

+29
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
using Microsoft.EntityFrameworkCore.Migrations;
2+
3+
#nullable disable
4+
5+
namespace AdminUi.Infrastructure.Database.Postgres.Migrations;
6+
7+
/// <inheritdoc />
8+
public partial class IdentitiesOverview : Migration
9+
{
10+
/// <inheritdoc />
11+
protected override void Up(MigrationBuilder migrationBuilder)
12+
{
13+
migrationBuilder.Sql("""
14+
CREATE OR REPLACE VIEW "IdentityOverviews" AS
15+
SELECT IDENTITIES."Address",
16+
IDENTITIES."CreatedAt",
17+
USERS."LastLoginAt",
18+
IDENTITIES."ClientId" AS "CreatedWithClient",
19+
DATAWALLETS."Version" AS "DatawalletVersion",
20+
IDENTITIES."IdentityVersion",
21+
TIERS."Id" AS "TierId",
22+
TIERS."Name" AS "TierName",
23+
COUNT(IDENTITIES."Address") OVER (PARTITION BY DEVICES."IdentityAddress") AS "NumberOfDevices"
24+
FROM "Devices"."Identities" IDENTITIES
25+
LEFT JOIN "Devices"."Devices" DEVICES ON DEVICES."IdentityAddress" = IDENTITIES."Address"
26+
LEFT JOIN (
27+
SELECT
28+
"DeviceId",
29+
MAX("LastLoginAt") AS "LastLoginAt"
30+
FROM "Devices"."AspNetUsers"
31+
GROUP BY "DeviceId"
32+
) AS USERS ON USERS."DeviceId" = DEVICES."Id"
33+
LEFT JOIN "Synchronization"."Datawallets" DATAWALLETS ON DATAWALLETS."Owner" = IDENTITIES."Address"
34+
LEFT JOIN "Devices"."Tiers" TIERS ON TIERS."Id" = IDENTITIES."TierId"
35+
""");
36+
}
37+
38+
/// <inheritdoc />
39+
protected override void Down(MigrationBuilder migrationBuilder)
40+
{
41+
migrationBuilder.Sql(""" DROP VIEW "IdentityOverviews" """);
42+
}
43+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
// <auto-generated />
2+
using AdminUi.Infrastructure.Persistence.Database;
3+
using Microsoft.EntityFrameworkCore;
4+
using Microsoft.EntityFrameworkCore.Infrastructure;
5+
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
6+
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
7+
8+
#nullable disable
9+
10+
namespace AdminUi.Infrastructure.Database.Postgres.Migrations
11+
{
12+
[DbContext(typeof(AdminUiDbContext))]
13+
partial class AdminUiDbContextModelSnapshot : ModelSnapshot
14+
{
15+
protected override void BuildModel(ModelBuilder modelBuilder)
16+
{
17+
#pragma warning disable 612, 618
18+
modelBuilder
19+
.HasAnnotation("ProductVersion", "7.0.9")
20+
.HasAnnotation("Relational:MaxIdentifierLength", 63);
21+
22+
NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder);
23+
#pragma warning restore 612, 618
24+
}
25+
}
26+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
3+
<PropertyGroup>
4+
<TargetFramework>net7.0</TargetFramework>
5+
<ImplicitUsings>enable</ImplicitUsings>
6+
<Nullable>enable</Nullable>
7+
</PropertyGroup>
8+
9+
<ItemGroup>
10+
<ProjectReference Include="..\AdminUi.Infrastructure\AdminUi.Infrastructure.csproj" />
11+
</ItemGroup>
12+
13+
</Project>

AdminUi/src/AdminUi.Infrastructure.Database.SqlServer/Migrations/20230801163145_IdentitiesOverview.Designer.cs

+29
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
using Microsoft.EntityFrameworkCore.Migrations;
2+
3+
#nullable disable
4+
5+
namespace AdminUi.Infrastructure.Database.SqlServer.Migrations;
6+
7+
/// <inheritdoc />
8+
public partial class IdentitiesOverview : Migration
9+
{
10+
/// <inheritdoc />
11+
protected override void Up(MigrationBuilder migrationBuilder)
12+
{
13+
migrationBuilder.Sql("""
14+
CREATE OR ALTER VIEW IdentityOverviews AS
15+
SELECT IDENTITIES.Address,
16+
IDENTITIES.CreatedAt,
17+
USERS.LastLoginAt,
18+
IDENTITIES.ClientId AS CreatedWithClient,
19+
DATAWALLETS.Version AS DatawalletVersion,
20+
IDENTITIES.IdentityVersion,
21+
TIERS.Id AS TierId,
22+
TIERS.Name AS TierName,
23+
COUNT(IDENTITIES.Address) OVER (PARTITION BY DEVICES.IdentityAddress) AS NumberOfDevices
24+
FROM Devices.Identities IDENTITIES
25+
LEFT JOIN Devices.Devices DEVICES ON DEVICES.IdentityAddress = IDENTITIES.Address
26+
LEFT JOIN (
27+
SELECT
28+
DeviceId,
29+
MAX(LastLoginAt) AS LastLoginAt
30+
FROM Devices.AspNetUsers
31+
GROUP BY DeviceId
32+
) AS USERS ON USERS.DeviceId = DEVICES.Id
33+
LEFT JOIN Synchronization.Datawallets DATAWALLETS ON DATAWALLETS.Owner = IDENTITIES.Address
34+
LEFT JOIN Devices.Tiers TIERS ON TIERS.Id = IDENTITIES.TierId
35+
""");
36+
}
37+
38+
/// <inheritdoc />
39+
protected override void Down(MigrationBuilder migrationBuilder)
40+
{
41+
migrationBuilder.Sql(""" DROP VIEW IdentityOverviews """);
42+
}
43+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
// <auto-generated />
2+
using AdminUi.Infrastructure.Persistence.Database;
3+
using Microsoft.EntityFrameworkCore;
4+
using Microsoft.EntityFrameworkCore.Infrastructure;
5+
using Microsoft.EntityFrameworkCore.Metadata;
6+
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
7+
8+
#nullable disable
9+
10+
namespace AdminUi.Infrastructure.Database.SqlServer.Migrations
11+
{
12+
[DbContext(typeof(AdminUiDbContext))]
13+
partial class AdminUiDbContextModelSnapshot : ModelSnapshot
14+
{
15+
protected override void BuildModel(ModelBuilder modelBuilder)
16+
{
17+
#pragma warning disable 612, 618
18+
modelBuilder
19+
.HasAnnotation("ProductVersion", "7.0.9")
20+
.HasAnnotation("Relational:MaxIdentifierLength", 128);
21+
22+
SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder);
23+
#pragma warning restore 612, 618
24+
}
25+
}
26+
}

0 commit comments

Comments
 (0)