@messaia/cdk 22.0.1-rc.7 → 22.0.1-rc.9

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.
@@ -14903,8 +14903,15 @@ class GenericService {
14903
14903
  * @param observeResponse Whether to observe the full response (default: false)
14904
14904
  */
14905
14905
  get(id, params, headers, handleError = true, observeResponse = false) {
14906
+ /* Normalize the 'projection' parameter in query parameters */
14907
+ const parsedParams = this.normalizeProjectionParam(params);
14908
+ /* Make the HTTP GET request */
14906
14909
  let request = this.http
14907
- .get(`${this.endpoint}/${id}`, { observe: (observeResponse ? 'response' : 'body'), params: Utils.toHttpParams(params), headers: this.toHttpHeaders(headers) });
14910
+ .get(`${this.endpoint}/${id}`, {
14911
+ observe: (observeResponse ? 'response' : 'body'),
14912
+ params: parsedParams instanceof HttpParams ? parsedParams : Utils.toHttpParams(parsedParams),
14913
+ headers: this.toHttpHeaders(headers)
14914
+ });
14908
14915
  /* Handle error */
14909
14916
  if (handleError) {
14910
14917
  request = request.pipe(catchError(this.handleError('get')));
@@ -14928,6 +14935,7 @@ class GenericService {
14928
14935
  * @param handleError Whether to handle errors (default: true)
14929
14936
  */
14930
14937
  count(params, path, headers, handleError = true) {
14938
+ /* Make the HTTP GET request to count entities */
14931
14939
  let request = this.http
14932
14940
  .get(`${this.endpoint}${path ? path : '/count'}`, { params: Utils.toHttpParams(params), headers: this.toHttpHeaders(headers) });
14933
14941
  /* Handle error */
@@ -14953,6 +14961,7 @@ class GenericService {
14953
14961
  * @returns Observable with the response data
14954
14962
  */
14955
14963
  getList(params, path, headers) {
14964
+ /* Normalize the 'projection' parameter in query parameters */
14956
14965
  const parsedParams = this.normalizeProjectionParam(params);
14957
14966
  return this.http
14958
14967
  .get(`${this.endpoint}${path ? path : ''}`, {
@@ -15006,177 +15015,99 @@ class GenericService {
15006
15015
  getListAsObservable() {
15007
15016
  return this.list.asObservable();
15008
15017
  }
15009
- /**
15010
- * Creates a new entity
15011
- * @param entity The entity to create
15012
- * @param path Optional relative path to the action
15013
- * @param httpOptions Optional HTTP options (headers, etc.)
15014
- * @param handleError Whether to handle errors (default: true)
15015
- */
15016
- create(entity, path, httpOptions, handleError = true) {
15018
+ create(entity, path, optionsOrHttpOptions, handleError = true, showMessage = false) {
15019
+ const resolved = this.resolveMutationOptions(optionsOrHttpOptions, handleError, showMessage);
15020
+ const options = this.withShowMessage(resolved.httpOptions, resolved.showMessage);
15017
15021
  let request = this.http
15018
- .post(`${this.endpoint}${path ? path : ''}`, entity, httpOptions);
15022
+ .post(`${this.endpoint}${path ? path : ''}`, entity, options);
15019
15023
  /* Handle error */
15020
- if (handleError) {
15024
+ if (resolved.handleError) {
15021
15025
  request = request.pipe(catchError(this.handleError('create')));
15022
15026
  }
15023
15027
  return request;
15024
15028
  }
15025
- /**
15026
- * Asynchronously creates a new entity
15027
- * @param entity The entity to create
15028
- * @param path Optional relative path to the action
15029
- * @param httpOptions Optional HTTP options (headers, etc.)
15030
- * @returns Promise resolving to the created entity
15031
- */
15032
- async createAsync(entity, path, httpOptions) {
15033
- return await firstValueFrom(this.create(entity, path, httpOptions));
15029
+ async createAsync(entity, path, optionsOrHttpOptions, showMessage = false) {
15030
+ const resolved = this.resolveMutationOptions(optionsOrHttpOptions, true, showMessage);
15031
+ return await firstValueFrom(this.create(entity, path, resolved.httpOptions, resolved.handleError, resolved.showMessage));
15034
15032
  }
15035
- /**
15036
- * Updates an existing entity asynchronously
15037
- * @param id The ID of the entity to update
15038
- * @param entity The updated entity data
15039
- * @param path Optional relative path to the action
15040
- * @param httpOptions Optional HTTP options (headers, etc.)
15041
- * @param handleError Whether to handle errors (default: true)
15042
- */
15043
- update(id, entity, path, httpOptions, handleError = true) {
15033
+ update(id, entity, path, optionsOrHttpOptions, handleError = true, showMessage = false) {
15034
+ const resolved = this.resolveMutationOptions(optionsOrHttpOptions, handleError, showMessage);
15035
+ const options = this.withShowMessage(resolved.httpOptions, resolved.showMessage);
15044
15036
  let request = this.http
15045
- .put(`${this.endpoint}${path ? path : ''}/${id}`, entity, httpOptions);
15037
+ .put(`${this.endpoint}${path ? path : ''}/${id}`, entity, options);
15046
15038
  /* Handle error */
15047
- if (handleError) {
15039
+ if (resolved.handleError) {
15048
15040
  request = request.pipe(catchError(this.handleError('update')));
15049
15041
  }
15050
15042
  return request;
15051
15043
  }
15052
- /**
15053
- * Asynchronously updates an existing entity
15054
- * @param id The ID of the entity to update
15055
- * @param entity The updated entity data
15056
- * @param path Optional relative path to the action
15057
- * @param httpOptions Optional HTTP options (headers, etc.)
15058
- * @returns Promise resolving to the updated entity
15059
- */
15060
- async updateAsync(id, entity, path, httpOptions) {
15061
- return await firstValueFrom(this.update(id, entity, path, httpOptions));
15044
+ async updateAsync(id, entity, path, optionsOrHttpOptions, showMessage = false) {
15045
+ const resolved = this.resolveMutationOptions(optionsOrHttpOptions, true, showMessage);
15046
+ return await firstValueFrom(this.update(id, entity, path, resolved.httpOptions, resolved.handleError, resolved.showMessage));
15062
15047
  }
15063
- /**
15064
- * Applies a JSON Patch to an entity
15065
- * @param id The ID of the item to patch
15066
- * @param body The patch body
15067
- * @param path Optional relative path to the action
15068
- * @param httpOptions Optional HTTP options (headers, etc.)
15069
- * @param handleError Whether to handle errors (default: true)
15070
- */
15071
- patch(id, body, path, httpOptions, handleError = true) {
15048
+ patch(id, body, path, optionsOrHttpOptions, handleError = true, showMessage = false) {
15049
+ const resolved = this.resolveMutationOptions(optionsOrHttpOptions, handleError, showMessage);
15050
+ const options = this.withShowMessage(resolved.httpOptions, resolved.showMessage) || {};
15072
15051
  /* Ensure correct content-type for patch */
15073
- const headers = new HttpHeaders({
15074
- 'Content-Type': 'application/json-patch+json'
15075
- });
15076
- /* Merge headers */
15077
- const options = {
15078
- ...httpOptions,
15079
- headers: httpOptions?.headers
15080
- ? httpOptions.headers.append('Content-Type', 'application/json-patch+json')
15081
- : headers
15082
- };
15052
+ const mergedHeaders = options?.headers instanceof HttpHeaders
15053
+ ? options.headers
15054
+ : this.toHttpHeaders(options?.headers);
15055
+ options.headers = mergedHeaders.set('Content-Type', 'application/json-patch+json');
15083
15056
  /* Create request */
15084
15057
  let request = this.http.patch(`${this.endpoint}${path ? path : ''}/${id}`, body, options);
15085
15058
  /* Handle error */
15086
- if (handleError) {
15059
+ if (resolved.handleError) {
15087
15060
  request = request.pipe(catchError(this.handleError('patch')));
15088
15061
  }
15089
15062
  return request;
15090
15063
  }
15091
- /**
15092
- * Asynchronously applies a JSON Patch to an entity
15093
- * @param id The ID of the item to patch
15094
- * @param body The patch body
15095
- * @param path Optional relative path to the action
15096
- * @param httpOptions Optional HTTP options (headers, etc.)
15097
- * @returns Promise resolving to the patched entity
15098
- */
15099
- async patchAsync(id, body, path, httpOptions) {
15100
- return await firstValueFrom(this.patch(id, body, path, httpOptions));
15064
+ async patchAsync(id, body, path, optionsOrHttpOptions, showMessage = false) {
15065
+ const resolved = this.resolveMutationOptions(optionsOrHttpOptions, true, showMessage);
15066
+ return await firstValueFrom(this.patch(id, body, path, resolved.httpOptions, resolved.handleError, resolved.showMessage));
15101
15067
  }
15102
- /**
15103
- * Applies a JSON Patch to multiple entities
15104
- * @param ids The IDs of the items to patch
15105
- * @param body The patch body
15106
- * @param path Optional relative path to the action
15107
- * @param httpOptions Optional HTTP options (headers, etc.)
15108
- * @param handleError Whether to handle errors (default: true)
15109
- */
15110
- patchList(ids, body, path, httpOptions, handleError = true) {
15068
+ patchList(ids, body, path, optionsOrHttpOptions, handleError = true, showMessage = false) {
15069
+ const resolved = this.resolveMutationOptions(optionsOrHttpOptions, handleError, showMessage);
15070
+ const options = this.withShowMessage(resolved.httpOptions, resolved.showMessage);
15111
15071
  let request = this.http
15112
- .patch(`${this.endpoint}${path ? path : ''}`, body, Object.assign(httpOptions || {}, { params: Utils.toHttpParams({ ids: ids }) }));
15072
+ .patch(`${this.endpoint}${path ? path : ''}`, body, Object.assign(options || {}, { params: Utils.toHttpParams({ ids: ids }) }));
15113
15073
  /* Handle error */
15114
- if (handleError) {
15074
+ if (resolved.handleError) {
15115
15075
  request = request.pipe(catchError(this.handleError('patch')));
15116
15076
  }
15117
15077
  return request;
15118
15078
  }
15119
- /**
15120
- * Asynchronously applies a JSON Patch to multiple entities
15121
- * @param ids The IDs of the items to patch
15122
- * @param body The patch body
15123
- * @param path Optional relative path to the action
15124
- * @param httpOptions Optional HTTP options (headers, etc.)
15125
- * @returns Promise resolving to the patched entities
15126
- */
15127
- async patchListAsync(ids, body, path, httpOptions) {
15128
- return await firstValueFrom(this.patchList(ids, body, path, httpOptions));
15079
+ async patchListAsync(ids, body, path, optionsOrHttpOptions, showMessage = false) {
15080
+ const resolved = this.resolveMutationOptions(optionsOrHttpOptions, true, showMessage);
15081
+ return await firstValueFrom(this.patchList(ids, body, path, resolved.httpOptions, resolved.handleError, resolved.showMessage));
15129
15082
  }
15130
- /**
15131
- * Deletes an entity by ID
15132
- * @param id The ID of the item to delete
15133
- * @param path Optional relative path to the action
15134
- * @param httpOptions Optional HTTP options (headers, etc.)
15135
- * @param handleError Whether to handle errors (default: true)
15136
- */
15137
- delete(id, path, httpOptions, handleError = true) {
15083
+ delete(id, path, optionsOrHttpOptions, handleError = true, showMessage = false) {
15084
+ const resolved = this.resolveMutationOptions(optionsOrHttpOptions, handleError, showMessage);
15085
+ const options = this.withShowMessage(resolved.httpOptions, resolved.showMessage);
15138
15086
  let request = this.http
15139
- .delete(`${this.endpoint}${path ? path : ''}/${id}`, httpOptions);
15087
+ .delete(`${this.endpoint}${path ? path : ''}/${id}`, options);
15140
15088
  /* Handle error */
15141
- if (handleError) {
15089
+ if (resolved.handleError) {
15142
15090
  request = request.pipe(catchError(this.handleError('delete')));
15143
15091
  }
15144
15092
  return request;
15145
15093
  }
15146
- /**
15147
- * Asynchronously deletes an entity by ID
15148
- * @param id The ID of the item to delete
15149
- * @param path Optional relative path to the action
15150
- * @param httpOptions Optional HTTP options (headers, etc.)
15151
- * @returns Promise resolving to the delete result
15152
- */
15153
- async deleteAsync(id, path, httpOptions) {
15154
- return await firstValueFrom(this.delete(id, path, httpOptions));
15094
+ async deleteAsync(id, path, optionsOrHttpOptions, showMessage = false) {
15095
+ const resolved = this.resolveMutationOptions(optionsOrHttpOptions, true, showMessage);
15096
+ return await firstValueFrom(this.delete(id, path, resolved.httpOptions, resolved.handleError, resolved.showMessage));
15155
15097
  }
15156
- /**
15157
- * Deletes multiple entities by IDs
15158
- * @param ids The IDs of the items to delete
15159
- * @param path Optional relative path to the action
15160
- * @param httpOptions Optional HTTP options (headers, etc.)
15161
- * @param handleError Whether to handle errors (default: true)
15162
- */
15163
- deleteList(ids, path, httpOptions, handleError = true) {
15164
- let request = this.http.delete(`${this.endpoint}${path ? path : ''}`, Object.assign(httpOptions || {}, { params: Utils.toHttpParams({ ids: ids }) }));
15098
+ deleteList(ids, path, optionsOrHttpOptions, handleError = true, showMessage = false) {
15099
+ const resolved = this.resolveMutationOptions(optionsOrHttpOptions, handleError, showMessage);
15100
+ const options = this.withShowMessage(resolved.httpOptions, resolved.showMessage);
15101
+ let request = this.http.delete(`${this.endpoint}${path ? path : ''}`, Object.assign(options || {}, { params: Utils.toHttpParams({ ids: ids }) }));
15165
15102
  /* Handle error */
15166
- if (handleError) {
15103
+ if (resolved.handleError) {
15167
15104
  request = request.pipe(catchError(this.handleError('deleteList')));
15168
15105
  }
15169
15106
  return request;
15170
15107
  }
15171
- /**
15172
- * Asynchronously deletes multiple entities by IDs
15173
- * @param ids The IDs of the items to delete
15174
- * @param path Optional relative path to the action
15175
- * @param httpOptions Optional HTTP options (headers, etc.)
15176
- * @returns Promise resolving to the delete result
15177
- */
15178
- async deleteListAsync(ids, path, httpOptions) {
15179
- return await firstValueFrom(this.deleteList(ids, path, httpOptions));
15108
+ async deleteListAsync(ids, path, optionsOrHttpOptions, showMessage = false) {
15109
+ const resolved = this.resolveMutationOptions(optionsOrHttpOptions, true, showMessage);
15110
+ return await firstValueFrom(this.deleteList(ids, path, resolved.httpOptions, resolved.handleError, resolved.showMessage));
15180
15111
  }
15181
15112
  /**
15182
15113
  * Downloads a file from the server
@@ -15214,16 +15145,16 @@ class GenericService {
15214
15145
  * Duplicates a record by ID
15215
15146
  * @param id The ID of the record to duplicate
15216
15147
  */
15217
- duplicate(id) {
15218
- return this.create(null, `/duplicate/${id}`);
15148
+ duplicate(id, showMessage = false) {
15149
+ return this.create(null, `/duplicate/${id}`, undefined, true, showMessage);
15219
15150
  }
15220
15151
  /**
15221
15152
  * Asynchronously duplicates a record by ID
15222
15153
  * @param id The ID of the record to duplicate
15223
15154
  * @returns Promise resolving to the duplicated record
15224
15155
  */
15225
- async duplicateAsync(id) {
15226
- return await firstValueFrom(this.duplicate(id));
15156
+ async duplicateAsync(id, showMessage = false) {
15157
+ return await firstValueFrom(this.duplicate(id, showMessage));
15227
15158
  }
15228
15159
  /**
15229
15160
  * Uploads a file to the server
@@ -15291,6 +15222,52 @@ class GenericService {
15291
15222
  .filter(key => body[key] != null && body[key] != '')
15292
15223
  .reduce((p, key) => p.set(key, body[key]), new HttpHeaders());
15293
15224
  }
15225
+ /**
15226
+ * Adds the Show-Message header to request options when enabled
15227
+ * @param httpOptions Existing HTTP options
15228
+ * @param showMessage Whether to add the Show-Message header
15229
+ * @returns HTTP options with optional Show-Message header
15230
+ */
15231
+ withShowMessage(httpOptions, showMessage = false) {
15232
+ if (!showMessage) {
15233
+ return httpOptions;
15234
+ }
15235
+ /* Create a copy of the httpOptions to avoid mutating the original object */
15236
+ const options = { ...(httpOptions || {}) };
15237
+ const headers = options.headers instanceof HttpHeaders
15238
+ ? options.headers
15239
+ : this.toHttpHeaders(options.headers);
15240
+ /* Set the Show-Message header to 'Yes' */
15241
+ options.headers = headers.set('Show-Message', 'Yes');
15242
+ return options;
15243
+ }
15244
+ /**
15245
+ * Normalizes legacy mutation arguments and options-object overload arguments
15246
+ * @param optionsOrHttpOptions Legacy httpOptions or options object
15247
+ * @param handleError Legacy handleError value
15248
+ * @param showMessage Legacy showMessage value
15249
+ * @returns Normalized mutation options
15250
+ */
15251
+ resolveMutationOptions(optionsOrHttpOptions, handleError = true, showMessage = false) {
15252
+ if (optionsOrHttpOptions && typeof optionsOrHttpOptions === 'object') {
15253
+ const options = optionsOrHttpOptions;
15254
+ /* Interpret as options-object overload only when one of its dedicated keys exists */
15255
+ if (Object.prototype.hasOwnProperty.call(options, 'httpOptions') ||
15256
+ Object.prototype.hasOwnProperty.call(options, 'handleError') ||
15257
+ Object.prototype.hasOwnProperty.call(options, 'showMessage')) {
15258
+ return {
15259
+ httpOptions: options.httpOptions ?? {},
15260
+ handleError: options.handleError ?? true,
15261
+ showMessage: options.showMessage ?? false
15262
+ };
15263
+ }
15264
+ }
15265
+ return {
15266
+ httpOptions: optionsOrHttpOptions ?? {},
15267
+ handleError,
15268
+ showMessage
15269
+ };
15270
+ }
15294
15271
  /**
15295
15272
  * Normalizes the 'projection' parameter in query parameters
15296
15273
  * @param params The query parameters (HttpParams or object)