@yuuvis/client-core 3.6.0 → 3.7.1

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.
@@ -3319,6 +3319,8 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.12", ngImpo
3319
3319
 
3320
3320
  const LOCALIZATION_COLUMNS = ['locale', 'label', 'description'];
3321
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.
3322
3324
  // eslint-disable-next-line @typescript-eslint/explicit-function-return-type
3323
3325
  const transformResponse = () => map((res) => (res.body ? res.body.objects.map((val) => val) : null));
3324
3326
  /**
@@ -3562,7 +3564,7 @@ class UploadService {
3562
3564
  const label = options.label || file.name;
3563
3565
  const request = this.#createHttpRequest(url, { file }, !silent);
3564
3566
  return silent
3565
- ? this.#http.request(request).pipe(filter((res) => res instanceof HttpResponse))
3567
+ ? this.#http.request(request).pipe(filter((res) => res instanceof HttpResponse), transformResponse())
3566
3568
  : this.#startUploadWithFile(request, label, options.scope).pipe(transformResponse());
3567
3569
  }
3568
3570
  /**
@@ -3578,7 +3580,7 @@ class UploadService {
3578
3580
  const formData = this.#createFormData({ file: files, data });
3579
3581
  const request = this.#createHttpRequest(url, { formData }, !silent);
3580
3582
  return silent
3581
- ? this.#http.request(request).pipe(filter((res) => res instanceof HttpResponse))
3583
+ ? this.#http.request(request).pipe(filter((res) => res instanceof HttpResponse), transformResponse())
3582
3584
  : this.#startUploadWithFile(request, label, options.scope).pipe(transformResponse());
3583
3585
  }
3584
3586
  #generateResult(result) {
@@ -4051,12 +4053,22 @@ class DmsService {
4051
4053
  .get(`/dms/objects/${id}/versions/${version}`)
4052
4054
  .pipe(map((res) => this.#searchResultToDmsObject(this.#searchService.toSearchResult(res).items[0])));
4053
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
+ */
4054
4070
  coreApiResponseToDmsObject(res) {
4055
- return this.#searchResultToDmsObject({
4056
- objectTypeId: res.properties[BaseObjectTypeField.OBJECT_TYPE_ID].value,
4057
- fields: new Map(Object.entries(res.properties)),
4058
- content: res.contentStreams?.[0]
4059
- });
4071
+ return this.coreResponseToDmsObjects({ objects: [res] })[0];
4060
4072
  }
4061
4073
  /**
4062
4074
  * Transforms a plain data object to a DmsObject.
@@ -5493,7 +5505,7 @@ const DEFAULT_LOCK_OPTIONS = {
5493
5505
  lockTag: LockField.LOCK_TAG,
5494
5506
  state: 1,
5495
5507
  override: false,
5496
- includeObjects: true
5508
+ includeObjects: false
5497
5509
  };
5498
5510
 
5499
5511
  /**
@@ -5502,24 +5514,26 @@ const DEFAULT_LOCK_OPTIONS = {
5502
5514
  class ObjectLockingService {
5503
5515
  #backend = inject(BackendService);
5504
5516
  #userService = inject(UserService);
5505
- /**
5506
- * Lock a DMS object by setting a lock tag with a given state.
5507
- * @param id ID of the object to lock
5508
- * @returns Observable emitting the updated tag data of the locked object
5509
- * @see {@link ObjectLockingResponse}
5510
- */
5511
- lock(id) {
5512
- const { lockTag, state, override, includeObjects } = DEFAULT_LOCK_OPTIONS;
5513
- return this.#backend.post(`/dms/objects/${id}/tags/${lockTag}/state/${state}?overwrite=${override}&includeObjects=${includeObjects}`, undefined, ApiBase.core);
5514
- }
5515
- /**
5516
- * Remove the lock tag from a DMS object.
5517
- * @param id ID of the object to unlock
5518
- * @param lockTag Tag identifier to remove; defaults to `LockField.LOCK_TAG`
5519
- * @returns Observable that completes once the tag has been deleted
5520
- */
5521
- unlock(id, lockTag = LockField.LOCK_TAG) {
5522
- return this.#backend.delete(`/dms/objects/${id}/tags/${lockTag}`, ApiBase.core);
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$;
5523
5537
  }
5524
5538
  /**
5525
5539
  * Inspect the lock state of a DMS object relative to the current user.
@@ -5538,6 +5552,11 @@ class ObjectLockingService {
5538
5552
  ownerId
5539
5553
  };
5540
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
+ }
5541
5560
  static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.12", ngImport: i0, type: ObjectLockingService, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
5542
5561
  static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "21.2.12", ngImport: i0, type: ObjectLockingService, providedIn: 'root' }); }
5543
5562
  }