@shko.online/dataverse-odata 0.1.1 → 0.1.3

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.
Files changed (98) hide show
  1. package/.eslintrc.json +59 -0
  2. package/.prettierrc.json +8 -0
  3. package/CHANGELOG.md +14 -0
  4. package/lib/cjs/getExpandFromParser.js +15 -15
  5. package/lib/cjs/getFetchXmlFromParser.js +13 -6
  6. package/lib/cjs/getOrderByFromParser.js +44 -0
  7. package/lib/cjs/getSelectFromParser.js +3 -3
  8. package/lib/cjs/getTopFromParser.js +9 -5
  9. package/lib/cjs/getXQueryFromParser.js +35 -0
  10. package/lib/cjs/index.js +42 -0
  11. package/lib/cjs/parseOData.js +11 -4
  12. package/lib/cjs/validateNotEmpty.js +17 -0
  13. package/lib/esm/getExpandFromParser.js +15 -15
  14. package/lib/esm/getFetchXmlFromParser.js +13 -6
  15. package/lib/esm/getOrderByFromParser.js +37 -0
  16. package/lib/esm/getSelectFromParser.js +3 -3
  17. package/lib/esm/getTopFromParser.js +10 -5
  18. package/lib/esm/getXQueryFromParser.js +28 -0
  19. package/lib/esm/index.js +6 -0
  20. package/lib/esm/parseOData.js +11 -4
  21. package/lib/esm/validateNotEmpty.js +10 -0
  22. package/lib/modern/getExpandFromParser.js +15 -15
  23. package/lib/modern/getFetchXmlFromParser.js +13 -6
  24. package/lib/modern/getOrderByFromParser.js +38 -0
  25. package/lib/modern/getSelectFromParser.js +3 -3
  26. package/lib/modern/getTopFromParser.js +10 -5
  27. package/lib/modern/getXQueryFromParser.js +28 -0
  28. package/lib/modern/index.js +6 -0
  29. package/lib/modern/parseOData.js +11 -4
  30. package/lib/modern/validateNotEmpty.js +10 -0
  31. package/lib/ts3.4/OData.types.d.ts +118 -0
  32. package/lib/ts3.4/getExpandFromParser.d.ts +2 -2
  33. package/lib/ts3.4/getFetchXmlFromParser.d.ts +2 -2
  34. package/lib/ts3.4/getOrderByFromParser.d.ts +7 -0
  35. package/lib/ts3.4/getSelectFromParser.d.ts +2 -2
  36. package/lib/ts3.4/getTopFromParser.d.ts +2 -2
  37. package/lib/ts3.4/getXQueryFromParser.d.ts +8 -0
  38. package/lib/ts3.4/index.d.ts +6 -0
  39. package/lib/ts3.4/validateNotEmpty.d.ts +3 -0
  40. package/lib/ts3.9/OData.types.d.ts +154 -0
  41. package/lib/ts3.9/getExpandFromParser.d.ts +2 -2
  42. package/lib/ts3.9/getFetchXmlFromParser.d.ts +2 -2
  43. package/lib/ts3.9/getFetchXmlFromParser.d.ts.map +1 -1
  44. package/lib/ts3.9/getOrderByFromParser.d.ts +7 -0
  45. package/lib/ts3.9/getOrderByFromParser.d.ts.map +1 -0
  46. package/lib/ts3.9/getSelectFromParser.d.ts +2 -2
  47. package/lib/ts3.9/getSelectFromParser.d.ts.map +1 -1
  48. package/lib/ts3.9/getTopFromParser.d.ts +2 -2
  49. package/lib/ts3.9/getTopFromParser.d.ts.map +1 -1
  50. package/lib/ts3.9/getXQueryFromParser.d.ts +8 -0
  51. package/lib/ts3.9/getXQueryFromParser.d.ts.map +1 -0
  52. package/lib/ts3.9/index.d.ts +6 -0
  53. package/lib/ts3.9/index.d.ts.map +1 -1
  54. package/lib/ts3.9/parseOData.d.ts.map +1 -1
  55. package/lib/ts3.9/validateNotEmpty.d.ts +3 -0
  56. package/lib/ts3.9/validateNotEmpty.d.ts.map +1 -0
  57. package/package.json +1 -1
  58. package/src/OData.types.d.ts +107 -14
  59. package/src/getExpandFromParser.ts +15 -15
  60. package/src/getFetchXmlFromParser.ts +15 -7
  61. package/src/getOrderByFromParser.ts +42 -0
  62. package/src/getSelectFromParser.ts +4 -4
  63. package/src/getTopFromParser.ts +11 -7
  64. package/src/getXQueryFromParser.ts +34 -0
  65. package/src/index.ts +7 -0
  66. package/src/parseOData.ts +11 -4
  67. package/src/validateNotEmpty.ts +12 -0
  68. package/tsconfig.build.json +3 -0
  69. package/tsconfig.json +2 -5
  70. package/jest.config.ts +0 -12
  71. package/lib/getExpandFromParser.d.ts +0 -7
  72. package/lib/getExpandFromParser.d.ts.map +0 -1
  73. package/lib/getExpandFromParser.js +0 -97
  74. package/lib/getExpandFromParser.js.map +0 -1
  75. package/lib/getFetchXmlFromParser.d.ts +0 -7
  76. package/lib/getFetchXmlFromParser.d.ts.map +0 -1
  77. package/lib/getFetchXmlFromParser.js +0 -41
  78. package/lib/getFetchXmlFromParser.js.map +0 -1
  79. package/lib/getSelectFromParser.d.ts +0 -7
  80. package/lib/getSelectFromParser.d.ts.map +0 -1
  81. package/lib/getSelectFromParser.js +0 -12
  82. package/lib/getSelectFromParser.js.map +0 -1
  83. package/lib/getTopFromParser.d.ts +0 -7
  84. package/lib/getTopFromParser.d.ts.map +0 -1
  85. package/lib/getTopFromParser.js +0 -27
  86. package/lib/getTopFromParser.js.map +0 -1
  87. package/lib/index.d.ts +0 -5
  88. package/lib/index.d.ts.map +0 -1
  89. package/lib/index.js +0 -4
  90. package/lib/index.js.map +0 -1
  91. package/lib/parseOData.d.ts +0 -3
  92. package/lib/parseOData.d.ts.map +0 -1
  93. package/lib/parseOData.js +0 -22
  94. package/lib/parseOData.js.map +0 -1
  95. package/tests/OData-Parser.$expand.test.ts +0 -39
  96. package/tests/OData-Parser.$top.test.ts +0 -36
  97. package/tests/OData-Parser.fetchXml.test.ts +0 -62
  98. package/tests/OData-Parser.test.ts +0 -17
