@opra/common 1.9.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 +1 -1
- package/browser/index.mjs +1 -1
- package/cjs/document/decorators/http-operation-entity.decorator.js +4 -1
- package/esm/document/decorators/http-operation-entity.decorator.js +4 -1
- package/package.json +1 -1
- package/types/document/decorators/http-operation-entity.decorator.d.ts +6 -6
- package/types/filter/ast/expressions/comparison-expression.d.ts +9 -1
- package/types/filter/filter-rules.d.ts +2 -2
|
@@ -120,8 +120,11 @@ function createFilterDecorator(decorator, decoratorChain, dataType) {
|
|
|
120
120
|
const filterOptions = (Array.isArray(arg0)
|
|
121
121
|
? { operators: arg0 }
|
|
122
122
|
: typeof arg0 === 'string'
|
|
123
|
-
? {
|
|
123
|
+
? {
|
|
124
|
+
operators: arg0.split(/\s*,\s*/),
|
|
125
|
+
}
|
|
124
126
|
: arg0) || {};
|
|
127
|
+
filterOptions.operators = filterOptions.operators || ['=', '!='];
|
|
125
128
|
decoratorChain.push(() => {
|
|
126
129
|
filterRules.set(field, filterOptions);
|
|
127
130
|
filterType.rules = filterRules.toJSON();
|
|
@@ -114,8 +114,11 @@ export function createFilterDecorator(decorator, decoratorChain, dataType) {
|
|
|
114
114
|
const filterOptions = (Array.isArray(arg0)
|
|
115
115
|
? { operators: arg0 }
|
|
116
116
|
: typeof arg0 === 'string'
|
|
117
|
-
? {
|
|
117
|
+
? {
|
|
118
|
+
operators: arg0.split(/\s*,\s*/),
|
|
119
|
+
}
|
|
118
120
|
: arg0) || {};
|
|
121
|
+
filterOptions.operators = filterOptions.operators || ['=', '!='];
|
|
119
122
|
decoratorChain.push(() => {
|
|
120
123
|
filterRules.set(field, filterOptions);
|
|
121
124
|
filterType.rules = filterRules.toJSON();
|
package/package.json
CHANGED
|
@@ -54,10 +54,10 @@ declare module '../http/http-operation.js' {
|
|
|
54
54
|
interface FilterOptions {
|
|
55
55
|
operators?: OpraFilter.ComparisonOperator[];
|
|
56
56
|
notes?: string;
|
|
57
|
-
prepare?: (
|
|
57
|
+
prepare?: (args: OpraFilter.ComparisonExpression.PrepareArgs) => any;
|
|
58
58
|
}
|
|
59
59
|
interface DeleteManyDecorator extends HttpOperationDecorator {
|
|
60
|
-
Filter(field: string, operators?: OpraFilter.ComparisonOperator[]): this;
|
|
60
|
+
Filter(field: string, operators?: OpraFilter.ComparisonOperator[] | string): this;
|
|
61
61
|
Filter(field: string, options?: FilterOptions): this;
|
|
62
62
|
}
|
|
63
63
|
interface DeleteManyArgs extends StrictOmit<HttpOperation.Options, 'method' | 'requestBody'> {
|
|
@@ -68,7 +68,7 @@ declare module '../http/http-operation.js' {
|
|
|
68
68
|
SortFields(...fields: OpraSchema.Field.QualifiedName[]): FindManyDecorator;
|
|
69
69
|
SortFields(fieldsMap: Record<OpraSchema.Field.QualifiedName, OpraSchema.Field.QualifiedName>): FindManyDecorator;
|
|
70
70
|
DefaultSort(...fields: OpraSchema.Field.QualifiedName[]): FindManyDecorator;
|
|
71
|
-
Filter(field: OpraSchema.Field.QualifiedName, operators?: OpraFilter.ComparisonOperator[]): this;
|
|
71
|
+
Filter(field: OpraSchema.Field.QualifiedName, operators?: OpraFilter.ComparisonOperator[] | string): this;
|
|
72
72
|
Filter(field: string, options?: FilterOptions): this;
|
|
73
73
|
}
|
|
74
74
|
interface FindManyArgs extends StrictOmit<HttpOperation.Options, 'method' | 'requestBody'> {
|
|
@@ -94,7 +94,7 @@ declare module '../http/http-operation.js' {
|
|
|
94
94
|
/** Update */
|
|
95
95
|
interface UpdateDecorator extends HttpOperationDecorator {
|
|
96
96
|
KeyParam(name: string, optionsOrType?: StrictOmit<HttpParameter.Options, 'location'> | string | TypeThunkAsync): this;
|
|
97
|
-
Filter(field: OpraSchema.Field.QualifiedName, operators?: OpraFilter.ComparisonOperator[]): this;
|
|
97
|
+
Filter(field: OpraSchema.Field.QualifiedName, operators?: OpraFilter.ComparisonOperator[] | string): this;
|
|
98
98
|
Filter(field: string, options?: FilterOptions): this;
|
|
99
99
|
}
|
|
100
100
|
interface UpdateArgs extends StrictOmit<HttpOperation.Options, 'method' | 'requestBody'> {
|
|
@@ -107,7 +107,7 @@ declare module '../http/http-operation.js' {
|
|
|
107
107
|
}
|
|
108
108
|
/** UpdateMany */
|
|
109
109
|
interface UpdateManyDecorator extends HttpOperationDecorator {
|
|
110
|
-
Filter(field: OpraSchema.Field.QualifiedName, operators?: OpraFilter.ComparisonOperator[]): this;
|
|
110
|
+
Filter(field: OpraSchema.Field.QualifiedName, operators?: OpraFilter.ComparisonOperator[] | string): this;
|
|
111
111
|
Filter(field: string, options?: FilterOptions): this;
|
|
112
112
|
}
|
|
113
113
|
interface UpdateManyArgs extends StrictOmit<HttpOperation.Options, 'method' | 'requestBody'> {
|
|
@@ -137,4 +137,4 @@ export declare function createSortFieldsDecorator<T extends HttpOperationDecorat
|
|
|
137
137
|
/**
|
|
138
138
|
*
|
|
139
139
|
*/
|
|
140
|
-
export declare function createFilterDecorator<T extends HttpOperationDecorator>(decorator: T, decoratorChain: Function[], dataType: string | Type): (field: string, arg0?: OpraFilter.ComparisonOperator[] | HttpOperation.Entity.FilterOptions) => T;
|
|
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;
|
|
@@ -5,7 +5,15 @@ export declare class ComparisonExpression extends Expression {
|
|
|
5
5
|
op: ComparisonOperator;
|
|
6
6
|
left: Expression;
|
|
7
7
|
right: Expression;
|
|
8
|
-
prepare?: (
|
|
8
|
+
prepare?: (args: ComparisonExpression.PrepareArgs) => any;
|
|
9
9
|
constructor(o: StrictOmit<ComparisonExpression, 'kind'>);
|
|
10
10
|
toString(): string;
|
|
11
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,7 +12,7 @@ export declare namespace FilterRules {
|
|
|
12
12
|
interface Rule {
|
|
13
13
|
operators?: ComparisonOperator[];
|
|
14
14
|
description?: string;
|
|
15
|
-
prepare?: (
|
|
15
|
+
prepare?: (args: ComparisonExpression.PrepareArgs) => any;
|
|
16
16
|
}
|
|
17
17
|
}
|
|
18
18
|
export declare class FilterRules {
|