@messaia/cdk 22.0.1-rc.7 → 22.0.1-rc.8
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/fesm2022/messaia-cdk.mjs +66 -38
- package/fesm2022/messaia-cdk.mjs.map +1 -1
- package/package.json +1 -1
- package/types/messaia-cdk.d.ts +23 -16
package/fesm2022/messaia-cdk.mjs
CHANGED
|
@@ -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}`, {
|
|
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 : ''}`, {
|
|
@@ -15013,9 +15022,10 @@ class GenericService {
|
|
|
15013
15022
|
* @param httpOptions Optional HTTP options (headers, etc.)
|
|
15014
15023
|
* @param handleError Whether to handle errors (default: true)
|
|
15015
15024
|
*/
|
|
15016
|
-
create(entity, path, httpOptions, handleError = true) {
|
|
15025
|
+
create(entity, path, httpOptions, handleError = true, showMessage = false) {
|
|
15026
|
+
const options = this.withShowMessage(httpOptions, showMessage);
|
|
15017
15027
|
let request = this.http
|
|
15018
|
-
.post(`${this.endpoint}${path ? path : ''}`, entity,
|
|
15028
|
+
.post(`${this.endpoint}${path ? path : ''}`, entity, options);
|
|
15019
15029
|
/* Handle error */
|
|
15020
15030
|
if (handleError) {
|
|
15021
15031
|
request = request.pipe(catchError(this.handleError('create')));
|
|
@@ -15029,8 +15039,8 @@ class GenericService {
|
|
|
15029
15039
|
* @param httpOptions Optional HTTP options (headers, etc.)
|
|
15030
15040
|
* @returns Promise resolving to the created entity
|
|
15031
15041
|
*/
|
|
15032
|
-
async createAsync(entity, path, httpOptions) {
|
|
15033
|
-
return await firstValueFrom(this.create(entity, path, httpOptions));
|
|
15042
|
+
async createAsync(entity, path, httpOptions, showMessage = false) {
|
|
15043
|
+
return await firstValueFrom(this.create(entity, path, httpOptions, true, showMessage));
|
|
15034
15044
|
}
|
|
15035
15045
|
/**
|
|
15036
15046
|
* Updates an existing entity asynchronously
|
|
@@ -15040,9 +15050,10 @@ class GenericService {
|
|
|
15040
15050
|
* @param httpOptions Optional HTTP options (headers, etc.)
|
|
15041
15051
|
* @param handleError Whether to handle errors (default: true)
|
|
15042
15052
|
*/
|
|
15043
|
-
update(id, entity, path, httpOptions, handleError = true) {
|
|
15053
|
+
update(id, entity, path, httpOptions, handleError = true, showMessage = false) {
|
|
15054
|
+
const options = this.withShowMessage(httpOptions, showMessage);
|
|
15044
15055
|
let request = this.http
|
|
15045
|
-
.put(`${this.endpoint}${path ? path : ''}/${id}`, entity,
|
|
15056
|
+
.put(`${this.endpoint}${path ? path : ''}/${id}`, entity, options);
|
|
15046
15057
|
/* Handle error */
|
|
15047
15058
|
if (handleError) {
|
|
15048
15059
|
request = request.pipe(catchError(this.handleError('update')));
|
|
@@ -15057,8 +15068,8 @@ class GenericService {
|
|
|
15057
15068
|
* @param httpOptions Optional HTTP options (headers, etc.)
|
|
15058
15069
|
* @returns Promise resolving to the updated entity
|
|
15059
15070
|
*/
|
|
15060
|
-
async updateAsync(id, entity, path, httpOptions) {
|
|
15061
|
-
return await firstValueFrom(this.update(id, entity, path, httpOptions));
|
|
15071
|
+
async updateAsync(id, entity, path, httpOptions, showMessage = false) {
|
|
15072
|
+
return await firstValueFrom(this.update(id, entity, path, httpOptions, true, showMessage));
|
|
15062
15073
|
}
|
|
15063
15074
|
/**
|
|
15064
15075
|
* Applies a JSON Patch to an entity
|
|
@@ -15068,18 +15079,13 @@ class GenericService {
|
|
|
15068
15079
|
* @param httpOptions Optional HTTP options (headers, etc.)
|
|
15069
15080
|
* @param handleError Whether to handle errors (default: true)
|
|
15070
15081
|
*/
|
|
15071
|
-
patch(id, body, path, httpOptions, handleError = true) {
|
|
15082
|
+
patch(id, body, path, httpOptions, handleError = true, showMessage = false) {
|
|
15083
|
+
const options = this.withShowMessage(httpOptions, showMessage);
|
|
15072
15084
|
/* Ensure correct content-type for patch */
|
|
15073
|
-
const
|
|
15074
|
-
|
|
15075
|
-
|
|
15076
|
-
|
|
15077
|
-
const options = {
|
|
15078
|
-
...httpOptions,
|
|
15079
|
-
headers: httpOptions?.headers
|
|
15080
|
-
? httpOptions.headers.append('Content-Type', 'application/json-patch+json')
|
|
15081
|
-
: headers
|
|
15082
|
-
};
|
|
15085
|
+
const mergedHeaders = options?.headers instanceof HttpHeaders
|
|
15086
|
+
? options.headers
|
|
15087
|
+
: this.toHttpHeaders(options?.headers);
|
|
15088
|
+
options.headers = mergedHeaders.set('Content-Type', 'application/json-patch+json');
|
|
15083
15089
|
/* Create request */
|
|
15084
15090
|
let request = this.http.patch(`${this.endpoint}${path ? path : ''}/${id}`, body, options);
|
|
15085
15091
|
/* Handle error */
|
|
@@ -15096,8 +15102,8 @@ class GenericService {
|
|
|
15096
15102
|
* @param httpOptions Optional HTTP options (headers, etc.)
|
|
15097
15103
|
* @returns Promise resolving to the patched entity
|
|
15098
15104
|
*/
|
|
15099
|
-
async patchAsync(id, body, path, httpOptions) {
|
|
15100
|
-
return await firstValueFrom(this.patch(id, body, path, httpOptions));
|
|
15105
|
+
async patchAsync(id, body, path, httpOptions, showMessage = false) {
|
|
15106
|
+
return await firstValueFrom(this.patch(id, body, path, httpOptions, true, showMessage));
|
|
15101
15107
|
}
|
|
15102
15108
|
/**
|
|
15103
15109
|
* Applies a JSON Patch to multiple entities
|
|
@@ -15107,9 +15113,10 @@ class GenericService {
|
|
|
15107
15113
|
* @param httpOptions Optional HTTP options (headers, etc.)
|
|
15108
15114
|
* @param handleError Whether to handle errors (default: true)
|
|
15109
15115
|
*/
|
|
15110
|
-
patchList(ids, body, path, httpOptions, handleError = true) {
|
|
15116
|
+
patchList(ids, body, path, httpOptions, handleError = true, showMessage = false) {
|
|
15117
|
+
const options = this.withShowMessage(httpOptions, showMessage);
|
|
15111
15118
|
let request = this.http
|
|
15112
|
-
.patch(`${this.endpoint}${path ? path : ''}`, body, Object.assign(
|
|
15119
|
+
.patch(`${this.endpoint}${path ? path : ''}`, body, Object.assign(options || {}, { params: Utils.toHttpParams({ ids: ids }) }));
|
|
15113
15120
|
/* Handle error */
|
|
15114
15121
|
if (handleError) {
|
|
15115
15122
|
request = request.pipe(catchError(this.handleError('patch')));
|
|
@@ -15124,8 +15131,8 @@ class GenericService {
|
|
|
15124
15131
|
* @param httpOptions Optional HTTP options (headers, etc.)
|
|
15125
15132
|
* @returns Promise resolving to the patched entities
|
|
15126
15133
|
*/
|
|
15127
|
-
async patchListAsync(ids, body, path, httpOptions) {
|
|
15128
|
-
return await firstValueFrom(this.patchList(ids, body, path, httpOptions));
|
|
15134
|
+
async patchListAsync(ids, body, path, httpOptions, showMessage = false) {
|
|
15135
|
+
return await firstValueFrom(this.patchList(ids, body, path, httpOptions, true, showMessage));
|
|
15129
15136
|
}
|
|
15130
15137
|
/**
|
|
15131
15138
|
* Deletes an entity by ID
|
|
@@ -15134,9 +15141,10 @@ class GenericService {
|
|
|
15134
15141
|
* @param httpOptions Optional HTTP options (headers, etc.)
|
|
15135
15142
|
* @param handleError Whether to handle errors (default: true)
|
|
15136
15143
|
*/
|
|
15137
|
-
delete(id, path, httpOptions, handleError = true) {
|
|
15144
|
+
delete(id, path, httpOptions, handleError = true, showMessage = false) {
|
|
15145
|
+
const options = this.withShowMessage(httpOptions, showMessage);
|
|
15138
15146
|
let request = this.http
|
|
15139
|
-
.delete(`${this.endpoint}${path ? path : ''}/${id}`,
|
|
15147
|
+
.delete(`${this.endpoint}${path ? path : ''}/${id}`, options);
|
|
15140
15148
|
/* Handle error */
|
|
15141
15149
|
if (handleError) {
|
|
15142
15150
|
request = request.pipe(catchError(this.handleError('delete')));
|
|
@@ -15150,8 +15158,8 @@ class GenericService {
|
|
|
15150
15158
|
* @param httpOptions Optional HTTP options (headers, etc.)
|
|
15151
15159
|
* @returns Promise resolving to the delete result
|
|
15152
15160
|
*/
|
|
15153
|
-
async deleteAsync(id, path, httpOptions) {
|
|
15154
|
-
return await firstValueFrom(this.delete(id, path, httpOptions));
|
|
15161
|
+
async deleteAsync(id, path, httpOptions, showMessage = false) {
|
|
15162
|
+
return await firstValueFrom(this.delete(id, path, httpOptions, true, showMessage));
|
|
15155
15163
|
}
|
|
15156
15164
|
/**
|
|
15157
15165
|
* Deletes multiple entities by IDs
|
|
@@ -15160,8 +15168,9 @@ class GenericService {
|
|
|
15160
15168
|
* @param httpOptions Optional HTTP options (headers, etc.)
|
|
15161
15169
|
* @param handleError Whether to handle errors (default: true)
|
|
15162
15170
|
*/
|
|
15163
|
-
deleteList(ids, path, httpOptions, handleError = true) {
|
|
15164
|
-
|
|
15171
|
+
deleteList(ids, path, httpOptions, handleError = true, showMessage = false) {
|
|
15172
|
+
const options = this.withShowMessage(httpOptions, showMessage);
|
|
15173
|
+
let request = this.http.delete(`${this.endpoint}${path ? path : ''}`, Object.assign(options || {}, { params: Utils.toHttpParams({ ids: ids }) }));
|
|
15165
15174
|
/* Handle error */
|
|
15166
15175
|
if (handleError) {
|
|
15167
15176
|
request = request.pipe(catchError(this.handleError('deleteList')));
|
|
@@ -15175,8 +15184,8 @@ class GenericService {
|
|
|
15175
15184
|
* @param httpOptions Optional HTTP options (headers, etc.)
|
|
15176
15185
|
* @returns Promise resolving to the delete result
|
|
15177
15186
|
*/
|
|
15178
|
-
async deleteListAsync(ids, path, httpOptions) {
|
|
15179
|
-
return await firstValueFrom(this.deleteList(ids, path, httpOptions));
|
|
15187
|
+
async deleteListAsync(ids, path, httpOptions, showMessage = false) {
|
|
15188
|
+
return await firstValueFrom(this.deleteList(ids, path, httpOptions, true, showMessage));
|
|
15180
15189
|
}
|
|
15181
15190
|
/**
|
|
15182
15191
|
* Downloads a file from the server
|
|
@@ -15214,16 +15223,16 @@ class GenericService {
|
|
|
15214
15223
|
* Duplicates a record by ID
|
|
15215
15224
|
* @param id The ID of the record to duplicate
|
|
15216
15225
|
*/
|
|
15217
|
-
duplicate(id) {
|
|
15218
|
-
return this.create(null, `/duplicate/${id}
|
|
15226
|
+
duplicate(id, showMessage = false) {
|
|
15227
|
+
return this.create(null, `/duplicate/${id}`, undefined, true, showMessage);
|
|
15219
15228
|
}
|
|
15220
15229
|
/**
|
|
15221
15230
|
* Asynchronously duplicates a record by ID
|
|
15222
15231
|
* @param id The ID of the record to duplicate
|
|
15223
15232
|
* @returns Promise resolving to the duplicated record
|
|
15224
15233
|
*/
|
|
15225
|
-
async duplicateAsync(id) {
|
|
15226
|
-
return await firstValueFrom(this.duplicate(id));
|
|
15234
|
+
async duplicateAsync(id, showMessage = false) {
|
|
15235
|
+
return await firstValueFrom(this.duplicate(id, showMessage));
|
|
15227
15236
|
}
|
|
15228
15237
|
/**
|
|
15229
15238
|
* Uploads a file to the server
|
|
@@ -15291,6 +15300,25 @@ class GenericService {
|
|
|
15291
15300
|
.filter(key => body[key] != null && body[key] != '')
|
|
15292
15301
|
.reduce((p, key) => p.set(key, body[key]), new HttpHeaders());
|
|
15293
15302
|
}
|
|
15303
|
+
/**
|
|
15304
|
+
* Adds the Show-Message header to request options when enabled
|
|
15305
|
+
* @param httpOptions Existing HTTP options
|
|
15306
|
+
* @param showMessage Whether to add the Show-Message header
|
|
15307
|
+
* @returns HTTP options with optional Show-Message header
|
|
15308
|
+
*/
|
|
15309
|
+
withShowMessage(httpOptions, showMessage = false) {
|
|
15310
|
+
if (!showMessage) {
|
|
15311
|
+
return httpOptions;
|
|
15312
|
+
}
|
|
15313
|
+
/* Create a copy of the httpOptions to avoid mutating the original object */
|
|
15314
|
+
const options = { ...(httpOptions || {}) };
|
|
15315
|
+
const headers = options.headers instanceof HttpHeaders
|
|
15316
|
+
? options.headers
|
|
15317
|
+
: this.toHttpHeaders(options.headers);
|
|
15318
|
+
/* Set the Show-Message header to 'Yes' */
|
|
15319
|
+
options.headers = headers.set('Show-Message', 'Yes');
|
|
15320
|
+
return options;
|
|
15321
|
+
}
|
|
15294
15322
|
/**
|
|
15295
15323
|
* Normalizes the 'projection' parameter in query parameters
|
|
15296
15324
|
* @param params The query parameters (HttpParams or object)
|