@@ -1,25 +1,30 @@
1
+ import { validateNotEmpty } from './validateNotEmpty';
2
+
1
3
  /**
2
- * Parses the $top query
3
- * @returns Returns true when the parse has an error
4
+ * Parses the {@link ODataTop.$top $top} query
5
+ * @returns Returns `false` when the parse has an error
4
6
  */
5
7
  export const getTopFromParser = (parser, result) => {
6
8
  const $topValue = parser.get('$top');
7
9
  if ($topValue !== null) {
10
+ if (!validateNotEmpty('$orderby', $topValue, result)) {
11
+ return false;
12
+ }
8
13
  let $top;
9
14
  if (!$topValue.match(/^\d+$/) || ($top = parseInt($topValue)) < 0) {
10
15
  result.error = {
11
16
  code: '0x0',
12
17
  message: `Invalid value '${$topValue}' for $top query option found. The $top query option requires a non-negative integer value.`
13
18
  };
14
- return true;
19
+ return false;
15
20
  } else if ($top === 0) {
16
21
  result.error = {
17
22
  code: '0x0',
18
23
  message: `Invalid value for $top query option.`
19
24
  };
20
- return true;
25
+ return false;
21
26
  }
22
27
  result.$top = $top;
23
28
  }
24
- return false;
29
+ return true;
25
30
  };
