angular-odata 0.101.0 → 0.102.6
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/esm2020/lib/api.mjs +83 -63
- package/esm2020/lib/cache/cache.mjs +1 -1
- package/esm2020/lib/cache/memory.mjs +3 -3
- package/esm2020/lib/cache/storage.mjs +3 -3
- package/esm2020/lib/client.mjs +3 -3
- package/esm2020/lib/models/collection.mjs +5 -6
- package/esm2020/lib/models/model.mjs +1 -3
- package/esm2020/lib/models/options.mjs +84 -44
- package/esm2020/lib/module.mjs +5 -5
- package/esm2020/lib/resources/query/builder.mjs +1 -1
- package/esm2020/lib/resources/query/expressions/compute.mjs +5 -5
- package/esm2020/lib/resources/query/expressions/expand.mjs +6 -6
- package/esm2020/lib/resources/query/expressions/filter.mjs +9 -9
- package/esm2020/lib/resources/query/expressions/index.mjs +3 -1
- package/esm2020/lib/resources/query/expressions/orderby.mjs +5 -5
- package/esm2020/lib/resources/query/expressions/search.mjs +3 -3
- package/esm2020/lib/resources/query/expressions/select.mjs +7 -7
- package/esm2020/lib/resources/query/handlers.mjs +140 -22
- package/esm2020/lib/resources/query/options.mjs +16 -13
- package/esm2020/lib/resources/request.mjs +31 -36
- package/esm2020/lib/resources/resource.mjs +15 -3
- package/esm2020/lib/resources/types/navigation-property.mjs +5 -3
- package/esm2020/lib/resources/types/options.mjs +1 -1
- package/esm2020/lib/resources/types/property.mjs +4 -4
- package/esm2020/lib/schema/enum-type.mjs +9 -25
- package/esm2020/lib/schema/parsers/callable.mjs +6 -1
- package/esm2020/lib/schema/parsers/enum-type.mjs +23 -3
- package/esm2020/lib/schema/parsers/structured-type.mjs +120 -42
- package/esm2020/lib/schema/structured-type.mjs +26 -38
- package/esm2020/lib/services/base.mjs +1 -1
- package/esm2020/lib/services/factory.mjs +3 -3
- package/esm2020/lib/types.mjs +1 -1
- package/esm2020/lib/utils/objects.mjs +2 -2
- package/esm2020/lib/utils/types.mjs +2 -7
- package/fesm2015/angular-odata.mjs +601 -342
- package/fesm2015/angular-odata.mjs.map +1 -1
- package/fesm2020/angular-odata.mjs +593 -335
- package/fesm2020/angular-odata.mjs.map +1 -1
- package/{angular-odata.d.ts → index.d.ts} +0 -0
- package/lib/api.d.ts +2 -4
- package/lib/models/collection.d.ts +5 -4
- package/lib/models/model.d.ts +4 -4
- package/lib/models/options.d.ts +20 -12
- package/lib/resources/query/builder.d.ts +1 -1
- package/lib/resources/query/expressions/compute.d.ts +7 -6
- package/lib/resources/query/expressions/expand.d.ts +17 -32
- package/lib/resources/query/expressions/filter.d.ts +11 -10
- package/lib/resources/query/expressions/index.d.ts +2 -0
- package/lib/resources/query/expressions/orderby.d.ts +7 -6
- package/lib/resources/query/expressions/search.d.ts +5 -4
- package/lib/resources/query/expressions/select.d.ts +7 -6
- package/lib/resources/query/handlers.d.ts +39 -33
- package/lib/resources/query/options.d.ts +14 -12
- package/lib/resources/request.d.ts +2 -1
- package/lib/resources/resource.d.ts +3 -2
- package/lib/resources/types/options.d.ts +4 -2
- package/lib/schema/enum-type.d.ts +7 -19
- package/lib/schema/parsers/callable.d.ts +1 -0
- package/lib/schema/parsers/enum-type.d.ts +18 -10
- package/lib/schema/parsers/structured-type.d.ts +47 -3
- package/lib/schema/structured-type.d.ts +19 -19
- package/lib/services/base.d.ts +9 -9
- package/lib/types.d.ts +5 -5
- package/lib/utils/objects.d.ts +1 -1
- package/lib/utils/strings.d.ts +1 -1
- package/lib/utils/types.d.ts +0 -1
- package/package.json +5 -5
|
File without changes
|
package/lib/api.d.ts
CHANGED
|
@@ -20,9 +20,7 @@ export declare class ODataApi {
|
|
|
20
20
|
options: ODataApiOptions;
|
|
21
21
|
cache: ODataCache;
|
|
22
22
|
errorHandler?: (error: any, caught: Observable<any>) => Observable<never>;
|
|
23
|
-
parsers:
|
|
24
|
-
[type: string]: Parser<any>;
|
|
25
|
-
};
|
|
23
|
+
parsers: Map<string, Parser<any>>;
|
|
26
24
|
schemas: ODataSchema[];
|
|
27
25
|
constructor(config: ApiConfig);
|
|
28
26
|
configure(settings?: {
|
|
@@ -96,5 +94,5 @@ export declare class ODataApi {
|
|
|
96
94
|
findCollectionByName(name: string): typeof ODataCollection | undefined;
|
|
97
95
|
findServiceByName(name: string): typeof ODataEntityService | undefined;
|
|
98
96
|
parserForType<T>(type: string, bindingType?: string): Parser<T>;
|
|
99
|
-
findOptionsForType<T>(type: string): ODataModelOptions<T> | undefined;
|
|
97
|
+
findOptionsForType<T>(type: string): ODataModelOptions<any> | ODataModelOptions<T> | undefined;
|
|
100
98
|
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { EventEmitter } from '@angular/core';
|
|
2
2
|
import { Observable } from 'rxjs';
|
|
3
|
-
import { ODataEntitiesAnnotations, ODataEntitySetResource, ODataNavigationPropertyResource, ODataOptions, ODataPropertyResource,
|
|
3
|
+
import { ODataActionOptions, ODataEntitiesAnnotations, ODataEntitySetResource, ODataFunctionOptions, ODataNavigationPropertyResource, ODataOptions, ODataPropertyResource, ODataQueryOptionsHandler, ODataResource } from '../resources';
|
|
4
|
+
import { ODataStructuredType } from '../schema/structured-type';
|
|
4
5
|
import { ODataModel } from './model';
|
|
5
6
|
import { ODataModelEntry, ODataModelEvent, ODataModelField } from './options';
|
|
6
7
|
export declare class ODataCollection<T, M extends ODataModel<T>> implements Iterable<M> {
|
|
@@ -103,9 +104,9 @@ export declare class ODataCollection<T, M extends ODataModel<T>> implements Iter
|
|
|
103
104
|
reparent?: boolean;
|
|
104
105
|
silent?: boolean;
|
|
105
106
|
}): void;
|
|
106
|
-
query(func: (q: ODataQueryOptionsHandler<T>) => void): this;
|
|
107
|
-
callFunction<P, R>(name: string, params: P | null, responseType: 'property' | 'model' | 'collection' | 'none', { ...options }?: {} &
|
|
108
|
-
callAction<P, R>(name: string, params: P | null, responseType: 'property' | 'model' | 'collection' | 'none', { ...options }?: {} &
|
|
107
|
+
query(func: (q: ODataQueryOptionsHandler<T>, s?: ODataStructuredType<T>) => void): this;
|
|
108
|
+
callFunction<P, R>(name: string, params: P | null, responseType: 'property' | 'model' | 'collection' | 'none', { ...options }?: {} & ODataFunctionOptions<R>): Observable<R | ODataModel<R> | ODataCollection<R, ODataModel<R>> | null>;
|
|
109
|
+
callAction<P, R>(name: string, params: P | null, responseType: 'property' | 'model' | 'collection' | 'none', { ...options }?: {} & ODataActionOptions<R>): Observable<R | ODataModel<R> | ODataCollection<R, ODataModel<R>> | null>;
|
|
109
110
|
private _unlink;
|
|
110
111
|
private _link;
|
|
111
112
|
private _findEntry;
|
package/lib/models/model.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { EventEmitter } from '@angular/core';
|
|
2
2
|
import { Observable } from 'rxjs';
|
|
3
|
-
import { EntityKey, ODataEntityAnnotations, ODataEntityResource, ODataNavigationPropertyResource, ODataOptions, ODataPropertyResource, ODataQueryArgumentsOptions, ODataQueryOptionsHandler, ODataResource, ODataSingletonResource } from '../resources';
|
|
3
|
+
import { EntityKey, ODataActionOptions, ODataEntityAnnotations, ODataEntityResource, ODataFunctionOptions, ODataNavigationPropertyResource, ODataOptions, ODataPropertyResource, ODataQueryArgumentsOptions, ODataQueryOptionsHandler, ODataResource, ODataSingletonResource } from '../resources';
|
|
4
4
|
import { ODataStructuredType } from '../schema';
|
|
5
5
|
import { ODataCollection } from './collection';
|
|
6
6
|
import { ModelOptions, ODataModelEvent, ODataModelField, ODataModelOptions, ODataModelRelation } from './options';
|
|
@@ -137,7 +137,7 @@ export declare class ODataModel<T> {
|
|
|
137
137
|
* Create an execution context for change the internal query of a resource
|
|
138
138
|
* @param func Function to execute
|
|
139
139
|
*/
|
|
140
|
-
query(func: (q: ODataQueryOptionsHandler<T>) => void): this;
|
|
140
|
+
query(func: (q: ODataQueryOptionsHandler<T>, s?: ODataStructuredType<T>) => void): this;
|
|
141
141
|
/**
|
|
142
142
|
* Perform a check on the internal state of the model and return true if the model is changed.
|
|
143
143
|
* @param include_navigation Check in navigation properties
|
|
@@ -152,8 +152,8 @@ export declare class ODataModel<T> {
|
|
|
152
152
|
* @returns The result of the context
|
|
153
153
|
*/
|
|
154
154
|
asEntity<R>(ctx: (model: this) => R): R;
|
|
155
|
-
callFunction<P, R>(name: string, params: P | null, responseType: 'property' | 'model' | 'collection' | 'none', { ...options }?: {} &
|
|
156
|
-
callAction<P, R>(name: string, params: P | null, responseType: 'property' | 'model' | 'collection' | 'none', { ...options }?: {} &
|
|
155
|
+
callFunction<P, R>(name: string, params: P | null, responseType: 'property' | 'model' | 'collection' | 'none', { ...options }?: {} & ODataFunctionOptions<R>): Observable<R | ODataModel<R> | ODataCollection<R, ODataModel<R>> | null>;
|
|
156
|
+
callAction<P, R>(name: string, params: P | null, responseType: 'property' | 'model' | 'collection' | 'none', { ...options }?: {} & ODataActionOptions<R>): Observable<R | ODataModel<R> | ODataCollection<R, ODataModel<R>> | null>;
|
|
157
157
|
cast<S>(type: string): ODataModel<S>;
|
|
158
158
|
fetchNavigationProperty<S>(name: keyof T | string, responseType: 'model' | 'collection', { ...options }?: {} & ODataQueryArgumentsOptions<S>): Observable<ODataModel<S> | ODataCollection<S, ODataModel<S>> | null>;
|
|
159
159
|
getValue<P>(name: keyof T | string, options?: ODataOptions): Observable<P | ODataModel<P> | ODataCollection<P, ODataModel<P>> | null>;
|
package/lib/models/options.d.ts
CHANGED
|
@@ -10,10 +10,10 @@ export declare class ODataModelEvent<T> {
|
|
|
10
10
|
value?: any;
|
|
11
11
|
previous?: any;
|
|
12
12
|
options?: any;
|
|
13
|
-
constructor(name: ODataModelEventType, { model, collection, previous, value,
|
|
13
|
+
constructor(name: ODataModelEventType, { model, collection, previous, value, field, options, }?: {
|
|
14
14
|
model?: ODataModel<T>;
|
|
15
15
|
collection?: ODataCollection<T, ODataModel<T>>;
|
|
16
|
-
|
|
16
|
+
field?: ODataModelField<any> | number;
|
|
17
17
|
previous?: any;
|
|
18
18
|
value?: any;
|
|
19
19
|
options?: any;
|
|
@@ -22,9 +22,9 @@ export declare class ODataModelEvent<T> {
|
|
|
22
22
|
stopPropagation(): void;
|
|
23
23
|
chain: [
|
|
24
24
|
ODataModel<any> | ODataCollection<any, ODataModel<any>>,
|
|
25
|
-
|
|
25
|
+
ODataModelField<any> | number | null
|
|
26
26
|
][];
|
|
27
|
-
push(model: ODataModel<any> | ODataCollection<any, ODataModel<any>>,
|
|
27
|
+
push(model: ODataModel<any> | ODataCollection<any, ODataModel<any>>, field: ODataModelField<any> | number): ODataModelEvent<T>;
|
|
28
28
|
visited(model: ODataModel<any> | ODataCollection<any, ODataModel<any>>): boolean;
|
|
29
29
|
get path(): string;
|
|
30
30
|
model?: ODataModel<T>;
|
|
@@ -162,16 +162,21 @@ export declare class ODataModelOptions<T> {
|
|
|
162
162
|
schema: ODataStructuredType<T>;
|
|
163
163
|
});
|
|
164
164
|
get api(): import("angular-odata").ODataApi;
|
|
165
|
-
type(
|
|
165
|
+
type({ alias }?: {
|
|
166
|
+
alias?: boolean;
|
|
167
|
+
}): string;
|
|
166
168
|
isTypeOf(type: string): boolean;
|
|
169
|
+
isModelFor(entity: T | {
|
|
170
|
+
[name: string]: any;
|
|
171
|
+
}): boolean;
|
|
167
172
|
findChildOptions(predicate: (options: ODataModelOptions<any>) => boolean): ODataModelOptions<any> | undefined;
|
|
168
173
|
configure({ findOptionsForType, options, }: {
|
|
169
174
|
findOptionsForType: (type: string) => ODataModelOptions<any> | undefined;
|
|
170
175
|
options: ParserOptions;
|
|
171
176
|
}): void;
|
|
172
|
-
fields({ include_navigation, include_parents, }
|
|
173
|
-
include_parents
|
|
174
|
-
include_navigation
|
|
177
|
+
fields({ include_navigation, include_parents, }: {
|
|
178
|
+
include_parents: boolean;
|
|
179
|
+
include_navigation: boolean;
|
|
175
180
|
}): ODataModelField<any>[];
|
|
176
181
|
field<F>(name: keyof T | string): ODataModelField<F>;
|
|
177
182
|
attach<R>(self: ODataModel<T>, resource: ODataEntityResource<R> | ODataNavigationPropertyResource<R> | ODataPropertyResource<R> | ODataSingletonResource<R>): void;
|
|
@@ -191,28 +196,31 @@ export declare class ODataModelOptions<T> {
|
|
|
191
196
|
resource?: ODataResource<T>;
|
|
192
197
|
annots?: ODataEntityAnnotations;
|
|
193
198
|
}): void;
|
|
194
|
-
query(self: ODataModel<T>, resource: ODataEntityResource<T> | ODataPropertyResource<T> | ODataNavigationPropertyResource<T> | ODataSingletonResource<T>, func: (q: ODataQueryOptionsHandler<T>) => void): ODataModel<T>;
|
|
199
|
+
query(self: ODataModel<T>, resource: ODataEntityResource<T> | ODataPropertyResource<T> | ODataNavigationPropertyResource<T> | ODataSingletonResource<T>, func: (q: ODataQueryOptionsHandler<T>, s?: ODataStructuredType<T>) => void): ODataModel<T>;
|
|
195
200
|
resolveKey(value: ODataModel<T> | T | {
|
|
196
201
|
[name: string]: any;
|
|
197
|
-
}, { field_mapping, resolve, }?: {
|
|
202
|
+
}, { field_mapping, resolve, single, }?: {
|
|
198
203
|
field_mapping?: boolean;
|
|
199
204
|
resolve?: boolean;
|
|
205
|
+
single?: boolean;
|
|
200
206
|
}): EntityKey<T> | {
|
|
201
207
|
[name: string]: any;
|
|
202
208
|
} | undefined;
|
|
203
209
|
resolveReferential(value: ODataModel<T> | T | {
|
|
204
210
|
[name: string]: any;
|
|
205
|
-
} | null, field: ODataModelField<any>, { field_mapping, resolve, }?: {
|
|
211
|
+
} | null, field: ODataModelField<any>, { field_mapping, resolve, single, }?: {
|
|
206
212
|
field_mapping?: boolean;
|
|
207
213
|
resolve?: boolean;
|
|
214
|
+
single?: boolean;
|
|
208
215
|
}): {
|
|
209
216
|
[name: string]: any;
|
|
210
217
|
} | null | undefined;
|
|
211
218
|
resolveReferenced(value: ODataModel<T> | T | {
|
|
212
219
|
[name: string]: any;
|
|
213
|
-
} | null, field: ODataModelField<any>, { field_mapping, resolve, }?: {
|
|
220
|
+
} | null, field: ODataModelField<any>, { field_mapping, resolve, single, }?: {
|
|
214
221
|
field_mapping?: boolean;
|
|
215
222
|
resolve?: boolean;
|
|
223
|
+
single?: boolean;
|
|
216
224
|
}): {
|
|
217
225
|
[name: string]: any;
|
|
218
226
|
} | null | undefined;
|
|
@@ -59,7 +59,7 @@ export declare type QueryCustomType = {
|
|
|
59
59
|
};
|
|
60
60
|
export declare type Value = string | Date | number | boolean | QueryCustomType;
|
|
61
61
|
export declare const raw: (value: string) => QueryCustomType;
|
|
62
|
-
export declare const alias: (value: any, name?: string
|
|
62
|
+
export declare const alias: (value: any, name?: string) => QueryCustomType;
|
|
63
63
|
export declare const duration: (value: string) => QueryCustomType;
|
|
64
64
|
export declare const binary: (value: string) => QueryCustomType;
|
|
65
65
|
export declare const isQueryCustomType: (value: any) => boolean;
|
|
@@ -1,18 +1,19 @@
|
|
|
1
1
|
import type { QueryCustomType } from '../builder';
|
|
2
2
|
import { Expression } from './base';
|
|
3
3
|
import { ODataFunctions, ODataOperators, Renderable } from './syntax';
|
|
4
|
+
export declare type ComputeExpressionBuilder<T> = {
|
|
5
|
+
t: T;
|
|
6
|
+
e: () => ComputeExpression<T>;
|
|
7
|
+
};
|
|
4
8
|
export declare class ComputeExpression<T> extends Expression<T> {
|
|
5
9
|
names: string[];
|
|
6
10
|
constructor({ children, names, }?: {
|
|
7
11
|
children?: Renderable[];
|
|
8
12
|
names?: string[];
|
|
9
13
|
});
|
|
10
|
-
static
|
|
11
|
-
static
|
|
12
|
-
static compute<T extends object>(opts: (builder:
|
|
13
|
-
s: T;
|
|
14
|
-
e: () => ComputeExpression<T>;
|
|
15
|
-
}, current?: ComputeExpression<T>) => ComputeExpression<T>, current?: ComputeExpression<T>): ComputeExpression<T>;
|
|
14
|
+
static expression<T>(): ComputeExpression<T>;
|
|
15
|
+
static type<T extends object>(): T;
|
|
16
|
+
static compute<T extends object>(opts: (builder: ComputeExpressionBuilder<T>, current?: ComputeExpression<T>) => ComputeExpression<T>, current?: ComputeExpression<T>): ComputeExpression<T>;
|
|
16
17
|
render({ aliases, escape, prefix, }?: {
|
|
17
18
|
aliases?: QueryCustomType[] | undefined;
|
|
18
19
|
escape?: boolean | undefined;
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import type { QueryCustomType } from '../builder';
|
|
2
2
|
import { Expression } from './base';
|
|
3
|
-
import {
|
|
4
|
-
import { OrderByExpression } from './orderby';
|
|
5
|
-
import {
|
|
6
|
-
import { SelectExpression } from './select';
|
|
7
|
-
import {
|
|
3
|
+
import { FilterExpression, FilterExpressionBuilder } from './filter';
|
|
4
|
+
import { OrderByExpression, OrderByExpressionBuilder } from './orderby';
|
|
5
|
+
import { SearchExpression, SearchExpressionBuilder } from './search';
|
|
6
|
+
import { SelectExpression, SelectExpressionBuilder } from './select';
|
|
7
|
+
import { Renderable } from './syntax';
|
|
8
8
|
export declare class ExpandField<T> implements Renderable {
|
|
9
9
|
protected field: any;
|
|
10
10
|
private values;
|
|
@@ -21,42 +21,27 @@ export declare class ExpandField<T> implements Renderable {
|
|
|
21
21
|
prefix?: string;
|
|
22
22
|
}): string;
|
|
23
23
|
clone(): ExpandField<unknown>;
|
|
24
|
-
select<T extends object>(opts: (builder:
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
s: T;
|
|
30
|
-
e: () => ExpandExpression<T>;
|
|
31
|
-
}, current?: ExpandExpression<T>) => ExpandExpression<T>): any;
|
|
32
|
-
filter<T extends object>(opts: (builder: {
|
|
33
|
-
s: T;
|
|
34
|
-
e: (connector?: FilterConnector) => FilterExpression<T>;
|
|
35
|
-
o: ODataOperators<T>;
|
|
36
|
-
f: ODataFunctions<T>;
|
|
37
|
-
}, current?: FilterExpression<T>) => FilterExpression<T>): any;
|
|
38
|
-
search<T extends object>(opts: (builder: {
|
|
39
|
-
e: (connector?: SearchConnector) => SearchExpression<T>;
|
|
40
|
-
}) => SearchExpression<T>): any;
|
|
41
|
-
orderBy<T extends object>(opts: (builder: {
|
|
42
|
-
s: T;
|
|
43
|
-
e: () => OrderByExpression<T>;
|
|
44
|
-
}, current?: OrderByExpression<T>) => OrderByExpression<T>): any;
|
|
24
|
+
select<T extends object>(opts: (builder: SelectExpressionBuilder<T>, current?: SelectExpression<T>) => SelectExpression<T>): SelectExpression<T>;
|
|
25
|
+
expand<T extends object>(opts: (builder: ExpandExpressionBuilder<T>, current?: ExpandExpression<T>) => ExpandExpression<T>): any;
|
|
26
|
+
filter<T extends object>(opts: (builder: FilterExpressionBuilder<T>, current?: FilterExpression<T>) => FilterExpression<T>): any;
|
|
27
|
+
search<T extends object>(opts: (builder: SearchExpressionBuilder<T>) => SearchExpression<T>): any;
|
|
28
|
+
orderBy<T extends object>(opts: (builder: OrderByExpressionBuilder<T>, current?: OrderByExpression<T>) => OrderByExpression<T>): any;
|
|
45
29
|
skip(n: number): any;
|
|
46
30
|
top(n: number): any;
|
|
47
31
|
levels(n: number | 'max'): any;
|
|
48
32
|
private option;
|
|
49
33
|
}
|
|
34
|
+
export declare type ExpandExpressionBuilder<T> = {
|
|
35
|
+
t: T;
|
|
36
|
+
e: () => ExpandExpression<T>;
|
|
37
|
+
};
|
|
50
38
|
export declare class ExpandExpression<T> extends Expression<T> {
|
|
51
39
|
constructor({ children, }?: {
|
|
52
40
|
children?: Renderable[];
|
|
53
41
|
});
|
|
54
|
-
static
|
|
55
|
-
static
|
|
56
|
-
static expand<T extends object>(opts: (builder:
|
|
57
|
-
s: T;
|
|
58
|
-
e: () => ExpandExpression<T>;
|
|
59
|
-
}, current?: ExpandExpression<T>) => ExpandExpression<T>, current?: ExpandExpression<T>): ExpandExpression<T>;
|
|
42
|
+
static expression<T>(): ExpandExpression<T>;
|
|
43
|
+
static type<T extends object>(): T;
|
|
44
|
+
static expand<T extends object>(opts: (builder: ExpandExpressionBuilder<T>, current?: ExpandExpression<T>) => ExpandExpression<T>, current?: ExpandExpression<T>): ExpandExpression<T>;
|
|
60
45
|
render({ aliases, escape, prefix, }?: {
|
|
61
46
|
aliases?: QueryCustomType[] | undefined;
|
|
62
47
|
escape?: boolean | undefined;
|
|
@@ -2,6 +2,12 @@ import type { QueryCustomType } from '../builder';
|
|
|
2
2
|
import { Expression } from './base';
|
|
3
3
|
import { ODataFunctions, ODataOperators, Renderable } from './syntax';
|
|
4
4
|
export declare type FilterConnector = 'and' | 'or';
|
|
5
|
+
export declare type FilterExpressionBuilder<T> = {
|
|
6
|
+
t: T;
|
|
7
|
+
e: (connector?: FilterConnector) => FilterExpression<T>;
|
|
8
|
+
o: ODataOperators<T>;
|
|
9
|
+
f: ODataFunctions<T>;
|
|
10
|
+
};
|
|
5
11
|
export declare class FilterExpression<F> extends Expression<F> {
|
|
6
12
|
private _connector;
|
|
7
13
|
private _negated;
|
|
@@ -10,14 +16,9 @@ export declare class FilterExpression<F> extends Expression<F> {
|
|
|
10
16
|
connector?: FilterConnector;
|
|
11
17
|
negated?: boolean;
|
|
12
18
|
});
|
|
13
|
-
static
|
|
14
|
-
static
|
|
15
|
-
static filter<T extends object>(opts: (builder:
|
|
16
|
-
s: T;
|
|
17
|
-
e: (connector?: FilterConnector) => FilterExpression<T>;
|
|
18
|
-
o: ODataOperators<T>;
|
|
19
|
-
f: ODataFunctions<T>;
|
|
20
|
-
}, current?: FilterExpression<T>) => FilterExpression<T>, current?: FilterExpression<T>): FilterExpression<T>;
|
|
19
|
+
static type<T extends object>(): T;
|
|
20
|
+
static expression<T>(connector?: FilterConnector): FilterExpression<T>;
|
|
21
|
+
static filter<T extends object>(opts: (builder: FilterExpressionBuilder<T>, current?: FilterExpression<T>) => FilterExpression<T>, current?: FilterExpression<T>): FilterExpression<T>;
|
|
21
22
|
toJSON(): {
|
|
22
23
|
children: any[];
|
|
23
24
|
connector: FilterConnector;
|
|
@@ -47,11 +48,11 @@ export declare class FilterExpression<F> extends Expression<F> {
|
|
|
47
48
|
startsWith(left: any, right: any, normalize?: boolean): FilterExpression<F>;
|
|
48
49
|
endsWith(left: any, right: any, normalize?: boolean): FilterExpression<F>;
|
|
49
50
|
any<N extends object>(left: N[], opts: (e: {
|
|
50
|
-
s: N;
|
|
51
51
|
e: (connector?: FilterConnector) => FilterExpression<N>;
|
|
52
|
+
t: N;
|
|
52
53
|
}) => FilterExpression<N>, alias?: string): FilterExpression<F>;
|
|
53
54
|
all<N extends object>(left: N[], opts: (e: {
|
|
54
|
-
|
|
55
|
+
t: N;
|
|
55
56
|
e: (connector?: FilterConnector) => FilterExpression<N>;
|
|
56
57
|
}) => FilterExpression<N>, alias?: string): FilterExpression<F>;
|
|
57
58
|
isof(type: string): FilterExpression<F>;
|
|
@@ -17,16 +17,17 @@ export declare class OrderByField implements Renderable {
|
|
|
17
17
|
}): string;
|
|
18
18
|
clone(): OrderByField;
|
|
19
19
|
}
|
|
20
|
+
export declare type OrderByExpressionBuilder<T> = {
|
|
21
|
+
t: T;
|
|
22
|
+
e: () => OrderByExpression<T>;
|
|
23
|
+
};
|
|
20
24
|
export declare class OrderByExpression<T> extends Expression<T> {
|
|
21
25
|
constructor({ children, }?: {
|
|
22
26
|
children?: Renderable[];
|
|
23
27
|
});
|
|
24
|
-
static
|
|
25
|
-
static
|
|
26
|
-
static orderBy<T extends object>(opts: (builder:
|
|
27
|
-
s: T;
|
|
28
|
-
e: () => OrderByExpression<T>;
|
|
29
|
-
}, current?: OrderByExpression<T>) => OrderByExpression<T>, current?: OrderByExpression<T>): OrderByExpression<T>;
|
|
28
|
+
static expression<T>(): OrderByExpression<T>;
|
|
29
|
+
static type<T extends object>(): T;
|
|
30
|
+
static orderBy<T extends object>(opts: (builder: OrderByExpressionBuilder<T>, current?: OrderByExpression<T>) => OrderByExpression<T>, current?: OrderByExpression<T>): OrderByExpression<T>;
|
|
30
31
|
private _add;
|
|
31
32
|
render({ aliases, escape, prefix, }?: {
|
|
32
33
|
aliases?: QueryCustomType[] | undefined;
|
|
@@ -17,6 +17,9 @@ export declare class SearchTerm implements Renderable {
|
|
|
17
17
|
}): string;
|
|
18
18
|
clone(): SearchTerm;
|
|
19
19
|
}
|
|
20
|
+
export declare type SearchExpressionBuilder<T> = {
|
|
21
|
+
e: (connector?: SearchConnector) => SearchExpression<T>;
|
|
22
|
+
};
|
|
20
23
|
export declare class SearchExpression<T> extends Expression<T> {
|
|
21
24
|
private _connector;
|
|
22
25
|
private _negated;
|
|
@@ -25,10 +28,8 @@ export declare class SearchExpression<T> extends Expression<T> {
|
|
|
25
28
|
connector?: SearchConnector;
|
|
26
29
|
negated?: boolean;
|
|
27
30
|
});
|
|
28
|
-
static
|
|
29
|
-
static search<T extends object>(opts: (builder:
|
|
30
|
-
e: (connector?: SearchConnector) => SearchExpression<T>;
|
|
31
|
-
}, current?: SearchExpression<T>) => SearchExpression<T>, current?: SearchExpression<T>): SearchExpression<T>;
|
|
31
|
+
static expression<T>(connector?: SearchConnector): SearchExpression<T>;
|
|
32
|
+
static search<T extends object>(opts: (builder: SearchExpressionBuilder<T>, current?: SearchExpression<T>) => SearchExpression<T>, current?: SearchExpression<T>): SearchExpression<T>;
|
|
32
33
|
private _add;
|
|
33
34
|
render({ aliases, escape, prefix, }?: {
|
|
34
35
|
aliases?: QueryCustomType[] | undefined;
|
|
@@ -1,16 +1,17 @@
|
|
|
1
1
|
import type { QueryCustomType } from '../builder';
|
|
2
2
|
import { Expression } from './base';
|
|
3
3
|
import { Renderable } from './syntax';
|
|
4
|
+
export declare type SelectExpressionBuilder<T> = {
|
|
5
|
+
t: T;
|
|
6
|
+
e: () => SelectExpression<T>;
|
|
7
|
+
};
|
|
4
8
|
export declare class SelectExpression<T> extends Expression<T> {
|
|
5
9
|
constructor({ children, }?: {
|
|
6
10
|
children?: Renderable[];
|
|
7
11
|
});
|
|
8
|
-
static
|
|
9
|
-
static
|
|
10
|
-
static select<T extends object>(
|
|
11
|
-
s: T;
|
|
12
|
-
e: () => SelectExpression<T>;
|
|
13
|
-
}, c?: SelectExpression<T>) => SelectExpression<T>, current?: SelectExpression<T>): SelectExpression<T>;
|
|
12
|
+
static expression<T>(): SelectExpression<T>;
|
|
13
|
+
static type<T extends object>(): T;
|
|
14
|
+
static select<T extends object>(opts: (builder: SelectExpressionBuilder<T>, current?: SelectExpression<T>) => SelectExpression<T>, current?: SelectExpression<T>): SelectExpression<T>;
|
|
14
15
|
render({ aliases, escape, prefix, }?: {
|
|
15
16
|
aliases?: QueryCustomType[] | undefined;
|
|
16
17
|
escape?: boolean | undefined;
|
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
import { QueryOptionNames } from '../../types';
|
|
2
2
|
import { Expand, Filter, OrderBy, Select, Transform } from './builder';
|
|
3
|
-
import { ComputeExpression,
|
|
4
|
-
import { ExpandExpression } from './expressions/expand';
|
|
5
|
-
import { SelectExpression } from './expressions/select';
|
|
3
|
+
import { ComputeExpression, ComputeExpressionBuilder, FilterExpression, FilterExpressionBuilder, OrderByExpression, OrderByExpressionBuilder, SearchExpression, SearchExpressionBuilder, ExpandExpression, ExpandExpressionBuilder, SelectExpression, SelectExpressionBuilder } from './expressions';
|
|
6
4
|
import type { ODataQueryArguments, ODataQueryOptions } from './options';
|
|
7
5
|
export declare class ODataQueryOptionHandler<T> {
|
|
8
6
|
private o;
|
|
@@ -45,6 +43,9 @@ export declare class ODataQueryOptionHandler<T> {
|
|
|
45
43
|
* @returns The value
|
|
46
44
|
*/
|
|
47
45
|
at(index: number): any;
|
|
46
|
+
some(predicate: (value: any) => boolean): boolean;
|
|
47
|
+
every(predicate: (value: any) => boolean): boolean;
|
|
48
|
+
find(predicate: (value: any) => boolean): any;
|
|
48
49
|
private assertObject;
|
|
49
50
|
/**
|
|
50
51
|
* Set the value for path in the managed odata query option.
|
|
@@ -86,6 +87,12 @@ export declare class ODataQueryOptionHandler<T> {
|
|
|
86
87
|
export declare class ODataQueryOptionsHandler<T> {
|
|
87
88
|
protected options: ODataQueryOptions<T>;
|
|
88
89
|
constructor(options: ODataQueryOptions<T>);
|
|
90
|
+
/**
|
|
91
|
+
* Create a raw odata value
|
|
92
|
+
* @param value The value to raw
|
|
93
|
+
* @returns The raw value
|
|
94
|
+
*/
|
|
95
|
+
raw(value: any): import("./builder").QueryCustomType;
|
|
89
96
|
/**
|
|
90
97
|
* Create a new odata alias parameter
|
|
91
98
|
* @link https://docs.oasis-open.org/odata/odata/v4.01/odata-v4.01-part2-url-conventions.html#sec_ParameterAliases
|
|
@@ -94,6 +101,18 @@ export declare class ODataQueryOptionsHandler<T> {
|
|
|
94
101
|
* @returns The alias
|
|
95
102
|
*/
|
|
96
103
|
alias(value: any, name?: string): import("./builder").QueryCustomType;
|
|
104
|
+
/**
|
|
105
|
+
* Create a duration odata value
|
|
106
|
+
* @param value The value to duration
|
|
107
|
+
* @returns The duration value
|
|
108
|
+
*/
|
|
109
|
+
duration(value: any): import("./builder").QueryCustomType;
|
|
110
|
+
/**
|
|
111
|
+
* Create a binary odata value
|
|
112
|
+
* @param value The value to binary
|
|
113
|
+
* @returns The binary value
|
|
114
|
+
*/
|
|
115
|
+
binary(value: any): import("./builder").QueryCustomType;
|
|
97
116
|
/**
|
|
98
117
|
* Normalize the given value to a valid odata value
|
|
99
118
|
* @param value The value to normalize
|
|
@@ -105,10 +124,7 @@ export declare class ODataQueryOptionsHandler<T> {
|
|
|
105
124
|
* If opts is given then set te value as new value for $select.
|
|
106
125
|
* @param opts Select<T> value or builder function for SelectExpression<T>
|
|
107
126
|
*/
|
|
108
|
-
select(opts:
|
|
109
|
-
s: T;
|
|
110
|
-
e: () => SelectExpression<T>;
|
|
111
|
-
}, current?: SelectExpression<T>) => SelectExpression<T>): SelectExpression<T>;
|
|
127
|
+
select(opts: SelectExpressionBuilder<T>): SelectExpression<T>;
|
|
112
128
|
select(opts: Select<T>): ODataQueryOptionHandler<T>;
|
|
113
129
|
select(): ODataQueryOptionHandler<T>;
|
|
114
130
|
/**
|
|
@@ -116,10 +132,7 @@ export declare class ODataQueryOptionsHandler<T> {
|
|
|
116
132
|
* If opts is given then set te value as new value for $expand.
|
|
117
133
|
* @param opts Expand<T> value or builder function for ExpandExpression<T>
|
|
118
134
|
*/
|
|
119
|
-
expand(opts:
|
|
120
|
-
s: T;
|
|
121
|
-
e: () => ExpandExpression<T>;
|
|
122
|
-
}, current?: ExpandExpression<T>) => ExpandExpression<T>): ExpandExpression<T>;
|
|
135
|
+
expand(opts: ExpandExpressionBuilder<T>): ExpandExpression<T>;
|
|
123
136
|
expand(opts: Expand<T>): ODataQueryOptionHandler<T>;
|
|
124
137
|
expand(): ODataQueryOptionHandler<T>;
|
|
125
138
|
/**
|
|
@@ -128,12 +141,7 @@ export declare class ODataQueryOptionsHandler<T> {
|
|
|
128
141
|
* @link https://docs.oasis-open.org/odata/odata/v4.01/odata-v4.01-part2-url-conventions.html#sec_SystemQueryOptioncompute
|
|
129
142
|
* @param opts string value or builder function for ComputeExpression<T>
|
|
130
143
|
*/
|
|
131
|
-
compute(opts: (builder:
|
|
132
|
-
s: T;
|
|
133
|
-
e: () => ComputeExpression<T>;
|
|
134
|
-
o: ODataOperators<T>;
|
|
135
|
-
f: ODataFunctions<T>;
|
|
136
|
-
}, current?: ComputeExpression<T>) => ComputeExpression<T>): ComputeExpression<T>;
|
|
144
|
+
compute(opts: (builder: ComputeExpressionBuilder<T>, current?: ComputeExpression<T>) => ComputeExpression<T>): ComputeExpression<T>;
|
|
137
145
|
compute(opts: string): ODataQueryOptionHandler<T>;
|
|
138
146
|
compute(): ODataQueryOptionHandler<T>;
|
|
139
147
|
/**
|
|
@@ -156,9 +164,7 @@ export declare class ODataQueryOptionsHandler<T> {
|
|
|
156
164
|
* If opts is given then set te value as new value for $search.
|
|
157
165
|
* @param opts string value or builder function for SearchExpression<T>
|
|
158
166
|
*/
|
|
159
|
-
search(opts: (builder:
|
|
160
|
-
e: (connector: SearchConnector) => SearchExpression<T>;
|
|
161
|
-
}, current?: SearchExpression<T>) => SearchExpression<T>): SearchExpression<T>;
|
|
167
|
+
search(opts: (builder: SearchExpressionBuilder<T>, current?: SearchExpression<T>) => SearchExpression<T>): SearchExpression<T>;
|
|
162
168
|
search(opts: string): ODataQueryOptionHandler<T>;
|
|
163
169
|
search(): ODataQueryOptionHandler<T>;
|
|
164
170
|
/**
|
|
@@ -166,12 +172,7 @@ export declare class ODataQueryOptionsHandler<T> {
|
|
|
166
172
|
* If opts is given then set te value as new value for $filter.
|
|
167
173
|
* @param opts Filter<T> value or builder function for FilterExpression<T>
|
|
168
174
|
*/
|
|
169
|
-
filter(opts: (builder:
|
|
170
|
-
s: T;
|
|
171
|
-
e: (connector?: FilterConnector) => FilterExpression<T>;
|
|
172
|
-
o: ODataOperators<T>;
|
|
173
|
-
f: ODataFunctions<T>;
|
|
174
|
-
}, current?: FilterExpression<T>) => FilterExpression<T>): FilterExpression<T>;
|
|
175
|
+
filter(opts: (builder: FilterExpressionBuilder<T>, current?: FilterExpression<T>) => FilterExpression<T>): FilterExpression<T>;
|
|
175
176
|
filter(opts: Filter<T>): ODataQueryOptionHandler<T>;
|
|
176
177
|
filter(): ODataQueryOptionHandler<T>;
|
|
177
178
|
/**
|
|
@@ -179,10 +180,7 @@ export declare class ODataQueryOptionsHandler<T> {
|
|
|
179
180
|
* If opts is given then set te value as new value for $orderby.
|
|
180
181
|
* @param opts OrderBy<T> value or builder function for OrderByExpression<T>
|
|
181
182
|
*/
|
|
182
|
-
orderBy(opts: (builder:
|
|
183
|
-
s: T;
|
|
184
|
-
e: () => OrderByExpression<T>;
|
|
185
|
-
}, current?: OrderByExpression<T>) => OrderByExpression<T>): OrderByExpression<T>;
|
|
183
|
+
orderBy(opts: (builder: OrderByExpressionBuilder<T>, current?: OrderByExpression<T>) => OrderByExpression<T>): OrderByExpression<T>;
|
|
186
184
|
orderBy(opts: OrderBy<T>): ODataQueryOptionHandler<T>;
|
|
187
185
|
orderBy(): ODataQueryOptionHandler<T>;
|
|
188
186
|
/**
|
|
@@ -211,14 +209,22 @@ export declare class ODataQueryOptionsHandler<T> {
|
|
|
211
209
|
* @param param0 skip or top or skiptoken
|
|
212
210
|
*/
|
|
213
211
|
paging({ skip, skiptoken, top, }?: {
|
|
214
|
-
skip?: number;
|
|
215
|
-
skiptoken?: string;
|
|
216
|
-
top?: number;
|
|
212
|
+
skip?: number | null;
|
|
213
|
+
skiptoken?: string | null;
|
|
214
|
+
top?: number | null;
|
|
217
215
|
}): void;
|
|
218
216
|
/**
|
|
219
217
|
* Shortcut for clear pagination by unset $top, $skip, $skiptoken.
|
|
220
218
|
*/
|
|
221
219
|
clearPaging(): void;
|
|
220
|
+
/**
|
|
221
|
+
* Shortcut for clear query.
|
|
222
|
+
*/
|
|
223
|
+
clear(): void;
|
|
224
|
+
/**
|
|
225
|
+
* Retrun the query.
|
|
226
|
+
*/
|
|
227
|
+
query(): ODataQueryArguments<T>;
|
|
222
228
|
/**
|
|
223
229
|
* Apply the given query options to the current query.
|
|
224
230
|
* @param query The query to be applied.
|
|
@@ -1,21 +1,23 @@
|
|
|
1
1
|
import { QueryOptionNames } from '../../types';
|
|
2
2
|
import { Expand, Filter, OrderBy, Select, Transform } from './builder';
|
|
3
|
-
import { Expression, FilterExpression, OrderByExpression, SearchExpression } from './expressions';
|
|
3
|
+
import { ComputeExpression, Expression, FilterExpression, OrderByExpression, SearchExpression } from './expressions';
|
|
4
4
|
import { ExpandExpression } from './expressions/expand';
|
|
5
5
|
import { SelectExpression } from './expressions/select';
|
|
6
6
|
import { ODataQueryOptionHandler } from './handlers';
|
|
7
7
|
export declare type ODataQueryArguments<T> = {
|
|
8
|
-
[QueryOptionNames.select]?: Select<T> | SelectExpression<T
|
|
9
|
-
[QueryOptionNames.
|
|
10
|
-
[QueryOptionNames.
|
|
11
|
-
[QueryOptionNames.
|
|
12
|
-
[QueryOptionNames.
|
|
13
|
-
[QueryOptionNames.
|
|
14
|
-
[QueryOptionNames.
|
|
15
|
-
[QueryOptionNames.
|
|
16
|
-
[QueryOptionNames.
|
|
17
|
-
[QueryOptionNames.
|
|
18
|
-
[QueryOptionNames.format]?: string;
|
|
8
|
+
[QueryOptionNames.select]?: Select<T> | SelectExpression<T> | null;
|
|
9
|
+
[QueryOptionNames.expand]?: Expand<T> | ExpandExpression<T> | null;
|
|
10
|
+
[QueryOptionNames.compute]?: string | ComputeExpression<T> | null;
|
|
11
|
+
[QueryOptionNames.filter]?: Filter<T> | FilterExpression<T> | null;
|
|
12
|
+
[QueryOptionNames.search]?: string | SearchExpression<T> | null;
|
|
13
|
+
[QueryOptionNames.transform]?: Transform<T> | null;
|
|
14
|
+
[QueryOptionNames.orderBy]?: OrderBy<T> | OrderByExpression<T> | null;
|
|
15
|
+
[QueryOptionNames.top]?: number | null;
|
|
16
|
+
[QueryOptionNames.skip]?: number | null;
|
|
17
|
+
[QueryOptionNames.skiptoken]?: string | null;
|
|
18
|
+
[QueryOptionNames.format]?: string | null;
|
|
19
|
+
[QueryOptionNames.levels]?: number | 'max' | null;
|
|
20
|
+
[QueryOptionNames.count]?: boolean | null;
|
|
19
21
|
};
|
|
20
22
|
export declare class ODataQueryOptions<T> {
|
|
21
23
|
values: Map<QueryOptionNames, any>;
|
|
@@ -16,7 +16,6 @@ export declare class ODataRequest<T> {
|
|
|
16
16
|
private readonly _headers;
|
|
17
17
|
private readonly _params;
|
|
18
18
|
private readonly _path;
|
|
19
|
-
private readonly _queryBody;
|
|
20
19
|
constructor(init: {
|
|
21
20
|
method: string;
|
|
22
21
|
api: ODataApi;
|
|
@@ -45,6 +44,8 @@ export declare class ODataRequest<T> {
|
|
|
45
44
|
get pathWithParams(): string;
|
|
46
45
|
get url(): string;
|
|
47
46
|
get urlWithParams(): string;
|
|
47
|
+
get cacheKey(): string;
|
|
48
|
+
isQueryBody(): boolean;
|
|
48
49
|
isBatch(): boolean;
|
|
49
50
|
isFetch(): boolean;
|
|
50
51
|
isMutate(): boolean;
|
|
@@ -37,6 +37,7 @@ export declare class ODataResource<T> {
|
|
|
37
37
|
* @returns boolean The resource has key ?
|
|
38
38
|
*/
|
|
39
39
|
hasKey(): boolean;
|
|
40
|
+
hasEntityKey(): boolean;
|
|
40
41
|
clearKey(): void | undefined;
|
|
41
42
|
asModel<M extends ODataModel<T>>(entity?: Partial<T> | {
|
|
42
43
|
[name: string]: any;
|
|
@@ -76,13 +77,13 @@ export declare class ODataResource<T> {
|
|
|
76
77
|
* @param f Function context for handle the segments
|
|
77
78
|
* @returns ODataActionResource
|
|
78
79
|
*/
|
|
79
|
-
segment(f: (q: ODataPathSegmentsHandler<T>) => void): this;
|
|
80
|
+
segment(f: (q: ODataPathSegmentsHandler<T>, s?: ODataStructuredType<T>) => void): this;
|
|
80
81
|
/**
|
|
81
82
|
* Handle the query options of the resource
|
|
82
83
|
* Create an object handler for mutate the query options of the resource
|
|
83
84
|
* @param f Function context for handle the query options
|
|
84
85
|
*/
|
|
85
|
-
query(f: (q: ODataQueryOptionsHandler<T>) => void): this;
|
|
86
|
+
query(f: (q: ODataQueryOptionsHandler<T>, s?: ODataStructuredType<T>) => void): this;
|
|
86
87
|
static resolveKey<T>(value: any, schema?: ODataStructuredType<T>): EntityKey<T> | undefined;
|
|
87
88
|
protected resolveKey(value: any): EntityKey<T> | undefined;
|
|
88
89
|
protected request(method: string, options: ODataOptions & {
|
|
@@ -25,6 +25,8 @@ export declare type ODataPropertyOptions = ODataOptions & {
|
|
|
25
25
|
export declare type ODataNoneOptions = ODataOptions & {
|
|
26
26
|
responseType?: 'none';
|
|
27
27
|
};
|
|
28
|
-
export declare type ODataQueryArgumentsOptions<T> = ODataQueryArguments<T
|
|
28
|
+
export declare type ODataQueryArgumentsOptions<T> = ODataOptions & ODataQueryArguments<T>;
|
|
29
|
+
export declare type ODataActionOptions<T> = ODataQueryArgumentsOptions<T>;
|
|
30
|
+
export declare type ODataFunctionOptions<T> = ODataQueryArgumentsOptions<T> & {
|
|
29
31
|
alias?: boolean;
|
|
30
|
-
}
|
|
32
|
+
};
|