Skip to content

Commit f95bb6a

Browse files
committed
improved structure
1 parent 9b4d9cb commit f95bb6a

25 files changed

+374
-277
lines changed

jsr.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
{
22
"name": "@mycore-test/js-common",
3-
"version": "0.1.0",
3+
"version": "0.1.1",
44
"exports": {
55
"./i18n": "./src/i18n/index.ts",
6+
"./acl/access-key": "./src/acl/access-key/index.ts",
67
"./auth": "./src/auth/index.ts",
7-
"./common/client": "./src/common/client/index.ts",
88
"./orcid": "./src/orcid/index.ts",
9-
"./common/cache": "./src/common/cache/index.ts",
10-
"./acl/accesskey": "./src/acl/accesskey/index.ts"
9+
"./utils/cache": "./src/utils/cache/index.ts",
10+
"./utils/client": "./src/utils/client/index.ts"
1111
},
1212
"publish": {
1313
"include": [
Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -16,23 +16,21 @@
1616
* along with MyCoRe. If not, see <http://www.gnu.org/licenses/>.
1717
*/
1818

19-
import { HttpClient, HttpResponse } from '../../common/client';
20-
import {
21-
AccessKey,
22-
CreateAccessKeyDto,
23-
UpdateAccessKeyDto,
24-
PartialUpdateAccessKeyDto,
25-
AccessKeySummary,
26-
} from './model';
19+
import { HttpClient, HttpResponse } from '../../utils/client';
20+
import { AccessKeyDto } from './dtos/access-key.dto';
21+
import { CreateAccessKeyDto } from './dtos/create-access-key.dto';
22+
import { UpdateAccessKeyDto } from './dtos/update-access-key.dto';
23+
import { PartialUpdateAccessKeyDto } from './dtos/partial-update-access-key.dto';
24+
import { AccessKeysSummary } from './dtos/access-keys-summary.dto';
2725

2826
/**
2927
* Extracts the response data and returns the access key summary.
3028
* @param response - The response object containing the data and headers.
3129
* @returns The parsed access keys summary.
3230
*/
3331
const createSummary = (
34-
response: HttpResponse<AccessKey[]>
35-
): AccessKeySummary => {
32+
response: HttpResponse<AccessKeyDto[]>
33+
): AccessKeysSummary => {
3634
const totalCount = response.headers['x-total-count'];
3735
return {
3836
accessKeys: response.data,
@@ -91,7 +89,7 @@ export class AccessKeyService {
9189
*/
9290
public async getAccessKeys(
9391
options?: GetAccessKeysOptions
94-
): Promise<AccessKeySummary> {
92+
): Promise<AccessKeysSummary> {
9593
const searchParams = new URLSearchParams();
9694
if (options?.reference) {
9795
searchParams.set('reference', options.reference);
@@ -107,7 +105,7 @@ export class AccessKeyService {
107105
}
108106
try {
109107
return createSummary(
110-
await this.client.get<AccessKey[]>(
108+
await this.client.get<AccessKeyDto[]>(
111109
`${API_URL}?${searchParams.toString()}`
112110
)
113111
);
@@ -121,9 +119,9 @@ export class AccessKeyService {
121119
* @param id - The ID of the access key.
122120
* @returns A promise that resolves with the access key data.
123121
*/
124-
public async getAccessKey(id: string): Promise<AccessKey> {
122+
public async getAccessKey(id: string): Promise<AccessKeyDto> {
125123
try {
126-
return (await this.client.get<AccessKey>(`${API_URL}/${id}`)).data;
124+
return (await this.client.get<AccessKeyDto>(`${API_URL}/${id}`)).data;
127125
} catch (error) {
128126
throw new Error(`Failed to get access key: ${(error as Error).message}`);
129127
}
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
/*!
2+
* This file is part of *** M y C o R e ***
3+
* See https://www.mycore.de/ for details.
4+
*
5+
* MyCoRe is free software: you can redistribute it and/or modify
6+
* it under the terms of the GNU General Public License as published by
7+
* the Free Software Foundation, either version 3 of the License, or
8+
* (at your option) any later version.
9+
*
10+
* MyCoRe is distributed in the hope that it will be useful,
11+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
12+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13+
* GNU General Public License for more details.
14+
*
15+
* You should have received a copy of the GNU General Public License
16+
* along with MyCoRe. If not, see <http://www.gnu.org/licenses/>.
17+
*/
18+
19+
/**
20+
* Represents an access key in the system.
21+
*/
22+
export interface AccessKeyDto {
23+
/**
24+
* The unique identifier for the access key.
25+
*/
26+
id: string;
27+
28+
/**
29+
* A reference or name associated with the access key.
30+
*/
31+
reference: string;
32+
33+
/**
34+
* The secret associated with the access key used for authentication.
35+
*/
36+
secret: string;
37+
38+
/**
39+
* The permission type for the authentication.
40+
*/
41+
type: string;
42+
43+
/**
44+
* Indicates whether the access key is currently useable.
45+
*/
46+
isActive: boolean;
47+
48+
/**
49+
* An optional comment or description that provides additional context for the access key.
50+
*/
51+
comment?: string;
52+
53+
/**
54+
* An optional expiration timestamp (in Unix time) indicating when the access key expires.
55+
* If `null`, the key does not expire.
56+
*/
57+
expiration?: number | null;
58+
}

src/acl/accesskey/config.ts renamed to src/acl/access-key/dtos/access-keys-summary.dto.ts

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,17 +16,19 @@
1616
* along with MyCoRe. If not, see <http://www.gnu.org/licenses/>.
1717
*/
1818

19+
import { AccessKeyDto } from './access-key.dto';
20+
1921
/**
20-
* Configuration for access keys.
22+
* Information about the access keys.
2123
*/
22-
export interface AccessKeyConfig {
24+
export interface AccessKeysSummary {
2325
/**
24-
* A boolean indicating whether access key for sessions are enabled.
26+
* An array access keys that are part of the summary.
2527
*/
26-
isAccessKeySessionEnabled: boolean;
28+
accessKeys: AccessKeyDto[];
2729

2830
/**
29-
* An array of strings representing the permissions that are allowed for access keys in sessions.
31+
* The total count of all access keys.
3032
*/
31-
allowedAccessKeySessionPermissions: string[];
33+
totalCount: number;
3234
}
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
/*!
2+
* This file is part of *** M y C o R e ***
3+
* See https://www.mycore.de/ for details.
4+
*
5+
* MyCoRe is free software: you can redistribute it and/or modify
6+
* it under the terms of the GNU General Public License as published by
7+
* the Free Software Foundation, either version 3 of the License, or
8+
* (at your option) any later version.
9+
*
10+
* MyCoRe is distributed in the hope that it will be useful,
11+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
12+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13+
* GNU General Public License for more details.
14+
*
15+
* You should have received a copy of the GNU General Public License
16+
* along with MyCoRe. If not, see <http://www.gnu.org/licenses/>.
17+
*/
18+
19+
/**
20+
* DTO for creating a new access key.
21+
*/
22+
export interface CreateAccessKeyDto {
23+
/**
24+
* A reference or name associated with the access key.
25+
*/
26+
reference: string;
27+
28+
/**
29+
* The secret associated with the access key used for authentication.
30+
*/
31+
secret: string;
32+
33+
/**
34+
* The permission type for the authentication.
35+
*/
36+
type: string;
37+
38+
/**
39+
* Indicates whether the access key is currently useable.
40+
*/
41+
isActive: boolean;
42+
43+
/**
44+
* An optional comment or description that provides additional context for the access key.
45+
*/
46+
comment?: string;
47+
48+
/**
49+
* An optional expiration timestamp (in Unix time) indicating when the access key expires.
50+
* If `null`, the key does not expire.
51+
*/
52+
expiration?: string | null;
53+
}
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
/*!
2+
* This file is part of *** M y C o R e ***
3+
* See https://www.mycore.de/ for details.
4+
*
5+
* MyCoRe is free software: you can redistribute it and/or modify
6+
* it under the terms of the GNU General Public License as published by
7+
* the Free Software Foundation, either version 3 of the License, or
8+
* (at your option) any later version.
9+
*
10+
* MyCoRe is distributed in the hope that it will be useful,
11+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
12+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13+
* GNU General Public License for more details.
14+
*
15+
* You should have received a copy of the GNU General Public License
16+
* along with MyCoRe. If not, see <http://www.gnu.org/licenses/>.
17+
*/
18+
19+
/**
20+
* DTO for partially updating an access key.
21+
*/
22+
export interface PartialUpdateAccessKeyDto {
23+
/**
24+
* An optional reference or name associated with the access key.
25+
*/
26+
reference?: string;
27+
28+
/**
29+
* An optional permission type for the authentication.
30+
*/
31+
type?: string;
32+
33+
/**
34+
* An optional that indicates whether the access key is currently useable.
35+
*/
36+
isActive?: boolean;
37+
38+
/**
39+
* An optional comment or description that provides additional context for the access key.
40+
*/
41+
comment?: string;
42+
43+
/**
44+
* An optional expiration timestamp (in Unix time) indicating when the access key expires.
45+
* If `null`, the key does not expire.
46+
*/
47+
expiration?: string | null;
48+
}
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
/*!
2+
* This file is part of *** M y C o R e ***
3+
* See https://www.mycore.de/ for details.
4+
*
5+
* MyCoRe is free software: you can redistribute it and/or modify
6+
* it under the terms of the GNU General Public License as published by
7+
* the Free Software Foundation, either version 3 of the License, or
8+
* (at your option) any later version.
9+
*
10+
* MyCoRe is distributed in the hope that it will be useful,
11+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
12+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13+
* GNU General Public License for more details.
14+
*
15+
* You should have received a copy of the GNU General Public License
16+
* along with MyCoRe. If not, see <http://www.gnu.org/licenses/>.
17+
*/
18+
19+
/**
20+
* DTO for updating an access key.
21+
*/
22+
export interface UpdateAccessKeyDto {
23+
/**
24+
* A reference or name associated with the access key.
25+
*/
26+
reference: string;
27+
28+
/**
29+
* The secret associated with the access key used for authentication.
30+
*/
31+
secret: string;
32+
33+
/**
34+
* The permission type for the authentication.
35+
*/
36+
type: string;
37+
38+
/**
39+
* Indicates whether the access key is currently useable.
40+
*/
41+
isActive: boolean;
42+
43+
/**
44+
* An optional comment or description that provides additional context for the access key.
45+
*/
46+
comment?: string;
47+
48+
/**
49+
* An optional expiration timestamp (in Unix time) indicating when the access key expires.
50+
* If `null`, the key does not expire.
51+
*/
52+
expiration?: number | null;
53+
}
Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,9 @@
2121
* @module
2222
*/
2323

24-
export * from './model';
25-
export * from './service';
26-
export * from './config';
24+
export * from './access-key.service';
25+
export * from './dtos/access-key.dto';
26+
export * from './dtos/access-keys-summary.dto';
27+
export * from './dtos/create-access-key.dto';
28+
export * from './dtos/partial-update-access-key.dto';
29+
export * from './dtos/update-access-key.dto';

0 commit comments

Comments
 (0)