@hahnpro/hpc-api 2026.10.2 → 2026.10.4
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/README.md +26 -20
- package/package.json +2 -2
- package/src/lib/interfaces/ai.interface.d.ts +1 -0
- package/src/lib/interfaces/ai.interface.js +1 -0
- package/src/lib/interfaces/asset.interface.d.ts +4 -1
- package/src/lib/interfaces/content.interface.d.ts +1 -0
- package/src/lib/interfaces/index.d.ts +2 -2
- package/src/lib/interfaces/index.js +2 -1
- package/src/lib/interfaces/knowledge.interface.d.ts +10 -0
- package/src/lib/interfaces/knowledge.interface.js +13 -1
- package/src/lib/interfaces/nats.interface.d.ts +14 -5
- package/src/lib/interfaces/nats.interface.js +15 -6
- package/src/lib/mock/asset.mock.service.d.ts +7 -2
- package/src/lib/mock/asset.mock.service.js +82 -11
- package/src/lib/mock/assetTypes.mock.service.d.ts +2 -1
- package/src/lib/mock/assetTypes.mock.service.js +12 -0
- package/src/lib/mock/content.mock.service.d.ts +3 -1
- package/src/lib/mock/content.mock.service.js +6 -0
- package/src/lib/mock/flow-modules.mock.service.d.ts +6 -6
- package/src/lib/mock/knowledge.mock.service.js +2 -1
- package/src/lib/queue.d.ts +1 -1
- package/src/lib/queue.js +2 -2
- package/src/lib/services/api-workflow.helpers.d.ts +13 -0
- package/src/lib/services/api-workflow.helpers.js +30 -0
- package/src/lib/services/asset.service.d.ts +9 -1
- package/src/lib/services/asset.service.js +11 -1
- package/src/lib/services/assettypes.service.d.ts +2 -1
- package/src/lib/services/assettypes.service.js +3 -0
- package/src/lib/services/content.service.d.ts +3 -1
- package/src/lib/services/content.service.js +2 -0
- package/src/lib/services/data.service.d.ts +1 -1
- package/src/lib/services/index.d.ts +2 -0
- package/src/lib/services/index.js +3 -1
- package/src/lib/services/organizations.service.d.ts +1 -0
- package/src/lib/services/organizations.service.js +1 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,10 +1,19 @@
|
|
|
1
1
|
# @hahnpro/hpc-api
|
|
2
2
|
|
|
3
|
+
# 2026.10.4
|
|
4
|
+
|
|
5
|
+
- Added `ToolName.ADD_ATTACHMENT_TO_ASSET` for attaching existing Content objects to Assets through AI #5158
|
|
6
|
+
- Removed `AssetService.addAttachment`; upload content and create an `ASSET_ATTACHMENT` object reference instead
|
|
7
|
+
- Deprecated `Asset.attachments` in favor of `AssetService.getAttachments`
|
|
8
|
+
- Updated the attachment examples to use the object-reference workflow
|
|
9
|
+
- Added asset type search support through `AssetTypesService.search`
|
|
10
|
+
|
|
3
11
|
# 2026.9.12
|
|
4
12
|
|
|
5
13
|
- Added permission verification support for object references, including reference-check endpoints for resources, AI threads, and user messages
|
|
6
14
|
- Added the `PermissionLevel` enum
|
|
7
15
|
- Added pagination and sorting parameters to object-reference queries
|
|
16
|
+
- Expanded object-reference service request options from `TokenOption` to `Config`
|
|
8
17
|
|
|
9
18
|
# 2026.9.11
|
|
10
19
|
|
package/README.md
CHANGED
|
@@ -60,7 +60,7 @@ defaults to `https://testing.hahnpro.com`), `AUTH_BASE_URL` (defaults to `API_BA
|
|
|
60
60
|
`AUTH_REALM` (defaults to `hpc`), `API_USER` and `AUTH_SECRET` environment variables;
|
|
61
61
|
|
|
62
62
|
```typescript
|
|
63
|
-
import { API } from '@hahnpro/flow-sdk';
|
|
63
|
+
import { API, ObjectReferenceType, ResourceType } from '@hahnpro/flow-sdk';
|
|
64
64
|
// or by using dotenv
|
|
65
65
|
import * as dotenv from 'dotenv';
|
|
66
66
|
|
|
@@ -304,14 +304,16 @@ res = requests.get(API_BASE_URL + API_CM_PATH + '/' + contentId + '/download', h
|
|
|
304
304
|
blob = res.content
|
|
305
305
|
```
|
|
306
306
|
|
|
307
|
+
> **Deprecated:** `Asset.attachments` and the legacy asset attachment endpoints are retained for compatibility. Use `ASSET_ATTACHMENT` object references instead.
|
|
308
|
+
|
|
307
309
|
Download Content attached to an Asset:
|
|
308
310
|
|
|
309
311
|
```python
|
|
310
312
|
ASSET_WITH_CONTENT = '1234'
|
|
311
|
-
res = requests.get(API_BASE_URL + API_AM_PATH +'/' + ASSET_WITH_CONTENT, headers=headers)
|
|
312
|
-
attachments = res.json()['
|
|
313
|
+
res = requests.get(API_BASE_URL + API_AM_PATH + '/' + ASSET_WITH_CONTENT + '/attachments', headers=headers)
|
|
314
|
+
attachments = res.json()['docs']
|
|
313
315
|
|
|
314
|
-
res = requests.get(API_BASE_URL + API_CM_PATH + '/' + attachments[0] + '/download', headers=headers)
|
|
316
|
+
res = requests.get(API_BASE_URL + API_CM_PATH + '/' + attachments[0]['id'] + '/download', headers=headers)
|
|
315
317
|
blob = res.content
|
|
316
318
|
```
|
|
317
319
|
|
|
@@ -337,13 +339,13 @@ res = requests.post(API_BASE_URL + API_CM_PATH, files=files, data=payload, heade
|
|
|
337
339
|
Attach Content to Asset:
|
|
338
340
|
|
|
339
341
|
```python
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
'
|
|
343
|
-
'
|
|
342
|
+
content = requests.post(API_BASE_URL + API_CM_PATH, data=payload, files=files, headers=headers).json()
|
|
343
|
+
reference = {
|
|
344
|
+
'srcId': '1234', 'tgtId': content['id'],
|
|
345
|
+
'srcType': 'asset', 'tgtType': 'content',
|
|
346
|
+
'relSrc': 'api-client', 'relType': 'asset_attachment'
|
|
344
347
|
}
|
|
345
|
-
|
|
346
|
-
res = requests.post(API_BASE_URL + API_AM_PATH + '/1234/attachment', data=payload, files=files, headers=headers)
|
|
348
|
+
res = requests.post(API_BASE_URL + '/api/references', json=reference, headers=headers)
|
|
347
349
|
```
|
|
348
350
|
|
|
349
351
|
</details>
|
|
@@ -365,11 +367,13 @@ const content = await api.contents.getOne('1234');
|
|
|
365
367
|
const file = await api.contents.download(content.id);
|
|
366
368
|
```
|
|
367
369
|
|
|
370
|
+
> **Deprecated:** `Asset.attachments` and the legacy asset attachment endpoints are retained for compatibility. Use `ASSET_ATTACHMENT` object references instead.
|
|
371
|
+
|
|
368
372
|
Download Content attached to an Asset:
|
|
369
373
|
|
|
370
374
|
```typescript
|
|
371
|
-
const
|
|
372
|
-
const file = await api.contents.download(
|
|
375
|
+
const attachments = await api.assets.getAttachments('1234');
|
|
376
|
+
const file = await api.contents.download(attachments.docs[0].id);
|
|
373
377
|
```
|
|
374
378
|
|
|
375
379
|
Upload new Content:
|
|
@@ -388,14 +392,16 @@ await api.contents.upload(form);
|
|
|
388
392
|
Attach Content to Asset:
|
|
389
393
|
|
|
390
394
|
```typescript
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
395
|
+
const asset = await api.assets.getOne('1234');
|
|
396
|
+
const content = await api.contents.upload(form);
|
|
397
|
+
await api.objectReferences.create({
|
|
398
|
+
srcId: asset.id,
|
|
399
|
+
tgtId: content.id,
|
|
400
|
+
srcType: ResourceType.ASSET,
|
|
401
|
+
tgtType: ResourceType.CONTENT,
|
|
402
|
+
relSrc: 'example',
|
|
403
|
+
relType: ObjectReferenceType.ASSET_ATTACHMENT,
|
|
404
|
+
});
|
|
399
405
|
```
|
|
400
406
|
|
|
401
407
|
</details>
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hahnpro/hpc-api",
|
|
3
|
-
"version": "2026.10.
|
|
3
|
+
"version": "2026.10.4",
|
|
4
4
|
"description": "Module for easy access to the HahnPRO Cloud API",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": {
|
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
"eventsource": "5.1.2",
|
|
19
19
|
"jose": "6.2.12",
|
|
20
20
|
"jwt-decode": "4.0.0",
|
|
21
|
-
"p-queue": "
|
|
21
|
+
"p-queue": "10.0.0",
|
|
22
22
|
"rxjs": "7.8.2",
|
|
23
23
|
"ts-mixer": "6.0.4",
|
|
24
24
|
"tslib": "2.8.1"
|
|
@@ -93,6 +93,7 @@ export declare enum ToolName {
|
|
|
93
93
|
FIND_TASK_BY_NAME = "findTaskByName",
|
|
94
94
|
GET_TASK_LOGBOOK_ENTRIES = "getTaskLogbookEntries",
|
|
95
95
|
CREATE_EVENT = "createEvent",
|
|
96
|
+
ADD_ATTACHMENT_TO_ASSET = "addAttachmentToAsset",
|
|
96
97
|
GET_ASSET_DATA = "getAssetData",
|
|
97
98
|
ASSET_SELECTION = "assetSelection",
|
|
98
99
|
SEARCH_FOR_ASSETS_BY_ID_NAME_TYPE = "searchForAssetsByIdNameType",
|
|
@@ -104,6 +104,7 @@ var ToolName;
|
|
|
104
104
|
ToolName["FIND_TASK_BY_NAME"] = "findTaskByName";
|
|
105
105
|
ToolName["GET_TASK_LOGBOOK_ENTRIES"] = "getTaskLogbookEntries";
|
|
106
106
|
ToolName["CREATE_EVENT"] = "createEvent";
|
|
107
|
+
ToolName["ADD_ATTACHMENT_TO_ASSET"] = "addAttachmentToAsset";
|
|
107
108
|
ToolName["GET_ASSET_DATA"] = "getAssetData";
|
|
108
109
|
ToolName["ASSET_SELECTION"] = "assetSelection";
|
|
109
110
|
ToolName["SEARCH_FOR_ASSETS_BY_ID_NAME_TYPE"] = "searchForAssetsByIdNameType";
|
|
@@ -36,6 +36,8 @@ export type AssetTypeRevision = AssetType & {
|
|
|
36
36
|
};
|
|
37
37
|
export interface Asset {
|
|
38
38
|
id?: string;
|
|
39
|
+
/** Case-sensitive media relay binding; only platform superusers may provision it. */
|
|
40
|
+
streamId?: string | null;
|
|
39
41
|
externalKey?: string;
|
|
40
42
|
name: string;
|
|
41
43
|
type: string | AssetType;
|
|
@@ -49,6 +51,7 @@ export interface Asset {
|
|
|
49
51
|
relations?: any[];
|
|
50
52
|
data?: any;
|
|
51
53
|
image?: string;
|
|
54
|
+
/** Legacy compatibility and revision data only. Use ASSET_ATTACHMENT object references and assets.getAttachments(). */
|
|
52
55
|
attachments?: string[];
|
|
53
56
|
notificationEndpoints?: string[];
|
|
54
57
|
aliases?: string[];
|
|
@@ -62,7 +65,7 @@ export interface Asset {
|
|
|
62
65
|
updatedAt?: string;
|
|
63
66
|
deletedAt?: string;
|
|
64
67
|
}
|
|
65
|
-
export type AssetRevision = Asset & {
|
|
68
|
+
export type AssetRevision = Omit<Asset, 'streamId'> & {
|
|
66
69
|
originalId: string;
|
|
67
70
|
};
|
|
68
71
|
export type Attachment = Content;
|
|
@@ -6,7 +6,7 @@ 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 { CompanyCandidate, ContactCandidate,
|
|
9
|
+
export type { CompanyCandidate, ContactCandidate, CrmContactMergeOverrides, CrmDealReminderDeliveryResult, 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, SendDealReminderPayload, TouchpointCandidate, } from './crm.interface';
|
|
10
10
|
export type { DataInterface, Filter, Paginated, RequestParameter } from './data.interface';
|
|
11
11
|
export type { DataspaceAllowedResourceType, DataspaceWorkflowResult, DataspaceWorkflowStatus, ShareInDataspaceDto, } from './dataspace.interface';
|
|
12
12
|
export type { EdgeDeviceRequestResponse, EdgeDeviceResult, WebIOData } from './edge-device.interface';
|
|
@@ -62,7 +62,7 @@ export { FlowDeployment, NATS_FLOW_TRIGGER_STATUSES } from './flow-deployment.in
|
|
|
62
62
|
export { Flow, FlowDiagram } from './flow.interface';
|
|
63
63
|
export { LABEL_COLORS } from './label.interface';
|
|
64
64
|
export { SubscriptionType } from './marketplace.interface';
|
|
65
|
-
export { NatsConsumers, natsFlowsPrefix, natsHpcPrefix, NatsStreams } from './nats.interface';
|
|
65
|
+
export { NatsConsumers, natsFlowsPrefix, natsHpcPrefix, NatsStreams, natsAuthPrefix } from './nats.interface';
|
|
66
66
|
export { NotificationRuleStatus } from './notification-rule.interface';
|
|
67
67
|
export { OrganizationMembersInviteOrAdd } from './organization.interface';
|
|
68
68
|
export { OwnerType } from './owner.interface';
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
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.MAX_TIME_SERIES_PER_VALUE_FEED = 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.PermissionLevel = exports.ObjectReferenceType = exports.OwnerType = exports.OrganizationMembersInviteOrAdd = exports.NotificationRuleStatus = exports.NatsStreams = exports.natsHpcPrefix = exports.natsFlowsPrefix = exports.NatsConsumers = exports.SubscriptionType = exports.LABEL_COLORS = 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.PermissionLevel = exports.ObjectReferenceType = exports.OwnerType = exports.OrganizationMembersInviteOrAdd = exports.NotificationRuleStatus = exports.natsAuthPrefix = exports.NatsStreams = exports.natsHpcPrefix = exports.natsFlowsPrefix = exports.NatsConsumers = exports.SubscriptionType = exports.LABEL_COLORS = void 0;
|
|
5
5
|
const tslib_1 = require("tslib");
|
|
6
6
|
var logbook_interface_1 = require("./logbook.interface");
|
|
7
7
|
Object.defineProperty(exports, "LogbookEntrySource", { enumerable: true, get: function () { return logbook_interface_1.LogbookEntrySource; } });
|
|
@@ -77,6 +77,7 @@ Object.defineProperty(exports, "NatsConsumers", { enumerable: true, get: functio
|
|
|
77
77
|
Object.defineProperty(exports, "natsFlowsPrefix", { enumerable: true, get: function () { return nats_interface_1.natsFlowsPrefix; } });
|
|
78
78
|
Object.defineProperty(exports, "natsHpcPrefix", { enumerable: true, get: function () { return nats_interface_1.natsHpcPrefix; } });
|
|
79
79
|
Object.defineProperty(exports, "NatsStreams", { enumerable: true, get: function () { return nats_interface_1.NatsStreams; } });
|
|
80
|
+
Object.defineProperty(exports, "natsAuthPrefix", { enumerable: true, get: function () { return nats_interface_1.natsAuthPrefix; } });
|
|
80
81
|
var notification_rule_interface_1 = require("./notification-rule.interface");
|
|
81
82
|
Object.defineProperty(exports, "NotificationRuleStatus", { enumerable: true, get: function () { return notification_rule_interface_1.NotificationRuleStatus; } });
|
|
82
83
|
var organization_interface_1 = require("./organization.interface");
|
|
@@ -98,11 +98,21 @@ export interface ConfirmKnowledge extends KnowledgeVersion {
|
|
|
98
98
|
}
|
|
99
99
|
export type KnowledgeRelation = 'OBSERVED_IN' | 'EVIDENCED_BY' | 'RELATED_TO' | 'APPLIES_TO';
|
|
100
100
|
export type KnowledgeScopeResult = 'matches' | 'not-established' | 'not-evaluated';
|
|
101
|
+
export type KnowledgeStatus = 'overdue' | 'confirmed' | 'unconfirmed';
|
|
102
|
+
export declare const KNOWLEDGE_STATUS_FILTERS: readonly ["confirmed", "needs-review"];
|
|
103
|
+
export type KnowledgeStatusFilter = (typeof KNOWLEDGE_STATUS_FILTERS)[number];
|
|
104
|
+
export declare function knowledgeStatus(page: {
|
|
105
|
+
staleAfter?: string | Date | null;
|
|
106
|
+
revision: number;
|
|
107
|
+
confirmations: Pick<KnowledgeConfirmation, 'revision'>[];
|
|
108
|
+
}, now?: number): KnowledgeStatus;
|
|
109
|
+
export declare function matchesKnowledgeStatus(status: KnowledgeStatus, filter: KnowledgeStatusFilter): boolean;
|
|
101
110
|
export interface KnowledgeQuery {
|
|
102
111
|
group?: 'direct' | 'broader' | 'related';
|
|
103
112
|
query?: string;
|
|
104
113
|
contextType?: 'asset' | 'location' | 'organization';
|
|
105
114
|
contextId?: string;
|
|
115
|
+
status?: KnowledgeStatusFilter;
|
|
106
116
|
cursor?: string;
|
|
107
117
|
limit?: number;
|
|
108
118
|
}
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.KNOWLEDGE_TARGET_TYPES = void 0;
|
|
3
|
+
exports.KNOWLEDGE_STATUS_FILTERS = exports.KNOWLEDGE_TARGET_TYPES = void 0;
|
|
4
|
+
exports.knowledgeStatus = knowledgeStatus;
|
|
5
|
+
exports.matchesKnowledgeStatus = matchesKnowledgeStatus;
|
|
4
6
|
const resource_interface_1 = require("./resource.interface");
|
|
5
7
|
exports.KNOWLEDGE_TARGET_TYPES = [
|
|
6
8
|
resource_interface_1.ResourceType.KNOWLEDGE,
|
|
@@ -10,3 +12,13 @@ exports.KNOWLEDGE_TARGET_TYPES = [
|
|
|
10
12
|
resource_interface_1.ResourceType.EVENT,
|
|
11
13
|
resource_interface_1.ResourceType.TASK,
|
|
12
14
|
];
|
|
15
|
+
exports.KNOWLEDGE_STATUS_FILTERS = ['confirmed', 'needs-review'];
|
|
16
|
+
function knowledgeStatus(page, now = Date.now()) {
|
|
17
|
+
if (page.staleAfter && new Date(page.staleAfter).getTime() <= now) {
|
|
18
|
+
return 'overdue';
|
|
19
|
+
}
|
|
20
|
+
return page.confirmations.some((item) => item.revision === page.revision) ? 'confirmed' : 'unconfirmed';
|
|
21
|
+
}
|
|
22
|
+
function matchesKnowledgeStatus(status, filter) {
|
|
23
|
+
return filter === 'confirmed' ? status === 'confirmed' : status !== 'confirmed';
|
|
24
|
+
}
|
|
@@ -13,6 +13,8 @@ export declare const NatsConsumers: {
|
|
|
13
13
|
readonly ContentDeindexer: "content-deindexer";
|
|
14
14
|
readonly ContentAnalysis: {
|
|
15
15
|
readonly AssetsReferencesResolver: "content-analysis-assets-references-resolver";
|
|
16
|
+
readonly AssetAttachmentReferenceCreated: "content-analysis-asset-attachment-reference-created";
|
|
17
|
+
readonly AssetAttachmentReferenceDeleted: "content-analysis-asset-attachment-reference-deleted";
|
|
16
18
|
readonly ContentTrashed: "content-trashed";
|
|
17
19
|
readonly ContentRestored: "content-restored";
|
|
18
20
|
};
|
|
@@ -42,10 +44,6 @@ export declare const NatsConsumers: {
|
|
|
42
44
|
readonly ReferenceTargetRestored: "reference-target-restored";
|
|
43
45
|
readonly ReferenceCreateCommand: "reference-create-command";
|
|
44
46
|
};
|
|
45
|
-
readonly OrgGroupService: {
|
|
46
|
-
readonly DeleteGroupOfDeletedOrgs: "delete-group-of-deleted-orgs";
|
|
47
|
-
readonly DeleteSubsOfDeletedOrgs: "delete-subs-of-deleted-orgs";
|
|
48
|
-
};
|
|
49
47
|
};
|
|
50
48
|
readonly flows: {
|
|
51
49
|
readonly FlowTrigger: "flow-trigger";
|
|
@@ -60,9 +58,20 @@ export declare const NatsConsumers: {
|
|
|
60
58
|
};
|
|
61
59
|
readonly organizations: {
|
|
62
60
|
readonly OrgGroupMembers: {
|
|
63
|
-
readonly
|
|
61
|
+
readonly AddMembership: "add-org-group-membership";
|
|
62
|
+
readonly DeleteMembership: "delete-org-group-membership";
|
|
63
|
+
};
|
|
64
|
+
readonly OrgInitializationsService: {
|
|
65
|
+
readonly InitializeOrg: "initialize-org";
|
|
66
|
+
};
|
|
67
|
+
readonly OrgGroupsService: {
|
|
68
|
+
readonly DeleteGroupOfDeletedOrg: "delete-group-of-deleted-org";
|
|
69
|
+
};
|
|
70
|
+
readonly OrgSubscriptionsService: {
|
|
71
|
+
readonly DeleteSubsOfDeletedOrg: "delete-subs-of-deleted-org";
|
|
64
72
|
};
|
|
65
73
|
};
|
|
66
74
|
};
|
|
67
75
|
export declare const natsHpcPrefix = "com.hahnpro";
|
|
68
76
|
export declare const natsFlowsPrefix = "fs";
|
|
77
|
+
export declare const natsAuthPrefix = "auth";
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.natsFlowsPrefix = exports.natsHpcPrefix = exports.NatsConsumers = exports.NatsStreams = void 0;
|
|
3
|
+
exports.natsAuthPrefix = exports.natsFlowsPrefix = exports.natsHpcPrefix = exports.NatsConsumers = exports.NatsStreams = void 0;
|
|
4
4
|
exports.NatsStreams = {
|
|
5
5
|
Resource: 'resource',
|
|
6
6
|
Flows: 'flows',
|
|
@@ -16,6 +16,8 @@ exports.NatsConsumers = {
|
|
|
16
16
|
ContentDeindexer: 'content-deindexer',
|
|
17
17
|
ContentAnalysis: {
|
|
18
18
|
AssetsReferencesResolver: 'content-analysis-assets-references-resolver',
|
|
19
|
+
AssetAttachmentReferenceCreated: 'content-analysis-asset-attachment-reference-created',
|
|
20
|
+
AssetAttachmentReferenceDeleted: 'content-analysis-asset-attachment-reference-deleted',
|
|
19
21
|
ContentTrashed: 'content-trashed',
|
|
20
22
|
ContentRestored: 'content-restored',
|
|
21
23
|
},
|
|
@@ -45,10 +47,6 @@ exports.NatsConsumers = {
|
|
|
45
47
|
ReferenceTargetRestored: 'reference-target-restored',
|
|
46
48
|
ReferenceCreateCommand: 'reference-create-command',
|
|
47
49
|
},
|
|
48
|
-
OrgGroupService: {
|
|
49
|
-
DeleteGroupOfDeletedOrgs: 'delete-group-of-deleted-orgs',
|
|
50
|
-
DeleteSubsOfDeletedOrgs: 'delete-subs-of-deleted-orgs',
|
|
51
|
-
},
|
|
52
50
|
},
|
|
53
51
|
[exports.NatsStreams.Flows]: {
|
|
54
52
|
FlowTrigger: 'flow-trigger',
|
|
@@ -63,9 +61,20 @@ exports.NatsConsumers = {
|
|
|
63
61
|
},
|
|
64
62
|
[exports.NatsStreams.Organizations]: {
|
|
65
63
|
OrgGroupMembers: {
|
|
66
|
-
|
|
64
|
+
AddMembership: 'add-org-group-membership',
|
|
65
|
+
DeleteMembership: 'delete-org-group-membership',
|
|
66
|
+
},
|
|
67
|
+
OrgInitializationsService: {
|
|
68
|
+
InitializeOrg: 'initialize-org',
|
|
69
|
+
},
|
|
70
|
+
OrgGroupsService: {
|
|
71
|
+
DeleteGroupOfDeletedOrg: 'delete-group-of-deleted-org',
|
|
72
|
+
},
|
|
73
|
+
OrgSubscriptionsService: {
|
|
74
|
+
DeleteSubsOfDeletedOrg: 'delete-subs-of-deleted-org',
|
|
67
75
|
},
|
|
68
76
|
},
|
|
69
77
|
};
|
|
70
78
|
exports.natsHpcPrefix = 'com.hahnpro';
|
|
71
79
|
exports.natsFlowsPrefix = 'fs';
|
|
80
|
+
exports.natsAuthPrefix = 'auth';
|
|
@@ -28,8 +28,13 @@ export declare class AssetMockService extends BaseService implements AssetServic
|
|
|
28
28
|
deleteOne(assetId: string, deleteQuery?: DeleteQuery): Promise<Asset>;
|
|
29
29
|
getMany(params?: RequestParameter): Promise<Paginated<Asset>>;
|
|
30
30
|
updateOne(assetId: string, dto: Asset): Promise<Asset>;
|
|
31
|
-
|
|
32
|
-
getAttachments(assetId: string): Promise<Paginated<Attachment>>;
|
|
31
|
+
/** Legacy attachment endpoint. Query ASSET_ATTACHMENT object references instead. */
|
|
32
|
+
getAttachments(assetId: string, params?: RequestParameter): Promise<Paginated<Attachment>>;
|
|
33
|
+
/** Legacy attachment endpoint. Use ASSET_ATTACHMENT object-reference APIs instead. */
|
|
34
|
+
bulkRemoveAttachments(assetId: string, attachmentIds: string[]): Promise<Asset>;
|
|
35
|
+
/** Legacy flow-module compatibility. Use content upload plus an ASSET_ATTACHMENT object reference instead. */
|
|
36
|
+
addAttachment(assetId: string, form: CrossPlatformFormData, _options?: TokenOption): Promise<Asset>;
|
|
37
|
+
/** Legacy attachment endpoint. Query ASSET_ATTACHMENT object references instead. */
|
|
33
38
|
getAssetsByAttachment(contentId: string, params?: RequestParameter): Promise<Paginated<Asset>>;
|
|
34
39
|
getChildren(assetId: string, params?: RequestParameter): Promise<Paginated<Asset>>;
|
|
35
40
|
getEventLevelOverride(ids: string[], causes: string[]): Promise<EventLevelOverride>;
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.AssetMockService = void 0;
|
|
4
4
|
const ts_mixer_1 = require("ts-mixer");
|
|
5
|
+
const interfaces_1 = require("../interfaces");
|
|
5
6
|
const data_mock_service_1 = require("./data.mock.service");
|
|
6
7
|
const share_mock_service_1 = require("./share.mock.service");
|
|
7
8
|
const trash_mock_service_1 = require("./trash.mock.service");
|
|
@@ -63,19 +64,89 @@ class AssetMockService extends BaseService {
|
|
|
63
64
|
const asset = await this.addOne(dto);
|
|
64
65
|
return Promise.resolve(asset);
|
|
65
66
|
}
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
const
|
|
69
|
-
asset
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
67
|
+
/** Legacy attachment endpoint. Query ASSET_ATTACHMENT object references instead. */
|
|
68
|
+
async getAttachments(assetId, params = {}) {
|
|
69
|
+
const asset = this.data.find((v) => v.id === assetId);
|
|
70
|
+
const legacyAttachmentIds = (asset?.attachments ?? []).map((attachmentId) => attachmentId.toString());
|
|
71
|
+
const references = await this.api.objectReferences.find({
|
|
72
|
+
objId: assetId,
|
|
73
|
+
types: [interfaces_1.ObjectReferenceType.ASSET_ATTACHMENT],
|
|
74
|
+
objIsSrc: true,
|
|
75
|
+
});
|
|
76
|
+
const attachmentIds = new Set([...legacyAttachmentIds, ...references.docs.map((reference) => reference.tgt)]);
|
|
73
77
|
const contents = await this.api.contents.getMany();
|
|
74
|
-
const docs = contents.docs.filter((
|
|
75
|
-
|
|
78
|
+
const docs = contents.docs.filter((content) => content.id && attachmentIds.has(content.id));
|
|
79
|
+
const limit = params.limit ?? Number.MAX_SAFE_INTEGER;
|
|
80
|
+
const page = params.page ?? 1;
|
|
81
|
+
const start = (page - 1) * limit;
|
|
82
|
+
return {
|
|
83
|
+
docs: limit > 0 ? docs.slice(start, start + limit) : [],
|
|
84
|
+
total: docs.length,
|
|
85
|
+
limit,
|
|
86
|
+
page,
|
|
87
|
+
pages: limit > 0 ? Math.ceil(docs.length / limit) : 0,
|
|
88
|
+
};
|
|
89
|
+
}
|
|
90
|
+
/** Legacy attachment endpoint. Use ASSET_ATTACHMENT object-reference APIs instead. */
|
|
91
|
+
async bulkRemoveAttachments(assetId, attachmentIds) {
|
|
92
|
+
const asset = this.data.find((v) => v.id === assetId);
|
|
93
|
+
if (!asset) {
|
|
94
|
+
throw new Error(`Asset ${assetId} not found`);
|
|
95
|
+
}
|
|
96
|
+
const attachmentIdsToRemove = new Set(attachmentIds);
|
|
97
|
+
asset.attachments = (asset.attachments ?? []).filter((attachmentId) => !attachmentIdsToRemove.has(attachmentId));
|
|
98
|
+
const references = await this.api.objectReferences.find({
|
|
99
|
+
objId: assetId,
|
|
100
|
+
types: [interfaces_1.ObjectReferenceType.ASSET_ATTACHMENT],
|
|
101
|
+
objIsSrc: true,
|
|
102
|
+
});
|
|
103
|
+
await Promise.all(references.docs
|
|
104
|
+
.filter((reference) => attachmentIdsToRemove.has(reference.tgt))
|
|
105
|
+
.map((reference) => this.api.objectReferences.deleteById(reference.id.toString())));
|
|
106
|
+
return asset;
|
|
107
|
+
}
|
|
108
|
+
/** Legacy flow-module compatibility. Use content upload plus an ASSET_ATTACHMENT object reference instead. */
|
|
109
|
+
async addAttachment(assetId, form, _options = {}) {
|
|
110
|
+
const asset = this.data.find((v) => v.id === assetId);
|
|
111
|
+
if (!asset) {
|
|
112
|
+
throw new Error(`Asset ${assetId} not found`);
|
|
113
|
+
}
|
|
114
|
+
const content = await this.api.contents.upload(form);
|
|
115
|
+
if (!content.id) {
|
|
116
|
+
throw new Error('Uploaded content has no id');
|
|
117
|
+
}
|
|
118
|
+
await this.api.objectReferences.create({
|
|
119
|
+
srcId: assetId,
|
|
120
|
+
tgtId: content.id,
|
|
121
|
+
srcType: interfaces_1.ResourceType.ASSET,
|
|
122
|
+
tgtType: interfaces_1.ResourceType.CONTENT,
|
|
123
|
+
relSrc: 'mock-api',
|
|
124
|
+
relType: interfaces_1.ObjectReferenceType.ASSET_ATTACHMENT,
|
|
125
|
+
});
|
|
126
|
+
return {
|
|
127
|
+
...asset,
|
|
128
|
+
attachments: [...(asset.attachments ?? []), content.id],
|
|
129
|
+
};
|
|
76
130
|
}
|
|
77
|
-
|
|
78
|
-
|
|
131
|
+
/** Legacy attachment endpoint. Query ASSET_ATTACHMENT object references instead. */
|
|
132
|
+
async getAssetsByAttachment(contentId, params = {}) {
|
|
133
|
+
const references = await this.api.objectReferences.find({
|
|
134
|
+
objId: contentId,
|
|
135
|
+
types: [interfaces_1.ObjectReferenceType.ASSET_ATTACHMENT],
|
|
136
|
+
objIsTgt: true,
|
|
137
|
+
});
|
|
138
|
+
const assetIds = references.docs.map((reference) => reference.src);
|
|
139
|
+
const docs = this.data.filter((asset) => asset.attachments?.includes(contentId) || assetIds.includes(asset.id));
|
|
140
|
+
const limit = params.limit ?? Number.MAX_SAFE_INTEGER;
|
|
141
|
+
const page = params.page ?? 1;
|
|
142
|
+
const start = (page - 1) * limit;
|
|
143
|
+
return {
|
|
144
|
+
docs: limit > 0 ? docs.slice(start, start + limit) : [],
|
|
145
|
+
total: docs.length,
|
|
146
|
+
limit,
|
|
147
|
+
page,
|
|
148
|
+
pages: limit > 0 ? Math.ceil(docs.length / limit) : 0,
|
|
149
|
+
};
|
|
79
150
|
}
|
|
80
151
|
getChildren(assetId, params = {}) {
|
|
81
152
|
return this.getManyFiltered({ parent: assetId }, params);
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { AssetType, AssetTypeRevision, DeleteAssetTypeQuery, Paginated, RequestParameter, Template, TokenOption } from '../interfaces';
|
|
1
|
+
import { AssetType, AssetTypeRevision, AssetTypeSearchResult, DeleteAssetTypeQuery, Paginated, RequestParameter, Template, TokenOption } from '../interfaces';
|
|
2
2
|
import { AssetTypesService } from '../services';
|
|
3
3
|
import { DataMockService } from './data.mock.service';
|
|
4
4
|
import { ShareMockService } from './share.mock.service';
|
|
@@ -18,6 +18,7 @@ export declare class AssetTypesMockService extends BaseService implements AssetT
|
|
|
18
18
|
deleteOne(id: string, deleteQuery?: DeleteAssetTypeQuery): Promise<any>;
|
|
19
19
|
updateOne(id: string, dto: AssetType): Promise<AssetType>;
|
|
20
20
|
getAssetCount(id: string): Promise<number>;
|
|
21
|
+
search(query: string, _params?: RequestParameter, _options?: TokenOption): Promise<AssetTypeSearchResult[]>;
|
|
21
22
|
getRevisions(id: string): Promise<Paginated<AssetTypeRevision>>;
|
|
22
23
|
rollback(id: string, revisionId: string): Promise<AssetType>;
|
|
23
24
|
deleteRevision(assetId: string, revisionId: string): Promise<any>;
|
|
@@ -52,6 +52,18 @@ class AssetTypesMockService extends BaseService {
|
|
|
52
52
|
getAssetCount(id) {
|
|
53
53
|
return Promise.resolve(0);
|
|
54
54
|
}
|
|
55
|
+
search(query, _params = {}, _options = {}) {
|
|
56
|
+
const normalizedQuery = query.toLowerCase();
|
|
57
|
+
return Promise.resolve(this.data
|
|
58
|
+
.filter((assetType) => !assetType.deletedAt && assetType.name.toLowerCase().includes(normalizedQuery))
|
|
59
|
+
.map((assetType) => ({
|
|
60
|
+
id: assetType.id,
|
|
61
|
+
name: assetType.name,
|
|
62
|
+
isSystemAssetType: assetType.isSystemAssetType ?? false,
|
|
63
|
+
isGlobalAssetType: false,
|
|
64
|
+
owner: assetType.owner,
|
|
65
|
+
})));
|
|
66
|
+
}
|
|
55
67
|
getRevisions(id) {
|
|
56
68
|
const revisions = this.revisions.filter((revision) => revision.originalId === id);
|
|
57
69
|
const page = {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Config, Content, DeleteQuery, Paginated, PermissionLevel, RequestParameter, ReturnType } from '../interfaces';
|
|
1
|
+
import { Config, Content, ContentAnalysis, DeleteQuery, Paginated, PermissionLevel, RequestParameter, ReturnType } from '../interfaces';
|
|
2
2
|
import { ContentService } from '../services';
|
|
3
3
|
import { CrossPlatformFormData } from '../utils';
|
|
4
4
|
import { DataMockService } from './data.mock.service';
|
|
@@ -22,6 +22,8 @@ export declare class ContentMockService extends BaseService implements ContentSe
|
|
|
22
22
|
download(id: string, returnType: ReturnType.BLOB, options?: any): Promise<Blob>;
|
|
23
23
|
download(id: string, returnType: ReturnType.ARRAYBUFFER, options?: any): Promise<ArrayBuffer>;
|
|
24
24
|
download(id: string, returnType: ReturnType.STREAM, options?: any): Promise<any>;
|
|
25
|
+
updateAnalysis(id: string, dto: Partial<ContentAnalysis>): Promise<ContentAnalysis>;
|
|
26
|
+
getAnalysis(id: string): Promise<ContentAnalysis>;
|
|
25
27
|
deleteOne(contentId: string, deleteQuery?: DeleteQuery): Promise<Content>;
|
|
26
28
|
getMany(params?: RequestParameter): Promise<Paginated<Content>>;
|
|
27
29
|
upload(form: CrossPlatformFormData): Promise<Content>;
|
|
@@ -64,6 +64,12 @@ class ContentMockService extends BaseService {
|
|
|
64
64
|
return Promise.reject(new Error(`ReturnType ${returnType} not supported in mock`));
|
|
65
65
|
}
|
|
66
66
|
}
|
|
67
|
+
updateAnalysis(id, dto) {
|
|
68
|
+
return Promise.resolve({ id, contentId: id, status: interfaces_1.ContentAnalysisStatus.NOT_STARTED, ...dto });
|
|
69
|
+
}
|
|
70
|
+
getAnalysis(id) {
|
|
71
|
+
return Promise.resolve({ id, contentId: id, status: interfaces_1.ContentAnalysisStatus.NOT_STARTED });
|
|
72
|
+
}
|
|
67
73
|
deleteOne(contentId, deleteQuery = {}) {
|
|
68
74
|
const content = this.data.find((v) => v.id === contentId);
|
|
69
75
|
if (!content?.deletedAt && !deleteQuery.force) {
|
|
@@ -7,28 +7,28 @@ import { ShareMockService } from './share.mock.service';
|
|
|
7
7
|
type ExtendedFlowModule = Replace<FlowModule, 'artifacts', Array<Artifact & {
|
|
8
8
|
path: string;
|
|
9
9
|
}>>;
|
|
10
|
-
declare const BaseService_base: import("ts-mixer/dist/types/types").Class<any[], DataMockService<import("./api.mock").Identity<Pick<FlowModule, "id" | "name" | "description" | "owner" | "createdAt" | "createdBy" | "updatedAt" | "updatedBy" | "tags" | "readPermissions" | "readWritePermissions" | "deletedAt" | "
|
|
10
|
+
declare const BaseService_base: import("ts-mixer/dist/types/types").Class<any[], DataMockService<import("./api.mock").Identity<Pick<FlowModule, "id" | "name" | "description" | "owner" | "createdAt" | "createdBy" | "updatedAt" | "updatedBy" | "tags" | "readPermissions" | "readWritePermissions" | "deletedAt" | "author" | "revision" | "functions"> & {
|
|
11
11
|
artifacts: (Artifact & {
|
|
12
12
|
path: string;
|
|
13
13
|
})[];
|
|
14
|
-
}>> & ShareMockService<import("./api.mock").Identity<Pick<FlowModule, "id" | "name" | "description" | "owner" | "createdAt" | "createdBy" | "updatedAt" | "updatedBy" | "tags" | "readPermissions" | "readWritePermissions" | "deletedAt" | "
|
|
14
|
+
}>> & ShareMockService<import("./api.mock").Identity<Pick<FlowModule, "id" | "name" | "description" | "owner" | "createdAt" | "createdBy" | "updatedAt" | "updatedBy" | "tags" | "readPermissions" | "readWritePermissions" | "deletedAt" | "author" | "revision" | "functions"> & {
|
|
15
15
|
artifacts: (Artifact & {
|
|
16
16
|
path: string;
|
|
17
17
|
})[];
|
|
18
|
-
}>>, (abstract new (data?: import("./api.mock").Identity<Pick<FlowModule, "id" | "name" | "description" | "owner" | "createdAt" | "createdBy" | "updatedAt" | "updatedBy" | "tags" | "readPermissions" | "readWritePermissions" | "deletedAt" | "
|
|
18
|
+
}>>, (abstract new (data?: import("./api.mock").Identity<Pick<FlowModule, "id" | "name" | "description" | "owner" | "createdAt" | "createdBy" | "updatedAt" | "updatedBy" | "tags" | "readPermissions" | "readWritePermissions" | "deletedAt" | "author" | "revision" | "functions"> & {
|
|
19
19
|
artifacts: (Artifact & {
|
|
20
20
|
path: string;
|
|
21
21
|
})[];
|
|
22
|
-
}>[]) => DataMockService<import("./api.mock").Identity<Pick<FlowModule, "id" | "name" | "description" | "owner" | "createdAt" | "createdBy" | "updatedAt" | "updatedBy" | "tags" | "readPermissions" | "readWritePermissions" | "deletedAt" | "
|
|
22
|
+
}>[]) => DataMockService<import("./api.mock").Identity<Pick<FlowModule, "id" | "name" | "description" | "owner" | "createdAt" | "createdBy" | "updatedAt" | "updatedBy" | "tags" | "readPermissions" | "readWritePermissions" | "deletedAt" | "author" | "revision" | "functions"> & {
|
|
23
23
|
artifacts: (Artifact & {
|
|
24
24
|
path: string;
|
|
25
25
|
})[];
|
|
26
26
|
}>>) & {
|
|
27
|
-
new (data?: import("./api.mock").Identity<Pick<FlowModule, "id" | "name" | "description" | "owner" | "createdAt" | "createdBy" | "updatedAt" | "updatedBy" | "tags" | "readPermissions" | "readWritePermissions" | "deletedAt" | "
|
|
27
|
+
new (data?: import("./api.mock").Identity<Pick<FlowModule, "id" | "name" | "description" | "owner" | "createdAt" | "createdBy" | "updatedAt" | "updatedBy" | "tags" | "readPermissions" | "readWritePermissions" | "deletedAt" | "author" | "revision" | "functions"> & {
|
|
28
28
|
artifacts: (Artifact & {
|
|
29
29
|
path: string;
|
|
30
30
|
})[];
|
|
31
|
-
}>[]): ShareMockService<import("./api.mock").Identity<Pick<FlowModule, "id" | "name" | "description" | "owner" | "createdAt" | "createdBy" | "updatedAt" | "updatedBy" | "tags" | "readPermissions" | "readWritePermissions" | "deletedAt" | "
|
|
31
|
+
}>[]): ShareMockService<import("./api.mock").Identity<Pick<FlowModule, "id" | "name" | "description" | "owner" | "createdAt" | "createdBy" | "updatedAt" | "updatedBy" | "tags" | "readPermissions" | "readWritePermissions" | "deletedAt" | "author" | "revision" | "functions"> & {
|
|
32
32
|
artifacts: (Artifact & {
|
|
33
33
|
path: string;
|
|
34
34
|
})[];
|
|
@@ -75,7 +75,8 @@ class KnowledgeMockService extends knowledge_service_1.KnowledgeService {
|
|
|
75
75
|
}
|
|
76
76
|
async getMany(query = {}) {
|
|
77
77
|
const term = query.query?.toLowerCase();
|
|
78
|
-
return this.list(this.data.filter((page) => !term || `${page.title} ${page.body}`.toLowerCase().includes(term))
|
|
78
|
+
return this.list(this.data.filter((page) => (!term || `${page.title} ${page.body}`.toLowerCase().includes(term)) &&
|
|
79
|
+
(!query.status || (0, interfaces_1.matchesKnowledgeStatus)((0, interfaces_1.knowledgeStatus)(page), query.status))), query);
|
|
79
80
|
}
|
|
80
81
|
async getHome(query = {}) {
|
|
81
82
|
return { direct: await this.getMany(query), broader: { docs: [], status: 'complete' }, related: { docs: [], status: 'complete' } };
|
package/src/lib/queue.d.ts
CHANGED
|
@@ -8,7 +8,7 @@ export declare class Queue extends PQueueBase {
|
|
|
8
8
|
private total;
|
|
9
9
|
private readonly throwOnTimeout;
|
|
10
10
|
constructor({ throwOnTimeout, ...options }: QueueOptions);
|
|
11
|
-
add<TaskResultType>(function_: QueueTask<TaskResultType>, options?: Partial<QueueAddOptions>): Promise<TaskResultType
|
|
11
|
+
add<TaskResultType>(function_: QueueTask<TaskResultType>, options?: Partial<QueueAddOptions>): Promise<Awaited<TaskResultType>>;
|
|
12
12
|
getStats(): {
|
|
13
13
|
peak: number;
|
|
14
14
|
pending: number;
|
package/src/lib/queue.js
CHANGED
|
@@ -10,10 +10,10 @@ class Queue extends PQueueBase {
|
|
|
10
10
|
this.peak = 0;
|
|
11
11
|
this.total = 0;
|
|
12
12
|
this.throwOnTimeout = throwOnTimeout;
|
|
13
|
-
this.
|
|
13
|
+
this.addEventListener('add', () => {
|
|
14
14
|
this.peak = Math.max(this.peak, this.size);
|
|
15
15
|
});
|
|
16
|
-
this.
|
|
16
|
+
this.addEventListener('active', () => {
|
|
17
17
|
this.total++;
|
|
18
18
|
});
|
|
19
19
|
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { Config, Content } from '../interfaces';
|
|
2
|
+
import { CrossPlatformFormData } from '../utils';
|
|
3
|
+
import { ContentService } from './content.service';
|
|
4
|
+
import { ObjectReferenceService } from './object-reference.service';
|
|
5
|
+
export interface AssetAttachmentApi {
|
|
6
|
+
contents: Pick<ContentService, 'upload' | 'deleteOne'>;
|
|
7
|
+
objectReferences: Pick<ObjectReferenceService, 'create'>;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* Uploads content and attaches it to an asset as an ASSET_ATTACHMENT reference.
|
|
11
|
+
* If the reference cannot be created, the uploaded content is removed again.
|
|
12
|
+
*/
|
|
13
|
+
export declare function uploadAssetAttachment(api: AssetAttachmentApi, assetId: string, form: CrossPlatformFormData, relSrc: string, options?: Config): Promise<Content>;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.uploadAssetAttachment = uploadAssetAttachment;
|
|
4
|
+
const interfaces_1 = require("../interfaces");
|
|
5
|
+
/**
|
|
6
|
+
* Uploads content and attaches it to an asset as an ASSET_ATTACHMENT reference.
|
|
7
|
+
* If the reference cannot be created, the uploaded content is removed again.
|
|
8
|
+
*/
|
|
9
|
+
async function uploadAssetAttachment(api, assetId, form, relSrc, options = {}) {
|
|
10
|
+
const content = await api.contents.upload(form, options);
|
|
11
|
+
if (!content.id) {
|
|
12
|
+
throw new Error('Uploaded content has no id');
|
|
13
|
+
}
|
|
14
|
+
const reference = {
|
|
15
|
+
srcId: assetId,
|
|
16
|
+
tgtId: content.id,
|
|
17
|
+
srcType: interfaces_1.ResourceType.ASSET,
|
|
18
|
+
tgtType: interfaces_1.ResourceType.CONTENT,
|
|
19
|
+
relSrc,
|
|
20
|
+
relType: interfaces_1.ObjectReferenceType.ASSET_ATTACHMENT,
|
|
21
|
+
};
|
|
22
|
+
try {
|
|
23
|
+
await api.objectReferences.create(reference, options);
|
|
24
|
+
}
|
|
25
|
+
catch (error) {
|
|
26
|
+
await api.contents.deleteOne(content.id, {}, options).catch(() => undefined);
|
|
27
|
+
throw error;
|
|
28
|
+
}
|
|
29
|
+
return content;
|
|
30
|
+
}
|
|
@@ -16,11 +16,19 @@ export declare class AssetService extends BaseService {
|
|
|
16
16
|
getReferenceCheck(id: string, permissionLevel: PermissionLevel, options?: Config): Promise<Asset>;
|
|
17
17
|
count(filter: Filter, options?: TokenOption): Promise<number>;
|
|
18
18
|
deleteOne(id: string, deleteQuery?: DeleteAssetQuery, options?: TokenOption): Promise<any>;
|
|
19
|
+
/**
|
|
20
|
+
* Legacy flow-module compatibility. The asset service stores the relation as an
|
|
21
|
+
* ASSET_ATTACHMENT object reference behind this endpoint.
|
|
22
|
+
*/
|
|
19
23
|
addAttachment: (id: string, form: CrossPlatformFormData, options?: TokenOption) => Promise<Asset>;
|
|
20
24
|
addElementToProperty(id: string, dto: AddToProperty): Promise<Asset>;
|
|
21
25
|
removeElementFromProperty(id: string, dto: RemoveFromProperty): Promise<Asset>;
|
|
22
26
|
getChildren(assetId: string, params?: RequestParameter, options?: TokenOption): Promise<Paginated<Asset>>;
|
|
23
|
-
|
|
27
|
+
/** Legacy attachment endpoint. Query ASSET_ATTACHMENT object references instead. */
|
|
28
|
+
getAttachments(assetId: string, params?: RequestParameter, options?: Config): Promise<Paginated<Attachment>>;
|
|
29
|
+
/** Legacy attachment endpoint. Use ASSET_ATTACHMENT object-reference APIs instead. */
|
|
30
|
+
bulkRemoveAttachments(assetId: string, attachmentIds: string[], options?: TokenOption): Promise<Asset>;
|
|
31
|
+
/** Legacy attachment endpoint. Query ASSET_ATTACHMENT object references instead. */
|
|
24
32
|
getAssetsByAttachment(contentId: string, params?: RequestParameter, options?: TokenOption): Promise<Paginated<Asset>>;
|
|
25
33
|
getEventLevelOverride(ids: string[], causes: string[], options?: TokenOption): Promise<EventLevelOverride>;
|
|
26
34
|
updateEventCausesAsset(id: string, dto: EventCause, options?: TokenOption): Promise<Asset>;
|
|
@@ -11,6 +11,10 @@ class BaseService extends (0, ts_mixer_1.Mixin)((data_service_1.DataService), sh
|
|
|
11
11
|
class AssetService extends BaseService {
|
|
12
12
|
constructor(httpClient) {
|
|
13
13
|
super(httpClient, '/assets');
|
|
14
|
+
/**
|
|
15
|
+
* Legacy flow-module compatibility. The asset service stores the relation as an
|
|
16
|
+
* ASSET_ATTACHMENT object reference behind this endpoint.
|
|
17
|
+
*/
|
|
14
18
|
this.addAttachment = (id, form, options = {}) => {
|
|
15
19
|
return this.httpClient.post(`${this.basePath}/${id}/attachment`, form, {
|
|
16
20
|
headers: (0, utils_1.getFormDataHeaders)(form),
|
|
@@ -42,11 +46,17 @@ class AssetService extends BaseService {
|
|
|
42
46
|
getChildren(assetId, params = {}, options = {}) {
|
|
43
47
|
return this.getManyFiltered({ parent: assetId }, params, options);
|
|
44
48
|
}
|
|
49
|
+
/** Legacy attachment endpoint. Query ASSET_ATTACHMENT object references instead. */
|
|
45
50
|
getAttachments(assetId, params = {}, options = {}) {
|
|
46
51
|
return this.httpClient.get(`${this.basePath}/${assetId}/attachments`, { params, ...options });
|
|
47
52
|
}
|
|
53
|
+
/** Legacy attachment endpoint. Use ASSET_ATTACHMENT object-reference APIs instead. */
|
|
54
|
+
bulkRemoveAttachments(assetId, attachmentIds, options = {}) {
|
|
55
|
+
return this.httpClient.post(`${this.basePath}/${assetId}/attachments/remove`, { ids: attachmentIds }, options);
|
|
56
|
+
}
|
|
57
|
+
/** Legacy attachment endpoint. Query ASSET_ATTACHMENT object references instead. */
|
|
48
58
|
getAssetsByAttachment(contentId, params = {}, options = {}) {
|
|
49
|
-
return this.
|
|
59
|
+
return this.httpClient.get(`${this.basePath}/attachments/${contentId}`, { params, ...options });
|
|
50
60
|
}
|
|
51
61
|
getEventLevelOverride(ids, causes, options = {}) {
|
|
52
62
|
return this.httpClient.post(`${this.basePath}/event-causes`, { ids, causes }, options);
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { AssetType, DeleteAssetTypeQuery, Paginated, Template, TokenOption } from '../interfaces';
|
|
1
|
+
import { AssetType, AssetTypeSearchResult, DeleteAssetTypeQuery, Paginated, RequestParameter, Template, TokenOption } from '../interfaces';
|
|
2
2
|
import { DataService } from './data.service';
|
|
3
3
|
import { HttpClientService } from './http-client.service';
|
|
4
4
|
import { ShareService } from './share.service';
|
|
@@ -14,6 +14,7 @@ export declare class AssetTypesService extends BaseService {
|
|
|
14
14
|
constructor(httpClient: HttpClientService);
|
|
15
15
|
deleteOne(id: string, deleteQuery?: DeleteAssetTypeQuery, options?: TokenOption): Promise<AssetType>;
|
|
16
16
|
getAssetCount(id: string, options?: TokenOption): Promise<number>;
|
|
17
|
+
search(query: string, params?: RequestParameter, options?: TokenOption): Promise<AssetTypeSearchResult[]>;
|
|
17
18
|
getRevisions(id: string, options?: TokenOption): Promise<Paginated<AssetType>>;
|
|
18
19
|
rollback(id: string, revisionId: string, options?: TokenOption): Promise<AssetType>;
|
|
19
20
|
deleteRevision(id: string, revisionId: string, options?: TokenOption): Promise<any>;
|
|
@@ -17,6 +17,9 @@ class AssetTypesService extends BaseService {
|
|
|
17
17
|
getAssetCount(id, options = {}) {
|
|
18
18
|
return this.httpClient.get(`${this.basePath}/${id}/countAssets`, options);
|
|
19
19
|
}
|
|
20
|
+
search(query, params = {}, options = {}) {
|
|
21
|
+
return this.httpClient.get(`${this.basePath}/search`, { params: { ...params, query }, ...options });
|
|
22
|
+
}
|
|
20
23
|
getRevisions(id, options = {}) {
|
|
21
24
|
return this.httpClient.get(`${this.basePath}/${id}/revisions`, options);
|
|
22
25
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Config, Content, PermissionLevel, ReturnType, TokenOption } from '../interfaces';
|
|
1
|
+
import { Config, Content, ContentAnalysis, PermissionLevel, RequestParameter, ReturnType, TokenOption } from '../interfaces';
|
|
2
2
|
import { CrossPlatformFormData } from '../utils';
|
|
3
3
|
import { DataService } from './data.service';
|
|
4
4
|
import { HttpClientService } from './http-client.service';
|
|
@@ -14,6 +14,8 @@ declare class BaseService extends BaseService_base {
|
|
|
14
14
|
export declare class ContentService extends BaseService {
|
|
15
15
|
constructor(httpClient: HttpClientService);
|
|
16
16
|
getReferenceCheck(id: string, permissionLevel: PermissionLevel, options?: Config): Promise<Content>;
|
|
17
|
+
updateAnalysis: (id: string, dto: Partial<ContentAnalysis>, params?: Pick<RequestParameter, "select">, options?: Config) => Promise<ContentAnalysis>;
|
|
18
|
+
getAnalysis: (id: string, params?: Pick<RequestParameter, "select">, options?: Config) => Promise<ContentAnalysis>;
|
|
17
19
|
upload: (form: CrossPlatformFormData, options?: Config) => Promise<Content>;
|
|
18
20
|
download(id: string, raw?: boolean, options?: TokenOption): Promise<Blob | ArrayBuffer>;
|
|
19
21
|
download(id: string, returnType: ReturnType.TEXT, options?: TokenOption): Promise<string>;
|
|
@@ -12,6 +12,8 @@ class BaseService extends (0, ts_mixer_1.Mixin)((data_service_1.DataService), sh
|
|
|
12
12
|
class ContentService extends BaseService {
|
|
13
13
|
constructor(httpClient) {
|
|
14
14
|
super(httpClient, '/contents');
|
|
15
|
+
this.updateAnalysis = (id, dto, params = {}, options = {}) => this.httpClient.put(`${this.basePath}/${id}/analysis`, dto, { params, ...options });
|
|
16
|
+
this.getAnalysis = (id, params = {}, options = {}) => this.httpClient.get(`${this.basePath}/${id}/analysis`, { params, ...options });
|
|
15
17
|
this.upload = (form, options = {}) => {
|
|
16
18
|
const headers = { ...(0, utils_1.getFormDataHeaders)(form), ...options.headers };
|
|
17
19
|
return this.httpClient.post(`${this.basePath}`, form, {
|
|
@@ -23,5 +23,5 @@ export declare class DataService<T> extends APIBase implements DataInterface<T>
|
|
|
23
23
|
updateOne(id: string, dto: any, options?: TokenOption & {
|
|
24
24
|
[key: string]: any;
|
|
25
25
|
}): Promise<T>;
|
|
26
|
-
deleteOne(id: string, deleteQuery?: DeleteQuery, options?:
|
|
26
|
+
deleteOne(id: string, deleteQuery?: DeleteQuery, options?: Config): Promise<any>;
|
|
27
27
|
}
|
|
@@ -3,6 +3,8 @@ export { TrashService } from './trash.service';
|
|
|
3
3
|
export { AiService } from './ai.service';
|
|
4
4
|
export { AlertService } from './alert.service';
|
|
5
5
|
export { AssetService } from './asset.service';
|
|
6
|
+
export { uploadAssetAttachment } from './api-workflow.helpers';
|
|
7
|
+
export type { AssetAttachmentApi } from './api-workflow.helpers';
|
|
6
8
|
export { AssetTypesService } from './assettypes.service';
|
|
7
9
|
export { AuthzService } from './authz';
|
|
8
10
|
export { ContentService } from './content.service';
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.VaultService = exports.UserService = exports.TimeseriesValueFeedManagementService = exports.TimeSeriesService = exports.TaskService = exports.ShareService = exports.SearchService = exports.ProxyService = exports.OrganizationsService = exports.OrganizationsResourcesService = exports.OrganizationsAdministrationService = exports.ObjectReferenceService = exports.NotificationService = exports.NotificationRuleService = exports.LogbookService = exports.LabelService = exports.HttpClientService = exports.FlowService = exports.FlowModuleService = exports.FlowFunctionService = exports.FlowDeploymentService = exports.FlangeSkillControlService = exports.EventService = exports.EndpointService = exports.DataspaceService = exports.CrmService = exports.ContentService = exports.AuthzService = exports.AssetTypesService = exports.AssetService = exports.AlertService = exports.AiService = exports.TrashService = exports.DataService = void 0;
|
|
3
|
+
exports.VaultService = exports.UserService = exports.TimeseriesValueFeedManagementService = exports.TimeSeriesService = exports.TaskService = exports.ShareService = exports.SearchService = exports.ProxyService = exports.OrganizationsService = exports.OrganizationsResourcesService = exports.OrganizationsAdministrationService = exports.ObjectReferenceService = exports.NotificationService = exports.NotificationRuleService = exports.LogbookService = exports.LabelService = exports.HttpClientService = exports.FlowService = exports.FlowModuleService = exports.FlowFunctionService = exports.FlowDeploymentService = exports.FlangeSkillControlService = exports.EventService = exports.EndpointService = exports.DataspaceService = exports.CrmService = exports.ContentService = exports.AuthzService = exports.AssetTypesService = exports.uploadAssetAttachment = exports.AssetService = exports.AlertService = exports.AiService = exports.TrashService = exports.DataService = void 0;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
5
|
var data_service_1 = require("./data.service");
|
|
6
6
|
Object.defineProperty(exports, "DataService", { enumerable: true, get: function () { return data_service_1.DataService; } });
|
|
@@ -12,6 +12,8 @@ var alert_service_1 = require("./alert.service");
|
|
|
12
12
|
Object.defineProperty(exports, "AlertService", { enumerable: true, get: function () { return alert_service_1.AlertService; } });
|
|
13
13
|
var asset_service_1 = require("./asset.service");
|
|
14
14
|
Object.defineProperty(exports, "AssetService", { enumerable: true, get: function () { return asset_service_1.AssetService; } });
|
|
15
|
+
var api_workflow_helpers_1 = require("./api-workflow.helpers");
|
|
16
|
+
Object.defineProperty(exports, "uploadAssetAttachment", { enumerable: true, get: function () { return api_workflow_helpers_1.uploadAssetAttachment; } });
|
|
15
17
|
var assettypes_service_1 = require("./assettypes.service");
|
|
16
18
|
Object.defineProperty(exports, "AssetTypesService", { enumerable: true, get: function () { return assettypes_service_1.AssetTypesService; } });
|
|
17
19
|
var authz_1 = require("./authz");
|
|
@@ -125,6 +125,7 @@ export declare class OrganizationsService extends APIBase {
|
|
|
125
125
|
* Returns an array of organizations where the current user is a member.
|
|
126
126
|
*
|
|
127
127
|
* @returns {Promise<Organization[]>} - Organizations (array of organizations)
|
|
128
|
+
* @deprecated Use getUserOrganizations(userId) instead, where userId is the id of the current user.
|
|
128
129
|
*/
|
|
129
130
|
getMyOrganizations(): Promise<Organization[]>;
|
|
130
131
|
/**
|
|
@@ -170,6 +170,7 @@ class OrganizationsService extends api_base_1.APIBase {
|
|
|
170
170
|
* Returns an array of organizations where the current user is a member.
|
|
171
171
|
*
|
|
172
172
|
* @returns {Promise<Organization[]>} - Organizations (array of organizations)
|
|
173
|
+
* @deprecated Use getUserOrganizations(userId) instead, where userId is the id of the current user.
|
|
173
174
|
*/
|
|
174
175
|
getMyOrganizations() {
|
|
175
176
|
return this.httpClient.get(`${this.basePath}/mine`);
|