ask-sdk-core
Advanced tools
Comparing version 2.0.4 to 2.0.5
@@ -5,2 +5,4 @@ import { Response } from 'ask-sdk-model'; | ||
import { HandlerInput } from './request/handler/HandlerInput'; | ||
import { RequestInterceptor } from './request/interceptor/RequestInterceptor'; | ||
import { ResponseInterceptor } from './request/interceptor/ResponseInterceptor'; | ||
import { RequestMapper } from './request/mapper/RequestMapper'; | ||
@@ -15,2 +17,4 @@ import { RequestDispatcher } from './RequestDispatcher'; | ||
protected handlerAdapters: HandlerAdapter[]; | ||
protected requestInterceptors: RequestInterceptor[]; | ||
protected responseInterceptors: ResponseInterceptor[]; | ||
constructor(options: { | ||
@@ -20,2 +24,4 @@ requestMappers: RequestMapper[]; | ||
errorMapper?: ErrorMapper; | ||
requestInterceptors?: RequestInterceptor[]; | ||
responseInterceptors?: ResponseInterceptor[]; | ||
}); | ||
@@ -22,0 +28,0 @@ /** |
@@ -59,2 +59,4 @@ /* | ||
this.errorMapper = options.errorMapper; | ||
this.requestInterceptors = options.requestInterceptors; | ||
this.responseInterceptors = options.responseInterceptors; | ||
} | ||
@@ -69,18 +71,45 @@ /** | ||
return __awaiter(this, void 0, void 0, function () { | ||
var response, err_1; | ||
return __generator(this, function (_a) { | ||
switch (_a.label) { | ||
var response, _i, _a, requestInterceptor, _b, _c, responseInterceptor, err_1; | ||
return __generator(this, function (_d) { | ||
switch (_d.label) { | ||
case 0: | ||
_a.trys.push([0, 2, , 4]); | ||
return [4 /*yield*/, this.dispatchRequest(handlerInput)]; | ||
_d.trys.push([0, 10, , 12]); | ||
if (!this.requestInterceptors) return [3 /*break*/, 4]; | ||
_i = 0, _a = this.requestInterceptors; | ||
_d.label = 1; | ||
case 1: | ||
response = _a.sent(); | ||
return [3 /*break*/, 4]; | ||
if (!(_i < _a.length)) return [3 /*break*/, 4]; | ||
requestInterceptor = _a[_i]; | ||
return [4 /*yield*/, requestInterceptor.process(handlerInput)]; | ||
case 2: | ||
err_1 = _a.sent(); | ||
_d.sent(); | ||
_d.label = 3; | ||
case 3: | ||
_i++; | ||
return [3 /*break*/, 1]; | ||
case 4: return [4 /*yield*/, this.dispatchRequest(handlerInput)]; | ||
case 5: | ||
// Dispatch request to handler chain | ||
response = _d.sent(); | ||
if (!this.responseInterceptors) return [3 /*break*/, 9]; | ||
_b = 0, _c = this.responseInterceptors; | ||
_d.label = 6; | ||
case 6: | ||
if (!(_b < _c.length)) return [3 /*break*/, 9]; | ||
responseInterceptor = _c[_b]; | ||
return [4 /*yield*/, responseInterceptor.process(handlerInput, response)]; | ||
case 7: | ||
_d.sent(); | ||
_d.label = 8; | ||
case 8: | ||
_b++; | ||
return [3 /*break*/, 6]; | ||
case 9: return [3 /*break*/, 12]; | ||
case 10: | ||
err_1 = _d.sent(); | ||
return [4 /*yield*/, this.dispatchError(handlerInput, err_1)]; | ||
case 3: | ||
response = _a.sent(); | ||
return [3 /*break*/, 4]; | ||
case 4: return [2 /*return*/, response]; | ||
case 11: | ||
response = _d.sent(); | ||
return [3 /*break*/, 12]; | ||
case 12: return [2 /*return*/, response]; | ||
} | ||
@@ -131,3 +160,3 @@ }); | ||
if (!adapter) { | ||
throw AskSdkUtils_1.createAskSdkError(this.constructor.name, 'HandlerAdapter not found!'); | ||
throw AskSdkUtils_1.createAskSdkError(this.constructor.name, "Could not find the handler adapter that supports the request handler."); | ||
} | ||
@@ -134,0 +163,0 @@ if (!requestInterceptors) return [3 /*break*/, 8]; |
@@ -25,3 +25,3 @@ /* | ||
BaseSkillFactory.init = function () { | ||
var thisRequestHandlers = []; | ||
var thisRequestHandlerChains = []; | ||
var thisRequestInterceptors = []; | ||
@@ -53,6 +53,8 @@ var thisResponseInterceptors = []; | ||
} | ||
thisRequestHandlers.push({ | ||
canHandle: canHandle, | ||
handle: executor, | ||
}); | ||
thisRequestHandlerChains.push(new DefaultRequestHandlerChain_1.DefaultRequestHandlerChain({ | ||
requestHandler: { | ||
canHandle: canHandle, | ||
handle: executor, | ||
}, | ||
})); | ||
return this; | ||
@@ -65,3 +67,8 @@ }, | ||
} | ||
thisRequestHandlers.push.apply(thisRequestHandlers, requestHandlers); | ||
for (var _a = 0, requestHandlers_1 = requestHandlers; _a < requestHandlers_1.length; _a++) { | ||
var requestHandler = requestHandlers_1[_a]; | ||
thisRequestHandlerChains.push(new DefaultRequestHandlerChain_1.DefaultRequestHandlerChain({ | ||
requestHandler: requestHandler, | ||
})); | ||
} | ||
return this; | ||
@@ -143,13 +150,4 @@ }, | ||
getSkillConfiguration: function () { | ||
var requestHandlerChains = []; | ||
for (var _i = 0, thisRequestHandlers_1 = thisRequestHandlers; _i < thisRequestHandlers_1.length; _i++) { | ||
var requestHandler = thisRequestHandlers_1[_i]; | ||
requestHandlerChains.push(new DefaultRequestHandlerChain_1.DefaultRequestHandlerChain({ | ||
requestHandler: requestHandler, | ||
requestInterceptors: thisRequestInterceptors, | ||
responseInterceptors: thisResponseInterceptors, | ||
})); | ||
} | ||
var requestMapper = new DefaultRequestMapper_1.DefaultRequestMapper({ | ||
requestHandlerChains: requestHandlerChains, | ||
requestHandlerChains: thisRequestHandlerChains, | ||
}); | ||
@@ -165,2 +163,4 @@ var errorMapper = thisErrorHandlers.length | ||
errorMapper: errorMapper, | ||
requestInterceptors: thisRequestInterceptors, | ||
responseInterceptors: thisResponseInterceptors, | ||
customUserAgent: thisCustomUserAgent, | ||
@@ -167,0 +167,0 @@ skillId: thisSkillId, |
@@ -69,2 +69,4 @@ /* | ||
errorMapper: skillConfiguration.errorMapper, | ||
requestInterceptors: skillConfiguration.requestInterceptors, | ||
responseInterceptors: skillConfiguration.responseInterceptors, | ||
}); | ||
@@ -71,0 +73,0 @@ } |
@@ -5,2 +5,4 @@ import { services } from 'ask-sdk-model'; | ||
import { HandlerAdapter } from '../dispatcher/request/handler/HandlerAdapter'; | ||
import { RequestInterceptor } from '../dispatcher/request/interceptor/RequestInterceptor'; | ||
import { ResponseInterceptor } from '../dispatcher/request/interceptor/ResponseInterceptor'; | ||
import { RequestMapper } from '../dispatcher/request/mapper/RequestMapper'; | ||
@@ -14,2 +16,4 @@ /** | ||
errorMapper?: ErrorMapper; | ||
requestInterceptors?: RequestInterceptor[]; | ||
responseInterceptors?: ResponseInterceptor[]; | ||
persistenceAdapter?: PersistenceAdapter; | ||
@@ -16,0 +20,0 @@ apiClient?: services.ApiClient; |
{ | ||
"name": "ask-sdk-core", | ||
"version": "2.0.4", | ||
"version": "2.0.5", | ||
"description": "Core package for Alexa Skills Kit SDK", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
173202
109
2750