@opra/common 1.28.5 → 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.
@@ -50,11 +50,10 @@ declare class HttpMediaTypeClass extends DocumentElement {
50
50
  example?: string;
51
51
  examples?: Record<string, string>;
52
52
  multipartFields: HttpMultipartField[];
53
- maxFields?: number;
54
- maxFieldsSize?: number;
55
- maxFiles?: number;
56
- maxFileSize?: number;
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.maxFieldsSize = initArgs.maxFieldsSize;
26
- _this.maxFields = initArgs.maxFields;
27
- _this.maxFiles = initArgs.maxFiles;
28
- _this.maxFileSize = initArgs.maxFileSize;
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
- maxFields: this.maxFields,
67
- maxFieldsSize: this.maxFieldsSize,
68
- maxFiles: this.maxFiles,
69
- maxFileSize: this.maxFileSize,
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",
@@ -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
- 'fatal' = "fatal",
4
- 'error' = "error",
5
- 'warning' = "warning",
6
- 'info' = "info"
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 (!exists)
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,6 +1,6 @@
1
1
  {
2
2
  "name": "@opra/common",
3
- "version": "1.28.5",
3
+ "version": "1.29.0",
4
4
  "description": "Opra common package",
5
5
  "author": "Panates",
6
6
  "license": "MIT",
@@ -11,7 +11,7 @@
11
11
  "@browsery/http-parser": "^0.5.10-r3",
12
12
  "@browsery/i18next": "^25.6.0",
13
13
  "@browsery/type-is": "^2.0.2-r1",
14
- "@jsopen/objects": "^2.2.2",
14
+ "@jsopen/objects": "^2.2.3",
15
15
  "fast-tokenizer": "^1.9.0",
16
16
  "object-hash": "^3.0.0",
17
17
  "putil-promisify": "^1.10.1",
@@ -20,7 +20,7 @@
20
20
  "super-fast-md5": "^1.0.3",
21
21
  "tslib": "^2.8.1",
22
22
  "uid": "^2.0.2",
23
- "valgen": "^6.2.0"
23
+ "valgen": "^6.2.2"
24
24
  },
25
25
  "type": "module",
26
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 fields
43
+ * Determines maximum number of multipart item
44
44
  */
45
- maxFields?: number;
45
+ maxParts?: number;
46
46
  /**
47
- * Determines maximum size of each multipart field
48
- */
49
- maxFieldsSize?: number;
50
- /**
51
- * Determines maximum number of multipart files
47
+ * Determines maximum size of each multipart item
52
48
  */
53
- maxFiles?: number;
49
+ maxPartSize?: number;
54
50
  /**
55
- * Determines maximum size of each multipart file
56
- */
57
- maxFileSize?: number;
58
- /**
59
- * Determines maximum size of all multipart files
51
+ * Determines maximum size of each multipart field
60
52
  */
61
- maxTotalFileSize?: number;
53
+ maxFieldSize?: number;
62
54
  /**
63
- * Determines minimum size of each multipart file
55
+ * Determines maximum size of all multipart items
64
56
  */
65
- minFileSize?: number;
57
+ maxTotalSize?: number;
66
58
  }