@@ -0,0 +1,28 @@
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
+
3
+ /**
4
+ * Parses the {@link ODataSavedQuery.savedQuery savedQuery} or
5
+ * {@link ODataUserQuery.userQuery userQuery} query
6
+ * @returns Returns `false` when the parse has an error
7
+ */
8
+ export const getXQueryFromParser = (X, parser, result) => {
9
+ const xQuery = parser.get(X);
10
+ if (xQuery !== null) {
11
+ if (!xQuery.trim()) {
12
+ result.error = {
13
+ code: '0x0',
14
+ message: 'Unrecognized Guid format.'
15
+ };
16
+ return false;
17
+ }
18
+ if (!xQuery.match(guidRegex)) {
19
+ result.error = {
20
+ code: '0x0',
21
+ message: 'Guid should contain 32 digits with 4 dashes (xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx).'
22
+ };
23
+ return false;
24
+ }
25
+ result[X] = xQuery;
26
+ }
27
+ return true;
28
+ };
package/lib/esm/index.js CHANGED
@@ -1,3 +1,9 @@
1
+ export { getExpandFromParser } from './getExpandFromParser';
2
+ export { getFetchXmlFromParser } from './getFetchXmlFromParser';
3
+ export { getOrderByFromParser } from './getOrderByFromParser';
4
+ export { getSelectFromParser } from './getSelectFromParser';
5
+ export { getTopFromParser } from './getTopFromParser';
6
+ export { getXQueryFromParser } from './getXQueryFromParser';
1
7
  export { parseOData } from './parseOData';
2
8
  import { parseOData } from './parseOData';
3
9
  export default parseOData;
@@ -2,6 +2,7 @@ import { getTopFromParser } from './getTopFromParser';
2
2
  import { getSelectFromParser } from './getSelectFromParser';
3
3
  import { getExpandFromParser } from './getExpandFromParser';
4
4
  import { getFetchXmlFromParser } from './getFetchXmlFromParser';
5
+ import { getXQueryFromParser } from './getXQueryFromParser';
5
6
 
6
7
  /**
7
8
  * parses the OData query and applies some Dataverse validations
@@ -11,16 +12,22 @@ import { getFetchXmlFromParser } from './getFetchXmlFromParser';
11
12
  export const parseOData = query => {
12
13
  const parser = new URLSearchParams(query);
13
14
  const result = {};
14
- if (getExpandFromParser(parser, result)) {
15
+ if (!getExpandFromParser(parser, result)) {
15
16
  return result;
16
17
  }
17
- if (getSelectFromParser(parser, result)) {
18
+ if (!getSelectFromParser(parser, result)) {
18
19
  return result;
19
20
  }
20
- if (getTopFromParser(parser, result)) {
21
+ if (!getTopFromParser(parser, result)) {
21
22
  return result;
22
23
  }
23
- if (getFetchXmlFromParser(parser, result)) {
24
+ if (!getFetchXmlFromParser(parser, result)) {
25
+ return result;
26
+ }
27
+ if (!getXQueryFromParser('savedQuery', parser, result)) {
28
+ return result;
29
+ }
30
+ if (!getXQueryFromParser('userQuery', parser, result)) {
24
31
  return result;
25
32
  }
26
33
  return result;
@@ -0,0 +1,10 @@
1
+ export const validateNotEmpty = (query, value, result) => {
2
+ if (!value.trim()) {
3
+ result.error = {
4
+ code: '0x0',
5
+ message: `The value for OData query '${query}' cannot be empty.`
6
+ };
7
+ return false;
8
+ }
9
+ return true;
10
+ };
@@ -1,18 +1,18 @@
1
1
  import { getSelectFromParser } from './getSelectFromParser';
2
2
 
3
3
  /**
4
- * Parses the $expand query
5
- * @returns Returns true when the parse has an error
4
+ * Parses the {@link ODataExpand.$expand $expand} query
5
+ * @returns Returns `false` when the parse has an error
6
6
  */
