@techextensor/tab-sdk 0.0.49 → 0.0.51
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/techextensor-tab-sdk.mjs +133 -81
- package/fesm2022/techextensor-tab-sdk.mjs.map +1 -1
- package/lib/crud/crud.service.d.ts +31 -18
- package/lib/enum/crud.enum.d.ts +14 -0
- package/lib/interface/crud.interface.d.ts +85 -0
- package/lib/ui/form.service.d.ts +10 -1
- package/package.json +2 -2
- package/public-api.d.ts +2 -0
|
@@ -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
|
-
|
|
506
|
+
this.handleNotification(response, options?.notify, CrudOperationType.ProcessRequest);
|
|
486
507
|
return response;
|
|
487
508
|
}
|
|
488
509
|
/**
|
|
@@ -511,6 +532,40 @@ 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
|
+
* Same behavior as CrudService notifications:
|
|
538
|
+
* - Success: auto-shown by default
|
|
539
|
+
* - Error: NOT shown by default (interceptor handles)
|
|
540
|
+
*/
|
|
541
|
+
handleNotification(response, notify, operation) {
|
|
542
|
+
if (notify?.silent)
|
|
543
|
+
return;
|
|
544
|
+
const isSuccess = response?.StatusCode === '200' || response?.IsSuccess === true;
|
|
545
|
+
const hasErrors = response?.Errors?.length > 0;
|
|
546
|
+
if (isSuccess) {
|
|
547
|
+
const successOpt = notify?.success;
|
|
548
|
+
if (successOpt === false)
|
|
549
|
+
return;
|
|
550
|
+
const successConfig = typeof successOpt === 'object' ? successOpt : undefined;
|
|
551
|
+
TabSdk.ui.showSuccess({
|
|
552
|
+
message: successConfig?.message || CRUD_DEFAULT_SUCCESS_MESSAGES[operation] || 'Success',
|
|
553
|
+
...(successConfig?.title ? { title: successConfig.title } : {}),
|
|
554
|
+
...(successConfig?.configuration ? { configuration: successConfig.configuration } : {})
|
|
555
|
+
});
|
|
556
|
+
}
|
|
557
|
+
else if (hasErrors) {
|
|
558
|
+
const errorOpt = notify?.error;
|
|
559
|
+
if (!errorOpt)
|
|
560
|
+
return;
|
|
561
|
+
const errorConfig = errorOpt;
|
|
562
|
+
TabSdk.ui.showError({
|
|
563
|
+
message: errorConfig.message || response.Errors[0],
|
|
564
|
+
...(errorConfig.title ? { title: errorConfig.title } : {}),
|
|
565
|
+
...(errorConfig.configuration ? { configuration: errorConfig.configuration } : {})
|
|
566
|
+
});
|
|
567
|
+
}
|
|
568
|
+
}
|
|
514
569
|
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.16", ngImport: i0, type: FormService, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
|
|
515
570
|
static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "19.2.16", ngImport: i0, type: FormService, providedIn: 'root' });
|
|
516
571
|
}
|
|
@@ -1015,83 +1070,57 @@ class CrudService {
|
|
|
1015
1070
|
* @returns A promise that resolves to a common API response containing the retrieved record.
|
|
1016
1071
|
*/
|
|
1017
1072
|
async executeDsq(payload, headers) {
|
|
1018
|
-
// Use the firstValueFrom RxJs operator to wait for the observable to complete
|
|
1019
1073
|
const response = await firstValueFrom(this._tabCrudService.get(payload, headers));
|
|
1020
|
-
// Return the response from the server
|
|
1021
1074
|
return response;
|
|
1022
1075
|
}
|
|
1023
1076
|
/**
|
|
1024
1077
|
* Inserts a record into the database using the provided payload.
|
|
1025
1078
|
*
|
|
1026
1079
|
* @param payload - The payload containing information to insert the record.
|
|
1027
|
-
* @param
|
|
1080
|
+
* @param optionsOrHeaders - Optional CrudOptions object with headers and notify config, or legacy headers object.
|
|
1028
1081
|
* @returns A promise that resolves to a common API response containing the inserted record.
|
|
1029
1082
|
*/
|
|
1030
|
-
async insert(payload,
|
|
1031
|
-
const response = await firstValueFrom(
|
|
1032
|
-
|
|
1033
|
-
this._tabCrudService.insert(payload, headers));
|
|
1034
|
-
// Return the response from the server
|
|
1083
|
+
async insert(payload, optionsOrHeaders) {
|
|
1084
|
+
const response = await firstValueFrom(this._tabCrudService.insert(payload, optionsOrHeaders?.headers));
|
|
1085
|
+
this.handleNotification(response, optionsOrHeaders?.notify, CrudOperationType.Insert);
|
|
1035
1086
|
return response;
|
|
1036
1087
|
}
|
|
1037
1088
|
/**
|
|
1038
|
-
|
|
1039
|
-
|
|
1040
|
-
|
|
1041
|
-
|
|
1042
|
-
|
|
1043
|
-
|
|
1044
|
-
async bulkInsert(payload,
|
|
1045
|
-
const response = await firstValueFrom(
|
|
1046
|
-
|
|
1047
|
-
this._tabCrudService.bulkInsert(payload, headers));
|
|
1048
|
-
// Return the response from the server
|
|
1089
|
+
* Inserts multiple records into the database using the provided payload.
|
|
1090
|
+
*
|
|
1091
|
+
* @param payload - The payload containing information to insert multiple records.
|
|
1092
|
+
* @param optionsOrHeaders - Optional CrudOptions object with headers and notify config, or legacy headers object.
|
|
1093
|
+
* @returns A promise that resolves to a common API response containing the inserted records.
|
|
1094
|
+
*/
|
|
1095
|
+
async bulkInsert(payload, optionsOrHeaders) {
|
|
1096
|
+
const response = await firstValueFrom(this._tabCrudService.bulkInsert(payload, optionsOrHeaders?.headers));
|
|
1097
|
+
this.handleNotification(response, optionsOrHeaders?.notify, CrudOperationType.Insert);
|
|
1049
1098
|
return response;
|
|
1050
1099
|
}
|
|
1051
1100
|
/**
|
|
1052
1101
|
* Updates a record in the database using the provided payload.
|
|
1053
1102
|
*
|
|
1054
1103
|
* @param payload - The payload containing information to update the record.
|
|
1055
|
-
* @param
|
|
1104
|
+
* @param optionsOrHeaders - Optional CrudOptions object with headers and notify config, or legacy headers object.
|
|
1056
1105
|
* @returns A promise that resolves to a common API response containing the updated record.
|
|
1057
1106
|
*/
|
|
1058
|
-
async update(payload,
|
|
1059
|
-
|
|
1060
|
-
|
|
1061
|
-
// Return the response from the server
|
|
1107
|
+
async update(payload, optionsOrHeaders) {
|
|
1108
|
+
const response = await firstValueFrom(this._tabCrudService.update(payload, optionsOrHeaders?.headers));
|
|
1109
|
+
this.handleNotification(response, optionsOrHeaders?.notify, CrudOperationType.Update);
|
|
1062
1110
|
return response;
|
|
1063
1111
|
}
|
|
1064
1112
|
/**
|
|
1065
1113
|
* Deletes a record from the database using the provided payload.
|
|
1066
1114
|
*
|
|
1067
1115
|
* @param payload - The payload containing information to delete the record.
|
|
1068
|
-
* @param
|
|
1116
|
+
* @param optionsOrHeaders - Optional CrudOptions object with headers and notify config, or legacy headers object.
|
|
1069
1117
|
* @returns A promise that resolves to a common API response containing the deleted record.
|
|
1070
1118
|
*/
|
|
1071
|
-
async delete(payload,
|
|
1072
|
-
|
|
1073
|
-
|
|
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
|
|
1119
|
+
async delete(payload, optionsOrHeaders) {
|
|
1120
|
+
const response = await firstValueFrom(this._tabCrudService.delete(payload, optionsOrHeaders?.headers));
|
|
1121
|
+
this.handleNotification(response, optionsOrHeaders?.notify, CrudOperationType.Delete);
|
|
1077
1122
|
return response;
|
|
1078
1123
|
}
|
|
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
1124
|
/**
|
|
1096
1125
|
* Executes a stored procedure using the provided payload.
|
|
1097
1126
|
*
|
|
@@ -1100,11 +1129,7 @@ class CrudService {
|
|
|
1100
1129
|
* @returns A promise that resolves to a common API response containing the result of executing the stored procedure.
|
|
1101
1130
|
*/
|
|
1102
1131
|
async executeStoredProcedure(payload, headers) {
|
|
1103
|
-
|
|
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
|
|
1132
|
+
const response = await firstValueFrom(this._tabCrudService.executeStoredProcedure(payload, headers));
|
|
1108
1133
|
return response;
|
|
1109
1134
|
}
|
|
1110
1135
|
/**
|
|
@@ -1115,11 +1140,7 @@ class CrudService {
|
|
|
1115
1140
|
* @returns A promise that resolves to a common API response containing the result of executing the select query.
|
|
1116
1141
|
*/
|
|
1117
1142
|
async executeSelectQuery(selectQueryId, parameters, additionalConfig) {
|
|
1118
|
-
|
|
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
|
|
1143
|
+
const response = await firstValueFrom(this._tabGetService.executeSelectQueryById(selectQueryId, parameters, additionalConfig));
|
|
1123
1144
|
return response;
|
|
1124
1145
|
}
|
|
1125
1146
|
/**
|
|
@@ -1130,48 +1151,34 @@ class CrudService {
|
|
|
1130
1151
|
* @returns A promise that resolves to a common API response containing the result of executing the select query.
|
|
1131
1152
|
*/
|
|
1132
1153
|
async executeSelectExecutor(data, parameters) {
|
|
1133
|
-
|
|
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
|
|
1154
|
+
const response = await firstValueFrom(this._tabGetService.selectExecutor(data, parameters));
|
|
1138
1155
|
return response;
|
|
1139
1156
|
}
|
|
1140
1157
|
/**
|
|
1141
1158
|
* Gets the search data using the provided search query and limit.
|
|
1142
1159
|
*
|
|
1143
|
-
* @param
|
|
1144
|
-
* @param limit - The number of records to limit the results to.
|
|
1160
|
+
* @param payload - The payload containing search query and limit.
|
|
1145
1161
|
* @param parameters - Optional parameters to pass to the search query.
|
|
1146
1162
|
* @returns A promise that resolves to a common API response containing the search data.
|
|
1147
1163
|
*/
|
|
1148
1164
|
async getSearchData(payload, parameters) {
|
|
1149
|
-
|
|
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
|
|
1165
|
+
const response = await firstValueFrom(this._tabGetService.getSearchData(payload, parameters));
|
|
1154
1166
|
return response;
|
|
1155
1167
|
}
|
|
1156
1168
|
/**
|
|
1157
1169
|
* Retrieves the history of records for a specified app object.
|
|
1158
1170
|
*
|
|
1159
|
-
* @param
|
|
1160
|
-
* @param recordIds - An array of record IDs to retrieve the history for.
|
|
1171
|
+
* @param payload - The payload containing app object ID and record IDs.
|
|
1161
1172
|
* @returns A promise that resolves to a common API response containing the record history.
|
|
1162
1173
|
*/
|
|
1163
1174
|
async getRecordHistory(payload) {
|
|
1164
|
-
|
|
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
|
|
1175
|
+
const response = await firstValueFrom(this._tabGetService.getHistory(payload));
|
|
1169
1176
|
return response;
|
|
1170
1177
|
}
|
|
1171
1178
|
/**
|
|
1172
1179
|
* Imports data into the database.
|
|
1173
1180
|
*
|
|
1174
|
-
* @param
|
|
1181
|
+
* @param payload - The data to import.
|
|
1175
1182
|
* @returns A promise that resolves to a common API response containing the result of importing the data.
|
|
1176
1183
|
*/
|
|
1177
1184
|
async import(payload) {
|
|
@@ -1181,6 +1188,51 @@ class CrudService {
|
|
|
1181
1188
|
// Return the response from the server
|
|
1182
1189
|
return response;
|
|
1183
1190
|
}
|
|
1191
|
+
/**
|
|
1192
|
+
* Handles notification display after a CRUD operation.
|
|
1193
|
+
*
|
|
1194
|
+
* Default behavior:
|
|
1195
|
+
* - Success: auto-shown with operation-specific message (e.g., "Record Created Successfully")
|
|
1196
|
+
* - Error: NOT shown (interceptor handles errors globally)
|
|
1197
|
+
*
|
|
1198
|
+
* Can be customized via CrudNotificationOptions:
|
|
1199
|
+
* - `silent: true` - suppresses all notifications
|
|
1200
|
+
* - `success: false` - suppresses success only
|
|
1201
|
+
* - `success: { message, title, configuration }` - custom success notification
|
|
1202
|
+
* - `error: { message, title, configuration }` - custom error notification (overrides interceptor)
|
|
1203
|
+
*/
|
|
1204
|
+
handleNotification(response, notify, operation) {
|
|
1205
|
+
// If silent, skip all notifications
|
|
1206
|
+
if (notify?.silent)
|
|
1207
|
+
return;
|
|
1208
|
+
const isSuccess = response?.StatusCode === '200' || response?.IsSuccess === true;
|
|
1209
|
+
const hasErrors = response?.Errors?.length > 0;
|
|
1210
|
+
if (isSuccess) {
|
|
1211
|
+
// Success notification: shown by default, unless explicitly suppressed
|
|
1212
|
+
const successOpt = notify?.success;
|
|
1213
|
+
if (successOpt === false)
|
|
1214
|
+
return;
|
|
1215
|
+
const successConfig = typeof successOpt === 'object' ? successOpt : undefined;
|
|
1216
|
+
TabSdk.ui.showSuccess({
|
|
1217
|
+
message: successConfig?.message || CRUD_DEFAULT_SUCCESS_MESSAGES[operation],
|
|
1218
|
+
...(successConfig?.title ? { title: successConfig.title } : {}),
|
|
1219
|
+
...(successConfig?.configuration ? { configuration: successConfig.configuration } : {})
|
|
1220
|
+
});
|
|
1221
|
+
}
|
|
1222
|
+
else if (hasErrors) {
|
|
1223
|
+
// Error notification: NOT shown by default (interceptor handles it)
|
|
1224
|
+
// Only shown if user explicitly provides error config
|
|
1225
|
+
const errorOpt = notify?.error;
|
|
1226
|
+
if (!errorOpt)
|
|
1227
|
+
return;
|
|
1228
|
+
const errorConfig = errorOpt;
|
|
1229
|
+
TabSdk.ui.showError({
|
|
1230
|
+
message: errorConfig.message || response.Errors[0],
|
|
1231
|
+
...(errorConfig.title ? { title: errorConfig.title } : {}),
|
|
1232
|
+
...(errorConfig.configuration ? { configuration: errorConfig.configuration } : {})
|
|
1233
|
+
});
|
|
1234
|
+
}
|
|
1235
|
+
}
|
|
1184
1236
|
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.16", ngImport: i0, type: CrudService, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
|
|
1185
1237
|
static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "19.2.16", ngImport: i0, type: CrudService, providedIn: 'root' });
|
|
1186
1238
|
}
|
|
@@ -2922,5 +2974,5 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.16", ngImpo
|
|
|
2922
2974
|
* Generated bundle index. Do not edit.
|
|
2923
2975
|
*/
|
|
2924
2976
|
|
|
2925
|
-
export { NavigationType, ScreenDisplayMode, StorageType, TabSdk };
|
|
2977
|
+
export { CRUD_DEFAULT_SUCCESS_MESSAGES, CrudOperationType, NavigationType, ScreenDisplayMode, StorageType, TabSdk };
|
|
2926
2978
|
//# sourceMappingURL=techextensor-tab-sdk.mjs.map
|