@adtrackify/at-service-common 1.0.28 → 1.0.29
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/index.d.ts +5 -0
- package/dist/index.js +238 -145
- package/dist/index.js.map +4 -4
- package/package.json +1 -1
- package/src/clients/index.ts +2 -1
- package/src/clients/third-party/index.ts +1 -0
package/dist/index.js
CHANGED
|
@@ -267,33 +267,33 @@ var require_json = __commonJS({
|
|
|
267
267
|
populateHostPrefix(req);
|
|
268
268
|
}
|
|
269
269
|
function extractError(resp) {
|
|
270
|
-
var
|
|
270
|
+
var error3 = {};
|
|
271
271
|
var httpResponse2 = resp.httpResponse;
|
|
272
|
-
|
|
273
|
-
if (typeof
|
|
274
|
-
|
|
272
|
+
error3.code = httpResponse2.headers["x-amzn-errortype"] || "UnknownError";
|
|
273
|
+
if (typeof error3.code === "string") {
|
|
274
|
+
error3.code = error3.code.split(":")[0];
|
|
275
275
|
}
|
|
276
276
|
if (httpResponse2.body.length > 0) {
|
|
277
277
|
try {
|
|
278
278
|
var e = JSON.parse(httpResponse2.body.toString());
|
|
279
279
|
var code = e.__type || e.code || e.Code;
|
|
280
280
|
if (code) {
|
|
281
|
-
|
|
281
|
+
error3.code = code.split("#").pop();
|
|
282
282
|
}
|
|
283
|
-
if (
|
|
284
|
-
|
|
283
|
+
if (error3.code === "RequestEntityTooLarge") {
|
|
284
|
+
error3.message = "Request body must be less than 1 MB";
|
|
285
285
|
} else {
|
|
286
|
-
|
|
286
|
+
error3.message = e.message || e.Message || null;
|
|
287
287
|
}
|
|
288
288
|
} catch (e2) {
|
|
289
|
-
|
|
290
|
-
|
|
289
|
+
error3.statusCode = httpResponse2.statusCode;
|
|
290
|
+
error3.message = httpResponse2.statusMessage;
|
|
291
291
|
}
|
|
292
292
|
} else {
|
|
293
|
-
|
|
294
|
-
|
|
293
|
+
error3.statusCode = httpResponse2.statusCode;
|
|
294
|
+
error3.message = httpResponse2.statusCode.toString();
|
|
295
295
|
}
|
|
296
|
-
resp.error = util.error(new Error(),
|
|
296
|
+
resp.error = util.error(new Error(), error3);
|
|
297
297
|
}
|
|
298
298
|
function extractData(resp) {
|
|
299
299
|
var body = resp.httpResponse.body.toString() || "{}";
|
|
@@ -3039,15 +3039,15 @@ var require_sequential_executor = __commonJS({
|
|
|
3039
3039
|
},
|
|
3040
3040
|
callListeners: function callListeners(listeners, args, doneCallback, prevError) {
|
|
3041
3041
|
var self = this;
|
|
3042
|
-
var
|
|
3042
|
+
var error3 = prevError || null;
|
|
3043
3043
|
function callNextListener(err) {
|
|
3044
3044
|
if (err) {
|
|
3045
|
-
|
|
3045
|
+
error3 = AWS3.util.error(error3 || new Error(), err);
|
|
3046
3046
|
if (self._haltHandlersOnError) {
|
|
3047
|
-
return doneCallback.call(self,
|
|
3047
|
+
return doneCallback.call(self, error3);
|
|
3048
3048
|
}
|
|
3049
3049
|
}
|
|
3050
|
-
self.callListeners(listeners, args, doneCallback,
|
|
3050
|
+
self.callListeners(listeners, args, doneCallback, error3);
|
|
3051
3051
|
}
|
|
3052
3052
|
while (listeners.length > 0) {
|
|
3053
3053
|
var listener = listeners.shift();
|
|
@@ -3058,15 +3058,15 @@ var require_sequential_executor = __commonJS({
|
|
|
3058
3058
|
try {
|
|
3059
3059
|
listener.apply(self, args);
|
|
3060
3060
|
} catch (err) {
|
|
3061
|
-
|
|
3061
|
+
error3 = AWS3.util.error(error3 || new Error(), err);
|
|
3062
3062
|
}
|
|
3063
|
-
if (
|
|
3064
|
-
doneCallback.call(self,
|
|
3063
|
+
if (error3 && self._haltHandlersOnError) {
|
|
3064
|
+
doneCallback.call(self, error3);
|
|
3065
3065
|
return;
|
|
3066
3066
|
}
|
|
3067
3067
|
}
|
|
3068
3068
|
}
|
|
3069
|
-
doneCallback.call(self,
|
|
3069
|
+
doneCallback.call(self, error3);
|
|
3070
3070
|
},
|
|
3071
3071
|
addListeners: function addListeners(listeners) {
|
|
3072
3072
|
var self = this;
|
|
@@ -3656,18 +3656,18 @@ var require_service = __commonJS({
|
|
|
3656
3656
|
monitoringEvent.FinalHttpStatusCode = response.httpResponse.statusCode;
|
|
3657
3657
|
}
|
|
3658
3658
|
if (response.error) {
|
|
3659
|
-
var
|
|
3659
|
+
var error3 = response.error;
|
|
3660
3660
|
var statusCode = response.httpResponse.statusCode;
|
|
3661
3661
|
if (statusCode > 299) {
|
|
3662
|
-
if (
|
|
3663
|
-
monitoringEvent.FinalAwsException =
|
|
3664
|
-
if (
|
|
3665
|
-
monitoringEvent.FinalAwsExceptionMessage =
|
|
3662
|
+
if (error3.code)
|
|
3663
|
+
monitoringEvent.FinalAwsException = error3.code;
|
|
3664
|
+
if (error3.message)
|
|
3665
|
+
monitoringEvent.FinalAwsExceptionMessage = error3.message;
|
|
3666
3666
|
} else {
|
|
3667
|
-
if (
|
|
3668
|
-
monitoringEvent.FinalSdkException =
|
|
3669
|
-
if (
|
|
3670
|
-
monitoringEvent.FinalSdkExceptionMessage =
|
|
3667
|
+
if (error3.code || error3.name)
|
|
3668
|
+
monitoringEvent.FinalSdkException = error3.code || error3.name;
|
|
3669
|
+
if (error3.message)
|
|
3670
|
+
monitoringEvent.FinalSdkExceptionMessage = error3.message;
|
|
3671
3671
|
}
|
|
3672
3672
|
}
|
|
3673
3673
|
return monitoringEvent;
|
|
@@ -3708,17 +3708,17 @@ var require_service = __commonJS({
|
|
|
3708
3708
|
attemptFailEvent: function attemptFailEvent(request) {
|
|
3709
3709
|
var monitoringEvent = this.apiAttemptEvent(request);
|
|
3710
3710
|
var response = request.response;
|
|
3711
|
-
var
|
|
3711
|
+
var error3 = response.error;
|
|
3712
3712
|
if (response.httpResponse.statusCode > 299) {
|
|
3713
|
-
if (
|
|
3714
|
-
monitoringEvent.AwsException =
|
|
3715
|
-
if (
|
|
3716
|
-
monitoringEvent.AwsExceptionMessage =
|
|
3713
|
+
if (error3.code)
|
|
3714
|
+
monitoringEvent.AwsException = error3.code;
|
|
3715
|
+
if (error3.message)
|
|
3716
|
+
monitoringEvent.AwsExceptionMessage = error3.message;
|
|
3717
3717
|
} else {
|
|
3718
|
-
if (
|
|
3719
|
-
monitoringEvent.SdkException =
|
|
3720
|
-
if (
|
|
3721
|
-
monitoringEvent.SdkExceptionMessage =
|
|
3718
|
+
if (error3.code || error3.name)
|
|
3719
|
+
monitoringEvent.SdkException = error3.code || error3.name;
|
|
3720
|
+
if (error3.message)
|
|
3721
|
+
monitoringEvent.SdkExceptionMessage = error3.message;
|
|
3722
3722
|
}
|
|
3723
3723
|
return monitoringEvent;
|
|
3724
3724
|
},
|
|
@@ -3828,30 +3828,30 @@ var require_service = __commonJS({
|
|
|
3828
3828
|
retryDelays: function retryDelays(retryCount, err) {
|
|
3829
3829
|
return AWS3.util.calculateRetryDelay(retryCount, this.config.retryDelayOptions, err);
|
|
3830
3830
|
},
|
|
3831
|
-
retryableError: function retryableError(
|
|
3832
|
-
if (this.timeoutError(
|
|
3831
|
+
retryableError: function retryableError(error3) {
|
|
3832
|
+
if (this.timeoutError(error3))
|
|
3833
3833
|
return true;
|
|
3834
|
-
if (this.networkingError(
|
|
3834
|
+
if (this.networkingError(error3))
|
|
3835
3835
|
return true;
|
|
3836
|
-
if (this.expiredCredentialsError(
|
|
3836
|
+
if (this.expiredCredentialsError(error3))
|
|
3837
3837
|
return true;
|
|
3838
|
-
if (this.throttledError(
|
|
3838
|
+
if (this.throttledError(error3))
|
|
3839
3839
|
return true;
|
|
3840
|
-
if (
|
|
3840
|
+
if (error3.statusCode >= 500)
|
|
3841
3841
|
return true;
|
|
3842
3842
|
return false;
|
|
3843
3843
|
},
|
|
3844
|
-
networkingError: function networkingError(
|
|
3845
|
-
return
|
|
3844
|
+
networkingError: function networkingError(error3) {
|
|
3845
|
+
return error3.code === "NetworkingError";
|
|
3846
3846
|
},
|
|
3847
|
-
timeoutError: function timeoutError(
|
|
3848
|
-
return
|
|
3847
|
+
timeoutError: function timeoutError(error3) {
|
|
3848
|
+
return error3.code === "TimeoutError";
|
|
3849
3849
|
},
|
|
3850
|
-
expiredCredentialsError: function expiredCredentialsError(
|
|
3851
|
-
return
|
|
3850
|
+
expiredCredentialsError: function expiredCredentialsError(error3) {
|
|
3851
|
+
return error3.code === "ExpiredTokenException";
|
|
3852
3852
|
},
|
|
3853
|
-
clockSkewError: function clockSkewError(
|
|
3854
|
-
switch (
|
|
3853
|
+
clockSkewError: function clockSkewError(error3) {
|
|
3854
|
+
switch (error3.code) {
|
|
3855
3855
|
case "RequestTimeTooSkewed":
|
|
3856
3856
|
case "RequestExpired":
|
|
3857
3857
|
case "InvalidSignatureException":
|
|
@@ -3876,10 +3876,10 @@ var require_service = __commonJS({
|
|
|
3876
3876
|
return Math.abs(this.getSkewCorrectedDate().getTime() - newServerTime) >= 3e5;
|
|
3877
3877
|
}
|
|
3878
3878
|
},
|
|
3879
|
-
throttledError: function throttledError(
|
|
3880
|
-
if (
|
|
3879
|
+
throttledError: function throttledError(error3) {
|
|
3880
|
+
if (error3.statusCode === 429)
|
|
3881
3881
|
return true;
|
|
3882
|
-
switch (
|
|
3882
|
+
switch (error3.code) {
|
|
3883
3883
|
case "ProvisionedThroughputExceededException":
|
|
3884
3884
|
case "Throttling":
|
|
3885
3885
|
case "ThrottlingException":
|
|
@@ -4599,9 +4599,9 @@ var require_discover_endpoint = __commonJS({
|
|
|
4599
4599
|
}
|
|
4600
4600
|
}
|
|
4601
4601
|
function invalidateCachedEndpoints(response) {
|
|
4602
|
-
var
|
|
4602
|
+
var error3 = response.error;
|
|
4603
4603
|
var httpResponse2 = response.httpResponse;
|
|
4604
|
-
if (
|
|
4604
|
+
if (error3 && (error3.code === "InvalidEndpointException" || httpResponse2.statusCode === 421)) {
|
|
4605
4605
|
var request = response.request;
|
|
4606
4606
|
var operations = request.service.api.operations || {};
|
|
4607
4607
|
var inputShape = operations[request.operation] ? operations[request.operation].input : void 0;
|
|
@@ -5003,7 +5003,7 @@ var require_event_listeners = __commonJS({
|
|
|
5003
5003
|
resp.request.emit("httpDownloadProgress", [value, resp]);
|
|
5004
5004
|
});
|
|
5005
5005
|
}
|
|
5006
|
-
function
|
|
5006
|
+
function error3(err) {
|
|
5007
5007
|
if (err.code !== "RequestAbortedError") {
|
|
5008
5008
|
var errCode = err.code === "TimeoutError" ? err.code : "NetworkingError";
|
|
5009
5009
|
err = AWS3.util.error(err, {
|
|
@@ -5026,11 +5026,11 @@ var require_event_listeners = __commonJS({
|
|
|
5026
5026
|
resp.request.httpRequest,
|
|
5027
5027
|
httpOptions,
|
|
5028
5028
|
callback,
|
|
5029
|
-
|
|
5029
|
+
error3
|
|
5030
5030
|
);
|
|
5031
5031
|
progress(stream);
|
|
5032
5032
|
} catch (err) {
|
|
5033
|
-
|
|
5033
|
+
error3(err);
|
|
5034
5034
|
}
|
|
5035
5035
|
}
|
|
5036
5036
|
var timeDiff = (resp.request.service.getSkewCorrectedDate() - this.signedAt) / 1e3;
|
|
@@ -5598,9 +5598,9 @@ var require_jmespath = __commonJS({
|
|
|
5598
5598
|
tokens.push({ type: TOK_PIPE, value: "|", start });
|
|
5599
5599
|
}
|
|
5600
5600
|
} else {
|
|
5601
|
-
var
|
|
5602
|
-
|
|
5603
|
-
throw
|
|
5601
|
+
var error3 = new Error("Unknown character:" + stream[this._current]);
|
|
5602
|
+
error3.name = "LexerError";
|
|
5603
|
+
throw error3;
|
|
5604
5604
|
}
|
|
5605
5605
|
}
|
|
5606
5606
|
return tokens;
|
|
@@ -5784,11 +5784,11 @@ var require_jmespath = __commonJS({
|
|
|
5784
5784
|
var ast = this.expression(0);
|
|
5785
5785
|
if (this._lookahead(0) !== TOK_EOF) {
|
|
5786
5786
|
var t = this._lookaheadToken(0);
|
|
5787
|
-
var
|
|
5787
|
+
var error3 = new Error(
|
|
5788
5788
|
"Unexpected token type: " + t.type + ", value: " + t.value
|
|
5789
5789
|
);
|
|
5790
|
-
|
|
5791
|
-
throw
|
|
5790
|
+
error3.name = "ParserError";
|
|
5791
|
+
throw error3;
|
|
5792
5792
|
}
|
|
5793
5793
|
return ast;
|
|
5794
5794
|
},
|
|
@@ -5969,15 +5969,15 @@ var require_jmespath = __commonJS({
|
|
|
5969
5969
|
this._advance();
|
|
5970
5970
|
} else {
|
|
5971
5971
|
var t = this._lookaheadToken(0);
|
|
5972
|
-
var
|
|
5973
|
-
|
|
5974
|
-
throw
|
|
5972
|
+
var error3 = new Error("Expected " + tokenType + ", got: " + t.type);
|
|
5973
|
+
error3.name = "ParserError";
|
|
5974
|
+
throw error3;
|
|
5975
5975
|
}
|
|
5976
5976
|
},
|
|
5977
5977
|
_errorToken: function(token) {
|
|
5978
|
-
var
|
|
5979
|
-
|
|
5980
|
-
throw
|
|
5978
|
+
var error3 = new Error("Invalid token (" + token.type + '): "' + token.value + '"');
|
|
5979
|
+
error3.name = "ParserError";
|
|
5980
|
+
throw error3;
|
|
5981
5981
|
},
|
|
5982
5982
|
_parseIndexExpression: function() {
|
|
5983
5983
|
if (this._lookahead(0) === TOK_COLON || this._lookahead(1) === TOK_COLON) {
|
|
@@ -6016,9 +6016,9 @@ var require_jmespath = __commonJS({
|
|
|
6016
6016
|
this._advance();
|
|
6017
6017
|
} else {
|
|
6018
6018
|
var t = this._lookahead(0);
|
|
6019
|
-
var
|
|
6020
|
-
|
|
6021
|
-
throw
|
|
6019
|
+
var error3 = new Error("Syntax error, unexpected token: " + t.value + "(" + t.type + ")");
|
|
6020
|
+
error3.name = "Parsererror";
|
|
6021
|
+
throw error3;
|
|
6022
6022
|
}
|
|
6023
6023
|
currentToken = this._lookahead(0);
|
|
6024
6024
|
}
|
|
@@ -6058,9 +6058,9 @@ var require_jmespath = __commonJS({
|
|
|
6058
6058
|
right = this._parseDotRHS(rbp);
|
|
6059
6059
|
} else {
|
|
6060
6060
|
var t = this._lookaheadToken(0);
|
|
6061
|
-
var
|
|
6062
|
-
|
|
6063
|
-
throw
|
|
6061
|
+
var error3 = new Error("Sytanx error, unexpected token: " + t.value + "(" + t.type + ")");
|
|
6062
|
+
error3.name = "ParserError";
|
|
6063
|
+
throw error3;
|
|
6064
6064
|
}
|
|
6065
6065
|
return right;
|
|
6066
6066
|
},
|
|
@@ -6324,9 +6324,9 @@ var require_jmespath = __commonJS({
|
|
|
6324
6324
|
if (step === null) {
|
|
6325
6325
|
step = 1;
|
|
6326
6326
|
} else if (step === 0) {
|
|
6327
|
-
var
|
|
6328
|
-
|
|
6329
|
-
throw
|
|
6327
|
+
var error3 = new Error("Invalid slice, step cannot be 0");
|
|
6328
|
+
error3.name = "RuntimeError";
|
|
6329
|
+
throw error3;
|
|
6330
6330
|
}
|
|
6331
6331
|
var stepValueNegative = step < 0 ? true : false;
|
|
6332
6332
|
if (start === null) {
|
|
@@ -7012,8 +7012,8 @@ var require_request = __commonJS({
|
|
|
7012
7012
|
if (statusCode < 300) {
|
|
7013
7013
|
req.removeListener("httpData", AWS3.EventListeners.Core.HTTP_DATA);
|
|
7014
7014
|
req.removeListener("httpError", AWS3.EventListeners.Core.HTTP_ERROR);
|
|
7015
|
-
req.on("httpError", function streamHttpError(
|
|
7016
|
-
resp.error =
|
|
7015
|
+
req.on("httpError", function streamHttpError(error3) {
|
|
7016
|
+
resp.error = error3;
|
|
7017
7017
|
resp.error.retryable = false;
|
|
7018
7018
|
});
|
|
7019
7019
|
var shouldCheckContentLength = false;
|
|
@@ -9362,7 +9362,7 @@ var require_util = __commonJS({
|
|
|
9362
9362
|
var match = str.match(/^\s*function (.+)\(/);
|
|
9363
9363
|
return match ? match[1] : str;
|
|
9364
9364
|
},
|
|
9365
|
-
error: function
|
|
9365
|
+
error: function error3(err, options2) {
|
|
9366
9366
|
var originalError = null;
|
|
9367
9367
|
if (typeof err.message === "string" && err.message !== "") {
|
|
9368
9368
|
if (typeof options2 === "string" || options2 && options2.message) {
|
|
@@ -9682,9 +9682,9 @@ var require_util = __commonJS({
|
|
|
9682
9682
|
var profilesFromCreds = iniLoader.loadFrom({
|
|
9683
9683
|
filename: filename || process.env[util.configOptInEnv] && process.env[util.sharedCredentialsFileEnv]
|
|
9684
9684
|
});
|
|
9685
|
-
} catch (
|
|
9685
|
+
} catch (error3) {
|
|
9686
9686
|
if (!process.env[util.configOptInEnv])
|
|
9687
|
-
throw
|
|
9687
|
+
throw error3;
|
|
9688
9688
|
}
|
|
9689
9689
|
for (var i = 0, profileNames = Object.keys(profilesFromConfig); i < profileNames.length; i++) {
|
|
9690
9690
|
profiles[profileNames[i]] = objectAssign(profiles[profileNames[i]] || {}, profilesFromConfig[profileNames[i]]);
|
|
@@ -10079,9 +10079,9 @@ var require_parse_event = __commonJS({
|
|
|
10079
10079
|
function parseError(message) {
|
|
10080
10080
|
var errorCode = message.headers[":error-code"];
|
|
10081
10081
|
var errorMessage = message.headers[":error-message"];
|
|
10082
|
-
var
|
|
10083
|
-
|
|
10084
|
-
return
|
|
10082
|
+
var error3 = new Error(errorMessage.value || errorMessage);
|
|
10083
|
+
error3.code = error3.name = errorCode.value || errorCode;
|
|
10084
|
+
return error3;
|
|
10085
10085
|
}
|
|
10086
10086
|
module.exports = {
|
|
10087
10087
|
parseEvent
|
|
@@ -14788,7 +14788,7 @@ var require_sax = __commonJS({
|
|
|
14788
14788
|
parser.script = "";
|
|
14789
14789
|
break;
|
|
14790
14790
|
default:
|
|
14791
|
-
|
|
14791
|
+
error3(parser, "Max buffer length exceeded: " + buffers[i]);
|
|
14792
14792
|
}
|
|
14793
14793
|
}
|
|
14794
14794
|
maxActual = Math.max(maxActual, len);
|
|
@@ -15276,7 +15276,7 @@ var require_sax = __commonJS({
|
|
|
15276
15276
|
text = text.replace(/\s+/g, " ");
|
|
15277
15277
|
return text;
|
|
15278
15278
|
}
|
|
15279
|
-
function
|
|
15279
|
+
function error3(parser, er) {
|
|
15280
15280
|
closeText(parser);
|
|
15281
15281
|
if (parser.trackPosition) {
|
|
15282
15282
|
er += "\nLine: " + parser.line + "\nColumn: " + parser.column + "\nChar: " + parser.c;
|
|
@@ -15290,7 +15290,7 @@ var require_sax = __commonJS({
|
|
|
15290
15290
|
if (parser.sawRoot && !parser.closedRoot)
|
|
15291
15291
|
strictFail(parser, "Unclosed root tag");
|
|
15292
15292
|
if (parser.state !== S.BEGIN && parser.state !== S.BEGIN_WHITESPACE && parser.state !== S.TEXT) {
|
|
15293
|
-
|
|
15293
|
+
error3(parser, "Unexpected end");
|
|
15294
15294
|
}
|
|
15295
15295
|
closeText(parser);
|
|
15296
15296
|
parser.c = "";
|
|
@@ -15304,7 +15304,7 @@ var require_sax = __commonJS({
|
|
|
15304
15304
|
throw new Error("bad call to strictFail");
|
|
15305
15305
|
}
|
|
15306
15306
|
if (parser.strict) {
|
|
15307
|
-
|
|
15307
|
+
error3(parser, message);
|
|
15308
15308
|
}
|
|
15309
15309
|
}
|
|
15310
15310
|
function newTag(parser) {
|
|
@@ -15545,7 +15545,7 @@ var require_sax = __commonJS({
|
|
|
15545
15545
|
throw this.error;
|
|
15546
15546
|
}
|
|
15547
15547
|
if (parser.closed) {
|
|
15548
|
-
return
|
|
15548
|
+
return error3(
|
|
15549
15549
|
parser,
|
|
15550
15550
|
"Cannot write after close. Assign an onready handler."
|
|
15551
15551
|
);
|
|
@@ -16258,11 +16258,11 @@ var require_parser2 = __commonJS({
|
|
|
16258
16258
|
});
|
|
16259
16259
|
this.saxParser.errThrown = false;
|
|
16260
16260
|
this.saxParser.onerror = function(_this) {
|
|
16261
|
-
return function(
|
|
16261
|
+
return function(error3) {
|
|
16262
16262
|
_this.saxParser.resume();
|
|
16263
16263
|
if (!_this.saxParser.errThrown) {
|
|
16264
16264
|
_this.saxParser.errThrown = true;
|
|
16265
|
-
return _this.emit("error",
|
|
16265
|
+
return _this.emit("error", error3);
|
|
16266
16266
|
}
|
|
16267
16267
|
};
|
|
16268
16268
|
}(this);
|
|
@@ -16559,10 +16559,10 @@ var require_node_parser = __commonJS({
|
|
|
16559
16559
|
NodeXmlParser.prototype.parse = function(xml, shape) {
|
|
16560
16560
|
shape = shape || {};
|
|
16561
16561
|
var result = null;
|
|
16562
|
-
var
|
|
16562
|
+
var error3 = null;
|
|
16563
16563
|
var parser = new xml2js.Parser(options2);
|
|
16564
16564
|
parser.parseString(xml, function(e, r) {
|
|
16565
|
-
|
|
16565
|
+
error3 = e;
|
|
16566
16566
|
result = r;
|
|
16567
16567
|
});
|
|
16568
16568
|
if (result) {
|
|
@@ -16571,8 +16571,8 @@ var require_node_parser = __commonJS({
|
|
|
16571
16571
|
data.ResponseMetadata = parseXml(result.ResponseMetadata[0], {});
|
|
16572
16572
|
}
|
|
16573
16573
|
return data;
|
|
16574
|
-
} else if (
|
|
16575
|
-
throw util.error(
|
|
16574
|
+
} else if (error3) {
|
|
16575
|
+
throw util.error(error3, { code: "XMLParserError", retryable: true });
|
|
16576
16576
|
} else {
|
|
16577
16577
|
return parseXml({}, shape);
|
|
16578
16578
|
}
|
|
@@ -16980,11 +16980,11 @@ var require_token_file_web_identity_credentials = __commonJS({
|
|
|
16980
16980
|
if (!this.service) {
|
|
16981
16981
|
var stsConfig = AWS3.util.merge({}, this.clientConfig);
|
|
16982
16982
|
this.service = new STS(stsConfig);
|
|
16983
|
-
this.service.retryableError = function(
|
|
16984
|
-
if (
|
|
16983
|
+
this.service.retryableError = function(error3) {
|
|
16984
|
+
if (error3.code === "IDPCommunicationErrorException" || error3.code === "InvalidIdentityToken") {
|
|
16985
16985
|
return true;
|
|
16986
16986
|
} else {
|
|
16987
|
-
return AWS3.Service.prototype.retryableError.call(this,
|
|
16987
|
+
return AWS3.Service.prototype.retryableError.call(this, error3);
|
|
16988
16988
|
}
|
|
16989
16989
|
};
|
|
16990
16990
|
}
|
|
@@ -235337,12 +235337,12 @@ var require_route53 = __commonJS({
|
|
|
235337
235337
|
var path = request.httpRequest.path;
|
|
235338
235338
|
request.httpRequest.path = path.replace(/\/%2F\w+%2F/, "/");
|
|
235339
235339
|
},
|
|
235340
|
-
retryableError: function retryableError(
|
|
235341
|
-
if (
|
|
235340
|
+
retryableError: function retryableError(error3) {
|
|
235341
|
+
if (error3.code === "PriorRequestNotComplete" && error3.statusCode === 400) {
|
|
235342
235342
|
return true;
|
|
235343
235343
|
} else {
|
|
235344
235344
|
var _super = AWS3.Service.prototype.retryableError;
|
|
235345
|
-
return _super.call(this,
|
|
235345
|
+
return _super.call(this, error3);
|
|
235346
235346
|
}
|
|
235347
235347
|
}
|
|
235348
235348
|
});
|
|
@@ -240663,22 +240663,22 @@ var require_s32 = __commonJS({
|
|
|
240663
240663
|
});
|
|
240664
240664
|
}
|
|
240665
240665
|
},
|
|
240666
|
-
retryableError: function retryableError(
|
|
240667
|
-
if (operationsWith200StatusCodeError[request.operation] &&
|
|
240666
|
+
retryableError: function retryableError(error3, request) {
|
|
240667
|
+
if (operationsWith200StatusCodeError[request.operation] && error3.statusCode === 200) {
|
|
240668
240668
|
return true;
|
|
240669
240669
|
} else if (request._requestRegionForBucket && request.service.bucketRegionCache[request._requestRegionForBucket]) {
|
|
240670
240670
|
return false;
|
|
240671
|
-
} else if (
|
|
240671
|
+
} else if (error3 && error3.code === "RequestTimeout") {
|
|
240672
240672
|
return true;
|
|
240673
|
-
} else if (
|
|
240674
|
-
request.httpRequest.region =
|
|
240675
|
-
if (
|
|
240673
|
+
} else if (error3 && regionRedirectErrorCodes.indexOf(error3.code) != -1 && error3.region && error3.region != request.httpRequest.region) {
|
|
240674
|
+
request.httpRequest.region = error3.region;
|
|
240675
|
+
if (error3.statusCode === 301) {
|
|
240676
240676
|
request.service.updateReqBucketRegion(request);
|
|
240677
240677
|
}
|
|
240678
240678
|
return true;
|
|
240679
240679
|
} else {
|
|
240680
240680
|
var _super = AWS3.Service.prototype.retryableError;
|
|
240681
|
-
return _super.call(this,
|
|
240681
|
+
return _super.call(this, error3, request);
|
|
240682
240682
|
}
|
|
240683
240683
|
},
|
|
240684
240684
|
updateReqBucketRegion: function updateReqBucketRegion(request, region) {
|
|
@@ -240794,10 +240794,10 @@ var require_s32 = __commonJS({
|
|
|
240794
240794
|
req.service.extractRequestIds(resp);
|
|
240795
240795
|
},
|
|
240796
240796
|
requestBucketRegion: function requestBucketRegion(resp, done) {
|
|
240797
|
-
var
|
|
240797
|
+
var error3 = resp.error;
|
|
240798
240798
|
var req = resp.request;
|
|
240799
240799
|
var bucket = req.params.Bucket || null;
|
|
240800
|
-
if (!
|
|
240800
|
+
if (!error3 || !bucket || error3.region || req.operation === "listObjects" || AWS3.util.isNode() && req.operation === "headBucket" || error3.statusCode === 400 && req.operation !== "headObject" || regionRedirectErrorCodes.indexOf(error3.code) === -1) {
|
|
240801
240801
|
return done();
|
|
240802
240802
|
}
|
|
240803
240803
|
var reqOperation = AWS3.util.isNode() ? "headBucket" : "listObjects";
|
|
@@ -240808,7 +240808,7 @@ var require_s32 = __commonJS({
|
|
|
240808
240808
|
regionReq._requestRegionForBucket = bucket;
|
|
240809
240809
|
regionReq.send(function() {
|
|
240810
240810
|
var region = req.service.bucketRegionCache[bucket] || null;
|
|
240811
|
-
|
|
240811
|
+
error3.region = region;
|
|
240812
240812
|
done();
|
|
240813
240813
|
});
|
|
240814
240814
|
},
|
|
@@ -240816,10 +240816,10 @@ var require_s32 = __commonJS({
|
|
|
240816
240816
|
if (!AWS3.util.isBrowser()) {
|
|
240817
240817
|
return done();
|
|
240818
240818
|
}
|
|
240819
|
-
var
|
|
240819
|
+
var error3 = resp.error;
|
|
240820
240820
|
var request = resp.request;
|
|
240821
240821
|
var bucket = request.params.Bucket;
|
|
240822
|
-
if (!
|
|
240822
|
+
if (!error3 || error3.code !== "NetworkingError" || !bucket || request.httpRequest.region === "us-east-1") {
|
|
240823
240823
|
return done();
|
|
240824
240824
|
}
|
|
240825
240825
|
var service = request.service;
|
|
@@ -404643,12 +404643,12 @@ var require_rdsdataservice = __commonJS({
|
|
|
404643
404643
|
"node_modules/aws-sdk/lib/services/rdsdataservice.js"() {
|
|
404644
404644
|
var AWS3 = require_core();
|
|
404645
404645
|
AWS3.util.update(AWS3.RDSDataService.prototype, {
|
|
404646
|
-
retryableError: function retryableError(
|
|
404647
|
-
if (
|
|
404646
|
+
retryableError: function retryableError(error3) {
|
|
404647
|
+
if (error3.code === "BadRequestException" && error3.message && error3.message.match(/^Communications link failure/) && error3.statusCode === 400) {
|
|
404648
404648
|
return true;
|
|
404649
404649
|
} else {
|
|
404650
404650
|
var _super = AWS3.Service.prototype.retryableError;
|
|
404651
|
-
return _super.call(this,
|
|
404651
|
+
return _super.call(this, error3);
|
|
404652
404652
|
}
|
|
404653
404653
|
}
|
|
404654
404654
|
});
|
|
@@ -628097,10 +628097,10 @@ var httpResponse = (res = {}) => {
|
|
|
628097
628097
|
status: res?.status || 0
|
|
628098
628098
|
};
|
|
628099
628099
|
};
|
|
628100
|
-
var handleAxiosError = (
|
|
628101
|
-
if (!
|
|
628102
|
-
throw
|
|
628103
|
-
return
|
|
628100
|
+
var handleAxiosError = (error3) => {
|
|
628101
|
+
if (!error3?.response && !error3?.request)
|
|
628102
|
+
throw error3;
|
|
628103
|
+
return error3.response ? httpResponse(error3.response) : httpResponse({ status: 500, data: { error: error3.request } });
|
|
628104
628104
|
};
|
|
628105
628105
|
var axiosHttpService = (config = {}) => {
|
|
628106
628106
|
config.adapter = httpAdapter;
|
|
@@ -628200,6 +628200,98 @@ var AccountsClient = class {
|
|
|
628200
628200
|
};
|
|
628201
628201
|
};
|
|
628202
628202
|
|
|
628203
|
+
// src/clients/third-party/shopify-client.ts
|
|
628204
|
+
import * as log4 from "lambda-log";
|
|
628205
|
+
var _shopify_api_version = process.env.SHOPIFY_API_VERSION;
|
|
628206
|
+
var ShopifyClient = class {
|
|
628207
|
+
getConfig = (shopifyDomain, accessToken) => {
|
|
628208
|
+
const config = {
|
|
628209
|
+
baseURL: `https://${shopifyDomain}/admin/api/${_shopify_api_version}`,
|
|
628210
|
+
headers: {
|
|
628211
|
+
common: {
|
|
628212
|
+
"X-Shopify-Access-Token": accessToken
|
|
628213
|
+
}
|
|
628214
|
+
}
|
|
628215
|
+
};
|
|
628216
|
+
return config;
|
|
628217
|
+
};
|
|
628218
|
+
getClient = (shopifyDomain, accessToken) => {
|
|
628219
|
+
return axiosHttpService(
|
|
628220
|
+
this.getConfig(shopifyDomain, accessToken)
|
|
628221
|
+
);
|
|
628222
|
+
};
|
|
628223
|
+
registerApp = async (shop, code, appKey, appSecret) => {
|
|
628224
|
+
const client2 = axiosHttpService();
|
|
628225
|
+
const url = "https://" + shop + "/admin/oauth/access_token";
|
|
628226
|
+
const payload2 = {
|
|
628227
|
+
client_id: appKey,
|
|
628228
|
+
client_secret: appSecret,
|
|
628229
|
+
code
|
|
628230
|
+
};
|
|
628231
|
+
const res = await client2.post(url, payload2);
|
|
628232
|
+
return res;
|
|
628233
|
+
};
|
|
628234
|
+
registerWebhookTopic = async (shop, accessToken, eventBridgeArn, topic) => {
|
|
628235
|
+
const client2 = axiosHttpService();
|
|
628236
|
+
const url = `https://${shop}/admin/api/${_shopify_api_version}/webhooks.json`;
|
|
628237
|
+
const payload2 = {
|
|
628238
|
+
webhook: {
|
|
628239
|
+
topic,
|
|
628240
|
+
address: eventBridgeArn,
|
|
628241
|
+
format: "json"
|
|
628242
|
+
}
|
|
628243
|
+
};
|
|
628244
|
+
const res = await client2.post(url, payload2, { headers: { "X-Shopify-Access-Token": accessToken } });
|
|
628245
|
+
if (res.status >= 400) {
|
|
628246
|
+
log4.error("Failed to register Webhook Topic", { shop, accessToken, eventBridgeArn, topic, url, payload: payload2 });
|
|
628247
|
+
}
|
|
628248
|
+
log4.debug("Shopify Client Webhook Registration Response", { registrationResponse: res });
|
|
628249
|
+
return res;
|
|
628250
|
+
};
|
|
628251
|
+
updateShopifyAppMetafield = async (shop, accessToken, pixelId) => {
|
|
628252
|
+
const url = `https://${shop}/admin/api/${_shopify_api_version}/metafields.json`;
|
|
628253
|
+
const payload2 = {
|
|
628254
|
+
metafield: {
|
|
628255
|
+
namespace: "adtr",
|
|
628256
|
+
key: "adtr.config",
|
|
628257
|
+
value: pixelId,
|
|
628258
|
+
type: "single_line_text_field"
|
|
628259
|
+
}
|
|
628260
|
+
};
|
|
628261
|
+
const res = await this.genericShopifyPost(url, accessToken, payload2);
|
|
628262
|
+
if (res.status >= 400) {
|
|
628263
|
+
log4.error("Failed to register Webhook Topic", { shop, accessToken, url, payload: payload2 });
|
|
628264
|
+
}
|
|
628265
|
+
return res;
|
|
628266
|
+
};
|
|
628267
|
+
getShopifyStoreProperties = async (shop, accessToken) => {
|
|
628268
|
+
const url = `https://${shop}/admin/api/${_shopify_api_version}/shop.json`;
|
|
628269
|
+
const res = await this.genericShopifyGet(url, accessToken);
|
|
628270
|
+
if (res.status >= 400) {
|
|
628271
|
+
log4.error("Failed to get Shopify Store Properties", { shop, accessToken, url });
|
|
628272
|
+
}
|
|
628273
|
+
return res;
|
|
628274
|
+
};
|
|
628275
|
+
genericShopifyPost = async (url, accessToken, payload2) => {
|
|
628276
|
+
const client2 = axiosHttpService();
|
|
628277
|
+
const res = await client2.post(url, payload2, { headers: { "X-Shopify-Access-Token": accessToken } });
|
|
628278
|
+
log4.debug("Shopify Client Response", { res });
|
|
628279
|
+
return res;
|
|
628280
|
+
};
|
|
628281
|
+
genericShopifyGet = async (url, accessToken) => {
|
|
628282
|
+
const client2 = axiosHttpService();
|
|
628283
|
+
const res = await client2.get(url, { headers: { "X-Shopify-Access-Token": accessToken } });
|
|
628284
|
+
log4.debug("Shopify Client Response", { res });
|
|
628285
|
+
return res;
|
|
628286
|
+
};
|
|
628287
|
+
genericShopifyPut = async (url, accessToken, payload2) => {
|
|
628288
|
+
const client2 = axiosHttpService();
|
|
628289
|
+
const res = await client2.put(url, payload2, { headers: { "X-Shopify-Access-Token": accessToken } });
|
|
628290
|
+
log4.debug("Shopify Client Response", { res });
|
|
628291
|
+
return res;
|
|
628292
|
+
};
|
|
628293
|
+
};
|
|
628294
|
+
|
|
628203
628295
|
// src/libs/http-error.ts
|
|
628204
628296
|
import { strict as assert } from "assert";
|
|
628205
628297
|
var deepClone = (o = {}) => JSON.parse(JSON.stringify(o));
|
|
@@ -628282,33 +628374,33 @@ __publicField(HttpError, "serviceUnavailable", (headers) => new _HttpError(503,
|
|
|
628282
628374
|
__publicField(HttpError, "gatewayTimeout", () => new _HttpError(504));
|
|
628283
628375
|
|
|
628284
628376
|
// src/helpers/input-validation-helper.ts
|
|
628285
|
-
import * as
|
|
628377
|
+
import * as log5 from "lambda-log";
|
|
628286
628378
|
var validateInput = (schema, input) => {
|
|
628287
|
-
const { error:
|
|
628288
|
-
if (
|
|
628289
|
-
|
|
628379
|
+
const { error: error3, value } = schema.validate(input);
|
|
628380
|
+
if (error3) {
|
|
628381
|
+
log5.info("", { error: error3 });
|
|
628290
628382
|
const httperr = HttpError.badRequest("Input Validation Failure", {
|
|
628291
|
-
errors:
|
|
628383
|
+
errors: error3.details.map((detail) => ({
|
|
628292
628384
|
message: detail?.message,
|
|
628293
628385
|
key: detail?.context?.key,
|
|
628294
628386
|
path: detail?.path
|
|
628295
628387
|
}))
|
|
628296
628388
|
});
|
|
628297
|
-
|
|
628389
|
+
log5.info("", { httperr });
|
|
628298
628390
|
throw httperr;
|
|
628299
628391
|
}
|
|
628300
628392
|
return value;
|
|
628301
628393
|
};
|
|
628302
628394
|
|
|
628303
628395
|
// src/helpers/logging-helper.ts
|
|
628304
|
-
import * as
|
|
628396
|
+
import * as log6 from "lambda-log";
|
|
628305
628397
|
var stage = process?.env?.STAGE;
|
|
628306
|
-
var configureLogger = (event, context,
|
|
628307
|
-
|
|
628308
|
-
|
|
628309
|
-
|
|
628310
|
-
|
|
628311
|
-
|
|
628398
|
+
var configureLogger = (event, context, debug3 = true) => {
|
|
628399
|
+
log6.options.meta.stage = stage;
|
|
628400
|
+
log6.options.meta.source_name = context?.functionName || "unknown";
|
|
628401
|
+
log6.options.meta.awsRequestId = context?.awsRequestId || "unknown";
|
|
628402
|
+
log6.options.meta.lambdaEvent = event;
|
|
628403
|
+
log6.options.debug = debug3;
|
|
628312
628404
|
};
|
|
628313
628405
|
|
|
628314
628406
|
// src/helpers/response-helper.ts
|
|
@@ -628318,13 +628410,13 @@ var success = (body) => {
|
|
|
628318
628410
|
var defaultError = {
|
|
628319
628411
|
message: "internalServerError"
|
|
628320
628412
|
};
|
|
628321
|
-
var failure = (
|
|
628322
|
-
statusCode =
|
|
628413
|
+
var failure = (error3, statusCode = 500) => {
|
|
628414
|
+
statusCode = error3?.statusCode ?? statusCode;
|
|
628323
628415
|
let body = defaultError;
|
|
628324
|
-
if (
|
|
628325
|
-
body =
|
|
628326
|
-
} else if (
|
|
628327
|
-
body = { message:
|
|
628416
|
+
if (error3?.body) {
|
|
628417
|
+
body = error3.body;
|
|
628418
|
+
} else if (error3?.message) {
|
|
628419
|
+
body = { message: error3.message };
|
|
628328
628420
|
} else if (statusCode === 500) {
|
|
628329
628421
|
body = defaultError;
|
|
628330
628422
|
}
|
|
@@ -628430,6 +628522,7 @@ export {
|
|
|
628430
628522
|
EventBridgeClient,
|
|
628431
628523
|
HttpError,
|
|
628432
628524
|
HttpStatusCodes,
|
|
628525
|
+
ShopifyClient,
|
|
628433
628526
|
axiosHttpService,
|
|
628434
628527
|
buildResponse,
|
|
628435
628528
|
configureLogger,
|