@shko.online/dataverse-odata 0.1.2 → 0.1.4

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 (88) 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 +19 -12
  5. package/lib/cjs/getFetchXmlFromParser.js +37 -35
  6. package/lib/cjs/getOrderByFromParser.js +28 -25
  7. package/lib/cjs/getSelectFromParser.js +13 -4
  8. package/lib/cjs/getTopFromParser.js +25 -21
  9. package/lib/cjs/getXQueryFromParser.js +9 -19
  10. package/lib/cjs/parseOData.js +2 -18
  11. package/lib/cjs/validators/atMostOnce.js +24 -0
  12. package/lib/cjs/validators/differentFromEmptyString.js +23 -0
  13. package/lib/cjs/validators/hasContent.js +24 -0
  14. package/lib/cjs/validators/isGuid.js +25 -0
  15. package/lib/cjs/validators/recognizedGuid.js +23 -0
  16. package/lib/esm/getExpandFromParser.js +18 -12
  17. package/lib/esm/getFetchXmlFromParser.js +37 -35
  18. package/lib/esm/getOrderByFromParser.js +28 -25
  19. package/lib/esm/getSelectFromParser.js +13 -4
  20. package/lib/esm/getTopFromParser.js +24 -21
  21. package/lib/esm/getXQueryFromParser.js +9 -18
  22. package/lib/esm/parseOData.js +2 -18
  23. package/lib/esm/validators/atMostOnce.js +17 -0
  24. package/lib/esm/validators/differentFromEmptyString.js +16 -0
  25. package/lib/esm/validators/hasContent.js +17 -0
  26. package/lib/esm/validators/isGuid.js +18 -0
  27. package/lib/esm/validators/recognizedGuid.js +16 -0
  28. package/lib/modern/getExpandFromParser.js +18 -12
  29. package/lib/modern/getFetchXmlFromParser.js +37 -35
  30. package/lib/modern/getOrderByFromParser.js +29 -26
  31. package/lib/modern/getSelectFromParser.js +13 -4
  32. package/lib/modern/getTopFromParser.js +24 -21
  33. package/lib/modern/getXQueryFromParser.js +9 -18
  34. package/lib/modern/parseOData.js +2 -18
  35. package/lib/modern/validators/atMostOnce.js +17 -0
  36. package/lib/modern/validators/differentFromEmptyString.js +16 -0
  37. package/lib/modern/validators/hasContent.js +17 -0
  38. package/lib/modern/validators/isGuid.js +18 -0
  39. package/lib/modern/validators/recognizedGuid.js +16 -0
  40. package/lib/ts3.4/OData.types.d.ts +118 -0
  41. package/lib/ts3.4/getSelectFromParser.d.ts +1 -1
  42. package/lib/ts3.4/validators/atMostOnce.d.ts +10 -0
  43. package/lib/ts3.4/validators/differentFromEmptyString.d.ts +9 -0
  44. package/lib/ts3.4/validators/hasContent.d.ts +10 -0
  45. package/lib/ts3.4/validators/isGuid.d.ts +9 -0
  46. package/lib/ts3.4/validators/recognizedGuid.d.ts +9 -0
  47. package/lib/ts3.9/OData.types.d.ts +154 -0
  48. package/lib/ts3.9/getExpandFromParser.d.ts.map +1 -1
  49. package/lib/ts3.9/getFetchXmlFromParser.d.ts.map +1 -1
  50. package/lib/ts3.9/getOrderByFromParser.d.ts.map +1 -1
  51. package/lib/ts3.9/getSelectFromParser.d.ts +1 -1
  52. package/lib/ts3.9/getSelectFromParser.d.ts.map +1 -1
  53. package/lib/ts3.9/getTopFromParser.d.ts.map +1 -1
  54. package/lib/ts3.9/getXQueryFromParser.d.ts.map +1 -1
  55. package/lib/ts3.9/parseOData.d.ts.map +1 -1
  56. package/lib/ts3.9/validators/atMostOnce.d.ts +10 -0
  57. package/lib/ts3.9/validators/atMostOnce.d.ts.map +1 -0
  58. package/lib/ts3.9/validators/differentFromEmptyString.d.ts +9 -0
  59. package/lib/ts3.9/validators/differentFromEmptyString.d.ts.map +1 -0
  60. package/lib/ts3.9/validators/hasContent.d.ts +10 -0
  61. package/lib/ts3.9/validators/hasContent.d.ts.map +1 -0
  62. package/lib/ts3.9/validators/isGuid.d.ts +9 -0
  63. package/lib/ts3.9/validators/isGuid.d.ts.map +1 -0
  64. package/lib/ts3.9/validators/recognizedGuid.d.ts +9 -0
  65. package/lib/ts3.9/validators/recognizedGuid.d.ts.map +1 -0
  66. package/package.json +1 -1
  67. package/src/OData.types.d.ts +33 -15
  68. package/src/getExpandFromParser.ts +23 -12
  69. package/src/getFetchXmlFromParser.ts +48 -45
  70. package/src/getOrderByFromParser.ts +30 -26
  71. package/src/getSelectFromParser.ts +13 -4
  72. package/src/getTopFromParser.ts +25 -21
  73. package/src/getXQueryFromParser.ts +10 -19
  74. package/src/parseOData.ts +10 -18
  75. package/src/validators/atMostOnce.ts +19 -0
  76. package/src/validators/differentFromEmptyString.ts +18 -0
  77. package/src/validators/hasContent.ts +19 -0
  78. package/src/validators/isGuid.ts +20 -0
  79. package/src/validators/recognizedGuid.ts +18 -0
  80. package/tsconfig.build.json +3 -0
  81. package/tsconfig.json +2 -5
  82. package/lib/cjs/validateNotEmpty.js +0 -17
  83. package/lib/esm/validateNotEmpty.js +0 -10
  84. package/lib/modern/validateNotEmpty.js +0 -10
  85. package/lib/ts3.4/validateNotEmpty.d.ts +0 -3
  86. package/lib/ts3.9/validateNotEmpty.d.ts +0 -3
  87. package/lib/ts3.9/validateNotEmpty.d.ts.map +0 -1
  88. package/src/validateNotEmpty.ts +0 -12
