@techextensor/tab-sdk 0.0.50 → 0.0.52

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.
@@ -446,6 +446,27 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.16", ngImpo
446
446
  }]
447
447
  }] });
448
448
 
449
+ /**
450
+ * CRUD operation types used internally by the SDK
451
+ * to determine default success messages and notification behavior.
452
+ */
453
+ var CrudOperationType;
454
+ (function (CrudOperationType) {
455
+ CrudOperationType["Insert"] = "insert";
456
+ CrudOperationType["Update"] = "update";
457
+ CrudOperationType["Delete"] = "delete";
458
+ CrudOperationType["ProcessRequest"] = "processRequest";
459
+ })(CrudOperationType || (CrudOperationType = {}));
460
+ /**
461
+ * Default success messages shown after each CRUD operation.
462
+ */
463
+ const CRUD_DEFAULT_SUCCESS_MESSAGES = {
464
+ [CrudOperationType.Insert]: 'Record Created Successfully',
465
+ [CrudOperationType.Update]: 'Record Updated Successfully',
466
+ [CrudOperationType.Delete]: 'Record Deleted Successfully',
467
+ [CrudOperationType.ProcessRequest]: 'Record Submitted Successfully',
468
+ };
469
+
449
470
  class FormService {
450
471
  _tabFormioService = inject(TabFormioService);
451
472
  _templateHelper = inject(TemplateHelper);
@@ -477,12 +498,12 @@ class FormService {
477
498
  * Processes a request using the provided request payload.
478
499
  *
479
500
  * @param requestPayload The payload to be processed.
501
+ * @param options - Optional CrudOptions object with headers and notify config.
480
502
  * @returns A promise of the response from the server.
481
503
  */
482
- async processRequest(requestPayload) {
483
- // Send the request payload to the server and await the response.
504
+ async processRequest(requestPayload, options) {
484
505
  const response = await firstValueFrom(this._tabFormioService.processRequest(requestPayload));
485
- // Return the server's response.
506
+ this.handleNotification(response, options?.skipDefaultToast, CrudOperationType.ProcessRequest);
486
507
  return response;
487
508
  }
488
509
  /**
@@ -511,6 +532,20 @@ class FormService {
511
532
  // Return the response from the server.
512
533
  return response;
513
534
  }
535
+ /**
536
+ * Handles notification display after a process request operation.
537
+ * Default: auto-shows success toast. When skipDefaultToast is true, no toast is shown.
538
+ */
539
+ handleNotification(response, skipDefaultToast, operation) {
540
+ if (skipDefaultToast)
541
+ return;
542
+ const isSuccess = response?.IsSuccess === true;
543
+ if (isSuccess) {
544
+ TabSdk.ui.showSuccess({
545
+ message: CRUD_DEFAULT_SUCCESS_MESSAGES[operation] || 'Success',
546
+ });
547
+ }
548
+ }
514
549
  static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.16", ngImport: i0, type: FormService, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
515
550
  static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "19.2.16", ngImport: i0, type: FormService, providedIn: 'root' });
516
551
  }
