@shko.online/dataverse-odata 0.1.2 → 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.
package/.eslintrc.json ADDED
@@ -0,0 +1,59 @@
1
+ {
2
+ "env": {
3
+ "browser": true,
4
+ "es2021": true
5
+ },
6
+ "extends": [
7
+ "eslint:recommended",
8
+ "plugin:react/recommended",
9
+ "plugin:@typescript-eslint/recommended",
10
+ "plugin:prettier/recommended",
11
+ "prettier",
12
+ "plugin:sonarjs/recommended"
13
+ ],
14
+ "parser": "@typescript-eslint/parser",
15
+ "parserOptions": {
16
+ "ecmaFeatures": {
17
+ "jsx": true
18
+ },
19
+ "ecmaVersion": 12,
20
+ "sourceType": "module"
21
+ },
22
+ "plugins": [
23
+ "react",
24
+ "react-hooks",
25
+ "@typescript-eslint",
26
+ "prettier",
27
+ "sonarjs"
28
+ ],
29
+ "settings": {
30
+ "react": {
31
+ "pragma": "React",
32
+ "version": "detect"
33
+ }
34
+ },
35
+ "ignorePatterns": ["**/generated/*.ts"],
36
+ "rules": {
37
+ "eqeqeq": [2, "smart"],
38
+ "react-hooks/exhaustive-deps": "warn",
39
+ "prettier/prettier": "error",
40
+ "arrow-body-style": "off",
41
+ "prefer-arrow-callback": "off",
42
+ "linebreak-style": [
43
+ "error",
44
+ "windows"
45
+ ],
46
+ "quotes": [
47
+ "error",
48
+ "single",
49
+ {
50
+ "avoidEscape": true,
51
+ "allowTemplateLiterals": true
52
+ }
53
+ ],
54
+ "semi": [
55
+ "error",
56
+ "always"
57
+ ]
58
+ }
59
+ }
@@ -0,0 +1,8 @@
1
+ {
2
+ "semi": true,
3
+ "trailingComma": "all",
4
+ "singleQuote": true,
5
+ "printWidth": 120,
6
+ "tabWidth": 4,
7
+ "endOfLine":"auto"
8
+ }
package/CHANGELOG.md CHANGED
@@ -1,3 +1,10 @@
1
+ ## [0.1.3](https://github.com/shko-online/dataverse-odata/compare/v0.1.2...v0.1.3) (2023-02-11)
2
+
3
+
4
+ ### Bug Fixes
5
+
6
+ * Fixed bundled types ([abbd95b](https://github.com/shko-online/dataverse-odata/commit/abbd95bbc0d118e9c2c20cbeb224025e84e33a9e))
7
+
1
8
  ## [0.1.2](https://github.com/shko-online/dataverse-odata/compare/v0.1.1...v0.1.2) (2023-02-11)
2
9
 
3
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, };
@@ -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
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@shko.online/dataverse-odata",
3
- "version": "0.1.2",
3
+ "version": "0.1.3",
4
4
  "description": "This package will help parse OData strings (only the Microsoft Dataverse subset). It can be used as a validator, or you can build some javascript library which consumes the output of this library.",
5
5
  "scripts": {
6
6
  "build": "npm run lint && node ../scripts/build.js",
@@ -1,11 +1,11 @@
1
- export interface ODataError {
1
+ interface ODataError {
2
2
  error?: {
3
3
  code: string;
4
4
  message: string;
5
5
  };
6
6
  }
7
7
 
8
- export interface ODataExpand {
8
+ interface ODataExpand {
9
9
  /**
10
10
  * Use the {@link ODataExpand.$expand $expand} system query option in the navigation properties
11
11
  * to control what data from related entities is returned.
@@ -26,9 +26,9 @@ export interface ODataExpand {
26
26
  };
27
27
  }
28
28
 
29
- export type ODataExpandQuery = ODataSelect & ODataExpand;
29
+ type ODataExpandQuery = ODataSelect & ODataExpand;
30
30
 
31
- export interface ODataFilter {
31
+ interface ODataFilter {
32
32
  /**
33
33
  * Use the {@link ODataFilter.$filter $filter} system query option to set criteria for which rows will be returned.
34
34
  *
@@ -37,7 +37,7 @@ export interface ODataFilter {
37
37
  $filter?: StandardOperator;
38
38
  }
39
39
 
40
- export interface ODataFetch {
40
+ interface ODataFetch {
41
41
  /**
42
42
  * You can compose a FetchXML query for a specific table.
43
43
  * Then, URL-encode the XML and pass it to the entity set
@@ -48,7 +48,7 @@ export interface ODataFetch {
48
48
  fetchXml?: XMLDocument;
49
49
  }
50
50
 
51
- export interface ODataOrderBy {
51
+ interface ODataOrderBy {
52
52
  /**
53
53
  * Specify the order in which items are returned using the {@link ODataOrderBy.$orderby $orderby}
54
54
  * system query option. Use the asc or desc suffix to specify ascending or descending order
@@ -59,7 +59,7 @@ export interface ODataOrderBy {
59
59
  $orderby?: { column: string; asc: boolean }[];
60
60
  }
61
61
 
62
- export interface ODataSavedQuery {
62
+ interface ODataSavedQuery {
63
63
  /**
64
64
  * You can use the `savedqueryid` value and pass it as the value to the {@link ODataSavedQuery.savedQuery savedQuery}
65
65
  * parameter to the entity set that matches the corresponding `returnedtypecode` of the saved query.
@@ -69,7 +69,7 @@ export interface ODataSavedQuery {
69
69
  savedQuery?: string;
70
70
  }
71
71
 
72
- export interface ODataSelect {
72
+ interface ODataSelect {
73
73
  /**
74
74
  * Use the {@link ODataSelect.$select $select} system query option to limit the properties returned.
75
75
  *
@@ -81,7 +81,7 @@ export interface ODataSelect {
81
81
  $select?: string[];
82
82
  }
83
83
 
84
- export interface ODataTop {
84
+ interface ODataTop {
85
85
  /**
86
86
  * You can limit the number of results returned by using the {@link ODataTop.$top $top} system query option.
87
87
  *
@@ -90,7 +90,7 @@ export interface ODataTop {
90
90
  $top?: number;
91
91
  }
92
92
 
93
- export interface ODataUserQuery {
93
+ interface ODataUserQuery {
94
94
  /**
95
95
  * You can use the `userqueryid` value and pass it as the value to the {@link OdataUserQuery.userQuery userQuery}
96
96
  * parameter to the entity set that matches the corresponding `returnedtypecode` of the user query.
@@ -100,9 +100,9 @@ export interface ODataUserQuery {
100
100
  userQuery?: string;
101
101
  }
102
102
 
103
- export type StandardOperators = 'eq' | 'ne' | 'gt' | 'ge' | 'lt' | 'le';
103
+ type StandardOperators = 'eq' | 'ne' | 'gt' | 'ge' | 'lt' | 'le';
104
104
 
105
- export interface StandardOperator {
105
+ interface StandardOperator {
106
106
  operator: StandardOperators;
107
107
  /**
108
108
  * The left side of the 'X' operator must be a property of the entity.
@@ -114,18 +114,18 @@ export interface StandardOperator {
114
114
  right: string | number;
115
115
  }
116
116
 
117
- export interface UnaryOperator {
117
+ interface UnaryOperator {
118
118
  operator: 'not';
119
119
  right: StandardOperator;
120
120
  }
121
121
 
122
- export interface BinaryOperator {
122
+ interface BinaryOperator {
123
123
  operator: 'and' | 'or';
124
124
  left: StandardOperator;
125
125
  right: StandardOperator;
126
126
  }
127
127
 
128
- export type ODataQuery = ODataError &
128
+ type ODataQuery = ODataError &
129
129
  ODataExpand &
130
130
  ODataFetch &
131
131
  ODataFilter &
@@ -134,3 +134,21 @@ export type ODataQuery = ODataError &
134
134
  ODataSelect &
135
135
  ODataTop &
136
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,5 +1,8 @@
1
1
  {
2
2
  "extends": "./tsconfig.json",
3
+ "include": [
4
+ "src"
5
+ ],
3
6
  "exclude": [
4
7
  "tests",
5
8
  "lib",
package/tsconfig.json CHANGED
@@ -16,11 +16,8 @@
16
16
  "resolveJsonModule": true,
17
17
  "declaration": true,
18
18
  "declarationMap": true,
19
- "sourceMap": true,
20
- "baseUrl": ".",
21
- "typeRoots": [
22
- "./node_modules/@types"
23
- ]
19
+ "sourceMap": true,
20
+ "baseUrl": "."
24
21
  },
25
22
  "exclude": [
26
23
  "node_modules",