@yuuvis/client-core 2.13.0 → 2.15.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.
@@ -0,0 +1,5 @@
1
+ export interface FileUploadOptions {
2
+ label?: string;
3
+ silent?: boolean;
4
+ scope?: string;
5
+ }
@@ -1,16 +1,16 @@
1
1
  import { Observable } from 'rxjs';
2
+ import { DmsObjectTag } from '../../model/dms-object.interface';
2
3
  import { DmsObject } from '../../model/dms-object.model';
4
+ import { FileUploadOptions } from '../../model/file-upload-options.model';
3
5
  import { HttpOptions } from '../backend/backend.interface';
4
6
  import { SearchResponse, SearchResult } from '../search/search.service.interface';
5
7
  import { CoreApiResponse, ObjectCopyOptions, ObjectDeleteOptions, ObjectDeleteResult, ObjectMoveOptions, ObjectOptions } from './dms.service.interface';
6
- import { DmsObjectTag } from '../../model/dms-object.interface';
7
8
  import * as i0 from "@angular/core";
8
9
  /**
9
10
  * Service for working with dms objects: create them, delete, etc.
10
11
  */
11
12
  export declare class DmsService {
12
13
  #private;
13
- private triggerEvent;
14
14
  /**
15
15
  * Create new dms object(s). Providing an array of files here instead of one will create
16
16
  * a new dms object for every file. In this case indexdata will shared across all files.
@@ -38,8 +38,48 @@ export declare class DmsService {
38
38
  * @param objectId ID of the dms object to upload the file to
39
39
  * @param file The file to be uploaded
40
40
  * @param label A label that will show up in the upload overlay dialog while uploading
41
+ *
42
+ * @deprecated use uploadFileContent instead. Provide label and silent through `options`
41
43
  */
42
44
  uploadContent(objectId: string, file: File, label?: string, silent?: boolean): Observable<any>;
45
+ /**
46
+ * Uploads a file as the content of an existing DMS object, replacing or setting its content stream.
47
+ *
48
+ * This is the preferred alternative to the legacy `uploadContent()` method. It accepts a typed
49
+ * `FileUploadOptions` object instead of individual parameters, which enables full control over
50
+ * the upload label, silent mode, and scope-based progress visibility.
51
+ *
52
+ * After a successful upload, a `DMS_OBJECT_UPDATED` event is triggered automatically so that
53
+ * any subscribed parts of the application can react to the change (e.g. refreshing a preview).
54
+ *
55
+ * **Behavior:**
56
+ * - Targets the content endpoint of the given DMS object: `/dms/objects/{objectId}/contents/file`
57
+ * - `options.label` is shown in the upload progress indicator; falls back to `file.name` if omitted
58
+ * - If `options.silent` is `true`, the upload runs in the background with no UI feedback
59
+ * and no `DMS_OBJECT_UPDATED` event is emitted
60
+ * - `options.scope` tags the upload so that only the `UploadProgressComponent` instance
61
+ * configured with the same scope will display progress for this upload
62
+ *
63
+ * @param objectId - ID of the DMS object whose content should be uploaded or replaced
64
+ * @param file - The `File` object to upload as the new content stream
65
+ * @param options - Upload configuration: label, silent mode, and optional scope
66
+ * @returns An `Observable` that emits the updated DMS object on completion
67
+ *
68
+ * @example
69
+ * ```typescript
70
+ * // Replace content with a visible progress indicator
71
+ * this.dmsService.uploadFileContent(objectId, file, { label: 'Uploading contract.pdf' }).subscribe();
72
+ *
73
+ * // Silent replacement (no UI feedback, no event emitted)
74
+ * this.dmsService.uploadFileContent(objectId, file, { label: 'report.pdf', silent: true }).subscribe();
75
+ *
76
+ * // Scoped upload — only UploadProgressComponent with scope 'detail-panel' will show this
77
+ * this.dmsService
78
+ * .uploadFileContent(objectId, file, { label: 'photo.jpg', scope: 'detail-panel' })
79
+ * .subscribe();
80
+ * ```
81
+ */
82
+ uploadFileContent(objectId: string, file: File, options: FileUploadOptions): Observable<unknown>;
43
83
  /**
44
84
  * Path of dms object content file.
45
85
  * @param objectId ID of the dms object
@@ -66,7 +106,7 @@ export declare class DmsService {
66
106
  * @param id ID of the object to be retrieved
67
107
  * @param version Desired version of the object
68
108
  */
69
- getDmsObject(id: string, version?: number, silent?: boolean, requestOptions?: HttpOptions | undefined): Observable<DmsObject>;
109
+ getDmsObject(id: string, version?: number, silent?: boolean, requestOptions?: HttpOptions): Observable<DmsObject>;
70
110
  /**
71
111
  * Get tags of a dms object.
72
112
  * @param objectData Data field of the dms object
@@ -161,6 +201,7 @@ export declare class DmsService {
161
201
  * @param searchResponse The backend response
162
202
  */
163
203
  toSearchResult(searchResponse: SearchResponse): SearchResult;
204
+ private triggerEvent;
164
205
  static ɵfac: i0.ɵɵFactoryDeclaration<DmsService, never>;
165
206
  static ɵprov: i0.ɵɵInjectableDeclaration<DmsService>;
166
207
  }