@@ -529,9 +564,9 @@ class TransitionService {
529
564
  * @param payload - The payload containing information to determine the next status.
530
565
  * @returns A promise that resolves to the common API response.
531
566
  */
532
- async getNextStatus(payload) {
567
+ async getNextStatus(payload, headers) {
533
568
  // Await the response from the getNextStatus method of the tabBlueprintService
534
- const response = await firstValueFrom(this._tabBlueprintService.getNextStatus(payload));
569
+ const response = await firstValueFrom(this._tabBlueprintService.getNextStatus(payload, undefined, headers));
535
570
  // Return the obtained response
536
571
  return response;
537
572
  }
@@ -541,8 +576,8 @@ class TransitionService {
541
576
  * @param payload - The payload containing information to update the status.
542
577
  * @returns A promise that resolves to the common API response.
543
578
  */
544
- async updateStatus(payload) {
545
- const response = await firstValueFrom(TabSdk.util?.updateStatus(payload));
579
+ async updateStatus(payload, headers) {
580
+ const response = await firstValueFrom(TabSdk.util?.updateStatus(payload, undefined, headers));
546
581
  // Return the obtained response
547
582
  return response;
548
583
  }
@@ -749,9 +784,9 @@ class FileService {
749
784
  * @param mediaId The ID of the media file to remove.
750
785
  * @returns A promise that resolves to a common API response.
751
786
  */
752
- async removeMediaFile(mediaId) {
787
+ async removeMediaFile(mediaId, headers) {
753
788
  // Use the firstValueFrom RxJs operator to wait for the observable to complete
754
- const response = await firstValueFrom(this._mediaUploadHelper.removeMediaFile(mediaId));
789
+ const response = await firstValueFrom(this._mediaUploadHelper.removeMediaFile(mediaId, headers));
755
790
  // Return the response from the server
756
791
  return response;
757
792
  }
@@ -915,9 +950,9 @@ class AnalyticsService {
915
950
  * @param payload The screen performance payload containing the statistics to be inserted.
916
951
  * @returns A promise that resolves to a common API response containing the result of the insertion.
917
952
  */
918
- async insertScreenPerformance(payload) {
953
+ async insertScreenPerformance(payload, headers) {
919
954
  // Use the firstValueFrom RxJs operator to wait for the observable to complete
920
- const response = await firstValueFrom(this._appHelper.insertScreenPerformanceStatistics(payload));
955
+ const response = await firstValueFrom(this._appHelper.insertScreenPerformanceStatistics(payload, headers));
921
956
  // Return the response from the server
922
957
  return response;
923
958
  }
@@ -1015,83 +1050,57 @@ class CrudService {
1015
1050
  * @returns A promise that resolves to a common API response containing the retrieved record.
1016
1051
  */
1017
1052
  async executeDsq(payload, headers) {
1018
- // Use the firstValueFrom RxJs operator to wait for the observable to complete
1019
1053
  const response = await firstValueFrom(this._tabCrudService.get(payload, headers));
1020
- // Return the response from the server
1021
1054
  return response;
1022
1055
  }
1023
1056
  /**
1024
1057
  * Inserts a record into the database using the provided payload.
1025
1058
  *
1026
1059
  * @param payload - The payload containing information to insert the record.
1027
- * @param headers - Optional headers to pass to the server.
1060
+ * @param optionsOrHeaders - Optional CrudOptions object with headers and notify config, or legacy headers object.
1028
1061
  * @returns A promise that resolves to a common API response containing the inserted record.
1029
1062
  */
1030
- async insert(payload, headers) {
1031
- const response = await firstValueFrom(
1032
- // Call the insert method of the TabCrudService and pass the payload and headers
1033
- this._tabCrudService.insert(payload, headers));
1034
- // Return the response from the server
1063
+ async insert(payload, optionsOrHeaders) {
1064
+ const response = await firstValueFrom(this._tabCrudService.insert(payload, optionsOrHeaders?.headers));
1065
+ this.handleNotification(response, optionsOrHeaders?.skipDefaultToast, CrudOperationType.Insert);
1035
1066
  return response;
1036
1067
  }
1037
1068
  /**
1038
- * Inserts multiple records into the database using the provided payload.
1039
- *
1040
- * @param payload - The payload containing information to insert multiple records.
1041
- * @param headers - Optional headers to pass to the server.
1042
- * @returns A promise that resolves to a common API response containing the inserted records.
1043
- */
1044
- async bulkInsert(payload, headers) {
1045
- const response = await firstValueFrom(
1046
- // Call the bulkInsert method of the TabCrudService and pass the payload and headers
1047
- this._tabCrudService.bulkInsert(payload, headers));
1048
- // Return the response from the server
1069
+ * Inserts multiple records into the database using the provided payload.
1070
+ *
1071
+ * @param payload - The payload containing information to insert multiple records.
1072
+ * @param optionsOrHeaders - Optional CrudOptions object with headers and notify config, or legacy headers object.
1073
+ * @returns A promise that resolves to a common API response containing the inserted records.
1074
+ */
1075
+ async bulkInsert(payload, optionsOrHeaders) {
1076
+ const response = await firstValueFrom(this._tabCrudService.bulkInsert(payload, optionsOrHeaders?.headers));
1077
+ this.handleNotification(response, optionsOrHeaders?.skipDefaultToast, CrudOperationType.Insert);
1049
1078
  return response;
1050
1079
  }
1051
1080
  /**
1052
1081
  * Updates a record in the database using the provided payload.
1053
1082
  *
1054
1083
  * @param payload - The payload containing information to update the record.
1055
- * @param headers - Optional headers to pass to the server.
1084
+ * @param optionsOrHeaders - Optional CrudOptions object with headers and notify config, or legacy headers object.
1056
1085
  * @returns A promise that resolves to a common API response containing the updated record.
1057
1086
  */
1058
- async update(payload, headers) {
1059
- // Use the firstValueFrom RxJs operator to wait for the observable to complete
1060
- const response = await firstValueFrom(this._tabCrudService.update(payload, headers));
1061
- // Return the response from the server
1087
+ async update(payload, optionsOrHeaders) {
1088
+ const response = await firstValueFrom(this._tabCrudService.update(payload, optionsOrHeaders?.headers));
1089
+ this.handleNotification(response, optionsOrHeaders?.skipDefaultToast, CrudOperationType.Update);
1062
1090
  return response;
1063
1091
  }
1064
1092
  /**
1065
1093
  * Deletes a record from the database using the provided payload.
1066
1094
  *
1067
1095
  * @param payload - The payload containing information to delete the record.
1068
- * @param headers - Optional headers to pass to the server.
1096
+ * @param optionsOrHeaders - Optional CrudOptions object with headers and notify config, or legacy headers object.
1069
1097
  * @returns A promise that resolves to a common API response containing the deleted record.
1070
1098
  */
1071
- async delete(payload, headers) {
1072
- // Use the firstValueFrom RxJs operator to wait for the observable to complete
1073
- const response = await firstValueFrom(
1074
- // Call the delete method of the TabCrudService and pass the payload and headers
1075
- this._tabCrudService.delete(payload, headers));
1076
- // Return the response from the server
1099
+ async delete(payload, optionsOrHeaders) {
1100
+ const response = await firstValueFrom(this._tabCrudService.delete(payload, optionsOrHeaders?.headers));
1101
+ this.handleNotification(response, optionsOrHeaders?.skipDefaultToast, CrudOperationType.Delete);
1077
1102
  return response;
1078
1103
  }
1079
- // /**
1080
- // * Executes a stored procedure using the provided payload.
1081
- // *
1082
- // * @param sp - The name of the stored procedure to execute.
1083
- // * @param headers - Optional headers to pass to the server.
1084
- // * @returns A promise that resolves to a common API response containing the result of executing the stored procedure.
1085
- // */
1086
- // async executeSp(sp: string, headers?: any): Promise<CommonApiResponse> {
1087
- // // Use the firstValueFrom RxJs operator to wait for the observable to complete
1088
- // const response = await firstValueFrom(
1089
- // // Call the executeSp method of the TabCrudService and pass the name of the stored procedure and headers
1090
- // this._tabCrudService.executeSp(sp, headers)
1091
- // );
1092
- // // Return the response from the server
1093
- // return response;
1094
- // }
1095
1104
  /**
1096
1105
  * Executes a stored procedure using the provided payload.
1097
1106
  *
@@ -1100,11 +1109,7 @@ class CrudService {
1100
1109
  * @returns A promise that resolves to a common API response containing the result of executing the stored procedure.
1101
1110
  */
1102
1111
  async executeStoredProcedure(payload, headers) {
1103
- // Use the firstValueFrom RxJs operator to wait for the observable to complete
1104
- const response = await firstValueFrom(
1105
- // Call the executeStoredProcedure method of the TabCrudService and pass the payload and headers
1106
- this._tabCrudService.executeStoredProcedure(payload, headers));
1107
- // Return the response from the server
1112
+ const response = await firstValueFrom(this._tabCrudService.executeStoredProcedure(payload, headers));
1108
1113
  return response;
1109
1114
  }
1110
1115
  /**
@@ -1114,12 +1119,8 @@ class CrudService {
1114
1119
  * @param parameters - Optional parameters to pass to the select query.
1115
1120
  * @returns A promise that resolves to a common API response containing the result of executing the select query.
1116
1121
  */
1117
- async executeSelectQuery(selectQueryId, parameters, additionalConfig) {
1118
- // Use the firstValueFrom RxJs operator to wait for the observable to complete
1119
- const response = await firstValueFrom(
1120
- // Call the executeSelectQueryById method of the TabGetService and pass the ID of the select query and parameters
1121
- this._tabGetService.executeSelectQueryById(selectQueryId, parameters, additionalConfig));
1122
- // Return the response from the server
1122
+ async executeSelectQuery(selectQueryId, parameters, additionalConfig, headers) {
1123
+ const response = await firstValueFrom(this._tabGetService.executeSelectQueryById(selectQueryId, parameters, additionalConfig, headers));
1123
1124
  return response;
1124
1125
  }
1125
1126
  /**
@@ -1129,49 +1130,35 @@ class CrudService {
1129
1130
  * @param parameters - Optional parameters to pass to the select query.
1130
1131
  * @returns A promise that resolves to a common API response containing the result of executing the select query.
1131
1132
  */
1132
- async executeSelectExecutor(data, parameters) {
1133
- // Use the firstValueFrom RxJs operator to wait for the observable to complete
1134
- const response = await firstValueFrom(
1135
- // Call the selectExecutor method of the TabGetService and pass the select query data and parameters
1136
- this._tabGetService.selectExecutor(data, parameters));
1137
- // Return the response from the server
1133
+ async executeSelectExecutor(data, parameters, headers) {
1134
+ const response = await firstValueFrom(this._tabGetService.selectExecutor(data, parameters, undefined, headers));
1138
1135
  return response;
1139
1136
  }
1140
1137
  /**
1141
1138
  * Gets the search data using the provided search query and limit.
1142
1139
  *
1143
- * @param searchQuery - The search query to search for.
1144
- * @param limit - The number of records to limit the results to.
1140
+ * @param payload - The payload containing search query and limit.
1145
1141
  * @param parameters - Optional parameters to pass to the search query.
1146
1142
  * @returns A promise that resolves to a common API response containing the search data.
1147
1143
  */
1148
1144
  async getSearchData(payload, parameters) {
1149
- // Use the firstValueFrom RxJs operator to wait for the observable to complete
1150
- const response = await firstValueFrom(
1151
- // Call the getSearchData method of the TabGetService and pass the search query and limit
1152
- this._tabGetService.getSearchData(payload, parameters));
1153
- // Return the response from the server
1145
+ const response = await firstValueFrom(this._tabGetService.getSearchData(payload, parameters));
1154
1146
  return response;
1155
1147
  }
1156
1148
  /**
1157
1149
  * Retrieves the history of records for a specified app object.
1158
1150
  *
1159
- * @param appObjectId - The ID of the app object to retrieve the record history for.
1160
- * @param recordIds - An array of record IDs to retrieve the history for.
1151
+ * @param payload - The payload containing app object ID and record IDs.
1161
1152
  * @returns A promise that resolves to a common API response containing the record history.
1162
1153
  */
1163
- async getRecordHistory(payload) {
1164
- // Use the firstValueFrom RxJs operator to wait for the observable to complete
1165
- const response = await firstValueFrom(
1166
- // Call the getHistory method of the TabGetService and pass the app object ID and record IDs
1167
- this._tabGetService.getHistory(payload));
1168
- // Return the response from the server
1154
+ async getRecordHistory(payload, headers) {
1155
+ const response = await firstValueFrom(this._tabGetService.getHistory(payload, headers));
1169
1156
  return response;
1170
1157
  }
1171
1158
  /**
1172
1159
  * Imports data into the database.
1173
1160
  *
1174
- * @param data - The data to import.
1161
+ * @param payload - The data to import.
1175
1162
  * @returns A promise that resolves to a common API response containing the result of importing the data.
1176
1163
  */
1177
1164
  async import(payload) {
@@ -1181,6 +1168,22 @@ class CrudService {
1181
1168
  // Return the response from the server
1182
1169
  return response;
1183
1170
  }
1171
+ /**
1172
+ * Handles notification display after a CRUD operation.
1173
+ *
1174
+ * Default behavior: auto-shows success toast with operation-specific message.
1175
+ * When skipDefaultToast is true, no toast is shown — caller handles it via TabSdk.ui.showSuccess().
1176
+ */
1177
+ handleNotification(response, skipDefaultToast, operation) {
1178
+ if (skipDefaultToast)
1179
+ return;
1180
+ const isSuccess = response?.IsSuccess === true;
1181
+ if (isSuccess) {
1182
+ TabSdk.ui.showSuccess({
1183
+ message: CRUD_DEFAULT_SUCCESS_MESSAGES[operation],
1184
+ });
1185
+ }
1186
+ }
1184
1187
  static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.16", ngImport: i0, type: CrudService, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
1185
1188
  static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "19.2.16", ngImport: i0, type: CrudService, providedIn: 'root' });
1186
1189
  }
@@ -2922,5 +2925,5 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.16", ngImpo
2922
2925
  * Generated bundle index. Do not edit.
2923
2926
  */
2924
2927
 
2925
- export { NavigationType, ScreenDisplayMode, StorageType, TabSdk };
2928
+ export { CRUD_DEFAULT_SUCCESS_MESSAGES, CrudOperationType, NavigationType, ScreenDisplayMode, StorageType, TabSdk };
2926
2929
  //# sourceMappingURL=techextensor-tab-sdk.mjs.map