@opra/common 1.8.0 → 1.9.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/browser/index.cjs +5 -5
- package/browser/index.mjs +5 -5
- package/cjs/document/data-type/enum-type.js +2 -2
- package/cjs/document/decorators/http-operation-entity-create.decorator.js +58 -0
- package/cjs/document/decorators/http-operation-entity-delete-many.decorator.js +41 -0
- package/cjs/document/decorators/http-operation-entity-delete.decorator.js +41 -0
- package/cjs/document/decorators/http-operation-entity-find-many.decorator.js +85 -0
- package/cjs/document/decorators/http-operation-entity-get.decorator.js +56 -0
- package/cjs/document/decorators/http-operation-entity-replace.decorator.js +56 -0
- package/cjs/document/decorators/http-operation-entity-update-many.decorator.js +50 -0
- package/cjs/document/decorators/http-operation-entity-update.decorator.js +66 -0
- package/cjs/document/decorators/http-operation-entity.decorator.js +86 -525
- package/cjs/document/http/http-parameter.js +1 -0
- package/cjs/document/index.js +9 -1
- package/cjs/filter/filter-rules.js +2 -1
- package/esm/document/data-type/enum-type.js +2 -2
- package/esm/document/decorators/http-operation-entity-create.decorator.js +56 -0
- package/esm/document/decorators/http-operation-entity-delete-many.decorator.js +39 -0
- package/esm/document/decorators/http-operation-entity-delete.decorator.js +39 -0
- package/esm/document/decorators/http-operation-entity-find-many.decorator.js +83 -0
- package/esm/document/decorators/http-operation-entity-get.decorator.js +54 -0
- package/esm/document/decorators/http-operation-entity-replace.decorator.js +54 -0
- package/esm/document/decorators/http-operation-entity-update-many.decorator.js +48 -0
- package/esm/document/decorators/http-operation-entity-update.decorator.js +64 -0
- package/esm/document/decorators/http-operation-entity.decorator.js +82 -525
- package/esm/document/http/http-parameter.js +1 -0
- package/esm/document/index.js +9 -1
- package/esm/filter/filter-rules.js +2 -1
- package/package.json +1 -1
- package/types/document/data-type/enum-type.d.ts +3 -3
- package/types/document/decorators/http-operation-entity-create.decorator.d.ts +1 -0
- package/types/document/decorators/http-operation-entity-delete-many.decorator.d.ts +1 -0
- package/types/document/decorators/http-operation-entity-delete.decorator.d.ts +1 -0
- package/types/document/decorators/http-operation-entity-find-many.decorator.d.ts +1 -0
- package/types/document/decorators/http-operation-entity-get.decorator.d.ts +1 -0
- package/types/document/decorators/http-operation-entity-replace.decorator.d.ts +1 -0
- package/types/document/decorators/http-operation-entity-update-many.decorator.d.ts +1 -0
- package/types/document/decorators/http-operation-entity-update.decorator.d.ts +1 -0
- package/types/document/decorators/http-operation-entity.decorator.d.ts +32 -4
- package/types/document/http/http-parameter.d.ts +3 -0
- package/types/document/index.d.ts +9 -1
- package/types/filter/ast/expressions/comparison-expression.d.ts +9 -0
- package/types/filter/filter-rules.d.ts +2 -1
|
@@ -41,7 +41,6 @@ export class FilterRules {
|
|
|
41
41
|
throw new TypeError(`Invalid filter query. Left side should be a data field.`);
|
|
42
42
|
}
|
|
43
43
|
// Check if filtering accepted for given field
|
|
44
|
-
// const findManyOp = this.getOperation('findMany');
|
|
45
44
|
const rule = this._rules.get(ast.left.value);
|
|
46
45
|
if (!rule) {
|
|
47
46
|
throw new OpraException({
|
|
@@ -67,6 +66,8 @@ export class FilterRules {
|
|
|
67
66
|
},
|
|
68
67
|
});
|
|
69
68
|
}
|
|
69
|
+
if (rule.prepare)
|
|
70
|
+
ast.prepare = rule.prepare;
|
|
70
71
|
this.normalizeFilterAst(ast.right, stack, currentType);
|
|
71
72
|
stack.pop();
|
|
72
73
|
return ast;
|
package/package.json
CHANGED
|
@@ -41,9 +41,9 @@ export interface EnumTypeStatic {
|
|
|
41
41
|
* @constructor
|
|
42
42
|
*/
|
|
43
43
|
new (owner: DocumentElement, args?: EnumType.InitArguments): EnumType;
|
|
44
|
-
<T extends EnumType.EnumObject, B extends EnumType.EnumObject>(enumSource: T, base
|
|
45
|
-
<T extends EnumType.EnumArray, B extends EnumType.EnumArray>(enumSource: T, base
|
|
46
|
-
<T extends EnumType.EnumObject | EnumType.EnumArray>(target: T, options
|
|
44
|
+
<T extends EnumType.EnumObject, B extends EnumType.EnumObject>(enumSource: T, base?: B, options?: EnumType.Options<T>): B & T;
|
|
45
|
+
<T extends EnumType.EnumArray, B extends EnumType.EnumArray>(enumSource: T, base?: B, options?: EnumType.Options<T>): B & T;
|
|
46
|
+
<T extends EnumType.EnumObject | EnumType.EnumArray>(target: T, options?: EnumType.Options<T>): T;
|
|
47
47
|
}
|
|
48
48
|
/**
|
|
49
49
|
* Type definition of EnumType prototype
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { StrictOmit, Type, TypeThunkAsync } from 'ts-gems';
|
|
2
2
|
import { OpraFilter } from '../../filter/index.js';
|
|
3
3
|
import { OpraSchema } from '../../schema/index.js';
|
|
4
|
+
import { HttpOperation } from '../http/http-operation.js';
|
|
4
5
|
import type { HttpParameter } from '../http/http-parameter.js';
|
|
5
6
|
import { HttpRequestBody } from '../http/http-request-body.js';
|
|
6
7
|
import { type HttpOperationDecorator } from './http-operation.decorator.js';
|
|
@@ -50,8 +51,14 @@ declare module '../http/http-operation.js' {
|
|
|
50
51
|
type: Type | string;
|
|
51
52
|
}
|
|
52
53
|
/** DeleteMany */
|
|
54
|
+
interface FilterOptions {
|
|
55
|
+
operators?: OpraFilter.ComparisonOperator[];
|
|
56
|
+
notes?: string;
|
|
57
|
+
prepare?: (args: OpraFilter.ComparisonExpression.PrepareArgs) => any;
|
|
58
|
+
}
|
|
53
59
|
interface DeleteManyDecorator extends HttpOperationDecorator {
|
|
54
|
-
Filter(field:
|
|
60
|
+
Filter(field: string, operators?: OpraFilter.ComparisonOperator[] | string): this;
|
|
61
|
+
Filter(field: string, options?: FilterOptions): this;
|
|
55
62
|
}
|
|
56
63
|
interface DeleteManyArgs extends StrictOmit<HttpOperation.Options, 'method' | 'requestBody'> {
|
|
57
64
|
type: Type | string;
|
|
@@ -59,8 +66,10 @@ declare module '../http/http-operation.js' {
|
|
|
59
66
|
/** FindMany */
|
|
60
67
|
interface FindManyDecorator extends HttpOperationDecorator {
|
|
61
68
|
SortFields(...fields: OpraSchema.Field.QualifiedName[]): FindManyDecorator;
|
|
69
|
+
SortFields(fieldsMap: Record<OpraSchema.Field.QualifiedName, OpraSchema.Field.QualifiedName>): FindManyDecorator;
|
|
62
70
|
DefaultSort(...fields: OpraSchema.Field.QualifiedName[]): FindManyDecorator;
|
|
63
|
-
Filter(field: OpraSchema.Field.QualifiedName, operators?: OpraFilter.ComparisonOperator[] | string
|
|
71
|
+
Filter(field: OpraSchema.Field.QualifiedName, operators?: OpraFilter.ComparisonOperator[] | string): this;
|
|
72
|
+
Filter(field: string, options?: FilterOptions): this;
|
|
64
73
|
}
|
|
65
74
|
interface FindManyArgs extends StrictOmit<HttpOperation.Options, 'method' | 'requestBody'> {
|
|
66
75
|
type: Type | string;
|
|
@@ -85,7 +94,8 @@ declare module '../http/http-operation.js' {
|
|
|
85
94
|
/** Update */
|
|
86
95
|
interface UpdateDecorator extends HttpOperationDecorator {
|
|
87
96
|
KeyParam(name: string, optionsOrType?: StrictOmit<HttpParameter.Options, 'location'> | string | TypeThunkAsync): this;
|
|
88
|
-
Filter(field: OpraSchema.Field.QualifiedName, operators?: OpraFilter.ComparisonOperator[] | string
|
|
97
|
+
Filter(field: OpraSchema.Field.QualifiedName, operators?: OpraFilter.ComparisonOperator[] | string): this;
|
|
98
|
+
Filter(field: string, options?: FilterOptions): this;
|
|
89
99
|
}
|
|
90
100
|
interface UpdateArgs extends StrictOmit<HttpOperation.Options, 'method' | 'requestBody'> {
|
|
91
101
|
type: Type | string;
|
|
@@ -97,7 +107,8 @@ declare module '../http/http-operation.js' {
|
|
|
97
107
|
}
|
|
98
108
|
/** UpdateMany */
|
|
99
109
|
interface UpdateManyDecorator extends HttpOperationDecorator {
|
|
100
|
-
Filter(field: OpraSchema.Field.QualifiedName, operators?: OpraFilter.ComparisonOperator[] | string
|
|
110
|
+
Filter(field: OpraSchema.Field.QualifiedName, operators?: OpraFilter.ComparisonOperator[] | string): this;
|
|
111
|
+
Filter(field: string, options?: FilterOptions): this;
|
|
101
112
|
}
|
|
102
113
|
interface UpdateManyArgs extends StrictOmit<HttpOperation.Options, 'method' | 'requestBody'> {
|
|
103
114
|
type: Type | string;
|
|
@@ -110,3 +121,20 @@ declare module '../http/http-operation.js' {
|
|
|
110
121
|
}
|
|
111
122
|
}
|
|
112
123
|
}
|
|
124
|
+
/**
|
|
125
|
+
*
|
|
126
|
+
* @param typ
|
|
127
|
+
*/
|
|
128
|
+
export declare function getDataTypeName(typ: Type | string): string;
|
|
129
|
+
/**
|
|
130
|
+
*
|
|
131
|
+
*/
|
|
132
|
+
export declare function createKeyParamDecorator<T extends HttpOperationDecorator>(decorator: T, decoratorChain: Function[]): (name: string, prmOptions?: StrictOmit<HttpParameter.Options, "location"> | string | Type) => T;
|
|
133
|
+
/**
|
|
134
|
+
*
|
|
135
|
+
*/
|
|
136
|
+
export declare function createSortFieldsDecorator<T extends HttpOperationDecorator>(decorator: T, decoratorChain: Function[]): (...varargs: any[]) => T;
|
|
137
|
+
/**
|
|
138
|
+
*
|
|
139
|
+
*/
|
|
140
|
+
export declare function createFilterDecorator<T extends HttpOperationDecorator>(decorator: T, decoratorChain: Function[], dataType: string | Type): (field: string, arg0?: OpraFilter.ComparisonOperator[] | string | HttpOperation.Entity.FilterOptions) => T;
|
|
@@ -16,10 +16,12 @@ export declare namespace HttpParameter {
|
|
|
16
16
|
}
|
|
17
17
|
interface Options extends Partial<StrictOmit<Metadata, 'type'>> {
|
|
18
18
|
type?: string | TypeThunkAsync | object;
|
|
19
|
+
parser?: (v: any) => any;
|
|
19
20
|
}
|
|
20
21
|
interface InitArguments extends Combine<{
|
|
21
22
|
type?: DataType;
|
|
22
23
|
}, Metadata> {
|
|
24
|
+
parser?: (v: any) => any;
|
|
23
25
|
}
|
|
24
26
|
}
|
|
25
27
|
/**
|
|
@@ -47,6 +49,7 @@ declare class HttpParameterClass extends Value {
|
|
|
47
49
|
deprecated?: boolean | string;
|
|
48
50
|
required?: boolean;
|
|
49
51
|
arraySeparator?: string;
|
|
52
|
+
parser?: (v: any) => any;
|
|
50
53
|
toJSON(options?: ApiDocument.ExportOptions): OpraSchema.HttpParameter;
|
|
51
54
|
}
|
|
52
55
|
export {};
|
|
@@ -1,4 +1,13 @@
|
|
|
1
1
|
import 'reflect-metadata';
|
|
2
|
+
import './decorators/http-operation-entity.decorator.js';
|
|
3
|
+
import './decorators/http-operation-entity-create.decorator.js';
|
|
4
|
+
import './decorators/http-operation-entity-delete.decorator.js';
|
|
5
|
+
import './decorators/http-operation-entity-delete-many.decorator.js';
|
|
6
|
+
import './decorators/http-operation-entity-find-many.decorator.js';
|
|
7
|
+
import './decorators/http-operation-entity-get.decorator.js';
|
|
8
|
+
import './decorators/http-operation-entity-replace.decorator.js';
|
|
9
|
+
import './decorators/http-operation-entity-update.decorator.js';
|
|
10
|
+
import './decorators/http-operation-entity-update-many.decorator.js';
|
|
2
11
|
import * as RpcControllerDecorator_ from './decorators/rpc-controller.decorator.js';
|
|
3
12
|
import * as RpcOperationDecorator_ from './decorators/rpc-operation.decorator.js';
|
|
4
13
|
import * as DataTypeFactory_ from './factory/data-type.factory.js';
|
|
@@ -24,7 +33,6 @@ export * from './data-type/pick-type.js';
|
|
|
24
33
|
export * from './data-type/primitive-types/index.js';
|
|
25
34
|
export * from './data-type/required-type.js';
|
|
26
35
|
export * from './data-type/simple-type.js';
|
|
27
|
-
export * from './decorators/http-operation-entity.decorator.js';
|
|
28
36
|
export type { RpcControllerDecorator } from './decorators/rpc-controller.decorator.js';
|
|
29
37
|
export type { RpcOperationDecorator } from './decorators/rpc-operation.decorator.js';
|
|
30
38
|
export * from './factory/api-document.factory.js';
|
|
@@ -5,6 +5,15 @@ export declare class ComparisonExpression extends Expression {
|
|
|
5
5
|
op: ComparisonOperator;
|
|
6
6
|
left: Expression;
|
|
7
7
|
right: Expression;
|
|
8
|
+
prepare?: (args: ComparisonExpression.PrepareArgs) => any;
|
|
8
9
|
constructor(o: StrictOmit<ComparisonExpression, 'kind'>);
|
|
9
10
|
toString(): string;
|
|
10
11
|
}
|
|
12
|
+
export declare namespace ComparisonExpression {
|
|
13
|
+
interface PrepareArgs {
|
|
14
|
+
left: string;
|
|
15
|
+
right: any;
|
|
16
|
+
op: ComparisonOperator;
|
|
17
|
+
adapter: string;
|
|
18
|
+
}
|
|
19
|
+
}
|
|
@@ -4,7 +4,7 @@ import { Validator } from 'valgen';
|
|
|
4
4
|
import type { ComplexType } from '../document/index.js';
|
|
5
5
|
import { ResponsiveMap } from '../helpers/index.js';
|
|
6
6
|
import { OpraSchema } from '../schema/index.js';
|
|
7
|
-
import { type ComparisonOperator, Expression } from './ast/index.js';
|
|
7
|
+
import { ComparisonExpression, type ComparisonOperator, Expression } from './ast/index.js';
|
|
8
8
|
export declare namespace FilterRules {
|
|
9
9
|
interface Options {
|
|
10
10
|
caseSensitive?: boolean;
|
|
@@ -12,6 +12,7 @@ export declare namespace FilterRules {
|
|
|
12
12
|
interface Rule {
|
|
13
13
|
operators?: ComparisonOperator[];
|
|
14
14
|
description?: string;
|
|
15
|
+
prepare?: (args: ComparisonExpression.PrepareArgs) => any;
|
|
15
16
|
}
|
|
16
17
|
}
|
|
17
18
|
export declare class FilterRules {
|