@opra/core 1.0.0-alpha.3 → 1.0.0-alpha.5
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.js +0 -1
- package/cjs/http/express-adapter.js +0 -5
- package/cjs/http/http-context.js +1 -0
- package/cjs/http/impl/http-handler.js +4 -3
- package/esm/execution-context.js +0 -1
- package/esm/http/express-adapter.js +0 -5
- package/esm/http/http-context.js +1 -0
- package/esm/http/impl/http-handler.js +4 -3
- package/package.json +4 -4
- package/types/execution-context.d.ts +0 -2
package/cjs/execution-context.js
CHANGED
|
@@ -11,7 +11,6 @@ class ExecutionContext extends strict_typed_events_1.AsyncEventEmitter {
|
|
|
11
11
|
this.document = init.document;
|
|
12
12
|
this.protocol = init.protocol;
|
|
13
13
|
this.platform = init.platform;
|
|
14
|
-
this.platformArgs = init.platformArgs;
|
|
15
14
|
}
|
|
16
15
|
addListener(event, listener) {
|
|
17
16
|
return super.addListener(event, listener);
|
|
@@ -65,14 +65,9 @@ class ExpressAdapter extends http_adapter_js_1.HttpAdapter {
|
|
|
65
65
|
const createContext = (_req, _res, args) => {
|
|
66
66
|
const request = http_incoming_interface_js_1.HttpIncoming.from(_req);
|
|
67
67
|
const response = http_outgoing_interface_js_1.HttpOutgoing.from(_res);
|
|
68
|
-
const platformArgs = {
|
|
69
|
-
request: _req,
|
|
70
|
-
response: _res,
|
|
71
|
-
};
|
|
72
68
|
return new http_context_js_1.HttpContext({
|
|
73
69
|
adapter: this,
|
|
74
70
|
platform: this.platform,
|
|
75
|
-
platformArgs,
|
|
76
71
|
request,
|
|
77
72
|
response,
|
|
78
73
|
controller: args?.controller,
|
package/cjs/http/http-context.js
CHANGED
|
@@ -104,6 +104,7 @@ class HttpContext extends execution_context_js_1.ExecutionContext {
|
|
|
104
104
|
mediaType.type?.generateCodec('decode', {
|
|
105
105
|
partial: operation.requestBody?.partial,
|
|
106
106
|
projection: '*',
|
|
107
|
+
ignoreReadonlyFields: true,
|
|
107
108
|
}) || valgen_1.vg.isAny();
|
|
108
109
|
this.adapter[constants_js_1.kAssetCache].set(mediaType, 'decode', decode);
|
|
109
110
|
}
|
|
@@ -123,7 +123,7 @@ class HttpHandler {
|
|
|
123
123
|
const getDecoder = (prm) => {
|
|
124
124
|
let decode = this[constants_js_1.kAssetCache].get(prm, 'decode');
|
|
125
125
|
if (!decode) {
|
|
126
|
-
decode = prm.type?.generateCodec('decode') || valgen_1.vg.isAny();
|
|
126
|
+
decode = prm.type?.generateCodec('decode', { ignoreReadonlyFields: true }) || valgen_1.vg.isAny();
|
|
127
127
|
this[constants_js_1.kAssetCache].set(prm, 'decode', decode);
|
|
128
128
|
}
|
|
129
129
|
return decode;
|
|
@@ -283,7 +283,7 @@ class HttpHandler {
|
|
|
283
283
|
const operationResultType = document.node.getDataType(common_1.OperationResult);
|
|
284
284
|
let operationResultEncoder = this[constants_js_1.kAssetCache].get(operationResultType, 'encode');
|
|
285
285
|
if (!operationResultEncoder) {
|
|
286
|
-
operationResultEncoder = operationResultType.generateCodec('encode');
|
|
286
|
+
operationResultEncoder = operationResultType.generateCodec('encode', { ignoreWriteonlyFields: true });
|
|
287
287
|
this[constants_js_1.kAssetCache].set(operationResultType, 'encode', operationResultEncoder);
|
|
288
288
|
}
|
|
289
289
|
/** Validate response */
|
|
@@ -295,6 +295,7 @@ class HttpHandler {
|
|
|
295
295
|
encode = operationResponse.type.generateCodec('encode', {
|
|
296
296
|
partial: operationResponse.partial,
|
|
297
297
|
projection: '*',
|
|
298
|
+
ignoreWriteonlyFields: true,
|
|
298
299
|
});
|
|
299
300
|
if (operationResponse) {
|
|
300
301
|
if (operationResponse.isArray)
|
|
@@ -545,7 +546,7 @@ class HttpHandler {
|
|
|
545
546
|
const dt = document.node.getComplexType('OperationResult');
|
|
546
547
|
let encode = this[constants_js_1.kAssetCache].get(dt, 'encode');
|
|
547
548
|
if (!encode) {
|
|
548
|
-
encode = dt.generateCodec('encode');
|
|
549
|
+
encode = dt.generateCodec('encode', { ignoreWriteonlyFields: true });
|
|
549
550
|
this[constants_js_1.kAssetCache].set(dt, 'encode', encode);
|
|
550
551
|
}
|
|
551
552
|
const { i18n } = this.adapter;
|
package/esm/execution-context.js
CHANGED
|
@@ -8,7 +8,6 @@ export class ExecutionContext extends AsyncEventEmitter {
|
|
|
8
8
|
this.document = init.document;
|
|
9
9
|
this.protocol = init.protocol;
|
|
10
10
|
this.platform = init.platform;
|
|
11
|
-
this.platformArgs = init.platformArgs;
|
|
12
11
|
}
|
|
13
12
|
addListener(event, listener) {
|
|
14
13
|
return super.addListener(event, listener);
|
|
@@ -61,14 +61,9 @@ export class ExpressAdapter extends HttpAdapter {
|
|
|
61
61
|
const createContext = (_req, _res, args) => {
|
|
62
62
|
const request = HttpIncoming.from(_req);
|
|
63
63
|
const response = HttpOutgoing.from(_res);
|
|
64
|
-
const platformArgs = {
|
|
65
|
-
request: _req,
|
|
66
|
-
response: _res,
|
|
67
|
-
};
|
|
68
64
|
return new HttpContext({
|
|
69
65
|
adapter: this,
|
|
70
66
|
platform: this.platform,
|
|
71
|
-
platformArgs,
|
|
72
67
|
request,
|
|
73
68
|
response,
|
|
74
69
|
controller: args?.controller,
|
package/esm/http/http-context.js
CHANGED
|
@@ -100,6 +100,7 @@ export class HttpContext extends ExecutionContext {
|
|
|
100
100
|
mediaType.type?.generateCodec('decode', {
|
|
101
101
|
partial: operation.requestBody?.partial,
|
|
102
102
|
projection: '*',
|
|
103
|
+
ignoreReadonlyFields: true,
|
|
103
104
|
}) || vg.isAny();
|
|
104
105
|
this.adapter[kAssetCache].set(mediaType, 'decode', decode);
|
|
105
106
|
}
|
|
@@ -119,7 +119,7 @@ export class HttpHandler {
|
|
|
119
119
|
const getDecoder = (prm) => {
|
|
120
120
|
let decode = this[kAssetCache].get(prm, 'decode');
|
|
121
121
|
if (!decode) {
|
|
122
|
-
decode = prm.type?.generateCodec('decode') || vg.isAny();
|
|
122
|
+
decode = prm.type?.generateCodec('decode', { ignoreReadonlyFields: true }) || vg.isAny();
|
|
123
123
|
this[kAssetCache].set(prm, 'decode', decode);
|
|
124
124
|
}
|
|
125
125
|
return decode;
|
|
@@ -279,7 +279,7 @@ export class HttpHandler {
|
|
|
279
279
|
const operationResultType = document.node.getDataType(OperationResult);
|
|
280
280
|
let operationResultEncoder = this[kAssetCache].get(operationResultType, 'encode');
|
|
281
281
|
if (!operationResultEncoder) {
|
|
282
|
-
operationResultEncoder = operationResultType.generateCodec('encode');
|
|
282
|
+
operationResultEncoder = operationResultType.generateCodec('encode', { ignoreWriteonlyFields: true });
|
|
283
283
|
this[kAssetCache].set(operationResultType, 'encode', operationResultEncoder);
|
|
284
284
|
}
|
|
285
285
|
/** Validate response */
|
|
@@ -291,6 +291,7 @@ export class HttpHandler {
|
|
|
291
291
|
encode = operationResponse.type.generateCodec('encode', {
|
|
292
292
|
partial: operationResponse.partial,
|
|
293
293
|
projection: '*',
|
|
294
|
+
ignoreWriteonlyFields: true,
|
|
294
295
|
});
|
|
295
296
|
if (operationResponse) {
|
|
296
297
|
if (operationResponse.isArray)
|
|
@@ -541,7 +542,7 @@ export class HttpHandler {
|
|
|
541
542
|
const dt = document.node.getComplexType('OperationResult');
|
|
542
543
|
let encode = this[kAssetCache].get(dt, 'encode');
|
|
543
544
|
if (!encode) {
|
|
544
|
-
encode = dt.generateCodec('encode');
|
|
545
|
+
encode = dt.generateCodec('encode', { ignoreWriteonlyFields: true });
|
|
545
546
|
this[kAssetCache].set(dt, 'encode', encode);
|
|
546
547
|
}
|
|
547
548
|
const { i18n } = this.adapter;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@opra/core",
|
|
3
|
-
"version": "1.0.0-alpha.
|
|
3
|
+
"version": "1.0.0-alpha.5",
|
|
4
4
|
"description": "Opra schema package",
|
|
5
5
|
"author": "Panates",
|
|
6
6
|
"license": "MIT",
|
|
@@ -21,8 +21,8 @@
|
|
|
21
21
|
"lint": "eslint . --max-warnings=0",
|
|
22
22
|
"check": "madge --circular src/**",
|
|
23
23
|
"format": "prettier . --write --log-level=warn",
|
|
24
|
-
"test": "jest",
|
|
25
|
-
"cover": "jest --collect-coverage",
|
|
24
|
+
"test": "jest --passWithNoTests",
|
|
25
|
+
"cover": "jest --passWithNoTests --collect-coverage",
|
|
26
26
|
"clean": "npm run clean:src && npm run clean:test && npm run clean:dist && npm run clean:cover",
|
|
27
27
|
"clean:src": "ts-cleanup -s src --all",
|
|
28
28
|
"clean:test": "ts-cleanup -s test --all",
|
|
@@ -31,7 +31,7 @@
|
|
|
31
31
|
},
|
|
32
32
|
"dependencies": {
|
|
33
33
|
"@browsery/type-is": "^1.6.18-r2",
|
|
34
|
-
"@opra/common": "^1.0.0-alpha.
|
|
34
|
+
"@opra/common": "^1.0.0-alpha.5",
|
|
35
35
|
"@types/formidable": "^3.4.5",
|
|
36
36
|
"accepts": "^1.3.8",
|
|
37
37
|
"base64-stream": "^1.0.0",
|
|
@@ -8,7 +8,6 @@ export declare namespace ExecutionContext {
|
|
|
8
8
|
document: ApiDocument;
|
|
9
9
|
protocol: OpraSchema.Protocol;
|
|
10
10
|
platform: string;
|
|
11
|
-
platformArgs: any;
|
|
12
11
|
}
|
|
13
12
|
type OnFinishListener = (error: Error | undefined, context: ExecutionContext) => void | Promise<void>;
|
|
14
13
|
}
|
|
@@ -19,7 +18,6 @@ export declare abstract class ExecutionContext extends AsyncEventEmitter {
|
|
|
19
18
|
readonly document: ApiDocument;
|
|
20
19
|
readonly protocol: OpraSchema.Protocol;
|
|
21
20
|
readonly platform: string;
|
|
22
|
-
readonly platformArgs: any;
|
|
23
21
|
protected constructor(init: ExecutionContext.Initiator);
|
|
24
22
|
addListener(event: 'finish', listener: ExecutionContext.OnFinishListener): this;
|
|
25
23
|
removeListener(event: 'finish', listener: ExecutionContext.OnFinishListener): this;
|