@opra/common 1.0.0-alpha.23 → 1.0.0-alpha.25
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/browser.js +269 -258
- package/cjs/document/data-type/complex-type-base.js +2 -2
- package/cjs/document/data-type/primitive-types/object.type.js +0 -3
- package/cjs/document/decorators/http-operation-entity.decorator.js +1 -1
- package/cjs/document/http/http-media-type.js +17 -2
- package/esm/document/data-type/complex-type-base.js +2 -2
- package/esm/document/data-type/primitive-types/object.type.js +0 -3
- package/esm/document/decorators/http-operation-entity.decorator.js +1 -1
- package/esm/document/http/http-media-type.js +16 -2
- package/package.json +2 -1
- package/types/document/data-type/complex-type-base.d.ts +1 -1
- package/types/document/http/http-media-type.d.ts +2 -1
- package/types/document/http/http-operation.d.ts +1 -1
|
@@ -132,7 +132,7 @@ class ComplexTypeBaseClass extends data_type_js_1.DataType {
|
|
|
132
132
|
}
|
|
133
133
|
}
|
|
134
134
|
return valgen_1.vg.isObject(schema, {
|
|
135
|
-
ctor: this.ctor,
|
|
135
|
+
ctor: this.name === 'object' ? Object : this.ctor,
|
|
136
136
|
additionalFields,
|
|
137
137
|
name: this.name,
|
|
138
138
|
coerce: true,
|
|
@@ -169,7 +169,7 @@ class ComplexTypeBaseClass extends data_type_js_1.DataType {
|
|
|
169
169
|
const fn = this._generateFieldCodec(codec, field, {
|
|
170
170
|
...context,
|
|
171
171
|
partial: context.partial === 'deep' ? context.partial : undefined,
|
|
172
|
-
projection
|
|
172
|
+
projection,
|
|
173
173
|
currentPath: currentPath + (currentPath ? '.' : '') + fieldName,
|
|
174
174
|
});
|
|
175
175
|
schema[fieldName] = context.partial || !field.required ? valgen_1.vg.optional(fn) : valgen_1.vg.required(fn);
|
|
@@ -2,7 +2,6 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.ObjectType = void 0;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
|
-
const constants_js_1 = require("../../constants.js");
|
|
6
5
|
const complex_type_js_1 = require("../complex-type.js");
|
|
7
6
|
let ObjectType = class ObjectType {
|
|
8
7
|
constructor(properties) {
|
|
@@ -19,5 +18,3 @@ exports.ObjectType = ObjectType = tslib_1.__decorate([
|
|
|
19
18
|
}),
|
|
20
19
|
tslib_1.__metadata("design:paramtypes", [Object])
|
|
21
20
|
], ObjectType);
|
|
22
|
-
const metadata = Reflect.getMetadata(constants_js_1.DATATYPE_METADATA, ObjectType);
|
|
23
|
-
metadata.ctor = Object;
|
|
@@ -196,7 +196,7 @@ http_operation_js_1.HttpOperation.Entity.FindMany = function (arg0, arg1) {
|
|
|
196
196
|
})
|
|
197
197
|
.QueryParam('limit', {
|
|
198
198
|
description: 'Determines number of returning instances',
|
|
199
|
-
type: new index_js_4.IntegerType({ minValue: 1 }),
|
|
199
|
+
type: new index_js_4.IntegerType({ minValue: 1, maxValue: args.maxLimit }),
|
|
200
200
|
})
|
|
201
201
|
.QueryParam('skip', {
|
|
202
202
|
description: 'Determines number of returning instances',
|
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.HttpMediaType = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const type_is_1 = tslib_1.__importDefault(require("@browsery/type-is"));
|
|
4
6
|
const ts_gems_1 = require("ts-gems");
|
|
7
|
+
const valgen_1 = require("valgen");
|
|
5
8
|
const index_js_1 = require("../../helpers/index.js");
|
|
6
9
|
const document_element_js_1 = require("../common/document-element.js");
|
|
7
10
|
const data_type_js_1 = require("../data-type/data-type.js");
|
|
@@ -24,7 +27,6 @@ exports.HttpMediaType = function (owner, initArgs) {
|
|
|
24
27
|
_this.maxFiles = initArgs.maxFiles;
|
|
25
28
|
_this.maxFileSize = initArgs.maxFileSize;
|
|
26
29
|
_this.maxTotalFileSize = initArgs.maxTotalFileSize;
|
|
27
|
-
_this.minFileSize = initArgs.minFileSize;
|
|
28
30
|
if (initArgs?.type) {
|
|
29
31
|
_this.type = initArgs?.type instanceof data_type_js_1.DataType ? initArgs.type : _this.owner.node.getDataType(initArgs.type);
|
|
30
32
|
}
|
|
@@ -59,12 +61,25 @@ class HttpMediaTypeClass extends document_element_js_1.DocumentElement {
|
|
|
59
61
|
maxFiles: this.maxFiles,
|
|
60
62
|
maxFileSize: this.maxFileSize,
|
|
61
63
|
maxTotalFileSize: this.maxTotalFileSize,
|
|
62
|
-
minFileSize: this.minFileSize,
|
|
63
64
|
});
|
|
64
65
|
if (this.multipartFields?.length) {
|
|
65
66
|
out.multipartFields = this.multipartFields.map(x => x.toJSON());
|
|
66
67
|
}
|
|
67
68
|
return out;
|
|
68
69
|
}
|
|
70
|
+
generateCodec(codec, options) {
|
|
71
|
+
let fn;
|
|
72
|
+
if (this.type) {
|
|
73
|
+
fn = this.type.generateCodec(codec, options);
|
|
74
|
+
}
|
|
75
|
+
else if (this.contentType) {
|
|
76
|
+
const arr = Array.isArray(this.contentType) ? this.contentType : [this.contentType];
|
|
77
|
+
if (arr.find(ct => type_is_1.default.is(ct, ['json']))) {
|
|
78
|
+
fn = this.node.findDataType('object').generateCodec(codec);
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
fn = fn || valgen_1.isAny;
|
|
82
|
+
return this.isArray ? valgen_1.vg.isArray(fn) : fn;
|
|
83
|
+
}
|
|
69
84
|
}
|
|
70
85
|
exports.HttpMediaType.prototype = HttpMediaTypeClass.prototype;
|
|
@@ -129,7 +129,7 @@ class ComplexTypeBaseClass extends DataType {
|
|
|
129
129
|
}
|
|
130
130
|
}
|
|
131
131
|
return vg.isObject(schema, {
|
|
132
|
-
ctor: this.ctor,
|
|
132
|
+
ctor: this.name === 'object' ? Object : this.ctor,
|
|
133
133
|
additionalFields,
|
|
134
134
|
name: this.name,
|
|
135
135
|
coerce: true,
|
|
@@ -166,7 +166,7 @@ class ComplexTypeBaseClass extends DataType {
|
|
|
166
166
|
const fn = this._generateFieldCodec(codec, field, {
|
|
167
167
|
...context,
|
|
168
168
|
partial: context.partial === 'deep' ? context.partial : undefined,
|
|
169
|
-
projection
|
|
169
|
+
projection,
|
|
170
170
|
currentPath: currentPath + (currentPath ? '.' : '') + fieldName,
|
|
171
171
|
});
|
|
172
172
|
schema[fieldName] = context.partial || !field.required ? vg.optional(fn) : vg.required(fn);
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { __decorate, __metadata } from "tslib";
|
|
2
|
-
import { DATATYPE_METADATA } from '../../constants.js';
|
|
3
2
|
import { ComplexType } from '../complex-type.js';
|
|
4
3
|
let ObjectType = class ObjectType {
|
|
5
4
|
constructor(properties) {
|
|
@@ -16,5 +15,3 @@ ObjectType = __decorate([
|
|
|
16
15
|
__metadata("design:paramtypes", [Object])
|
|
17
16
|
], ObjectType);
|
|
18
17
|
export { ObjectType };
|
|
19
|
-
const metadata = Reflect.getMetadata(DATATYPE_METADATA, ObjectType);
|
|
20
|
-
metadata.ctor = Object;
|
|
@@ -194,7 +194,7 @@ HttpOperation.Entity.FindMany = function (arg0, arg1) {
|
|
|
194
194
|
})
|
|
195
195
|
.QueryParam('limit', {
|
|
196
196
|
description: 'Determines number of returning instances',
|
|
197
|
-
type: new IntegerType({ minValue: 1 }),
|
|
197
|
+
type: new IntegerType({ minValue: 1, maxValue: args.maxLimit }),
|
|
198
198
|
})
|
|
199
199
|
.QueryParam('skip', {
|
|
200
200
|
description: 'Determines number of returning instances',
|
|
@@ -1,4 +1,6 @@
|
|
|
1
|
+
import typeIs from '@browsery/type-is';
|
|
1
2
|
import { asMutable } from 'ts-gems';
|
|
3
|
+
import { isAny, vg } from 'valgen';
|
|
2
4
|
import { omitUndefined } from '../../helpers/index.js';
|
|
3
5
|
import { DocumentElement } from '../common/document-element.js';
|
|
4
6
|
import { DataType } from '../data-type/data-type.js';
|
|
@@ -21,7 +23,6 @@ export const HttpMediaType = function (owner, initArgs) {
|
|
|
21
23
|
_this.maxFiles = initArgs.maxFiles;
|
|
22
24
|
_this.maxFileSize = initArgs.maxFileSize;
|
|
23
25
|
_this.maxTotalFileSize = initArgs.maxTotalFileSize;
|
|
24
|
-
_this.minFileSize = initArgs.minFileSize;
|
|
25
26
|
if (initArgs?.type) {
|
|
26
27
|
_this.type = initArgs?.type instanceof DataType ? initArgs.type : _this.owner.node.getDataType(initArgs.type);
|
|
27
28
|
}
|
|
@@ -56,12 +57,25 @@ class HttpMediaTypeClass extends DocumentElement {
|
|
|
56
57
|
maxFiles: this.maxFiles,
|
|
57
58
|
maxFileSize: this.maxFileSize,
|
|
58
59
|
maxTotalFileSize: this.maxTotalFileSize,
|
|
59
|
-
minFileSize: this.minFileSize,
|
|
60
60
|
});
|
|
61
61
|
if (this.multipartFields?.length) {
|
|
62
62
|
out.multipartFields = this.multipartFields.map(x => x.toJSON());
|
|
63
63
|
}
|
|
64
64
|
return out;
|
|
65
65
|
}
|
|
66
|
+
generateCodec(codec, options) {
|
|
67
|
+
let fn;
|
|
68
|
+
if (this.type) {
|
|
69
|
+
fn = this.type.generateCodec(codec, options);
|
|
70
|
+
}
|
|
71
|
+
else if (this.contentType) {
|
|
72
|
+
const arr = Array.isArray(this.contentType) ? this.contentType : [this.contentType];
|
|
73
|
+
if (arr.find(ct => typeIs.is(ct, ['json']))) {
|
|
74
|
+
fn = this.node.findDataType('object').generateCodec(codec);
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
fn = fn || isAny;
|
|
78
|
+
return this.isArray ? vg.isArray(fn) : fn;
|
|
79
|
+
}
|
|
66
80
|
}
|
|
67
81
|
HttpMediaType.prototype = HttpMediaTypeClass.prototype;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@opra/common",
|
|
3
|
-
"version": "1.0.0-alpha.
|
|
3
|
+
"version": "1.0.0-alpha.25",
|
|
4
4
|
"description": "Opra common package",
|
|
5
5
|
"author": "Panates",
|
|
6
6
|
"license": "MIT",
|
|
@@ -40,6 +40,7 @@
|
|
|
40
40
|
"@browsery/highland": "^2.13.5",
|
|
41
41
|
"@browsery/http-parser": "^0.5.8",
|
|
42
42
|
"@browsery/i18next": "^23.11.5",
|
|
43
|
+
"@browsery/type-is": "^1.6.18-r3",
|
|
43
44
|
"fast-tokenizer": "^1.3.0",
|
|
44
45
|
"lodash.omit": "^4.5.0",
|
|
45
46
|
"putil-isplainobject": "^1.1.5",
|
|
@@ -74,7 +74,7 @@ declare abstract class ComplexTypeBaseClass extends DataType {
|
|
|
74
74
|
}): IsObject.Schema;
|
|
75
75
|
protected _generateFieldCodec(codec: 'encode' | 'decode', field: ApiField, context: StrictOmit<DataType.GenerateCodecOptions, 'projection'> & {
|
|
76
76
|
currentPath: string;
|
|
77
|
-
projection?: FieldsProjection;
|
|
77
|
+
projection?: FieldsProjection | '*';
|
|
78
78
|
}): Validator;
|
|
79
79
|
}
|
|
80
80
|
export {};
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { Combine, StrictOmit, Type } from 'ts-gems';
|
|
2
|
+
import { Validator } from 'valgen';
|
|
2
3
|
import { OpraSchema } from '../../schema/index.js';
|
|
3
4
|
import { DocumentElement } from '../common/document-element.js';
|
|
4
5
|
import { DataType } from '../data-type/data-type.js';
|
|
@@ -52,8 +53,8 @@ declare class HttpMediaTypeClass extends DocumentElement {
|
|
|
52
53
|
maxFiles?: number;
|
|
53
54
|
maxFileSize?: number;
|
|
54
55
|
maxTotalFileSize?: number;
|
|
55
|
-
minFileSize?: number;
|
|
56
56
|
findMultipartField(fieldName: string, fieldType?: OpraSchema.HttpMultipartFieldType): HttpMultipartField | undefined;
|
|
57
57
|
toJSON(): OpraSchema.HttpMediaType;
|
|
58
|
+
generateCodec(codec: 'encode' | 'decode', options?: DataType.GenerateCodecOptions): Validator;
|
|
58
59
|
}
|
|
59
60
|
export {};
|
|
@@ -20,7 +20,7 @@ export declare namespace HttpOperation {
|
|
|
20
20
|
requestBody?: HttpRequestBody.Metadata;
|
|
21
21
|
immediateFetch?: boolean;
|
|
22
22
|
}
|
|
23
|
-
interface Options extends Partial<Pick<Metadata, 'path' | 'description' | 'method' | 'immediateFetch'>> {
|
|
23
|
+
interface Options extends Partial<Pick<Metadata, 'path' | 'mergePath' | 'description' | 'method' | 'immediateFetch'>> {
|
|
24
24
|
requestBody?: HttpRequestBody.Options;
|
|
25
25
|
}
|
|
26
26
|
interface InitArguments extends Combine<{
|