-
Notifications
You must be signed in to change notification settings - Fork 46
/
Copy pathodata-uri.ts
46 lines (43 loc) · 1.58 KB
/
odata-uri.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
/* Copyright (c) 2020 SAP SE or an SAP affiliate company. All rights reserved. */
import { Selectable, FieldType } from '../selectable';
import { Expandable } from '../expandable';
import { EntityBase, Constructable } from '../entity';
import { Filterable } from '../filter';
import { Orderable } from '../order';
import { EdmTypeShared } from '../edm-types';
/**
* Union of necessary methods for the OData URI conversion.
* In v2/uri-conversion/odata-uri.ts and v4/uri-conversion/odata-uri.ts the instance for v2 and v4 are created.
*/
export interface ODataUri {
getExpand<EntityT extends EntityBase>(
selects: Selectable<EntityT>[],
expands: Expandable<EntityT>[],
entityConstructor: Constructable<EntityT>
): Partial<{ expand: string }>;
getFilter<EntityT extends EntityBase>(
filter: Filterable<EntityT>,
entityConstructor: Constructable<EntityT>
): Partial<{ filter: string }>;
getEntityKeys<EntityT extends EntityBase>(
entity: EntityT,
entityConstructor: Constructable<EntityT>
): Record<string, any>;
getOrderBy<EntityT extends EntityBase>(
orderBy: Orderable<EntityT>[]
): Partial<{ orderby: string }>;
getResourcePathForKeys<EntityT extends EntityBase>(
keys: Record<string, FieldType>,
entityConstructor: Constructable<EntityT>
): string;
getSelect<EntityT extends EntityBase>(
selects: Selectable<EntityT>[]
): Partial<{ select: string }>;
convertToUriFormat(
value: any,
edmType: EdmTypeShared<'v2'> | EdmTypeShared<'v4'>
): string;
}
export function prependDollar(param: string): string {
return `$${param}`;
}