@shko.online/dataverse-odata 0.1.4 → 0.1.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/.editorconfig +8 -0
- package/.github/workflows/publish.yml +44 -0
- package/.prettierrc.json +7 -7
- package/.releaserc.yaml +23 -23
- package/CHANGELOG.md +14 -0
- package/LICENSE +21 -0
- package/azure-pipelines.yml +32 -0
- package/lib/cjs/getAliasedProperty.js +36 -0
- package/lib/cjs/getExpandFromParser.js +1 -1
- package/lib/cjs/getFilterFromParser.js +31 -0
- package/lib/cjs/getOrderByFromParser.js +41 -10
- package/lib/cjs/index.js +1 -2
- package/lib/cjs/parseOData.js +2 -1
- package/lib/cjs/validators/atMostOnce.js +6 -6
- package/lib/cjs/validators/differentFromEmptyString.js +5 -5
- package/lib/cjs/validators/hasContent.js +6 -6
- package/lib/cjs/validators/isGuid.js +5 -5
- package/lib/cjs/validators/recognizedGuid.js +5 -5
- package/lib/esm/getAliasedProperty.js +29 -0
- package/lib/esm/getExpandFromParser.js +1 -1
- package/lib/esm/getFilterFromParser.js +24 -0
- package/lib/esm/getOrderByFromParser.js +41 -10
- package/lib/esm/parseOData.js +2 -1
- package/lib/esm/validators/atMostOnce.js +6 -6
- package/lib/esm/validators/differentFromEmptyString.js +5 -5
- package/lib/esm/validators/hasContent.js +6 -6
- package/lib/esm/validators/isGuid.js +5 -5
- package/lib/esm/validators/recognizedGuid.js +5 -5
- package/lib/modern/getAliasedProperty.js +29 -0
- package/lib/modern/getExpandFromParser.js +1 -1
- package/lib/modern/getFilterFromParser.js +24 -0
- package/lib/modern/getOrderByFromParser.js +42 -11
- package/lib/modern/parseOData.js +2 -1
- package/lib/modern/validators/atMostOnce.js +6 -6
- package/lib/modern/validators/differentFromEmptyString.js +5 -5
- package/lib/modern/validators/hasContent.js +6 -6
- package/lib/modern/validators/isGuid.js +5 -5
- package/lib/modern/validators/recognizedGuid.js +5 -5
- package/lib/ts3.4/OData.types.d.ts +29 -6
- package/lib/ts3.4/getAliasedProperty.d.ts +10 -0
- package/lib/ts3.4/getFilterFromParser.d.ts +7 -0
- package/lib/ts3.4/getXQueryFromParser.d.ts +1 -1
- package/lib/ts3.4/validators/atMostOnce.d.ts +1 -1
- package/lib/ts3.9/OData.types.d.ts +141 -154
- package/lib/ts3.9/getAliasedProperty.d.ts +10 -0
- package/lib/ts3.9/getExpandFromParser.d.ts +7 -7
- package/lib/ts3.9/getFetchXmlFromParser.d.ts +7 -7
- package/lib/ts3.9/getFilterFromParser.d.ts +7 -0
- package/lib/ts3.9/getOrderByFromParser.d.ts +7 -7
- package/lib/ts3.9/getSelectFromParser.d.ts +7 -7
- package/lib/ts3.9/getTopFromParser.d.ts +7 -7
- package/lib/ts3.9/getXQueryFromParser.d.ts +8 -8
- package/lib/ts3.9/index.d.ts +11 -11
- package/lib/ts3.9/parseOData.d.ts +8 -8
- package/lib/ts3.9/validators/atMostOnce.d.ts +10 -10
- package/lib/ts3.9/validators/differentFromEmptyString.d.ts +9 -9
- package/lib/ts3.9/validators/hasContent.d.ts +10 -10
- package/lib/ts3.9/validators/isGuid.d.ts +9 -9
- package/lib/ts3.9/validators/recognizedGuid.d.ts +9 -9
- package/lib/ts4.2/OData.types.d.ts +183 -0
- package/lib/ts4.2/getAliasedProperty.d.ts +10 -0
- package/lib/ts4.2/getAliasedProperty.d.ts.map +1 -0
- package/lib/ts4.2/getExpandFromParser.d.ts +7 -0
- package/lib/{ts3.9 → ts4.2}/getExpandFromParser.d.ts.map +1 -1
- package/lib/ts4.2/getFetchXmlFromParser.d.ts +7 -0
- package/lib/{ts3.9 → ts4.2}/getFetchXmlFromParser.d.ts.map +1 -1
- package/lib/ts4.2/getFilterFromParser.d.ts +7 -0
- package/lib/ts4.2/getFilterFromParser.d.ts.map +1 -0
- package/lib/ts4.2/getOrderByFromParser.d.ts +7 -0
- package/lib/ts4.2/getOrderByFromParser.d.ts.map +1 -0
- package/lib/ts4.2/getSelectFromParser.d.ts +7 -0
- package/lib/{ts3.9 → ts4.2}/getSelectFromParser.d.ts.map +1 -1
- package/lib/ts4.2/getTopFromParser.d.ts +7 -0
- package/lib/{ts3.9 → ts4.2}/getTopFromParser.d.ts.map +1 -1
- package/lib/ts4.2/getXQueryFromParser.d.ts +8 -0
- package/lib/{ts3.9 → ts4.2}/getXQueryFromParser.d.ts.map +1 -1
- package/lib/ts4.2/index.d.ts +11 -0
- package/lib/ts4.2/parseOData.d.ts +8 -0
- package/lib/{ts3.9 → ts4.2}/parseOData.d.ts.map +1 -1
- package/lib/ts4.2/validators/atMostOnce.d.ts +10 -0
- package/lib/{ts3.9 → ts4.2}/validators/atMostOnce.d.ts.map +1 -1
- package/lib/ts4.2/validators/differentFromEmptyString.d.ts +9 -0
- package/lib/{ts3.9 → ts4.2}/validators/differentFromEmptyString.d.ts.map +1 -1
- package/lib/ts4.2/validators/hasContent.d.ts +10 -0
- package/lib/{ts3.9 → ts4.2}/validators/hasContent.d.ts.map +1 -1
- package/lib/ts4.2/validators/isGuid.d.ts +9 -0
- package/lib/{ts3.9 → ts4.2}/validators/isGuid.d.ts.map +1 -1
- package/lib/ts4.2/validators/recognizedGuid.d.ts +9 -0
- package/lib/{ts3.9 → ts4.2}/validators/recognizedGuid.d.ts.map +1 -1
- package/package.json +20 -11
- package/src/OData.types.d.ts +35 -6
- package/src/getAliasedProperty.ts +34 -0
- package/src/getExpandFromParser.ts +1 -1
- package/src/getFilterFromParser.ts +23 -0
- package/src/getOrderByFromParser.ts +46 -10
- package/src/parseOData.ts +3 -1
- package/src/validators/atMostOnce.ts +19 -19
- package/src/validators/differentFromEmptyString.ts +18 -18
- package/src/validators/hasContent.ts +19 -19
- package/src/validators/isGuid.ts +20 -20
- package/src/validators/recognizedGuid.ts +18 -18
- package/lib/ts3.9/getOrderByFromParser.d.ts.map +0 -1
- /package/lib/{ts3.9 → ts4.2}/index.d.ts.map +0 -0
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Options of this type must be specified at most once.
|
|
3
|
-
* @param option The option being validated (ex. $top)
|
|
4
|
-
* @param value The result of {@link URLSearchParams.getAll getAll}
|
|
5
|
-
* @param result The {@link ODataQuery} to append the error to
|
|
6
|
-
* @returns {boolean} Returns `false` when the parse has an error
|
|
1
|
+
/**
|
|
2
|
+
* Options of this type must be specified at most once.
|
|
3
|
+
* @param option The option being validated (ex. $top)
|
|
4
|
+
* @param value The result of {@link URLSearchParams.getAll getAll}
|
|
5
|
+
* @param result The {@link ODataQuery} to append the error to
|
|
6
|
+
* @returns {boolean} Returns `false` when the parse has an error
|
|
7
7
|
*/
|
|
8
8
|
export const hasContent = (query, value, result) => {
|
|
9
9
|
if (!value[0].trim()) {
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
const guidRegex = /[0-9A-F]{8}\-[0-9A-F]{4}-[0-9A-F]{4}-[0-9A-F]{4}-[0-9A-F]{12}/gi;
|
|
2
2
|
|
|
3
|
-
/**
|
|
4
|
-
*
|
|
5
|
-
* @param value The result of {@link URLSearchParams.getAll getAll}
|
|
6
|
-
* @param result The {@link ODataQuery} to append the error to
|
|
7
|
-
* @returns {boolean} Returns `false` when the parse has an error
|
|
3
|
+
/**
|
|
4
|
+
*
|
|
5
|
+
* @param value The result of {@link URLSearchParams.getAll getAll}
|
|
6
|
+
* @param result The {@link ODataQuery} to append the error to
|
|
7
|
+
* @returns {boolean} Returns `false` when the parse has an error
|
|
8
8
|
*/
|
|
9
9
|
export const isGuid = (value, result) => {
|
|
10
10
|
if (!value[0].match(guidRegex)) {
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
/**
|
|
2
|
-
*
|
|
3
|
-
* @param value The result of {@link URLSearchParams.getAll getAll}
|
|
4
|
-
* @param result The {@link ODataQuery} to append the error to
|
|
5
|
-
* @returns {boolean} Returns `false` when the parse has an error
|
|
1
|
+
/**
|
|
2
|
+
*
|
|
3
|
+
* @param value The result of {@link URLSearchParams.getAll getAll}
|
|
4
|
+
* @param result The {@link ODataQuery} to append the error to
|
|
5
|
+
* @returns {boolean} Returns `false` when the parse has an error
|
|
6
6
|
*/
|
|
7
7
|
export const recognizedGuid = (value, result) => {
|
|
8
8
|
if (!value[0].trim()) {
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Recursively gets the value of an aliased property. For example, if the query is `$orderby=@p1` and `@p1=name`, this function will return `name`
|
|
3
|
+
* @param parser The URLSearchParams object containing the query parameters
|
|
4
|
+
* @param result Will contain the error details in case there is any
|
|
5
|
+
* @param property The property to expand
|
|
6
|
+
* @returns The expanded property or null when there is an error
|
|
7
|
+
*/
|
|
8
|
+
export const getAliasedProperty = (parser, result, property) => {
|
|
9
|
+
let propertyName = parser.get(property);
|
|
10
|
+
if (!propertyName) {
|
|
11
|
+
result.error = {
|
|
12
|
+
code: '0x80060888',
|
|
13
|
+
message: 'Order By Property must be of type EdmProperty'
|
|
14
|
+
};
|
|
15
|
+
return null;
|
|
16
|
+
}
|
|
17
|
+
if (!/^[@a-zA-Z]\w+/gi.test(propertyName)) {
|
|
18
|
+
const position = propertyName.length;
|
|
19
|
+
result.error = {
|
|
20
|
+
code: '0x80060888',
|
|
21
|
+
message: `Syntax error at position ${position} in '${propertyName}'.`
|
|
22
|
+
};
|
|
23
|
+
return null;
|
|
24
|
+
}
|
|
25
|
+
if (propertyName.startsWith('@')) {
|
|
26
|
+
return getAliasedProperty(parser, result, propertyName);
|
|
27
|
+
}
|
|
28
|
+
return propertyName;
|
|
29
|
+
};
|
|
@@ -70,7 +70,7 @@ const extractExpand = (value, $expand) => {
|
|
|
70
70
|
$expand.$expand[match[1]] = innerExpand;
|
|
71
71
|
}
|
|
72
72
|
matchLength = matchLength + index;
|
|
73
|
-
const secondMatch =
|
|
73
|
+
const secondMatch = new RegExp(/\s*(,?)\s*d/).exec(value.substring(matchLength + 1));
|
|
74
74
|
if (secondMatch !== null) {
|
|
75
75
|
matchLength = matchLength + secondMatch[0].length;
|
|
76
76
|
if (secondMatch[1] !== null) {
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { atMostOnce } from './validators/atMostOnce';
|
|
2
|
+
const option = '$filter';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Parses the {@link ODataFilter.$filter $filter} query
|
|
6
|
+
* @returns {boolean} Returns `false` when the parse has an error
|
|
7
|
+
*/
|
|
8
|
+
export const getFilterFromParser = (parser, result) => {
|
|
9
|
+
const value = parser.getAll(option);
|
|
10
|
+
if (value.length === 0) {
|
|
11
|
+
return true;
|
|
12
|
+
}
|
|
13
|
+
if (!atMostOnce(option, value, result)) {
|
|
14
|
+
return false;
|
|
15
|
+
}
|
|
16
|
+
if (value.length > 0) {
|
|
17
|
+
result.$filter = {
|
|
18
|
+
operator: 'eq',
|
|
19
|
+
left: '',
|
|
20
|
+
right: ''
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
return true;
|
|
24
|
+
};
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
+
import "core-js/modules/esnext.string.match-all.js";
|
|
2
|
+
import { getAliasedProperty } from './getAliasedProperty';
|
|
1
3
|
import { atMostOnce } from './validators/atMostOnce';
|
|
2
4
|
import { hasContent } from './validators/hasContent';
|
|
3
5
|
const option = '$orderby';
|
|
4
|
-
const edmProperty = /\w{1-255}/gi;
|
|
5
6
|
|
|
6
7
|
/**
|
|
7
8
|
* Parses the {@link ODataOrderBy.$orderby $orderby} query
|
|
@@ -16,26 +17,56 @@ export const getOrderByFromParser = (parser, result) => {
|
|
|
16
17
|
return false;
|
|
17
18
|
}
|
|
18
19
|
let $orderby = value[0].trimEnd();
|
|
20
|
+
let $orderbyParts = $orderby.split(',');
|
|
19
21
|
const orderByArray = [];
|
|
20
|
-
|
|
21
|
-
|
|
22
|
+
let position = 0;
|
|
23
|
+
for (const element of $orderbyParts) {
|
|
24
|
+
const parts = Array.from(element.matchAll(/\s*(\S+)/gi));
|
|
25
|
+
if (parts.length > 2) {
|
|
26
|
+
position = position + parts[0][0].length + parts[1][0].length + parts[2][0].length;
|
|
22
27
|
result.error = {
|
|
23
|
-
code: '
|
|
24
|
-
message: `Syntax error at position ${
|
|
28
|
+
code: '0x80060888',
|
|
29
|
+
message: `Syntax error at position ${position} in '${$orderby}'.`
|
|
25
30
|
};
|
|
26
31
|
return false;
|
|
27
32
|
}
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
33
|
+
if (!/^[@a-zA-Z]\w+/gi.test(parts[0][1])) {
|
|
34
|
+
position = position + parts[0][0].length;
|
|
35
|
+
result.error = {
|
|
36
|
+
code: '0x80060888',
|
|
37
|
+
message: `Syntax error at position ${position} in '${$orderby}'.`
|
|
38
|
+
};
|
|
39
|
+
return false;
|
|
40
|
+
}
|
|
41
|
+
const orderBy = {
|
|
42
|
+
column: parts[0][1],
|
|
43
|
+
asc: true // default is ascending
|
|
44
|
+
};
|
|
45
|
+
if (parts[0][1].startsWith('@')) {
|
|
46
|
+
orderBy.column = getAliasedProperty(parser, result, parts[0][1]);
|
|
47
|
+
if (!orderBy.column) {
|
|
48
|
+
return false;
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
if (parts.length === 1) {
|
|
52
|
+
orderByArray.push(orderBy);
|
|
53
|
+
continue;
|
|
54
|
+
}
|
|
55
|
+
if (parts[1][1].toLowerCase() === 'asc') {
|
|
56
|
+
orderBy.asc = true;
|
|
57
|
+
orderByArray.push(orderBy);
|
|
58
|
+
} else if (parts[1][1].toLowerCase() === 'desc') {
|
|
59
|
+
orderBy.asc = false;
|
|
60
|
+
orderByArray.push(orderBy);
|
|
61
|
+
} else {
|
|
62
|
+
position = position + parts[0][0].length + parts[1][0].length;
|
|
32
63
|
result.error = {
|
|
33
64
|
code: '0x80060888',
|
|
34
|
-
message:
|
|
65
|
+
message: `Syntax error at position ${position} in '${$orderby}'.`
|
|
35
66
|
};
|
|
36
67
|
return false;
|
|
37
68
|
}
|
|
38
|
-
}
|
|
69
|
+
}
|
|
39
70
|
result.$orderby = orderByArray;
|
|
40
71
|
return true;
|
|
41
72
|
};
|
package/lib/modern/parseOData.js
CHANGED
|
@@ -4,6 +4,7 @@ import { getExpandFromParser } from './getExpandFromParser';
|
|
|
4
4
|
import { getFetchXmlFromParser } from './getFetchXmlFromParser';
|
|
5
5
|
import { getXQueryFromParser } from './getXQueryFromParser';
|
|
6
6
|
import { getOrderByFromParser } from './getOrderByFromParser';
|
|
7
|
+
import { getFilterFromParser } from './getFilterFromParser';
|
|
7
8
|
|
|
8
9
|
/**
|
|
9
10
|
* parses the OData query and applies some Dataverse validations
|
|
@@ -13,6 +14,6 @@ import { getOrderByFromParser } from './getOrderByFromParser';
|
|
|
13
14
|
export const parseOData = query => {
|
|
14
15
|
const parser = new URLSearchParams(query);
|
|
15
16
|
const result = {};
|
|
16
|
-
getExpandFromParser(parser, result) &&
|
|
17
|
+
getExpandFromParser(parser, result) && getFetchXmlFromParser(parser, result) && getFilterFromParser(parser, result) && getSelectFromParser(parser, result) && getTopFromParser(parser, result) && getXQueryFromParser('savedQuery', parser, result) && getXQueryFromParser('userQuery', parser, result) && getOrderByFromParser(parser, result);
|
|
17
18
|
return result;
|
|
18
19
|
};
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Options of this type must be specified at most once.
|
|
3
|
-
* @param option The option being validated (ex. $top)
|
|
4
|
-
* @param value The result of {@link URLSearchParams.getAll getAll}
|
|
5
|
-
* @param result The {@link ODataQuery} to append the error to
|
|
6
|
-
* @returns {boolean} Returns `false` when the parse has an error
|
|
1
|
+
/**
|
|
2
|
+
* Options of this type must be specified at most once.
|
|
3
|
+
* @param option The option being validated (ex. $top)
|
|
4
|
+
* @param value The result of {@link URLSearchParams.prototype.getAll URLSearchParams.getAll}
|
|
5
|
+
* @param result The {@link ODataQuery} to append the error to
|
|
6
|
+
* @returns {boolean} Returns `false` when the parse has an error
|
|
7
7
|
*/
|
|
8
8
|
export const atMostOnce = (option, value, result) => {
|
|
9
9
|
if (value.length > 1) {
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
/**
|
|
2
|
-
*
|
|
3
|
-
* @param value The result of {@link URLSearchParams.getAll getAll}
|
|
4
|
-
* @param result The {@link ODataQuery} to append the error to
|
|
5
|
-
* @returns {boolean} Returns `false` when the parse has an error
|
|
1
|
+
/**
|
|
2
|
+
*
|
|
3
|
+
* @param value The result of {@link URLSearchParams.getAll getAll}
|
|
4
|
+
* @param result The {@link ODataQuery} to append the error to
|
|
5
|
+
* @returns {boolean} Returns `false` when the parse has an error
|
|
6
6
|
*/
|
|
7
7
|
export const differentFromEmptyString = (value, result) => {
|
|
8
8
|
if (value[0] === '') {
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Options of this type must be specified at most once.
|
|
3
|
-
* @param option The option being validated (ex. $top)
|
|
4
|
-
* @param value The result of {@link URLSearchParams.getAll getAll}
|
|
5
|
-
* @param result The {@link ODataQuery} to append the error to
|
|
6
|
-
* @returns {boolean} Returns `false` when the parse has an error
|
|
1
|
+
/**
|
|
2
|
+
* Options of this type must be specified at most once.
|
|
3
|
+
* @param option The option being validated (ex. $top)
|
|
4
|
+
* @param value The result of {@link URLSearchParams.getAll getAll}
|
|
5
|
+
* @param result The {@link ODataQuery} to append the error to
|
|
6
|
+
* @returns {boolean} Returns `false` when the parse has an error
|
|
7
7
|
*/
|
|
8
8
|
export const hasContent = (query, value, result) => {
|
|
9
9
|
if (!value[0].trim()) {
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
const guidRegex = /[0-9A-F]{8}\-[0-9A-F]{4}-[0-9A-F]{4}-[0-9A-F]{4}-[0-9A-F]{12}/gi;
|
|
2
2
|
|
|
3
|
-
/**
|
|
4
|
-
*
|
|
5
|
-
* @param value The result of {@link URLSearchParams.getAll getAll}
|
|
6
|
-
* @param result The {@link ODataQuery} to append the error to
|
|
7
|
-
* @returns {boolean} Returns `false` when the parse has an error
|
|
3
|
+
/**
|
|
4
|
+
*
|
|
5
|
+
* @param value The result of {@link URLSearchParams.getAll getAll}
|
|
6
|
+
* @param result The {@link ODataQuery} to append the error to
|
|
7
|
+
* @returns {boolean} Returns `false` when the parse has an error
|
|
8
8
|
*/
|
|
9
9
|
export const isGuid = (value, result) => {
|
|
10
10
|
if (!value[0].match(guidRegex)) {
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
/**
|
|
2
|
-
*
|
|
3
|
-
* @param value The result of {@link URLSearchParams.getAll getAll}
|
|
4
|
-
* @param result The {@link ODataQuery} to append the error to
|
|
5
|
-
* @returns {boolean} Returns `false` when the parse has an error
|
|
1
|
+
/**
|
|
2
|
+
*
|
|
3
|
+
* @param value The result of {@link URLSearchParams.getAll getAll}
|
|
4
|
+
* @param result The {@link ODataQuery} to append the error to
|
|
5
|
+
* @returns {boolean} Returns `false` when the parse has an error
|
|
6
6
|
*/
|
|
7
7
|
export const recognizedGuid = (value, result) => {
|
|
8
8
|
if (!value[0].trim()) {
|
|
@@ -27,12 +27,13 @@ interface ODataExpand {
|
|
|
27
27
|
type ODataExpandQuery = ODataSelect & ODataExpand;
|
|
28
28
|
interface ODataFilter {
|
|
29
29
|
/**
|
|
30
|
-
* Use the {@link
|
|
30
|
+
* Use the {@link $filter $filter} system query option to set criteria for which rows will be returned.
|
|
31
31
|
*
|
|
32
32
|
* * Microsoft Docs: {@link https://learn.microsoft.com/power-apps/developer/data-platform/webapi/query-data-web-api?WT.mc_id=DX-MVP-5004767#filter-results Filter results }
|
|
33
33
|
*/
|
|
34
|
-
$filter?:
|
|
34
|
+
$filter?: FilterOperator;
|
|
35
35
|
}
|
|
36
|
+
type FilterOperator = StandardOperator | ColumnOperator | UnaryOperator | BinaryOperator | QueryFunctionOperator;
|
|
36
37
|
interface ODataFetch {
|
|
37
38
|
/**
|
|
38
39
|
* You can compose a FetchXML query for a specific table.
|
|
@@ -93,7 +94,17 @@ interface ODataUserQuery {
|
|
|
93
94
|
*/
|
|
94
95
|
userQuery?: string;
|
|
95
96
|
}
|
|
96
|
-
type
|
|
97
|
+
type StandardEqualityOperators = 'eq' | 'ne';
|
|
98
|
+
type StandardOperators = StandardEqualityOperators | 'gt' | 'ge' | 'lt' | 'le';
|
|
99
|
+
/**
|
|
100
|
+
*
|
|
101
|
+
* * Microsoft Docs: {@link https://learn.microsoft.com/en-us/power-apps/developer/data-platform/webapi/query/filter-rows#column-comparison Column comparison }
|
|
102
|
+
*/
|
|
103
|
+
interface ColumnOperator {
|
|
104
|
+
column: string;
|
|
105
|
+
operator: StandardOperators;
|
|
106
|
+
otherColumn: string;
|
|
107
|
+
}
|
|
97
108
|
interface StandardOperator {
|
|
98
109
|
operator: StandardOperators;
|
|
99
110
|
/**
|
|
@@ -105,14 +116,26 @@ interface StandardOperator {
|
|
|
105
116
|
*/
|
|
106
117
|
right: string | number;
|
|
107
118
|
}
|
|
119
|
+
type QueryFunctionOperators = 'contains' | 'endswith' | 'startswith';
|
|
120
|
+
interface QueryFunctionOperator {
|
|
121
|
+
operator: QueryFunctionOperators;
|
|
122
|
+
/**
|
|
123
|
+
* The left side of the 'X' operator must be a property of the entity.
|
|
124
|
+
*/
|
|
125
|
+
left: string;
|
|
126
|
+
/**
|
|
127
|
+
* The right side of the 'X' operator must be a constant value.
|
|
128
|
+
*/
|
|
129
|
+
right: string;
|
|
130
|
+
}
|
|
108
131
|
interface UnaryOperator {
|
|
109
132
|
operator: 'not';
|
|
110
|
-
right:
|
|
133
|
+
right: FilterOperator;
|
|
111
134
|
}
|
|
112
135
|
interface BinaryOperator {
|
|
113
136
|
operator: 'and' | 'or';
|
|
114
|
-
left:
|
|
115
|
-
right:
|
|
137
|
+
left: FilterOperator;
|
|
138
|
+
right: FilterOperator;
|
|
116
139
|
}
|
|
117
140
|
type ODataQuery = ODataError & ODataExpand & ODataFetch & ODataFilter & ODataOrderBy & ODataSavedQuery & ODataSelect & ODataTop & ODataUserQuery;
|
|
118
141
|
export { BinaryOperator, ODataError, ODataExpand, ODataExpandQuery, ODataFetch, ODataFilter, ODataOrderBy, ODataQuery, ODataSavedQuery, ODataSelect, ODataTop, ODataUserQuery, StandardOperator, StandardOperators, UnaryOperator, };
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { ODataQuery } from "./OData.types";
|
|
2
|
+
/**
|
|
3
|
+
* Recursively gets the value of an aliased property. For example, if the query is `$orderby=@p1` and `@p1=name`, this function will return `name`
|
|
4
|
+
* @param parser The URLSearchParams object containing the query parameters
|
|
5
|
+
* @param result Will contain the error details in case there is any
|
|
6
|
+
* @param property The property to expand
|
|
7
|
+
* @returns The expanded property or null when there is an error
|
|
8
|
+
*/
|
|
9
|
+
export declare const getAliasedProperty: (parser: URLSearchParams, result: ODataQuery, property: string) => string;
|
|
10
|
+
//# sourceMappingURL=getAliasedProperty.d.ts.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { ODataQuery } from './OData.types';
|
|
2
|
+
/**
|
|
3
|
+
* Parses the {@link ODataFilter.$filter $filter} query
|
|
4
|
+
* @returns {boolean} Returns `false` when the parse has an error
|
|
5
|
+
*/
|
|
6
|
+
export declare const getFilterFromParser: (parser: URLSearchParams, result: ODataQuery) => boolean;
|
|
7
|
+
//# sourceMappingURL=getFilterFromParser.d.ts.map
|
|
@@ -4,5 +4,5 @@ import { ODataQuery } from './OData.types';
|
|
|
4
4
|
* {@link ODataUserQuery.userQuery userQuery} query
|
|
5
5
|
* @returns Returns `false` when the parse has an error
|
|
6
6
|
*/
|
|
7
|
-
export declare const getXQueryFromParser: (X:
|
|
7
|
+
export declare const getXQueryFromParser: (X: "savedQuery" | "userQuery", parser: URLSearchParams, result: ODataQuery) => boolean;
|
|
8
8
|
//# sourceMappingURL=getXQueryFromParser.d.ts.map
|
|
@@ -2,7 +2,7 @@ import { ODataQuery } from '../OData.types';
|
|
|
2
2
|
/**
|
|
3
3
|
* Options of this type must be specified at most once.
|
|
4
4
|
* @param option The option being validated (ex. $top)
|
|
5
|
-
* @param value The result of {@link URLSearchParams.getAll getAll}
|
|
5
|
+
* @param value The result of {@link URLSearchParams.prototype.getAll URLSearchParams.getAll}
|
|
6
6
|
* @param result The {@link ODataQuery} to append the error to
|
|
7
7
|
* @returns {boolean} Returns `false` when the parse has an error
|
|
8
8
|
*/
|