@@ -1,5 +1,6 @@
1
1
  export interface ObjectOptions {
2
2
  waitForSearchConsistency?: boolean;
3
+ scope?: string;
3
4
  }
4
5
  export interface ObjectDeleteOptions extends ObjectOptions {
5
6
  silent?: boolean;
@@ -1,5 +1,5 @@
1
1
  import { Observable } from 'rxjs';
2
- import { YuvEvent, IsAny } from './event.interface';
2
+ import { IsAny, YuvEvent } from './event.interface';
3
3
  import * as i0 from "@angular/core";
4
4
  /**
5
5
  * Service for providing triggered events
@@ -15,6 +15,7 @@ export interface ProgressStatusItem {
15
15
  progress: Observable<number>;
16
16
  subscription: Subscription;
17
17
  result?: UploadResult[];
18
+ scope?: string;
18
19
  err?: {
19
20
  code: number;
20
21
  message: string;
@@ -1,4 +1,5 @@
1
1
  import { Observable } from 'rxjs';
2
+ import { FileUploadOptions } from '../../model/file-upload-options.model';
2
3
  import { ProgressStatus } from './upload.interface';
3
4
  import * as i0 from "@angular/core";
4
5
  /**
@@ -13,20 +14,145 @@ export declare class UploadService {
13
14
  * @param url The URL to upload the file to
14
15
  * @param file The file to be uploaded
15
16
  * @param label A label that will show up in the upload overlay dialog while uploading
17
+ *
18
+ * @deprecated use uploadFile instead. `label`, `silent` as well as `scope` can be provided through `options`.
16
19
  */
17
20
  upload(url: string, file: File, label?: string, silent?: boolean): Observable<any>;
21
+ /**
22
+ * Uploads a single file to the specified URL using the structured `FileUploadOptions` object.
23
+ *
24
+ * This is the preferred alternative to the legacy `upload()` method. It accepts a typed
25
+ * options object instead of individual parameters, which makes it easier to pass optional
26
+ * settings such as `silent` mode and `scope` without relying on positional arguments.
27
+ *
28
+ * **Behavior:**
29
+ * - If `options.silent` is `false` (default), the upload appears in the upload overlay dialog
30
+ * and progress is tracked via `status$`
31
+ * - If `options.silent` is `true`, the upload runs quietly in the background with no UI feedback
32
+ * - `options.label` is shown in the overlay dialog during upload; falls back to `file.name` if omitted
33
+ * - `options.scope` tags the upload with a named scope, enabling an `UploadProgressComponent`
34
+ * configured with the same scope to display only the uploads relevant to its section of the UI
35
+ *
36
+ * @param url - The backend URL to POST the file to
37
+ * @param file - The `File` object to be uploaded
38
+ * @param options - Upload configuration: label, silent mode, and optional scope
39
+ * @returns An `Observable` that emits the server response on completion
40
+ *
41
+ * @example
42
+ * ```typescript
43
+ * // Standard upload with progress indicator
44
+ * this.uploadService.uploadFile(url, file, { label: 'Uploading contract.pdf' }).subscribe();
45
+ *
46
+ * // Silent upload (no UI, runs in background)
47
+ * this.uploadService.uploadFile(url, file, { label: 'document.pdf', silent: true }).subscribe();
48
+ *
49
+ * // Scoped upload — only the UploadProgressComponent with scope 'profile-editor' will show this
50
+ * this.uploadService.uploadFile(url, file, { label: 'photo.jpg', scope: 'profile-editor' }).subscribe();
51
+ * ```
52
+ */
53
+ uploadFile(url: string, file: File, options: FileUploadOptions): Observable<unknown>;
18
54
  /**
19
55
  * Upload files using multipart upload.
20
56
  * @param url The URL to upload the files to
21
57
  * @param files The files to be uploaded
22
58
  * @param data Data to be send along with the files
23
59
  * @param label A label that will show up in the upload overlay dialog while uploading
60
+ *
61
+ * @deprecated Use multipartUpload(url, files, options, data) instead. Provide scope through options.
24
62
  */
25
63
  uploadMultipart(url: string, files: File[], data?: any, label?: string, silent?: boolean): Observable<any>;
64
+ /**
65
+ * Uploads multiple files to the specified URL using a multipart/form-data request.
66
+ *
67
+ * This is the preferred method for multi-file uploads. It accepts a typed `FileUploadOptions`
68
+ * object for configuration, making it easier to pass `scope` and other options compared
69
+ * to the legacy `uploadMultipart()` overload.
70
+ *
71
+ * **Behavior:**
72
+ * - All files are bundled into a single `FormData` payload under the `files` field
73
+ * - Optional `data` is appended as a JSON blob under the `data` field
74
+ * - If `options.silent` is `false` (default), upload progress is shown in the overlay dialog
75
+ * - If `options.silent` is `true`, the upload runs in the background with no UI feedback
76
+ * - `options.scope` tags the upload with a named scope, enabling an `UploadProgressComponent`
77
+ * configured with the same scope to display only the uploads relevant to its section of the UI
78
+ *
79
+ * @param url - The backend URL to POST the multipart request to
80
+ * @param files - Array of `File` objects to upload
81
+ * @param options - Upload configuration: label (required), silent mode, and optional scope
82
+ * @param data - Optional metadata object to send alongside the files (serialized as JSON)
83
+ * @returns An `Observable` that emits the server response on completion
84
+ *
85
+ * @example
86
+ * ```typescript
87
+ * // Upload files with a visible progress indicator
88
+ * this.uploadService.multipartUpload(url, files, { label: 'Uploading 3 files' }).subscribe();
89
+ *
90
+ * // Upload files with additional metadata
91
+ * this.uploadService
92
+ * .multipartUpload(url, files, { label: 'Batch upload' }, { folderId: 'abc123' })
93
+ * .subscribe();
94
+ *
95
+ * // Scoped upload — only the UploadProgressComponent with scope 'mail-editor' will show this
96
+ * this.uploadService
97
+ * .multipartUpload(url, files, { label: 'attachments', scope: 'mail-editor' })
98
+ * .subscribe();
99
+ * ```
100
+ */
101
+ multipartUpload(url: string, files: File[], options: FileUploadOptions, data?: unknown): Observable<unknown>;
102
+ /**
103
+ * Creates a document on the server by sending structured metadata without a file attachment.
104
+ *
105
+ * Unlike `uploadFile()` and `multipartUpload()`, this method does not attach any file content.
106
+ * It is intended for creating document objects from metadata alone — for example, creating
107
+ * a folder, a placeholder record, or a document entry where the content stream will be
108
+ * provided separately.
109
+ *
110
+ * **Behavior:**
111
+ * - Sends the `data` object as a JSON blob inside a `FormData` payload
112
+ * - Progress is NOT tracked — this method does not appear in `status$`
113
+ * - Errors are re-thrown so the caller can handle them via the returned `Observable`
114
+ *
115
+ * @param url - The backend URL to POST the document creation request to
116
+ * @param data - Metadata object describing the document to be created
117
+ * @returns An `Observable` that emits the created object(s) on success
118
+ *
119
+ * @example
120
+ * ```typescript
121
+ * const metadata = {
122
+ * objectTypeId: 'yuv:document',
123
+ * properties: { 'yuv:title': 'My Document' }
124
+ * };
125
+ *
126
+ * this.uploadService.createDocument(url, metadata).subscribe((result) => {
127
+ * console.log('Created:', result);
128
+ * });
129
+ * ```
130
+ */
26
131
  createDocument(url: string, data: any): Observable<any>;
27
132
  /**
28
- * Cancels an upload request and removes it from the list of files being uploaded.
29
- * @param id ID of the UploadItem to be canceled
133
+ * Cancels one or all active upload requests and removes them from the tracked upload list.
134
+ *
135
+ * This method unsubscribes from the underlying HTTP request, effectively aborting the upload,
136
+ * and removes the corresponding item(s) from the internal status list. The updated status
137
+ * is then emitted via `status$` so that any subscribed UI components (e.g. the upload overlay)
138
+ * can reflect the change immediately.
139
+ *
140
+ * **Behavior:**
141
+ * - If `id` is provided, only the matching upload item is cancelled
142
+ * - If `id` is omitted, **all** active uploads are cancelled at once
143
+ * - If the provided `id` does not match any active item, the call is a no-op
144
+ * - After cancellation, the error count on `status$` is recalculated
145
+ *
146
+ * @param id - Optional ID of the upload item to cancel. Omit to cancel all active uploads.
147
+ *
148
+ * @example
149
+ * ```typescript
150
+ * // Cancel a specific upload by ID
151
+ * this.uploadService.cancelItem(uploadId);
152
+ *
153
+ * // Cancel all ongoing uploads (e.g. on component destroy or user confirmation)
154
+ * this.uploadService.cancelItem();
155
+ * ```
30
156
  */
31
157
  cancelItem(id?: string): void;
32
158
  static ɵfac: i0.ɵɵFactoryDeclaration<UploadService, never>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@yuuvis/client-core",
3
- "version": "2.13.0",
3
+ "version": "2.15.0",
4
4
  "author": "OPTIMAL SYSTEMS GmbH <npm@optimal-systems.de>",
5
5
  "license": "MIT",
6
6
  "peerDependencies": {