@opra/common 0.16.2 → 0.17.1
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/document/constants.js +1 -1
- package/cjs/document/data-type/complex-type.js +69 -56
- package/cjs/document/data-type/simple-type.js +0 -1
- package/cjs/document/resource/collection.js +15 -16
- package/cjs/document/resource/singleton.js +2 -2
- package/cjs/http/http-params.js +10 -11
- package/esm/document/api-document.js +33 -37
- package/esm/document/constants.js +3 -6
- package/esm/document/data-type/api-field.js +12 -15
- package/esm/document/data-type/builtin/any.type.js +5 -8
- package/esm/document/data-type/builtin/base64.type.js +5 -8
- package/esm/document/data-type/builtin/bigint.type.js +5 -8
- package/esm/document/data-type/builtin/boolean.type.js +8 -11
- package/esm/document/data-type/builtin/date.type.js +7 -10
- package/esm/document/data-type/builtin/guid.type.js +9 -12
- package/esm/document/data-type/builtin/index.js +10 -13
- package/esm/document/data-type/builtin/integer.type.js +10 -13
- package/esm/document/data-type/builtin/number.type.js +7 -10
- package/esm/document/data-type/builtin/object.type.js +5 -8
- package/esm/document/data-type/builtin/string.type.js +8 -11
- package/esm/document/data-type/builtin/time.type.js +7 -10
- package/esm/document/data-type/builtin/timestamp.type.js +9 -12
- package/esm/document/data-type/complex-type.js +94 -85
- package/esm/document/data-type/data-type.js +9 -12
- package/esm/document/data-type/enum-type.js +15 -19
- package/esm/document/data-type/mapped-type.js +24 -29
- package/esm/document/data-type/simple-type.js +17 -22
- package/esm/document/data-type/union-type.js +26 -29
- package/esm/document/factory/add-references.js +3 -7
- package/esm/document/factory/create-document.js +10 -16
- package/esm/document/factory/factory.js +33 -37
- package/esm/document/factory/import-resource-class.js +16 -22
- package/esm/document/factory/import-type-class.js +24 -34
- package/esm/document/factory/index.js +1 -4
- package/esm/document/factory/process-resources.js +10 -16
- package/esm/document/factory/process-types.js +31 -37
- package/esm/document/index.js +14 -17
- package/esm/document/resource/collection.js +58 -63
- package/esm/document/resource/resource.js +9 -12
- package/esm/document/resource/singleton.js +27 -31
- package/esm/document/utils/inspect.util.js +4 -7
- package/esm/document/utils/string-compare.util.js +1 -5
- package/esm/exception/enums/issue-severity.enum.js +2 -5
- package/esm/exception/error-issue.js +1 -2
- package/esm/exception/http-errors/bad-request.error.js +4 -8
- package/esm/exception/http-errors/failed-dependency.error.js +4 -8
- package/esm/exception/http-errors/forbidden.error.js +4 -8
- package/esm/exception/http-errors/internal-server.error.js +4 -8
- package/esm/exception/http-errors/method-not-allowed.error.js +4 -8
- package/esm/exception/http-errors/not-acceptable.error.js +4 -8
- package/esm/exception/http-errors/not-found.error.js +4 -8
- package/esm/exception/http-errors/unauthorized.error.js +4 -8
- package/esm/exception/http-errors/unprocessable-entity.error.js +4 -8
- package/esm/exception/index.js +15 -18
- package/esm/exception/opra-exception.js +3 -7
- package/esm/exception/resource-errors/resource-conflict.error.js +4 -8
- package/esm/exception/resource-errors/resource-not-found.error.js +4 -8
- package/esm/exception/wrap-exception.js +20 -24
- package/esm/filter/antlr/OpraFilterLexer.js +6 -9
- package/esm/filter/antlr/OpraFilterListener.js +2 -5
- package/esm/filter/antlr/OpraFilterParser.js +79 -126
- package/esm/filter/antlr/OpraFilterVisitor.js +2 -5
- package/esm/filter/ast/abstract/ast.js +1 -5
- package/esm/filter/ast/abstract/expression.js +2 -6
- package/esm/filter/ast/abstract/literal.js +2 -6
- package/esm/filter/ast/abstract/term.js +2 -6
- package/esm/filter/ast/expressions/arithmetic-expression.js +3 -8
- package/esm/filter/ast/expressions/array-expression.js +2 -6
- package/esm/filter/ast/expressions/comparison-expression.js +2 -6
- package/esm/filter/ast/expressions/logical-expression.js +2 -6
- package/esm/filter/ast/expressions/parentheses-expression.js +2 -6
- package/esm/filter/ast/index.js +16 -19
- package/esm/filter/ast/terms/boolean-literal.js +2 -6
- package/esm/filter/ast/terms/date-literal.js +8 -12
- package/esm/filter/ast/terms/external-constant.js +2 -6
- package/esm/filter/ast/terms/null-literal.js +2 -6
- package/esm/filter/ast/terms/number-literal.js +4 -8
- package/esm/filter/ast/terms/qualified-identifier.js +2 -6
- package/esm/filter/ast/terms/string-literal.js +4 -8
- package/esm/filter/ast/terms/time-literal.js +6 -10
- package/esm/filter/build.js +45 -69
- package/esm/filter/errors.js +3 -9
- package/esm/filter/filter-tree-visitor.js +26 -31
- package/esm/filter/index.js +5 -8
- package/esm/filter/opra-error-listener.js +4 -8
- package/esm/filter/parse.js +14 -19
- package/esm/filter/utils.js +2 -7
- package/esm/helpers/function-utils.js +8 -14
- package/esm/helpers/get-stack-filename.js +1 -5
- package/esm/helpers/index.js +8 -11
- package/esm/helpers/is-url.js +1 -5
- package/esm/helpers/mixin-utils.js +2 -7
- package/esm/helpers/object-utils.js +6 -12
- package/esm/helpers/path-to-object-tree.js +1 -5
- package/esm/helpers/responsive-map.js +1 -5
- package/esm/helpers/type-guards.js +7 -17
- package/esm/http/codecs/boolean-codec.js +1 -5
- package/esm/http/codecs/date-codec.js +1 -5
- package/esm/http/codecs/filter-codec.js +5 -9
- package/esm/http/codecs/integer-codec.js +2 -6
- package/esm/http/codecs/number-codec.js +1 -5
- package/esm/http/codecs/string-codec.js +1 -5
- package/esm/http/enums/http-headers-codes.enum.js +2 -5
- package/esm/http/enums/http-status-codes.enum.js +2 -5
- package/esm/http/enums/http-status-messages.js +1 -4
- package/esm/http/http-headers.js +5 -9
- package/esm/http/http-message.host.js +13 -18
- package/esm/http/http-params.js +30 -36
- package/esm/http/http-request-message.js +18 -22
- package/esm/http/http-response-message.js +23 -28
- package/esm/http/index.js +14 -17
- package/esm/http/interfaces/client-http-headers.interface.js +1 -2
- package/esm/http/interfaces/cookie-options.interface.js +1 -2
- package/esm/http/interfaces/server-http-headers.interface.js +1 -2
- package/esm/i18n/i18n.js +23 -28
- package/esm/i18n/index.js +5 -9
- package/esm/i18n/string-utils.js +2 -7
- package/esm/i18n/translate.js +3 -7
- package/esm/index.js +11 -16
- package/esm/schema/constants.js +1 -4
- package/esm/schema/data-type/complex-type.interface.js +2 -5
- package/esm/schema/data-type/data-type.interface.js +1 -2
- package/esm/schema/data-type/enum-type.interface.js +2 -5
- package/esm/schema/data-type/field.interface.js +1 -2
- package/esm/schema/data-type/mapped-type.interface.js +2 -5
- package/esm/schema/data-type/simple-type.interface.js +2 -5
- package/esm/schema/data-type/union-type.interface.js +2 -5
- package/esm/schema/document.interface.js +1 -2
- package/esm/schema/index.js +31 -34
- package/esm/schema/resource/collection.interface.js +2 -5
- package/esm/schema/resource/container.interface.js +2 -5
- package/esm/schema/resource/endpoint.interface.js +1 -2
- package/esm/schema/resource/resource.interface.js +1 -2
- package/esm/schema/resource/singleton.interface.js +2 -5
- package/esm/schema/type-guards.js +40 -53
- package/esm/types.js +1 -2
- package/esm/url/index.js +5 -8
- package/esm/url/opra-url-path-component.js +3 -7
- package/esm/url/opra-url-path.js +14 -18
- package/esm/url/opra-url.js +15 -19
- package/esm/url/utils/decode-path-component.js +4 -8
- package/esm/url/utils/encode-path-component.js +3 -8
- package/esm/utils/path-utils.js +2 -7
- package/package.json +1 -1
- package/types/document/data-type/complex-type.d.ts +8 -2
- package/types/document/resource/collection.d.ts +5 -3
- package/types/document/resource/singleton.d.ts +3 -1
- package/types/filter/ast/terms/qualified-identifier.d.ts +4 -0
- package/types/http/http-params.d.ts +20 -19
|
@@ -1,14 +1,10 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
exports.encodePathComponent = void 0;
|
|
4
|
-
const tslib_1 = require("tslib");
|
|
5
|
-
const putil_isplainobject_1 = tslib_1.__importDefault(require("putil-isplainobject"));
|
|
6
|
-
function encodePathComponent(resource, key, typeCast) {
|
|
1
|
+
import isPlainObject from 'putil-isplainobject';
|
|
2
|
+
export function encodePathComponent(resource, key, typeCast) {
|
|
7
3
|
if (resource == null)
|
|
8
4
|
return '';
|
|
9
5
|
let keyString = '';
|
|
10
6
|
if (key !== '' && key != null) {
|
|
11
|
-
if ((
|
|
7
|
+
if (isPlainObject(key)) {
|
|
12
8
|
const arr = [];
|
|
13
9
|
for (const k of Object.keys(key)) {
|
|
14
10
|
arr.push(encodeURIComponent(k) + '=' + encodeURIComponent(key[k]));
|
|
@@ -24,4 +20,3 @@ function encodePathComponent(resource, key, typeCast) {
|
|
|
24
20
|
(keyString ? '@' + keyString : '') +
|
|
25
21
|
(typeCast ? '::' + typeCast : '');
|
|
26
22
|
}
|
|
27
|
-
exports.encodePathComponent = encodePathComponent;
|
package/esm/utils/path-utils.js
CHANGED
|
@@ -1,7 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.joinPath = exports.normalizePath = void 0;
|
|
4
|
-
function normalizePath(p, noLeadingSlash) {
|
|
1
|
+
export function normalizePath(p, noLeadingSlash) {
|
|
5
2
|
if (!p)
|
|
6
3
|
return '';
|
|
7
4
|
while (noLeadingSlash && p.startsWith('/'))
|
|
@@ -10,8 +7,7 @@ function normalizePath(p, noLeadingSlash) {
|
|
|
10
7
|
p = p.substring(0, p.length - 1);
|
|
11
8
|
return p;
|
|
12
9
|
}
|
|
13
|
-
|
|
14
|
-
function joinPath(...p) {
|
|
10
|
+
export function joinPath(...p) {
|
|
15
11
|
const out = [];
|
|
16
12
|
let s;
|
|
17
13
|
for (let i = 0, l = p.length; i < l; i++) {
|
|
@@ -21,4 +17,3 @@ function joinPath(...p) {
|
|
|
21
17
|
}
|
|
22
18
|
return out.join('/');
|
|
23
19
|
}
|
|
24
|
-
exports.joinPath = joinPath;
|
package/package.json
CHANGED
|
@@ -30,10 +30,16 @@ export interface ComplexType extends StrictOmit<DataType, 'own' | 'exportSchema'
|
|
|
30
30
|
readonly ctor: Type;
|
|
31
31
|
readonly base?: ComplexType | UnionType;
|
|
32
32
|
readonly own: ComplexType.OwnProperties;
|
|
33
|
+
readonly abstract?: boolean;
|
|
34
|
+
readonly additionalFields?: boolean;
|
|
33
35
|
exportSchema(): OpraSchema.ComplexType;
|
|
34
36
|
addField(init: ApiField.InitArguments): ApiField;
|
|
35
|
-
|
|
36
|
-
|
|
37
|
+
iteratePath(path: string, silent?: boolean): IterableIterator<[string, ApiField | undefined, string]>;
|
|
38
|
+
getField(nameOrPath: string): ApiField;
|
|
39
|
+
findField(nameOrPath: string): ApiField | undefined;
|
|
40
|
+
normalizeFieldPath(fields: string): string;
|
|
41
|
+
normalizeFieldPath(fields: string[]): string[];
|
|
42
|
+
normalizeFieldPath(fields: string | string[]): string | string[];
|
|
37
43
|
}
|
|
38
44
|
/**
|
|
39
45
|
* Type definition of ComplexType constructor type
|
|
@@ -44,9 +44,11 @@ export interface Collection extends StrictOmit<Resource, 'exportSchema' | '_cons
|
|
|
44
44
|
readonly primaryKey: string[];
|
|
45
45
|
exportSchema(): OpraSchema.Collection;
|
|
46
46
|
parseKeyValue(value: any): any;
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
47
|
+
normalizeFieldPath(fields: string): string;
|
|
48
|
+
normalizeFieldPath(fields: string[]): string[];
|
|
49
|
+
normalizeFieldPath(fields: string | string[]): string | string[];
|
|
50
|
+
normalizeSortFields(fields: string | string[]): string[];
|
|
51
|
+
normalizeFilter(ast: Expression): Expression;
|
|
50
52
|
_construct(init: Collection.InitArguments): void;
|
|
51
53
|
}
|
|
52
54
|
export interface CollectionConstructor {
|
|
@@ -34,7 +34,9 @@ export interface Singleton extends StrictOmit<Resource, 'exportSchema' | '_const
|
|
|
34
34
|
readonly operations: Singleton.Operations;
|
|
35
35
|
readonly controller?: object | Type;
|
|
36
36
|
exportSchema(): OpraSchema.Singleton;
|
|
37
|
-
|
|
37
|
+
normalizeFieldPath(fields: string): string;
|
|
38
|
+
normalizeFieldPath(fields: string[]): string[];
|
|
39
|
+
normalizeFieldPath(fields: string | string[]): string | string[];
|
|
38
40
|
_construct(init: Singleton.InitArguments): void;
|
|
39
41
|
}
|
|
40
42
|
export interface SingletonConstructor {
|
|
@@ -1,4 +1,8 @@
|
|
|
1
|
+
import type { ApiField } from '../../../document/data-type/api-field.js';
|
|
2
|
+
import { DataType } from '../../../document/data-type/data-type.js';
|
|
1
3
|
import { Literal } from '../abstract/literal.js';
|
|
2
4
|
export declare class QualifiedIdentifier extends Literal {
|
|
5
|
+
dataType: DataType;
|
|
6
|
+
field?: ApiField;
|
|
3
7
|
constructor(value: string);
|
|
4
8
|
}
|
|
@@ -7,7 +7,8 @@ import { IntegerCodec } from './codecs/integer-codec.js';
|
|
|
7
7
|
import { NumberCodec } from './codecs/number-codec.js';
|
|
8
8
|
import { StringCodec } from './codecs/string-codec.js';
|
|
9
9
|
export declare namespace HttpParams {
|
|
10
|
-
type Initiator = string | URLSearchParams | HttpParams | Map<string,
|
|
10
|
+
type Initiator = string | URLSearchParams | HttpParams | Map<string, HttpParams.Value> | Record<string, HttpParams.Value>;
|
|
11
|
+
type Value = string | number | boolean | object | null;
|
|
11
12
|
interface Options {
|
|
12
13
|
onChange?: () => void;
|
|
13
14
|
params?: Record<string, ParamDefinition>;
|
|
@@ -16,8 +17,8 @@ export declare namespace HttpParams {
|
|
|
16
17
|
codec?: Codec | string;
|
|
17
18
|
};
|
|
18
19
|
interface Codec {
|
|
19
|
-
decode(value: string):
|
|
20
|
-
encode(value:
|
|
20
|
+
decode(value: string): HttpParams.Value;
|
|
21
|
+
encode(value: HttpParams.Value): string;
|
|
21
22
|
}
|
|
22
23
|
}
|
|
23
24
|
interface HttpParamMetadata {
|
|
@@ -36,7 +37,7 @@ export declare class HttpParams {
|
|
|
36
37
|
protected static kSize: symbol;
|
|
37
38
|
protected static kParamDefs: symbol;
|
|
38
39
|
protected static kOptions: symbol;
|
|
39
|
-
protected [kEntries]: ResponsiveMap<
|
|
40
|
+
protected [kEntries]: ResponsiveMap<HttpParams.Value[]>;
|
|
40
41
|
protected [kSize]: number;
|
|
41
42
|
protected [kOptions]: HttpParams.Options;
|
|
42
43
|
protected [kParamDefs]: Map<string, HttpParamMetadata>;
|
|
@@ -46,27 +47,27 @@ export declare class HttpParams {
|
|
|
46
47
|
* Appends a new value to the existing set of values for a parameter
|
|
47
48
|
* and returns this instance
|
|
48
49
|
*/
|
|
49
|
-
append(name: string, value?:
|
|
50
|
+
append(name: string, value?: HttpParams.Value): this;
|
|
50
51
|
appendAll(input: HttpParams.Initiator): this;
|
|
51
52
|
changed(): void;
|
|
52
53
|
clear(): void;
|
|
53
54
|
/**
|
|
54
55
|
* Deletes values for a given parameter
|
|
55
56
|
*/
|
|
56
|
-
delete(name: string, value?:
|
|
57
|
+
delete(name: string, value?: HttpParams.Value): this;
|
|
57
58
|
/**
|
|
58
59
|
* Returns an iterable of key, value pairs for every entry in the map.
|
|
59
60
|
*/
|
|
60
|
-
entries(): IterableIterator<[string,
|
|
61
|
-
forEach(callbackFn: (value:
|
|
61
|
+
entries(): IterableIterator<[string, HttpParams.Value]>;
|
|
62
|
+
forEach(callbackFn: (value: HttpParams.Value, key: string, parent: HttpParams) => void, thisArg?: any): void;
|
|
62
63
|
/**
|
|
63
64
|
* Retrieves value of a given parameter at given index
|
|
64
65
|
*/
|
|
65
|
-
get(name: string, index?: number):
|
|
66
|
+
get(name: string, index?: number): HttpParams.Value;
|
|
66
67
|
/**
|
|
67
68
|
* Retrieves an array of values for a given parameter.
|
|
68
69
|
*/
|
|
69
|
-
getAll(name: string):
|
|
70
|
+
getAll(name: string): HttpParams.Value[] | null;
|
|
70
71
|
/**
|
|
71
72
|
* Retrieves the names of the parameters.
|
|
72
73
|
*/
|
|
@@ -74,7 +75,7 @@ export declare class HttpParams {
|
|
|
74
75
|
/**
|
|
75
76
|
* Retrieves the names of the parameters.
|
|
76
77
|
*/
|
|
77
|
-
values(): IterableIterator<
|
|
78
|
+
values(): IterableIterator<HttpParams.Value>;
|
|
78
79
|
/**
|
|
79
80
|
* Checks for existence of a parameter.
|
|
80
81
|
*/
|
|
@@ -83,23 +84,23 @@ export declare class HttpParams {
|
|
|
83
84
|
* Sets or modifies a value for a given parameter.
|
|
84
85
|
* If the header already exists, its value is replaced with the given value
|
|
85
86
|
*/
|
|
86
|
-
set(name: string, value
|
|
87
|
+
set(name: string, value?: HttpParams.Value): this;
|
|
87
88
|
sort(compareFn?: (a: string, b: string) => number): this;
|
|
88
89
|
/**
|
|
89
90
|
* Serializes the body to an encoded string, where key-value pairs (separated by `=`) are
|
|
90
91
|
* separated by `&`s.
|
|
91
92
|
*/
|
|
92
93
|
toString(): string;
|
|
93
|
-
getProxy(): Record<string,
|
|
94
|
+
getProxy(): Record<string, HttpParams.Value>;
|
|
94
95
|
define(params: Record<string, HttpParams.ParamDefinition>): this;
|
|
95
96
|
define(name: string, options: HttpParams.ParamDefinition): this;
|
|
96
|
-
encodeValue(value:
|
|
97
|
-
decodeValue(value: string, key: string):
|
|
98
|
-
|
|
99
|
-
protected _delete(name: string, value?: string | string[]): boolean;
|
|
100
|
-
protected _set(name: string, value: any, index?: number): void;
|
|
101
|
-
[Symbol.iterator](): IterableIterator<[string, string]>;
|
|
97
|
+
encodeValue(value: HttpParams.Value, key: string): string;
|
|
98
|
+
decodeValue(value: string, key: string): HttpParams.Value;
|
|
99
|
+
[Symbol.iterator](): IterableIterator<[string, HttpParams.Value]>;
|
|
102
100
|
get [Symbol.toStringTag](): string;
|
|
101
|
+
protected _append(name: string, value?: HttpParams.Value): void;
|
|
102
|
+
protected _delete(name: string, value?: HttpParams.Value): boolean;
|
|
103
|
+
protected _set(name: string, value?: HttpParams.Value, index?: number): void;
|
|
103
104
|
static codecs: {
|
|
104
105
|
boolean: BooleanCodec;
|
|
105
106
|
date: DateCodec;
|