@en-solutions/tgm-client-sdk 1.8.4 → 1.9.2
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/esm2022/lib/models/api/ai-usage.models.mjs +6 -0
- package/esm2022/lib/models/api/grid.models.mjs +6 -0
- package/esm2022/lib/models/api/plugin.models.mjs +3 -0
- package/esm2022/lib/models/auth/index.mjs +2 -1
- package/esm2022/lib/models/auth/webauthn.models.mjs +2 -0
- package/esm2022/lib/models/index.mjs +3 -1
- package/esm2022/lib/services/api/ai-usage.service.mjs +36 -0
- package/esm2022/lib/services/api/asset-lifecycle.service.mjs +7 -4
- package/esm2022/lib/services/api/export.service.mjs +14 -1
- package/esm2022/lib/services/api/grid.service.mjs +80 -0
- package/esm2022/lib/services/api/index.mjs +4 -1
- package/esm2022/lib/services/api/plugin.service.mjs +49 -0
- package/esm2022/lib/services/auth/index.mjs +2 -1
- package/esm2022/lib/services/auth/webauthn.service.mjs +63 -0
- package/fesm2022/en-solutions-tgm-client-sdk.mjs +240 -5
- package/fesm2022/en-solutions-tgm-client-sdk.mjs.map +1 -1
- package/lib/models/api/ai-usage.models.d.ts +24 -0
- package/lib/models/api/grid.models.d.ts +55 -0
- package/lib/models/api/plugin.models.d.ts +20 -0
- package/lib/models/auth/index.d.ts +1 -0
- package/lib/models/auth/webauthn.models.d.ts +8 -0
- package/lib/models/index.d.ts +2 -0
- package/lib/services/api/ai-usage.service.d.ts +22 -0
- package/lib/services/api/asset-lifecycle.service.d.ts +2 -1
- package/lib/services/api/export.service.d.ts +4 -0
- package/lib/services/api/grid.service.d.ts +54 -0
- package/lib/services/api/index.d.ts +3 -0
- package/lib/services/api/plugin.service.d.ts +25 -0
- package/lib/services/auth/index.d.ts +1 -0
- package/lib/services/auth/webauthn.service.d.ts +32 -0
- package/package.json +5 -3
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* AI usage / cost attribution models.
|
|
3
|
+
* Mirrors GET /api/ai/usage/summary (backend AiUsageController).
|
|
4
|
+
*/
|
|
5
|
+
/** Feature/source taxonomy used to attribute AI usage (matches backend AiFeature). */
|
|
6
|
+
export type AiFeature = 'AI_ASSISTANT' | 'AGENT' | 'CORTEX' | 'EMBEDDINGS' | 'SEMANTIC_SEARCH' | 'NL_SEARCH' | 'TRANSCRIPTION' | 'REPORT_GENERATION' | 'SANDBOX' | 'OTHER' | string;
|
|
7
|
+
/** One aggregation row (by feature, provider or model). */
|
|
8
|
+
export interface AiUsageRow {
|
|
9
|
+
key: string;
|
|
10
|
+
calls: number;
|
|
11
|
+
tokens: number;
|
|
12
|
+
costUsd: number;
|
|
13
|
+
}
|
|
14
|
+
/** Usage summary over a date range for the current tenant. */
|
|
15
|
+
export interface AiUsageSummary {
|
|
16
|
+
from: string;
|
|
17
|
+
to: string;
|
|
18
|
+
totalCalls: number;
|
|
19
|
+
totalTokens: number;
|
|
20
|
+
totalCostUsd: number;
|
|
21
|
+
byFeature: AiUsageRow[];
|
|
22
|
+
byProvider: AiUsageRow[];
|
|
23
|
+
byModel: AiUsageRow[];
|
|
24
|
+
}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Grid Management plugin models — distribution network nodes/links and live status.
|
|
3
|
+
* Mirrors the backend `ca.ensolutions.tgm.grid` entities and DTOs.
|
|
4
|
+
*/
|
|
5
|
+
export type GridNodeType = 'SUBSTATION' | 'DISTRIBUTION_SUBSTATION' | 'TRANSFORMER' | 'FEEDER' | 'LINE' | 'SWITCH' | 'RING_MAIN_UNIT' | 'BUSBAR' | 'POLE' | 'METER' | 'OTHER';
|
|
6
|
+
export type GridLinkType = 'OVERHEAD_LINE' | 'UNDERGROUND_CABLE' | 'TRANSFORMER_LINK' | 'BUSBAR_LINK' | 'OTHER';
|
|
7
|
+
/** Live availability state of a grid element. */
|
|
8
|
+
export type OperationalState = 'UP' | 'DEGRADED' | 'DOWN' | 'IMPACTED' | 'UNKNOWN';
|
|
9
|
+
export interface GridNode {
|
|
10
|
+
id?: number;
|
|
11
|
+
name: string;
|
|
12
|
+
nodeType: GridNodeType;
|
|
13
|
+
description?: string;
|
|
14
|
+
latitude?: number;
|
|
15
|
+
longitude?: number;
|
|
16
|
+
voltageLevelKv?: number;
|
|
17
|
+
ratedCapacityKva?: number;
|
|
18
|
+
parentNodeId?: number;
|
|
19
|
+
operationalState?: OperationalState;
|
|
20
|
+
stateSince?: string;
|
|
21
|
+
lastTelemetryAt?: string;
|
|
22
|
+
componentId?: number;
|
|
23
|
+
locationId?: number;
|
|
24
|
+
deviceGatewayId?: number;
|
|
25
|
+
aipNetworkNodeId?: number;
|
|
26
|
+
customFields?: Record<string, any>;
|
|
27
|
+
createdAt?: string;
|
|
28
|
+
updatedAt?: string;
|
|
29
|
+
}
|
|
30
|
+
export interface GridLink {
|
|
31
|
+
id?: number;
|
|
32
|
+
name?: string;
|
|
33
|
+
fromNodeId: number;
|
|
34
|
+
toNodeId: number;
|
|
35
|
+
linkType?: GridLinkType;
|
|
36
|
+
operationalState?: OperationalState;
|
|
37
|
+
lengthKm?: number;
|
|
38
|
+
voltageLevelKv?: number;
|
|
39
|
+
createdAt?: string;
|
|
40
|
+
updatedAt?: string;
|
|
41
|
+
}
|
|
42
|
+
/** A node's live status as returned by GET /api/grid/status and pushed on /topic/grid/status. */
|
|
43
|
+
export interface GridNodeStatus {
|
|
44
|
+
id: number;
|
|
45
|
+
name: string;
|
|
46
|
+
nodeType: GridNodeType;
|
|
47
|
+
latitude?: number;
|
|
48
|
+
longitude?: number;
|
|
49
|
+
voltageLevelKv?: number;
|
|
50
|
+
operationalState: OperationalState;
|
|
51
|
+
parentNodeId?: number;
|
|
52
|
+
lastTelemetryAt?: string;
|
|
53
|
+
activeAlertSeverity?: 'INFO' | 'WARNING' | 'CRITICAL' | 'EMERGENCY' | null;
|
|
54
|
+
reachable: boolean;
|
|
55
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/** Plugin framework models — installable per-tenant modules. */
|
|
2
|
+
export interface PluginStatus {
|
|
3
|
+
id: string;
|
|
4
|
+
name: string;
|
|
5
|
+
version: string;
|
|
6
|
+
description: string;
|
|
7
|
+
requiredLicenseFeature?: string | null;
|
|
8
|
+
menuModuleId?: string | null;
|
|
9
|
+
installed: boolean;
|
|
10
|
+
status: 'INSTALLED' | 'DISABLED' | 'NOT_INSTALLED' | string;
|
|
11
|
+
installedAt?: string | null;
|
|
12
|
+
}
|
|
13
|
+
export interface InstalledPlugin {
|
|
14
|
+
id?: number;
|
|
15
|
+
pluginId: string;
|
|
16
|
+
version?: string;
|
|
17
|
+
status: 'INSTALLED' | 'DISABLED';
|
|
18
|
+
installedAt?: string;
|
|
19
|
+
installedBy?: string;
|
|
20
|
+
}
|
package/lib/models/index.d.ts
CHANGED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { Observable } from 'rxjs';
|
|
2
|
+
import { TgmHttpClient } from '../../core/http-client.service';
|
|
3
|
+
import { ApiResponse } from '../../models/base.models';
|
|
4
|
+
import { AiUsageSummary } from '../../models/api/ai-usage.models';
|
|
5
|
+
import * as i0 from "@angular/core";
|
|
6
|
+
/**
|
|
7
|
+
* AI usage & cost attribution for the current tenant.
|
|
8
|
+
* Backend: AiUsageController (admin-only).
|
|
9
|
+
*/
|
|
10
|
+
export declare class AiUsageService {
|
|
11
|
+
private http;
|
|
12
|
+
private basePath;
|
|
13
|
+
constructor(http: TgmHttpClient);
|
|
14
|
+
/**
|
|
15
|
+
* Usage summary (calls, tokens, cost) broken down by feature / provider / model.
|
|
16
|
+
* @param from optional ISO date (yyyy-MM-dd), defaults server-side to 30 days ago
|
|
17
|
+
* @param to optional ISO date (yyyy-MM-dd), defaults server-side to today
|
|
18
|
+
*/
|
|
19
|
+
getSummary(from?: string, to?: string): Observable<ApiResponse<AiUsageSummary>>;
|
|
20
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<AiUsageService, never>;
|
|
21
|
+
static ɵprov: i0.ɵɵInjectableDeclaration<AiUsageService>;
|
|
22
|
+
}
|
|
@@ -22,7 +22,8 @@ export declare class AssetLifecycleService {
|
|
|
22
22
|
getRecommendedReplacement(): Observable<ApiResponse<AssetLifecycle[]>>;
|
|
23
23
|
getDashboard(): Observable<ApiResponse<any>>;
|
|
24
24
|
getStageEnums(): Observable<ApiResponse<string[]>>;
|
|
25
|
-
/** Create a lifecycle record via the collection endpoint
|
|
25
|
+
/** Create a lifecycle record via the standard collection endpoint. The backend expects a FLAT
|
|
26
|
+
* payload — wrapping it in { data } makes Spring ignore every field and persist an empty record. */
|
|
26
27
|
createRecord(data: Record<string, any>): Observable<ApiResponse<AssetLifecycle>>;
|
|
27
28
|
static ɵfac: i0.ɵɵFactoryDeclaration<AssetLifecycleService, never>;
|
|
28
29
|
static ɵprov: i0.ɵɵInjectableDeclaration<AssetLifecycleService>;
|
|
@@ -5,6 +5,10 @@ export declare class ExportService {
|
|
|
5
5
|
private http;
|
|
6
6
|
private basePath;
|
|
7
7
|
constructor(http: TgmHttpClient);
|
|
8
|
+
/** Export the dashboard KPIs as CSV (period in days, default 30). */
|
|
9
|
+
exportDashboardCsv(periodDays?: number): Observable<Blob>;
|
|
10
|
+
/** Export the dashboard KPIs as Excel (period in days, default 30). */
|
|
11
|
+
exportDashboardExcel(periodDays?: number): Observable<Blob>;
|
|
8
12
|
exportInspectionsExcel(ids?: number[]): Observable<Blob>;
|
|
9
13
|
exportInspectionsCsv(ids?: number[]): Observable<Blob>;
|
|
10
14
|
exportInspectionsPdf(ids?: number[]): Observable<Blob>;
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { Observable } from 'rxjs';
|
|
2
|
+
import { TgmHttpClient } from '../../core/http-client.service';
|
|
3
|
+
import { WebSocketService } from '../../core/websocket.service';
|
|
4
|
+
import { BaseCrudService } from './base-crud.service';
|
|
5
|
+
import { ApiResponse } from '../../models/base.models';
|
|
6
|
+
import { GridLink, GridNode, GridNodeStatus } from '../../models/api/grid.models';
|
|
7
|
+
import * as i0 from "@angular/core";
|
|
8
|
+
/** CRUD for grid nodes (`/api/grid/nodes`). Requires the grid-management plugin. */
|
|
9
|
+
export declare class GridNodeService extends BaseCrudService<GridNode> {
|
|
10
|
+
protected resourcePath: string;
|
|
11
|
+
constructor(http: TgmHttpClient);
|
|
12
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<GridNodeService, never>;
|
|
13
|
+
static ɵprov: i0.ɵɵInjectableDeclaration<GridNodeService>;
|
|
14
|
+
}
|
|
15
|
+
/** CRUD for grid links/edges (`/api/grid/links`). */
|
|
16
|
+
export declare class GridLinkService extends BaseCrudService<GridLink> {
|
|
17
|
+
protected resourcePath: string;
|
|
18
|
+
constructor(http: TgmHttpClient);
|
|
19
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<GridLinkService, never>;
|
|
20
|
+
static ɵprov: i0.ɵɵInjectableDeclaration<GridLinkService>;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Real-time distribution-grid view: the status snapshot that powers the map plus a live STOMP feed.
|
|
24
|
+
*
|
|
25
|
+
* Typical usage:
|
|
26
|
+
* ```ts
|
|
27
|
+
* grid.status().subscribe(r => this.render(r.data)); // initial map render
|
|
28
|
+
* grid.liveStatus().subscribe(snapshot => this.render(snapshot)); // live updates
|
|
29
|
+
* ```
|
|
30
|
+
*/
|
|
31
|
+
export declare class GridService {
|
|
32
|
+
private http;
|
|
33
|
+
private ws;
|
|
34
|
+
private base;
|
|
35
|
+
static readonly TOPIC_STATUS = "/topic/grid/status";
|
|
36
|
+
constructor(http: TgmHttpClient, ws: WebSocketService);
|
|
37
|
+
/** Live status snapshot of every node (for the initial map render). */
|
|
38
|
+
status(): Observable<ApiResponse<GridNodeStatus[]>>;
|
|
39
|
+
/** All links/edges (for drawing the topology). */
|
|
40
|
+
links(): Observable<ApiResponse<GridLink[]>>;
|
|
41
|
+
/** Admin: recompute and persist live states, then broadcast over WebSocket. */
|
|
42
|
+
recompute(): Observable<ApiResponse<{
|
|
43
|
+
changed: number;
|
|
44
|
+
}>>;
|
|
45
|
+
/**
|
|
46
|
+
* Live stream of full status snapshots pushed on `/topic/grid/status`.
|
|
47
|
+
* Ensure {@link WebSocketService.connect} has been called once after login.
|
|
48
|
+
*/
|
|
49
|
+
liveStatus(): Observable<GridNodeStatus[]>;
|
|
50
|
+
/** Live stream for a single node pushed on `/topic/grid/node/{id}`. */
|
|
51
|
+
liveNode(nodeId: number): Observable<GridNodeStatus>;
|
|
52
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<GridService, never>;
|
|
53
|
+
static ɵprov: i0.ɵɵInjectableDeclaration<GridService>;
|
|
54
|
+
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
export { BaseCrudService } from './base-crud.service';
|
|
2
|
+
export { AiUsageService } from './ai-usage.service';
|
|
2
3
|
export { CompanyService } from './company.service';
|
|
3
4
|
export { UnitService } from './unit.service';
|
|
4
5
|
export { ComponentService, ComponentGroupService, SubAssemblyService } from './component.service';
|
|
@@ -101,3 +102,5 @@ export { AuditEntryService } from './audit-entry.service';
|
|
|
101
102
|
export { ThresholdAlertRuleService } from './threshold-alert-rule.service';
|
|
102
103
|
export { CmsContentTypeService, CmsDataService } from './cms.service';
|
|
103
104
|
export { CmsMenuHelper, CmsMenuItem, CmsMenuSection } from './cms-menu.helper';
|
|
105
|
+
export { GridService, GridNodeService, GridLinkService } from './grid.service';
|
|
106
|
+
export { PluginService } from './plugin.service';
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { Observable } from 'rxjs';
|
|
2
|
+
import { TgmHttpClient } from '../../core/http-client.service';
|
|
3
|
+
import { ApiResponse } from '../../models/base.models';
|
|
4
|
+
import { InstalledPlugin, PluginStatus } from '../../models/api/plugin.models';
|
|
5
|
+
import * as i0 from "@angular/core";
|
|
6
|
+
/**
|
|
7
|
+
* Installable modules (plugins) for the current organization.
|
|
8
|
+
*
|
|
9
|
+
* `list()` is readable by any authenticated user — the frontend uses it to decide which modules /
|
|
10
|
+
* menus to reveal. `install()` / `uninstall()` require an admin and run the plugin's isolated
|
|
11
|
+
* migrations on the tenant DB.
|
|
12
|
+
*/
|
|
13
|
+
export declare class PluginService {
|
|
14
|
+
private http;
|
|
15
|
+
private base;
|
|
16
|
+
constructor(http: TgmHttpClient);
|
|
17
|
+
/** Catalog of all plugins with this organization's install status. */
|
|
18
|
+
list(): Observable<ApiResponse<PluginStatus[]>>;
|
|
19
|
+
/** True if the given plugin is installed for the current organization. */
|
|
20
|
+
isInstalled(pluginId: string): Observable<boolean>;
|
|
21
|
+
install(pluginId: string): Observable<ApiResponse<InstalledPlugin>>;
|
|
22
|
+
uninstall(pluginId: string): Observable<ApiResponse<void>>;
|
|
23
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<PluginService, never>;
|
|
24
|
+
static ɵprov: i0.ɵɵInjectableDeclaration<PluginService>;
|
|
25
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { Observable } from 'rxjs';
|
|
2
|
+
import { TgmHttpClient } from '../../core/http-client.service';
|
|
3
|
+
import { ApiResponse } from '../../models/base.models';
|
|
4
|
+
import { AuthResponse } from '../../models/auth/login.models';
|
|
5
|
+
import { WebAuthnCredentialView } from '../../models/auth/webauthn.models';
|
|
6
|
+
import * as i0 from "@angular/core";
|
|
7
|
+
/**
|
|
8
|
+
* WebAuthn / passkeys / security keys.
|
|
9
|
+
*
|
|
10
|
+
* Registration & key management require an authenticated session; passkey login is public.
|
|
11
|
+
* Uses @github/webauthn-json (the matching browser library for the backend's Yubico server).
|
|
12
|
+
*/
|
|
13
|
+
export declare class WebAuthnService {
|
|
14
|
+
private http;
|
|
15
|
+
private base;
|
|
16
|
+
constructor(http: TgmHttpClient);
|
|
17
|
+
/** True if this browser supports WebAuthn. */
|
|
18
|
+
isSupported(): boolean;
|
|
19
|
+
/** Register a new passkey / security key for the current (logged-in) user. */
|
|
20
|
+
registerKey(deviceName?: string): Promise<void>;
|
|
21
|
+
/**
|
|
22
|
+
* Log in with a passkey. Pass a username for username-first flows, or omit it for a
|
|
23
|
+
* usernameless (discoverable credential) login. Stores the JWT on success.
|
|
24
|
+
*/
|
|
25
|
+
loginWithPasskey(username?: string): Promise<AuthResponse>;
|
|
26
|
+
/** List the current user's registered keys. */
|
|
27
|
+
listKeys(): Observable<ApiResponse<WebAuthnCredentialView[]>>;
|
|
28
|
+
/** Remove a registered key. */
|
|
29
|
+
deleteKey(id: number): Observable<ApiResponse<void>>;
|
|
30
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<WebAuthnService, never>;
|
|
31
|
+
static ɵprov: i0.ɵɵInjectableDeclaration<WebAuthnService>;
|
|
32
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@en-solutions/tgm-client-sdk",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.9.2",
|
|
4
4
|
"description": "TGM Manager Client SDK for Angular 18 - Type-safe services for all TGM API endpoints",
|
|
5
5
|
"license": "SEE LICENSE IN LICENSE",
|
|
6
6
|
"repository": {
|
|
@@ -8,13 +8,15 @@
|
|
|
8
8
|
"url": "https://github.com/EN-Solutions/tgm-client-sdk.git"
|
|
9
9
|
},
|
|
10
10
|
"publishConfig": {
|
|
11
|
-
"registry": "https://
|
|
11
|
+
"registry": "https://registry.npmjs.org/",
|
|
12
|
+
"access": "public"
|
|
12
13
|
},
|
|
13
14
|
"peerDependencies": {
|
|
14
15
|
"@angular/common": "^18.0.0",
|
|
15
16
|
"@angular/core": "^18.0.0",
|
|
16
17
|
"@angular/forms": "^18.0.0",
|
|
17
|
-
"rxjs": "^7.8.0"
|
|
18
|
+
"rxjs": "^7.8.0",
|
|
19
|
+
"@github/webauthn-json": "^2.1.1"
|
|
18
20
|
},
|
|
19
21
|
"dependencies": {
|
|
20
22
|
"@stomp/stompjs": "^7.0.0",
|