@messaia/cdk 20.2.1 → 20.2.3
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 +39 -11
- package/fesm2022/messaia-cdk.mjs.map +1 -1
- package/index.d.ts +17 -5
- package/package.json +1 -1
package/fesm2022/messaia-cdk.mjs
CHANGED
|
@@ -13140,6 +13140,13 @@ class EnumMetadata {
|
|
|
13140
13140
|
* @type {boolean}
|
|
13141
13141
|
*/
|
|
13142
13142
|
hidden;
|
|
13143
|
+
/**
|
|
13144
|
+
* @property Hide
|
|
13145
|
+
* @description An optional function that returns a boolean to conditionally hide the enum value based on runtime parameters.
|
|
13146
|
+
* For example, you can hide certain enum values depending on another enum's value.
|
|
13147
|
+
* @type {(context: any) => boolean}
|
|
13148
|
+
*/
|
|
13149
|
+
hide;
|
|
13143
13150
|
/**
|
|
13144
13151
|
* Constructor to initialize the EnumMetadata class with optional values.
|
|
13145
13152
|
* @param init An optional partial object to initialize the properties of EnumMetadata.
|
|
@@ -20001,42 +20008,59 @@ class GenericFormBaseComponent extends BaseComponent {
|
|
|
20001
20008
|
* Loads an item by ID.
|
|
20002
20009
|
* This method fetches the item if the component is in edit mode and the service endpoint is defined.
|
|
20003
20010
|
*
|
|
20004
|
-
* @param
|
|
20005
|
-
*
|
|
20011
|
+
* @param successCallback - A function to be called after the item has been successfully loaded.
|
|
20012
|
+
* This function will receive the loaded item as an argument.
|
|
20013
|
+
* @param errorCallback - A function to be called if an error occurs during loading.
|
|
20014
|
+
* This function will receive the error as an argument.
|
|
20015
|
+
* @param headers - Optional HTTP headers to include in the request.
|
|
20006
20016
|
*/
|
|
20007
|
-
loadItem(
|
|
20017
|
+
loadItem(successCallback, errorCallback, headers) {
|
|
20008
20018
|
if (this.isEditMode && this.service?.endpoint) {
|
|
20009
20019
|
/* Set loading state to true to indicate that an item is being loaded */
|
|
20010
20020
|
this.isLoading = true;
|
|
20011
20021
|
/* Trigger change detection to update the view with the loading state */
|
|
20012
20022
|
this.changeDetectorRef.detectChanges();
|
|
20013
20023
|
/* Call the asynchronous method to load the item */
|
|
20014
|
-
this.loadItemAsync().subscribe({
|
|
20024
|
+
this.loadItemAsync(headers).subscribe({
|
|
20015
20025
|
/* Handle the response when the item is successfully loaded */
|
|
20016
20026
|
next: (item) => {
|
|
20017
20027
|
/* Set loading state to false to indicate that loading has completed */
|
|
20018
20028
|
this.isLoading = false;
|
|
20019
|
-
/* Execute the callback if provided
|
|
20020
|
-
if (
|
|
20021
|
-
|
|
20029
|
+
/* Execute the success callback if provided */
|
|
20030
|
+
if (successCallback) {
|
|
20031
|
+
successCallback(item);
|
|
20022
20032
|
}
|
|
20023
20033
|
},
|
|
20024
20034
|
/* Handle any errors that occur during the loading process */
|
|
20025
|
-
error: (error) =>
|
|
20035
|
+
error: (error) => {
|
|
20036
|
+
/* Set loading state to false to indicate that loading has completed with error */
|
|
20037
|
+
this.isLoading = false;
|
|
20038
|
+
/* Parse the error internally */
|
|
20039
|
+
this.parseErrors(error);
|
|
20040
|
+
/* Execute the error callback if provided */
|
|
20041
|
+
if (errorCallback) {
|
|
20042
|
+
errorCallback(error);
|
|
20043
|
+
}
|
|
20044
|
+
}
|
|
20026
20045
|
});
|
|
20027
20046
|
}
|
|
20028
20047
|
}
|
|
20029
20048
|
/**
|
|
20030
20049
|
* Loads an item by ID asynchronously.
|
|
20050
|
+
*
|
|
20051
|
+
* @param headers - Optional HTTP headers to include in the request.
|
|
20031
20052
|
* @returns An Observable of the loaded entity.
|
|
20032
20053
|
*/
|
|
20033
|
-
loadItemAsync() {
|
|
20054
|
+
loadItemAsync(headers) {
|
|
20034
20055
|
if (this.id) {
|
|
20056
|
+
/* Merge provided headers with default 'Disable-Cache' header */
|
|
20057
|
+
const mergedHeaders = Object.assign({ 'Disable-Cache': 'Yes' }, headers || {});
|
|
20058
|
+
/* Perform the GET request to load the entity */
|
|
20035
20059
|
return this.service.get(this.id, Object.assign(this.query || {}, {
|
|
20036
20060
|
includes: this.includes?.length ? this.includes : this.updateIncludes,
|
|
20037
20061
|
projection: this.projection?.join(','),
|
|
20038
20062
|
observe: 'response'
|
|
20039
|
-
}),
|
|
20063
|
+
}), mergedHeaders, true, true).pipe(map((response) => {
|
|
20040
20064
|
/* Read permissions from the http headers */
|
|
20041
20065
|
const permissions = response?.headers?.get('Permissions')?.split(';') ?? [];
|
|
20042
20066
|
return {
|
|
@@ -20843,7 +20867,7 @@ class BaseInterceptor {
|
|
|
20843
20867
|
event => {
|
|
20844
20868
|
if (event instanceof HttpResponse) {
|
|
20845
20869
|
/* Check for specific headers in the response */
|
|
20846
|
-
if (req.headers.get('Show-Message')) {
|
|
20870
|
+
if (req.headers.get('Show-Message')?.trim().toLowerCase() == 'yes') {
|
|
20847
20871
|
/* Show success messages for different types of requests */
|
|
20848
20872
|
if (req.method == 'POST') {
|
|
20849
20873
|
this.snackBar.open($localize `:@@snackbar.send.success:Data sent successfully.`, undefined, {
|
|
@@ -20878,6 +20902,10 @@ class BaseInterceptor {
|
|
|
20878
20902
|
},
|
|
20879
20903
|
/* Handle errors */
|
|
20880
20904
|
error => {
|
|
20905
|
+
/* Check if the 'Show-Message' header is set to 'yes' */
|
|
20906
|
+
if (req.headers.get('Show-Message')?.trim().toLowerCase() != 'yes') {
|
|
20907
|
+
return;
|
|
20908
|
+
}
|
|
20881
20909
|
/* Handle validation errors for status code 400 (Bad Request) */
|
|
20882
20910
|
if (error.status == 400) {
|
|
20883
20911
|
let message = this.parseErrors(error.error);
|