@opra/common 1.28.4 → 1.29.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/LICENSE +1 -1
- package/README.md +86 -4
- package/browser.js +4 -4
- package/document/http/http-media-type.d.ts +4 -5
- package/document/http/http-media-type.js +8 -10
- package/enums/mime-types.enum.d.ts +1 -0
- package/enums/mime-types.enum.js +1 -0
- package/exception/issue-severity.enum.d.ts +4 -4
- package/helpers/responsive-map.d.ts +3 -1
- package/helpers/responsive-map.js +46 -2
- package/package.json +4 -3
- package/schema/http/http-media-type.interface.d.ts +8 -16
|
@@ -50,11 +50,10 @@ declare class HttpMediaTypeClass extends DocumentElement {
|
|
|
50
50
|
example?: string;
|
|
51
51
|
examples?: Record<string, string>;
|
|
52
52
|
multipartFields: HttpMultipartField[];
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
maxTotalFileSize?: number;
|
|
53
|
+
maxParts?: number;
|
|
54
|
+
maxPartSize?: number;
|
|
55
|
+
maxFieldSize?: number;
|
|
56
|
+
maxTotalSize?: number;
|
|
58
57
|
designType?: Type;
|
|
59
58
|
findMultipartField(fieldName: string, fieldType?: OpraSchema.HttpMultipartFieldType): HttpMultipartField | undefined;
|
|
60
59
|
toJSON(options?: ApiDocument.ExportOptions): OpraSchema.HttpMediaType;
|
|
@@ -22,11 +22,10 @@ export const HttpMediaType = function (owner, initArgs) {
|
|
|
22
22
|
_this.contentEncoding = initArgs.contentEncoding;
|
|
23
23
|
_this.examples = initArgs.examples;
|
|
24
24
|
_this.multipartFields = [];
|
|
25
|
-
_this.
|
|
26
|
-
_this.
|
|
27
|
-
_this.
|
|
28
|
-
_this.
|
|
29
|
-
_this.maxTotalFileSize = initArgs.maxTotalFileSize;
|
|
25
|
+
_this.maxParts = initArgs.maxParts;
|
|
26
|
+
_this.maxPartSize = initArgs.maxPartSize;
|
|
27
|
+
_this.maxFieldSize = initArgs.maxFieldSize;
|
|
28
|
+
_this.maxTotalSize = initArgs.maxTotalSize;
|
|
30
29
|
if (initArgs?.type) {
|
|
31
30
|
_this.type =
|
|
32
31
|
initArgs?.type instanceof DataType
|
|
@@ -63,11 +62,10 @@ class HttpMediaTypeClass extends DocumentElement {
|
|
|
63
62
|
isArray: this.isArray,
|
|
64
63
|
example: this.example,
|
|
65
64
|
examples: this.examples,
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
maxTotalFileSize: this.maxTotalFileSize,
|
|
65
|
+
maxParts: this.maxParts,
|
|
66
|
+
maxPartSize: this.maxPartSize,
|
|
67
|
+
maxFieldSize: this.maxFieldSize,
|
|
68
|
+
maxTotalSize: this.maxTotalSize,
|
|
71
69
|
});
|
|
72
70
|
if (this.multipartFields?.length) {
|
|
73
71
|
out.multipartFields = this.multipartFields.map(x => x.toJSON(options));
|
|
@@ -12,6 +12,7 @@ export declare enum MimeTypes {
|
|
|
12
12
|
html = "text/html",
|
|
13
13
|
markdown = "text/markdown",
|
|
14
14
|
binary = "binary/octet-stream",
|
|
15
|
+
multipart_mixed = "multipart/mixed",
|
|
15
16
|
opra_response_json = "application/opra.response+json",
|
|
16
17
|
opra_response_xml = "application/opra.response+xml",
|
|
17
18
|
opra_response_yaml = "text/opra.response+yaml",
|
package/enums/mime-types.enum.js
CHANGED
|
@@ -14,6 +14,7 @@ export var MimeTypes;
|
|
|
14
14
|
MimeTypes["html"] = "text/html";
|
|
15
15
|
MimeTypes["markdown"] = "text/markdown";
|
|
16
16
|
MimeTypes["binary"] = "binary/octet-stream";
|
|
17
|
+
MimeTypes["multipart_mixed"] = "multipart/mixed";
|
|
17
18
|
MimeTypes["opra_response_json"] = "application/opra.response+json";
|
|
18
19
|
MimeTypes["opra_response_xml"] = "application/opra.response+xml";
|
|
19
20
|
MimeTypes["opra_response_yaml"] = "text/opra.response+yaml";
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
export declare namespace IssueSeverity {
|
|
2
2
|
enum Enum {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
3
|
+
fatal = "fatal",
|
|
4
|
+
error = "error",
|
|
5
|
+
warning = "warning",
|
|
6
|
+
info = "info"
|
|
7
7
|
}
|
|
8
8
|
const name = "IssueSeverity";
|
|
9
9
|
const description = "Severity of the issue";
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import EventEmitter from 'events';
|
|
1
2
|
export interface ResponsiveMapOptions {
|
|
2
3
|
wellKnownKeys?: string[];
|
|
3
4
|
caseSensitive?: boolean;
|
|
@@ -11,7 +12,7 @@ declare const kSize: unique symbol;
|
|
|
11
12
|
/**
|
|
12
13
|
* A Map implementation that supports case-insensitivity and ordered keys
|
|
13
14
|
*/
|
|
14
|
-
export declare class ResponsiveMap<V> {
|
|
15
|
+
export declare class ResponsiveMap<V> extends EventEmitter {
|
|
15
16
|
private [kSize];
|
|
16
17
|
private [kEntries];
|
|
17
18
|
private [kKeyMap];
|
|
@@ -31,6 +32,7 @@ export declare class ResponsiveMap<V> {
|
|
|
31
32
|
delete(key: string): boolean;
|
|
32
33
|
sort(compareFn?: (a: string, b: string) => number): this;
|
|
33
34
|
toObject(): Record<string, V>;
|
|
35
|
+
toProxy(): Record<string, V>;
|
|
34
36
|
[Symbol.iterator](): IterableIterator<[string, V]>;
|
|
35
37
|
get [Symbol.toStringTag](): string;
|
|
36
38
|
protected _getOriginalKey(key: string): string;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import EventEmitter from 'events';
|
|
1
2
|
function isMap(v) {
|
|
2
3
|
return v && typeof v.forEach === 'function';
|
|
3
4
|
}
|
|
@@ -9,8 +10,9 @@ const kSize = Symbol.for('kSize');
|
|
|
9
10
|
/**
|
|
10
11
|
* A Map implementation that supports case-insensitivity and ordered keys
|
|
11
12
|
*/
|
|
12
|
-
export class ResponsiveMap {
|
|
13
|
+
export class ResponsiveMap extends EventEmitter {
|
|
13
14
|
constructor(init, options) {
|
|
15
|
+
super();
|
|
14
16
|
Object.defineProperty(this, kSize, {
|
|
15
17
|
value: 0,
|
|
16
18
|
enumerable: false,
|
|
@@ -57,6 +59,8 @@ export class ResponsiveMap {
|
|
|
57
59
|
Object.keys(this[kEntries]).forEach(k => delete this[kEntries][k]);
|
|
58
60
|
Object.keys(this[kKeyMap]).forEach(k => delete this[kKeyMap][k]);
|
|
59
61
|
this[kSize] = 0;
|
|
62
|
+
this.emit('change');
|
|
63
|
+
this.emit('clear');
|
|
60
64
|
}
|
|
61
65
|
forEach(callbackfn, thisArg) {
|
|
62
66
|
for (const [k, v] of this.entries()) {
|
|
@@ -81,6 +85,8 @@ export class ResponsiveMap {
|
|
|
81
85
|
if (!exists)
|
|
82
86
|
this[kSize]++;
|
|
83
87
|
this[kKeyMap][storeKey] = key;
|
|
88
|
+
this.emit('change');
|
|
89
|
+
this.emit('set', key, value);
|
|
84
90
|
return this;
|
|
85
91
|
}
|
|
86
92
|
setAll(source) {
|
|
@@ -104,8 +110,10 @@ export class ResponsiveMap {
|
|
|
104
110
|
const exists = Object.prototype.hasOwnProperty.call(this[kEntries], storeKey);
|
|
105
111
|
delete this[kEntries][storeKey];
|
|
106
112
|
delete this[kKeyMap][storeKey];
|
|
107
|
-
if (
|
|
113
|
+
if (exists) {
|
|
108
114
|
this[kSize]--;
|
|
115
|
+
this.emit('change');
|
|
116
|
+
}
|
|
109
117
|
return exists;
|
|
110
118
|
}
|
|
111
119
|
sort(compareFn) {
|
|
@@ -122,6 +130,7 @@ export class ResponsiveMap {
|
|
|
122
130
|
this[kKeyMap][k] = oldKeymap[k];
|
|
123
131
|
}
|
|
124
132
|
this[kSize] = keys.length;
|
|
133
|
+
this.emit('change');
|
|
125
134
|
return this;
|
|
126
135
|
}
|
|
127
136
|
toObject() {
|
|
@@ -131,6 +140,41 @@ export class ResponsiveMap {
|
|
|
131
140
|
}
|
|
132
141
|
return out;
|
|
133
142
|
}
|
|
143
|
+
toProxy() {
|
|
144
|
+
const _this = this;
|
|
145
|
+
return new Proxy(_this[kEntries], {
|
|
146
|
+
get(target, prop) {
|
|
147
|
+
return typeof prop === 'string' ? _this.get(prop) : undefined;
|
|
148
|
+
},
|
|
149
|
+
set(target, prop, value) {
|
|
150
|
+
if (typeof prop === 'string') {
|
|
151
|
+
_this.set(prop, value);
|
|
152
|
+
return true;
|
|
153
|
+
}
|
|
154
|
+
return false;
|
|
155
|
+
},
|
|
156
|
+
has(target, prop) {
|
|
157
|
+
return typeof prop === 'string' ? _this.has(prop) : false;
|
|
158
|
+
},
|
|
159
|
+
deleteProperty(target, prop) {
|
|
160
|
+
if (typeof prop === 'string') {
|
|
161
|
+
_this.delete(prop);
|
|
162
|
+
return true;
|
|
163
|
+
}
|
|
164
|
+
return false;
|
|
165
|
+
},
|
|
166
|
+
defineProperty(target, prop, attributes) {
|
|
167
|
+
if (typeof prop === 'string') {
|
|
168
|
+
if (attributes.value !== undefined)
|
|
169
|
+
_this.set(prop, attributes.value);
|
|
170
|
+
else
|
|
171
|
+
_this.delete(prop);
|
|
172
|
+
return true;
|
|
173
|
+
}
|
|
174
|
+
return false;
|
|
175
|
+
},
|
|
176
|
+
});
|
|
177
|
+
}
|
|
134
178
|
[Symbol.iterator]() {
|
|
135
179
|
return this.entries();
|
|
136
180
|
}
|
package/package.json
CHANGED
|
@@ -1,16 +1,17 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@opra/common",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.29.0",
|
|
4
4
|
"description": "Opra common package",
|
|
5
5
|
"author": "Panates",
|
|
6
6
|
"license": "MIT",
|
|
7
|
+
"homepage": "https://www.oprajs.com",
|
|
7
8
|
"dependencies": {
|
|
8
9
|
"@browsery/antlr4": "^4.13.3-r7",
|
|
9
10
|
"@browsery/highland": "^2.13.6-r5",
|
|
10
11
|
"@browsery/http-parser": "^0.5.10-r3",
|
|
11
12
|
"@browsery/i18next": "^25.6.0",
|
|
12
13
|
"@browsery/type-is": "^2.0.2-r1",
|
|
13
|
-
"@jsopen/objects": "^2.2.
|
|
14
|
+
"@jsopen/objects": "^2.2.3",
|
|
14
15
|
"fast-tokenizer": "^1.9.0",
|
|
15
16
|
"object-hash": "^3.0.0",
|
|
16
17
|
"putil-promisify": "^1.10.1",
|
|
@@ -19,7 +20,7 @@
|
|
|
19
20
|
"super-fast-md5": "^1.0.3",
|
|
20
21
|
"tslib": "^2.8.1",
|
|
21
22
|
"uid": "^2.0.2",
|
|
22
|
-
"valgen": "^6.2.
|
|
23
|
+
"valgen": "^6.2.2"
|
|
23
24
|
},
|
|
24
25
|
"type": "module",
|
|
25
26
|
"module": "./index.js",
|
|
@@ -40,27 +40,19 @@ export interface HttpMediaType {
|
|
|
40
40
|
*/
|
|
41
41
|
multipartFields?: HttpMultipartField[];
|
|
42
42
|
/**
|
|
43
|
-
* Determines maximum number of multipart
|
|
43
|
+
* Determines maximum number of multipart item
|
|
44
44
|
*/
|
|
45
|
-
|
|
45
|
+
maxParts?: number;
|
|
46
46
|
/**
|
|
47
|
-
* Determines maximum size of each multipart
|
|
48
|
-
*/
|
|
49
|
-
maxFieldsSize?: number;
|
|
50
|
-
/**
|
|
51
|
-
* Determines maximum number of multipart files
|
|
47
|
+
* Determines maximum size of each multipart item
|
|
52
48
|
*/
|
|
53
|
-
|
|
49
|
+
maxPartSize?: number;
|
|
54
50
|
/**
|
|
55
|
-
* Determines maximum size of each multipart
|
|
56
|
-
*/
|
|
57
|
-
maxFileSize?: number;
|
|
58
|
-
/**
|
|
59
|
-
* Determines maximum size of all multipart files
|
|
51
|
+
* Determines maximum size of each multipart field
|
|
60
52
|
*/
|
|
61
|
-
|
|
53
|
+
maxFieldSize?: number;
|
|
62
54
|
/**
|
|
63
|
-
* Determines
|
|
55
|
+
* Determines maximum size of all multipart items
|
|
64
56
|
*/
|
|
65
|
-
|
|
57
|
+
maxTotalSize?: number;
|
|
66
58
|
}
|