@opra/core 0.26.4 → 0.27.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.
@@ -102,20 +102,36 @@ class PlatformAdapterHost extends strict_typed_events_1.AsyncEventEmitter {
102
102
  }
103
103
  return controller;
104
104
  }
105
- async getOperationHandler(resource, operationOrAction) {
105
+ async getActionHandler(resource, name) {
106
106
  resource = typeof resource === 'object' && resource instanceof common_1.Resource
107
107
  ? resource
108
108
  : this.api.getResource(resource);
109
109
  const controller = await this.getController(resource);
110
- const endpoint = (resource instanceof common_1.CrudResource && resource.operations.get(operationOrAction)) ||
111
- resource.actions.get(operationOrAction);
110
+ const endpoint = resource.actions.get(name);
111
+ if (endpoint) {
112
+ const handler = typeof controller[endpoint.name] === 'function' ? controller[endpoint.name] : undefined;
113
+ if (handler)
114
+ return { controller, endpoint, handler };
115
+ }
116
+ throw new common_1.BadRequestError({
117
+ message: (0, common_1.translate)('ACTION_NOT_FOUND', { resource: resource.name, action: name }, `The {{resource}} resource doesn't have an action named '{{action}}'`),
118
+ severity: 'error',
119
+ code: 'ACTION_NOT_FOUND'
120
+ });
121
+ }
122
+ async getOperationHandler(resource, name) {
123
+ resource = typeof resource === 'object' && resource instanceof common_1.Resource
124
+ ? resource
125
+ : this.api.getResource(resource);
126
+ const controller = await this.getController(resource);
127
+ const endpoint = resource instanceof common_1.CrudResource && resource.operations.get(name);
112
128
  if (endpoint) {
113
129
  const handler = typeof controller[endpoint.name] === 'function' ? controller[endpoint.name] : undefined;
114
130
  if (handler)
115
131
  return { controller, endpoint, handler };
116
132
  }
117
133
  throw new common_1.ForbiddenError({
118
- message: (0, common_1.translate)('OPERATION_FORBIDDEN', { resource: resource.name, endpoint: operationOrAction }, `'{{resource}}' does not accept '{{endpoint}}' operations`),
134
+ message: (0, common_1.translate)('OPERATION_FORBIDDEN', { resource: resource.name, operation: name }, `'The {{resource}} resource does not accept '{{operation}}' operations`),
119
135
  severity: 'error',
120
136
  code: 'OPERATION_FORBIDDEN'
121
137
  });
@@ -6,7 +6,7 @@ var RequestContext;
6
6
  function from(executionContext, request, response) {
7
7
  const out = {
8
8
  request,
9
- response,
9
+ response
10
10
  };
11
11
  Object.setPrototypeOf(out, executionContext);
12
12
  return out;
@@ -4,7 +4,6 @@ export class ExecutionContextHost extends AsyncEventEmitter {
4
4
  super();
5
5
  this.api = api;
6
6
  this.platform = platform;
7
- this.errors = [];
8
7
  this.ws = protocol.ws;
9
8
  this.rpc = protocol.rpc;
10
9
  if (protocol.http) {