Skip to content

Commit 6810dca

Browse files
committed
feat: refactor DNamespaceLicense service and view for improved structure and additional properties
1 parent 40390e7 commit 6810dca

File tree

2 files changed

+34
-17
lines changed

2 files changed

+34
-17
lines changed

src/components/d-namespace/license/DNamespaceLicense.service.ts

Lines changed: 12 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -6,32 +6,27 @@ import {
66
import {DNamespaceLicenseView} from "./DNamespaceLicense.view";
77
import {ReactiveArrayService, ReactiveArrayStore} from "../../../utils/reactiveArrayService";
88

9-
export interface DNamespaceLicenseService {
10-
licenseCreate(payload: NamespacesLicensesCreateInput): DNamespaceLicenseView | undefined
11-
licenseDelete(payload: NamespacesLicensesDeleteInput): void
12-
findById(id: Scalars['NamespaceLicenseID']['output']): DNamespaceLicenseView | undefined
13-
}
14-
15-
export class DNamespaceLicenseReactiveService extends ReactiveArrayService<DNamespaceLicenseView> implements DNamespaceLicenseService{
9+
export abstract class DNamespaceLicenseService extends ReactiveArrayService<DNamespaceLicenseView> {
1610

1711
constructor(payload: ReactiveArrayStore<DNamespaceLicenseView>) {
1812
super(payload);
1913
}
2014

15+
abstract licenseCreate(payload: NamespacesLicensesCreateInput): DNamespaceLicenseView | undefined
16+
17+
abstract licenseDelete(payload: NamespacesLicensesDeleteInput): void
18+
19+
abstract findById(id: Scalars['NamespaceLicenseID']['output']): DNamespaceLicenseView | undefined
20+
}
21+
22+
export abstract class DNamespaceLicenseReactiveService extends DNamespaceLicenseService {
23+
2124
findById(id: Scalars["NamespaceLicenseID"]["output"]): DNamespaceLicenseView | undefined {
2225
return this.values().find(license => license.id === id);
2326
}
2427

25-
licenseCreate(payload: NamespacesLicensesCreateInput): DNamespaceLicenseView | undefined {
26-
return undefined;
27-
}
28+
abstract override licenseCreate(payload: NamespacesLicensesCreateInput): DNamespaceLicenseView | undefined
2829

29-
licenseDelete(payload: NamespacesLicensesDeleteInput): void {
30-
if (this.findById(payload.namespaceLicenseId)) {
31-
const index = this.values().findIndex(license => license.id === payload.namespaceLicenseId);
32-
this.delete(index);
33-
this.update()
34-
}
35-
}
30+
abstract override licenseDelete(payload: NamespacesLicensesDeleteInput): void
3631

3732
}

src/components/d-namespace/license/DNamespaceLicense.view.ts

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,55 @@
11
import {Maybe, Namespace, NamespaceLicense, Scalars} from "@code0-tech/sagittarius-graphql-types";
22

33
export class DNamespaceLicenseView {
4+
/** Time when this NamespaceLicense was created */
45
private readonly _createdAt?: Maybe<Scalars['Time']['output']>;
6+
/** The end date of the license */
7+
private readonly _endDate?: Maybe<Scalars['Time']['output']>;
58
/** Global ID of this NamespaceLicense */
69
private readonly _id?: Maybe<Scalars['NamespaceLicenseID']['output']>;
10+
/** The licensee information */
11+
private readonly _licensee?: Maybe<Scalars['JSON']['output']>;
712
/** The namespace the license belongs to */
813
private readonly _namespace?: Maybe<Namespace>;
14+
/** The start date of the license */
15+
private readonly _startDate?: Maybe<Scalars['Time']['output']>;
916
/** Time when this NamespaceLicense was last updated */
1017
private readonly _updatedAt?: Maybe<Scalars['Time']['output']>;
1118

1219
constructor(payload: NamespaceLicense) {
1320
this._createdAt = payload.createdAt;
21+
this._endDate = payload.endDate;
1422
this._id = payload.id;
23+
this._licensee = payload.licensee;
1524
this._namespace = payload.namespace;
25+
this._startDate = payload.startDate;
1626
this._updatedAt = payload.updatedAt;
1727
}
1828

1929
get createdAt(): Maybe<Scalars["Time"]["output"]> | undefined {
2030
return this._createdAt;
2131
}
2232

33+
get endDate(): Maybe<Scalars["Time"]["output"]> | undefined {
34+
return this._endDate;
35+
}
36+
2337
get id(): Maybe<Scalars["NamespaceLicenseID"]["output"]> | undefined {
2438
return this._id;
2539
}
2640

41+
get licensee(): Maybe<Scalars["JSON"]["output"]> | undefined {
42+
return this._licensee;
43+
}
44+
2745
get namespace(): Maybe<Namespace> | undefined {
2846
return this._namespace;
2947
}
3048

49+
get startDate(): Maybe<Scalars["Time"]["output"]> | undefined {
50+
return this._startDate;
51+
}
52+
3153
get updatedAt(): Maybe<Scalars["Time"]["output"]> | undefined {
3254
return this._updatedAt;
3355
}

0 commit comments

Comments
 (0)