@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.
- package/cjs/execution-context.host.js +0 -1
- package/cjs/http/http-adapter-host.js +190 -169
- package/cjs/platform-adapter.host.js +20 -4
- package/cjs/request-context.js +1 -1
- package/esm/execution-context.host.js +0 -1
- package/esm/http/http-adapter-host.js +191 -170
- package/esm/platform-adapter.host.js +21 -5
- package/esm/request-context.js +1 -1
- package/i18n/en/error.json +2 -1
- package/package.json +4 -4
- package/types/augmentation/collection.augmentation.d.ts +32 -18
- package/types/augmentation/container.augmentation.d.ts +4 -3
- package/types/augmentation/singleton.augmentation.d.ts +20 -12
- package/types/augmentation/storage.augmentation.d.ts +16 -9
- package/types/execution-context.d.ts +0 -1
- package/types/execution-context.host.d.ts +0 -1
- package/types/http/http-adapter-host.d.ts +4 -4
- package/types/platform-adapter.host.d.ts +8 -3
- package/types/request.d.ts +2 -4
- package/types/request.host.d.ts +2 -0
- package/types/response.d.ts +1 -1
|
@@ -102,20 +102,36 @@ class PlatformAdapterHost extends strict_typed_events_1.AsyncEventEmitter {
|
|
|
102
102
|
}
|
|
103
103
|
return controller;
|
|
104
104
|
}
|
|
105
|
-
async
|
|
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 =
|
|
111
|
-
|
|
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,
|
|
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
|
});
|
package/cjs/request-context.js
CHANGED