@hahnpro/hpc-api 2026.10.3 → 2026.10.5
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 +3 -3
- 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 +1 -0
- package/src/lib/interfaces/authz/permission.interface.d.ts +5 -0
- package/src/lib/interfaces/authz/permission.interface.js +2 -0
- package/src/lib/interfaces/index.d.ts +2 -2
- package/src/lib/interfaces/nats.interface.d.ts +2 -0
- package/src/lib/interfaces/nats.interface.js +2 -0
- 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/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/authz/org-group.service.d.ts +2 -2
- 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/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.5",
|
|
4
4
|
"description": "Module for easy access to the HahnPRO Cloud API",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": {
|
|
@@ -15,10 +15,10 @@
|
|
|
15
15
|
"dependencies": {
|
|
16
16
|
"@microsoft/fetch-event-source": "2.0.1",
|
|
17
17
|
"axios": "1.20.0",
|
|
18
|
-
"eventsource": "5.1.
|
|
18
|
+
"eventsource": "5.1.3",
|
|
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";
|
|
@@ -51,6 +51,7 @@ export interface Asset {
|
|
|
51
51
|
relations?: any[];
|
|
52
52
|
data?: any;
|
|
53
53
|
image?: string;
|
|
54
|
+
/** Legacy compatibility and revision data only. Use ASSET_ATTACHMENT object references and assets.getAttachments(). */
|
|
54
55
|
attachments?: string[];
|
|
55
56
|
notificationEndpoints?: string[];
|
|
56
57
|
aliases?: string[];
|
|
@@ -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';
|
|
@@ -45,7 +45,7 @@ export type { MostRecentTimeSeriesValueUpdate, Retention, SearchTimeSeriesResult
|
|
|
45
45
|
export type { CreateTimeSeriesValueFeedDto, TimeSeriesValueFeed, TimeSeriesValueFeedManagementApi, TimeSeriesValueFeedUrls, UpdateTimeSeriesValueFeedDto, } from './time-series-value-feed.interface';
|
|
46
46
|
export { MAX_TIME_SERIES_PER_VALUE_FEED } from './time-series-value-feed.interface';
|
|
47
47
|
export type { Translation, TranslationData } from './translation.interface';
|
|
48
|
-
export type { Consent,
|
|
48
|
+
export type { Consent, TableSetting, TableSettingProfile, UserSettings, Permission } from './user-settings.interface';
|
|
49
49
|
export type { KVSecretVersion, VaultSecret } from './vault.interface';
|
|
50
50
|
export { AgentId, AiAssistantId, AssistantMessageStatus, ATTACHMENT_CAPABLE_AGENT_IDS, AttachmentHandlingMode, AvailableLanguages, ErrorMessageType, FinishReason, HandOffTool, OneShotTaskId, ReferenceType, ReturnToReferrerTool, Role, ToolMessageStatus, ToolName, ToolType, } from './ai.interface';
|
|
51
51
|
export { AlertLevel, AlertStatus, AlertType, DEFAULT_DEADMAN_CONDITION, DEFAULT_RELATIVE_CONDITION, DEFAULT_THRESHOLD_CONDITION, } from './alert.interface';
|
|
@@ -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
|
};
|
|
@@ -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
|
},
|
|
@@ -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 = {
|
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,9 +1,9 @@
|
|
|
1
1
|
import { APIBase } from '../../api-base';
|
|
2
|
-
import type { CreateOrgGroup, OrgGroup, SqlPagination, SqlPaginationResult, TokenOption, UpdateOrgGroup } from '../../interfaces';
|
|
2
|
+
import type { CreateOrgGroup, OrgGroup, SqlPagination, SqlPaginationResult, SqlSort, TokenOption, UpdateOrgGroup } from '../../interfaces';
|
|
3
3
|
import { HttpClientService } from '../http-client.service';
|
|
4
4
|
export declare class OrgGroupService extends APIBase {
|
|
5
5
|
constructor(httpClient: HttpClientService);
|
|
6
|
-
getOrgGroupsOfUsersActiveOrg(sqlPagination?: SqlPagination, options?: TokenOption): Promise<SqlPaginationResult<OrgGroup>>;
|
|
6
|
+
getOrgGroupsOfUsersActiveOrg(sqlPagination?: SqlPagination & SqlSort, options?: TokenOption): Promise<SqlPaginationResult<OrgGroup>>;
|
|
7
7
|
getOrgGroupById(orgGroupId: string, options?: TokenOption): Promise<OrgGroup>;
|
|
8
8
|
createOrgGroup(createOrgGroup: CreateOrgGroup, options?: TokenOption): Promise<OrgGroup>;
|
|
9
9
|
updateOrgGroup(orgGroupId: string, updateOrgGroup: UpdateOrgGroup, options?: TokenOption): Promise<OrgGroup>;
|
|
@@ -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");
|