@plyaz/api 1.2.2 → 1.3.0
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/dist/api/client/clientEventManager.d.ts +8 -2
- package/dist/api/client/clientEventManager.d.ts.map +1 -1
- package/dist/api/client/createApiClient.d.ts.map +1 -1
- package/dist/api/client/helpers/interceptors.d.ts +2 -2
- package/dist/api/client/helpers/interceptors.d.ts.map +1 -1
- package/dist/api/config/global.d.ts.map +1 -1
- package/dist/api/debugger/DebugReport.d.ts.map +1 -1
- package/dist/api/debugger/UnifiedDebugger.d.ts.map +1 -1
- package/dist/api/debugger/queue/DebuggerQueueManager.d.ts.map +1 -1
- package/dist/api/debugger/queue/OperationTracker.d.ts.map +1 -1
- package/dist/api/endpoints/campaigns.d.ts.map +1 -1
- package/dist/api/endpoints/index.d.ts +55 -0
- package/dist/api/endpoints/index.d.ts.map +1 -1
- package/dist/api/endpoints/infobip.d.ts +209 -0
- package/dist/api/endpoints/infobip.d.ts.map +1 -0
- package/dist/api/errors/adapter.d.ts +71 -0
- package/dist/api/errors/adapter.d.ts.map +1 -0
- package/dist/api/errors/index.d.ts +3 -15
- package/dist/api/errors/index.d.ts.map +1 -1
- package/dist/api/events/EventManager.d.ts.map +1 -1
- package/dist/api/events/factories/base.d.ts +11 -3
- package/dist/api/events/factories/base.d.ts.map +1 -1
- package/dist/api/events/factories/errors.d.ts +10 -10
- package/dist/api/events/factories/errors.d.ts.map +1 -1
- package/dist/api/events/queue/ConfigUpdateQueueManager.d.ts.map +1 -1
- package/dist/api/events/queue/EventQueueManager.d.ts.map +1 -1
- package/dist/api/headers/headerBuilder.d.ts.map +1 -1
- package/dist/api/hooks/factories/createApiMutation.d.ts +3 -3
- package/dist/api/hooks/factories/createApiMutation.d.ts.map +1 -1
- package/dist/api/hooks/factories/createApiQuery.d.ts +3 -3
- package/dist/api/hooks/factories/createApiQuery.d.ts.map +1 -1
- package/dist/api/hooks/index.d.ts +0 -1
- package/dist/api/hooks/index.d.ts.map +1 -1
- package/dist/api/index.d.ts +1 -1
- package/dist/api/index.d.ts.map +1 -1
- package/dist/api/network/frameworks/express.d.ts.map +1 -1
- package/dist/api/network/frameworks/nestjs/decorators.d.ts +9 -1
- package/dist/api/network/frameworks/nestjs/decorators.d.ts.map +1 -1
- package/dist/api/network/frameworks/nestjs/enrichedHeadersGuard.d.ts.map +1 -1
- package/dist/api/network/frameworks/nestjs/enrichedHeadersInterceptor.d.ts.map +1 -1
- package/dist/api/network/networkConfigurationManager.d.ts.map +1 -1
- package/dist/api/network/status.d.ts +1 -4
- package/dist/api/network/status.d.ts.map +1 -1
- package/dist/api/performance/performanceMonitor.d.ts.map +1 -1
- package/dist/api/polling/index.d.ts +1 -1
- package/dist/api/polling/index.d.ts.map +1 -1
- package/dist/api/polling/strategies.d.ts +1 -5
- package/dist/api/polling/strategies.d.ts.map +1 -1
- package/dist/api/polling/utils.d.ts.map +1 -1
- package/dist/api/pubsub/index.d.ts.map +1 -1
- package/dist/api/pubsub/react.d.ts +6 -10
- package/dist/api/pubsub/react.d.ts.map +1 -1
- package/dist/api/queue/BaseOperationTracker.d.ts.map +1 -1
- package/dist/api/queue/EventQueueManager.d.ts.map +1 -1
- package/dist/api/queue/QueueOrchestrator.d.ts.map +1 -1
- package/dist/api/services/campaigns/GET/useCampaign.d.ts +1 -1
- package/dist/api/services/campaigns/GET/useCampaign.d.ts.map +1 -1
- package/dist/api/services/campaigns/GET/useCampaignParticipants.d.ts +1 -11
- package/dist/api/services/campaigns/GET/useCampaignParticipants.d.ts.map +1 -1
- package/dist/api/services/campaigns/GET/useCampaignStats.d.ts +1 -1
- package/dist/api/services/campaigns/GET/useCampaignStats.d.ts.map +1 -1
- package/dist/api/services/campaigns/GET/useCampaigns.d.ts +1 -1
- package/dist/api/services/campaigns/GET/useCampaigns.d.ts.map +1 -1
- package/dist/api/services/campaigns/PUT/useUpdateCampaign.d.ts +1 -9
- package/dist/api/services/campaigns/PUT/useUpdateCampaign.d.ts.map +1 -1
- package/dist/api/services/index.d.ts +1 -0
- package/dist/api/services/index.d.ts.map +1 -1
- package/dist/api/services/infobip/email/GET/fetchEmailLogs.d.ts +50 -0
- package/dist/api/services/infobip/email/GET/fetchEmailLogs.d.ts.map +1 -0
- package/dist/api/services/infobip/email/GET/fetchEmailReports.d.ts +44 -0
- package/dist/api/services/infobip/email/GET/fetchEmailReports.d.ts.map +1 -0
- package/dist/api/services/infobip/email/GET/fetchScheduledEmailStatuses.d.ts +28 -0
- package/dist/api/services/infobip/email/GET/fetchScheduledEmailStatuses.d.ts.map +1 -0
- package/dist/api/services/infobip/email/GET/fetchScheduledEmails.d.ts +27 -0
- package/dist/api/services/infobip/email/GET/fetchScheduledEmails.d.ts.map +1 -0
- package/dist/api/services/infobip/email/GET/fetchValidations.d.ts +60 -0
- package/dist/api/services/infobip/email/GET/fetchValidations.d.ts.map +1 -0
- package/dist/api/services/infobip/email/GET/index.d.ts +10 -0
- package/dist/api/services/infobip/email/GET/index.d.ts.map +1 -0
- package/dist/api/services/infobip/email/POST/bulkValidateEmails.d.ts +50 -0
- package/dist/api/services/infobip/email/POST/bulkValidateEmails.d.ts.map +1 -0
- package/dist/api/services/infobip/email/POST/index.d.ts +9 -0
- package/dist/api/services/infobip/email/POST/index.d.ts.map +1 -0
- package/dist/api/services/infobip/email/POST/sendAdvancedEmail.d.ts +67 -0
- package/dist/api/services/infobip/email/POST/sendAdvancedEmail.d.ts.map +1 -0
- package/dist/api/services/infobip/email/POST/sendEmail.d.ts +60 -0
- package/dist/api/services/infobip/email/POST/sendEmail.d.ts.map +1 -0
- package/dist/api/services/infobip/email/POST/validateEmail.d.ts +40 -0
- package/dist/api/services/infobip/email/POST/validateEmail.d.ts.map +1 -0
- package/dist/api/services/infobip/email/PUT/index.d.ts +7 -0
- package/dist/api/services/infobip/email/PUT/index.d.ts.map +1 -0
- package/dist/api/services/infobip/email/PUT/rescheduleEmails.d.ts +29 -0
- package/dist/api/services/infobip/email/PUT/rescheduleEmails.d.ts.map +1 -0
- package/dist/api/services/infobip/email/PUT/updateScheduledEmailStatuses.d.ts +36 -0
- package/dist/api/services/infobip/email/PUT/updateScheduledEmailStatuses.d.ts.map +1 -0
- package/dist/api/services/infobip/email/index.d.ts +8 -0
- package/dist/api/services/infobip/email/index.d.ts.map +1 -0
- package/dist/api/services/infobip/index.d.ts +6 -0
- package/dist/api/services/infobip/index.d.ts.map +1 -0
- package/dist/api/utils/index.d.ts +0 -3
- package/dist/api/utils/index.d.ts.map +1 -1
- package/dist/index.cjs +1130 -1395
- package/dist/index.cjs.map +1 -1
- package/dist/index.mjs +1079 -1349
- package/dist/index.mjs.map +1 -1
- package/package.json +7 -5
- package/dist/api/errors/ApiPackageError.d.ts +0 -101
- package/dist/api/errors/ApiPackageError.d.ts.map +0 -1
- package/dist/api/errors/definitions.d.ts +0 -24
- package/dist/api/errors/definitions.d.ts.map +0 -1
- package/dist/api/errors/error-codes.d.ts +0 -116
- package/dist/api/errors/error-codes.d.ts.map +0 -1
- package/dist/api/errors/error-events.d.ts +0 -63
- package/dist/api/errors/error-events.d.ts.map +0 -1
- package/dist/api/errors/types-constants.d.ts +0 -64
- package/dist/api/errors/types-constants.d.ts.map +0 -1
- package/dist/api/hooks/types.d.ts +0 -82
- package/dist/api/hooks/types.d.ts.map +0 -1
- package/dist/api/utils/generation/correlation-id.d.ts +0 -206
- package/dist/api/utils/generation/correlation-id.d.ts.map +0 -1
- package/dist/api/utils/generation/id-generator.d.ts +0 -133
- package/dist/api/utils/generation/id-generator.d.ts.map +0 -1
- package/dist/api/utils/generation/request-id.d.ts +0 -106
- package/dist/api/utils/generation/request-id.d.ts.map +0 -1
package/dist/index.cjs
CHANGED
|
@@ -1,9 +1,12 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
4
|
-
var types = require('@plyaz/types');
|
|
5
|
-
var api = require('@plyaz/types/api');
|
|
3
|
+
var errors$1 = require('@plyaz/errors');
|
|
6
4
|
var fetchff = require('fetchff');
|
|
5
|
+
var api = require('@plyaz/types/api');
|
|
6
|
+
var logger$1 = require('@plyaz/logger');
|
|
7
|
+
var types = require('@plyaz/types');
|
|
8
|
+
var config = require('@plyaz/config');
|
|
9
|
+
var errors = require('@plyaz/types/errors');
|
|
7
10
|
var async_hooks = require('async_hooks');
|
|
8
11
|
var common = require('@nestjs/common');
|
|
9
12
|
var rxjs = require('rxjs');
|
|
@@ -1007,302 +1010,6 @@ function applyPollingStrategy(strategy) {
|
|
|
1007
1010
|
return strategy;
|
|
1008
1011
|
}
|
|
1009
1012
|
__name(applyPollingStrategy, "applyPollingStrategy");
|
|
1010
|
-
var ERROR_DEFINITIONS = {
|
|
1011
|
-
// Authentication
|
|
1012
|
-
[api.API_ERROR_CODES.AUTH_UNAUTHORIZED]: {
|
|
1013
|
-
code: api.API_ERROR_CODES.AUTH_UNAUTHORIZED,
|
|
1014
|
-
status: config.HTTP_STATUS.UNAUTHORIZED,
|
|
1015
|
-
category: types.ERROR_CATEGORY.Authentication
|
|
1016
|
-
},
|
|
1017
|
-
[api.API_ERROR_CODES.AUTH_FORBIDDEN]: {
|
|
1018
|
-
code: api.API_ERROR_CODES.AUTH_FORBIDDEN,
|
|
1019
|
-
status: config.HTTP_STATUS.FORBIDDEN,
|
|
1020
|
-
category: types.ERROR_CATEGORY.Authorization
|
|
1021
|
-
},
|
|
1022
|
-
[api.API_ERROR_CODES.AUTH_TOKEN_EXPIRED]: {
|
|
1023
|
-
code: api.API_ERROR_CODES.AUTH_TOKEN_EXPIRED,
|
|
1024
|
-
status: config.HTTP_STATUS.UNAUTHORIZED,
|
|
1025
|
-
category: types.ERROR_CATEGORY.Authentication
|
|
1026
|
-
},
|
|
1027
|
-
[api.API_ERROR_CODES.AUTH_INVALID_CREDENTIALS]: {
|
|
1028
|
-
code: api.API_ERROR_CODES.AUTH_INVALID_CREDENTIALS,
|
|
1029
|
-
status: config.HTTP_STATUS.UNAUTHORIZED,
|
|
1030
|
-
category: types.ERROR_CATEGORY.Authentication
|
|
1031
|
-
},
|
|
1032
|
-
// Rate Limiting
|
|
1033
|
-
[api.API_ERROR_CODES.RATE_LIMIT_EXCEEDED]: {
|
|
1034
|
-
code: api.API_ERROR_CODES.RATE_LIMIT_EXCEEDED,
|
|
1035
|
-
status: config.HTTP_STATUS.TOO_MANY_REQUESTS,
|
|
1036
|
-
category: types.ERROR_CATEGORY.RateLimit
|
|
1037
|
-
},
|
|
1038
|
-
// Resource Errors
|
|
1039
|
-
[api.API_ERROR_CODES.RESOURCE_NOT_FOUND]: {
|
|
1040
|
-
code: api.API_ERROR_CODES.RESOURCE_NOT_FOUND,
|
|
1041
|
-
status: config.HTTP_STATUS.NOT_FOUND,
|
|
1042
|
-
category: types.ERROR_CATEGORY.NotFound
|
|
1043
|
-
},
|
|
1044
|
-
// System Errors
|
|
1045
|
-
[api.API_ERROR_CODES.INTERNAL_SERVER_ERROR]: {
|
|
1046
|
-
code: api.API_ERROR_CODES.INTERNAL_SERVER_ERROR,
|
|
1047
|
-
status: config.HTTP_STATUS.INTERNAL_SERVER_ERROR,
|
|
1048
|
-
category: types.ERROR_CATEGORY.Server
|
|
1049
|
-
},
|
|
1050
|
-
[api.API_ERROR_CODES.SERVICE_UNAVAILABLE]: {
|
|
1051
|
-
code: api.API_ERROR_CODES.SERVICE_UNAVAILABLE,
|
|
1052
|
-
status: config.HTTP_STATUS.SERVICE_UNAVAILABLE,
|
|
1053
|
-
category: types.ERROR_CATEGORY.Server
|
|
1054
|
-
},
|
|
1055
|
-
[api.API_ERROR_CODES.EXTERNAL_SERVICE_ERROR]: {
|
|
1056
|
-
code: api.API_ERROR_CODES.EXTERNAL_SERVICE_ERROR,
|
|
1057
|
-
status: config.HTTP_STATUS.BAD_GATEWAY,
|
|
1058
|
-
category: types.ERROR_CATEGORY.ExternalService
|
|
1059
|
-
},
|
|
1060
|
-
// Validation
|
|
1061
|
-
[api.API_ERROR_CODES.VALIDATION_ERROR]: {
|
|
1062
|
-
code: api.API_ERROR_CODES.VALIDATION_ERROR,
|
|
1063
|
-
status: config.HTTP_STATUS.BAD_REQUEST,
|
|
1064
|
-
category: types.ERROR_CATEGORY.Validation
|
|
1065
|
-
},
|
|
1066
|
-
[api.API_ERROR_CODES.VALIDATION_FAILED]: {
|
|
1067
|
-
code: api.API_ERROR_CODES.VALIDATION_FAILED,
|
|
1068
|
-
status: config.HTTP_STATUS.BAD_REQUEST,
|
|
1069
|
-
category: types.ERROR_CATEGORY.Validation
|
|
1070
|
-
},
|
|
1071
|
-
[api.API_ERROR_CODES.REQUIRED_FIELD_MISSING]: {
|
|
1072
|
-
code: api.API_ERROR_CODES.REQUIRED_FIELD_MISSING,
|
|
1073
|
-
status: config.HTTP_STATUS.BAD_REQUEST,
|
|
1074
|
-
category: types.ERROR_CATEGORY.Validation,
|
|
1075
|
-
fieldsLeft: ["field"]
|
|
1076
|
-
},
|
|
1077
|
-
[api.API_ERROR_CODES.INVALID_FORMAT]: {
|
|
1078
|
-
code: api.API_ERROR_CODES.INVALID_FORMAT,
|
|
1079
|
-
status: config.HTTP_STATUS.BAD_REQUEST,
|
|
1080
|
-
category: types.ERROR_CATEGORY.Validation
|
|
1081
|
-
},
|
|
1082
|
-
[api.API_ERROR_CODES.STRING_TOO_SHORT]: {
|
|
1083
|
-
code: api.API_ERROR_CODES.STRING_TOO_SHORT,
|
|
1084
|
-
status: config.HTTP_STATUS.BAD_REQUEST,
|
|
1085
|
-
category: types.ERROR_CATEGORY.Validation,
|
|
1086
|
-
fieldsLeft: ["field", "minLength"]
|
|
1087
|
-
},
|
|
1088
|
-
[api.API_ERROR_CODES.STRING_TOO_LONG]: {
|
|
1089
|
-
code: api.API_ERROR_CODES.STRING_TOO_LONG,
|
|
1090
|
-
status: config.HTTP_STATUS.BAD_REQUEST,
|
|
1091
|
-
category: types.ERROR_CATEGORY.Validation,
|
|
1092
|
-
fieldsLeft: ["field", "maxLength"]
|
|
1093
|
-
},
|
|
1094
|
-
// Request Errors
|
|
1095
|
-
[api.API_ERROR_CODES.REQUEST_TIMEOUT]: {
|
|
1096
|
-
code: api.API_ERROR_CODES.REQUEST_TIMEOUT,
|
|
1097
|
-
status: config.HTTP_STATUS.REQUEST_TIMEOUT,
|
|
1098
|
-
category: types.ERROR_CATEGORY.Timeout
|
|
1099
|
-
},
|
|
1100
|
-
[api.API_ERROR_CODES.REQUEST_ABORTED]: {
|
|
1101
|
-
code: api.API_ERROR_CODES.REQUEST_ABORTED,
|
|
1102
|
-
status: 0,
|
|
1103
|
-
// No HTTP status for aborted
|
|
1104
|
-
category: types.ERROR_CATEGORY.Client
|
|
1105
|
-
},
|
|
1106
|
-
[api.API_ERROR_CODES.REQUEST_INVALID_PARAMS]: {
|
|
1107
|
-
code: api.API_ERROR_CODES.REQUEST_INVALID_PARAMS,
|
|
1108
|
-
status: config.HTTP_STATUS.BAD_REQUEST,
|
|
1109
|
-
category: types.ERROR_CATEGORY.Client
|
|
1110
|
-
},
|
|
1111
|
-
[api.API_ERROR_CODES.REQUEST_PREPARATION_FAILED]: {
|
|
1112
|
-
code: api.API_ERROR_CODES.REQUEST_PREPARATION_FAILED,
|
|
1113
|
-
status: config.HTTP_STATUS.BAD_REQUEST,
|
|
1114
|
-
category: types.ERROR_CATEGORY.Client
|
|
1115
|
-
},
|
|
1116
|
-
// Response Errors
|
|
1117
|
-
[api.API_ERROR_CODES.RESPONSE_INVALID_FORMAT]: {
|
|
1118
|
-
code: api.API_ERROR_CODES.RESPONSE_INVALID_FORMAT,
|
|
1119
|
-
status: config.HTTP_STATUS.UNPROCESSABLE_ENTITY,
|
|
1120
|
-
category: types.ERROR_CATEGORY.Client
|
|
1121
|
-
},
|
|
1122
|
-
[api.API_ERROR_CODES.RESPONSE_PARSING_FAILED]: {
|
|
1123
|
-
code: api.API_ERROR_CODES.RESPONSE_PARSING_FAILED,
|
|
1124
|
-
status: config.HTTP_STATUS.UNPROCESSABLE_ENTITY,
|
|
1125
|
-
category: types.ERROR_CATEGORY.Client
|
|
1126
|
-
},
|
|
1127
|
-
// Network
|
|
1128
|
-
[api.API_ERROR_CODES.NETWORK_ERROR]: {
|
|
1129
|
-
code: api.API_ERROR_CODES.NETWORK_ERROR,
|
|
1130
|
-
status: config.HTTP_STATUS.BAD_GATEWAY,
|
|
1131
|
-
category: types.ERROR_CATEGORY.Network
|
|
1132
|
-
},
|
|
1133
|
-
[api.API_ERROR_CODES.NETWORK_TIMEOUT]: {
|
|
1134
|
-
code: api.API_ERROR_CODES.NETWORK_TIMEOUT,
|
|
1135
|
-
status: config.HTTP_STATUS.GATEWAY_TIMEOUT,
|
|
1136
|
-
category: types.ERROR_CATEGORY.Timeout
|
|
1137
|
-
},
|
|
1138
|
-
[api.API_ERROR_CODES.NETWORK_CONNECTION_FAILED]: {
|
|
1139
|
-
code: api.API_ERROR_CODES.NETWORK_CONNECTION_FAILED,
|
|
1140
|
-
status: 0,
|
|
1141
|
-
// No HTTP status for connection failure
|
|
1142
|
-
category: types.ERROR_CATEGORY.Network
|
|
1143
|
-
},
|
|
1144
|
-
[api.API_ERROR_CODES.NETWORK_OFFLINE]: {
|
|
1145
|
-
code: api.API_ERROR_CODES.NETWORK_OFFLINE,
|
|
1146
|
-
status: 0,
|
|
1147
|
-
// No HTTP status for offline
|
|
1148
|
-
category: types.ERROR_CATEGORY.Network
|
|
1149
|
-
},
|
|
1150
|
-
[api.API_ERROR_CODES.NETWORK_DNS_FAILED]: {
|
|
1151
|
-
code: api.API_ERROR_CODES.NETWORK_DNS_FAILED,
|
|
1152
|
-
status: 0,
|
|
1153
|
-
// No HTTP status for DNS failure
|
|
1154
|
-
category: types.ERROR_CATEGORY.Network
|
|
1155
|
-
},
|
|
1156
|
-
// Server
|
|
1157
|
-
[api.API_ERROR_CODES.SERVER_ERROR]: {
|
|
1158
|
-
code: api.API_ERROR_CODES.SERVER_ERROR,
|
|
1159
|
-
status: config.HTTP_STATUS.INTERNAL_SERVER_ERROR,
|
|
1160
|
-
category: types.ERROR_CATEGORY.Server
|
|
1161
|
-
},
|
|
1162
|
-
// Client
|
|
1163
|
-
[api.API_ERROR_CODES.CLIENT_ERROR]: {
|
|
1164
|
-
code: api.API_ERROR_CODES.CLIENT_ERROR,
|
|
1165
|
-
status: config.HTTP_STATUS.BAD_REQUEST,
|
|
1166
|
-
category: types.ERROR_CATEGORY.Client
|
|
1167
|
-
},
|
|
1168
|
-
[api.API_ERROR_CODES.CLIENT_CANCELLED]: {
|
|
1169
|
-
code: api.API_ERROR_CODES.CLIENT_CANCELLED,
|
|
1170
|
-
status: 0,
|
|
1171
|
-
// No HTTP status for cancelled
|
|
1172
|
-
category: types.ERROR_CATEGORY.Client
|
|
1173
|
-
},
|
|
1174
|
-
[api.API_ERROR_CODES.CLIENT_INITIALIZATION_FAILED]: {
|
|
1175
|
-
code: api.API_ERROR_CODES.CLIENT_INITIALIZATION_FAILED,
|
|
1176
|
-
status: 0,
|
|
1177
|
-
// No HTTP status for initialization failure
|
|
1178
|
-
category: types.ERROR_CATEGORY.Client
|
|
1179
|
-
},
|
|
1180
|
-
[api.API_ERROR_CODES.CLIENT_INVALID_CONFIG]: {
|
|
1181
|
-
code: api.API_ERROR_CODES.CLIENT_INVALID_CONFIG,
|
|
1182
|
-
status: 0,
|
|
1183
|
-
// No HTTP status for configuration errors
|
|
1184
|
-
category: types.ERROR_CATEGORY.Client
|
|
1185
|
-
},
|
|
1186
|
-
[api.API_ERROR_CODES.CLIENT_MISSING_BASE_URL]: {
|
|
1187
|
-
code: api.API_ERROR_CODES.CLIENT_MISSING_BASE_URL,
|
|
1188
|
-
status: 0,
|
|
1189
|
-
// No HTTP status for configuration errors
|
|
1190
|
-
category: types.ERROR_CATEGORY.Client
|
|
1191
|
-
},
|
|
1192
|
-
[api.API_ERROR_CODES.CONFIG_VALIDATION_FAILED]: {
|
|
1193
|
-
code: api.API_ERROR_CODES.CONFIG_VALIDATION_FAILED,
|
|
1194
|
-
status: config.HTTP_STATUS.BAD_REQUEST,
|
|
1195
|
-
category: types.ERROR_CATEGORY.Validation
|
|
1196
|
-
},
|
|
1197
|
-
[api.API_ERROR_CODES.HEADER_PROCESSING_FAILED]: {
|
|
1198
|
-
code: api.API_ERROR_CODES.HEADER_PROCESSING_FAILED,
|
|
1199
|
-
status: config.HTTP_STATUS.INTERNAL_SERVER_ERROR,
|
|
1200
|
-
category: types.ERROR_CATEGORY.Headers
|
|
1201
|
-
},
|
|
1202
|
-
[api.API_ERROR_CODES.NETWORK_OVERRIDE_FAILED]: {
|
|
1203
|
-
code: api.API_ERROR_CODES.NETWORK_OVERRIDE_FAILED,
|
|
1204
|
-
status: config.HTTP_STATUS.INTERNAL_SERVER_ERROR,
|
|
1205
|
-
category: types.ERROR_CATEGORY.Network
|
|
1206
|
-
},
|
|
1207
|
-
// Headers
|
|
1208
|
-
[api.API_ERROR_CODES.HEADERS_ENRICHMENT_FAILED]: {
|
|
1209
|
-
code: api.API_ERROR_CODES.HEADERS_ENRICHMENT_FAILED,
|
|
1210
|
-
status: config.HTTP_STATUS.BAD_REQUEST,
|
|
1211
|
-
category: types.ERROR_CATEGORY.Headers
|
|
1212
|
-
},
|
|
1213
|
-
[api.API_ERROR_CODES.HEADERS_VALIDATION_FAILED]: {
|
|
1214
|
-
code: api.API_ERROR_CODES.HEADERS_VALIDATION_FAILED,
|
|
1215
|
-
status: config.HTTP_STATUS.BAD_REQUEST,
|
|
1216
|
-
category: types.ERROR_CATEGORY.Headers
|
|
1217
|
-
},
|
|
1218
|
-
[api.API_ERROR_CODES.HEADERS_MERGE_CONFLICT]: {
|
|
1219
|
-
code: api.API_ERROR_CODES.HEADERS_MERGE_CONFLICT,
|
|
1220
|
-
status: config.HTTP_STATUS.CONFLICT,
|
|
1221
|
-
category: types.ERROR_CATEGORY.Headers
|
|
1222
|
-
},
|
|
1223
|
-
// Cache
|
|
1224
|
-
[api.API_ERROR_CODES.CACHE_STORAGE_FAILED]: {
|
|
1225
|
-
code: api.API_ERROR_CODES.CACHE_STORAGE_FAILED,
|
|
1226
|
-
status: 0,
|
|
1227
|
-
// No HTTP status for cache failures
|
|
1228
|
-
category: types.ERROR_CATEGORY.Cache
|
|
1229
|
-
},
|
|
1230
|
-
[api.API_ERROR_CODES.CACHE_RETRIEVAL_FAILED]: {
|
|
1231
|
-
code: api.API_ERROR_CODES.CACHE_RETRIEVAL_FAILED,
|
|
1232
|
-
status: 0,
|
|
1233
|
-
// No HTTP status for cache failures
|
|
1234
|
-
category: types.ERROR_CATEGORY.Cache
|
|
1235
|
-
},
|
|
1236
|
-
[api.API_ERROR_CODES.CACHE_INVALIDATION_FAILED]: {
|
|
1237
|
-
code: api.API_ERROR_CODES.CACHE_INVALIDATION_FAILED,
|
|
1238
|
-
status: 0,
|
|
1239
|
-
// No HTTP status for cache failures
|
|
1240
|
-
category: types.ERROR_CATEGORY.Cache
|
|
1241
|
-
},
|
|
1242
|
-
// Retry
|
|
1243
|
-
[api.API_ERROR_CODES.RETRY_EXHAUSTED]: {
|
|
1244
|
-
code: api.API_ERROR_CODES.RETRY_EXHAUSTED,
|
|
1245
|
-
status: config.HTTP_STATUS.SERVICE_UNAVAILABLE,
|
|
1246
|
-
category: types.ERROR_CATEGORY.Retry
|
|
1247
|
-
},
|
|
1248
|
-
[api.API_ERROR_CODES.RETRY_STRATEGY_INVALID]: {
|
|
1249
|
-
code: api.API_ERROR_CODES.RETRY_STRATEGY_INVALID,
|
|
1250
|
-
status: 0,
|
|
1251
|
-
// No HTTP status for strategy errors
|
|
1252
|
-
category: types.ERROR_CATEGORY.Retry
|
|
1253
|
-
},
|
|
1254
|
-
// Strategy
|
|
1255
|
-
[api.API_ERROR_CODES.STRATEGY_INVALID]: {
|
|
1256
|
-
code: api.API_ERROR_CODES.STRATEGY_INVALID,
|
|
1257
|
-
status: 0,
|
|
1258
|
-
// No HTTP status for strategy errors
|
|
1259
|
-
category: types.ERROR_CATEGORY.Strategy
|
|
1260
|
-
},
|
|
1261
|
-
[api.API_ERROR_CODES.STRATEGY_CONFLICT]: {
|
|
1262
|
-
code: api.API_ERROR_CODES.STRATEGY_CONFLICT,
|
|
1263
|
-
status: config.HTTP_STATUS.CONFLICT,
|
|
1264
|
-
category: types.ERROR_CATEGORY.Strategy
|
|
1265
|
-
},
|
|
1266
|
-
// Regional
|
|
1267
|
-
[api.API_ERROR_CODES.REGIONAL_PRESET_NOT_FOUND]: {
|
|
1268
|
-
code: api.API_ERROR_CODES.REGIONAL_PRESET_NOT_FOUND,
|
|
1269
|
-
status: 0,
|
|
1270
|
-
// No HTTP status for regional preset errors
|
|
1271
|
-
category: types.ERROR_CATEGORY.Regional
|
|
1272
|
-
},
|
|
1273
|
-
[api.API_ERROR_CODES.REGION_DETECTION_FAILED]: {
|
|
1274
|
-
code: api.API_ERROR_CODES.REGION_DETECTION_FAILED,
|
|
1275
|
-
status: config.HTTP_STATUS.INTERNAL_SERVER_ERROR,
|
|
1276
|
-
category: types.ERROR_CATEGORY.Regional
|
|
1277
|
-
},
|
|
1278
|
-
// Timeout
|
|
1279
|
-
[api.API_ERROR_CODES.TIMEOUT]: {
|
|
1280
|
-
code: api.API_ERROR_CODES.TIMEOUT,
|
|
1281
|
-
status: config.HTTP_STATUS.REQUEST_TIMEOUT,
|
|
1282
|
-
category: types.ERROR_CATEGORY.Timeout
|
|
1283
|
-
},
|
|
1284
|
-
// Unknown
|
|
1285
|
-
[api.API_ERROR_CODES.UNKNOWN_ERROR]: {
|
|
1286
|
-
code: api.API_ERROR_CODES.UNKNOWN_ERROR,
|
|
1287
|
-
status: config.HTTP_STATUS.INTERNAL_SERVER_ERROR,
|
|
1288
|
-
category: types.ERROR_CATEGORY.Unknown
|
|
1289
|
-
}
|
|
1290
|
-
};
|
|
1291
|
-
function getErrorDefinition(errorCode) {
|
|
1292
|
-
return ERROR_DEFINITIONS[errorCode];
|
|
1293
|
-
}
|
|
1294
|
-
__name(getErrorDefinition, "getErrorDefinition");
|
|
1295
|
-
function getErrorCodeByStatus(status) {
|
|
1296
|
-
const entry = Object.entries(ERROR_DEFINITIONS).find(
|
|
1297
|
-
([, definition]) => definition.status === status
|
|
1298
|
-
);
|
|
1299
|
-
return entry?.[0];
|
|
1300
|
-
}
|
|
1301
|
-
__name(getErrorCodeByStatus, "getErrorCodeByStatus");
|
|
1302
|
-
function getErrorCategory(errorCode) {
|
|
1303
|
-
return ERROR_DEFINITIONS[errorCode]?.category ?? types.ERROR_CATEGORY.Unknown;
|
|
1304
|
-
}
|
|
1305
|
-
__name(getErrorCategory, "getErrorCategory");
|
|
1306
1013
|
var BINARY_HEAP = {
|
|
1307
1014
|
/** Number of children per node in binary heap */
|
|
1308
1015
|
CHILDREN_PER_NODE: 2,
|
|
@@ -2029,8 +1736,6 @@ function removeCircularReferences(obj) {
|
|
|
2029
1736
|
}
|
|
2030
1737
|
}
|
|
2031
1738
|
__name(removeCircularReferences, "removeCircularReferences");
|
|
2032
|
-
|
|
2033
|
-
// src/api/utils/time.ts
|
|
2034
1739
|
var MS_IN_SECOND = 1e3;
|
|
2035
1740
|
var SECONDS_PER_MINUTE = 60;
|
|
2036
1741
|
var MINUTES_PER_HOUR = 60;
|
|
@@ -2575,13 +2280,13 @@ var BaseEventFactory = class {
|
|
|
2575
2280
|
constructor(namespace, emitter) {
|
|
2576
2281
|
this.namespace = namespace;
|
|
2577
2282
|
this.emitter = emitter;
|
|
2578
|
-
api.
|
|
2283
|
+
api.EVENT_SCOPES_WITH_TEMPORARY.forEach((scope) => {
|
|
2579
2284
|
this.scopedHandlers.set(scope, /* @__PURE__ */ new Map());
|
|
2580
2285
|
this.originalHandlers.set(scope, /* @__PURE__ */ new Map());
|
|
2581
2286
|
});
|
|
2582
2287
|
this.trackFactoryOperation("factory_initialized", {
|
|
2583
2288
|
namespace: this.namespace,
|
|
2584
|
-
scopesInitialized: api.
|
|
2289
|
+
scopesInitialized: api.EVENT_SCOPES_WITH_TEMPORARY.length,
|
|
2585
2290
|
emitterType: "EventEmitter"
|
|
2586
2291
|
});
|
|
2587
2292
|
}
|
|
@@ -2733,16 +2438,14 @@ var BaseEventFactory = class {
|
|
|
2733
2438
|
* - Non-scoped wildcards for backwards compatibility (e.g., headers:*)
|
|
2734
2439
|
*/
|
|
2735
2440
|
emitAcrossScopes(eventType, eventName, data, scopes) {
|
|
2736
|
-
const targetScopes = scopes ?? api.
|
|
2737
|
-
const
|
|
2738
|
-
(s) => s === "temporary" ? "request" : s
|
|
2739
|
-
);
|
|
2740
|
-
const scopeOrder = [...api.EVENT_SCOPES];
|
|
2441
|
+
const targetScopes = scopes ?? api.EVENT_SCOPES_WITH_TEMPORARY;
|
|
2442
|
+
const scopeOrder = [...api.EVENT_SCOPES_WITH_TEMPORARY];
|
|
2741
2443
|
for (const scope of scopeOrder) {
|
|
2742
|
-
if (
|
|
2743
|
-
const
|
|
2444
|
+
if (targetScopes.includes(scope)) {
|
|
2445
|
+
const emitScope = scope === "temporary" ? "request" : scope;
|
|
2446
|
+
const namespacedEvent = `${emitScope}:${eventType}:${eventName}`;
|
|
2744
2447
|
this.emitter.emit(namespacedEvent, data);
|
|
2745
|
-
const wildcardEvent = `${
|
|
2448
|
+
const wildcardEvent = `${emitScope}:${eventType}:*`;
|
|
2746
2449
|
const wildcardData2 = typeof data === "object" && data !== null ? { ...data, originalEvent: eventName } : { data, originalEvent: eventName };
|
|
2747
2450
|
this.emitter.emit(wildcardEvent, wildcardData2);
|
|
2748
2451
|
}
|
|
@@ -2940,6 +2643,52 @@ var BaseEventFactory = class {
|
|
|
2940
2643
|
});
|
|
2941
2644
|
return this.createHandlerUnsubscribe(scope, eventName, handler, unsubscribes);
|
|
2942
2645
|
}
|
|
2646
|
+
/**
|
|
2647
|
+
* Remove a specific handler from a scoped event
|
|
2648
|
+
*
|
|
2649
|
+
* @param scope - The scope to remove from ('global', 'config', 'client', 'request')
|
|
2650
|
+
* @param eventName - The event name (e.g., 'validation', 'network', '*')
|
|
2651
|
+
* @param handler - The specific handler to remove (should be the original handler, not wrapped)
|
|
2652
|
+
*/
|
|
2653
|
+
removeScopedHandler(scope, eventName, handler) {
|
|
2654
|
+
const startTime = Date.now();
|
|
2655
|
+
const scopeMap = this.scopedHandlers.get(scope);
|
|
2656
|
+
const originalMap = this.originalHandlers.get(scope);
|
|
2657
|
+
if (!scopeMap || !originalMap) {
|
|
2658
|
+
return;
|
|
2659
|
+
}
|
|
2660
|
+
const handlers = scopeMap.get(eventName);
|
|
2661
|
+
const originals = originalMap.get(eventName);
|
|
2662
|
+
if (!handlers || !originals) {
|
|
2663
|
+
return;
|
|
2664
|
+
}
|
|
2665
|
+
const handlerAsUnknown = handler;
|
|
2666
|
+
const originalIndex = originals.indexOf(handlerAsUnknown);
|
|
2667
|
+
if (originalIndex === -1) {
|
|
2668
|
+
return;
|
|
2669
|
+
}
|
|
2670
|
+
const beforeCount = handlers.length;
|
|
2671
|
+
const wrappedHandler = handlers[originalIndex];
|
|
2672
|
+
handlers.splice(originalIndex, 1);
|
|
2673
|
+
originals.splice(originalIndex, 1);
|
|
2674
|
+
const scopedEventKey = `${scope}:${this.namespace}:${eventName}`;
|
|
2675
|
+
this.emitter.off(scopedEventKey, wrappedHandler);
|
|
2676
|
+
if (handlers.length === 0) {
|
|
2677
|
+
scopeMap.delete(eventName);
|
|
2678
|
+
originalMap.delete(eventName);
|
|
2679
|
+
} else {
|
|
2680
|
+
scopeMap.set(eventName, handlers);
|
|
2681
|
+
originalMap.set(eventName, originals);
|
|
2682
|
+
}
|
|
2683
|
+
this.trackFactoryOperation("specific_handler_removed", {
|
|
2684
|
+
scope,
|
|
2685
|
+
eventName,
|
|
2686
|
+
beforeHandlerCount: beforeCount,
|
|
2687
|
+
afterHandlerCount: handlers.length,
|
|
2688
|
+
eventDeleted: handlers.length === 0,
|
|
2689
|
+
removalTime: Date.now() - startTime
|
|
2690
|
+
});
|
|
2691
|
+
}
|
|
2943
2692
|
/**
|
|
2944
2693
|
* Remove all listeners for a scoped event
|
|
2945
2694
|
*
|
|
@@ -4688,13 +4437,13 @@ var HANDLER_SCOPES = {
|
|
|
4688
4437
|
REQUEST: "request"
|
|
4689
4438
|
// Request-level handlers (highest priority, per-request)
|
|
4690
4439
|
};
|
|
4691
|
-
var
|
|
4440
|
+
var EVENT_SCOPES = [
|
|
4692
4441
|
HANDLER_SCOPES.GLOBAL,
|
|
4693
4442
|
HANDLER_SCOPES.CONFIG,
|
|
4694
4443
|
HANDLER_SCOPES.CLIENT,
|
|
4695
4444
|
HANDLER_SCOPES.REQUEST
|
|
4696
4445
|
];
|
|
4697
|
-
var
|
|
4446
|
+
var EVENT_SCOPES_WITH_TEMPORARY2 = [...EVENT_SCOPES, "temporary"];
|
|
4698
4447
|
function createHandlerNamespace(eventType, scope) {
|
|
4699
4448
|
return `${HANDLER_SCOPES[scope]}:${eventType}`;
|
|
4700
4449
|
}
|
|
@@ -4886,6 +4635,7 @@ __name(getHandlerNamespaceForEvent, "getHandlerNamespaceForEvent");
|
|
|
4886
4635
|
|
|
4887
4636
|
// src/api/events/EventManager.ts
|
|
4888
4637
|
var SLOW_REQUEST_THRESHOLD_MS = 5e3;
|
|
4638
|
+
var logger = new logger$1.ApiLogger({ service: types.LOGGER_SERVICES.EVENT_MANAGER, transport: "console" });
|
|
4889
4639
|
var EventManager = class _EventManager extends BaseEventFactory {
|
|
4890
4640
|
static {
|
|
4891
4641
|
__name(this, "EventManager");
|
|
@@ -4903,7 +4653,7 @@ var EventManager = class _EventManager extends BaseEventFactory {
|
|
|
4903
4653
|
// DEFAULT: ALL scopes are active ['global', 'config', 'client', 'request']
|
|
4904
4654
|
// This means events are emitted to handlers at all scope levels by default
|
|
4905
4655
|
// Can be restricted by calling setEventScopes() with specific scopes
|
|
4906
|
-
eventScopes = [...
|
|
4656
|
+
eventScopes = [...EVENT_SCOPES];
|
|
4907
4657
|
currentEventScopes = this.eventScopes;
|
|
4908
4658
|
// Alias for compatibility
|
|
4909
4659
|
constructor() {
|
|
@@ -5079,9 +4829,10 @@ var EventManager = class _EventManager extends BaseEventFactory {
|
|
|
5079
4829
|
*/
|
|
5080
4830
|
setupDebugHandlers() {
|
|
5081
4831
|
this.on(DEBUG_EVENTS2.CONFIG_CONFLICT, (event) => {
|
|
5082
|
-
|
|
5083
|
-
|
|
5084
|
-
|
|
4832
|
+
logger.debug("Config conflict detected", {
|
|
4833
|
+
conflictType: event.type,
|
|
4834
|
+
source: event.source
|
|
4835
|
+
});
|
|
5085
4836
|
});
|
|
5086
4837
|
}
|
|
5087
4838
|
/**
|
|
@@ -5375,6 +5126,7 @@ var eventManager = {
|
|
|
5375
5126
|
getEventStats: /* @__PURE__ */ __name(() => getEventManager().getEventStats(), "getEventStats"),
|
|
5376
5127
|
getActiveScopes: /* @__PURE__ */ __name(() => getEventManager().getActiveScopes(), "getActiveScopes")
|
|
5377
5128
|
};
|
|
5129
|
+
var logger2 = new logger$1.ApiLogger({ service: types.LOGGER_SERVICES.EVENT_QUEUE, transport: "console" });
|
|
5378
5130
|
var EventQueueManager = class _EventQueueManager {
|
|
5379
5131
|
static {
|
|
5380
5132
|
__name(this, "EventQueueManager");
|
|
@@ -5476,7 +5228,11 @@ var EventQueueManager = class _EventQueueManager {
|
|
|
5476
5228
|
}
|
|
5477
5229
|
}
|
|
5478
5230
|
if (config.isDev) {
|
|
5479
|
-
|
|
5231
|
+
logger2.warn("Event processing failed", {
|
|
5232
|
+
eventType: event.eventType,
|
|
5233
|
+
eventName: event.eventName,
|
|
5234
|
+
error: error instanceof Error ? error.message : String(error)
|
|
5235
|
+
});
|
|
5480
5236
|
}
|
|
5481
5237
|
}
|
|
5482
5238
|
}
|
|
@@ -7515,6 +7271,7 @@ function colorProgressBar(value, max2, width = DEFAULT_PROGRESS_BAR_WIDTH) {
|
|
|
7515
7271
|
return `[${bar}] ${percentText}`;
|
|
7516
7272
|
}
|
|
7517
7273
|
__name(colorProgressBar, "colorProgressBar");
|
|
7274
|
+
var logger3 = new logger$1.ApiLogger({ service: types.LOGGER_SERVICES.DEBUG_REPORT, transport: "console" });
|
|
7518
7275
|
var DEBUG_REPORT_CONSTANTS = {
|
|
7519
7276
|
// Byte sizes
|
|
7520
7277
|
BYTES_PER_KB: 1024,
|
|
@@ -9260,24 +9017,26 @@ function logNetworkOverride(params) {
|
|
|
9260
9017
|
networkQuality,
|
|
9261
9018
|
duration
|
|
9262
9019
|
} = params;
|
|
9263
|
-
|
|
9264
|
-
|
|
9265
|
-
|
|
9266
|
-
|
|
9020
|
+
logger3.group(`🔧 Network Config Override: ${property}`);
|
|
9021
|
+
logger3.info("Value changed", {
|
|
9022
|
+
from: originalValue,
|
|
9023
|
+
to: overrideValue
|
|
9024
|
+
});
|
|
9025
|
+
logger3.info("Source", { source });
|
|
9026
|
+
logger3.info("Reason", { reason });
|
|
9267
9027
|
if (networkQuality) {
|
|
9268
|
-
|
|
9028
|
+
logger3.info("Network Quality", { quality: networkQuality.toLowerCase() });
|
|
9269
9029
|
}
|
|
9270
9030
|
if (networkInfo?.saveData) {
|
|
9271
|
-
|
|
9031
|
+
logger3.info("Save-Data enabled");
|
|
9272
9032
|
}
|
|
9273
9033
|
if (duration) {
|
|
9274
|
-
|
|
9034
|
+
logger3.info("Duration", { ms: duration });
|
|
9275
9035
|
}
|
|
9276
|
-
|
|
9036
|
+
logger3.groupEnd();
|
|
9277
9037
|
}
|
|
9278
9038
|
__name(logNetworkOverride, "logNetworkOverride");
|
|
9279
|
-
|
|
9280
|
-
// src/api/debugger/UnifiedDebugger.ts
|
|
9039
|
+
var logger4 = new logger$1.ApiLogger({ service: types.LOGGER_SERVICES.UNIFIED_DEBUGGER, transport: "console" });
|
|
9281
9040
|
var DEBUGGER_CONSTANTS = {
|
|
9282
9041
|
// Array/Division constants
|
|
9283
9042
|
HALF_DIVISOR: 2,
|
|
@@ -9463,7 +9222,10 @@ var UnifiedDebugger = class _UnifiedDebugger {
|
|
|
9463
9222
|
}
|
|
9464
9223
|
}
|
|
9465
9224
|
);
|
|
9466
|
-
|
|
9225
|
+
logger4.warn("⚠️ Debugger tracking failed", {
|
|
9226
|
+
error: apiError.message,
|
|
9227
|
+
context: apiError.context
|
|
9228
|
+
});
|
|
9467
9229
|
}
|
|
9468
9230
|
/**
|
|
9469
9231
|
* Safe tracking helper that handles errors properly
|
|
@@ -9798,11 +9560,11 @@ var UnifiedDebugger = class _UnifiedDebugger {
|
|
|
9798
9560
|
try {
|
|
9799
9561
|
const presetReport = this.getPresetChangeReport();
|
|
9800
9562
|
if (presetReport) {
|
|
9801
|
-
|
|
9802
|
-
|
|
9563
|
+
logger4.info(presetReport);
|
|
9564
|
+
logger4.info("");
|
|
9803
9565
|
}
|
|
9804
9566
|
const report = await generateComprehensiveReport();
|
|
9805
|
-
|
|
9567
|
+
logger4.info(formatReportForConsole(report));
|
|
9806
9568
|
} catch (err) {
|
|
9807
9569
|
const error = new ApiPackageError(
|
|
9808
9570
|
"Failed to generate debug report",
|
|
@@ -9810,7 +9572,9 @@ var UnifiedDebugger = class _UnifiedDebugger {
|
|
|
9810
9572
|
api.API_ERROR_CODES.DEBUG_TRACKING_FAILED,
|
|
9811
9573
|
{ cause: err }
|
|
9812
9574
|
);
|
|
9813
|
-
|
|
9575
|
+
logger4.error("⚠️ Failed to generate debug report", {
|
|
9576
|
+
error: error.message
|
|
9577
|
+
});
|
|
9814
9578
|
throw error;
|
|
9815
9579
|
}
|
|
9816
9580
|
}
|
|
@@ -10127,11 +9891,11 @@ var UnifiedDebugger = class _UnifiedDebugger {
|
|
|
10127
9891
|
trigger: options.trigger,
|
|
10128
9892
|
timestamp
|
|
10129
9893
|
};
|
|
10130
|
-
if (this.enabled
|
|
10131
|
-
|
|
10132
|
-
|
|
10133
|
-
|
|
10134
|
-
|
|
9894
|
+
if (this.enabled) {
|
|
9895
|
+
logger4.group(`📋 Network preset applied: ${options.preset}`);
|
|
9896
|
+
logger4.info(`Quality: ${options.networkConditions.quality}`);
|
|
9897
|
+
logger4.info(`Trigger: ${options.trigger}`);
|
|
9898
|
+
logger4.groupEnd();
|
|
10135
9899
|
}
|
|
10136
9900
|
}
|
|
10137
9901
|
options.changes.forEach((change) => {
|
|
@@ -10193,8 +9957,8 @@ var UnifiedDebugger = class _UnifiedDebugger {
|
|
|
10193
9957
|
source: "networkPreset",
|
|
10194
9958
|
reason: options.trigger
|
|
10195
9959
|
});
|
|
10196
|
-
if (this.enabled
|
|
10197
|
-
|
|
9960
|
+
if (this.enabled) {
|
|
9961
|
+
logger4.info("🔄 Network config restored", { property });
|
|
10198
9962
|
}
|
|
10199
9963
|
this.addToHistory({
|
|
10200
9964
|
type: "network",
|
|
@@ -10221,16 +9985,16 @@ var UnifiedDebugger = class _UnifiedDebugger {
|
|
|
10221
9985
|
trigger: options.trigger,
|
|
10222
9986
|
timestamp: Date.now()
|
|
10223
9987
|
};
|
|
10224
|
-
if (this.enabled
|
|
10225
|
-
|
|
10226
|
-
|
|
10227
|
-
|
|
9988
|
+
if (this.enabled) {
|
|
9989
|
+
logger4.group(`📋 Network preset applied: ${presetId}`);
|
|
9990
|
+
logger4.info(`Quality: ${options.networkQuality}`);
|
|
9991
|
+
logger4.info(`Trigger: ${options.trigger}`);
|
|
10228
9992
|
changes.forEach((change) => {
|
|
10229
9993
|
const prev = typeof change.previousValue === "string" ? `"${change.previousValue}"` : String(change.previousValue);
|
|
10230
9994
|
const next = typeof change.newValue === "string" ? `"${change.newValue}"` : String(change.newValue);
|
|
10231
|
-
|
|
9995
|
+
logger4.info(` ${change.property}: ${prev} → ${next}`);
|
|
10232
9996
|
});
|
|
10233
|
-
|
|
9997
|
+
logger4.groupEnd();
|
|
10234
9998
|
}
|
|
10235
9999
|
const configChanges = changes.reduce(
|
|
10236
10000
|
(acc, change) => {
|
|
@@ -10653,14 +10417,14 @@ var UnifiedDebugger = class _UnifiedDebugger {
|
|
|
10653
10417
|
*/
|
|
10654
10418
|
enableNetworkDebug() {
|
|
10655
10419
|
this.setEnabled(true);
|
|
10656
|
-
|
|
10420
|
+
logger4.info("🌐 Network configuration debugging enabled");
|
|
10657
10421
|
}
|
|
10658
10422
|
/**
|
|
10659
10423
|
* Disable network config debugging
|
|
10660
10424
|
*/
|
|
10661
10425
|
disableNetworkDebug() {
|
|
10662
10426
|
this.setEnabled(false);
|
|
10663
|
-
|
|
10427
|
+
logger4.info("🌐 Network configuration debugging disabled");
|
|
10664
10428
|
}
|
|
10665
10429
|
/**
|
|
10666
10430
|
* Clear network debug data
|
|
@@ -10669,8 +10433,8 @@ var UnifiedDebugger = class _UnifiedDebugger {
|
|
|
10669
10433
|
this.networkOverrides.clear();
|
|
10670
10434
|
this.history = [];
|
|
10671
10435
|
this.lastPresetChange = void 0;
|
|
10672
|
-
if (this.enabled
|
|
10673
|
-
|
|
10436
|
+
if (this.enabled) {
|
|
10437
|
+
logger4.info("🗑️ Network configuration debug data cleared");
|
|
10674
10438
|
}
|
|
10675
10439
|
this.getDebugFactory().emitNetworkDataCleared();
|
|
10676
10440
|
eventManager.debug.emitNetworkDataCleared();
|
|
@@ -10691,7 +10455,7 @@ var UnifiedDebugger = class _UnifiedDebugger {
|
|
|
10691
10455
|
duration: config.duration
|
|
10692
10456
|
});
|
|
10693
10457
|
if (this.enabled && config.trigger) {
|
|
10694
|
-
|
|
10458
|
+
logger4.info(`🌐 Network override triggered by ${config.trigger}`, {
|
|
10695
10459
|
property: config.property,
|
|
10696
10460
|
value: config.overrideValue,
|
|
10697
10461
|
reason: config.reason
|
|
@@ -11072,6 +10836,9 @@ function validateConfigUpdate(updates, options) {
|
|
|
11072
10836
|
};
|
|
11073
10837
|
}
|
|
11074
10838
|
__name(validateConfigUpdate, "validateConfigUpdate");
|
|
10839
|
+
new logger$1.ApiLogger({ service: types.LOGGER_SERVICES.CONFIG_QUEUE, transport: "console" });
|
|
10840
|
+
new logger$1.ApiLogger({ service: types.LOGGER_SERVICES.QUEUE_ORCHESTRATOR, transport: "console" });
|
|
10841
|
+
var logger7 = new logger$1.ApiLogger({ service: types.LOGGER_SERVICES.OPERATION_TRACKER, transport: "console" });
|
|
11075
10842
|
var BaseOperationTracker = class {
|
|
11076
10843
|
constructor(queueName, priorityDetector, sourceDetector) {
|
|
11077
10844
|
this.queueName = queueName;
|
|
@@ -11136,7 +10903,10 @@ var BaseOperationTracker = class {
|
|
|
11136
10903
|
try {
|
|
11137
10904
|
await this.processor(op.data);
|
|
11138
10905
|
} catch (error) {
|
|
11139
|
-
|
|
10906
|
+
logger7.error("Failed to process operation", {
|
|
10907
|
+
queueName: this.queueName,
|
|
10908
|
+
error: error instanceof Error ? error.message : String(error)
|
|
10909
|
+
});
|
|
11140
10910
|
this.handleProcessingError(error, op.data);
|
|
11141
10911
|
}
|
|
11142
10912
|
}
|
|
@@ -11145,8 +10915,9 @@ var BaseOperationTracker = class {
|
|
|
11145
10915
|
*/
|
|
11146
10916
|
handleProcessingError(error, operation) {
|
|
11147
10917
|
if (config.isDev) {
|
|
11148
|
-
|
|
11149
|
-
|
|
10918
|
+
logger7.debug("Error processing operation", {
|
|
10919
|
+
queueName: this.queueName,
|
|
10920
|
+
error: error instanceof Error ? error.message : String(error),
|
|
11150
10921
|
operation: operation.operation,
|
|
11151
10922
|
event: operation.event
|
|
11152
10923
|
});
|
|
@@ -11225,6 +10996,14 @@ function createDefaultSourceDetector() {
|
|
|
11225
10996
|
};
|
|
11226
10997
|
}
|
|
11227
10998
|
__name(createDefaultSourceDetector, "createDefaultSourceDetector");
|
|
10999
|
+
new logger$1.ApiLogger({
|
|
11000
|
+
service: types.LOGGER_SERVICES.EVENT_QUEUE_MANAGER,
|
|
11001
|
+
transport: "console"
|
|
11002
|
+
});
|
|
11003
|
+
var logger9 = new logger$1.ApiLogger({
|
|
11004
|
+
service: types.LOGGER_SERVICES.DEBUGGER_QUEUE_MANAGER,
|
|
11005
|
+
transport: "console"
|
|
11006
|
+
});
|
|
11228
11007
|
var DebuggerQueueManager = class _DebuggerQueueManager {
|
|
11229
11008
|
static {
|
|
11230
11009
|
__name(this, "DebuggerQueueManager");
|
|
@@ -11296,7 +11075,9 @@ var DebuggerQueueManager = class _DebuggerQueueManager {
|
|
|
11296
11075
|
}
|
|
11297
11076
|
} catch (error) {
|
|
11298
11077
|
if (config.isDev) {
|
|
11299
|
-
|
|
11078
|
+
logger9.warn("Operation failed", {
|
|
11079
|
+
error: error instanceof Error ? error.message : String(error)
|
|
11080
|
+
});
|
|
11300
11081
|
}
|
|
11301
11082
|
}
|
|
11302
11083
|
}
|
|
@@ -11389,6 +11170,7 @@ var DebuggerQueueManager = class _DebuggerQueueManager {
|
|
|
11389
11170
|
}
|
|
11390
11171
|
};
|
|
11391
11172
|
var MAX_RETRY_ATTEMPTS = 3;
|
|
11173
|
+
var logger10 = new logger$1.ApiLogger({ service: types.LOGGER_SERVICES.OPERATION_TRACKER, transport: "console" });
|
|
11392
11174
|
var OperationTracker = class _OperationTracker extends BaseOperationTracker {
|
|
11393
11175
|
static {
|
|
11394
11176
|
__name(this, "OperationTracker");
|
|
@@ -11452,7 +11234,12 @@ var OperationTracker = class _OperationTracker extends BaseOperationTracker {
|
|
|
11452
11234
|
handleProcessingError(error, operation) {
|
|
11453
11235
|
const retryCount = operation.retryCount ?? 0;
|
|
11454
11236
|
if (operation.category === "debugging" && retryCount < MAX_RETRY_ATTEMPTS) {
|
|
11455
|
-
|
|
11237
|
+
logger10.warn("Retrying critical operation", {
|
|
11238
|
+
attempt: retryCount + 1,
|
|
11239
|
+
maxAttempts: MAX_RETRY_ATTEMPTS,
|
|
11240
|
+
operation: operation.operation,
|
|
11241
|
+
category: operation.category
|
|
11242
|
+
});
|
|
11456
11243
|
this.getQueue().add({
|
|
11457
11244
|
data: {
|
|
11458
11245
|
...operation,
|
|
@@ -11461,7 +11248,12 @@ var OperationTracker = class _OperationTracker extends BaseOperationTracker {
|
|
|
11461
11248
|
priority: api.PRIORITY_LEVEL.CRITICAL
|
|
11462
11249
|
});
|
|
11463
11250
|
} else {
|
|
11464
|
-
|
|
11251
|
+
logger10.error("Failed to process operation after retries", {
|
|
11252
|
+
operation: operation.operation,
|
|
11253
|
+
category: operation.category,
|
|
11254
|
+
retryCount,
|
|
11255
|
+
error: error instanceof Error ? error.message : String(error)
|
|
11256
|
+
});
|
|
11465
11257
|
}
|
|
11466
11258
|
}
|
|
11467
11259
|
/**
|
|
@@ -11544,6 +11336,7 @@ var trackingQueue = {
|
|
|
11544
11336
|
return [];
|
|
11545
11337
|
}
|
|
11546
11338
|
};
|
|
11339
|
+
var logger11 = new logger$1.ApiLogger({ service: types.LOGGER_SERVICES.PUB_SUB, transport: "console" });
|
|
11547
11340
|
var EVENT_CONSTANTS = {
|
|
11548
11341
|
/** Minimum event segments for scoped events (namespace:scope:event) */
|
|
11549
11342
|
MIN_SCOPED_SEGMENTS: 2,
|
|
@@ -11649,7 +11442,10 @@ function createEmitMethod(listeners, trackOperation) {
|
|
|
11649
11442
|
try {
|
|
11650
11443
|
callback(data);
|
|
11651
11444
|
} catch (error) {
|
|
11652
|
-
|
|
11445
|
+
logger11.error("Event listener failed", {
|
|
11446
|
+
event,
|
|
11447
|
+
error: error instanceof Error ? error.message : String(error)
|
|
11448
|
+
});
|
|
11653
11449
|
}
|
|
11654
11450
|
});
|
|
11655
11451
|
listeners.forEach((callbacks, pattern) => {
|
|
@@ -11662,7 +11458,11 @@ function createEmitMethod(listeners, trackOperation) {
|
|
|
11662
11458
|
const wildcardData = typeof data === "object" && data !== null ? { ...data, originalEvent: event.split(":").pop() } : { data, originalEvent: event.split(":").pop() };
|
|
11663
11459
|
callback(wildcardData);
|
|
11664
11460
|
} catch (error) {
|
|
11665
|
-
|
|
11461
|
+
logger11.error("Wildcard listener failed", {
|
|
11462
|
+
event,
|
|
11463
|
+
pattern: prefix,
|
|
11464
|
+
error: error instanceof Error ? error.message : String(error)
|
|
11465
|
+
});
|
|
11666
11466
|
}
|
|
11667
11467
|
});
|
|
11668
11468
|
}
|
|
@@ -11674,7 +11474,10 @@ function createEmitMethod(listeners, trackOperation) {
|
|
|
11674
11474
|
try {
|
|
11675
11475
|
callback(data);
|
|
11676
11476
|
} catch (error) {
|
|
11677
|
-
|
|
11477
|
+
logger11.error("Global wildcard listener failed", {
|
|
11478
|
+
event,
|
|
11479
|
+
error: error instanceof Error ? error.message : String(error)
|
|
11480
|
+
});
|
|
11678
11481
|
}
|
|
11679
11482
|
});
|
|
11680
11483
|
}
|
|
@@ -11839,7 +11642,9 @@ function createEventEmitter() {
|
|
|
11839
11642
|
result = handlerResult;
|
|
11840
11643
|
}
|
|
11841
11644
|
} catch (error) {
|
|
11842
|
-
|
|
11645
|
+
logger11.warn("Handler in chain failed", {
|
|
11646
|
+
error: error instanceof Error ? error.message : String(error)
|
|
11647
|
+
});
|
|
11843
11648
|
}
|
|
11844
11649
|
}
|
|
11845
11650
|
return result;
|
|
@@ -11909,858 +11714,239 @@ var EventHelpers = {
|
|
|
11909
11714
|
return namespace ? [`${namespace}:*`] : [];
|
|
11910
11715
|
}, "getMatchingWildcards")
|
|
11911
11716
|
};
|
|
11717
|
+
var API_ERROR_NAMESPACE = "api";
|
|
11718
|
+
var DEFAULT_TIMEOUT_MS2 = 3e4;
|
|
11912
11719
|
var DEFAULT_SERVER_ERROR_STATUS2 = 500;
|
|
11913
|
-
var
|
|
11914
|
-
|
|
11915
|
-
|
|
11916
|
-
|
|
11917
|
-
|
|
11918
|
-
|
|
11919
|
-
|
|
11920
|
-
|
|
11921
|
-
|
|
11720
|
+
var SCOPE_MAP = {
|
|
11721
|
+
GLOBAL: "global",
|
|
11722
|
+
CONFIG: "config",
|
|
11723
|
+
CLIENT: "client",
|
|
11724
|
+
REQUEST: "request",
|
|
11725
|
+
TEMPORARY: "temporary"
|
|
11726
|
+
};
|
|
11727
|
+
function convertToApiEventScope(scope) {
|
|
11728
|
+
const mapped = SCOPE_MAP[scope];
|
|
11729
|
+
if (!mapped) {
|
|
11730
|
+
throw new Error(`Invalid EventScope: ${scope}`);
|
|
11922
11731
|
}
|
|
11923
|
-
return
|
|
11924
|
-
}
|
|
11925
|
-
__name(mapHandlerNameToEventName, "mapHandlerNameToEventName");
|
|
11926
|
-
function registerScopedHandlers(scope, handlers, options = {}) {
|
|
11927
|
-
Object.entries(handlers).forEach(([handlerName, handler]) => {
|
|
11928
|
-
if (handler) {
|
|
11929
|
-
const eventName = mapHandlerNameToEventName(handlerName);
|
|
11930
|
-
const wrappedHandler = /* @__PURE__ */ __name((event) => {
|
|
11931
|
-
const error = event?.data?.error ?? event;
|
|
11932
|
-
try {
|
|
11933
|
-
handler(error);
|
|
11934
|
-
} catch (err) {
|
|
11935
|
-
console.error("Error in error handler:", err);
|
|
11936
|
-
}
|
|
11937
|
-
}, "wrappedHandler");
|
|
11938
|
-
eventManager.errors.addScopedHandler(api.HANDLER_SCOPES[scope], eventName, wrappedHandler, {
|
|
11939
|
-
...options,
|
|
11940
|
-
originalHandler: handler
|
|
11941
|
-
});
|
|
11942
|
-
}
|
|
11943
|
-
});
|
|
11732
|
+
return mapped;
|
|
11944
11733
|
}
|
|
11945
|
-
__name(
|
|
11946
|
-
|
|
11947
|
-
|
|
11948
|
-
|
|
11949
|
-
|
|
11950
|
-
|
|
11951
|
-
|
|
11952
|
-
|
|
11953
|
-
|
|
11734
|
+
__name(convertToApiEventScope, "convertToApiEventScope");
|
|
11735
|
+
var ApiPackageError = class extends errors$1.ApiPackageError {
|
|
11736
|
+
static {
|
|
11737
|
+
__name(this, "ApiPackageError");
|
|
11738
|
+
}
|
|
11739
|
+
};
|
|
11740
|
+
var apiErrorEventFactory = {
|
|
11741
|
+
addScopedHandler(scope, eventName, handler, options) {
|
|
11742
|
+
const eventScope = convertToApiEventScope(scope);
|
|
11743
|
+
eventManager.errors.addScopedHandler(eventScope, eventName, handler, options);
|
|
11744
|
+
},
|
|
11745
|
+
removeScopedHandler(scope, eventName, handler) {
|
|
11746
|
+
const apiScope = convertToApiEventScope(scope);
|
|
11747
|
+
if (!handler) {
|
|
11748
|
+
eventManager.errors.removeAllScopedListeners(apiScope, eventName);
|
|
11954
11749
|
} else {
|
|
11955
|
-
|
|
11956
|
-
handlerName = `on${camelCase.charAt(0).toUpperCase() + camelCase.slice(1)}Error`;
|
|
11750
|
+
eventManager.errors.removeScopedHandler(apiScope, eventName, handler);
|
|
11957
11751
|
}
|
|
11958
|
-
|
|
11959
|
-
|
|
11960
|
-
|
|
11752
|
+
},
|
|
11753
|
+
getOriginalScopedHandlers(scope) {
|
|
11754
|
+
const eventScope = convertToApiEventScope(scope);
|
|
11755
|
+
return eventManager.errors.getOriginalScopedHandlers(eventScope);
|
|
11756
|
+
},
|
|
11757
|
+
emit(eventName, data, options) {
|
|
11758
|
+
if (options?.scopes && options.scopes.length > 0) {
|
|
11759
|
+
options.scopes.forEach((scope) => {
|
|
11760
|
+
const apiScope = convertToApiEventScope(scope);
|
|
11761
|
+
const scopedEventKey = `${apiScope}:errors:${eventName}`;
|
|
11762
|
+
eventManager.errors.emit(scopedEventKey, data);
|
|
11763
|
+
});
|
|
11764
|
+
} else {
|
|
11765
|
+
eventManager.errors.emit(eventName, data);
|
|
11961
11766
|
}
|
|
11767
|
+
}
|
|
11768
|
+
};
|
|
11769
|
+
var isApiNamespaceRegistered = false;
|
|
11770
|
+
function ensureApiNamespaceRegistered() {
|
|
11771
|
+
if (isApiNamespaceRegistered) {
|
|
11772
|
+
return;
|
|
11773
|
+
}
|
|
11774
|
+
errors$1.registerEventFactory(API_ERROR_NAMESPACE, apiErrorEventFactory);
|
|
11775
|
+
errors$1.ApiPackageError.configure({
|
|
11776
|
+
namespace: API_ERROR_NAMESPACE,
|
|
11777
|
+
eventFactory: apiErrorEventFactory
|
|
11962
11778
|
});
|
|
11963
|
-
|
|
11779
|
+
isApiNamespaceRegistered = true;
|
|
11964
11780
|
}
|
|
11965
|
-
__name(
|
|
11781
|
+
__name(ensureApiNamespaceRegistered, "ensureApiNamespaceRegistered");
|
|
11782
|
+
ensureApiNamespaceRegistered();
|
|
11966
11783
|
function registerErrorHandler(eventType, handler, options = {}) {
|
|
11967
|
-
|
|
11968
|
-
|
|
11969
|
-
|
|
11970
|
-
|
|
11971
|
-
try {
|
|
11972
|
-
handler(error);
|
|
11973
|
-
} catch (err) {
|
|
11974
|
-
console.error("Error in error handler:", err);
|
|
11975
|
-
}
|
|
11976
|
-
}, "wrappedHandler");
|
|
11977
|
-
return eventManager.errors.addScopedHandler(
|
|
11978
|
-
api.HANDLER_SCOPES[scope],
|
|
11979
|
-
type,
|
|
11980
|
-
wrappedHandler,
|
|
11981
|
-
{ strategy, originalHandler: handler }
|
|
11982
|
-
);
|
|
11784
|
+
return errors$1.registerErrorHandler(API_ERROR_NAMESPACE, eventType, handler, {
|
|
11785
|
+
...options,
|
|
11786
|
+
eventFactory: apiErrorEventFactory
|
|
11787
|
+
});
|
|
11983
11788
|
}
|
|
11984
11789
|
__name(registerErrorHandler, "registerErrorHandler");
|
|
11790
|
+
function registerErrorHandlers(handlers, options = {}) {
|
|
11791
|
+
const { scope = "GLOBAL", ...rest } = options;
|
|
11792
|
+
errors$1.registerScopedHandlers(API_ERROR_NAMESPACE, scope, handlers, {
|
|
11793
|
+
...rest,
|
|
11794
|
+
eventFactory: apiErrorEventFactory
|
|
11795
|
+
});
|
|
11796
|
+
}
|
|
11797
|
+
__name(registerErrorHandlers, "registerErrorHandlers");
|
|
11985
11798
|
function setErrorHandlers(handlers, scope = "GLOBAL") {
|
|
11986
|
-
|
|
11799
|
+
errors$1.setErrorHandlers(API_ERROR_NAMESPACE, handlers, scope, apiErrorEventFactory);
|
|
11987
11800
|
}
|
|
11988
11801
|
__name(setErrorHandlers, "setErrorHandlers");
|
|
11989
11802
|
function getErrorHandlers(scope = "GLOBAL") {
|
|
11990
|
-
return
|
|
11803
|
+
return errors$1.getErrorHandlers(API_ERROR_NAMESPACE, scope, apiErrorEventFactory);
|
|
11991
11804
|
}
|
|
11992
11805
|
__name(getErrorHandlers, "getErrorHandlers");
|
|
11993
|
-
function registerErrorHandlers(handlers, options = {}) {
|
|
11994
|
-
const { scope = "GLOBAL", strategy = "merge" } = options;
|
|
11995
|
-
registerScopedHandlers(scope, handlers, { strategy });
|
|
11996
|
-
}
|
|
11997
|
-
__name(registerErrorHandlers, "registerErrorHandlers");
|
|
11998
11806
|
function unregisterErrorHandlers(eventTypes, options = {}) {
|
|
11999
11807
|
const { scope = "GLOBAL" } = options;
|
|
12000
|
-
|
|
12001
|
-
if (!eventTypes) {
|
|
12002
|
-
eventManager.errors.clearScopedHandlers(scopeKey);
|
|
12003
|
-
} else {
|
|
12004
|
-
eventTypes.forEach((eventType) => {
|
|
12005
|
-
const type = typeof eventType === "string" && eventType.startsWith("errors:") ? getErrorEventType(eventType) : eventType;
|
|
12006
|
-
eventManager.errors.removeAllScopedListeners(scopeKey, type);
|
|
12007
|
-
});
|
|
12008
|
-
}
|
|
11808
|
+
errors$1.unregisterScopedHandlers(API_ERROR_NAMESPACE, scope, eventTypes, apiErrorEventFactory);
|
|
12009
11809
|
}
|
|
12010
11810
|
__name(unregisterErrorHandlers, "unregisterErrorHandlers");
|
|
12011
11811
|
function clearErrorHandlers(options = {}) {
|
|
12012
|
-
|
|
12013
|
-
|
|
12014
|
-
|
|
12015
|
-
eventManager.errors.clearScopedHandlers(scopeKey);
|
|
11812
|
+
errors$1.clearErrorHandlers(API_ERROR_NAMESPACE, {
|
|
11813
|
+
...options,
|
|
11814
|
+
eventFactory: apiErrorEventFactory
|
|
12016
11815
|
});
|
|
12017
11816
|
}
|
|
12018
11817
|
__name(clearErrorHandlers, "clearErrorHandlers");
|
|
12019
11818
|
function onceErrorHandler(eventType, handler, options = {}) {
|
|
12020
|
-
|
|
12021
|
-
|
|
12022
|
-
|
|
12023
|
-
const eventData = event;
|
|
12024
|
-
const error = eventData?.data?.error ?? event;
|
|
12025
|
-
handler(error);
|
|
11819
|
+
errors$1.registerOnceErrorHandler(API_ERROR_NAMESPACE, eventType, handler, {
|
|
11820
|
+
...options,
|
|
11821
|
+
eventFactory: apiErrorEventFactory
|
|
12026
11822
|
});
|
|
12027
11823
|
}
|
|
12028
11824
|
__name(onceErrorHandler, "onceErrorHandler");
|
|
12029
|
-
|
|
12030
|
-
|
|
12031
|
-
|
|
12032
|
-
|
|
12033
|
-
|
|
12034
|
-
|
|
12035
|
-
|
|
12036
|
-
|
|
12037
|
-
});
|
|
12038
|
-
}, "network"),
|
|
12039
|
-
validation: /* @__PURE__ */ __name((error) => {
|
|
12040
|
-
eventManager.errors.emitValidationError({
|
|
12041
|
-
error,
|
|
12042
|
-
field: error.context?.field,
|
|
12043
|
-
value: error.context?.value,
|
|
12044
|
-
constraints: error.context?.constraints
|
|
12045
|
-
});
|
|
12046
|
-
}, "validation"),
|
|
12047
|
-
authentication: /* @__PURE__ */ __name((error) => {
|
|
12048
|
-
eventManager.errors.emitAuthenticationError(
|
|
12049
|
-
error,
|
|
12050
|
-
error.context?.realm,
|
|
12051
|
-
error.context?.scheme
|
|
12052
|
-
);
|
|
12053
|
-
}, "authentication"),
|
|
12054
|
-
rateLimit: /* @__PURE__ */ __name((error) => {
|
|
12055
|
-
eventManager.errors.emitRateLimitError({
|
|
12056
|
-
error,
|
|
12057
|
-
limit: error.context?.limit,
|
|
12058
|
-
remaining: error.context?.remaining,
|
|
12059
|
-
resetAt: error.context?.resetAt,
|
|
12060
|
-
retryAfter: error.context?.retryAfter
|
|
12061
|
-
});
|
|
12062
|
-
}, "rateLimit"),
|
|
12063
|
-
server: /* @__PURE__ */ __name((error) => {
|
|
12064
|
-
eventManager.errors.emitServerError({
|
|
12065
|
-
error,
|
|
12066
|
-
statusCode: error.statusCode ?? DEFAULT_SERVER_ERROR_STATUS2,
|
|
12067
|
-
serverMessage: error.context?.serverMessage,
|
|
12068
|
-
traceId: error.context?.traceId
|
|
12069
|
-
});
|
|
12070
|
-
}, "server"),
|
|
12071
|
-
timeout: /* @__PURE__ */ __name((error) => {
|
|
12072
|
-
eventManager.errors.emitTimeoutError({
|
|
12073
|
-
error,
|
|
12074
|
-
timeout: error.context?.timeoutMs || error.context?.timeout || 0,
|
|
12075
|
-
operation: error.context?.operation,
|
|
12076
|
-
url: error.context?.url
|
|
12077
|
-
});
|
|
12078
|
-
}, "timeout"),
|
|
12079
|
-
authorization: /* @__PURE__ */ __name((error) => {
|
|
12080
|
-
eventManager.errors.emitAuthorizationError({
|
|
12081
|
-
error,
|
|
12082
|
-
url: error.context?.url,
|
|
12083
|
-
method: error.context?.method,
|
|
12084
|
-
resource: void 0,
|
|
12085
|
-
permission: void 0
|
|
12086
|
-
});
|
|
12087
|
-
}, "authorization"),
|
|
12088
|
-
notFound: /* @__PURE__ */ __name((error) => {
|
|
12089
|
-
eventManager.errors.emitNotFoundError(error, error.context?.url, void 0);
|
|
12090
|
-
}, "notFound"),
|
|
12091
|
-
conflict: /* @__PURE__ */ __name((error) => {
|
|
12092
|
-
eventManager.errors.emitConflictError({
|
|
12093
|
-
error,
|
|
12094
|
-
conflictingResource: void 0,
|
|
12095
|
-
currentValue: void 0,
|
|
12096
|
-
attemptedValue: void 0
|
|
12097
|
-
});
|
|
12098
|
-
}, "conflict"),
|
|
12099
|
-
client: /* @__PURE__ */ __name((error) => {
|
|
12100
|
-
eventManager.errors.emitClientError({
|
|
12101
|
-
error,
|
|
12102
|
-
status: error.statusCode ?? DEFAULT_CLIENT_ERROR_STATUS,
|
|
12103
|
-
url: error.context?.url,
|
|
12104
|
-
method: error.context?.method
|
|
12105
|
-
});
|
|
12106
|
-
}, "client"),
|
|
12107
|
-
externalService: /* @__PURE__ */ __name((error) => {
|
|
12108
|
-
eventManager.errors.emitExternalServiceError({
|
|
12109
|
-
error,
|
|
12110
|
-
service: void 0,
|
|
12111
|
-
endpoint: error.context?.url,
|
|
12112
|
-
timeout: error.context?.timeout
|
|
12113
|
-
});
|
|
12114
|
-
}, "externalService"),
|
|
12115
|
-
cache: /* @__PURE__ */ __name((error) => {
|
|
12116
|
-
eventManager.errors.emitCacheError(
|
|
12117
|
-
error,
|
|
12118
|
-
error.context?.operation,
|
|
12119
|
-
error.context && "cacheKey" in error.context ? error.context.cacheKey : "unknown"
|
|
12120
|
-
);
|
|
12121
|
-
}, "cache"),
|
|
12122
|
-
headers: /* @__PURE__ */ __name((error) => {
|
|
12123
|
-
eventManager.errors.emitHeadersError(error, void 0, error.context?.operation);
|
|
12124
|
-
}, "headers"),
|
|
12125
|
-
retry: /* @__PURE__ */ __name((error) => {
|
|
12126
|
-
eventManager.errors.emitRetryError({
|
|
12127
|
-
error,
|
|
12128
|
-
attempts: void 0,
|
|
12129
|
-
maxAttempts: void 0,
|
|
12130
|
-
lastError: error.context?.originalError
|
|
12131
|
-
});
|
|
12132
|
-
}, "retry")
|
|
12133
|
-
};
|
|
12134
|
-
function getCategoryKey(category) {
|
|
12135
|
-
if (!category) {
|
|
12136
|
-
return "unknown";
|
|
12137
|
-
}
|
|
12138
|
-
return api.ERROR_CATEGORY_TO_EMITTER_KEY[category] || category.toLowerCase();
|
|
12139
|
-
}
|
|
12140
|
-
__name(getCategoryKey, "getCategoryKey");
|
|
12141
|
-
async function emitErrorEvent(error) {
|
|
12142
|
-
const categoryKey = getCategoryKey(error.category);
|
|
12143
|
-
const emitter = ERROR_EMITTERS[categoryKey];
|
|
12144
|
-
if (emitter) {
|
|
12145
|
-
emitter(error);
|
|
12146
|
-
} else {
|
|
12147
|
-
eventManager.errors.emitGenericError(error);
|
|
12148
|
-
}
|
|
12149
|
-
}
|
|
12150
|
-
__name(emitErrorEvent, "emitErrorEvent");
|
|
12151
|
-
|
|
12152
|
-
// src/api/utils/generation/id-generator.ts
|
|
12153
|
-
var ID_CONSTANTS = {
|
|
12154
|
-
RANDOM_START_INDEX: 2,
|
|
12155
|
-
DEFAULT_RANDOM_LENGTH: 8,
|
|
12156
|
-
MAX_PREFIX_LENGTH: 10,
|
|
12157
|
-
DEFAULT_RADIX: 36,
|
|
12158
|
-
TWO_PARTS: 2
|
|
12159
|
-
};
|
|
12160
|
-
var DEFAULT_OPTIONS = {
|
|
12161
|
-
prefix: "",
|
|
12162
|
-
suffix: "",
|
|
12163
|
-
useTimestamp: false,
|
|
12164
|
-
separator: "_",
|
|
12165
|
-
includeRandom: true,
|
|
12166
|
-
radix: ID_CONSTANTS.DEFAULT_RADIX,
|
|
12167
|
-
randomLength: ID_CONSTANTS.DEFAULT_RANDOM_LENGTH
|
|
12168
|
-
};
|
|
12169
|
-
function generateBaseId(options = {}) {
|
|
12170
|
-
const opts = { ...DEFAULT_OPTIONS, ...options };
|
|
12171
|
-
const components = [];
|
|
12172
|
-
if (opts.prefix) {
|
|
12173
|
-
components.push(opts.prefix);
|
|
12174
|
-
}
|
|
12175
|
-
if (opts.useTimestamp) {
|
|
12176
|
-
const timestamp = Date.now().toString(opts.radix);
|
|
12177
|
-
components.push(timestamp);
|
|
12178
|
-
if (opts.includeRandom) {
|
|
12179
|
-
const random = Math.random().toString(opts.radix).slice(
|
|
12180
|
-
ID_CONSTANTS.RANDOM_START_INDEX,
|
|
12181
|
-
ID_CONSTANTS.RANDOM_START_INDEX + opts.randomLength
|
|
12182
|
-
);
|
|
12183
|
-
components.push(random);
|
|
12184
|
-
}
|
|
12185
|
-
} else {
|
|
12186
|
-
components.push(generateUUID());
|
|
12187
|
-
}
|
|
12188
|
-
if (opts.suffix) {
|
|
12189
|
-
components.push(opts.suffix);
|
|
12190
|
-
}
|
|
12191
|
-
return components.join(opts.separator);
|
|
12192
|
-
}
|
|
12193
|
-
__name(generateBaseId, "generateBaseId");
|
|
12194
|
-
function generateContextualId(context, options = {}) {
|
|
12195
|
-
const baseId = generateBaseId(options);
|
|
12196
|
-
const contextParts = [];
|
|
12197
|
-
for (const [, value] of Object.entries(context)) {
|
|
12198
|
-
if (value !== void 0) {
|
|
12199
|
-
contextParts.push(String(value));
|
|
12200
|
-
}
|
|
12201
|
-
}
|
|
12202
|
-
if (contextParts.length > 0) {
|
|
12203
|
-
return `${contextParts.join(":")}:${baseId}`;
|
|
12204
|
-
}
|
|
12205
|
-
return baseId;
|
|
12206
|
-
}
|
|
12207
|
-
__name(generateContextualId, "generateContextualId");
|
|
12208
|
-
function extractFromLastSeparator(id, separator) {
|
|
12209
|
-
const lastIndex = id.lastIndexOf(separator);
|
|
12210
|
-
return lastIndex !== -1 ? id.substring(lastIndex + 1) : null;
|
|
12211
|
-
}
|
|
12212
|
-
__name(extractFromLastSeparator, "extractFromLastSeparator");
|
|
12213
|
-
function extractFromFirstSeparator(id, separator) {
|
|
12214
|
-
const firstIndex = id.indexOf(separator);
|
|
12215
|
-
return firstIndex !== -1 ? id.substring(0, firstIndex) : null;
|
|
12216
|
-
}
|
|
12217
|
-
__name(extractFromFirstSeparator, "extractFromFirstSeparator");
|
|
12218
|
-
function extractAfterPrefix(id, separator) {
|
|
12219
|
-
const firstIndex = id.indexOf(separator);
|
|
12220
|
-
if (firstIndex === -1 || separator !== "_") {
|
|
12221
|
-
return null;
|
|
12222
|
-
}
|
|
12223
|
-
const prefix = id.substring(0, firstIndex);
|
|
12224
|
-
const isShortAlphabeticPrefix = prefix.length <= ID_CONSTANTS.MAX_PREFIX_LENGTH && /^[a-z]+$/i.test(prefix);
|
|
12225
|
-
return isShortAlphabeticPrefix ? id.substring(firstIndex + 1) : null;
|
|
12226
|
-
}
|
|
12227
|
-
__name(extractAfterPrefix, "extractAfterPrefix");
|
|
12228
|
-
function extractWithUnderscoreSeparator(id, separator) {
|
|
12229
|
-
const afterPrefix = extractAfterPrefix(id, separator);
|
|
12230
|
-
if (afterPrefix) {
|
|
12231
|
-
return afterPrefix;
|
|
12232
|
-
}
|
|
12233
|
-
return extractFromLastSeparator(id, separator);
|
|
11825
|
+
function emitNetworkErrorEvent(error, context) {
|
|
11826
|
+
eventManager.errors.emitNetworkError({
|
|
11827
|
+
error,
|
|
11828
|
+
url: context?.url,
|
|
11829
|
+
method: context?.method,
|
|
11830
|
+
status: error.statusCode,
|
|
11831
|
+
retryable: error.retryable
|
|
11832
|
+
});
|
|
12234
11833
|
}
|
|
12235
|
-
__name(
|
|
12236
|
-
function
|
|
12237
|
-
|
|
12238
|
-
|
|
12239
|
-
|
|
12240
|
-
|
|
11834
|
+
__name(emitNetworkErrorEvent, "emitNetworkErrorEvent");
|
|
11835
|
+
function emitTimeoutErrorEvent(error, context) {
|
|
11836
|
+
eventManager.errors.emitTimeoutError({
|
|
11837
|
+
error,
|
|
11838
|
+
timeout: context?.timeout ?? context?.timeoutMs ?? DEFAULT_TIMEOUT_MS2,
|
|
11839
|
+
url: context?.url,
|
|
11840
|
+
operation: context?.operation
|
|
11841
|
+
});
|
|
12241
11842
|
}
|
|
12242
|
-
__name(
|
|
12243
|
-
function
|
|
12244
|
-
|
|
12245
|
-
|
|
12246
|
-
|
|
12247
|
-
|
|
12248
|
-
|
|
11843
|
+
__name(emitTimeoutErrorEvent, "emitTimeoutErrorEvent");
|
|
11844
|
+
function emitServerErrorEvent(error, context) {
|
|
11845
|
+
eventManager.errors.emitServerError({
|
|
11846
|
+
error,
|
|
11847
|
+
statusCode: error.statusCode ?? DEFAULT_SERVER_ERROR_STATUS2,
|
|
11848
|
+
serverMessage: context?.serverMessage,
|
|
11849
|
+
traceId: context?.traceId
|
|
11850
|
+
});
|
|
12249
11851
|
}
|
|
12250
|
-
__name(
|
|
12251
|
-
function
|
|
12252
|
-
|
|
12253
|
-
|
|
11852
|
+
__name(emitServerErrorEvent, "emitServerErrorEvent");
|
|
11853
|
+
function emitAuthorizationErrorEvent(error, context) {
|
|
11854
|
+
eventManager.errors.emitAuthorizationError({
|
|
11855
|
+
error,
|
|
11856
|
+
url: context?.url,
|
|
11857
|
+
method: context?.method,
|
|
11858
|
+
resource: context?.resource,
|
|
11859
|
+
permission: context?.permission
|
|
11860
|
+
});
|
|
12254
11861
|
}
|
|
12255
|
-
__name(
|
|
12256
|
-
function
|
|
12257
|
-
|
|
12258
|
-
|
|
11862
|
+
__name(emitAuthorizationErrorEvent, "emitAuthorizationErrorEvent");
|
|
11863
|
+
function emitRateLimitErrorEvent(error, context) {
|
|
11864
|
+
eventManager.errors.emitRateLimitError({
|
|
11865
|
+
error,
|
|
11866
|
+
limit: context?.limit,
|
|
11867
|
+
remaining: context?.remaining,
|
|
11868
|
+
resetAt: context?.resetAt,
|
|
11869
|
+
retryAfter: context?.retryAfter
|
|
11870
|
+
});
|
|
12259
11871
|
}
|
|
12260
|
-
__name(
|
|
12261
|
-
function
|
|
12262
|
-
|
|
12263
|
-
|
|
11872
|
+
__name(emitRateLimitErrorEvent, "emitRateLimitErrorEvent");
|
|
11873
|
+
function emitValidationErrorEvent(error) {
|
|
11874
|
+
eventManager.errors.emitValidationError({
|
|
11875
|
+
error,
|
|
11876
|
+
field: void 0,
|
|
11877
|
+
value: void 0,
|
|
11878
|
+
constraints: void 0
|
|
11879
|
+
});
|
|
12264
11880
|
}
|
|
12265
|
-
__name(
|
|
12266
|
-
function
|
|
12267
|
-
|
|
12268
|
-
|
|
12269
|
-
|
|
12270
|
-
|
|
12271
|
-
|
|
12272
|
-
return !rejectList.includes(id);
|
|
11881
|
+
__name(emitValidationErrorEvent, "emitValidationErrorEvent");
|
|
11882
|
+
function emitAuthenticationErrorEvent(error, context) {
|
|
11883
|
+
eventManager.errors.emitAuthenticationError(
|
|
11884
|
+
error,
|
|
11885
|
+
context?.realm,
|
|
11886
|
+
context?.scheme
|
|
11887
|
+
);
|
|
12273
11888
|
}
|
|
12274
|
-
__name(
|
|
12275
|
-
function
|
|
12276
|
-
|
|
12277
|
-
|
|
12278
|
-
|
|
12279
|
-
|
|
11889
|
+
__name(emitAuthenticationErrorEvent, "emitAuthenticationErrorEvent");
|
|
11890
|
+
function emitNotFoundErrorEvent(error, context) {
|
|
11891
|
+
eventManager.errors.emitNotFoundError(error, context?.url);
|
|
11892
|
+
}
|
|
11893
|
+
__name(emitNotFoundErrorEvent, "emitNotFoundErrorEvent");
|
|
11894
|
+
var ERROR_CATEGORY_HANDLERS = {
|
|
11895
|
+
network: emitNetworkErrorEvent,
|
|
11896
|
+
validation: emitValidationErrorEvent,
|
|
11897
|
+
authentication: emitAuthenticationErrorEvent,
|
|
11898
|
+
authorization: emitAuthorizationErrorEvent,
|
|
11899
|
+
"rate.limit": emitRateLimitErrorEvent,
|
|
11900
|
+
timeout: emitTimeoutErrorEvent,
|
|
11901
|
+
"not.found": emitNotFoundErrorEvent,
|
|
11902
|
+
server: emitServerErrorEvent
|
|
11903
|
+
};
|
|
11904
|
+
function emitErrorEvent(error) {
|
|
11905
|
+
const context = error.context;
|
|
11906
|
+
const category = error.category?.toLowerCase();
|
|
11907
|
+
const handler = category ? ERROR_CATEGORY_HANDLERS[category] : void 0;
|
|
11908
|
+
if (handler) {
|
|
11909
|
+
handler(error, context);
|
|
11910
|
+
} else {
|
|
11911
|
+
eventManager.errors.emitGenericError(error);
|
|
12280
11912
|
}
|
|
12281
|
-
return null;
|
|
12282
|
-
}
|
|
12283
|
-
__name(checkPatterns, "checkPatterns");
|
|
12284
|
-
function isAnyPatternAllowed(options) {
|
|
12285
|
-
return !!(options.allowUuid ?? options.allowTimestamp ?? options.allowPrefix);
|
|
12286
|
-
}
|
|
12287
|
-
__name(isAnyPatternAllowed, "isAnyPatternAllowed");
|
|
12288
|
-
function checkIdPatterns(id, options) {
|
|
12289
|
-
const patterns = [
|
|
12290
|
-
{ check: isUuidPattern, allowed: options.allowUuid },
|
|
12291
|
-
{ check: isTimestampPattern, allowed: options.allowTimestamp },
|
|
12292
|
-
{ check: isPrefixedPattern, allowed: options.allowPrefix }
|
|
12293
|
-
];
|
|
12294
|
-
return checkPatterns(id, patterns);
|
|
12295
11913
|
}
|
|
12296
|
-
__name(
|
|
12297
|
-
|
|
12298
|
-
|
|
12299
|
-
|
|
12300
|
-
|
|
12301
|
-
}
|
|
12302
|
-
return isAnyPatternAllowed(options) && isValidFallbackPattern(id);
|
|
11914
|
+
__name(emitErrorEvent, "emitErrorEvent");
|
|
11915
|
+
|
|
11916
|
+
// src/api/polling/utils.ts
|
|
11917
|
+
function isPollingActive(config) {
|
|
11918
|
+
return (config.interval ?? 0) > 0;
|
|
12303
11919
|
}
|
|
12304
|
-
__name(
|
|
12305
|
-
function
|
|
12306
|
-
|
|
12307
|
-
|
|
12308
|
-
return false;
|
|
11920
|
+
__name(isPollingActive, "isPollingActive");
|
|
11921
|
+
function calculatePollingDuration(config) {
|
|
11922
|
+
if (!config.interval || !config.maxAttempts || config.maxAttempts <= 0) {
|
|
11923
|
+
return null;
|
|
12309
11924
|
}
|
|
12310
|
-
|
|
11925
|
+
const intervals = config.interval * config.maxAttempts;
|
|
11926
|
+
const delays = (config.delay ?? 0) * config.maxAttempts;
|
|
11927
|
+
return intervals + delays;
|
|
12311
11928
|
}
|
|
12312
|
-
__name(
|
|
12313
|
-
function
|
|
12314
|
-
|
|
12315
|
-
if (id.includes(":")) {
|
|
12316
|
-
const lastColonIndex = id.lastIndexOf(":");
|
|
11929
|
+
__name(calculatePollingDuration, "calculatePollingDuration");
|
|
11930
|
+
function getSSRSafePollingConfig(config) {
|
|
11931
|
+
if (!isBrowser()) {
|
|
12317
11932
|
return {
|
|
12318
|
-
|
|
12319
|
-
|
|
12320
|
-
|
|
11933
|
+
...config,
|
|
11934
|
+
interval: 0,
|
|
11935
|
+
maxAttempts: 1
|
|
12321
11936
|
};
|
|
12322
11937
|
}
|
|
12323
|
-
|
|
12324
|
-
if (parts.length === 1) {
|
|
12325
|
-
return { core: id, full: id };
|
|
12326
|
-
}
|
|
12327
|
-
if (parts.length === ID_CONSTANTS.TWO_PARTS) {
|
|
12328
|
-
if (parts[0].length <= ID_CONSTANTS.MAX_PREFIX_LENGTH && /^[a-z]+$/i.test(parts[0])) {
|
|
12329
|
-
return { prefix: parts[0], core: parts[1], full: id };
|
|
12330
|
-
}
|
|
12331
|
-
return { core: parts[0], suffix: parts[1], full: id };
|
|
12332
|
-
}
|
|
12333
|
-
return {
|
|
12334
|
-
prefix: parts[0],
|
|
12335
|
-
core: parts.slice(1, -1).join(separator),
|
|
12336
|
-
suffix: parts[parts.length - 1],
|
|
12337
|
-
full: id
|
|
12338
|
-
};
|
|
11938
|
+
return config;
|
|
12339
11939
|
}
|
|
12340
|
-
__name(
|
|
12341
|
-
function
|
|
12342
|
-
|
|
12343
|
-
|
|
12344
|
-
|
|
12345
|
-
|
|
12346
|
-
|
|
12347
|
-
|
|
12348
|
-
|
|
12349
|
-
|
|
12350
|
-
correlationGenerators.set(
|
|
12351
|
-
type,
|
|
12352
|
-
createIdGenerator({
|
|
12353
|
-
prefix: type,
|
|
12354
|
-
useTimestamp: true,
|
|
12355
|
-
includeRandom: true,
|
|
12356
|
-
radix: 36,
|
|
12357
|
-
randomLength: 8
|
|
12358
|
-
})
|
|
12359
|
-
);
|
|
12360
|
-
}
|
|
12361
|
-
return correlationGenerators.get(type);
|
|
12362
|
-
}
|
|
12363
|
-
__name(getCorrelationGenerator, "getCorrelationGenerator");
|
|
12364
|
-
function generateCorrelationId(type = api.CORRELATION_TYPE.GENERIC, options) {
|
|
12365
|
-
const generator = getCorrelationGenerator(type);
|
|
12366
|
-
return generator(options);
|
|
12367
|
-
}
|
|
12368
|
-
__name(generateCorrelationId, "generateCorrelationId");
|
|
12369
|
-
function generateContextualCorrelationId(context, type = api.CORRELATION_TYPE.GENERIC, options) {
|
|
12370
|
-
return generateContextualId(context, {
|
|
12371
|
-
prefix: type,
|
|
12372
|
-
useTimestamp: true,
|
|
12373
|
-
includeRandom: true,
|
|
12374
|
-
radix: 36,
|
|
12375
|
-
randomLength: 8,
|
|
12376
|
-
...options
|
|
12377
|
-
});
|
|
12378
|
-
}
|
|
12379
|
-
__name(generateContextualCorrelationId, "generateContextualCorrelationId");
|
|
12380
|
-
function generateNetworkCorrelationId(options) {
|
|
12381
|
-
return generateCorrelationId(api.CORRELATION_TYPE.NETWORK, options);
|
|
12382
|
-
}
|
|
12383
|
-
__name(generateNetworkCorrelationId, "generateNetworkCorrelationId");
|
|
12384
|
-
function generateApiCorrelationId(options) {
|
|
12385
|
-
return generateCorrelationId(api.CORRELATION_TYPE.API, options);
|
|
12386
|
-
}
|
|
12387
|
-
__name(generateApiCorrelationId, "generateApiCorrelationId");
|
|
12388
|
-
function generateSessionCorrelationId(options) {
|
|
12389
|
-
return generateCorrelationId(api.CORRELATION_TYPE.SESSION, options);
|
|
12390
|
-
}
|
|
12391
|
-
__name(generateSessionCorrelationId, "generateSessionCorrelationId");
|
|
12392
|
-
function generateTraceCorrelationId(options) {
|
|
12393
|
-
return generateCorrelationId(api.CORRELATION_TYPE.TRACE, options);
|
|
12394
|
-
}
|
|
12395
|
-
__name(generateTraceCorrelationId, "generateTraceCorrelationId");
|
|
12396
|
-
function extractBaseCorrelationId(contextualId) {
|
|
12397
|
-
let id = extractBaseId(contextualId, { separator: ":", extractLast: true });
|
|
12398
|
-
const prefixes = Object.values(api.CORRELATION_TYPE);
|
|
12399
|
-
for (const prefix of prefixes) {
|
|
12400
|
-
if (id.startsWith(`${prefix}_`)) {
|
|
12401
|
-
id = id.substring(prefix.length + 1);
|
|
12402
|
-
break;
|
|
12403
|
-
}
|
|
12404
|
-
}
|
|
12405
|
-
return id;
|
|
12406
|
-
}
|
|
12407
|
-
__name(extractBaseCorrelationId, "extractBaseCorrelationId");
|
|
12408
|
-
function extractCorrelationType(id) {
|
|
12409
|
-
let idToCheck = id;
|
|
12410
|
-
if (id.includes(":")) {
|
|
12411
|
-
const parts = id.split(":");
|
|
12412
|
-
idToCheck = parts[parts.length - 1];
|
|
12413
|
-
}
|
|
12414
|
-
const parsed = parseId(idToCheck, { separator: "_" });
|
|
12415
|
-
if (parsed.prefix) {
|
|
12416
|
-
const types = Object.values(api.CORRELATION_TYPE);
|
|
12417
|
-
if (types.includes(parsed.prefix)) {
|
|
12418
|
-
return parsed.prefix;
|
|
12419
|
-
}
|
|
12420
|
-
}
|
|
12421
|
-
return void 0;
|
|
12422
|
-
}
|
|
12423
|
-
__name(extractCorrelationType, "extractCorrelationType");
|
|
12424
|
-
function isValidCorrelationId(id) {
|
|
12425
|
-
let idToValidate = id;
|
|
12426
|
-
if (id.includes(":")) {
|
|
12427
|
-
const parts = id.split(":");
|
|
12428
|
-
idToValidate = parts[parts.length - 1];
|
|
12429
|
-
}
|
|
12430
|
-
return isValidId(idToValidate, {
|
|
12431
|
-
allowUuid: true,
|
|
12432
|
-
allowTimestamp: true,
|
|
12433
|
-
allowPrefix: true,
|
|
12434
|
-
minLength: 5
|
|
12435
|
-
});
|
|
12436
|
-
}
|
|
12437
|
-
__name(isValidCorrelationId, "isValidCorrelationId");
|
|
12438
|
-
function createCorrelationIdGenerator(type = api.CORRELATION_TYPE.GENERIC, defaultOptions = {}) {
|
|
12439
|
-
return createIdGenerator({
|
|
12440
|
-
prefix: type,
|
|
12441
|
-
useTimestamp: true,
|
|
12442
|
-
includeRandom: true,
|
|
12443
|
-
radix: 36,
|
|
12444
|
-
randomLength: 8,
|
|
12445
|
-
...defaultOptions
|
|
12446
|
-
});
|
|
12447
|
-
}
|
|
12448
|
-
__name(createCorrelationIdGenerator, "createCorrelationIdGenerator");
|
|
12449
|
-
function linkCorrelationIds(...ids) {
|
|
12450
|
-
return ids.join("->");
|
|
12451
|
-
}
|
|
12452
|
-
__name(linkCorrelationIds, "linkCorrelationIds");
|
|
12453
|
-
function extractLinkedCorrelationIds(linkedId) {
|
|
12454
|
-
return linkedId.split("->");
|
|
12455
|
-
}
|
|
12456
|
-
__name(extractLinkedCorrelationIds, "extractLinkedCorrelationIds");
|
|
12457
|
-
|
|
12458
|
-
// src/api/errors/ApiPackageError.ts
|
|
12459
|
-
var ApiPackageError = class _ApiPackageError extends Error {
|
|
12460
|
-
static {
|
|
12461
|
-
__name(this, "ApiPackageError");
|
|
12462
|
-
}
|
|
12463
|
-
statusCode;
|
|
12464
|
-
errorCode;
|
|
12465
|
-
message;
|
|
12466
|
-
errors;
|
|
12467
|
-
correlationId;
|
|
12468
|
-
timestamp;
|
|
12469
|
-
// Additional properties beyond ErrorResponse
|
|
12470
|
-
responseError;
|
|
12471
|
-
category;
|
|
12472
|
-
cause;
|
|
12473
|
-
context;
|
|
12474
|
-
// Store the original request/response data from fetchff (not Web API types)
|
|
12475
|
-
requestConfig;
|
|
12476
|
-
responseData;
|
|
12477
|
-
details;
|
|
12478
|
-
originalError;
|
|
12479
|
-
metadata;
|
|
12480
|
-
/**
|
|
12481
|
-
* Getter for code property (alias for errorCode)
|
|
12482
|
-
* Provides compatibility with standard error patterns
|
|
12483
|
-
*/
|
|
12484
|
-
get code() {
|
|
12485
|
-
return this.errorCode;
|
|
12486
|
-
}
|
|
12487
|
-
constructor(message, statusCode, errorCode = api.API_ERROR_CODES.UNKNOWN_ERROR, options) {
|
|
12488
|
-
super(message);
|
|
12489
|
-
this.name = "ApiPackageError";
|
|
12490
|
-
this.message = message;
|
|
12491
|
-
this.errorCode = errorCode;
|
|
12492
|
-
this.timestamp = (/* @__PURE__ */ new Date()).toISOString();
|
|
12493
|
-
this.statusCode = this.resolveStatusCode(statusCode, errorCode);
|
|
12494
|
-
if (options) {
|
|
12495
|
-
this.errors = options.errors;
|
|
12496
|
-
this.correlationId = options.correlationId ?? generateApiCorrelationId();
|
|
12497
|
-
this.responseError = options.responseError;
|
|
12498
|
-
this.cause = options.cause;
|
|
12499
|
-
this.context = options.context;
|
|
12500
|
-
this.details = options.errors;
|
|
12501
|
-
this.originalError = options.cause;
|
|
12502
|
-
if (options.responseError) {
|
|
12503
|
-
this.requestConfig = options.responseError.request;
|
|
12504
|
-
this.responseData = options.responseError.response;
|
|
12505
|
-
}
|
|
12506
|
-
} else {
|
|
12507
|
-
this.correlationId = generateApiCorrelationId();
|
|
12508
|
-
}
|
|
12509
|
-
this.category = this.categorizeError();
|
|
12510
|
-
Object.setPrototypeOf(this, _ApiPackageError.prototype);
|
|
12511
|
-
this.emitEvent();
|
|
12512
|
-
}
|
|
12513
|
-
/**
|
|
12514
|
-
* Resolves the status code from the provided value or error definitions
|
|
12515
|
-
*/
|
|
12516
|
-
resolveStatusCode(statusCode, errorCode) {
|
|
12517
|
-
if (statusCode !== void 0) {
|
|
12518
|
-
return statusCode;
|
|
12519
|
-
}
|
|
12520
|
-
const definition = api.ERROR_DEFINITIONS[errorCode];
|
|
12521
|
-
if (definition?.status !== void 0) {
|
|
12522
|
-
return definition.status;
|
|
12523
|
-
}
|
|
12524
|
-
return config.HTTP_STATUS.INTERNAL_SERVER_ERROR;
|
|
12525
|
-
}
|
|
12526
|
-
/**
|
|
12527
|
-
* Emit error event for this error
|
|
12528
|
-
* Can be called with a specific client context or uses global handlers
|
|
12529
|
-
*/
|
|
12530
|
-
emitEvent() {
|
|
12531
|
-
void Promise.resolve().then(() => emitErrorEvent(this)).catch(() => {
|
|
12532
|
-
});
|
|
12533
|
-
}
|
|
12534
|
-
/**
|
|
12535
|
-
* Creates an ApiPackageError from a fetchff ResponseError
|
|
12536
|
-
*/
|
|
12537
|
-
static fromResponseError(responseError, config$1, clientContext) {
|
|
12538
|
-
const statusCode = responseError.status ?? config.HTTP_STATUS.INTERNAL_SERVER_ERROR;
|
|
12539
|
-
const message = responseError.message ?? "An error occurred";
|
|
12540
|
-
const code = this.determineErrorCode(responseError);
|
|
12541
|
-
return new _ApiPackageError(message, statusCode, code, {
|
|
12542
|
-
responseError,
|
|
12543
|
-
cause: responseError,
|
|
12544
|
-
clientContext,
|
|
12545
|
-
context: {
|
|
12546
|
-
url: config$1?.url ?? "",
|
|
12547
|
-
method: config$1?.method ?? "GET"
|
|
12548
|
-
}
|
|
12549
|
-
});
|
|
12550
|
-
}
|
|
12551
|
-
/**
|
|
12552
|
-
* Creates an ApiPackageError from a standard Error
|
|
12553
|
-
*/
|
|
12554
|
-
static fromError(error, statusCode, errorCode = api.API_ERROR_CODES.UNKNOWN_ERROR, context) {
|
|
12555
|
-
if (error instanceof _ApiPackageError) {
|
|
12556
|
-
return error;
|
|
12557
|
-
}
|
|
12558
|
-
const { code, status } = this.classifyError(error, errorCode, statusCode);
|
|
12559
|
-
return new _ApiPackageError(error.message, status, code, {
|
|
12560
|
-
cause: error,
|
|
12561
|
-
clientContext: context
|
|
12562
|
-
});
|
|
12563
|
-
}
|
|
12564
|
-
/**
|
|
12565
|
-
* Classifies an error and returns appropriate code and status
|
|
12566
|
-
*/
|
|
12567
|
-
static classifyError(error, defaultCode, defaultStatus) {
|
|
12568
|
-
if (error.name === "NetworkError" || error.message.includes("network")) {
|
|
12569
|
-
return { code: api.API_ERROR_CODES.NETWORK_ERROR, status: 0 };
|
|
12570
|
-
}
|
|
12571
|
-
if (error.name === "TimeoutError" || error.message.includes("timeout")) {
|
|
12572
|
-
return { code: api.API_ERROR_CODES.REQUEST_TIMEOUT, status: config.HTTP_STATUS.REQUEST_TIMEOUT };
|
|
12573
|
-
}
|
|
12574
|
-
if (error.name === "AbortError") {
|
|
12575
|
-
return { code: api.API_ERROR_CODES.REQUEST_ABORTED, status: 0 };
|
|
12576
|
-
}
|
|
12577
|
-
return { code: defaultCode, status: defaultStatus };
|
|
12578
|
-
}
|
|
12579
|
-
/**
|
|
12580
|
-
* Determines appropriate error code from ResponseError by looking up status in ERROR_DEFINITIONS
|
|
12581
|
-
*/
|
|
12582
|
-
static determineErrorCode(error) {
|
|
12583
|
-
if ("isCancelled" in error && error.isCancelled) {
|
|
12584
|
-
return api.API_ERROR_CODES.CLIENT_CANCELLED;
|
|
12585
|
-
}
|
|
12586
|
-
const status = error.status ?? 0;
|
|
12587
|
-
const errorCode = getErrorCodeByStatus(status);
|
|
12588
|
-
if (errorCode) {
|
|
12589
|
-
return errorCode;
|
|
12590
|
-
}
|
|
12591
|
-
return this.getGenericErrorCode(status);
|
|
12592
|
-
}
|
|
12593
|
-
/**
|
|
12594
|
-
* Gets a generic error code based on HTTP status range
|
|
12595
|
-
*/
|
|
12596
|
-
static getGenericErrorCode(status) {
|
|
12597
|
-
if (status === 0) {
|
|
12598
|
-
return api.API_ERROR_CODES.NETWORK_ERROR;
|
|
12599
|
-
}
|
|
12600
|
-
if (status >= config.HTTP_STATUS.BAD_REQUEST && status < config.HTTP_STATUS.INTERNAL_SERVER_ERROR) {
|
|
12601
|
-
return api.API_ERROR_CODES.CLIENT_ERROR;
|
|
12602
|
-
}
|
|
12603
|
-
if (status >= config.HTTP_STATUS.INTERNAL_SERVER_ERROR) {
|
|
12604
|
-
return api.API_ERROR_CODES.SERVER_ERROR;
|
|
12605
|
-
}
|
|
12606
|
-
return api.API_ERROR_CODES.UNKNOWN_ERROR;
|
|
12607
|
-
}
|
|
12608
|
-
/**
|
|
12609
|
-
* Gets the error category from ERROR_DEFINITIONS
|
|
12610
|
-
*/
|
|
12611
|
-
categorizeError() {
|
|
12612
|
-
const definition = api.ERROR_DEFINITIONS[this.errorCode];
|
|
12613
|
-
return definition?.category ?? types.ERROR_CATEGORY.Unknown;
|
|
12614
|
-
}
|
|
12615
|
-
/**
|
|
12616
|
-
* Checks if this is a specific category of error
|
|
12617
|
-
*/
|
|
12618
|
-
isAuthError() {
|
|
12619
|
-
return this.category === types.ERROR_CATEGORY.Authentication || this.category === types.ERROR_CATEGORY.Authorization;
|
|
12620
|
-
}
|
|
12621
|
-
isValidationError() {
|
|
12622
|
-
return this.category === types.ERROR_CATEGORY.Validation;
|
|
12623
|
-
}
|
|
12624
|
-
isNetworkError() {
|
|
12625
|
-
return this.category === types.ERROR_CATEGORY.Network;
|
|
12626
|
-
}
|
|
12627
|
-
isServerError() {
|
|
12628
|
-
return this.category === types.ERROR_CATEGORY.Server;
|
|
12629
|
-
}
|
|
12630
|
-
isClientError() {
|
|
12631
|
-
return this.statusCode >= config.HTTP_STATUS.BAD_REQUEST && this.statusCode < config.HTTP_STATUS.INTERNAL_SERVER_ERROR;
|
|
12632
|
-
}
|
|
12633
|
-
isRetryable() {
|
|
12634
|
-
return this.category === types.ERROR_CATEGORY.Network || this.category === types.ERROR_CATEGORY.Server || this.category === types.ERROR_CATEGORY.Timeout || this.statusCode === config.HTTP_STATUS.TOO_MANY_REQUESTS || // Rate limit
|
|
12635
|
-
this.statusCode >= config.HTTP_STATUS.INTERNAL_SERVER_ERROR;
|
|
12636
|
-
}
|
|
12637
|
-
/**
|
|
12638
|
-
* Converts to ErrorResponse format (as per task-020)
|
|
12639
|
-
*/
|
|
12640
|
-
toJSON() {
|
|
12641
|
-
return {
|
|
12642
|
-
statusCode: this.statusCode,
|
|
12643
|
-
errorCode: this.errorCode,
|
|
12644
|
-
message: this.message,
|
|
12645
|
-
errors: this.errors ?? [],
|
|
12646
|
-
correlationId: this.correlationId,
|
|
12647
|
-
timestamp: this.timestamp
|
|
12648
|
-
};
|
|
12649
|
-
}
|
|
12650
|
-
/**
|
|
12651
|
-
* Creates a string representation
|
|
12652
|
-
*/
|
|
12653
|
-
toString() {
|
|
12654
|
-
return `[${this.errorCode}] ${this.message} (Status: ${this.statusCode}, Category: ${this.category})`;
|
|
12655
|
-
}
|
|
12656
|
-
/**
|
|
12657
|
-
* Check if error is an ApiPackageError
|
|
12658
|
-
*/
|
|
12659
|
-
static isApiPackageError(error) {
|
|
12660
|
-
return error instanceof _ApiPackageError;
|
|
12661
|
-
}
|
|
12662
|
-
/**
|
|
12663
|
-
* Get user-friendly message for display
|
|
12664
|
-
*/
|
|
12665
|
-
getUserMessage() {
|
|
12666
|
-
const customMessage = this.getCustomUserMessage();
|
|
12667
|
-
if (customMessage) {
|
|
12668
|
-
return customMessage;
|
|
12669
|
-
}
|
|
12670
|
-
return this.getDefaultUserMessage();
|
|
12671
|
-
}
|
|
12672
|
-
/**
|
|
12673
|
-
* Gets custom user message from error details if available
|
|
12674
|
-
*/
|
|
12675
|
-
getCustomUserMessage() {
|
|
12676
|
-
if (!this.details?.length) {
|
|
12677
|
-
return null;
|
|
12678
|
-
}
|
|
12679
|
-
const userMessage = this.details.find((d) => d.field === "userMessage");
|
|
12680
|
-
return userMessage ? userMessage.message : null;
|
|
12681
|
-
}
|
|
12682
|
-
/**
|
|
12683
|
-
* Gets default user message based on error category
|
|
12684
|
-
*/
|
|
12685
|
-
getDefaultUserMessage() {
|
|
12686
|
-
const messages = {
|
|
12687
|
-
[types.ERROR_CATEGORY.Authentication]: "Authentication failed. Please check your credentials.",
|
|
12688
|
-
[types.ERROR_CATEGORY.Authorization]: "You do not have permission to perform this action.",
|
|
12689
|
-
[types.ERROR_CATEGORY.Validation]: "Please check your input and try again.",
|
|
12690
|
-
[types.ERROR_CATEGORY.NotFound]: "The requested resource was not found.",
|
|
12691
|
-
[types.ERROR_CATEGORY.RateLimit]: "Too many requests. Please try again later.",
|
|
12692
|
-
[types.ERROR_CATEGORY.Network]: "Network error. Please check your connection.",
|
|
12693
|
-
[types.ERROR_CATEGORY.Timeout]: "The request timed out. Please try again.",
|
|
12694
|
-
[types.ERROR_CATEGORY.Server]: "Server error. Please try again later.",
|
|
12695
|
-
[types.ERROR_CATEGORY.Client]: "Client error. Please check your request.",
|
|
12696
|
-
[types.ERROR_CATEGORY.Blockchain]: "Blockchain error. Please try again later.",
|
|
12697
|
-
[types.ERROR_CATEGORY.ExternalService]: "External service error. Please try again later.",
|
|
12698
|
-
[types.ERROR_CATEGORY.Conflict]: "Conflict detected. Please resolve and try again.",
|
|
12699
|
-
[types.ERROR_CATEGORY.Cache]: "Cache error. Please try again.",
|
|
12700
|
-
[types.ERROR_CATEGORY.Headers]: "Headers error. Please check your request headers.",
|
|
12701
|
-
[types.ERROR_CATEGORY.Retry]: "Retry limit exceeded. Please try again later.",
|
|
12702
|
-
[types.ERROR_CATEGORY.Strategy]: "Strategy error. Invalid configuration.",
|
|
12703
|
-
[types.ERROR_CATEGORY.Regional]: "Regional configuration error. Please check your region settings.",
|
|
12704
|
-
[types.ERROR_CATEGORY.Unknown]: "An unexpected error occurred. Please try again later."
|
|
12705
|
-
};
|
|
12706
|
-
return messages[this.category] ?? "An unexpected error occurred. Please try again later.";
|
|
12707
|
-
}
|
|
12708
|
-
};
|
|
12709
|
-
|
|
12710
|
-
// src/api/errors/error-codes.ts
|
|
12711
|
-
var API_ERROR_CODES6 = {
|
|
12712
|
-
// Client Configuration Errors
|
|
12713
|
-
CLIENT_INITIALIZATION_FAILED: "CLIENT_INITIALIZATION_FAILED",
|
|
12714
|
-
// Header Errors
|
|
12715
|
-
HEADERS_ENRICHMENT_FAILED: "HEADERS_ENRICHMENT_FAILED",
|
|
12716
|
-
// Polling Errors
|
|
12717
|
-
POLLING_TIMEOUT: "POLLING_TIMEOUT",
|
|
12718
|
-
POLLING_CANCELLED: "POLLING_CANCELLED"};
|
|
12719
|
-
var PACKAGE_STATUS_CODES3 = {
|
|
12720
|
-
// Internal system errors
|
|
12721
|
-
INITIALIZATION_FAILED: 1040,
|
|
12722
|
-
OPERATION_FAILED: 1041};
|
|
12723
|
-
|
|
12724
|
-
// src/api/errors/types-constants.ts
|
|
12725
|
-
var OPERATIONS3 = {
|
|
12726
|
-
ENRICHMENT: "enrichment",
|
|
12727
|
-
INITIALIZATION: "initialization",
|
|
12728
|
-
POLLING: "polling"};
|
|
12729
|
-
|
|
12730
|
-
// src/api/polling/utils.ts
|
|
12731
|
-
function isPollingActive(config) {
|
|
12732
|
-
return (config.interval ?? 0) > 0;
|
|
12733
|
-
}
|
|
12734
|
-
__name(isPollingActive, "isPollingActive");
|
|
12735
|
-
function calculatePollingDuration(config) {
|
|
12736
|
-
if (!config.interval || !config.maxAttempts || config.maxAttempts <= 0) {
|
|
12737
|
-
return null;
|
|
12738
|
-
}
|
|
12739
|
-
const intervals = config.interval * config.maxAttempts;
|
|
12740
|
-
const delays = (config.delay ?? 0) * config.maxAttempts;
|
|
12741
|
-
return intervals + delays;
|
|
12742
|
-
}
|
|
12743
|
-
__name(calculatePollingDuration, "calculatePollingDuration");
|
|
12744
|
-
function getSSRSafePollingConfig(config) {
|
|
12745
|
-
if (!isBrowser()) {
|
|
12746
|
-
return {
|
|
12747
|
-
...config,
|
|
12748
|
-
interval: 0,
|
|
12749
|
-
maxAttempts: 1
|
|
12750
|
-
};
|
|
12751
|
-
}
|
|
12752
|
-
return config;
|
|
12753
|
-
}
|
|
12754
|
-
__name(getSSRSafePollingConfig, "getSSRSafePollingConfig");
|
|
12755
|
-
function createProgressivePolling(options = {}) {
|
|
12756
|
-
const { baseInterval = 1e3, maxInterval = 3e4, multiplier = 1.5 } = options;
|
|
12757
|
-
return {
|
|
12758
|
-
interval: baseInterval,
|
|
12759
|
-
delay: 0,
|
|
12760
|
-
maxAttempts: -1,
|
|
12761
|
-
shouldStop: /* @__PURE__ */ __name((_response, attempt) => {
|
|
12762
|
-
return false;
|
|
12763
|
-
}, "shouldStop")
|
|
11940
|
+
__name(getSSRSafePollingConfig, "getSSRSafePollingConfig");
|
|
11941
|
+
function createProgressivePolling(options = {}) {
|
|
11942
|
+
const { baseInterval = 1e3, maxInterval = 3e4, multiplier = 1.5 } = options;
|
|
11943
|
+
return {
|
|
11944
|
+
interval: baseInterval,
|
|
11945
|
+
delay: 0,
|
|
11946
|
+
maxAttempts: -1,
|
|
11947
|
+
shouldStop: /* @__PURE__ */ __name((_response, attempt) => {
|
|
11948
|
+
return false;
|
|
11949
|
+
}, "shouldStop")
|
|
12764
11950
|
};
|
|
12765
11951
|
}
|
|
12766
11952
|
__name(createProgressivePolling, "createProgressivePolling");
|
|
@@ -12777,11 +11963,11 @@ function createConditionalPolling(options) {
|
|
|
12777
11963
|
if (options.errorCondition?.(response)) {
|
|
12778
11964
|
new ApiPackageError(
|
|
12779
11965
|
"polling.error_condition",
|
|
12780
|
-
|
|
12781
|
-
|
|
11966
|
+
errors.INTERNAL_STATUS_CODES.OPERATION_FAILED,
|
|
11967
|
+
errors.API_ERROR_CODES.POLLING_CANCELLED,
|
|
12782
11968
|
{
|
|
12783
11969
|
context: {
|
|
12784
|
-
operation:
|
|
11970
|
+
operation: errors.COMMON_OPERATIONS.POLLING,
|
|
12785
11971
|
reason: "Error condition met",
|
|
12786
11972
|
i18n: {
|
|
12787
11973
|
reason: "error_condition"
|
|
@@ -12796,11 +11982,11 @@ function createConditionalPolling(options) {
|
|
|
12796
11982
|
if (elapsed >= options.timeoutMs) {
|
|
12797
11983
|
new ApiPackageError(
|
|
12798
11984
|
"polling.timeout",
|
|
12799
|
-
|
|
12800
|
-
|
|
11985
|
+
errors.INTERNAL_STATUS_CODES.OPERATION_FAILED,
|
|
11986
|
+
errors.API_ERROR_CODES.POLLING_TIMEOUT,
|
|
12801
11987
|
{
|
|
12802
11988
|
context: {
|
|
12803
|
-
operation:
|
|
11989
|
+
operation: errors.COMMON_OPERATIONS.POLLING,
|
|
12804
11990
|
timeoutMs: options.timeoutMs,
|
|
12805
11991
|
elapsed,
|
|
12806
11992
|
i18n: {
|
|
@@ -13967,7 +13153,7 @@ function filterToFetchffProperties(config) {
|
|
|
13967
13153
|
maxPollingAttempts,
|
|
13968
13154
|
shouldStopPolling,
|
|
13969
13155
|
fetcher,
|
|
13970
|
-
logger,
|
|
13156
|
+
logger: logger19,
|
|
13971
13157
|
// Cache properties
|
|
13972
13158
|
cacheTime,
|
|
13973
13159
|
staleTime,
|
|
@@ -14060,7 +13246,7 @@ function filterToFetchffProperties(config) {
|
|
|
14060
13246
|
if (shouldStopPolling !== void 0 && shouldStopPolling !== null)
|
|
14061
13247
|
fetchffConfig.shouldStopPolling = shouldStopPolling;
|
|
14062
13248
|
if (fetcher !== void 0 && fetcher !== null) fetchffConfig.fetcher = fetcher;
|
|
14063
|
-
if (
|
|
13249
|
+
if (logger19 !== void 0 && logger19 !== null) fetchffConfig.logger = logger19;
|
|
14064
13250
|
if (cacheTime !== void 0) fetchffConfig.cacheTime = cacheTime;
|
|
14065
13251
|
if (staleTime !== void 0) fetchffConfig.staleTime = staleTime;
|
|
14066
13252
|
if (skipCache !== void 0) fetchffConfig.skipCache = skipCache;
|
|
@@ -14437,11 +13623,33 @@ function trackGlobalConfigUpdate(params) {
|
|
|
14437
13623
|
});
|
|
14438
13624
|
}
|
|
14439
13625
|
__name(trackGlobalConfigUpdate, "trackGlobalConfigUpdate");
|
|
13626
|
+
function handleGlobalErrorSystemConfig(errorConfig) {
|
|
13627
|
+
const alreadyInitialized = errors$1.isErrorSystemInitialized();
|
|
13628
|
+
if (alreadyInitialized) {
|
|
13629
|
+
if (errorConfig.locale) {
|
|
13630
|
+
errors$1.setErrorLocale(errorConfig.locale);
|
|
13631
|
+
}
|
|
13632
|
+
if (errorConfig.additionalCatalogs) {
|
|
13633
|
+
Object.entries(errorConfig.additionalCatalogs).forEach(([locale, catalog]) => {
|
|
13634
|
+
errors$1.addMessageCatalog(locale, catalog, true);
|
|
13635
|
+
});
|
|
13636
|
+
}
|
|
13637
|
+
} else {
|
|
13638
|
+
errors$1.initializeErrorSystem({
|
|
13639
|
+
defaultLocale: errorConfig.locale,
|
|
13640
|
+
additionalCatalogs: errorConfig.additionalCatalogs
|
|
13641
|
+
});
|
|
13642
|
+
}
|
|
13643
|
+
}
|
|
13644
|
+
__name(handleGlobalErrorSystemConfig, "handleGlobalErrorSystemConfig");
|
|
14440
13645
|
function setGlobalConfig(config) {
|
|
14441
13646
|
try {
|
|
14442
13647
|
const startTime = Date.now();
|
|
14443
13648
|
const currentConfig = globalApiConfig;
|
|
14444
13649
|
validateConfigObject(config);
|
|
13650
|
+
if (config.errors) {
|
|
13651
|
+
handleGlobalErrorSystemConfig(config.errors);
|
|
13652
|
+
}
|
|
14445
13653
|
const { merged: mergedConfig, entries: configEntries } = mergeGlobalConfig(
|
|
14446
13654
|
currentConfig,
|
|
14447
13655
|
config
|
|
@@ -14616,10 +13824,6 @@ var campaignEndpoints = {
|
|
|
14616
13824
|
createCampaign: {
|
|
14617
13825
|
url: "/campaigns",
|
|
14618
13826
|
method: "POST"
|
|
14619
|
-
// Example: Override global settings for this endpoint
|
|
14620
|
-
// cancellable: true, // Cancel previous create requests
|
|
14621
|
-
// timeout: 60000, // Longer timeout for creation
|
|
14622
|
-
// retry: { attempts: 1 } // Don't retry POST requests
|
|
14623
13827
|
},
|
|
14624
13828
|
updateCampaign: {
|
|
14625
13829
|
url: "/campaigns/:id",
|
|
@@ -14632,9 +13836,6 @@ var campaignEndpoints = {
|
|
|
14632
13836
|
getCampaignStats: {
|
|
14633
13837
|
url: "/campaigns/:id/stats",
|
|
14634
13838
|
method: "GET"
|
|
14635
|
-
// Example: Cache stats for longer
|
|
14636
|
-
// cacheTime: 600, // Cache for 10 minutes
|
|
14637
|
-
// staleTime: 1200 // Consider stale after 20 minutes
|
|
14638
13839
|
},
|
|
14639
13840
|
getCampaignParticipants: {
|
|
14640
13841
|
url: "/campaigns/:id/participants",
|
|
@@ -14712,6 +13913,111 @@ var pollingEndpoints = {
|
|
|
14712
13913
|
}
|
|
14713
13914
|
};
|
|
14714
13915
|
|
|
13916
|
+
// src/api/endpoints/infobip.ts
|
|
13917
|
+
var infobipEmailEndpoints = {
|
|
13918
|
+
// ========== Outbound Email ==========
|
|
13919
|
+
/**
|
|
13920
|
+
* POST /email/3/send - Send email (simple, with attachment support)
|
|
13921
|
+
* Multipart/form-data for attachments
|
|
13922
|
+
*/
|
|
13923
|
+
sendEmail: {
|
|
13924
|
+
url: "/email/3/send",
|
|
13925
|
+
method: "POST"
|
|
13926
|
+
},
|
|
13927
|
+
/**
|
|
13928
|
+
* POST /email/4/send - Send advanced email
|
|
13929
|
+
* JSON payload with full customization
|
|
13930
|
+
*/
|
|
13931
|
+
sendAdvancedEmail: {
|
|
13932
|
+
url: "/email/4/messages",
|
|
13933
|
+
method: "POST"
|
|
13934
|
+
},
|
|
13935
|
+
/**
|
|
13936
|
+
* POST /email/3/mime - Send email via MIME format
|
|
13937
|
+
*/
|
|
13938
|
+
sendEmailMime: {
|
|
13939
|
+
url: "/email/3/mime",
|
|
13940
|
+
method: "POST"
|
|
13941
|
+
},
|
|
13942
|
+
// ========== Email Validation ==========
|
|
13943
|
+
/**
|
|
13944
|
+
* POST /email/2/validation - Validate single email address
|
|
13945
|
+
*/
|
|
13946
|
+
validateEmail: {
|
|
13947
|
+
url: "/email/2/validation",
|
|
13948
|
+
method: "POST"
|
|
13949
|
+
},
|
|
13950
|
+
/**
|
|
13951
|
+
* POST /email/2/validations - Bulk validate email addresses
|
|
13952
|
+
* Returns 202 with validation request ID
|
|
13953
|
+
*/
|
|
13954
|
+
bulkValidateEmails: {
|
|
13955
|
+
url: "/email/2/validations",
|
|
13956
|
+
method: "POST"
|
|
13957
|
+
},
|
|
13958
|
+
/**
|
|
13959
|
+
* GET /email/2/validations - Get validation results
|
|
13960
|
+
* Retrieve bulk validation results with filtering
|
|
13961
|
+
*/
|
|
13962
|
+
getValidations: {
|
|
13963
|
+
url: "/email/2/validations",
|
|
13964
|
+
method: "GET",
|
|
13965
|
+
cacheTime: 30,
|
|
13966
|
+
staleTime: 60
|
|
13967
|
+
},
|
|
13968
|
+
// ========== Logs & Reports ==========
|
|
13969
|
+
/**
|
|
13970
|
+
* GET /email/1/reports - Get email delivery reports
|
|
13971
|
+
*/
|
|
13972
|
+
getEmailReports: {
|
|
13973
|
+
url: "/email/1/reports",
|
|
13974
|
+
method: "GET",
|
|
13975
|
+
cacheTime: 30,
|
|
13976
|
+
staleTime: 60
|
|
13977
|
+
},
|
|
13978
|
+
/**
|
|
13979
|
+
* GET /email/1/logs - Get email logs
|
|
13980
|
+
*/
|
|
13981
|
+
getEmailLogs: {
|
|
13982
|
+
url: "/email/1/logs",
|
|
13983
|
+
method: "GET",
|
|
13984
|
+
cacheTime: 60,
|
|
13985
|
+
staleTime: 120
|
|
13986
|
+
},
|
|
13987
|
+
// ========== Scheduled Messages (Bulk Operations) ==========
|
|
13988
|
+
/**
|
|
13989
|
+
* GET /email/1/bulks - Get scheduled email bulks
|
|
13990
|
+
*/
|
|
13991
|
+
getScheduledEmails: {
|
|
13992
|
+
url: "/email/1/bulks",
|
|
13993
|
+
method: "GET"
|
|
13994
|
+
},
|
|
13995
|
+
/**
|
|
13996
|
+
* GET /email/1/bulks/status - Get scheduled email statuses
|
|
13997
|
+
*/
|
|
13998
|
+
getScheduledEmailStatuses: {
|
|
13999
|
+
url: "/email/1/bulks/status",
|
|
14000
|
+
method: "GET"
|
|
14001
|
+
},
|
|
14002
|
+
/**
|
|
14003
|
+
* PUT /email/1/bulks - Reschedule emails
|
|
14004
|
+
*/
|
|
14005
|
+
rescheduleEmails: {
|
|
14006
|
+
url: "/email/1/bulks",
|
|
14007
|
+
method: "PUT"
|
|
14008
|
+
},
|
|
14009
|
+
/**
|
|
14010
|
+
* PUT /email/1/bulks/status - Update scheduled email statuses
|
|
14011
|
+
*/
|
|
14012
|
+
updateScheduledEmailStatuses: {
|
|
14013
|
+
url: "/email/1/bulks/status",
|
|
14014
|
+
method: "PUT"
|
|
14015
|
+
}
|
|
14016
|
+
};
|
|
14017
|
+
var infobipEndpoints = {
|
|
14018
|
+
...infobipEmailEndpoints
|
|
14019
|
+
};
|
|
14020
|
+
|
|
14715
14021
|
// src/api/endpoints/utils.ts
|
|
14716
14022
|
function getEndpointUrl(name) {
|
|
14717
14023
|
return endpoints[name].url;
|
|
@@ -14884,7 +14190,9 @@ __name(validatePathParams, "validatePathParams");
|
|
|
14884
14190
|
var endpoints = {
|
|
14885
14191
|
...campaignEndpoints,
|
|
14886
14192
|
// These are only examples for the polling, none of these endpoints doesnt exist yet
|
|
14887
|
-
...pollingEndpoints
|
|
14193
|
+
...pollingEndpoints,
|
|
14194
|
+
// Infobip third-party provider endpoints (Email, SMS, WhatsApp)
|
|
14195
|
+
...infobipEndpoints
|
|
14888
14196
|
};
|
|
14889
14197
|
var isSlowConnection = fetchff.isSlowConnection;
|
|
14890
14198
|
function isNetworkAPISupported() {
|
|
@@ -18265,6 +17573,7 @@ async function prepareRequestConfigWithEnrichedHeaders(requestConfig, clientConf
|
|
|
18265
17573
|
return config;
|
|
18266
17574
|
}
|
|
18267
17575
|
__name(prepareRequestConfigWithEnrichedHeaders, "prepareRequestConfigWithEnrichedHeaders");
|
|
17576
|
+
new logger$1.ApiLogger({ service: types.LOGGER_SERVICES.EXPRESS_FRAMEWORK, transport: "console" });
|
|
18268
17577
|
var networkDetectionMiddleware = /* @__PURE__ */ __name((req, res, next) => {
|
|
18269
17578
|
const headerInfo = getNetworkInfoFromHeaders(req.headers);
|
|
18270
17579
|
const networkInfo = {
|
|
@@ -18425,6 +17734,7 @@ __name(exports.MinimumConnectionGuard, "MinimumConnectionGuard");
|
|
|
18425
17734
|
exports.MinimumConnectionGuard = __decorateClass([
|
|
18426
17735
|
common.Injectable()
|
|
18427
17736
|
], exports.MinimumConnectionGuard);
|
|
17737
|
+
var logger13 = new logger$1.ApiLogger({ service: types.LOGGER_SERVICES.NESTJS_GUARD, transport: "console" });
|
|
18428
17738
|
var EnrichedHeadersGuard = class {
|
|
18429
17739
|
constructor(options = {}) {
|
|
18430
17740
|
this.options = options;
|
|
@@ -18439,7 +17749,7 @@ var EnrichedHeadersGuard = class {
|
|
|
18439
17749
|
for (const requiredHeader of requiredHeaders) {
|
|
18440
17750
|
if (!enrichedHeaders[requiredHeader]) {
|
|
18441
17751
|
if (debug) {
|
|
18442
|
-
|
|
17752
|
+
logger13.warn("Missing required header", { requiredHeader });
|
|
18443
17753
|
}
|
|
18444
17754
|
return false;
|
|
18445
17755
|
}
|
|
@@ -18456,7 +17766,7 @@ var EnrichedHeadersGuard = class {
|
|
|
18456
17766
|
const complianceHeader = enrichedHeaders["x-compliance-required"];
|
|
18457
17767
|
if (!complianceHeader) {
|
|
18458
17768
|
if (debug) {
|
|
18459
|
-
|
|
17769
|
+
logger13.warn("No compliance information available");
|
|
18460
17770
|
}
|
|
18461
17771
|
return false;
|
|
18462
17772
|
}
|
|
@@ -18466,7 +17776,7 @@ var EnrichedHeadersGuard = class {
|
|
|
18466
17776
|
);
|
|
18467
17777
|
if (!hasRequiredCompliance) {
|
|
18468
17778
|
if (debug) {
|
|
18469
|
-
|
|
17779
|
+
logger13.warn("Required compliance not met", {
|
|
18470
17780
|
required: requiredCompliance,
|
|
18471
17781
|
current: currentCompliance
|
|
18472
17782
|
});
|
|
@@ -18480,7 +17790,7 @@ var EnrichedHeadersGuard = class {
|
|
|
18480
17790
|
*/
|
|
18481
17791
|
async buildHeadersForRequest(request, enrichedOptions, debug) {
|
|
18482
17792
|
if (debug) {
|
|
18483
|
-
|
|
17793
|
+
logger13.debug("Processing request with enriched headers guard", {
|
|
18484
17794
|
method: request.method,
|
|
18485
17795
|
url: request.url,
|
|
18486
17796
|
userAgent: request.headers["user-agent"]
|
|
@@ -18496,7 +17806,7 @@ var EnrichedHeadersGuard = class {
|
|
|
18496
17806
|
};
|
|
18497
17807
|
const enrichedHeaders = await buildEnrichedHeaders(requestContext, enrichedOptions);
|
|
18498
17808
|
if (debug) {
|
|
18499
|
-
|
|
17809
|
+
logger13.debug("Built enriched headers in guard", { enrichedHeaders });
|
|
18500
17810
|
}
|
|
18501
17811
|
return enrichedHeaders;
|
|
18502
17812
|
}
|
|
@@ -18528,7 +17838,9 @@ var EnrichedHeadersGuard = class {
|
|
|
18528
17838
|
*/
|
|
18529
17839
|
async handleBuildError(error, request, debug) {
|
|
18530
17840
|
if (debug) {
|
|
18531
|
-
|
|
17841
|
+
logger13.error("Error building headers in guard", {
|
|
17842
|
+
error: error instanceof Error ? error.message : String(error)
|
|
17843
|
+
});
|
|
18532
17844
|
}
|
|
18533
17845
|
new ApiPackageError(
|
|
18534
17846
|
"nestjs.guard.enriched_headers_failed",
|
|
@@ -18576,6 +17888,7 @@ __name(EnrichedHeadersGuard, "EnrichedHeadersGuard");
|
|
|
18576
17888
|
EnrichedHeadersGuard = __decorateClass([
|
|
18577
17889
|
common.Injectable()
|
|
18578
17890
|
], EnrichedHeadersGuard);
|
|
17891
|
+
var logger14 = new logger$1.ApiLogger({ service: types.LOGGER_SERVICES.NESTJS_INTERCEPTOR, transport: "console" });
|
|
18579
17892
|
var EnrichedHeadersInterceptor = class {
|
|
18580
17893
|
constructor(options = {}) {
|
|
18581
17894
|
this.options = options;
|
|
@@ -18627,7 +17940,9 @@ var EnrichedHeadersInterceptor = class {
|
|
|
18627
17940
|
*/
|
|
18628
17941
|
handleContextError(error, request, debug) {
|
|
18629
17942
|
if (debug) {
|
|
18630
|
-
|
|
17943
|
+
logger14.error("Error in interceptor context", {
|
|
17944
|
+
error: error.message
|
|
17945
|
+
});
|
|
18631
17946
|
}
|
|
18632
17947
|
new ApiPackageError(
|
|
18633
17948
|
"nestjs.interceptor.context_error",
|
|
@@ -18652,7 +17967,9 @@ var EnrichedHeadersInterceptor = class {
|
|
|
18652
17967
|
*/
|
|
18653
17968
|
handleBuildError(error, request, next, debug) {
|
|
18654
17969
|
if (debug) {
|
|
18655
|
-
|
|
17970
|
+
logger14.error("Error building headers in interceptor", {
|
|
17971
|
+
error: error instanceof Error ? error.message : String(error)
|
|
17972
|
+
});
|
|
18656
17973
|
}
|
|
18657
17974
|
new ApiPackageError(
|
|
18658
17975
|
"nestjs.interceptor.enriched_headers_failed",
|
|
@@ -18696,7 +18013,9 @@ var EnrichedHeadersInterceptor = class {
|
|
|
18696
18013
|
*/
|
|
18697
18014
|
handleFallbackError(error, request, debug) {
|
|
18698
18015
|
if (debug) {
|
|
18699
|
-
|
|
18016
|
+
logger14.error("Error in fallback context", {
|
|
18017
|
+
error: error.message
|
|
18018
|
+
});
|
|
18700
18019
|
}
|
|
18701
18020
|
new ApiPackageError(
|
|
18702
18021
|
"nestjs.interceptor.fallback_error",
|
|
@@ -18723,7 +18042,7 @@ var EnrichedHeadersInterceptor = class {
|
|
|
18723
18042
|
const response = http.getResponse();
|
|
18724
18043
|
try {
|
|
18725
18044
|
if (debug) {
|
|
18726
|
-
|
|
18045
|
+
logger14.debug("Processing request with enriched headers interceptor", {
|
|
18727
18046
|
method: request.method,
|
|
18728
18047
|
url: request.url,
|
|
18729
18048
|
userAgent: request.headers["user-agent"]
|
|
@@ -18731,7 +18050,7 @@ var EnrichedHeadersInterceptor = class {
|
|
|
18731
18050
|
}
|
|
18732
18051
|
const enrichedHeaders = await this.buildHeaders(request, enrichedOptions);
|
|
18733
18052
|
if (debug) {
|
|
18734
|
-
|
|
18053
|
+
logger14.debug("Built enriched headers in interceptor", { enrichedHeaders });
|
|
18735
18054
|
}
|
|
18736
18055
|
if (storeInRequest) {
|
|
18737
18056
|
request.enrichedHeaders = enrichedHeaders;
|
|
@@ -19456,65 +18775,6 @@ var NetworkPresetNames = {
|
|
|
19456
18775
|
BACKGROUND_SYNC: "background-sync"
|
|
19457
18776
|
};
|
|
19458
18777
|
|
|
19459
|
-
// src/api/utils/generation/request-id.ts
|
|
19460
|
-
var REQUEST_ID_CONSTANTS = {
|
|
19461
|
-
PREFIX_LENGTH: 4
|
|
19462
|
-
// Length of 'req_'
|
|
19463
|
-
};
|
|
19464
|
-
var requestIdGenerator = createIdGenerator({
|
|
19465
|
-
prefix: "req",
|
|
19466
|
-
useTimestamp: false
|
|
19467
|
-
// Use UUID for request IDs for guaranteed uniqueness
|
|
19468
|
-
});
|
|
19469
|
-
function generateRequestId(options) {
|
|
19470
|
-
return requestIdGenerator(options);
|
|
19471
|
-
}
|
|
19472
|
-
__name(generateRequestId, "generateRequestId");
|
|
19473
|
-
function generateContextualRequestId(method, url, options) {
|
|
19474
|
-
const context = {};
|
|
19475
|
-
if (method || url) {
|
|
19476
|
-
context.method = method ?? "UNKNOWN";
|
|
19477
|
-
context.url = url ?? "UNKNOWN";
|
|
19478
|
-
}
|
|
19479
|
-
return generateContextualId(context, {
|
|
19480
|
-
prefix: "req",
|
|
19481
|
-
...options
|
|
19482
|
-
});
|
|
19483
|
-
}
|
|
19484
|
-
__name(generateContextualRequestId, "generateContextualRequestId");
|
|
19485
|
-
function extractBaseRequestId(contextualId) {
|
|
19486
|
-
let id = extractBaseId(contextualId, { separator: ":", extractLast: true });
|
|
19487
|
-
if (id.startsWith("req_")) {
|
|
19488
|
-
id = id.substring(REQUEST_ID_CONSTANTS.PREFIX_LENGTH);
|
|
19489
|
-
}
|
|
19490
|
-
return id;
|
|
19491
|
-
}
|
|
19492
|
-
__name(extractBaseRequestId, "extractBaseRequestId");
|
|
19493
|
-
function isValidRequestId(id) {
|
|
19494
|
-
return isValidId(id, {
|
|
19495
|
-
allowUuid: true,
|
|
19496
|
-
allowTimestamp: true,
|
|
19497
|
-
allowPrefix: true,
|
|
19498
|
-
minLength: 5
|
|
19499
|
-
});
|
|
19500
|
-
}
|
|
19501
|
-
__name(isValidRequestId, "isValidRequestId");
|
|
19502
|
-
function generateShortRequestId(options) {
|
|
19503
|
-
return requestIdGenerator({
|
|
19504
|
-
useTimestamp: true,
|
|
19505
|
-
randomLength: 8,
|
|
19506
|
-
...options
|
|
19507
|
-
});
|
|
19508
|
-
}
|
|
19509
|
-
__name(generateShortRequestId, "generateShortRequestId");
|
|
19510
|
-
function createRequestIdGenerator(defaultOptions = {}) {
|
|
19511
|
-
return createIdGenerator({
|
|
19512
|
-
prefix: "req",
|
|
19513
|
-
...defaultOptions
|
|
19514
|
-
});
|
|
19515
|
-
}
|
|
19516
|
-
__name(createRequestIdGenerator, "createRequestIdGenerator");
|
|
19517
|
-
|
|
19518
18778
|
// src/api/utils/async-control.ts
|
|
19519
18779
|
function debounce(func, delay) {
|
|
19520
18780
|
let timeoutId;
|
|
@@ -19796,6 +19056,10 @@ function getAllMediaExtensions() {
|
|
|
19796
19056
|
}
|
|
19797
19057
|
__name(getAllMediaExtensions, "getAllMediaExtensions");
|
|
19798
19058
|
var MEDIA_MIME_PREFIXES = ["image/", "video/", "audio/"];
|
|
19059
|
+
var logger15 = new logger$1.ApiLogger({
|
|
19060
|
+
service: types.LOGGER_SERVICES.CLIENT_EVENT_MANAGER,
|
|
19061
|
+
transport: "console"
|
|
19062
|
+
});
|
|
19799
19063
|
var EVENT_CONSTANTS2 = {
|
|
19800
19064
|
DEBUG_INFO_INTERVAL_MULTIPLIER: 5,
|
|
19801
19065
|
IMPACT_THRESHOLDS: {
|
|
@@ -20008,7 +19272,9 @@ var ClientEventManager = class _ClientEventManager {
|
|
|
20008
19272
|
const registeredHandlers = [];
|
|
20009
19273
|
finalHandlers.forEach((h) => {
|
|
20010
19274
|
if (typeof h !== "function") {
|
|
20011
|
-
|
|
19275
|
+
logger15.warn("Invalid handler provided - not a function", {
|
|
19276
|
+
handlerType: typeof h
|
|
19277
|
+
});
|
|
20012
19278
|
return;
|
|
20013
19279
|
}
|
|
20014
19280
|
const wrappedHandler = /* @__PURE__ */ __name((eventData) => {
|
|
@@ -20525,10 +19791,20 @@ var ClientEventManager = class _ClientEventManager {
|
|
|
20525
19791
|
return this.eventManager.getActiveScopes();
|
|
20526
19792
|
}
|
|
20527
19793
|
/**
|
|
20528
|
-
* Emit error event
|
|
19794
|
+
* Emit error event at CLIENT scope
|
|
19795
|
+
*
|
|
19796
|
+
* Note: ApiPackageError instances automatically emit to ALL scopes when created.
|
|
19797
|
+
* This method emits specifically at CLIENT scope, useful for:
|
|
19798
|
+
* - Re-emitting errors that were caught and handled elsewhere
|
|
19799
|
+
* - Manual emission timing control
|
|
19800
|
+
* - Client-level error broadcasting
|
|
20529
19801
|
*/
|
|
20530
19802
|
emitError(error) {
|
|
20531
|
-
|
|
19803
|
+
errors$1.emitScopedErrorEvent(API_ERROR_NAMESPACE, error, {
|
|
19804
|
+
scopes: ["CLIENT"],
|
|
19805
|
+
eventFactory: apiErrorEventFactory,
|
|
19806
|
+
category: error.category
|
|
19807
|
+
});
|
|
20532
19808
|
}
|
|
20533
19809
|
/**
|
|
20534
19810
|
* Emit request start event
|
|
@@ -21415,8 +20691,6 @@ function mergeHeaders(...headerSets) {
|
|
|
21415
20691
|
return result;
|
|
21416
20692
|
}
|
|
21417
20693
|
__name(mergeHeaders, "mergeHeaders");
|
|
21418
|
-
|
|
21419
|
-
// src/api/headers/headerBuilder.ts
|
|
21420
20694
|
var HeaderBuilder = class {
|
|
21421
20695
|
static {
|
|
21422
20696
|
__name(this, "HeaderBuilder");
|
|
@@ -21651,7 +20925,7 @@ var HeaderBuilder = class {
|
|
|
21651
20925
|
* ```
|
|
21652
20926
|
*/
|
|
21653
20927
|
correlationId(id) {
|
|
21654
|
-
this._headers["x-correlation-id"] = id ?? generateCorrelationId();
|
|
20928
|
+
this._headers["x-correlation-id"] = id ?? errors$1.generateCorrelationId("req_correlation");
|
|
21655
20929
|
return this;
|
|
21656
20930
|
}
|
|
21657
20931
|
/**
|
|
@@ -21667,7 +20941,7 @@ var HeaderBuilder = class {
|
|
|
21667
20941
|
* ```
|
|
21668
20942
|
*/
|
|
21669
20943
|
requestId(id) {
|
|
21670
|
-
this._headers["x-request-id"] = id ?? generateRequestId();
|
|
20944
|
+
this._headers["x-request-id"] = id ?? errors$1.generateRequestId();
|
|
21671
20945
|
return this;
|
|
21672
20946
|
}
|
|
21673
20947
|
/**
|
|
@@ -21683,7 +20957,7 @@ var HeaderBuilder = class {
|
|
|
21683
20957
|
* ```
|
|
21684
20958
|
*/
|
|
21685
20959
|
traceId(traceId) {
|
|
21686
|
-
this._headers["x-trace-id"] = traceId ?? generateTraceCorrelationId();
|
|
20960
|
+
this._headers["x-trace-id"] = traceId ?? errors$1.generateTraceCorrelationId();
|
|
21687
20961
|
return this;
|
|
21688
20962
|
}
|
|
21689
20963
|
/**
|
|
@@ -22990,10 +22264,9 @@ function hasEncryptableFields(requestConfig, config) {
|
|
|
22990
22264
|
return targets.some((target) => hasMatchingFieldsInTarget(target, requestConfig, config));
|
|
22991
22265
|
}
|
|
22992
22266
|
__name(hasEncryptableFields, "hasEncryptableFields");
|
|
22993
|
-
|
|
22994
|
-
// src/api/client/helpers/interceptors.ts
|
|
22995
22267
|
var DEFAULT_MAX_RETRIES = 3;
|
|
22996
22268
|
var DEFAULT_SUCCESS_STATUS = config.HTTP_STATUS.OK;
|
|
22269
|
+
var logger16 = new logger$1.ApiLogger({ service: types.LOGGER_SERVICES.INTERCEPTORS, transport: "console" });
|
|
22997
22270
|
function trackHeaderChanges(beforeHeaders, afterHeaders, interceptorIndex) {
|
|
22998
22271
|
const changes = [];
|
|
22999
22272
|
Object.entries(afterHeaders).forEach(([key, value]) => {
|
|
@@ -23036,7 +22309,7 @@ function createOnRetryHandler(handlers) {
|
|
|
23036
22309
|
return (response, retryAttempt) => {
|
|
23037
22310
|
const performanceFactory = getPerformanceEventFactory();
|
|
23038
22311
|
performanceFactory.emitRetry({
|
|
23039
|
-
requestId: generateRequestId(),
|
|
22312
|
+
requestId: errors$1.generateRequestId(),
|
|
23040
22313
|
attempt: retryAttempt,
|
|
23041
22314
|
maxAttempts: DEFAULT_MAX_RETRIES,
|
|
23042
22315
|
reason: response.error?.message ?? "Retry attempt",
|
|
@@ -23053,10 +22326,30 @@ function createOnRetryHandler(handlers) {
|
|
|
23053
22326
|
};
|
|
23054
22327
|
}
|
|
23055
22328
|
__name(createOnRetryHandler, "createOnRetryHandler");
|
|
23056
|
-
function
|
|
22329
|
+
function normalizeHeaders4(headers2) {
|
|
22330
|
+
const normalized = {};
|
|
22331
|
+
for (const [key, value] of Object.entries(headers2 || {})) {
|
|
22332
|
+
normalized[key.toLowerCase()] = value;
|
|
22333
|
+
}
|
|
22334
|
+
return normalized;
|
|
22335
|
+
}
|
|
22336
|
+
__name(normalizeHeaders4, "normalizeHeaders");
|
|
22337
|
+
function mergeHeadersCaseInsensitive(...headerSets) {
|
|
22338
|
+
const result = {};
|
|
22339
|
+
for (const headers2 of headerSets) {
|
|
22340
|
+
if (!headers2) continue;
|
|
22341
|
+
for (const [key, value] of Object.entries(headers2)) {
|
|
22342
|
+
const normalizedKey = key.toLowerCase();
|
|
22343
|
+
result[normalizedKey] = value;
|
|
22344
|
+
}
|
|
22345
|
+
}
|
|
22346
|
+
return result;
|
|
22347
|
+
}
|
|
22348
|
+
__name(mergeHeadersCaseInsensitive, "mergeHeadersCaseInsensitive");
|
|
22349
|
+
function createOnRequestHandler(handlers, enrichedHeadersConfig, encryptionConfig, configStrategy) {
|
|
23057
22350
|
return async (config) => {
|
|
23058
22351
|
const performanceFactory = getPerformanceEventFactory();
|
|
23059
|
-
const requestId = generateRequestId();
|
|
22352
|
+
const requestId = errors$1.generateRequestId();
|
|
23060
22353
|
startRequestTracking(requestId);
|
|
23061
22354
|
UnifiedDebugger.getInstance().trackConfigChange(
|
|
23062
22355
|
{ headers: config.headers },
|
|
@@ -23077,12 +22370,28 @@ function createOnRequestHandler(handlers, enrichedHeadersConfig, encryptionConfi
|
|
|
23077
22370
|
"enrichedHeaders",
|
|
23078
22371
|
{ requestId }
|
|
23079
22372
|
);
|
|
23080
|
-
|
|
23081
|
-
|
|
23082
|
-
|
|
23083
|
-
|
|
22373
|
+
const strategy = configStrategy;
|
|
22374
|
+
if (strategy === "replace") {
|
|
22375
|
+
processedConfig = {
|
|
22376
|
+
...processedConfig,
|
|
22377
|
+
headers: normalizeHeaders4(enrichedHeaders)
|
|
22378
|
+
};
|
|
22379
|
+
} else {
|
|
22380
|
+
const mergedHeaders = mergeHeadersCaseInsensitive(
|
|
22381
|
+
enrichedHeaders,
|
|
22382
|
+
// Enriched headers (x-correlation-id, x-platform-type, etc.)
|
|
22383
|
+
config.headers
|
|
22384
|
+
// Existing headers (Authorization, Content-Type, etc.) - OVERRIDE enriched
|
|
22385
|
+
);
|
|
22386
|
+
processedConfig = {
|
|
22387
|
+
...processedConfig,
|
|
22388
|
+
headers: mergedHeaders
|
|
22389
|
+
};
|
|
22390
|
+
}
|
|
23084
22391
|
} catch (error) {
|
|
23085
|
-
|
|
22392
|
+
logger16.error("Failed to enrich headers", {
|
|
22393
|
+
error: error instanceof Error ? error.message : String(error)
|
|
22394
|
+
});
|
|
23086
22395
|
}
|
|
23087
22396
|
}
|
|
23088
22397
|
if (encryptionConfig?.enabled) {
|
|
@@ -23092,7 +22401,9 @@ function createOnRequestHandler(handlers, enrichedHeadersConfig, encryptionConfi
|
|
|
23092
22401
|
processedConfig = await encryptionInterceptor(processedConfig);
|
|
23093
22402
|
UnifiedDebugger.getInstance().trackConfigChange({ encryption: "applied" }, "encryption");
|
|
23094
22403
|
} catch (error) {
|
|
23095
|
-
|
|
22404
|
+
logger16.error("Failed to encrypt request", {
|
|
22405
|
+
error: error instanceof Error ? error.message : String(error)
|
|
22406
|
+
});
|
|
23096
22407
|
}
|
|
23097
22408
|
}
|
|
23098
22409
|
if (handlers && handlers.length > 0) {
|
|
@@ -23111,7 +22422,7 @@ function createOnResponseHandler(handlers, clearTemporaryOverrides2, clearOnComp
|
|
|
23111
22422
|
return async (response) => {
|
|
23112
22423
|
const performanceFactory = getPerformanceEventFactory();
|
|
23113
22424
|
performanceFactory.emitRequestComplete({
|
|
23114
|
-
requestId: generateRequestId(),
|
|
22425
|
+
requestId: errors$1.generateRequestId(),
|
|
23115
22426
|
url: response.config?.url ?? "",
|
|
23116
22427
|
method: response.config?.method ?? "GET",
|
|
23117
22428
|
status: response.status ?? DEFAULT_SUCCESS_STATUS,
|
|
@@ -23132,7 +22443,9 @@ function createOnResponseHandler(handlers, clearTemporaryOverrides2, clearOnComp
|
|
|
23132
22443
|
processedResponse = await decryptionInterceptor(processedResponse);
|
|
23133
22444
|
UnifiedDebugger.getInstance().trackConfigChange({ decryption: "applied" }, "encryption");
|
|
23134
22445
|
} catch (error) {
|
|
23135
|
-
|
|
22446
|
+
logger16.error("Failed to decrypt response", {
|
|
22447
|
+
error: error instanceof Error ? error.message : String(error)
|
|
22448
|
+
});
|
|
23136
22449
|
}
|
|
23137
22450
|
}
|
|
23138
22451
|
if (clearOnComplete && clearTemporaryOverrides2) {
|
|
@@ -23146,7 +22459,7 @@ function createOnErrorHandler(handlers, clearTemporaryOverrides2, clearOnComplet
|
|
|
23146
22459
|
return async (error) => {
|
|
23147
22460
|
const performanceFactory = getPerformanceEventFactory();
|
|
23148
22461
|
performanceFactory.emitRequestComplete({
|
|
23149
|
-
requestId: generateRequestId(),
|
|
22462
|
+
requestId: errors$1.generateRequestId(),
|
|
23150
22463
|
url: error.config?.url ?? "",
|
|
23151
22464
|
method: error.config?.method ?? "GET",
|
|
23152
22465
|
status: error.status ?? 0,
|
|
@@ -23229,8 +22542,14 @@ function setupUnifiedHandlers(params) {
|
|
|
23229
22542
|
);
|
|
23230
22543
|
const clearOnComplete = mergedConfig.configOverride?.clearOnComplete ?? globalConfig?.configOverride?.clearOnComplete ?? clientOptions?.configOverride?.clearOnComplete;
|
|
23231
22544
|
const encryptionConfig = mergedConfig.encryption ?? globalConfig?.encryption ?? clientOptions?.encryption;
|
|
22545
|
+
const configStrategy = mergedConfig.configOverride?.strategy ?? clientOptions?.configOverride?.strategy ?? globalConfig?.configOverride?.strategy ?? "merge";
|
|
23232
22546
|
return {
|
|
23233
|
-
onRequest: createOnRequestHandler(
|
|
22547
|
+
onRequest: createOnRequestHandler(
|
|
22548
|
+
mergedOnRequest,
|
|
22549
|
+
enrichedHeadersConfig,
|
|
22550
|
+
encryptionConfig,
|
|
22551
|
+
configStrategy
|
|
22552
|
+
),
|
|
23234
22553
|
onResponse: createOnResponseHandler(
|
|
23235
22554
|
mergedOnResponse,
|
|
23236
22555
|
clearTemporaryOverrides2,
|
|
@@ -23242,13 +22561,12 @@ function setupUnifiedHandlers(params) {
|
|
|
23242
22561
|
};
|
|
23243
22562
|
}
|
|
23244
22563
|
__name(setupUnifiedHandlers, "setupUnifiedHandlers");
|
|
23245
|
-
|
|
23246
|
-
// src/api/client/createApiClient.ts
|
|
23247
22564
|
var ID_GENERATION = {
|
|
23248
22565
|
BASE: 36,
|
|
23249
22566
|
SUBSTR_START: 2,
|
|
23250
22567
|
SUBSTR_LENGTH: 9
|
|
23251
22568
|
};
|
|
22569
|
+
var logger17 = new logger$1.ApiLogger({ service: types.LOGGER_SERVICES.API_CLIENT, transport: "console" });
|
|
23252
22570
|
function applyStrategies(config, options) {
|
|
23253
22571
|
let resolvedConfig = config;
|
|
23254
22572
|
if (options.unifiedStrategy) {
|
|
@@ -23278,12 +22596,11 @@ function applyStrategies(config, options) {
|
|
|
23278
22596
|
);
|
|
23279
22597
|
}
|
|
23280
22598
|
});
|
|
23281
|
-
|
|
23282
|
-
|
|
22599
|
+
logger17.warn("Individual strategies override unified strategy", {
|
|
22600
|
+
unifiedStrategy: options.unifiedStrategy,
|
|
23283
22601
|
individualStrategies,
|
|
23284
|
-
|
|
23285
|
-
|
|
23286
|
-
);
|
|
22602
|
+
conflictsCount: debuggerInstance.getConflicts().length
|
|
22603
|
+
});
|
|
23287
22604
|
}
|
|
23288
22605
|
}
|
|
23289
22606
|
resolvedConfig = applyIndividualStrategies(resolvedConfig, options);
|
|
@@ -23314,12 +22631,12 @@ async function finalizeConfig(resolvedConfig, options) {
|
|
|
23314
22631
|
} catch (error) {
|
|
23315
22632
|
new ApiPackageError(
|
|
23316
22633
|
"headers.processing.failed",
|
|
23317
|
-
|
|
23318
|
-
|
|
22634
|
+
errors.INTERNAL_STATUS_CODES.OPERATION_FAILED,
|
|
22635
|
+
errors.API_ERROR_CODES.HEADERS_ENRICHMENT_FAILED,
|
|
23319
22636
|
{
|
|
23320
22637
|
cause: error instanceof Error ? error : void 0,
|
|
23321
22638
|
context: {
|
|
23322
|
-
operation:
|
|
22639
|
+
operation: errors.COMMON_OPERATIONS.ENRICHMENT,
|
|
23323
22640
|
originalError: error instanceof Error ? error.message : String(error),
|
|
23324
22641
|
i18n: {
|
|
23325
22642
|
error: error instanceof Error ? error.message : String(error)
|
|
@@ -23360,12 +22677,12 @@ __name(applyDefaultOptions, "applyDefaultOptions");
|
|
|
23360
22677
|
function handleClientInitError(error) {
|
|
23361
22678
|
throw new ApiPackageError(
|
|
23362
22679
|
"client.initialization.failed",
|
|
23363
|
-
|
|
23364
|
-
|
|
22680
|
+
errors.INTERNAL_STATUS_CODES.INITIALIZATION_FAILED,
|
|
22681
|
+
errors.API_ERROR_CODES.CLIENT_INITIALIZATION_FAILED,
|
|
23365
22682
|
{
|
|
23366
22683
|
cause: error instanceof Error ? error : void 0,
|
|
23367
22684
|
context: {
|
|
23368
|
-
operation:
|
|
22685
|
+
operation: errors.COMMON_OPERATIONS.INITIALIZATION,
|
|
23369
22686
|
originalError: error instanceof Error ? error.message : String(error),
|
|
23370
22687
|
i18n: {
|
|
23371
22688
|
error: error instanceof Error ? error.message : String(error)
|
|
@@ -23476,7 +22793,9 @@ function analyzeConfigChanges(previousConfig, newConfig, updates) {
|
|
|
23476
22793
|
}
|
|
23477
22794
|
__name(analyzeConfigChanges, "analyzeConfigChanges");
|
|
23478
22795
|
function handleInvalidConfigUpdate(validation, updates, updateOptions) {
|
|
23479
|
-
|
|
22796
|
+
logger17.warn("Invalid configuration update", {
|
|
22797
|
+
errors: validation.errors
|
|
22798
|
+
});
|
|
23480
22799
|
UnifiedDebugger.getInstance().trackEventOperation(
|
|
23481
22800
|
api.EVENT_OPERATIONS.CONFIG_UPDATE_FAILED,
|
|
23482
22801
|
"updateConfig",
|
|
@@ -23551,6 +22870,25 @@ function trackSuccessfulConfigUpdate(params) {
|
|
|
23551
22870
|
);
|
|
23552
22871
|
}
|
|
23553
22872
|
__name(trackSuccessfulConfigUpdate, "trackSuccessfulConfigUpdate");
|
|
22873
|
+
function handleClientErrorSystemConfig(errorConfig) {
|
|
22874
|
+
const alreadyInitialized = errors$1.isErrorSystemInitialized();
|
|
22875
|
+
if (alreadyInitialized) {
|
|
22876
|
+
if (errorConfig.locale) {
|
|
22877
|
+
errors$1.setErrorLocale(errorConfig.locale);
|
|
22878
|
+
}
|
|
22879
|
+
if (errorConfig.additionalCatalogs) {
|
|
22880
|
+
Object.entries(errorConfig.additionalCatalogs).forEach(([locale, catalog]) => {
|
|
22881
|
+
errors$1.addMessageCatalog(locale, catalog, true);
|
|
22882
|
+
});
|
|
22883
|
+
}
|
|
22884
|
+
} else {
|
|
22885
|
+
errors$1.initializeErrorSystem({
|
|
22886
|
+
defaultLocale: errorConfig.locale,
|
|
22887
|
+
additionalCatalogs: errorConfig.additionalCatalogs
|
|
22888
|
+
});
|
|
22889
|
+
}
|
|
22890
|
+
}
|
|
22891
|
+
__name(handleClientErrorSystemConfig, "handleClientErrorSystemConfig");
|
|
23554
22892
|
function createUpdateConfigMethod(initialConfigState, eventManager2, client, setConfigState) {
|
|
23555
22893
|
let configState = initialConfigState;
|
|
23556
22894
|
return (updates, updateOptions) => {
|
|
@@ -23560,6 +22898,9 @@ function createUpdateConfigMethod(initialConfigState, eventManager2, client, set
|
|
|
23560
22898
|
if (updates.tracking) {
|
|
23561
22899
|
applyTrackingConfiguration(updates);
|
|
23562
22900
|
}
|
|
22901
|
+
if (updates.errors) {
|
|
22902
|
+
handleClientErrorSystemConfig(updates.errors);
|
|
22903
|
+
}
|
|
23563
22904
|
const validation = validateConfigUpdate(updates, updateOptions);
|
|
23564
22905
|
if (!validation.valid) {
|
|
23565
22906
|
handleInvalidConfigUpdate(validation, updates, updateOptions);
|
|
@@ -23588,68 +22929,106 @@ function createUpdateConfigMethod(initialConfigState, eventManager2, client, set
|
|
|
23588
22929
|
};
|
|
23589
22930
|
}
|
|
23590
22931
|
__name(createUpdateConfigMethod, "createUpdateConfigMethod");
|
|
23591
|
-
|
|
23592
|
-
|
|
23593
|
-
|
|
23594
|
-
|
|
23595
|
-
|
|
23596
|
-
|
|
23597
|
-
|
|
23598
|
-
|
|
23599
|
-
|
|
22932
|
+
function createFetchffClient(fetchffConfig, effectiveConfig, options, unifiedHandlers) {
|
|
22933
|
+
return fetchff.createApiFetcher({
|
|
22934
|
+
...fetchffConfig,
|
|
22935
|
+
baseURL: effectiveConfig.baseURL ?? options.apiUrl,
|
|
22936
|
+
endpoints,
|
|
22937
|
+
onRequest: unifiedHandlers.onRequest,
|
|
22938
|
+
onResponse: unifiedHandlers.onResponse,
|
|
22939
|
+
onError: unifiedHandlers.onError,
|
|
22940
|
+
onRetry: unifiedHandlers.onRetry
|
|
22941
|
+
});
|
|
22942
|
+
}
|
|
22943
|
+
__name(createFetchffClient, "createFetchffClient");
|
|
22944
|
+
function enhanceClientWithMethods(params) {
|
|
22945
|
+
const {
|
|
22946
|
+
clientWithEvents,
|
|
22947
|
+
stateContainer,
|
|
22948
|
+
eventManager: eventManager2,
|
|
22949
|
+
client,
|
|
22950
|
+
clientId,
|
|
22951
|
+
globalConfig,
|
|
22952
|
+
options
|
|
22953
|
+
} = params;
|
|
22954
|
+
clientWithEvents.updateConfig = createUpdateConfigMethod(
|
|
22955
|
+
stateContainer.current,
|
|
22956
|
+
eventManager2,
|
|
22957
|
+
client,
|
|
22958
|
+
(newState) => {
|
|
22959
|
+
stateContainer.current = newState;
|
|
22960
|
+
}
|
|
22961
|
+
);
|
|
22962
|
+
clientWithEvents.getConfig = createGetConfigMethod(
|
|
22963
|
+
() => stateContainer.current,
|
|
22964
|
+
globalConfig,
|
|
22965
|
+
clientId,
|
|
22966
|
+
options
|
|
22967
|
+
);
|
|
22968
|
+
clientWithEvents.clearTemporaryOverrides = createClearTemporaryOverridesMethod(
|
|
22969
|
+
() => stateContainer.current,
|
|
22970
|
+
(newState) => {
|
|
22971
|
+
stateContainer.current = newState;
|
|
22972
|
+
},
|
|
22973
|
+
client,
|
|
22974
|
+
eventManager2
|
|
22975
|
+
);
|
|
22976
|
+
}
|
|
22977
|
+
__name(enhanceClientWithMethods, "enhanceClientWithMethods");
|
|
22978
|
+
function initializeClientSystems(options) {
|
|
22979
|
+
applyTrackingConfiguration(options);
|
|
22980
|
+
if (options.errors) {
|
|
22981
|
+
handleClientErrorSystemConfig(options.errors);
|
|
22982
|
+
}
|
|
22983
|
+
}
|
|
22984
|
+
__name(initializeClientSystems, "initializeClientSystems");
|
|
22985
|
+
async function createApiClient(options = {}) {
|
|
22986
|
+
try {
|
|
22987
|
+
initializeClientSystems(options);
|
|
22988
|
+
UnifiedDebugger.getInstance().clear();
|
|
22989
|
+
options = applyDefaultOptions(options);
|
|
22990
|
+
const userConfig = createPreservedConfig(options);
|
|
22991
|
+
const resolvedConfig = await processClientConfig(options);
|
|
22992
|
+
const mergedConfig = await finalizeConfig(resolvedConfig, options);
|
|
22993
|
+
void UnifiedDebugger.getInstance().logConflicts();
|
|
23600
22994
|
const globalConfig = getGlobalConfig();
|
|
23601
|
-
|
|
22995
|
+
const stateContainer = {
|
|
22996
|
+
current: createConfigState(mergedConfig)
|
|
22997
|
+
};
|
|
23602
22998
|
if (options.configOverride) {
|
|
23603
|
-
const result = applyConfigOverride(
|
|
23604
|
-
|
|
22999
|
+
const result = applyConfigOverride(stateContainer.current, options.configOverride);
|
|
23000
|
+
stateContainer.current = result.state;
|
|
23605
23001
|
}
|
|
23606
|
-
const effectiveConfig = getEffectiveConfig(
|
|
23002
|
+
const effectiveConfig = getEffectiveConfig(stateContainer.current);
|
|
23607
23003
|
const fetchffConfig = toFetchffConfig(effectiveConfig);
|
|
23608
23004
|
let clearTemporaryOverridesFn;
|
|
23609
23005
|
const unifiedHandlers = setupUnifiedHandlers({
|
|
23610
23006
|
mergedConfig: effectiveConfig,
|
|
23611
|
-
// Use effective config here too
|
|
23612
23007
|
enrichedHeadersConfig: options.enrichedHeaders,
|
|
23613
23008
|
globalConfig,
|
|
23614
23009
|
clientOptions: options,
|
|
23615
23010
|
clearTemporaryOverrides: /* @__PURE__ */ __name(() => clearTemporaryOverridesFn?.(), "clearTemporaryOverrides")
|
|
23616
23011
|
});
|
|
23617
|
-
const client =
|
|
23618
|
-
...fetchffConfig,
|
|
23619
|
-
baseURL: effectiveConfig.baseURL ?? options.url,
|
|
23620
|
-
endpoints,
|
|
23621
|
-
// Use unified handlers that handle both ApiConfig callbacks and event emissions
|
|
23622
|
-
onRequest: unifiedHandlers.onRequest,
|
|
23623
|
-
onResponse: unifiedHandlers.onResponse,
|
|
23624
|
-
onError: unifiedHandlers.onError,
|
|
23625
|
-
onRetry: unifiedHandlers.onRetry
|
|
23626
|
-
});
|
|
23012
|
+
const client = createFetchffClient(fetchffConfig, effectiveConfig, options, unifiedHandlers);
|
|
23627
23013
|
const clientWithEvents = setupClientEvents(client, globalConfig, options);
|
|
23628
23014
|
const { eventManager: eventManager2 } = clientWithEvents;
|
|
23015
|
+
Object.defineProperty(clientWithEvents, "then", {
|
|
23016
|
+
value: void 0,
|
|
23017
|
+
writable: false,
|
|
23018
|
+
enumerable: false,
|
|
23019
|
+
configurable: true
|
|
23020
|
+
});
|
|
23629
23021
|
clearTemporaryOverridesFn = /* @__PURE__ */ __name(() => eventManager2.clearTemporaryOverrides(), "clearTemporaryOverridesFn");
|
|
23630
23022
|
const clientId = emitClientCreatedEvent(effectiveConfig, options);
|
|
23631
|
-
|
|
23632
|
-
|
|
23633
|
-
|
|
23023
|
+
enhanceClientWithMethods({
|
|
23024
|
+
clientWithEvents,
|
|
23025
|
+
stateContainer,
|
|
23026
|
+
eventManager: eventManager2,
|
|
23634
23027
|
client,
|
|
23635
|
-
(newState) => {
|
|
23636
|
-
configState = newState;
|
|
23637
|
-
}
|
|
23638
|
-
);
|
|
23639
|
-
clientWithEvents.getConfig = createGetConfigMethod(
|
|
23640
|
-
() => configState,
|
|
23641
|
-
globalConfig,
|
|
23642
23028
|
clientId,
|
|
23029
|
+
globalConfig,
|
|
23643
23030
|
options
|
|
23644
|
-
);
|
|
23645
|
-
clientWithEvents.clearTemporaryOverrides = createClearTemporaryOverridesMethod(
|
|
23646
|
-
() => configState,
|
|
23647
|
-
(newState) => {
|
|
23648
|
-
configState = newState;
|
|
23649
|
-
},
|
|
23650
|
-
client,
|
|
23651
|
-
eventManager2
|
|
23652
|
-
);
|
|
23031
|
+
});
|
|
23653
23032
|
if (options.networkAware?.enabled) {
|
|
23654
23033
|
setupNetworkMonitoring(clientWithEvents, options, userConfig);
|
|
23655
23034
|
}
|
|
@@ -23724,18 +23103,13 @@ function createApiQuery(serviceFn, defaultOptions) {
|
|
|
23724
23103
|
__name(createApiQuery, "createApiQuery");
|
|
23725
23104
|
function createApiMutation(serviceFn, defaultOptions) {
|
|
23726
23105
|
return /* @__PURE__ */ __name(function useApiMutation(serviceOptions, mutationOptions) {
|
|
23727
|
-
const mergedMutationOptions = deepMerge(
|
|
23728
|
-
|
|
23729
|
-
|
|
23730
|
-
|
|
23731
|
-
|
|
23732
|
-
|
|
23733
|
-
|
|
23734
|
-
if (response.error) throw response.error;
|
|
23735
|
-
return response.data;
|
|
23736
|
-
}, "mutationFn")
|
|
23737
|
-
}
|
|
23738
|
-
);
|
|
23106
|
+
const mergedMutationOptions = deepMerge(DEFAULT_MUTATION_OPTIONS, defaultOptions ?? {}, mutationOptions ?? {}, {
|
|
23107
|
+
mutationFn: /* @__PURE__ */ __name(async (variables) => {
|
|
23108
|
+
const response = await serviceFn(variables, serviceOptions);
|
|
23109
|
+
if (response.error) throw response.error;
|
|
23110
|
+
return response.data;
|
|
23111
|
+
}, "mutationFn")
|
|
23112
|
+
});
|
|
23739
23113
|
return reactQuery.useMutation(
|
|
23740
23114
|
mergedMutationOptions
|
|
23741
23115
|
);
|
|
@@ -24181,6 +23555,10 @@ function getEnhancedClientHints(headers2, options) {
|
|
|
24181
23555
|
return response;
|
|
24182
23556
|
}
|
|
24183
23557
|
__name(getEnhancedClientHints, "getEnhancedClientHints");
|
|
23558
|
+
var logger18 = new logger$1.ApiLogger({
|
|
23559
|
+
service: types.LOGGER_SERVICES.NETWORK_CONFIGURATION,
|
|
23560
|
+
transport: "console"
|
|
23561
|
+
});
|
|
24184
23562
|
var NetworkConfigurationManager = class {
|
|
24185
23563
|
static {
|
|
24186
23564
|
__name(this, "NetworkConfigurationManager");
|
|
@@ -24246,9 +23624,11 @@ var NetworkConfigurationManager = class {
|
|
|
24246
23624
|
*/
|
|
24247
23625
|
registerPreset(preset) {
|
|
24248
23626
|
this.availablePresets.set(preset.id, preset);
|
|
24249
|
-
|
|
24250
|
-
|
|
24251
|
-
|
|
23627
|
+
logger18.info("Network preset registered", {
|
|
23628
|
+
presetName: preset.name,
|
|
23629
|
+
presetId: preset.id,
|
|
23630
|
+
targetQuality: preset.targetQuality
|
|
23631
|
+
});
|
|
24252
23632
|
}
|
|
24253
23633
|
/**
|
|
24254
23634
|
* Get all available presets
|
|
@@ -24424,7 +23804,7 @@ var NetworkConfigurationManager = class {
|
|
|
24424
23804
|
}
|
|
24425
23805
|
});
|
|
24426
23806
|
this.cleanupFunctions.push(unsubscribe);
|
|
24427
|
-
|
|
23807
|
+
logger18.info("Auto preset switching enabled");
|
|
24428
23808
|
}
|
|
24429
23809
|
/**
|
|
24430
23810
|
* Disable automatic preset monitoring
|
|
@@ -24433,7 +23813,7 @@ var NetworkConfigurationManager = class {
|
|
|
24433
23813
|
this.monitoringEnabled = false;
|
|
24434
23814
|
this.cleanupFunctions.forEach((cleanup) => cleanup());
|
|
24435
23815
|
this.cleanupFunctions = [];
|
|
24436
|
-
|
|
23816
|
+
logger18.info("Auto preset switching disabled");
|
|
24437
23817
|
}
|
|
24438
23818
|
/**
|
|
24439
23819
|
* Get current active overrides for debugging
|
|
@@ -24447,7 +23827,7 @@ var NetworkConfigurationManager = class {
|
|
|
24447
23827
|
restoreAllOverrides() {
|
|
24448
23828
|
const overrides = Array.from(this.activeOverrides.values());
|
|
24449
23829
|
overrides.forEach((override) => override.restore());
|
|
24450
|
-
|
|
23830
|
+
logger18.info("Restored temporary overrides", { count: overrides.length });
|
|
24451
23831
|
}
|
|
24452
23832
|
/**
|
|
24453
23833
|
* Get configuration manager stats for debugging
|
|
@@ -24699,7 +24079,7 @@ var NetworkConfigurationManager = class {
|
|
|
24699
24079
|
changes.push("caching");
|
|
24700
24080
|
}
|
|
24701
24081
|
if (changes.length > 0) {
|
|
24702
|
-
|
|
24082
|
+
logger18.info("User preferences updated", { changes });
|
|
24703
24083
|
}
|
|
24704
24084
|
}
|
|
24705
24085
|
/**
|
|
@@ -25206,7 +24586,7 @@ function useOptimisticUpdate(key, initialData) {
|
|
|
25206
24586
|
const nextState = {
|
|
25207
24587
|
data: response.data,
|
|
25208
24588
|
isValidating: response.isFetching ?? false,
|
|
25209
|
-
error: response.error
|
|
24589
|
+
error: response.error
|
|
25210
24590
|
};
|
|
25211
24591
|
setState(nextState);
|
|
25212
24592
|
});
|
|
@@ -25683,6 +25063,355 @@ function useDeleteCampaign(serviceOptions, mutationOptions) {
|
|
|
25683
25063
|
})(serviceOptions, mutationOptions);
|
|
25684
25064
|
}
|
|
25685
25065
|
__name(useDeleteCampaign, "useDeleteCampaign");
|
|
25066
|
+
async function sendInfobipEmail(payload, options) {
|
|
25067
|
+
const client = options?.apiClient ?? getDefaultApiClient();
|
|
25068
|
+
if (!payload.from) {
|
|
25069
|
+
throw new ApiPackageError(
|
|
25070
|
+
"Missing required field: from",
|
|
25071
|
+
void 0,
|
|
25072
|
+
api.API_ERROR_CODES.REQUIRED_FIELD_MISSING
|
|
25073
|
+
);
|
|
25074
|
+
}
|
|
25075
|
+
if (!payload.to) {
|
|
25076
|
+
throw new ApiPackageError(
|
|
25077
|
+
"Missing required field: to",
|
|
25078
|
+
void 0,
|
|
25079
|
+
api.API_ERROR_CODES.REQUIRED_FIELD_MISSING
|
|
25080
|
+
);
|
|
25081
|
+
}
|
|
25082
|
+
if (!payload.subject) {
|
|
25083
|
+
throw new ApiPackageError(
|
|
25084
|
+
"Missing required field: subject",
|
|
25085
|
+
void 0,
|
|
25086
|
+
api.API_ERROR_CODES.REQUIRED_FIELD_MISSING
|
|
25087
|
+
);
|
|
25088
|
+
}
|
|
25089
|
+
const serviceDefaults = {
|
|
25090
|
+
retry: { attempts: 0 },
|
|
25091
|
+
timeout: 15e3
|
|
25092
|
+
// 15 second timeout for email sends
|
|
25093
|
+
};
|
|
25094
|
+
const mergedConfig = mergeConfigs(serviceDefaults, options?.apiConfig ?? {});
|
|
25095
|
+
const updateOptions = {
|
|
25096
|
+
strategy: "temporary",
|
|
25097
|
+
...options?.updateConfigOptions
|
|
25098
|
+
};
|
|
25099
|
+
if (shouldApplyConfig(mergedConfig, updateOptions)) {
|
|
25100
|
+
client.updateConfig(mergedConfig, updateOptions);
|
|
25101
|
+
}
|
|
25102
|
+
return client.sendEmail({
|
|
25103
|
+
body: payload
|
|
25104
|
+
});
|
|
25105
|
+
}
|
|
25106
|
+
__name(sendInfobipEmail, "sendInfobipEmail");
|
|
25107
|
+
async function sendInfobipAdvancedEmail(payload, options) {
|
|
25108
|
+
const client = options?.apiClient ?? getDefaultApiClient();
|
|
25109
|
+
if (!payload.messages || payload.messages.length === 0) {
|
|
25110
|
+
throw new ApiPackageError(
|
|
25111
|
+
"Missing required field: messages (must be a non-empty array)",
|
|
25112
|
+
void 0,
|
|
25113
|
+
api.API_ERROR_CODES.REQUIRED_FIELD_MISSING
|
|
25114
|
+
);
|
|
25115
|
+
}
|
|
25116
|
+
for (const [index, message] of payload.messages.entries()) {
|
|
25117
|
+
if (!message.sender) {
|
|
25118
|
+
throw new ApiPackageError(
|
|
25119
|
+
`Missing required field: messages[${index}].sender`,
|
|
25120
|
+
void 0,
|
|
25121
|
+
api.API_ERROR_CODES.REQUIRED_FIELD_MISSING
|
|
25122
|
+
);
|
|
25123
|
+
}
|
|
25124
|
+
if (!message.destinations || message.destinations.length === 0) {
|
|
25125
|
+
throw new ApiPackageError(
|
|
25126
|
+
`Missing required field: messages[${index}].destinations (must be a non-empty array)`,
|
|
25127
|
+
void 0,
|
|
25128
|
+
api.API_ERROR_CODES.REQUIRED_FIELD_MISSING
|
|
25129
|
+
);
|
|
25130
|
+
}
|
|
25131
|
+
if (!message.content?.subject) {
|
|
25132
|
+
throw new ApiPackageError(
|
|
25133
|
+
`Missing required field: messages[${index}].content.subject`,
|
|
25134
|
+
void 0,
|
|
25135
|
+
api.API_ERROR_CODES.REQUIRED_FIELD_MISSING
|
|
25136
|
+
);
|
|
25137
|
+
}
|
|
25138
|
+
}
|
|
25139
|
+
const serviceDefaults = {
|
|
25140
|
+
retry: { attempts: 0 },
|
|
25141
|
+
timeout: 15e3
|
|
25142
|
+
// 15 second timeout for email sends
|
|
25143
|
+
};
|
|
25144
|
+
const mergedConfig = mergeConfigs(serviceDefaults, options?.apiConfig ?? {});
|
|
25145
|
+
const updateOptions = {
|
|
25146
|
+
strategy: "temporary",
|
|
25147
|
+
...options?.updateConfigOptions
|
|
25148
|
+
};
|
|
25149
|
+
if (shouldApplyConfig(mergedConfig, updateOptions)) {
|
|
25150
|
+
client.updateConfig(mergedConfig, updateOptions);
|
|
25151
|
+
}
|
|
25152
|
+
return client.sendAdvancedEmail({
|
|
25153
|
+
body: payload
|
|
25154
|
+
});
|
|
25155
|
+
}
|
|
25156
|
+
__name(sendInfobipAdvancedEmail, "sendInfobipAdvancedEmail");
|
|
25157
|
+
async function validateInfobipEmail(email, options) {
|
|
25158
|
+
const client = options?.apiClient ?? getDefaultApiClient();
|
|
25159
|
+
const payload = typeof email === "string" ? { to: email } : email;
|
|
25160
|
+
if (!payload?.to) {
|
|
25161
|
+
throw new ApiPackageError(
|
|
25162
|
+
"Missing required field: to (email address)",
|
|
25163
|
+
void 0,
|
|
25164
|
+
api.API_ERROR_CODES.REQUIRED_FIELD_MISSING
|
|
25165
|
+
);
|
|
25166
|
+
}
|
|
25167
|
+
if (!payload.to.includes("@")) {
|
|
25168
|
+
throw new ApiPackageError(
|
|
25169
|
+
"Invalid email format: must contain @",
|
|
25170
|
+
void 0,
|
|
25171
|
+
api.API_ERROR_CODES.INVALID_FORMAT
|
|
25172
|
+
);
|
|
25173
|
+
}
|
|
25174
|
+
const serviceDefaults = {
|
|
25175
|
+
retry: { attempts: 2, delay: 500 },
|
|
25176
|
+
cacheTime: 300,
|
|
25177
|
+
// Cache validation results for 5 minutes
|
|
25178
|
+
staleTime: 600,
|
|
25179
|
+
// Consider stale after 10 minutes
|
|
25180
|
+
timeout: 5e3
|
|
25181
|
+
// 5 second timeout
|
|
25182
|
+
};
|
|
25183
|
+
const mergedConfig = mergeConfigs(serviceDefaults, options?.apiConfig ?? {});
|
|
25184
|
+
const updateOptions = {
|
|
25185
|
+
strategy: "temporary",
|
|
25186
|
+
...options?.updateConfigOptions
|
|
25187
|
+
};
|
|
25188
|
+
if (shouldApplyConfig(mergedConfig, updateOptions)) {
|
|
25189
|
+
client.updateConfig(mergedConfig, updateOptions);
|
|
25190
|
+
}
|
|
25191
|
+
return client.validateEmail({
|
|
25192
|
+
body: payload
|
|
25193
|
+
});
|
|
25194
|
+
}
|
|
25195
|
+
__name(validateInfobipEmail, "validateInfobipEmail");
|
|
25196
|
+
async function bulkValidateInfobipEmails(payload, options) {
|
|
25197
|
+
const client = options?.apiClient ?? getDefaultApiClient();
|
|
25198
|
+
const MAX_BULK_EMAIL_VALIDATION_SIZE = 1e4;
|
|
25199
|
+
if (!payload.destinations || payload.destinations.length === 0) {
|
|
25200
|
+
throw new ApiPackageError(
|
|
25201
|
+
"Missing required field: destinations (must be a non-empty array)",
|
|
25202
|
+
void 0,
|
|
25203
|
+
api.API_ERROR_CODES.REQUIRED_FIELD_MISSING
|
|
25204
|
+
);
|
|
25205
|
+
}
|
|
25206
|
+
if (payload.destinations.length > MAX_BULK_EMAIL_VALIDATION_SIZE) {
|
|
25207
|
+
throw new ApiPackageError(
|
|
25208
|
+
`Too many email addresses: maximum ${MAX_BULK_EMAIL_VALIDATION_SIZE} per request`,
|
|
25209
|
+
void 0,
|
|
25210
|
+
api.API_ERROR_CODES.INVALID_FORMAT
|
|
25211
|
+
);
|
|
25212
|
+
}
|
|
25213
|
+
const serviceDefaults = {
|
|
25214
|
+
retry: { attempts: 0 },
|
|
25215
|
+
// Don't retry bulk validation requests
|
|
25216
|
+
timeout: 3e4
|
|
25217
|
+
// 30 second timeout for bulk operations
|
|
25218
|
+
};
|
|
25219
|
+
const mergedConfig = mergeConfigs(serviceDefaults, options?.apiConfig ?? {});
|
|
25220
|
+
const updateOptions = {
|
|
25221
|
+
strategy: "temporary",
|
|
25222
|
+
...options?.updateConfigOptions
|
|
25223
|
+
};
|
|
25224
|
+
if (shouldApplyConfig(mergedConfig, updateOptions)) {
|
|
25225
|
+
client.updateConfig(mergedConfig, updateOptions);
|
|
25226
|
+
}
|
|
25227
|
+
return client.bulkValidateEmails({
|
|
25228
|
+
body: payload
|
|
25229
|
+
});
|
|
25230
|
+
}
|
|
25231
|
+
__name(bulkValidateInfobipEmails, "bulkValidateInfobipEmails");
|
|
25232
|
+
|
|
25233
|
+
// src/api/services/infobip/email/GET/fetchEmailReports.ts
|
|
25234
|
+
async function fetchInfobipEmailReports(params, options) {
|
|
25235
|
+
const client = options?.apiClient ?? getDefaultApiClient();
|
|
25236
|
+
const serviceDefaults = {
|
|
25237
|
+
cacheTime: 30,
|
|
25238
|
+
// Cache for 30 seconds
|
|
25239
|
+
staleTime: 60,
|
|
25240
|
+
// Consider stale after 1 minute
|
|
25241
|
+
timeout: 1e4
|
|
25242
|
+
// 10 second timeout
|
|
25243
|
+
};
|
|
25244
|
+
const mergedConfig = mergeConfigs(serviceDefaults, options?.apiConfig ?? {});
|
|
25245
|
+
const updateOptions = {
|
|
25246
|
+
strategy: "temporary",
|
|
25247
|
+
...options?.updateConfigOptions
|
|
25248
|
+
};
|
|
25249
|
+
if (shouldApplyConfig(mergedConfig, updateOptions)) {
|
|
25250
|
+
client.updateConfig(mergedConfig, updateOptions);
|
|
25251
|
+
}
|
|
25252
|
+
return client.getEmailReports({
|
|
25253
|
+
params
|
|
25254
|
+
});
|
|
25255
|
+
}
|
|
25256
|
+
__name(fetchInfobipEmailReports, "fetchInfobipEmailReports");
|
|
25257
|
+
|
|
25258
|
+
// src/api/services/infobip/email/GET/fetchEmailLogs.ts
|
|
25259
|
+
async function fetchInfobipEmailLogs(params, options) {
|
|
25260
|
+
const client = options?.apiClient ?? getDefaultApiClient();
|
|
25261
|
+
const serviceDefaults = {
|
|
25262
|
+
cacheTime: 60,
|
|
25263
|
+
// Cache for 1 minute
|
|
25264
|
+
staleTime: 120,
|
|
25265
|
+
// Consider stale after 2 minutes
|
|
25266
|
+
timeout: 1e4
|
|
25267
|
+
// 10 second timeout
|
|
25268
|
+
};
|
|
25269
|
+
const mergedConfig = mergeConfigs(serviceDefaults, options?.apiConfig ?? {});
|
|
25270
|
+
const updateOptions = {
|
|
25271
|
+
strategy: "temporary",
|
|
25272
|
+
...options?.updateConfigOptions
|
|
25273
|
+
};
|
|
25274
|
+
if (shouldApplyConfig(mergedConfig, updateOptions)) {
|
|
25275
|
+
client.updateConfig(mergedConfig, updateOptions);
|
|
25276
|
+
}
|
|
25277
|
+
return client.getEmailLogs({
|
|
25278
|
+
params
|
|
25279
|
+
});
|
|
25280
|
+
}
|
|
25281
|
+
__name(fetchInfobipEmailLogs, "fetchInfobipEmailLogs");
|
|
25282
|
+
|
|
25283
|
+
// src/api/services/infobip/email/GET/fetchScheduledEmails.ts
|
|
25284
|
+
async function fetchInfobipScheduledEmails(params, options) {
|
|
25285
|
+
const client = options?.apiClient ?? getDefaultApiClient();
|
|
25286
|
+
const serviceDefaults = {
|
|
25287
|
+
retry: { attempts: 2, delay: 500 },
|
|
25288
|
+
cacheTime: 30,
|
|
25289
|
+
staleTime: 60,
|
|
25290
|
+
timeout: 1e4
|
|
25291
|
+
};
|
|
25292
|
+
const mergedConfig = mergeConfigs(serviceDefaults, options?.apiConfig ?? {});
|
|
25293
|
+
const updateOptions = {
|
|
25294
|
+
strategy: "temporary",
|
|
25295
|
+
...options?.updateConfigOptions
|
|
25296
|
+
};
|
|
25297
|
+
if (shouldApplyConfig(mergedConfig, updateOptions)) {
|
|
25298
|
+
client.updateConfig(mergedConfig, updateOptions);
|
|
25299
|
+
}
|
|
25300
|
+
return client.getScheduledEmails({
|
|
25301
|
+
params
|
|
25302
|
+
});
|
|
25303
|
+
}
|
|
25304
|
+
__name(fetchInfobipScheduledEmails, "fetchInfobipScheduledEmails");
|
|
25305
|
+
|
|
25306
|
+
// src/api/services/infobip/email/GET/fetchScheduledEmailStatuses.ts
|
|
25307
|
+
async function fetchInfobipScheduledEmailStatuses(params, options) {
|
|
25308
|
+
const client = options?.apiClient ?? getDefaultApiClient();
|
|
25309
|
+
const serviceDefaults = {
|
|
25310
|
+
retry: { attempts: 2, delay: 500 },
|
|
25311
|
+
cacheTime: 30,
|
|
25312
|
+
staleTime: 60,
|
|
25313
|
+
timeout: 1e4
|
|
25314
|
+
};
|
|
25315
|
+
const mergedConfig = mergeConfigs(serviceDefaults, options?.apiConfig ?? {});
|
|
25316
|
+
const updateOptions = {
|
|
25317
|
+
strategy: "temporary",
|
|
25318
|
+
...options?.updateConfigOptions
|
|
25319
|
+
};
|
|
25320
|
+
if (shouldApplyConfig(mergedConfig, updateOptions)) {
|
|
25321
|
+
client.updateConfig(mergedConfig, updateOptions);
|
|
25322
|
+
}
|
|
25323
|
+
return client.getScheduledEmailStatuses({
|
|
25324
|
+
params
|
|
25325
|
+
});
|
|
25326
|
+
}
|
|
25327
|
+
__name(fetchInfobipScheduledEmailStatuses, "fetchInfobipScheduledEmailStatuses");
|
|
25328
|
+
|
|
25329
|
+
// src/api/services/infobip/email/GET/fetchValidations.ts
|
|
25330
|
+
async function fetchInfobipValidations(params, options) {
|
|
25331
|
+
const client = options?.apiClient ?? getDefaultApiClient();
|
|
25332
|
+
const serviceDefaults = {
|
|
25333
|
+
retry: { attempts: 2, delay: 500 },
|
|
25334
|
+
cacheTime: 60,
|
|
25335
|
+
// Cache results for 1 minute
|
|
25336
|
+
staleTime: 120,
|
|
25337
|
+
// Consider stale after 2 minutes
|
|
25338
|
+
timeout: 1e4
|
|
25339
|
+
// 10 second timeout
|
|
25340
|
+
};
|
|
25341
|
+
const mergedConfig = mergeConfigs(serviceDefaults, options?.apiConfig ?? {});
|
|
25342
|
+
const updateOptions = {
|
|
25343
|
+
strategy: "temporary",
|
|
25344
|
+
...options?.updateConfigOptions
|
|
25345
|
+
};
|
|
25346
|
+
if (shouldApplyConfig(mergedConfig, updateOptions)) {
|
|
25347
|
+
client.updateConfig(mergedConfig, updateOptions);
|
|
25348
|
+
}
|
|
25349
|
+
return client.getValidations({
|
|
25350
|
+
params
|
|
25351
|
+
});
|
|
25352
|
+
}
|
|
25353
|
+
__name(fetchInfobipValidations, "fetchInfobipValidations");
|
|
25354
|
+
async function rescheduleInfobipEmails(params, payload, options) {
|
|
25355
|
+
const client = options?.apiClient ?? getDefaultApiClient();
|
|
25356
|
+
if (!payload.sendAt) {
|
|
25357
|
+
throw new ApiPackageError(
|
|
25358
|
+
"Missing required field: sendAt",
|
|
25359
|
+
void 0,
|
|
25360
|
+
api.API_ERROR_CODES.REQUIRED_FIELD_MISSING
|
|
25361
|
+
);
|
|
25362
|
+
}
|
|
25363
|
+
const serviceDefaults = {
|
|
25364
|
+
retry: { attempts: 1 },
|
|
25365
|
+
timeout: 1e4
|
|
25366
|
+
};
|
|
25367
|
+
const mergedConfig = mergeConfigs(serviceDefaults, options?.apiConfig ?? {});
|
|
25368
|
+
const updateOptions = {
|
|
25369
|
+
strategy: "temporary",
|
|
25370
|
+
...options?.updateConfigOptions
|
|
25371
|
+
};
|
|
25372
|
+
if (shouldApplyConfig(mergedConfig, updateOptions)) {
|
|
25373
|
+
client.updateConfig(mergedConfig, updateOptions);
|
|
25374
|
+
}
|
|
25375
|
+
return client.rescheduleEmails({
|
|
25376
|
+
params,
|
|
25377
|
+
body: payload
|
|
25378
|
+
});
|
|
25379
|
+
}
|
|
25380
|
+
__name(rescheduleInfobipEmails, "rescheduleInfobipEmails");
|
|
25381
|
+
async function updateInfobipScheduledEmailStatuses(params, payload, options) {
|
|
25382
|
+
const client = options?.apiClient ?? getDefaultApiClient();
|
|
25383
|
+
if (!payload.status) {
|
|
25384
|
+
throw new ApiPackageError(
|
|
25385
|
+
"Missing required field: status",
|
|
25386
|
+
void 0,
|
|
25387
|
+
api.API_ERROR_CODES.REQUIRED_FIELD_MISSING
|
|
25388
|
+
);
|
|
25389
|
+
}
|
|
25390
|
+
if (payload.status !== "PAUSED" && payload.status !== "PROCESSING") {
|
|
25391
|
+
throw new ApiPackageError(
|
|
25392
|
+
"Invalid status: must be PAUSED or PROCESSING",
|
|
25393
|
+
void 0,
|
|
25394
|
+
api.API_ERROR_CODES.INVALID_FORMAT
|
|
25395
|
+
);
|
|
25396
|
+
}
|
|
25397
|
+
const serviceDefaults = {
|
|
25398
|
+
retry: { attempts: 1 },
|
|
25399
|
+
timeout: 1e4
|
|
25400
|
+
};
|
|
25401
|
+
const mergedConfig = mergeConfigs(serviceDefaults, options?.apiConfig ?? {});
|
|
25402
|
+
const updateOptions = {
|
|
25403
|
+
strategy: "temporary",
|
|
25404
|
+
...options?.updateConfigOptions
|
|
25405
|
+
};
|
|
25406
|
+
if (shouldApplyConfig(mergedConfig, updateOptions)) {
|
|
25407
|
+
client.updateConfig(mergedConfig, updateOptions);
|
|
25408
|
+
}
|
|
25409
|
+
return client.updateScheduledEmailStatuses({
|
|
25410
|
+
params,
|
|
25411
|
+
body: payload
|
|
25412
|
+
});
|
|
25413
|
+
}
|
|
25414
|
+
__name(updateInfobipScheduledEmailStatuses, "updateInfobipScheduledEmailStatuses");
|
|
25686
25415
|
function getSSRSafeConfig(config) {
|
|
25687
25416
|
if (!isBrowser()) {
|
|
25688
25417
|
return {
|
|
@@ -25900,17 +25629,29 @@ __name(toFetchffRevalidationConfig, "toFetchffRevalidationConfig");
|
|
|
25900
25629
|
resources: revalidationStrategies.static
|
|
25901
25630
|
});
|
|
25902
25631
|
|
|
25903
|
-
Object.defineProperty(exports, "
|
|
25632
|
+
Object.defineProperty(exports, "getErrorCategory", {
|
|
25904
25633
|
enumerable: true,
|
|
25905
|
-
get: function () { return
|
|
25634
|
+
get: function () { return errors$1.getErrorCategory; }
|
|
25906
25635
|
});
|
|
25907
|
-
Object.defineProperty(exports, "
|
|
25636
|
+
Object.defineProperty(exports, "getErrorCodeByStatus", {
|
|
25908
25637
|
enumerable: true,
|
|
25909
|
-
get: function () { return
|
|
25638
|
+
get: function () { return errors$1.getErrorCodeByStatus; }
|
|
25910
25639
|
});
|
|
25911
|
-
Object.defineProperty(exports, "
|
|
25640
|
+
Object.defineProperty(exports, "getErrorDefinition", {
|
|
25912
25641
|
enumerable: true,
|
|
25913
|
-
get: function () { return
|
|
25642
|
+
get: function () { return errors$1.getErrorDefinition; }
|
|
25643
|
+
});
|
|
25644
|
+
Object.defineProperty(exports, "removeRevalidators", {
|
|
25645
|
+
enumerable: true,
|
|
25646
|
+
get: function () { return fetchff.removeRevalidators; }
|
|
25647
|
+
});
|
|
25648
|
+
Object.defineProperty(exports, "revalidate", {
|
|
25649
|
+
enumerable: true,
|
|
25650
|
+
get: function () { return fetchff.revalidate; }
|
|
25651
|
+
});
|
|
25652
|
+
Object.defineProperty(exports, "revalidateAll", {
|
|
25653
|
+
enumerable: true,
|
|
25654
|
+
get: function () { return fetchff.revalidateAll; }
|
|
25914
25655
|
});
|
|
25915
25656
|
Object.defineProperty(exports, "NETWORK_QUALITY", {
|
|
25916
25657
|
enumerable: true,
|
|
@@ -25920,17 +25661,25 @@ Object.defineProperty(exports, "PUB_SUB_EVENT", {
|
|
|
25920
25661
|
enumerable: true,
|
|
25921
25662
|
get: function () { return api.PUB_SUB_EVENT; }
|
|
25922
25663
|
});
|
|
25923
|
-
Object.defineProperty(exports, "
|
|
25664
|
+
Object.defineProperty(exports, "API_ERROR_CODES", {
|
|
25924
25665
|
enumerable: true,
|
|
25925
|
-
get: function () { return
|
|
25666
|
+
get: function () { return errors.API_ERROR_CODES; }
|
|
25926
25667
|
});
|
|
25927
|
-
Object.defineProperty(exports, "
|
|
25668
|
+
Object.defineProperty(exports, "ERROR_DEFINITIONS", {
|
|
25928
25669
|
enumerable: true,
|
|
25929
|
-
get: function () { return
|
|
25670
|
+
get: function () { return errors.ERROR_DEFINITIONS; }
|
|
25930
25671
|
});
|
|
25931
|
-
Object.defineProperty(exports, "
|
|
25672
|
+
Object.defineProperty(exports, "ERROR_FIELDS", {
|
|
25932
25673
|
enumerable: true,
|
|
25933
|
-
get: function () { return
|
|
25674
|
+
get: function () { return errors.COMMON_FIELDS; }
|
|
25675
|
+
});
|
|
25676
|
+
Object.defineProperty(exports, "OPERATIONS", {
|
|
25677
|
+
enumerable: true,
|
|
25678
|
+
get: function () { return errors.COMMON_OPERATIONS; }
|
|
25679
|
+
});
|
|
25680
|
+
Object.defineProperty(exports, "STORAGE_TYPES", {
|
|
25681
|
+
enumerable: true,
|
|
25682
|
+
get: function () { return errors.COMMON_STORAGE_TYPES; }
|
|
25934
25683
|
});
|
|
25935
25684
|
exports.ALL_EVENTS = ALL_EVENTS;
|
|
25936
25685
|
exports.ApiPackageError = ApiPackageError;
|
|
@@ -25942,8 +25691,8 @@ exports.ConfigBuilder = ConfigBuilder;
|
|
|
25942
25691
|
exports.DEBUG_EVENTS = DEBUG_EVENTS2;
|
|
25943
25692
|
exports.ERROR_EVENTS = ERROR_EVENTS2;
|
|
25944
25693
|
exports.EVENT_NAMESPACES = EVENT_NAMESPACES2;
|
|
25945
|
-
exports.EVENT_SCOPES =
|
|
25946
|
-
exports.EVENT_SCOPES_WITH_TEMPORARY =
|
|
25694
|
+
exports.EVENT_SCOPES = EVENT_SCOPES;
|
|
25695
|
+
exports.EVENT_SCOPES_WITH_TEMPORARY = EVENT_SCOPES_WITH_TEMPORARY2;
|
|
25947
25696
|
exports.Environment = Environment;
|
|
25948
25697
|
exports.EventHelpers = EventHelpers;
|
|
25949
25698
|
exports.EventManager = EventManager;
|
|
@@ -25998,6 +25747,7 @@ exports.buildCacheKey = buildCacheKey;
|
|
|
25998
25747
|
exports.buildEndpointUrl = buildEndpointUrl;
|
|
25999
25748
|
exports.buildFullUrl = buildFullUrl;
|
|
26000
25749
|
exports.buildUrl = buildUrl;
|
|
25750
|
+
exports.bulkValidateInfobipEmails = bulkValidateInfobipEmails;
|
|
26001
25751
|
exports.bytesToBase64 = bytesToBase64;
|
|
26002
25752
|
exports.cacheKeyPatterns = cacheKeyPatterns;
|
|
26003
25753
|
exports.cacheStrategies = cacheStrategies;
|
|
@@ -26032,7 +25782,6 @@ exports.createConfigBuilder = createConfigBuilder;
|
|
|
26032
25782
|
exports.createConfigHistoryEntry = createConfigHistoryEntry;
|
|
26033
25783
|
exports.createConfigState = createConfigState;
|
|
26034
25784
|
exports.createConflict = createConflict;
|
|
26035
|
-
exports.createCorrelationIdGenerator = createCorrelationIdGenerator;
|
|
26036
25785
|
exports.createCustomPreset = createCustomPreset;
|
|
26037
25786
|
exports.createCustomUnifiedStrategy = createCustomUnifiedStrategy;
|
|
26038
25787
|
exports.createDate = createDate;
|
|
@@ -26045,7 +25794,6 @@ exports.createEncryptionInterceptors = createEncryptionInterceptors;
|
|
|
26045
25794
|
exports.createEventEmitter = createEventEmitter;
|
|
26046
25795
|
exports.createHistoryEntry = createHistoryEntry;
|
|
26047
25796
|
exports.createHistorySummary = createHistorySummary;
|
|
26048
|
-
exports.createIdGenerator = createIdGenerator;
|
|
26049
25797
|
exports.createLimitedInterval = createLimitedInterval;
|
|
26050
25798
|
exports.createManagedInterval = createManagedInterval;
|
|
26051
25799
|
exports.createNetworkDetectionMiddleware = createNetworkDetectionMiddleware;
|
|
@@ -26054,7 +25802,6 @@ exports.createPerformanceBenchmark = createPerformanceBenchmark;
|
|
|
26054
25802
|
exports.createPollingStrategy = createPollingStrategy;
|
|
26055
25803
|
exports.createPreservedConfig = createPreservedConfig;
|
|
26056
25804
|
exports.createProgressivePolling = createProgressivePolling;
|
|
26057
|
-
exports.createRequestIdGenerator = createRequestIdGenerator;
|
|
26058
25805
|
exports.createRetryConfig = createRetryConfig;
|
|
26059
25806
|
exports.createRetryStrategy = createRetryStrategy;
|
|
26060
25807
|
exports.createRevalidationKey = createRevalidationKey;
|
|
@@ -26087,17 +25834,17 @@ exports.endpoints = endpoints;
|
|
|
26087
25834
|
exports.eventManager = eventManager;
|
|
26088
25835
|
exports.exportKeyToBase64 = exportKeyToBase64;
|
|
26089
25836
|
exports.extendRevalidationPresets = extendPresets;
|
|
26090
|
-
exports.extractBaseCorrelationId = extractBaseCorrelationId;
|
|
26091
|
-
exports.extractBaseId = extractBaseId;
|
|
26092
|
-
exports.extractBaseRequestId = extractBaseRequestId;
|
|
26093
|
-
exports.extractCorrelationType = extractCorrelationType;
|
|
26094
25837
|
exports.extractFields = extractFields;
|
|
26095
|
-
exports.extractLinkedCorrelationIds = extractLinkedCorrelationIds;
|
|
26096
25838
|
exports.extractUrlParams = extractUrlParams;
|
|
26097
25839
|
exports.fetchCampaign = fetchCampaign;
|
|
26098
25840
|
exports.fetchCampaignParticipants = fetchCampaignParticipants;
|
|
26099
25841
|
exports.fetchCampaignStats = fetchCampaignStats;
|
|
26100
25842
|
exports.fetchCampaigns = fetchCampaigns;
|
|
25843
|
+
exports.fetchInfobipEmailLogs = fetchInfobipEmailLogs;
|
|
25844
|
+
exports.fetchInfobipEmailReports = fetchInfobipEmailReports;
|
|
25845
|
+
exports.fetchInfobipScheduledEmailStatuses = fetchInfobipScheduledEmailStatuses;
|
|
25846
|
+
exports.fetchInfobipScheduledEmails = fetchInfobipScheduledEmails;
|
|
25847
|
+
exports.fetchInfobipValidations = fetchInfobipValidations;
|
|
26101
25848
|
exports.filterHistory = filterHistory;
|
|
26102
25849
|
exports.filterObject = filterObject;
|
|
26103
25850
|
exports.findEndpointsByPattern = findEndpointsByPattern;
|
|
@@ -26109,22 +25856,11 @@ exports.formatTimeForInterval = formatTimeForInterval;
|
|
|
26109
25856
|
exports.fromFetchffConfig = fromFetchffConfig;
|
|
26110
25857
|
exports.fromISOString = fromISOString;
|
|
26111
25858
|
exports.fromUnixTimestamp = fromUnixTimestamp;
|
|
26112
|
-
exports.generateApiCorrelationId = generateApiCorrelationId;
|
|
26113
|
-
exports.generateBaseId = generateBaseId;
|
|
26114
25859
|
exports.generateComprehensiveReport = generateComprehensiveReport;
|
|
26115
|
-
exports.generateContextualCorrelationId = generateContextualCorrelationId;
|
|
26116
|
-
exports.generateContextualId = generateContextualId;
|
|
26117
|
-
exports.generateContextualRequestId = generateContextualRequestId;
|
|
26118
|
-
exports.generateCorrelationId = generateCorrelationId;
|
|
26119
25860
|
exports.generateIV = generateIV;
|
|
26120
25861
|
exports.generateIssueBreakdown = generateIssueBreakdown;
|
|
26121
|
-
exports.generateNetworkCorrelationId = generateNetworkCorrelationId;
|
|
26122
25862
|
exports.generateRandomKey = generateRandomKey;
|
|
26123
25863
|
exports.generateRecommendations = generateRecommendations;
|
|
26124
|
-
exports.generateRequestId = generateRequestId;
|
|
26125
|
-
exports.generateSessionCorrelationId = generateSessionCorrelationId;
|
|
26126
|
-
exports.generateShortRequestId = generateShortRequestId;
|
|
26127
|
-
exports.generateTraceCorrelationId = generateTraceCorrelationId;
|
|
26128
25864
|
exports.generateUUID = generateUUID;
|
|
26129
25865
|
exports.getActiveOverrideKeys = getActiveOverrideKeys;
|
|
26130
25866
|
exports.getAdaptiveApiConfig = getAdaptiveApiConfig;
|
|
@@ -26164,9 +25900,6 @@ exports.getEntries = getEntries;
|
|
|
26164
25900
|
exports.getEnv = getEnv;
|
|
26165
25901
|
exports.getEnvironmentInfo = getEnvironmentInfo;
|
|
26166
25902
|
exports.getEnvironmentName = getEnvironmentName;
|
|
26167
|
-
exports.getErrorCategory = getErrorCategory;
|
|
26168
|
-
exports.getErrorCodeByStatus = getErrorCodeByStatus;
|
|
26169
|
-
exports.getErrorDefinition = getErrorDefinition;
|
|
26170
25903
|
exports.getErrorHandlers = getErrorHandlers;
|
|
26171
25904
|
exports.getEventManager = getEventManager;
|
|
26172
25905
|
exports.getExtendedEnvironmentInfo = getExtendedEnvironmentInfo;
|
|
@@ -26254,6 +25987,8 @@ exports.importKey = importKey;
|
|
|
26254
25987
|
exports.inBrowser = inBrowser;
|
|
26255
25988
|
exports.inRange = inRange;
|
|
26256
25989
|
exports.inServer = inServer;
|
|
25990
|
+
exports.infobipEmailEndpoints = infobipEmailEndpoints;
|
|
25991
|
+
exports.infobipEndpoints = infobipEndpoints;
|
|
26257
25992
|
exports.invalidationScenarios = invalidationScenarios;
|
|
26258
25993
|
exports.inverseLerp = inverseLerp;
|
|
26259
25994
|
exports.isAbortError = isAbortError;
|
|
@@ -26317,15 +26052,12 @@ exports.isTest = isTest;
|
|
|
26317
26052
|
exports.isToday = isToday;
|
|
26318
26053
|
exports.isTouchDevice = isTouchDevice;
|
|
26319
26054
|
exports.isUnifiedStrategyName = isUnifiedStrategyName;
|
|
26320
|
-
exports.isValidCorrelationId = isValidCorrelationId;
|
|
26321
26055
|
exports.isValidDate = isValidDate;
|
|
26322
26056
|
exports.isValidEnumValue = isValidEnumValue;
|
|
26323
26057
|
exports.isValidFieldPath = isValidFieldPath;
|
|
26324
|
-
exports.isValidId = isValidId;
|
|
26325
26058
|
exports.isValidJSON = isValidJSON;
|
|
26326
26059
|
exports.isValidNumber = isValidNumber2;
|
|
26327
26060
|
exports.isValidPollingConfig = isValidPollingConfig;
|
|
26328
|
-
exports.isValidRequestId = isValidRequestId;
|
|
26329
26061
|
exports.isValidRevalidationStrategyName = isValidStrategyName;
|
|
26330
26062
|
exports.isWebWorker = isWebWorker;
|
|
26331
26063
|
exports.isWifiConnection = isWifiConnection;
|
|
@@ -26337,7 +26069,6 @@ exports.jsonEquals = jsonEquals;
|
|
|
26337
26069
|
exports.keyBy = keyBy;
|
|
26338
26070
|
exports.leaveCampaign = leaveCampaign;
|
|
26339
26071
|
exports.lerp = lerp;
|
|
26340
|
-
exports.linkCorrelationIds = linkCorrelationIds;
|
|
26341
26072
|
exports.logNetworkConfigReport = logNetworkConfigReport;
|
|
26342
26073
|
exports.mapKeys = mapKeys;
|
|
26343
26074
|
exports.mapObject = mapObject;
|
|
@@ -26373,7 +26104,6 @@ exports.onceErrorHandler = onceErrorHandler;
|
|
|
26373
26104
|
exports.oneOf = oneOf;
|
|
26374
26105
|
exports.parseAndValidateNumber = parseAndValidateNumber;
|
|
26375
26106
|
exports.parseFieldPath = parseFieldPath;
|
|
26376
|
-
exports.parseId = parseId;
|
|
26377
26107
|
exports.percentage = percentage;
|
|
26378
26108
|
exports.pick = pick;
|
|
26379
26109
|
exports.pollingEndpoints = pollingEndpoints;
|
|
@@ -26394,6 +26124,7 @@ exports.removeSensitiveHeaders = removeSensitiveHeaders;
|
|
|
26394
26124
|
exports.removeUndefined = removeUndefined;
|
|
26395
26125
|
exports.requestTracker = requestTracker;
|
|
26396
26126
|
exports.requestWithTimeout = requestWithTimeout;
|
|
26127
|
+
exports.rescheduleInfobipEmails = rescheduleInfobipEmails;
|
|
26397
26128
|
exports.resetGlobalConfig = resetGlobalConfig;
|
|
26398
26129
|
exports.resetRevalidationPresets = resetPresets;
|
|
26399
26130
|
exports.resolveConflict = resolveConflict;
|
|
@@ -26408,6 +26139,8 @@ exports.safeParseJSON = safeParseJSON;
|
|
|
26408
26139
|
exports.safeStringify = safeStringify;
|
|
26409
26140
|
exports.sanitizeHeaders = sanitizeHeaders2;
|
|
26410
26141
|
exports.secondsToMs = secondsToMs;
|
|
26142
|
+
exports.sendInfobipAdvancedEmail = sendInfobipAdvancedEmail;
|
|
26143
|
+
exports.sendInfobipEmail = sendInfobipEmail;
|
|
26411
26144
|
exports.sequentialRequests = sequentialRequests;
|
|
26412
26145
|
exports.setCache = setCache;
|
|
26413
26146
|
exports.setConfigWarnings = setConfigWarnings;
|
|
@@ -26461,6 +26194,7 @@ exports.unifiedStrategies = unifiedStrategies;
|
|
|
26461
26194
|
exports.unregisterErrorHandlers = unregisterErrorHandlers;
|
|
26462
26195
|
exports.updateCampaign = updateCampaign;
|
|
26463
26196
|
exports.updateGlobalConfig = updateGlobalConfig;
|
|
26197
|
+
exports.updateInfobipScheduledEmailStatuses = updateInfobipScheduledEmailStatuses;
|
|
26464
26198
|
exports.useAbortableRequest = useAbortableRequest;
|
|
26465
26199
|
exports.useApiConfigConflicts = useApiConfigConflicts;
|
|
26466
26200
|
exports.useApiDebugInfo = useApiDebugInfo;
|
|
@@ -26488,6 +26222,7 @@ exports.useUpdateCampaign = useUpdateCampaign;
|
|
|
26488
26222
|
exports.validateConfigUpdate = validateConfigUpdate;
|
|
26489
26223
|
exports.validateEncryptionConfig = validateEncryptionConfig;
|
|
26490
26224
|
exports.validateHeaders = validateHeaders2;
|
|
26225
|
+
exports.validateInfobipEmail = validateInfobipEmail;
|
|
26491
26226
|
exports.validatePathParams = validatePathParams;
|
|
26492
26227
|
exports.validatePreset = validatePreset;
|
|
26493
26228
|
exports.waitForOnline = waitForOnline;
|