7
7
  export const getExpandFromParser = (parser, result) => {
8
8
  const $expand = parser.get('$expand');
9
9
  if ($expand !== null) {
10
10
  result.$expand = {};
11
- if (extractExpand($expand, result)) {
12
- return true;
11
+ if (!extractExpand($expand, result)) {
12
+ return false;
13
13
  }
14
14
  }
15
- return false;
15
+ return true;
16
16
  };
17
17
  const extractExpand = (value, $expand) => {
18
18
  const match = value.match(/^\s*(\w(\w|\d|_)*)\s*(,|\()?\s*/);
@@ -21,7 +21,7 @@ const extractExpand = (value, $expand) => {
21
21
  code: '0x0',
22
22
  message: 'invalid expand expression'
23
23
  };
24
- return true;
24
+ return false;
25
25
  }
26
26
  let matchSeparator = match[3];
27
27
  let matchLength = match[0].length;
@@ -41,25 +41,25 @@ const extractExpand = (value, $expand) => {
41
41
  code: '0x0',
42
42
  message: error
43
43
  };
44
- return true;
44
+ return false;
45
45
  }
46
46
  if ($expand.$expand !== undefined) {
47
47
  const innerExpand = {};
48
48
  const parser = new URLSearchParams('?' + value.substring(matchLength, matchLength + index));
49
- if (getSelectFromParser(parser, innerExpand)) {
49
+ if (!getSelectFromParser(parser, innerExpand)) {
50
50
  $expand.error = innerExpand.error;
51
- return true;
51
+ return false;
52
52
  }
53
- if (getExpandFromParser(parser, innerExpand)) {
53
+ if (!getExpandFromParser(parser, innerExpand)) {
54
54
  $expand.error = innerExpand.error;
55
- return true;
55
+ return false;
56
56
  }
57
57
  if (innerExpand.$expand === undefined && innerExpand.$select === undefined) {
58
58
  $expand.error = {
59
59
  code: '0x0',
60
60
  message: 'Empty expand'
61
61
  };
62
- return true;
62
+ return false;
63
63
  }
64
64
  $expand.$expand[match[1]] = innerExpand;
65
65
  }
@@ -73,11 +73,11 @@ const extractExpand = (value, $expand) => {
73
73
  }
74
74
  }
75
75
  if (matchSeparator === ',') {
76
- if (extractExpand(value.substring(matchLength), $expand)) {
77
- return true;
76
+ if (!extractExpand(value.substring(matchLength), $expand)) {
77
+ return false;
78
78
  }
79
79
  }
80
- return false;
80
+ return true;
81
81
  };
82
82
  const getClosingBracket = value => {
83
83
  let depth = 1;
@@ -1,10 +1,17 @@
1
1
  /**
2
- * Parses the fetchXml query
3
- * @returns Returns true when the parse has an error
2
+ * Parses the {@link ODataFetch.fetchXml fetchXml} query
3
+ * @returns Returns `false` when the parse has an error
4
4
  */
5
5
  export const getFetchXmlFromParser = (parser, result) => {
6
6
  const fetchXml = parser.get('fetchXml');
7
7
  if (fetchXml !== null) {
8
+ if (fetchXml === '') {
9
+ result.error = {
10
+ code: '0x80040203',
11
+ message: 'Expected non-empty string.'
12
+ };
13
+ return false;
14
+ }
8
15
  const serializer = new DOMParser();
9
16
  const fetchXmlDocument = serializer.parseFromString(fetchXml, 'text/xml');
10
17
  if (fetchXmlDocument.documentElement.tagName === 'parsererror') {
@@ -12,7 +19,7 @@ export const getFetchXmlFromParser = (parser, result) => {
12
19
  code: '0x80040201',
13
20
  message: 'Invalid XML.'
14
21
  };
15
- return true;
22
+ return false;
16
23
  }
17
24
  const entity = fetchXmlDocument.evaluate('fetch/entity', fetchXmlDocument, null, XPathResult.ANY_TYPE, null).iterateNext();
18
25
  if (fetchXmlDocument.documentElement.children.length != 1 || !entity || !entity.getAttribute('name')) {
@@ -20,7 +27,7 @@ export const getFetchXmlFromParser = (parser, result) => {
20
27
  code: '0x80041102',
21
28
  message: 'Entity Name was not specified in FetchXml String.'
22
29
  };
23
- return true;
30
+ return false;
24
31
  }
25
32
  const invalidAttribute = fetchXmlDocument.evaluate('fetch/entity/*[not(self::filter or self::order or self::link-entity or self::attribute or self::all-attributes or self::no-attrs)]', fetchXmlDocument, null, XPathResult.ANY_TYPE, null).iterateNext();
26
33
  if (invalidAttribute) {
@@ -28,9 +35,9 @@ export const getFetchXmlFromParser = (parser, result) => {
28
35
  code: '0x8004111c',
29
36
  message: `Invalid Child Node, valid nodes are filter, order, link-entity, attribute, all-attributes, no-attrs. NodeName = ${invalidAttribute.tagName} NodeXml = ${invalidAttribute.outerHTML}`
30
37
  };
31
- return true;
38
+ return false;
32
39
  }
33
40
  result.fetchXml = fetchXmlDocument;
34
41
  }
35
- return false;
42
+ return true;
36
43
  };
@@ -0,0 +1,38 @@
1
+ import { validateNotEmpty } from './validateNotEmpty';
2
+ const edmProperty = /\w{1-255}/gi;
3
+
4
+ /**
5
+ * Parses the {@link ODataOrderBy.$orderby $orderby} query
6
+ * @returns Returns `false` when the parse has an error
7
+ */
8
+ export const getOrderByFromParser = (parser, result) => {
9
+ let $orderby = parser.get('$orderby');
10
+ if ($orderby !== null) {
11
+ if (!validateNotEmpty('$orderby', $orderby, result)) {
12
+ return false;
13
+ }
14
+ $orderby = $orderby.trimEnd();
15
+ const orderByArray = [];
16
+ for (let i = 0; i < $orderby.length; i++) {
17
+ if (false /* syntax error */) {
18
+ result.error = {
19
+ code: '0x0',
20
+ message: `Syntax error at position ${i} in '${$orderby}'.`
21
+ };
22
+ return false;
23
+ }
24
+ }
25
+ orderByArray.forEach(orderBy => {
26
+ var _orderBy$column;
27
+ if (!((_orderBy$column = orderBy.column) !== null && _orderBy$column !== void 0 && _orderBy$column.match(edmProperty))) {
28
+ result.error = {
29
+ code: '0x80060888',
30
+ message: 'Order By Property must be of type EdmProperty'
31
+ };
32
+ return false;
33
+ }
34
+ });
35
+ result.$orderby = orderByArray;
36
+ }
37
+ return true;
38
+ };
@@ -1,11 +1,11 @@
1
1
  /**
2
- * Parses the $select query
3
- * @returns Returns true when the parse has an error
2
+ * Parses the {@link ODataSelect.$select $select} query
3
+ * @returns Returns `false` when the parse has an error
4
4
  */
5
5
  export const getSelectFromParser = (parser, result) => {
6
6
  const $select = parser.get('$select');
7
7
  if ($select !== null) {
8
8
  result.$select = $select.split(',');
9
9
  }
10
- return false;
10
+ return true;
11
11
  };
@@ -1,25 +1,30 @@
1
+ import { validateNotEmpty } from './validateNotEmpty';
2
+
1
3
  /**
2
- * Parses the $top query
3
- * @returns Returns true when the parse has an error
4
+ * Parses the {@link ODataTop.$top $top} query
5
+ * @returns Returns `false` when the parse has an error
4
6
  */
5
7
  export const getTopFromParser = (parser, result) => {
6
8
  const $topValue = parser.get('$top');
7
9
  if ($topValue !== null) {
10
+ if (!validateNotEmpty('$orderby', $topValue, result)) {
11
+ return false;
12
+ }
8
13
  let $top;
9
14
  if (!$topValue.match(/^\d+$/) || ($top = parseInt($topValue)) < 0) {
10
15
  result.error = {
11
16
  code: '0x0',
12
17
  message: `Invalid value '${$topValue}' for $top query option found. The $top query option requires a non-negative integer value.`
13
18
  };
14
- return true;
19
+ return false;
15
20
  } else if ($top === 0) {
16
21
  result.error = {
17
22
  code: '0x0',
18
23
  message: `Invalid value for $top query option.`
19
24
  };
20
- return true;
25
+ return false;
21
26
  }
22
27
  result.$top = $top;
23
28
  }
24
- return false;
29
+ return true;
25
30
  };
@@ -0,0 +1,28 @@
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
+
3
+ /**
4
+ * Parses the {@link ODataSavedQuery.savedQuery savedQuery} or
5
+ * {@link ODataUserQuery.userQuery userQuery} query
6
+ * @returns Returns `false` when the parse has an error
7
+ */
8
+ export const getXQueryFromParser = (X, parser, result) => {
9
+ const xQuery = parser.get(X);
10
+ if (xQuery !== null) {
11
+ if (!xQuery.trim()) {
12
+ result.error = {
13
+ code: '0x0',
14
+ message: 'Unrecognized Guid format.'
15
+ };
16
+ return false;
17
+ }
18
+ if (!xQuery.match(guidRegex)) {
19
+ result.error = {
20
+ code: '0x0',
21
+ message: 'Guid should contain 32 digits with 4 dashes (xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx).'
22
+ };
23
+ return false;
24
+ }
25
+ result[X] = xQuery;
26
+ }
27
+ return true;
28
+ };
@@ -1,3 +1,9 @@
1
+ export { getExpandFromParser } from './getExpandFromParser';
2
+ export { getFetchXmlFromParser } from './getFetchXmlFromParser';
3
+ export { getOrderByFromParser } from './getOrderByFromParser';
4
+ export { getSelectFromParser } from './getSelectFromParser';
5
+ export { getTopFromParser } from './getTopFromParser';
6
+ export { getXQueryFromParser } from './getXQueryFromParser';
1
7
  export { parseOData } from './parseOData';
2
8
  import { parseOData } from './parseOData';
3
9
  export default parseOData;
@@ -2,6 +2,7 @@ import { getTopFromParser } from './getTopFromParser';
2
2
  import { getSelectFromParser } from './getSelectFromParser';
3
3
  import { getExpandFromParser } from './getExpandFromParser';
4
4
  import { getFetchXmlFromParser } from './getFetchXmlFromParser';
5
+ import { getXQueryFromParser } from './getXQueryFromParser';
5
6
 
6
7
  /**
7
8
  * parses the OData query and applies some Dataverse validations
@@ -11,16 +12,22 @@ import { getFetchXmlFromParser } from './getFetchXmlFromParser';
11
12
  export const parseOData = query => {
12
13
  const parser = new URLSearchParams(query);
13
14
  const result = {};
14
- if (getExpandFromParser(parser, result)) {
15
+ if (!getExpandFromParser(parser, result)) {
15
16
  return result;
16
17
  }
17
- if (getSelectFromParser(parser, result)) {
18
+ if (!getSelectFromParser(parser, result)) {
18
19
  return result;
19
20
  }
20
- if (getTopFromParser(parser, result)) {
21
+ if (!getTopFromParser(parser, result)) {
21
22
  return result;
22
23
  }
23
- if (getFetchXmlFromParser(parser, result)) {
24
+ if (!getFetchXmlFromParser(parser, result)) {
25
+ return result;
26
+ }
27
+ if (!getXQueryFromParser('savedQuery', parser, result)) {
28
+ return result;
29
+ }
30
+ if (!getXQueryFromParser('userQuery', parser, result)) {
24
31
  return result;
25
32
  }
26
33
  return result;
@@ -0,0 +1,10 @@
1
+ export const validateNotEmpty = (query, value, result) => {
2
+ if (!value.trim()) {
3
+ result.error = {
4
+ code: '0x0',
5
+ message: `The value for OData query '${query}' cannot be empty.`
6
+ };
7
+ return false;
8
+ }
9
+ return true;
10
+ };
@@ -0,0 +1,118 @@
1
+ interface ODataError {
2
+ error?: {
3
+ code: string;
4
+ message: string;
5
+ };
6
+ }
7
+ interface ODataExpand {
8
+ /**
9
+ * Use the {@link ODataExpand.$expand $expand} system query option in the navigation properties
10
+ * to control what data from related entities is returned.
11
+ * There are two types of navigation properties:
12
+ * * Single-valued navigation properties correspond to Lookup attributes that support many-to-one
13
+ * relationships and allow setting a reference to another entity.
14
+ * * Collection-valued navigation properties correspond to one-to-many or many-to-many relationships.
15
+ *
16
+ * If you include only the name of the navigation property, you'll receive all the properties for
17
+ * related records. You can limit the properties returned for related records using the
18
+ * {@link ODataSelect.$select $select} system query option in parentheses after the navigation
19
+ * property name. Use this for both single-valued and collection-valued navigation properties.
20
+ *
21
+ * * Microsoft Docs: {@link https://learn.microsoft.com/power-apps/developer/data-platform/webapi/retrieve-related-entities-query?WT.mc_id=DX-MVP-5004767 Retrieve related table records with a query }
22
+ */
23
+ $expand?: {
24
+ [relationship: string]: ODataExpandQuery;
25
+ };
26
+ }
27
+ type ODataExpandQuery = ODataSelect & ODataExpand;
28
+ interface ODataFilter {
29
+ /**
30
+ * Use the {@link ODataFilter.$filter $filter} system query option to set criteria for which rows will be returned.
31
+ *
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
+ */
34
+ $filter?: StandardOperator;
35
+ }
36
+ interface ODataFetch {
37
+ /**
38
+ * You can compose a FetchXML query for a specific table.
39
+ * Then, URL-encode the XML and pass it to the entity set
40
+ * using the {@link ODataFetch.fetchXml fetchXml} query string parameter.
41
+ *
42
+ * * Microsoft Docs: {@link https://learn.microsoft.com/en-us/power-apps/developer/data-platform/webapi/use-fetchxml-web-api?WT.mc_id=DX-MVP-5004767 Use FetchXml with Web API }
43
+ */
44
+ fetchXml?: XMLDocument;
45
+ }
46
+ interface ODataOrderBy {
47
+ /**
48
+ * Specify the order in which items are returned using the {@link ODataOrderBy.$orderby $orderby}
49
+ * system query option. Use the asc or desc suffix to specify ascending or descending order
50
+ * respectively. The default is ascending if the suffix isn't applied.
51
+ *
52
+ * * Microsoft Docs: {@link https://learn.microsoft.com/en-us/power-apps/developer/data-platform/webapi/query-data-web-api?WT.mc_id=DX-MVP-5004767#order-results Order results }
53
+ */
54
+ $orderby?: {
55
+ column: string;
56
+ asc: boolean;
57
+ }[];
58
+ }
59
+ interface ODataSavedQuery {
60
+ /**
61
+ * You can use the `savedqueryid` value and pass it as the value to the {@link ODataSavedQuery.savedQuery savedQuery}
62
+ * parameter to the entity set that matches the corresponding `returnedtypecode` of the saved query.
63
+ *
64
+ * * Microsoft Docs: {@link https://learn.microsoft.com/en-us/power-apps/developer/data-platform/webapi/retrieve-and-execute-predefined-queries?WT.mc_id=DX-MVP-5004767#predefined-queries Retrieve and execute predefined queries }
65
+ */
66
+ savedQuery?: string;
67
+ }
68
+ interface ODataSelect {
69
+ /**
70
+ * Use the {@link ODataSelect.$select $select} system query option to limit the properties returned.
71
+ *
72
+ * This is a performance best practice. If properties aren't specified using
73
+ * {@link ODataSelect.$select $select}, all properties will be returned.
74
+ *
75
+ * * Microsoft Docs: {@link https://learn.microsoft.com/power-apps/developer/data-platform/webapi/query-data-web-api?WT.mc_id=DX-MVP-5004767#request-specific-properties Request specific properties }
76
+ */
77
+ $select?: string[];
78
+ }
79
+ interface ODataTop {
80
+ /**
81
+ * You can limit the number of results returned by using the {@link ODataTop.$top $top} system query option.
82
+ *
83
+ * * Microsoft Docs: {@link https://learn.microsoft.com/power-apps/developer/data-platform/webapi/query-data-web-api?WT.mc_id=DX-MVP-5004767#use-top-query-option Use $top query option }
84
+ */
85
+ $top?: number;
86
+ }
87
+ interface ODataUserQuery {
88
+ /**
89
+ * You can use the `userqueryid` value and pass it as the value to the {@link OdataUserQuery.userQuery userQuery}
90
+ * parameter to the entity set that matches the corresponding `returnedtypecode` of the user query.
91
+ *
92
+ * * Microsoft Docs: {@link https://learn.microsoft.com/en-us/power-apps/developer/data-platform/webapi/retrieve-and-execute-predefined-queries?WT.mc_id=DX-MVP-5004767#predefined-queries Retrieve and execute predefined queries }
93
+ */
94
+ userQuery?: string;
95
+ }
96
+ type StandardOperators = 'eq' | 'ne' | 'gt' | 'ge' | 'lt' | 'le';
97
+ interface StandardOperator {
98
+ operator: StandardOperators;
99
+ /**
100
+ * The left side of the 'X' operator must be a property of the entity.
101
+ */
102
+ left: string;
103
+ /**
104
+ * The right side of the 'X' operator must be a constant value.
105
+ */
106
+ right: string | number;
107
+ }
108
+ interface UnaryOperator {
109
+ operator: 'not';
110
+ right: StandardOperator;
111
+ }
112
+ interface BinaryOperator {
113
+ operator: 'and' | 'or';
114
+ left: StandardOperator;
115
+ right: StandardOperator;
116
+ }
117
+ type ODataQuery = ODataError & ODataExpand & ODataFetch & ODataFilter & ODataOrderBy & ODataSavedQuery & ODataSelect & ODataTop & ODataUserQuery;
118
+ export { BinaryOperator, ODataError, ODataExpand, ODataExpandQuery, ODataFetch, ODataFilter, ODataOrderBy, ODataQuery, ODataSavedQuery, ODataSelect, ODataTop, ODataUserQuery, StandardOperator, StandardOperators, UnaryOperator, };
@@ -1,7 +1,7 @@
1
1
  import { ODataQuery } from './OData.types';
2
2
  /**
3
- * Parses the $expand query
4
- * @returns Returns true when the parse has an error
3
+ * Parses the {@link ODataExpand.$expand $expand} query
4
+ * @returns Returns `false` when the parse has an error
5
5
  */
6
6
  export declare const getExpandFromParser: (parser: URLSearchParams, result: ODataQuery) => boolean;
7
7
  //# sourceMappingURL=getExpandFromParser.d.ts.map
@@ -1,7 +1,7 @@
1
1
  import { ODataQuery } from './OData.types';
2
2
  /**
3
- * Parses the fetchXml query
4
- * @returns Returns true when the parse has an error
3
+ * Parses the {@link ODataFetch.fetchXml fetchXml} query
4
+ * @returns Returns `false` when the parse has an error
5
5
  */
6
6
  export declare const getFetchXmlFromParser: (parser: URLSearchParams, result: ODataQuery) => boolean;
7
7
  //# sourceMappingURL=getFetchXmlFromParser.d.ts.map
@@ -0,0 +1,7 @@
1
+ import { ODataQuery } from './OData.types';
2
+ /**
3
+ * Parses the {@link ODataOrderBy.$orderby $orderby} query
4
+ * @returns Returns `false` when the parse has an error
5
+ */
6
+ export declare const getOrderByFromParser: (parser: URLSearchParams, result: ODataQuery) => boolean;
7
+ //# sourceMappingURL=getOrderByFromParser.d.ts.map
@@ -1,7 +1,7 @@
1
1
  import { ODataQuery } from './OData.types';
2
2
  /**
3
- * Parses the $select query
4
- * @returns Returns true when the parse has an error
3
+ * Parses the {@link ODataSelect.$select $select} query
4
+ * @returns Returns `false` when the parse has an error
5
5
  */
6
6
  export declare const getSelectFromParser: (parser: URLSearchParams, result: ODataQuery) => boolean;
7
7
  //# sourceMappingURL=getSelectFromParser.d.ts.map
@@ -1,7 +1,7 @@
1
1
  import { ODataQuery } from './OData.types';
2
2
  /**
3
- * Parses the $top query
4
- * @returns Returns true when the parse has an error
3
+ * Parses the {@link ODataTop.$top $top} query
4
+ * @returns Returns `false` when the parse has an error
5
5
  */
6
6
  export declare const getTopFromParser: (parser: URLSearchParams, result: ODataQuery) => boolean;
7
7
  //# sourceMappingURL=getTopFromParser.d.ts.map
@@ -0,0 +1,8 @@
1
+ import { ODataQuery } from './OData.types';
2
+ /**
3
+ * Parses the {@link ODataSavedQuery.savedQuery savedQuery} or
4
+ * {@link ODataUserQuery.userQuery userQuery} query
5
+ * @returns Returns `false` when the parse has an error
6
+ */
7
+ export declare const getXQueryFromParser: (X: 'savedQuery' | 'userQuery', parser: URLSearchParams, result: ODataQuery) => boolean;
8
+ //# sourceMappingURL=getXQueryFromParser.d.ts.map
@@ -1,4 +1,10 @@
1
1
  export { BinaryOperator, ODataError, ODataExpand, ODataExpandQuery, ODataFetch, ODataFilter, ODataQuery, ODataSelect, ODataTop, StandardOperator, StandardOperators, } from './OData.types';
2
+ export { getExpandFromParser } from './getExpandFromParser';
3
+ export { getFetchXmlFromParser } from './getFetchXmlFromParser';
4
+ export { getOrderByFromParser } from './getOrderByFromParser';
5
+ export { getSelectFromParser } from './getSelectFromParser';
6
+ export { getTopFromParser } from './getTopFromParser';
7
+ export { getXQueryFromParser } from './getXQueryFromParser';
2
8
  export { parseOData } from './parseOData';
3
9
  import { parseOData } from './parseOData';
4
10
  export default parseOData;
@@ -0,0 +1,3 @@
1
+ import { ODataQuery } from './OData.types';
2
+ export declare const validateNotEmpty: (query: string, value: string, result: ODataQuery) => boolean;
3
+ //# sourceMappingURL=validateNotEmpty.d.ts.map