@hahnpro/hpc-api 2026.7.10 → 2026.8.0
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/CHANGELOG.md +9 -0
- package/package.json +4 -4
- package/src/lib/interfaces/ai.interface.d.ts +9 -3
- package/src/lib/interfaces/ai.interface.js +7 -1
- package/src/lib/interfaces/index.d.ts +6 -6
- package/src/lib/interfaces/index.js +3 -2
- package/src/lib/interfaces/type-guards.js +1 -1
- package/src/lib/mock/asset.mock.service.d.ts +2 -2
- package/src/lib/mock/event.mock.service.js +6 -1
- package/src/lib/mock/timeseries.mock.service.js +13 -1
- package/src/lib/services/asset.service.d.ts +2 -2
- package/src/lib/utils.d.ts +2 -1
- package/src/lib/utils.js +4 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,14 @@
|
|
|
1
1
|
# @hahnpro/hpc-api
|
|
2
2
|
|
|
3
|
+
# 2026.7.9
|
|
4
|
+
|
|
5
|
+
- Added `AttachmentHandlingMode.DISABLED` to disable attachment handling for individual AI messages
|
|
6
|
+
- Added and exported `ATTACHMENT_CAPABLE_AGENT_IDS` and `agentSupportsAttachments` for centralized agent attachment capabilities
|
|
7
|
+
- Added `LOAD_USER_MESSAGE_ATTACHMENT_REFERENCES`, `LOAD_ATTACHMENT_ANALYSIS`, and `SEARCH_IN_ATTACHMENTS` tool names for on-demand attachment loading
|
|
8
|
+
- Changed `MessageAttachment` to require `id` and replaced the extracted `text` field with `mimetype`
|
|
9
|
+
- Implemented `EventMockService.getLastEventByAssetAndGroups` to return the latest event cause for each requested group
|
|
10
|
+
- Implemented `TimeseriesMockService.getMostRecentTimeSeriesValueByAssetAndTimeSeriesName` to return the latest value for each requested time series
|
|
11
|
+
|
|
3
12
|
# 2026.7.6
|
|
4
13
|
|
|
5
14
|
- Changed the HPC-API `getAttachments`-endpoint for assets to be able to use it with pagination
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hahnpro/hpc-api",
|
|
3
|
-
"version": "2026.
|
|
3
|
+
"version": "2026.8.0",
|
|
4
4
|
"description": "Module for easy access to the HahnPRO Cloud API",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": {
|
|
@@ -9,9 +9,9 @@
|
|
|
9
9
|
},
|
|
10
10
|
"dependencies": {
|
|
11
11
|
"@microsoft/fetch-event-source": "2.0.1",
|
|
12
|
-
"axios": "1.
|
|
13
|
-
"eventsource": "4.1.
|
|
14
|
-
"jose": "6.2.
|
|
12
|
+
"axios": "1.19.0",
|
|
13
|
+
"eventsource": "4.1.1",
|
|
14
|
+
"jose": "6.2.8",
|
|
15
15
|
"jwt-decode": "4.0.0",
|
|
16
16
|
"p-queue": "9.3.3",
|
|
17
17
|
"rxjs": "7.8.2",
|
|
@@ -48,6 +48,7 @@ export declare enum ToolType {
|
|
|
48
48
|
BUILT_IN_ACTION = "built_in-action"
|
|
49
49
|
}
|
|
50
50
|
export declare enum AttachmentHandlingMode {
|
|
51
|
+
DISABLED = "disabled",
|
|
51
52
|
USE_ANALYSIS_IN_CHAT = "useAnalysisInChat",
|
|
52
53
|
DONT_USE_ANALYSIS_IN_CHAT = "dontUseAnalysisInChat"
|
|
53
54
|
}
|
|
@@ -79,6 +80,7 @@ export declare enum AgentId {
|
|
|
79
80
|
AXALTA_MESSAGE = "axalta-message-agent",
|
|
80
81
|
TRIAGE = "triage-agent"
|
|
81
82
|
}
|
|
83
|
+
export declare const ATTACHMENT_CAPABLE_AGENT_IDS: AgentId[];
|
|
82
84
|
export declare enum ToolName {
|
|
83
85
|
SWITCH_ASSISTANT = "switchAssistant",
|
|
84
86
|
FIND_TASKS_BY_ASSET = "findTasksByAsset",
|
|
@@ -107,9 +109,13 @@ export declare enum ToolName {
|
|
|
107
109
|
USE_DRYER_SELECTION_TOOL = "useDryerSelectionTool",
|
|
108
110
|
USE_RFD_BASIC_CALCULATION_TOOL = "useRfdBasicCalculationTool",
|
|
109
111
|
ADD_TASK_LOGBOOK_ENTRY = "addTaskLogbookEntry",
|
|
112
|
+
LOAD_USER_MESSAGE_ATTACHMENT_REFERENCES = "loadUserMessageAttachmentReferences",
|
|
113
|
+
SEARCH_IN_ATTACHMENTS = "searchInAttachments",
|
|
114
|
+
LOAD_ATTACHMENT_ANALYSIS = "loadAttachmentAnalysis",
|
|
110
115
|
WEB_SEARCH = "web_search",
|
|
111
116
|
USE_SKILL = "useSkill",
|
|
112
|
-
READ_SKILL_FILE = "readSkillFile"
|
|
117
|
+
READ_SKILL_FILE = "readSkillFile",
|
|
118
|
+
RUN_SKILL_SCRIPT = "runSkillScript"
|
|
113
119
|
}
|
|
114
120
|
export declare enum ReturnToReferrerTool {
|
|
115
121
|
ASSET_IDENTIFIER = "returnToReferrer_asset-identifier-agent",
|
|
@@ -171,9 +177,9 @@ export interface ResourceSelectionRejected {
|
|
|
171
177
|
message: string;
|
|
172
178
|
}
|
|
173
179
|
export interface MessageAttachment {
|
|
174
|
-
id
|
|
180
|
+
id: string;
|
|
175
181
|
filename: string;
|
|
176
|
-
|
|
182
|
+
mimetype: string;
|
|
177
183
|
}
|
|
178
184
|
interface AssistantLabels {
|
|
179
185
|
name: string;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.OneShotTaskId = exports.AiAssistantId = exports.HandOffTool = exports.ReturnToReferrerTool = exports.ToolName = exports.AgentId = exports.ReferenceType = exports.AttachmentHandlingMode = exports.ToolType = exports.ErrorMessageType = exports.Role = exports.AvailableLanguages = exports.FinishReason = exports.ToolMessageStatus = exports.AssistantMessageStatus = void 0;
|
|
3
|
+
exports.OneShotTaskId = exports.AiAssistantId = exports.HandOffTool = exports.ReturnToReferrerTool = exports.ToolName = exports.ATTACHMENT_CAPABLE_AGENT_IDS = exports.AgentId = exports.ReferenceType = exports.AttachmentHandlingMode = exports.ToolType = exports.ErrorMessageType = exports.Role = exports.AvailableLanguages = exports.FinishReason = exports.ToolMessageStatus = exports.AssistantMessageStatus = void 0;
|
|
4
4
|
var AssistantMessageStatus;
|
|
5
5
|
(function (AssistantMessageStatus) {
|
|
6
6
|
AssistantMessageStatus["ABORTING"] = "aborting";
|
|
@@ -56,6 +56,7 @@ var ToolType;
|
|
|
56
56
|
})(ToolType || (exports.ToolType = ToolType = {}));
|
|
57
57
|
var AttachmentHandlingMode;
|
|
58
58
|
(function (AttachmentHandlingMode) {
|
|
59
|
+
AttachmentHandlingMode["DISABLED"] = "disabled";
|
|
59
60
|
AttachmentHandlingMode["USE_ANALYSIS_IN_CHAT"] = "useAnalysisInChat";
|
|
60
61
|
AttachmentHandlingMode["DONT_USE_ANALYSIS_IN_CHAT"] = "dontUseAnalysisInChat";
|
|
61
62
|
})(AttachmentHandlingMode || (exports.AttachmentHandlingMode = AttachmentHandlingMode = {}));
|
|
@@ -89,6 +90,7 @@ var AgentId;
|
|
|
89
90
|
AgentId["AXALTA_MESSAGE"] = "axalta-message-agent";
|
|
90
91
|
AgentId["TRIAGE"] = "triage-agent";
|
|
91
92
|
})(AgentId || (exports.AgentId = AgentId = {}));
|
|
93
|
+
exports.ATTACHMENT_CAPABLE_AGENT_IDS = [AgentId.ASSET, AgentId.ASSET_WEB, AgentId.REPORT, AgentId.MESSAGE];
|
|
92
94
|
var ToolName;
|
|
93
95
|
(function (ToolName) {
|
|
94
96
|
ToolName["SWITCH_ASSISTANT"] = "switchAssistant";
|
|
@@ -118,9 +120,13 @@ var ToolName;
|
|
|
118
120
|
ToolName["USE_DRYER_SELECTION_TOOL"] = "useDryerSelectionTool";
|
|
119
121
|
ToolName["USE_RFD_BASIC_CALCULATION_TOOL"] = "useRfdBasicCalculationTool";
|
|
120
122
|
ToolName["ADD_TASK_LOGBOOK_ENTRY"] = "addTaskLogbookEntry";
|
|
123
|
+
ToolName["LOAD_USER_MESSAGE_ATTACHMENT_REFERENCES"] = "loadUserMessageAttachmentReferences";
|
|
124
|
+
ToolName["SEARCH_IN_ATTACHMENTS"] = "searchInAttachments";
|
|
125
|
+
ToolName["LOAD_ATTACHMENT_ANALYSIS"] = "loadAttachmentAnalysis";
|
|
121
126
|
ToolName["WEB_SEARCH"] = "web_search";
|
|
122
127
|
ToolName["USE_SKILL"] = "useSkill";
|
|
123
128
|
ToolName["READ_SKILL_FILE"] = "readSkillFile";
|
|
129
|
+
ToolName["RUN_SKILL_SCRIPT"] = "runSkillScript";
|
|
124
130
|
})(ToolName || (exports.ToolName = ToolName = {}));
|
|
125
131
|
var ReturnToReferrerTool;
|
|
126
132
|
(function (ReturnToReferrerTool) {
|
|
@@ -6,14 +6,14 @@ export type { Audit } from './audit.interface';
|
|
|
6
6
|
export type { Author } from './author.interface';
|
|
7
7
|
export type { AzureBillingEvent, AzureBillingResult, Billing, BillingEvent, BillingResource, BillingSubscription, BillingValues, OnceBilledResources, RegularlyBilledResources, } from './billing.interface';
|
|
8
8
|
export type { Content, ContentAnalysis, ContentChange, ContentSearchResult, IndexingStatusData, ReindexStatusSsePayload, } from './content.interface';
|
|
9
|
-
export type { CrmContactMergeOverrides, CrmDuplicateEntityType, CrmDuplicateGroup, CrmDuplicateGroupStatus, CrmDuplicateMember, CrmDuplicateReasonCode, CrmEmailMerge, CrmGetContactDuplicatesResponse, CrmGetDuplicatesQuery, CrmGetDuplicatesResponse,
|
|
9
|
+
export type { CompanyCandidate, ContactCandidate, CrmContactMergeOverrides, CrmDuplicateEntityType, CrmDuplicateGroup, CrmDuplicateGroupStatus, CrmDuplicateMember, CrmDuplicateReasonCode, CrmEmailMerge, CrmGetContactDuplicatesResponse, CrmGetDuplicatesQuery, CrmGetDuplicatesResponse, CrmImportContactDuplicateDetails, CrmImportContactDuplicateMemberDetails, CrmImportDuplicateDecision, CrmImportDuplicateEntityType, CrmImportDuplicateGroup, CrmImportDuplicateMember, CrmImportDuplicateReasonCode, CrmImportJsonRequest, CrmImportParser, CrmImportResponse, CrmMergeContactDuplicatesRequest, CrmMergeContactDuplicatesResponse, ImportResult, ImportResultStats, MatchResult, MeetingReport, ReportActivity, ReportParticipant, ReportSummary, TouchpointCandidate, } from './crm.interface';
|
|
10
10
|
export type { DataInterface, Filter, Paginated, RequestParameter } from './data.interface';
|
|
11
|
-
export type { DataspaceAllowedResourceType,
|
|
11
|
+
export type { DataspaceAllowedResourceType, DataspaceWorkflowResult, DataspaceWorkflowStatus, ShareInDataspaceDto, } from './dataspace.interface';
|
|
12
12
|
export type { EdgeDeviceRequestResponse, EdgeDeviceResult, WebIOData } from './edge-device.interface';
|
|
13
13
|
export type { AdditionalNotificationData, Endpoint, EndpointConfig, EndpointLog, NotificationEndpoint, NotificationEndpointLog, NotificationLogType, NotificationPayload, SearchEndpointResult, } from './endpoint.interface';
|
|
14
14
|
export type { CreateEventDto, Event, EventCountByAsset } from './event.interface';
|
|
15
15
|
export type { BookedExaminee, Examination, ReviewScore, TimeSlot, WorkStation } from './flange-skill-control.interface';
|
|
16
|
-
export type { FlowConnection, FlowDeploymentMetrics, FlowDeploymentStatistic, FlowElement, FlowLog, FlowModel,
|
|
16
|
+
export type { FlowConnection, FlowDeploymentMetrics, FlowDeploymentStatistic, FlowElement, FlowLog, FlowModel, Metrics, NatsFlowTriggerData, NatsFlowTriggerState, NatsFlowTriggerStatus, Stats, StatsValues, } from './flow-deployment.interface';
|
|
17
17
|
export type { BillingEventsData, DeploymentId, DeploymentTriggerResponse, Executor, ExecutorEnvironment, ExecutorEventType, ExecutorId, ExecutorStats, WorkerId, } from './flow-executor.interface';
|
|
18
18
|
export type { DataDescription, FlowFunction, FlowFunctionDto, FlowFunctionRevision, SearchFlowTypeResult, Stream, } from './flow-function.interface';
|
|
19
19
|
export type { FlowModule, FlowModuleArtifact } from './flow-module.interface';
|
|
@@ -22,6 +22,8 @@ export type { Config, Issuer, TokenOption } from './http.interface';
|
|
|
22
22
|
export type { InvitationRepresentation } from './invitation-representation.interface';
|
|
23
23
|
export type { KeycloakProfile } from './keycloak-profile.interface';
|
|
24
24
|
export type { CreateLabelDto, Label, LabelColor, UpdateLabelDto } from './label.interface';
|
|
25
|
+
export { LogbookEntrySource } from './logbook.interface';
|
|
26
|
+
export type { LogbookEntry, LogbookEntryDto } from './logbook.interface';
|
|
25
27
|
export type { MeteredQuantity, MeteringDimension, Plan, PlanComponents, RecurrentBillingTerm, SourceOffer, Subscription, SubscriptionInfo, Term, } from './marketplace.interface';
|
|
26
28
|
export type { NotificationRule, StatusRule, TagRule } from './notification-rule.interface';
|
|
27
29
|
export type { Notification, NotificationType } from './notification.interface';
|
|
@@ -38,14 +40,12 @@ export type { SearchMatchReason, SearchMatchReasonContentPart, SearchOptions, Se
|
|
|
38
40
|
export type { Secret } from './secret.interface';
|
|
39
41
|
export type { ServerSentEvent } from './sse.interface';
|
|
40
42
|
export type { Artifact, FileType, Storage, StorageProvider } from './storage.interface';
|
|
41
|
-
export { LogbookEntrySource } from './logbook.interface';
|
|
42
|
-
export type { LogbookEntry, LogbookEntryDto } from './logbook.interface';
|
|
43
43
|
export type { Assignee, Task } from './task.interface';
|
|
44
44
|
export type { Retention, SearchTimeSeriesResult, SelectedField, TimeSeries, TimeSeriesBucket, TimeseriesChange, TimeSeriesCondition, TimeseriesSubject, TimeSeriesValue, TS_GROUPS, } from './timeseries.interface';
|
|
45
45
|
export type { Translation, TranslationData } from './translation.interface';
|
|
46
46
|
export type { Application, Consent, Permission, TableSetting, TableSettingProfile, UserSettings } from './user-settings.interface';
|
|
47
47
|
export type { KVSecretVersion, VaultSecret } from './vault.interface';
|
|
48
|
-
export { AgentId, AiAssistantId, AssistantMessageStatus, AttachmentHandlingMode, AvailableLanguages, ErrorMessageType, FinishReason, HandOffTool, OneShotTaskId, ReferenceType, ReturnToReferrerTool, Role, ToolMessageStatus, ToolName, ToolType, } from './ai.interface';
|
|
48
|
+
export { AgentId, AiAssistantId, AssistantMessageStatus, ATTACHMENT_CAPABLE_AGENT_IDS, AttachmentHandlingMode, AvailableLanguages, ErrorMessageType, FinishReason, HandOffTool, OneShotTaskId, ReferenceType, ReturnToReferrerTool, Role, ToolMessageStatus, ToolName, ToolType, } from './ai.interface';
|
|
49
49
|
export { AlertLevel, AlertStatus, AlertType, DEFAULT_DEADMAN_CONDITION, DEFAULT_RELATIVE_CONDITION, DEFAULT_THRESHOLD_CONDITION, } from './alert.interface';
|
|
50
50
|
export { ChangeAction } from './api.interface';
|
|
51
51
|
export { BillingResourceType } from './billing.interface';
|
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
4
|
-
exports.WebSocketMessageType = exports.SecretType = exports.isUserMessage = exports.isTask = exports.isStorage = exports.isOwner = exports.isLogbookEntry = exports.isEvent = exports.isContentAnalysis = exports.isContent = exports.isAuthor = exports.isAssignee = exports.isAsset = exports.TranslationEditData = exports.RETENTION_VALUES = exports.TaskStatus = exports.Priority = exports.INACTIVE_TASK_STATUSES = exports.buildTaskStatusFilter = exports.AssigneeType = exports.ACTIVE_TASK_STATUSES = exports.ResourceType = exports.resourceApiPathToTypeMap = exports.ResourceApiPath = exports.PermissionType = exports.isPopulated = exports.EventType = exports.CommandType = exports.arePopulated = exports.ObjectReferenceType = exports.OwnerType = exports.OrganizationMembersInviteOrAdd = exports.NotificationRuleStatus = exports.NatsStreams = exports.natsHpcPrefix = exports.natsFlowsPrefix = exports.NatsConsumers = void 0;
|
|
3
|
+
exports.LABEL_COLORS = exports.FlowDiagram = exports.Flow = exports.NATS_FLOW_TRIGGER_STATUSES = exports.FlowDeployment = exports.UNKOWN_STATES = exports.STOPPED_STATES = exports.RUNNING_STATES = exports.PROCESSING_STATES = exports.FlowDeploymentStatus = exports.ERROR_STATES = exports.TimeSlotStatus = exports.APPLICATION_AREA = exports.eventLevels = exports.EventLevelOverrideWrapper = exports.EventLevel = exports.NotificationEndpointType = exports.NotificationEndpointStatus = exports.NotificationEndpointSpamProtection = exports.DataspaceWorkflowType = exports.DataspaceAllowedResourceTypes = exports.instanceOfTimePeriod = exports.ReturnType = exports.IndexingStatus = exports.ContentAnalysisStatus = exports.BillingResourceType = exports.ChangeAction = exports.DEFAULT_THRESHOLD_CONDITION = exports.DEFAULT_RELATIVE_CONDITION = exports.DEFAULT_DEADMAN_CONDITION = exports.AlertType = exports.AlertStatus = exports.AlertLevel = exports.ToolType = exports.ToolName = exports.ToolMessageStatus = exports.Role = exports.ReturnToReferrerTool = exports.ReferenceType = exports.OneShotTaskId = exports.HandOffTool = exports.FinishReason = exports.ErrorMessageType = exports.AvailableLanguages = exports.AttachmentHandlingMode = exports.ATTACHMENT_CAPABLE_AGENT_IDS = exports.AssistantMessageStatus = exports.AiAssistantId = exports.AgentId = exports.LogbookEntrySource = void 0;
|
|
4
|
+
exports.WebSocketMessageType = exports.SecretType = exports.isUserMessage = exports.isTask = exports.isStorage = exports.isOwner = exports.isLogbookEntry = exports.isEvent = exports.isContentAnalysis = exports.isContent = exports.isAuthor = exports.isAssignee = exports.isAsset = exports.TranslationEditData = exports.RETENTION_VALUES = exports.TaskStatus = exports.Priority = exports.INACTIVE_TASK_STATUSES = exports.buildTaskStatusFilter = exports.AssigneeType = exports.ACTIVE_TASK_STATUSES = exports.ResourceType = exports.resourceApiPathToTypeMap = exports.ResourceApiPath = exports.PermissionType = exports.isPopulated = exports.EventType = exports.CommandType = exports.arePopulated = exports.ObjectReferenceType = exports.OwnerType = exports.OrganizationMembersInviteOrAdd = exports.NotificationRuleStatus = exports.NatsStreams = exports.natsHpcPrefix = exports.natsFlowsPrefix = exports.NatsConsumers = exports.SubscriptionType = void 0;
|
|
5
5
|
var logbook_interface_1 = require("./logbook.interface");
|
|
6
6
|
Object.defineProperty(exports, "LogbookEntrySource", { enumerable: true, get: function () { return logbook_interface_1.LogbookEntrySource; } });
|
|
7
7
|
var ai_interface_1 = require("./ai.interface");
|
|
8
8
|
Object.defineProperty(exports, "AgentId", { enumerable: true, get: function () { return ai_interface_1.AgentId; } });
|
|
9
9
|
Object.defineProperty(exports, "AiAssistantId", { enumerable: true, get: function () { return ai_interface_1.AiAssistantId; } });
|
|
10
10
|
Object.defineProperty(exports, "AssistantMessageStatus", { enumerable: true, get: function () { return ai_interface_1.AssistantMessageStatus; } });
|
|
11
|
+
Object.defineProperty(exports, "ATTACHMENT_CAPABLE_AGENT_IDS", { enumerable: true, get: function () { return ai_interface_1.ATTACHMENT_CAPABLE_AGENT_IDS; } });
|
|
11
12
|
Object.defineProperty(exports, "AttachmentHandlingMode", { enumerable: true, get: function () { return ai_interface_1.AttachmentHandlingMode; } });
|
|
12
13
|
Object.defineProperty(exports, "AvailableLanguages", { enumerable: true, get: function () { return ai_interface_1.AvailableLanguages; } });
|
|
13
14
|
Object.defineProperty(exports, "ErrorMessageType", { enumerable: true, get: function () { return ai_interface_1.ErrorMessageType; } });
|
|
@@ -36,7 +36,7 @@ const isStringArray = (value) => isArrayOf(value, isString);
|
|
|
36
36
|
const isOptionalStringArray = (value) => isOptionalArrayOf(value, isString);
|
|
37
37
|
const isOptionalUnknownArray = (value) => value === undefined || Array.isArray(value);
|
|
38
38
|
const hasOwn = (value, property) => Object.prototype.hasOwnProperty.call(value, property);
|
|
39
|
-
const isMessageAttachment = (value) => isRecord(value) &&
|
|
39
|
+
const isMessageAttachment = (value) => isRecord(value) && isString(value.id) && isString(value.filename) && isString(value.mimetype);
|
|
40
40
|
const isResourceReference = (value) => isRecord(value) && isString(value.id) && isEnumValue(resource_interface_1.ResourceType, value.resourceType) && isOptionalBoolean(value.dependent);
|
|
41
41
|
const isOneOf = (value, allowed) => allowed.includes(value);
|
|
42
42
|
const isEnumValue = (target, value) => Object.values(target).includes(value);
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { AddToProperty, Asset, AssetRevision, Attachment, DeleteQuery, EventCause, EventLevelOverride, Filter, Paginated, RemoveFromProperty, RequestParameter,
|
|
1
|
+
import { AddToProperty, Asset, AssetRevision, Attachment, DeleteQuery, EventCause, EventLevelOverride, Filter, Paginated, RemoveFromProperty, RequestParameter, SearchResultItem, TokenOption } from '../interfaces';
|
|
2
2
|
import { AssetService } from '../services';
|
|
3
3
|
import { CrossPlatformFormData } from '../utils';
|
|
4
4
|
import type { MockAPI } from './api.mock';
|
|
@@ -40,6 +40,6 @@ export declare class AssetMockService extends BaseService implements AssetServic
|
|
|
40
40
|
}): Promise<void>;
|
|
41
41
|
search(query: string, params?: RequestParameter, options?: TokenOption & {
|
|
42
42
|
[key: string]: any;
|
|
43
|
-
}): Promise<
|
|
43
|
+
}): Promise<SearchResultItem[]>;
|
|
44
44
|
}
|
|
45
45
|
export {};
|
|
@@ -40,7 +40,12 @@ class EventMockService extends BaseService {
|
|
|
40
40
|
return Promise.resolve(this.data[this.data.length - 1]);
|
|
41
41
|
}
|
|
42
42
|
getLastEventByAssetAndGroups(assetId, groups) {
|
|
43
|
-
|
|
43
|
+
return Promise.resolve(Object.fromEntries(groups.map((group) => [
|
|
44
|
+
group,
|
|
45
|
+
this.data
|
|
46
|
+
.filter((event) => event.assetRef === assetId && event.group === group)
|
|
47
|
+
.sort((a, b) => new Date(b.createdAt ?? 0).valueOf() - new Date(a.createdAt ?? 0).valueOf())[0]?.cause ?? '',
|
|
48
|
+
])));
|
|
44
49
|
}
|
|
45
50
|
countEventsByGroup(group, assetId) {
|
|
46
51
|
return Promise.resolve(this.data.filter((event) => event.group === group && (!assetId || event.assetRef === assetId)).length);
|
|
@@ -137,7 +137,19 @@ class TimeseriesMockService extends BaseService {
|
|
|
137
137
|
return ts.data.filter((v) => v.timestamp < to && v.timestamp > from);
|
|
138
138
|
}
|
|
139
139
|
getMostRecentTimeSeriesValueByAssetAndTimeSeriesName(assetId, timeSeriesNames) {
|
|
140
|
-
|
|
140
|
+
const result = Object.fromEntries(timeSeriesNames.map((name) => [name, '']));
|
|
141
|
+
for (const timeSeries of this.data) {
|
|
142
|
+
if (timeSeries.assetRef !== assetId || !timeSeriesNames.includes(timeSeries.name)) {
|
|
143
|
+
continue;
|
|
144
|
+
}
|
|
145
|
+
const mostRecentValue = [...(timeSeries.data ?? [])].sort((a, b) => b.timestamp - a.timestamp)[0];
|
|
146
|
+
if (!mostRecentValue) {
|
|
147
|
+
continue;
|
|
148
|
+
}
|
|
149
|
+
const metric = timeSeries.metrics?.[0];
|
|
150
|
+
result[timeSeries.name] = metric ? (mostRecentValue[metric] ?? '') : (mostRecentValue.value ?? '');
|
|
151
|
+
}
|
|
152
|
+
return Promise.resolve(result);
|
|
141
153
|
}
|
|
142
154
|
}
|
|
143
155
|
exports.TimeseriesMockService = TimeseriesMockService;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { AddToProperty, Asset, AssetRevision, Attachment, DeleteAssetQuery, EventCause, EventLevelOverride, Filter, Paginated, RemoveFromProperty, RequestParameter,
|
|
1
|
+
import { AddToProperty, Asset, AssetRevision, Attachment, DeleteAssetQuery, EventCause, EventLevelOverride, Filter, Paginated, RemoveFromProperty, RequestParameter, SearchResultItem, TokenOption } from '../interfaces';
|
|
2
2
|
import { CrossPlatformFormData } from '../utils';
|
|
3
3
|
import { DataService } from './data.service';
|
|
4
4
|
import { HttpClientService } from './http-client.service';
|
|
@@ -33,6 +33,6 @@ export declare class AssetService extends BaseService {
|
|
|
33
33
|
}): Promise<void>;
|
|
34
34
|
search(query: string, params?: RequestParameter, options?: TokenOption & {
|
|
35
35
|
[key: string]: any;
|
|
36
|
-
}): Promise<
|
|
36
|
+
}): Promise<SearchResultItem[]>;
|
|
37
37
|
}
|
|
38
38
|
export {};
|
package/src/lib/utils.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Filter } from './interfaces';
|
|
1
|
+
import { AgentId, Filter } from './interfaces';
|
|
2
2
|
export type CrossPlatformFormData = FormData | {
|
|
3
3
|
getHeaders(): Record<string, string>;
|
|
4
4
|
};
|
|
@@ -11,3 +11,4 @@ export type CrossPlatformFormData = FormData | {
|
|
|
11
11
|
*/
|
|
12
12
|
export declare function getFormDataHeaders(form: CrossPlatformFormData): Record<string, string>;
|
|
13
13
|
export declare function getFilterString(filter: Filter): string;
|
|
14
|
+
export declare function agentSupportsAttachments(agent?: AgentId | null): boolean;
|
package/src/lib/utils.js
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.getFormDataHeaders = getFormDataHeaders;
|
|
4
4
|
exports.getFilterString = getFilterString;
|
|
5
|
+
exports.agentSupportsAttachments = agentSupportsAttachments;
|
|
5
6
|
// cross-platform FormData type that works in both node and browser
|
|
6
7
|
const interfaces_1 = require("./interfaces");
|
|
7
8
|
/**
|
|
@@ -37,3 +38,6 @@ function getFilterString(filter) {
|
|
|
37
38
|
}
|
|
38
39
|
return filters.join(';');
|
|
39
40
|
}
|
|
41
|
+
function agentSupportsAttachments(agent) {
|
|
42
|
+
return agent != null && interfaces_1.ATTACHMENT_CAPABLE_AGENT_IDS.includes(agent);
|
|
43
|
+
}
|