@@ -1,4 +1,6 @@
1
- import { validateNotEmpty } from './validateNotEmpty';
1
+ import { atMostOnce } from './validators/atMostOnce';
2
+ import { hasContent } from './validators/hasContent';
3
+ const option = '$orderby';
2
4
  const edmProperty = /\w{1-255}/gi;
3
5
 
4
6
  /**
@@ -6,33 +8,34 @@ const edmProperty = /\w{1-255}/gi;
6
8
  * @returns Returns `false` when the parse has an error
7
9
  */
8
10
  export const getOrderByFromParser = (parser, result) => {
9
- let $orderby = parser.get('$orderby');
10
- if ($orderby !== null) {
11
- if (!validateNotEmpty('$orderby', $orderby, result)) {
11
+ let value = parser.getAll(option);
12
+ if (value.length === 0) {
13
+ return true;
14
+ }
15
+ if (!atMostOnce(option, value, result) || !hasContent(option, value, result)) {
16
+ return false;
17
+ }
18
+ let $orderby = value[0].trimEnd();
19
+ const orderByArray = [];
20
+ for (let i = 0; i < $orderby.length; i++) {
21
+ if (false /* syntax error */) {
22
+ result.error = {
23
+ code: '0x0',
24
+ message: `Syntax error at position ${i} in '${$orderby}'.`
25
+ };
12
26
  return false;
13
27
  }
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
28
  }
29
+ orderByArray.forEach(orderBy => {
30
+ var _orderBy$column;
31
+ if (!((_orderBy$column = orderBy.column) !== null && _orderBy$column !== void 0 && _orderBy$column.match(edmProperty))) {
32
+ result.error = {
33
+ code: '0x80060888',
34
+ message: 'Order By Property must be of type EdmProperty'
35
+ };
36
+ return false;
37
+ }
38
+ });
39
+ result.$orderby = orderByArray;
37
40
  return true;
38
41
  };
@@ -1,11 +1,20 @@
1
+ import { atMostOnce } from './validators/atMostOnce';
2
+ const option = '$select';
3
+
1
4
  /**
2
5
  * Parses the {@link ODataSelect.$select $select} query
3
- * @returns Returns `false` when the parse has an error
6
+ * @returns {boolean} Returns `false` when the parse has an error
4
7
  */
5
8
  export const getSelectFromParser = (parser, result) => {
6
- const $select = parser.get('$select');
7
- if ($select !== null) {
8
- result.$select = $select.split(',');
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.$select = value[0].split(',');
9
18
  }
10
19
  return true;
11
20
  };
@@ -1,30 +1,33 @@
1
- import { validateNotEmpty } from './validateNotEmpty';
1
+ import { atMostOnce } from './validators/atMostOnce';
2
+ import { hasContent } from './validators/hasContent';
3
+ const option = '$top';
2
4
 
3
5
  /**
4
6
  * Parses the {@link ODataTop.$top $top} query
5
7
  * @returns Returns `false` when the parse has an error
6
8
  */
7
9
  export const getTopFromParser = (parser, result) => {
8
- const $topValue = parser.get('$top');
9
- if ($topValue !== null) {
10
- if (!validateNotEmpty('$orderby', $topValue, result)) {
11
- return false;
12
- }
13
- let $top;
14
- if (!$topValue.match(/^\d+$/) || ($top = parseInt($topValue)) < 0) {
15
- result.error = {
16
- code: '0x0',
17
- message: `Invalid value '${$topValue}' for $top query option found. The $top query option requires a non-negative integer value.`
18
- };
19
- return false;
20
- } else if ($top === 0) {
21
- result.error = {
22
- code: '0x0',
23
- message: `Invalid value for $top query option.`
24
- };
25
- return false;
26
- }
27
- result.$top = $top;
10
+ const value = parser.getAll(option);
11
+ if (value.length === 0) {
12
+ return true;
28
13
  }
14
+ if (!atMostOnce(option, value, result) || !hasContent(option, value, result)) {
15
+ return false;
16
+ }
17
+ let $top;
18
+ if (!value[0].match(/^\d+$/) || ($top = parseInt(value[0])) < 0) {
19
+ result.error = {
20
+ code: '0x0',
21
+ message: `Invalid value '${value}' for $top query option found. The $top query option requires a non-negative integer value.`
22
+ };
23
+ return false;
24
+ } else if ($top === 0) {
25
+ result.error = {
26
+ code: '0x0',
27
+ message: `Invalid value for $top query option.`
28
+ };
29
+ return false;
30
+ }
31
+ result.$top = $top;
29
32
  return true;
30
33
  };
@@ -1,4 +1,5 @@
1
- const guidRegex = /[0-9A-F]{8}\-[0-9A-F]{4}-[0-9A-F]{4}-[0-9A-F]{4}-[0-9A-F]{12}/gi;
1
+ import { isGuid } from './validators/isGuid';
2
+ import { recognizedGuid } from './validators/recognizedGuid';
2
3
 
3
4
  /**
4
5
  * Parses the {@link ODataSavedQuery.savedQuery savedQuery} or
@@ -6,23 +7,13 @@ const guidRegex = /[0-9A-F]{8}\-[0-9A-F]{4}-[0-9A-F]{4}-[0-9A-F]{4}-[0-9A-F]{12}
6
7
  * @returns Returns `false` when the parse has an error
7
8
  */
8
9
  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;
10
+ const value = parser.getAll(X);
11
+ if (value.length === 0) {
12
+ return true;
26
13
  }
14
+ if (!recognizedGuid(value, result) || !isGuid(value, result)) {
15
+ return false;
16
+ }
17
+ result[X] = value[0];
27
18
  return true;
28
19
  };
@@ -3,6 +3,7 @@ import { getSelectFromParser } from './getSelectFromParser';
3
3
  import { getExpandFromParser } from './getExpandFromParser';
4
4
  import { getFetchXmlFromParser } from './getFetchXmlFromParser';
5
5
  import { getXQueryFromParser } from './getXQueryFromParser';
6
+ import { getOrderByFromParser } from './getOrderByFromParser';
6
7
 
7
8
  /**
8
9
  * parses the OData query and applies some Dataverse validations
@@ -12,23 +13,6 @@ import { getXQueryFromParser } from './getXQueryFromParser';
12
13
  export const parseOData = query => {
13
14
  const parser = new URLSearchParams(query);
14
15
  const result = {};
15
- if (!getExpandFromParser(parser, result)) {
16
- return result;
17
- }
18
- if (!getSelectFromParser(parser, result)) {
19
- return result;
20
- }
21
- if (!getTopFromParser(parser, result)) {
22
- return result;
23
- }
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)) {
31
- return result;
32
- }
16
+ getExpandFromParser(parser, result) && getSelectFromParser(parser, result) && getTopFromParser(parser, result) && getFetchXmlFromParser(parser, result) && getXQueryFromParser('savedQuery', parser, result) && getXQueryFromParser('userQuery', parser, result) && getOrderByFromParser(parser, result);
33
17
  return result;
34
18
  };
@@ -0,0 +1,17 @@
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
+ */
8
+ export const atMostOnce = (option, value, result) => {
9
+ if (value.length > 1) {
10
+ result.error = {
11
+ code: '0x0',
12
+ message: `Query option '${option}' was specified more than once, but it must be specified at most once.`
13
+ };
14
+ return false;
15
+ }
16
+ return true;
17
+ };
@@ -0,0 +1,16 @@
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
+ */
7
+ export const differentFromEmptyString = (value, result) => {
8
+ if (value[0] === '') {
9
+ result.error = {
10
+ code: '0x80040203',
11
+ message: 'Expected non-empty string.'
12
+ };
13
+ return false;
14
+ }
15
+ return true;
16
+ };
@@ -0,0 +1,17 @@
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
+ */
8
+ export const hasContent = (query, value, result) => {
9
+ if (!value[0].trim()) {
10
+ result.error = {
11
+ code: '0x0',
12
+ message: `The value for OData query '${query}' cannot be empty.`
13
+ };
14
+ return false;
15
+ }
16
+ return true;
17
+ };
@@ -0,0 +1,18 @@
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
+ *
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
+ */
9
+ export const isGuid = (value, result) => {
10
+ if (!value[0].match(guidRegex)) {
11
+ result.error = {
12
+ code: '0x0',
13
+ message: 'Guid should contain 32 digits with 4 dashes (xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx).'
14
+ };
15
+ return false;
16
+ }
17
+ return true;
18
+ };
@@ -0,0 +1,16 @@
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
+ */
7
+ export const recognizedGuid = (value, result) => {
8
+ if (!value[0].trim()) {
9
+ result.error = {
10
+ code: '0x0',
11
+ message: 'Unrecognized Guid format.'
12
+ };
13
+ return false;
14
+ }
15
+ return true;
16
+ };
@@ -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
3
  * Parses the {@link ODataSelect.$select $select} query
4
- * @returns Returns `false` when the parse has an error
4
+ * @returns {boolean} 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
@@ -0,0 +1,10 @@
1
+ import { ODataQuery } from '../OData.types';
2
+ /**
3
+ * Options of this type must be specified at most once.
4
+ * @param option The option being validated (ex. $top)
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
+ */
9
+ export declare const atMostOnce: (option: string, value: string[], result: ODataQuery) => boolean;
10
+ //# sourceMappingURL=atMostOnce.d.ts.map
@@ -0,0 +1,9 @@
1
+ import { ODataQuery } from '../OData.types';
2
+ /**
3
+ *
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
+ */
8
+ export declare const differentFromEmptyString: (value: string[], result: ODataQuery) => boolean;
9
+ //# sourceMappingURL=differentFromEmptyString.d.ts.map
@@ -0,0 +1,10 @@
1
+ import { ODataQuery } from '../OData.types';
2
+ /**
3
+ * Options of this type must be specified at most once.
4
+ * @param option The option being validated (ex. $top)
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
+ */
9
+ export declare const hasContent: (query: string, value: string[], result: ODataQuery) => boolean;
10
+ //# sourceMappingURL=hasContent.d.ts.map
@@ -0,0 +1,9 @@
1
+ import { ODataQuery } from '../OData.types';
2
+ /**
3
+ *
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
+ */
8
+ export declare const isGuid: (value: string[], result: ODataQuery) => boolean;
9
+ //# sourceMappingURL=isGuid.d.ts.map
@@ -0,0 +1,9 @@
1
+ import { ODataQuery } from '../OData.types';
2
+ /**
3
+ *
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
+ */
8
+ export declare const recognizedGuid: (value: string[], result: ODataQuery) => boolean;
9
+ //# sourceMappingURL=recognizedGuid.d.ts.map
@@ -0,0 +1,154 @@
1
+ interface ODataError {
2
+ error?: {
3
+ code: string;
4
+ message: string;
5
+ };
6
+ }
7
+
8
+ interface ODataExpand {
9
+ /**
10
+ * Use the {@link ODataExpand.$expand $expand} system query option in the navigation properties
11
+ * to control what data from related entities is returned.
12
+ * There are two types of navigation properties:
13
+ * * Single-valued navigation properties correspond to Lookup attributes that support many-to-one
14
+ * relationships and allow setting a reference to another entity.
15
+ * * Collection-valued navigation properties correspond to one-to-many or many-to-many relationships.
16
+ *
17
+ * If you include only the name of the navigation property, you'll receive all the properties for
18
+ * related records. You can limit the properties returned for related records using the
19
+ * {@link ODataSelect.$select $select} system query option in parentheses after the navigation
20
+ * property name. Use this for both single-valued and collection-valued navigation properties.
21
+ *
22
+ * * 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 }
23
+ */
24
+ $expand?: {
25
+ [relationship: string]: ODataExpandQuery;
26
+ };
27
+ }
28
+
29
+ type ODataExpandQuery = ODataSelect & ODataExpand;
30
+
31
+ interface ODataFilter {
32
+ /**
33
+ * Use the {@link ODataFilter.$filter $filter} system query option to set criteria for which rows will be returned.
34
+ *
35
+ * * 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 }
36
+ */
37
+ $filter?: StandardOperator;
38
+ }
39
+
40
+ interface ODataFetch {
41
+ /**
42
+ * You can compose a FetchXML query for a specific table.
43
+ * Then, URL-encode the XML and pass it to the entity set
44
+ * using the {@link ODataFetch.fetchXml fetchXml} query string parameter.
45
+ *
46
+ * * 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 }
47
+ */
48
+ fetchXml?: XMLDocument;
49
+ }
50
+
51
+ interface ODataOrderBy {
52
+ /**
53
+ * Specify the order in which items are returned using the {@link ODataOrderBy.$orderby $orderby}
54
+ * system query option. Use the asc or desc suffix to specify ascending or descending order
55
+ * respectively. The default is ascending if the suffix isn't applied.
56
+ *
57
+ * * 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 }
58
+ */
59
+ $orderby?: { column: string; asc: boolean }[];
60
+ }
61
+
62
+ interface ODataSavedQuery {
63
+ /**
64
+ * You can use the `savedqueryid` value and pass it as the value to the {@link ODataSavedQuery.savedQuery savedQuery}
65
+ * parameter to the entity set that matches the corresponding `returnedtypecode` of the saved query.
66
+ *
67
+ * * 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 }
68
+ */
69
+ savedQuery?: string;
70
+ }
71
+
72
+ interface ODataSelect {
73
+ /**
74
+ * Use the {@link ODataSelect.$select $select} system query option to limit the properties returned.
75
+ *
76
+ * This is a performance best practice. If properties aren't specified using
77
+ * {@link ODataSelect.$select $select}, all properties will be returned.
78
+ *
79
+ * * 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 }
80
+ */
81
+ $select?: string[];
82
+ }
83
+
84
+ interface ODataTop {
85
+ /**
86
+ * You can limit the number of results returned by using the {@link ODataTop.$top $top} system query option.
87
+ *
88
+ * * 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 }
89
+ */
90
+ $top?: number;
91
+ }
92
+
93
+ interface ODataUserQuery {
94
+ /**
95
+ * You can use the `userqueryid` value and pass it as the value to the {@link OdataUserQuery.userQuery userQuery}
96
+ * parameter to the entity set that matches the corresponding `returnedtypecode` of the user query.
97
+ *
98
+ * * 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 }
99
+ */
100
+ userQuery?: string;
101
+ }
102
+
103
+ type StandardOperators = 'eq' | 'ne' | 'gt' | 'ge' | 'lt' | 'le';
104
+
105
+ interface StandardOperator {
106
+ operator: StandardOperators;
107
+ /**
108
+ * The left side of the 'X' operator must be a property of the entity.
109
+ */
110
+ left: string;
111
+ /**
112
+ * The right side of the 'X' operator must be a constant value.
113
+ */
114
+ right: string | number;
115
+ }
116
+
117
+ interface UnaryOperator {
118
+ operator: 'not';
119
+ right: StandardOperator;
120
+ }
121
+
122
+ interface BinaryOperator {
123
+ operator: 'and' | 'or';
124
+ left: StandardOperator;
125
+ right: StandardOperator;
126
+ }
127
+
128
+ type ODataQuery = ODataError &
129
+ ODataExpand &
130
+ ODataFetch &
131
+ ODataFilter &
132
+ ODataOrderBy &
133
+ ODataSavedQuery &
134
+ ODataSelect &
135
+ ODataTop &
136
+ ODataUserQuery;
137
+
138
+ export type {
139
+ BinaryOperator,
140
+ ODataError,
141
+ ODataExpand,
142
+ ODataExpandQuery,
143
+ ODataFetch,
144
+ ODataFilter,
145
+ ODataOrderBy,
146
+ ODataQuery,
147
+ ODataSavedQuery,
148
+ ODataSelect,
149
+ ODataTop,
150
+ ODataUserQuery,
151
+ StandardOperator,
152
+ StandardOperators,
153
+ UnaryOperator,
154
+ };
@@ -1 +1 @@
1
- {"version":3,"file":"getExpandFromParser.d.ts","sourceRoot":"","sources":["../../src/getExpandFromParser.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAA6C,UAAU,EAAE,MAAM,eAAe,CAAC;AAI3F;;;GAGG;AACH,eAAO,MAAM,mBAAmB,WAAY,eAAe,UAAU,UAAU,KAAG,OAUjF,CAAC"}
1
+ {"version":3,"file":"getExpandFromParser.d.ts","sourceRoot":"","sources":["../../src/getExpandFromParser.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAA6C,UAAU,EAAE,MAAM,eAAe,CAAC;AAO3F;;;GAGG;AACH,eAAO,MAAM,mBAAmB,WAAY,eAAe,UAAU,UAAU,KAAG,OAejF,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"getFetchXmlFromParser.d.ts","sourceRoot":"","sources":["../../src/getFetchXmlFromParser.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAc,MAAM,eAAe,CAAC;AAE5D;;;GAGG;AACH,eAAO,MAAM,qBAAqB,WAAY,eAAe,UAAU,UAAU,KAAG,OAiDnF,CAAC"}
1
+ {"version":3,"file":"getFetchXmlFromParser.d.ts","sourceRoot":"","sources":["../../src/getFetchXmlFromParser.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAc,MAAM,eAAe,CAAC;AAM5D;;;GAGG;AACH,eAAO,MAAM,qBAAqB,WAAY,eAAe,UAAU,UAAU,KAAG,OAgDnF,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"getOrderByFromParser.d.ts","sourceRoot":"","sources":["../../src/getOrderByFromParser.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAgB,MAAM,eAAe,CAAC;AAK9D;;;GAGG;AACH,eAAO,MAAM,oBAAoB,WAAY,eAAe,UAAU,UAAU,KAAG,OAgClF,CAAC"}
1
+ {"version":3,"file":"getOrderByFromParser.d.ts","sourceRoot":"","sources":["../../src/getOrderByFromParser.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAgB,MAAM,eAAe,CAAC;AAO9D;;;GAGG;AACH,eAAO,MAAM,oBAAoB,WAAY,eAAe,UAAU,UAAU,KAAG,OAkClF,CAAC"}