@yuuvis/client-core 3.5.0 → 3.7.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.
|
@@ -299,30 +299,6 @@ class DmsObject {
|
|
|
299
299
|
}
|
|
300
300
|
this.sots = searchResultItem.fields.get(BaseObjectTypeField.SECONDARY_OBJECT_TYPE_IDS) || [];
|
|
301
301
|
}
|
|
302
|
-
// /**
|
|
303
|
-
// * Get the value (state) of a certain tag
|
|
304
|
-
// * @param name The tags name
|
|
305
|
-
// * @returns The value of the tag or null if the tag does not exist
|
|
306
|
-
// */
|
|
307
|
-
// getTag(name: string): any {
|
|
308
|
-
// const tags: unknown[][] = this.data[BaseObjectTypeField.TAGS] as unknown[][];
|
|
309
|
-
// const tag: unknown[] | null = tags ? (tags.find((t: any) => t[0] === name) as unknown[]) : null;
|
|
310
|
-
// return tag ? tag[1] : null;
|
|
311
|
-
// }
|
|
312
|
-
// getRetentionState(): RetentionState {
|
|
313
|
-
// if (this.data[RetentionField.RETENTION_START]) {
|
|
314
|
-
// const retentionStart = new Date(this.data[RetentionField.RETENTION_START] as string);
|
|
315
|
-
// const retentionEnd = new Date(this.data[RetentionField.RETENTION_END] as string);
|
|
316
|
-
// const today = new Date();
|
|
317
|
-
// return retentionStart <= today && today <= retentionEnd
|
|
318
|
-
// ? RetentionState.ACTIVE
|
|
319
|
-
// : today < retentionStart
|
|
320
|
-
// ? RetentionState.INACTIVE
|
|
321
|
-
// : RetentionState.DESTRUCT;
|
|
322
|
-
// } else {
|
|
323
|
-
// return RetentionState.NONE;
|
|
324
|
-
// }
|
|
325
|
-
// }
|
|
326
302
|
#generateData(fields) {
|
|
327
303
|
const result = {};
|
|
328
304
|
for (const [key, val] of fields.entries()) {
|
|
@@ -3343,6 +3319,8 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.12", ngImpo
|
|
|
3343
3319
|
|
|
3344
3320
|
const LOCALIZATION_COLUMNS = ['locale', 'label', 'description'];
|
|
3345
3321
|
|
|
3322
|
+
// Accepts both the `CreatedObject` shape (non-silent path, body?: ...) and a raw
|
|
3323
|
+
// `HttpResponse` (silent path, body: ... | null), so both upload branches emit the same array.
|
|
3346
3324
|
// eslint-disable-next-line @typescript-eslint/explicit-function-return-type
|
|
3347
3325
|
const transformResponse = () => map((res) => (res.body ? res.body.objects.map((val) => val) : null));
|
|
3348
3326
|
/**
|
|
@@ -3586,7 +3564,7 @@ class UploadService {
|
|
|
3586
3564
|
const label = options.label || file.name;
|
|
3587
3565
|
const request = this.#createHttpRequest(url, { file }, !silent);
|
|
3588
3566
|
return silent
|
|
3589
|
-
? this.#http.request(request).pipe(filter((res) => res instanceof HttpResponse))
|
|
3567
|
+
? this.#http.request(request).pipe(filter((res) => res instanceof HttpResponse), transformResponse())
|
|
3590
3568
|
: this.#startUploadWithFile(request, label, options.scope).pipe(transformResponse());
|
|
3591
3569
|
}
|
|
3592
3570
|
/**
|
|
@@ -3602,7 +3580,7 @@ class UploadService {
|
|
|
3602
3580
|
const formData = this.#createFormData({ file: files, data });
|
|
3603
3581
|
const request = this.#createHttpRequest(url, { formData }, !silent);
|
|
3604
3582
|
return silent
|
|
3605
|
-
? this.#http.request(request).pipe(filter((res) => res instanceof HttpResponse))
|
|
3583
|
+
? this.#http.request(request).pipe(filter((res) => res instanceof HttpResponse), transformResponse())
|
|
3606
3584
|
: this.#startUploadWithFile(request, label, options.scope).pipe(transformResponse());
|
|
3607
3585
|
}
|
|
3608
3586
|
#generateResult(result) {
|
|
@@ -4075,12 +4053,22 @@ class DmsService {
|
|
|
4075
4053
|
.get(`/dms/objects/${id}/versions/${version}`)
|
|
4076
4054
|
.pipe(map((res) => this.#searchResultToDmsObject(this.#searchService.toSearchResult(res).items[0])));
|
|
4077
4055
|
}
|
|
4056
|
+
/**
|
|
4057
|
+
* Transforms a Core-API response holding one or more objects (`{ objects: [...] }`) into DmsObjects.
|
|
4058
|
+
* Unwraps each property `value`, folds in the content stream and tags, just like a regular fetch.
|
|
4059
|
+
* @param response The Core-API response (e.g. fetch, batch or lock/unlock response)
|
|
4060
|
+
* @returns Array of DmsObjects (empty array if the response has no objects)
|
|
4061
|
+
*/
|
|
4062
|
+
coreResponseToDmsObjects(response) {
|
|
4063
|
+
return this.toSearchResult(response).items.map((item) => this.#searchResultToDmsObject(item));
|
|
4064
|
+
}
|
|
4065
|
+
/**
|
|
4066
|
+
* Transforms a single Core-API object response into a DmsObject.
|
|
4067
|
+
* @param res The Core-API object response (`{ properties, contentStreams }`)
|
|
4068
|
+
* @returns The mapped DmsObject
|
|
4069
|
+
*/
|
|
4078
4070
|
coreApiResponseToDmsObject(res) {
|
|
4079
|
-
return this
|
|
4080
|
-
objectTypeId: res.properties[BaseObjectTypeField.OBJECT_TYPE_ID].value,
|
|
4081
|
-
fields: new Map(Object.entries(res.properties)),
|
|
4082
|
-
content: res.contentStreams?.[0]
|
|
4083
|
-
});
|
|
4071
|
+
return this.coreResponseToDmsObjects({ objects: [res] })[0];
|
|
4084
4072
|
}
|
|
4085
4073
|
/**
|
|
4086
4074
|
* Transforms a plain data object to a DmsObject.
|
|
@@ -5517,7 +5505,7 @@ const DEFAULT_LOCK_OPTIONS = {
|
|
|
5517
5505
|
lockTag: LockField.LOCK_TAG,
|
|
5518
5506
|
state: 1,
|
|
5519
5507
|
override: false,
|
|
5520
|
-
includeObjects:
|
|
5508
|
+
includeObjects: false
|
|
5521
5509
|
};
|
|
5522
5510
|
|
|
5523
5511
|
/**
|
|
@@ -5526,24 +5514,26 @@ const DEFAULT_LOCK_OPTIONS = {
|
|
|
5526
5514
|
class ObjectLockingService {
|
|
5527
5515
|
#backend = inject(BackendService);
|
|
5528
5516
|
#userService = inject(UserService);
|
|
5529
|
-
|
|
5530
|
-
|
|
5531
|
-
|
|
5532
|
-
|
|
5533
|
-
|
|
5534
|
-
|
|
5535
|
-
|
|
5536
|
-
|
|
5537
|
-
|
|
5538
|
-
|
|
5539
|
-
|
|
5540
|
-
|
|
5541
|
-
|
|
5542
|
-
|
|
5543
|
-
|
|
5544
|
-
|
|
5545
|
-
|
|
5546
|
-
|
|
5517
|
+
#dms = inject(DmsService);
|
|
5518
|
+
lock(id, includeObjects = DEFAULT_LOCK_OPTIONS.includeObjects) {
|
|
5519
|
+
const { lockTag, state, override } = DEFAULT_LOCK_OPTIONS;
|
|
5520
|
+
const params = this.#searchQueryParams([
|
|
5521
|
+
{ name: 'overwrite', value: `${override}` },
|
|
5522
|
+
{ name: 'waitForSearchConsistency', value: 'true' },
|
|
5523
|
+
{ name: 'includeObjects', value: `${includeObjects}` }
|
|
5524
|
+
]);
|
|
5525
|
+
const requestUrl = `/dms/objects/${id}/tags/${lockTag}/state/${state}?${params}`;
|
|
5526
|
+
const req$ = this.#backend.post(requestUrl, undefined, ApiBase.core);
|
|
5527
|
+
return includeObjects ? req$.pipe(map((res) => this.#dms.coreApiResponseToDmsObject(res.objects[0]))) : req$;
|
|
5528
|
+
}
|
|
5529
|
+
unlock(id, lockTag = LockField.LOCK_TAG, includeObjects = DEFAULT_LOCK_OPTIONS.includeObjects) {
|
|
5530
|
+
const params = this.#searchQueryParams([
|
|
5531
|
+
{ name: 'waitForSearchConsistency', value: 'true' },
|
|
5532
|
+
{ name: 'includeObjects', value: `${includeObjects}` }
|
|
5533
|
+
]);
|
|
5534
|
+
const requestUrl = `/dms/objects/${id}/tags/${lockTag}?${params}`;
|
|
5535
|
+
const req$ = this.#backend.delete(requestUrl, ApiBase.core);
|
|
5536
|
+
return includeObjects ? req$.pipe(map((res) => this.#dms.coreApiResponseToDmsObject(res.objects[0]))) : req$;
|
|
5547
5537
|
}
|
|
5548
5538
|
/**
|
|
5549
5539
|
* Inspect the lock state of a DMS object relative to the current user.
|
|
@@ -5562,6 +5552,11 @@ class ObjectLockingService {
|
|
|
5562
5552
|
ownerId
|
|
5563
5553
|
};
|
|
5564
5554
|
}
|
|
5555
|
+
#searchQueryParams(options) {
|
|
5556
|
+
const params = new URLSearchParams();
|
|
5557
|
+
options.forEach(({ name, value }) => value !== undefined && params.set(name, value));
|
|
5558
|
+
return params.toString();
|
|
5559
|
+
}
|
|
5565
5560
|
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.12", ngImport: i0, type: ObjectLockingService, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
5566
5561
|
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "21.2.12", ngImport: i0, type: ObjectLockingService, providedIn: 'root' }); }
|
|
5567
5562
|
}
|