@opra/common 0.18.3 → 0.19.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/browser.js +1225 -910
- package/cjs/document/api-document.js +55 -38
- package/cjs/document/data-type/api-field.js +5 -5
- package/cjs/document/data-type/builtin/any.type.js +3 -5
- package/cjs/document/data-type/builtin/base64.type.js +5 -28
- package/cjs/document/data-type/builtin/bigint.type.js +7 -25
- package/cjs/document/data-type/builtin/boolean.type.js +5 -18
- package/cjs/document/data-type/builtin/date.type.js +13 -9
- package/cjs/document/data-type/builtin/index.js +3 -1
- package/cjs/document/data-type/builtin/integer.type.js +5 -18
- package/cjs/document/data-type/builtin/number.type.js +5 -23
- package/cjs/document/data-type/builtin/object.type.js +4 -9
- package/cjs/document/data-type/builtin/string.type.js +5 -14
- package/cjs/document/data-type/builtin/time.type.js +11 -23
- package/cjs/document/data-type/builtin/timestamp.type.js +8 -20
- package/cjs/document/data-type/builtin/uuid.type.js +15 -0
- package/cjs/document/data-type/complex-type.js +151 -92
- package/cjs/document/data-type/data-type.js +32 -31
- package/cjs/document/data-type/enum-type.js +49 -43
- package/cjs/document/data-type/mapped-type.js +115 -70
- package/cjs/document/data-type/simple-type.js +46 -45
- package/cjs/document/data-type/union-type.js +69 -36
- package/cjs/document/factory/create-document.js +5 -3
- package/cjs/document/factory/factory.js +23 -20
- package/cjs/document/factory/import-type-class.js +13 -4
- package/cjs/document/resource/collection.js +55 -59
- package/cjs/document/resource/resource.js +10 -21
- package/cjs/document/resource/singleton.js +36 -39
- package/cjs/exception/common-errors/validation.error.js +11 -0
- package/cjs/exception/index.js +2 -1
- package/cjs/exception/{enums/issue-severity.enum.js → issue-severity.enum.js} +1 -1
- package/cjs/exception/opra-exception.js +2 -2
- package/cjs/filter/antlr/OpraFilterLexer.js +1 -1
- package/cjs/filter/antlr/OpraFilterParser.js +1 -1
- package/cjs/filter/errors.js +5 -0
- package/cjs/http/enums/http-headers-codes.enum.js +1 -1
- package/cjs/http/enums/http-status-codes.enum.js +1 -1
- package/cjs/http/http-request-message.js +1 -1
- package/cjs/http/http-response-message.js +1 -1
- package/cjs/schema/data-type/complex-type.interface.js +1 -1
- package/cjs/schema/data-type/enum-type.interface.js +1 -1
- package/cjs/schema/data-type/mapped-type.interface.js +1 -1
- package/cjs/schema/data-type/simple-type.interface.js +1 -1
- package/cjs/schema/data-type/union-type.interface.js +1 -1
- package/cjs/schema/index.js +3 -41
- package/cjs/schema/opra-schema.ns.js +18 -0
- package/cjs/schema/resource/collection.interface.js +1 -1
- package/cjs/schema/resource/container.interface.js +1 -1
- package/cjs/schema/resource/singleton.interface.js +1 -1
- package/esm/document/api-document.js +55 -38
- package/esm/document/data-type/api-field.js +5 -5
- package/esm/document/data-type/builtin/any.type.js +2 -4
- package/esm/document/data-type/builtin/base64.type.js +4 -27
- package/esm/document/data-type/builtin/bigint.type.js +6 -24
- package/esm/document/data-type/builtin/boolean.type.js +4 -17
- package/esm/document/data-type/builtin/date.type.js +12 -8
- package/esm/document/data-type/builtin/index.js +3 -1
- package/esm/document/data-type/builtin/integer.type.js +4 -17
- package/esm/document/data-type/builtin/number.type.js +4 -22
- package/esm/document/data-type/builtin/object.type.js +3 -8
- package/esm/document/data-type/builtin/string.type.js +4 -13
- package/esm/document/data-type/builtin/time.type.js +10 -22
- package/esm/document/data-type/builtin/timestamp.type.js +7 -19
- package/esm/document/data-type/builtin/uuid.type.js +12 -0
- package/esm/document/data-type/complex-type.js +151 -92
- package/esm/document/data-type/data-type.js +31 -31
- package/esm/document/data-type/enum-type.js +49 -43
- package/esm/document/data-type/mapped-type.js +114 -70
- package/esm/document/data-type/simple-type.js +45 -44
- package/esm/document/data-type/union-type.js +68 -36
- package/esm/document/factory/create-document.js +6 -4
- package/esm/document/factory/factory.js +23 -20
- package/esm/document/factory/import-type-class.js +13 -4
- package/esm/document/resource/collection.js +55 -59
- package/esm/document/resource/resource.js +9 -21
- package/esm/document/resource/singleton.js +36 -39
- package/esm/exception/common-errors/validation.error.js +7 -0
- package/esm/exception/index.js +2 -1
- package/esm/exception/opra-exception.js +2 -2
- package/esm/filter/antlr/OpraFilterLexer.js +2 -1
- package/esm/filter/antlr/OpraFilterParser.js +2 -1
- package/esm/filter/errors.js +5 -0
- package/esm/schema/index.js +2 -41
- package/esm/schema/opra-schema.ns.js +15 -0
- package/package.json +6 -4
- package/types/document/api-document.d.ts +3 -2
- package/types/document/data-type/builtin/base64.type.d.ts +0 -4
- package/types/document/data-type/builtin/bigint.type.d.ts +1 -5
- package/types/document/data-type/builtin/boolean.type.d.ts +0 -3
- package/types/document/data-type/builtin/date.type.d.ts +1 -3
- package/types/document/data-type/builtin/index.d.ts +3 -1
- package/types/document/data-type/builtin/integer.type.d.ts +1 -5
- package/types/document/data-type/builtin/number.type.d.ts +0 -4
- package/types/document/data-type/builtin/object.type.d.ts +0 -1
- package/types/document/data-type/builtin/string.type.d.ts +0 -3
- package/types/document/data-type/builtin/time.type.d.ts +1 -6
- package/types/document/data-type/builtin/timestamp.type.d.ts +0 -3
- package/types/document/data-type/builtin/uuid.type.d.ts +2 -0
- package/types/document/data-type/complex-type.d.ts +29 -16
- package/types/document/data-type/data-type.d.ts +19 -15
- package/types/document/data-type/enum-type.d.ts +15 -5
- package/types/document/data-type/mapped-type.d.ts +27 -5
- package/types/document/data-type/simple-type.d.ts +26 -12
- package/types/document/data-type/union-type.d.ts +20 -5
- package/types/document/factory/factory.d.ts +3 -2
- package/types/document/resource/collection.d.ts +11 -9
- package/types/document/resource/resource.d.ts +3 -9
- package/types/document/resource/singleton.d.ts +7 -5
- package/types/exception/common-errors/validation.error.d.ts +4 -0
- package/types/exception/error-issue.d.ts +1 -1
- package/types/exception/index.d.ts +2 -1
- package/types/exception/opra-exception.d.ts +4 -2
- package/types/filter/errors.d.ts +3 -0
- package/types/schema/data-type/enum-type.interface.d.ts +5 -5
- package/types/schema/data-type/simple-type.interface.d.ts +5 -11
- package/types/schema/index.d.ts +2 -51
- package/types/schema/opra-schema.ns.d.ts +15 -0
- package/cjs/document/data-type/builtin/guid.type.js +0 -35
- package/esm/document/data-type/builtin/guid.type.js +0 -32
- package/types/document/data-type/builtin/guid.type.d.ts +0 -7
- /package/esm/exception/{enums/issue-severity.enum.js → issue-severity.enum.js} +0 -0
- /package/types/exception/{enums/issue-severity.enum.d.ts → issue-severity.enum.d.ts} +0 -0
|
@@ -10,64 +10,28 @@ import { SimpleType } from '../data-type/simple-type.js';
|
|
|
10
10
|
import { Resource } from './resource.js';
|
|
11
11
|
const NESTJS_INJECTABLE_WATERMARK = '__injectable__';
|
|
12
12
|
const NAME_PATTERN = /^(.*)(Resource|Collection)$/;
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
const
|
|
20
|
-
return function (target) {
|
|
21
|
-
const name = options?.name || target.name.match(NAME_PATTERN)?.[1] || target.name;
|
|
22
|
-
const metadata = Reflect.getOwnMetadata(METADATA_KEY, target) || {};
|
|
23
|
-
const baseMetadata = Reflect.getOwnMetadata(METADATA_KEY, Object.getPrototypeOf(target));
|
|
24
|
-
if (baseMetadata) {
|
|
25
|
-
merge(metadata, baseMetadata, { deep: true });
|
|
26
|
-
}
|
|
27
|
-
metadata.kind = OpraSchema.Collection.Kind;
|
|
28
|
-
metadata.name = name;
|
|
29
|
-
metadata.type = type;
|
|
30
|
-
// Merge with previous metadata object
|
|
31
|
-
const m = Reflect.getMetadata(METADATA_KEY, target);
|
|
32
|
-
if (m && metadata !== m)
|
|
33
|
-
Object.assign(metadata, omit(m), Object.keys(metadata));
|
|
34
|
-
// Merge options
|
|
35
|
-
if (options)
|
|
36
|
-
Object.assign(metadata, omit(options, ['kind', 'name', 'type', 'controller']));
|
|
37
|
-
Reflect.defineMetadata(METADATA_KEY, metadata, target);
|
|
38
|
-
/* Define Injectable metadata for NestJS support*/
|
|
39
|
-
Reflect.defineMetadata(NESTJS_INJECTABLE_WATERMARK, true, target);
|
|
40
|
-
};
|
|
41
|
-
}
|
|
42
|
-
// Constructor
|
|
43
|
-
const [document, init] = args;
|
|
44
|
-
// call super()
|
|
45
|
-
Resource.apply(this, [document, init]);
|
|
46
|
-
};
|
|
47
|
-
const proto = {
|
|
48
|
-
_construct(init) {
|
|
49
|
-
// call super()
|
|
50
|
-
Resource.prototype._construct.call(this, init);
|
|
51
|
-
const _this = this;
|
|
52
|
-
_this.kind = OpraSchema.Collection.Kind;
|
|
53
|
-
_this.controller = init.controller;
|
|
54
|
-
const operations = _this.operations = init.operations || {};
|
|
55
|
-
const dataType = _this.type = init.type;
|
|
13
|
+
class CollectionClass extends Resource {
|
|
14
|
+
constructor(document, init) {
|
|
15
|
+
super(document, init);
|
|
16
|
+
this.kind = OpraSchema.Collection.Kind;
|
|
17
|
+
this.controller = init.controller;
|
|
18
|
+
const operations = this.operations = init.operations || {};
|
|
19
|
+
const dataType = this.type = init.type;
|
|
56
20
|
// Validate key fields
|
|
57
|
-
|
|
21
|
+
this.primaryKey = init.primaryKey
|
|
58
22
|
? (Array.isArray(init.primaryKey) ? init.primaryKey : [init.primaryKey])
|
|
59
23
|
: [];
|
|
60
|
-
if (!
|
|
61
|
-
throw new TypeError(`You must provide primaryKey for Collection resource ("${
|
|
62
|
-
|
|
24
|
+
if (!this.primaryKey.length)
|
|
25
|
+
throw new TypeError(`You must provide primaryKey for Collection resource ("${this.name}")`);
|
|
26
|
+
this.primaryKey.forEach(f => {
|
|
63
27
|
const field = dataType.getField(f);
|
|
64
28
|
if (!(field?.type instanceof SimpleType))
|
|
65
29
|
throw new TypeError(`Only Simple type allowed for primary keys but "${f}" is a ${field.type.kind}`);
|
|
66
30
|
});
|
|
67
|
-
if (
|
|
68
|
-
const instance = typeof
|
|
69
|
-
? new
|
|
70
|
-
:
|
|
31
|
+
if (this.controller) {
|
|
32
|
+
const instance = typeof this.controller == 'function'
|
|
33
|
+
? new this.controller()
|
|
34
|
+
: this.controller;
|
|
71
35
|
for (const operation of Object.values(operations)) {
|
|
72
36
|
if (!operation.handler && operation.handlerName) {
|
|
73
37
|
const fn = instance[operation.handlerName];
|
|
@@ -77,7 +41,7 @@ const proto = {
|
|
|
77
41
|
}
|
|
78
42
|
}
|
|
79
43
|
}
|
|
80
|
-
}
|
|
44
|
+
}
|
|
81
45
|
exportSchema() {
|
|
82
46
|
const out = Resource.prototype.exportSchema.call(this);
|
|
83
47
|
Object.assign(out, omitUndefined({
|
|
@@ -86,7 +50,7 @@ const proto = {
|
|
|
86
50
|
primaryKey: this.primaryKey
|
|
87
51
|
}));
|
|
88
52
|
return out;
|
|
89
|
-
}
|
|
53
|
+
}
|
|
90
54
|
parseKeyValue(value) {
|
|
91
55
|
if (!this.primaryKey?.length)
|
|
92
56
|
return;
|
|
@@ -117,22 +81,22 @@ const proto = {
|
|
|
117
81
|
throw new TypeError(`You must provide value of primary field(s) (${primaryKey})`);
|
|
118
82
|
return result;
|
|
119
83
|
}
|
|
120
|
-
}
|
|
84
|
+
}
|
|
121
85
|
normalizeFieldPath(path) {
|
|
122
86
|
return this.type.normalizeFieldPath(path);
|
|
123
|
-
}
|
|
87
|
+
}
|
|
124
88
|
normalizeSortFields(fields) {
|
|
125
89
|
const normalized = this.type.normalizeFieldPath(fields);
|
|
126
90
|
const findManyEndpoint = this.operations.findMany;
|
|
127
91
|
const sortFields = findManyEndpoint && findManyEndpoint.sortFields;
|
|
128
|
-
normalized.forEach(field => {
|
|
92
|
+
(Array.isArray(normalized) ? normalized : [normalized]).forEach(field => {
|
|
129
93
|
if (!sortFields?.find(x => x === field))
|
|
130
94
|
throw new BadRequestError({
|
|
131
95
|
message: translate('error:UNACCEPTED_SORT_FIELD', { field }, `Field '${field}' is not available for sort operation`),
|
|
132
96
|
});
|
|
133
97
|
});
|
|
134
98
|
return normalized;
|
|
135
|
-
}
|
|
99
|
+
}
|
|
136
100
|
normalizeFilter(filter) {
|
|
137
101
|
if (!filter)
|
|
138
102
|
return;
|
|
@@ -162,9 +126,41 @@ const proto = {
|
|
|
162
126
|
}
|
|
163
127
|
return ast;
|
|
164
128
|
}
|
|
129
|
+
}
|
|
130
|
+
/**
|
|
131
|
+
*
|
|
132
|
+
*/
|
|
133
|
+
export const Collection = function (...args) {
|
|
134
|
+
// ClassDecorator
|
|
135
|
+
if (!this) {
|
|
136
|
+
const [type, options] = args;
|
|
137
|
+
return function (target) {
|
|
138
|
+
const name = options?.name || target.name.match(NAME_PATTERN)?.[1] || target.name;
|
|
139
|
+
const metadata = Reflect.getOwnMetadata(METADATA_KEY, target) || {};
|
|
140
|
+
const baseMetadata = Reflect.getOwnMetadata(METADATA_KEY, Object.getPrototypeOf(target));
|
|
141
|
+
if (baseMetadata) {
|
|
142
|
+
merge(metadata, baseMetadata, { deep: true });
|
|
143
|
+
}
|
|
144
|
+
metadata.kind = OpraSchema.Collection.Kind;
|
|
145
|
+
metadata.name = name;
|
|
146
|
+
metadata.type = type;
|
|
147
|
+
// Merge with previous metadata object
|
|
148
|
+
const m = Reflect.getMetadata(METADATA_KEY, target);
|
|
149
|
+
if (m && metadata !== m)
|
|
150
|
+
Object.assign(metadata, omit(m), Object.keys(metadata));
|
|
151
|
+
// Merge options
|
|
152
|
+
if (options)
|
|
153
|
+
Object.assign(metadata, omit(options, ['kind', 'name', 'type', 'controller']));
|
|
154
|
+
Reflect.defineMetadata(METADATA_KEY, metadata, target);
|
|
155
|
+
/* Define Injectable metadata for NestJS support*/
|
|
156
|
+
Reflect.defineMetadata(NESTJS_INJECTABLE_WATERMARK, true, target);
|
|
157
|
+
};
|
|
158
|
+
}
|
|
159
|
+
// Constructor
|
|
160
|
+
const [document, init] = args;
|
|
161
|
+
merge(this, new CollectionClass(document, init), { descriptor: true });
|
|
165
162
|
};
|
|
166
|
-
|
|
167
|
-
Object.setPrototypeOf(Collection.prototype, Resource.prototype);
|
|
163
|
+
Collection.prototype = CollectionClass.prototype;
|
|
168
164
|
function createOperationDecorator(operation) {
|
|
169
165
|
return (options) => ((target, propertyKey) => {
|
|
170
166
|
const metadata = {
|
|
@@ -1,35 +1,23 @@
|
|
|
1
1
|
import { omitUndefined } from '../../helpers/object-utils.js';
|
|
2
2
|
import { colorFgMagenta, colorFgYellow, colorReset, nodeInspectCustom } from '../utils/inspect.util.js';
|
|
3
|
-
export
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
3
|
+
export class Resource {
|
|
4
|
+
constructor(document, init) {
|
|
5
|
+
this.document = document;
|
|
6
|
+
this.name = init.name;
|
|
7
|
+
this.description = init.description;
|
|
8
|
+
this.controller = init.controller;
|
|
8
9
|
}
|
|
9
|
-
const _this = this;
|
|
10
|
-
_this.document = document;
|
|
11
|
-
_this.name = init.name;
|
|
12
|
-
_this.description = init.description;
|
|
13
|
-
_this.controller = init.controller;
|
|
14
|
-
_this._construct(init);
|
|
15
|
-
};
|
|
16
|
-
const proto = {
|
|
17
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
18
|
-
_construct(init) {
|
|
19
|
-
// Do nothing
|
|
20
|
-
},
|
|
21
10
|
exportSchema() {
|
|
22
11
|
return omitUndefined({
|
|
23
12
|
kind: this.kind,
|
|
24
13
|
description: this.description
|
|
25
14
|
});
|
|
26
|
-
}
|
|
15
|
+
}
|
|
27
16
|
toString() {
|
|
28
17
|
return `[${Object.getPrototypeOf(this).constructor.name} ${this.name || '#anonymous'}]`;
|
|
29
|
-
}
|
|
18
|
+
}
|
|
30
19
|
[nodeInspectCustom]() {
|
|
31
20
|
return `[${colorFgYellow + Object.getPrototypeOf(this).constructor.name + colorReset}` +
|
|
32
21
|
` ${colorFgMagenta + this.name + colorReset}]`;
|
|
33
22
|
}
|
|
34
|
-
}
|
|
35
|
-
Object.assign(Resource.prototype, proto);
|
|
23
|
+
}
|
|
@@ -1,10 +1,44 @@
|
|
|
1
1
|
import omit from 'lodash.omit';
|
|
2
|
+
import merge from 'putil-merge';
|
|
2
3
|
import { omitUndefined } from '../../helpers/index.js';
|
|
3
4
|
import { OpraSchema } from '../../schema/index.js';
|
|
4
5
|
import { METADATA_KEY } from '../constants.js';
|
|
5
6
|
import { Resource } from './resource.js';
|
|
6
7
|
const NESTJS_INJECTABLE_WATERMARK = '__injectable__';
|
|
7
8
|
const NAME_PATTERN = /^(.*)(Resource|Singleton)$/;
|
|
9
|
+
class SingletonClass extends Resource {
|
|
10
|
+
constructor(document, init) {
|
|
11
|
+
super(document, init);
|
|
12
|
+
this.kind = OpraSchema.Singleton.Kind;
|
|
13
|
+
this.controller = init.controller;
|
|
14
|
+
const operations = this.operations = init.operations || {};
|
|
15
|
+
this.type = init.type;
|
|
16
|
+
if (this.controller) {
|
|
17
|
+
const instance = typeof this.controller == 'function'
|
|
18
|
+
? new this.controller()
|
|
19
|
+
: this.controller;
|
|
20
|
+
for (const operation of Object.values(operations)) {
|
|
21
|
+
if (!operation.handler && operation.handlerName) {
|
|
22
|
+
const fn = instance[operation.handlerName];
|
|
23
|
+
if (!fn)
|
|
24
|
+
throw new TypeError(`No such operation handler (${operation.handlerName}) found`);
|
|
25
|
+
operation.handler = fn.bind(instance);
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
exportSchema() {
|
|
31
|
+
const out = Resource.prototype.exportSchema.call(this);
|
|
32
|
+
Object.assign(out, omitUndefined({
|
|
33
|
+
type: this.type.name,
|
|
34
|
+
operations: this.operations
|
|
35
|
+
}));
|
|
36
|
+
return out;
|
|
37
|
+
}
|
|
38
|
+
normalizeFieldPath(path) {
|
|
39
|
+
return this.type.normalizeFieldPath(path);
|
|
40
|
+
}
|
|
41
|
+
}
|
|
8
42
|
export const Singleton = function (...args) {
|
|
9
43
|
// ClassDecorator
|
|
10
44
|
if (!this) {
|
|
@@ -29,46 +63,9 @@ export const Singleton = function (...args) {
|
|
|
29
63
|
}
|
|
30
64
|
// Constructor
|
|
31
65
|
const [document, init] = args;
|
|
32
|
-
|
|
33
|
-
Resource.apply(this, [document, init]);
|
|
34
|
-
};
|
|
35
|
-
const proto = {
|
|
36
|
-
_construct(init) {
|
|
37
|
-
// call super()
|
|
38
|
-
Resource.prototype._construct.call(this, init);
|
|
39
|
-
const _this = this;
|
|
40
|
-
_this.kind = OpraSchema.Singleton.Kind;
|
|
41
|
-
_this.controller = init.controller;
|
|
42
|
-
const operations = _this.operations = init.operations || {};
|
|
43
|
-
_this.type = init.type;
|
|
44
|
-
if (_this.controller) {
|
|
45
|
-
const instance = typeof _this.controller == 'function'
|
|
46
|
-
? new _this.controller()
|
|
47
|
-
: _this.controller;
|
|
48
|
-
for (const operation of Object.values(operations)) {
|
|
49
|
-
if (!operation.handler && operation.handlerName) {
|
|
50
|
-
const fn = instance[operation.handlerName];
|
|
51
|
-
if (!fn)
|
|
52
|
-
throw new TypeError(`No such operation handler (${operation.handlerName}) found`);
|
|
53
|
-
operation.handler = fn.bind(instance);
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
},
|
|
58
|
-
exportSchema() {
|
|
59
|
-
const out = Resource.prototype.exportSchema.call(this);
|
|
60
|
-
Object.assign(out, omitUndefined({
|
|
61
|
-
type: this.type.name,
|
|
62
|
-
operations: this.operations
|
|
63
|
-
}));
|
|
64
|
-
return out;
|
|
65
|
-
},
|
|
66
|
-
normalizeFieldPath(path) {
|
|
67
|
-
return this.type.normalizeFieldPath(path);
|
|
68
|
-
},
|
|
66
|
+
merge(this, new SingletonClass(document, init), { descriptor: true });
|
|
69
67
|
};
|
|
70
|
-
|
|
71
|
-
Object.setPrototypeOf(Singleton.prototype, Resource.prototype);
|
|
68
|
+
Singleton.prototype = SingletonClass.prototype;
|
|
72
69
|
function createOperationDecorator(operation) {
|
|
73
70
|
return (options) => ((target, propertyKey) => {
|
|
74
71
|
const metadata = {
|
package/esm/exception/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export * from './opra-exception.js';
|
|
2
2
|
export * from './error-issue.js';
|
|
3
3
|
export * from './wrap-exception.js';
|
|
4
|
-
export * from './
|
|
4
|
+
export * from './issue-severity.enum.js';
|
|
5
5
|
export * from './http-errors/bad-request.error.js';
|
|
6
6
|
export * from './http-errors/failed-dependency.error.js';
|
|
7
7
|
export * from './http-errors/forbidden.error.js';
|
|
@@ -13,3 +13,4 @@ export * from './http-errors/unauthorized.error.js';
|
|
|
13
13
|
export * from './http-errors/unprocessable-entity.error.js';
|
|
14
14
|
export * from './resource-errors/resource-conflict.error.js';
|
|
15
15
|
export * from './resource-errors/resource-not-found.error.js';
|
|
16
|
+
export * from './common-errors/validation.error.js';
|
|
@@ -7,14 +7,14 @@ export class OpraException extends Error {
|
|
|
7
7
|
super('');
|
|
8
8
|
this.status = 500;
|
|
9
9
|
this._initName();
|
|
10
|
+
if (issue instanceof Error)
|
|
11
|
+
cause = issue;
|
|
10
12
|
if (cause) {
|
|
11
13
|
this.cause = cause;
|
|
12
14
|
if (cause.stack)
|
|
13
15
|
this.stack = cause.stack;
|
|
14
16
|
}
|
|
15
17
|
this._init(issue || cause || 'Unknown error');
|
|
16
|
-
if (issue instanceof Error)
|
|
17
|
-
this.stack = issue.stack;
|
|
18
18
|
this.message = i18n.deep(this.issue.message);
|
|
19
19
|
}
|
|
20
20
|
get issue() {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// Generated from ./src/filter/antlr/OpraFilter.g4 by ANTLR 4.12.0
|
|
2
2
|
// noinspection ES6UnusedImports,JSUnusedGlobalSymbols,JSUnusedLocalSymbols
|
|
3
3
|
import { ATNDeserializer, DFA, Lexer, LexerATNSimulator, PredictionContextCache, Token } from "@browsery/antlr4";
|
|
4
|
-
|
|
4
|
+
class OpraFilterLexer extends Lexer {
|
|
5
5
|
constructor(input) {
|
|
6
6
|
super(input);
|
|
7
7
|
this._interp = new LexerATNSimulator(this, OpraFilterLexer._ATN, OpraFilterLexer.DecisionsToDFA, new PredictionContextCache());
|
|
@@ -274,3 +274,4 @@ OpraFilterLexer._serializedATN = [4, 0, 43, 426, 6, -1, 2, 0,
|
|
|
274
274
|
268, 273, 279, 282, 286, 291, 293, 301, 303, 306, 311, 319, 321, 326, 328, 335, 337, 341,
|
|
275
275
|
346, 361, 370, 376, 390, 392, 394, 399, 404, 409, 411, 416, 1, 0, 1, 0];
|
|
276
276
|
OpraFilterLexer.DecisionsToDFA = OpraFilterLexer._ATN.decisionToState.map((ds, index) => new DFA(ds, index));
|
|
277
|
+
export default OpraFilterLexer;
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
// Generated from ./src/filter/antlr/OpraFilter.g4 by ANTLR 4.12.0
|
|
3
3
|
// noinspection ES6UnusedImports,JSUnusedGlobalSymbols,JSUnusedLocalSymbols
|
|
4
4
|
import { ATN, ATNDeserializer, DFA, FailedPredicateException, NoViableAltException, Parser, ParserATNSimulator, ParserRuleContext, PredictionContextCache, RecognitionException, Token } from '@browsery/antlr4';
|
|
5
|
-
|
|
5
|
+
class OpraFilterParser extends Parser {
|
|
6
6
|
get grammarFileName() {
|
|
7
7
|
return "OpraFilter.g4";
|
|
8
8
|
}
|
|
@@ -909,6 +909,7 @@ OpraFilterParser._serializedATN = [4, 1, 43, 120, 2, 0, 7, 0, 2,
|
|
|
909
909
|
7, 3, 0, 0, 112, 27, 1, 0, 0, 0, 113, 114, 7, 4, 0, 0, 114, 29, 1, 0, 0, 0, 115, 116, 7, 5, 0, 0, 116,
|
|
910
910
|
31, 1, 0, 0, 0, 117, 118, 5, 36, 0, 0, 118, 33, 1, 0, 0, 0, 6, 48, 56, 65, 77, 84, 100];
|
|
911
911
|
OpraFilterParser.DecisionsToDFA = OpraFilterParser._ATN.decisionToState.map((ds, index) => new DFA(ds, index));
|
|
912
|
+
export default OpraFilterParser;
|
|
912
913
|
export class RootContext extends ParserRuleContext {
|
|
913
914
|
constructor(parser, parent, invokingState) {
|
|
914
915
|
super(parent, invokingState);
|
package/esm/filter/errors.js
CHANGED
|
@@ -1,6 +1,11 @@
|
|
|
1
1
|
export class SyntaxError extends TypeError {
|
|
2
2
|
}
|
|
3
3
|
export class ValidationError extends TypeError {
|
|
4
|
+
constructor(message) {
|
|
5
|
+
super(typeof message === 'string' ? message : message?.message);
|
|
6
|
+
if (typeof message === 'object')
|
|
7
|
+
Object.assign(this, message);
|
|
8
|
+
}
|
|
4
9
|
}
|
|
5
10
|
export class FilterParseError extends Error {
|
|
6
11
|
constructor(message, args) {
|
package/esm/schema/index.js
CHANGED
|
@@ -1,41 +1,2 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
import { EnumType as _EnumType } from './data-type/enum-type.interface.js';
|
|
4
|
-
import { MappedType as _MappedType } from './data-type/mapped-type.interface.js';
|
|
5
|
-
import { SimpleType as _SimpleType } from './data-type/simple-type.interface.js';
|
|
6
|
-
import { UnionType as _UnionType } from './data-type/union-type.interface.js';
|
|
7
|
-
import { Collection as _Collection } from './resource/collection.interface.js';
|
|
8
|
-
import { Container as _Container } from './resource/container.interface.js';
|
|
9
|
-
import { Singleton as _Singleton } from './resource/singleton.interface.js';
|
|
10
|
-
import { isCollection as _isCollection, isComplexType as _isComplexType, isContainer as _isContainer, isDataType as _isDataType, isEnumType as _isEnumType, isMappedType as _isMappedType, isResource as _isResource, isSimpleType as _isSimpleType, isSingleton as _isSingleton, isUnionType as _isUnionType } from './type-guards.js';
|
|
11
|
-
export var OpraSchema;
|
|
12
|
-
(function (OpraSchema) {
|
|
13
|
-
// Re-export constants and types
|
|
14
|
-
OpraSchema.SpecVersion = _SpecVersion;
|
|
15
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
16
|
-
OpraSchema.ComplexType = _ComplexType;
|
|
17
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
18
|
-
OpraSchema.EnumType = _EnumType;
|
|
19
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
20
|
-
OpraSchema.MappedType = _MappedType;
|
|
21
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
22
|
-
OpraSchema.SimpleType = _SimpleType;
|
|
23
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
24
|
-
OpraSchema.UnionType = _UnionType;
|
|
25
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
26
|
-
OpraSchema.Collection = _Collection;
|
|
27
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
28
|
-
OpraSchema.Container = _Container;
|
|
29
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
30
|
-
OpraSchema.Singleton = _Singleton;
|
|
31
|
-
OpraSchema.isDataType = _isDataType;
|
|
32
|
-
OpraSchema.isComplexType = _isComplexType;
|
|
33
|
-
OpraSchema.isEnumType = _isEnumType;
|
|
34
|
-
OpraSchema.isMappedType = _isMappedType;
|
|
35
|
-
OpraSchema.isSimpleType = _isSimpleType;
|
|
36
|
-
OpraSchema.isUnionType = _isUnionType;
|
|
37
|
-
OpraSchema.isResource = _isResource;
|
|
38
|
-
OpraSchema.isCollection = _isCollection;
|
|
39
|
-
OpraSchema.isContainer = _isContainer;
|
|
40
|
-
OpraSchema.isSingleton = _isSingleton;
|
|
41
|
-
})(OpraSchema || (OpraSchema = {}));
|
|
1
|
+
import * as OpraSchema from './opra-schema.ns.js';
|
|
2
|
+
export { OpraSchema };
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export * from './data-type/complex-type.interface.js';
|
|
2
|
+
export * from './data-type/data-type.interface.js';
|
|
3
|
+
export * from './data-type/enum-type.interface.js';
|
|
4
|
+
export * from './data-type/field.interface.js';
|
|
5
|
+
export * from './data-type/simple-type.interface.js';
|
|
6
|
+
export * from './data-type/mapped-type.interface.js';
|
|
7
|
+
export * from './data-type/union-type.interface.js';
|
|
8
|
+
export * from './resource/collection.interface.js';
|
|
9
|
+
export * from './resource/container.interface.js';
|
|
10
|
+
export * from './resource/endpoint.interface.js';
|
|
11
|
+
export * from './resource/resource.interface.js';
|
|
12
|
+
export * from './resource/singleton.interface.js';
|
|
13
|
+
export * from './constants.js';
|
|
14
|
+
export * from './document.interface.js';
|
|
15
|
+
export * from './type-guards.js';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@opra/common",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.19.0",
|
|
4
4
|
"description": "Opra internationalization package",
|
|
5
5
|
"author": "Panates",
|
|
6
6
|
"license": "MIT",
|
|
@@ -41,7 +41,7 @@
|
|
|
41
41
|
"antlr4": "java -jar ./tools/antlr4-4.12.1-SNAPSHOT-complete.jar -Dlanguage=TypeScript ./src/filter/antlr/OpraFilter.g4 -visitor"
|
|
42
42
|
},
|
|
43
43
|
"dependencies": {
|
|
44
|
-
"@browsery/antlr4": "^0.
|
|
44
|
+
"@browsery/antlr4": "^0.7.0",
|
|
45
45
|
"@browsery/highland": "^0.4.0",
|
|
46
46
|
"@browsery/http-parser": "^0.4.0",
|
|
47
47
|
"@browsery/i18next": "^0.5.0",
|
|
@@ -49,9 +49,10 @@
|
|
|
49
49
|
"content-disposition": "^0.5.4",
|
|
50
50
|
"cookie": "^0.5.0",
|
|
51
51
|
"cookie-signature": "^1.2.1",
|
|
52
|
-
"dayjs": "^1.11.
|
|
52
|
+
"dayjs": "^1.11.8",
|
|
53
53
|
"encodeurl": "^1.0.2",
|
|
54
54
|
"fast-tokenizer": "^1.2.2",
|
|
55
|
+
"fastest-validator": "^1.17.0",
|
|
55
56
|
"lodash.omit": "^4.5.0",
|
|
56
57
|
"mime-types": "^2.1.35",
|
|
57
58
|
"putil-isplainobject": "^1.1.5",
|
|
@@ -60,7 +61,8 @@
|
|
|
60
61
|
"putil-varhelpers": "^1.6.5",
|
|
61
62
|
"reflect-metadata": "^0.1.13",
|
|
62
63
|
"type-is": "^1.6.18",
|
|
63
|
-
"uid": "^2.0.1"
|
|
64
|
+
"uid": "^2.0.1",
|
|
65
|
+
"valgen": "^4.0.0-alpha.5"
|
|
64
66
|
},
|
|
65
67
|
"devDependencies": {
|
|
66
68
|
"@browsery/fs": "^0.4.0",
|
|
@@ -8,8 +8,9 @@ import type { Collection } from './resource/collection.js';
|
|
|
8
8
|
import { Resource } from './resource/resource.js';
|
|
9
9
|
import { Singleton } from './resource/singleton.js';
|
|
10
10
|
export declare class ApiDocument {
|
|
11
|
-
protected
|
|
12
|
-
protected
|
|
11
|
+
protected _designCtorMap: Map<Function | Type<any>, string>;
|
|
12
|
+
protected _typeCache: ResponsiveMap<DataType>;
|
|
13
|
+
protected _typesCacheByCtor: Map<object | Type<any>, DataType>;
|
|
13
14
|
url?: string;
|
|
14
15
|
info: OpraSchema.DocumentInfo;
|
|
15
16
|
references: ResponsiveMap<ApiDocument>;
|
|
@@ -3,8 +3,10 @@ export * from './base64.type.js';
|
|
|
3
3
|
export * from './bigint.type.js';
|
|
4
4
|
export * from './boolean.type.js';
|
|
5
5
|
export * from './date.type.js';
|
|
6
|
-
export * from './
|
|
6
|
+
export * from './uuid.type.js';
|
|
7
7
|
export * from './integer.type.js';
|
|
8
8
|
export * from './number.type.js';
|
|
9
9
|
export * from './object.type.js';
|
|
10
10
|
export * from './string.type.js';
|
|
11
|
+
export * from './time.type.js';
|
|
12
|
+
export * from './timestamp.type.js';
|
|
@@ -1,7 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
export declare class TimeType extends StringType {
|
|
3
|
-
decode(v: any): string | undefined;
|
|
4
|
-
encode(v: any): string | undefined;
|
|
5
|
-
coerce(v: any): string | undefined;
|
|
6
|
-
validate(v: string): void;
|
|
1
|
+
export declare class TimeType {
|
|
7
2
|
}
|