@shko.online/dataverse-odata 0.1.0 → 0.1.1

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 (57) hide show
  1. package/.babelrc.js +160 -160
  2. package/.releaserc.yaml +23 -0
  3. package/CHANGELOG.md +6 -0
  4. package/README.md +3 -0
  5. package/jest.config.ts +12 -12
  6. package/lib/cjs/getExpandFromParser.js +3 -3
  7. package/lib/cjs/getFetchXmlFromParser.js +3 -3
  8. package/lib/cjs/getSelectFromParser.js +3 -3
  9. package/lib/cjs/getTopFromParser.js +3 -3
  10. package/lib/cjs/parseOData.js +5 -0
  11. package/lib/esm/getExpandFromParser.js +3 -3
  12. package/lib/esm/getFetchXmlFromParser.js +3 -3
  13. package/lib/esm/getSelectFromParser.js +3 -3
  14. package/lib/esm/getTopFromParser.js +3 -3
  15. package/lib/esm/parseOData.js +6 -0
  16. package/lib/getExpandFromParser.d.ts +6 -6
  17. package/lib/getExpandFromParser.js +96 -96
  18. package/lib/getFetchXmlFromParser.d.ts +6 -6
  19. package/lib/getFetchXmlFromParser.js +40 -40
  20. package/lib/getSelectFromParser.d.ts +6 -6
  21. package/lib/getSelectFromParser.js +11 -11
  22. package/lib/getTopFromParser.d.ts +6 -6
  23. package/lib/getTopFromParser.js +26 -26
  24. package/lib/index.d.ts +4 -4
  25. package/lib/index.js +3 -3
  26. package/lib/modern/getExpandFromParser.js +3 -3
  27. package/lib/modern/getFetchXmlFromParser.js +3 -3
  28. package/lib/modern/getSelectFromParser.js +3 -3
  29. package/lib/modern/getTopFromParser.js +3 -3
  30. package/lib/modern/parseOData.js +6 -0
  31. package/lib/parseOData.d.ts +2 -2
  32. package/lib/parseOData.js +21 -21
  33. package/lib/ts3.4/getFetchXmlFromParser.d.ts +1 -1
  34. package/lib/ts3.4/parseOData.d.ts +5 -0
  35. package/lib/ts3.9/getExpandFromParser.d.ts +6 -6
  36. package/lib/ts3.9/getExpandFromParser.d.ts.map +1 -1
  37. package/lib/ts3.9/getFetchXmlFromParser.d.ts +6 -6
  38. package/lib/ts3.9/getSelectFromParser.d.ts +6 -6
  39. package/lib/ts3.9/getTopFromParser.d.ts +6 -6
  40. package/lib/ts3.9/index.d.ts +4 -4
  41. package/lib/ts3.9/index.d.ts.map +1 -1
  42. package/lib/ts3.9/parseOData.d.ts +7 -2
  43. package/lib/ts3.9/parseOData.d.ts.map +1 -1
  44. package/package.json +13 -8
  45. package/src/OData.types.d.ts +61 -61
  46. package/src/getExpandFromParser.ts +106 -105
  47. package/src/getFetchXmlFromParser.ts +48 -48
  48. package/src/getSelectFromParser.ts +13 -13
  49. package/src/getTopFromParser.ts +27 -27
  50. package/src/index.ts +17 -16
  51. package/src/parseOData.ts +29 -23
  52. package/tests/OData-Parser.$expand.test.ts +39 -39
  53. package/tests/OData-Parser.$top.test.ts +36 -36
  54. package/tests/OData-Parser.fetchXml.test.ts +62 -62
  55. package/tests/OData-Parser.test.ts +17 -17
  56. package/tsconfig.build.json +8 -8
  57. package/tsconfig.json +35 -35
package/.babelrc.js CHANGED
@@ -1,161 +1,161 @@
1
- const withTests = {
2
- presets: [
3
- [
4
- '@babel/preset-env',
5
- { shippedProposals: true, useBuiltIns: 'usage', corejs: '3', targets: { node: 'current' } },
6
- ],
7
- ],
8
- plugins: [
9
- '@storybook/babel-plugin-require-context-hook',
10
- 'babel-plugin-dynamic-import-node',
11
- '@babel/plugin-transform-runtime',
12
- ],
13
- };
14
-
15
- // type BabelMode = 'cjs' | 'esm' | 'modern';
16
-
17
- const modules = process.env.BABEL_MODE === 'cjs' ? 'auto' : false;
18
-
19
- // FIXME: optional chaining introduced in chrome 80, not supported by wepback4
20
- // https://github.com/webpack/webpack/issues/10227#issuecomment-642734920
21
- const targets = process.env.BABEL_MODE === 'modern' ? { chrome: '79' } : 'defaults';
22
-
23
- module.exports = {
24
- ignore: [
25
- './lib/codemod/src/transforms/__testfixtures__',
26
- './lib/postinstall/src/__testfixtures__',
27
- '**/typings.d.ts',
28
- ],
29
- presets: [
30
- [
31
- '@babel/preset-env',
32
- {
33
- shippedProposals: true,
34
- useBuiltIns: 'usage',
35
- corejs: '3',
36
- targets,
37
- modules,
38
- },
39
- ],
40
- '@babel/preset-typescript',
41
- '@babel/preset-react',
42
- '@babel/preset-flow',
43
- ],
44
- plugins: [
45
- [
46
- '@babel/plugin-proposal-decorators',
47
- {
48
- legacy: true,
49
- },
50
- ],
51
- ['@babel/plugin-proposal-class-properties', { loose: true }],
52
- ['@babel/plugin-proposal-private-methods', { loose: true }],
53
- ['@babel/plugin-proposal-private-property-in-object', { loose: true }],
54
- '@babel/plugin-proposal-export-default-from',
55
- '@babel/plugin-syntax-dynamic-import',
56
- ['@babel/plugin-proposal-object-rest-spread', { loose: true, useBuiltIns: true }],
57
- 'babel-plugin-macros',
58
- ['@emotion', { sourceMap: true, autoLabel: 'always' }],
59
- ],
60
- env: {
61
- test: withTests,
62
- },
63
- overrides: [
64
- {
65
- test: './examples/vue-kitchen-sink',
66
- presets: ['@vue/babel-preset-jsx'],
67
- env: {
68
- test: withTests,
69
- },
70
- },
71
- {
72
- test: './lib',
73
- presets: [
74
- [
75
- '@babel/preset-env',
76
- {
77
- shippedProposals: true,
78
- useBuiltIns: 'usage',
79
- corejs: '3',
80
- modules,
81
- targets,
82
- },
83
- ],
84
- '@babel/preset-react',
85
- ],
86
- plugins: [
87
- ['@babel/plugin-proposal-object-rest-spread', { loose: true, useBuiltIns: true }],
88
- '@babel/plugin-proposal-export-default-from',
89
- '@babel/plugin-syntax-dynamic-import',
90
- ['@babel/plugin-proposal-private-property-in-object', { loose: true }],
91
- ['@babel/plugin-proposal-class-properties', { loose: true }],
92
- 'babel-plugin-macros',
93
- ['@emotion', { sourceMap: true, autoLabel: 'always' }],
94
- 'babel-plugin-add-react-displayname',
95
- ],
96
- env: {
97
- test: withTests,
98
- },
99
- },
100
- {
101
- test: [
102
- './lib/node-logger',
103
- './lib/core',
104
- './lib/core-common',
105
- './lib/core-server',
106
- './lib/builder-webpack4',
107
- './lib/builder-webpack5',
108
- './lib/codemod',
109
- './addons/storyshots',
110
- '**/src/server/**',
111
- '**/src/bin/**',
112
- ],
113
- presets: [
114
- [
115
- '@babel/preset-env',
116
- {
117
- shippedProposals: true,
118
- useBuiltIns: 'usage',
119
- targets: {
120
- node: '10',
121
- },
122
- modules,
123
- corejs: '3',
124
- },
125
- ],
126
- ],
127
- plugins: [
128
- '@emotion',
129
- 'babel-plugin-macros',
130
- '@babel/plugin-transform-arrow-functions',
131
- '@babel/plugin-transform-shorthand-properties',
132
- '@babel/plugin-transform-block-scoping',
133
- '@babel/plugin-transform-destructuring',
134
- ['@babel/plugin-proposal-private-property-in-object', { loose: true }],
135
- ['@babel/plugin-proposal-class-properties', { loose: true }],
136
- '@babel/plugin-proposal-object-rest-spread',
137
- '@babel/plugin-proposal-export-default-from',
138
- ],
139
- env: {
140
- test: withTests,
141
- },
142
- },
143
- {
144
- test: ['**/virtualModuleEntry.template.js'],
145
- presets: [
146
- [
147
- '@babel/preset-env',
148
- {
149
- shippedProposals: true,
150
- useBuiltIns: 'usage',
151
- targets: {
152
- node: '10',
153
- },
154
- corejs: '3',
155
- modules: false,
156
- },
157
- ],
158
- ],
159
- },
160
- ],
1
+ const withTests = {
2
+ presets: [
3
+ [
4
+ '@babel/preset-env',
5
+ { shippedProposals: true, useBuiltIns: 'usage', corejs: '3', targets: { node: 'current' } },
6
+ ],
7
+ ],
8
+ plugins: [
9
+ '@storybook/babel-plugin-require-context-hook',
10
+ 'babel-plugin-dynamic-import-node',
11
+ '@babel/plugin-transform-runtime',
12
+ ],
13
+ };
14
+
15
+ // type BabelMode = 'cjs' | 'esm' | 'modern';
16
+
17
+ const modules = process.env.BABEL_MODE === 'cjs' ? 'auto' : false;
18
+
19
+ // FIXME: optional chaining introduced in chrome 80, not supported by wepback4
20
+ // https://github.com/webpack/webpack/issues/10227#issuecomment-642734920
21
+ const targets = process.env.BABEL_MODE === 'modern' ? { chrome: '79' } : 'defaults';
22
+
23
+ module.exports = {
24
+ ignore: [
25
+ './lib/codemod/src/transforms/__testfixtures__',
26
+ './lib/postinstall/src/__testfixtures__',
27
+ '**/typings.d.ts',
28
+ ],
29
+ presets: [
30
+ [
31
+ '@babel/preset-env',
32
+ {
33
+ shippedProposals: true,
34
+ useBuiltIns: 'usage',
35
+ corejs: '3',
36
+ targets,
37
+ modules,
38
+ },
39
+ ],
40
+ '@babel/preset-typescript',
41
+ '@babel/preset-react',
42
+ '@babel/preset-flow',
43
+ ],
44
+ plugins: [
45
+ [
46
+ '@babel/plugin-proposal-decorators',
47
+ {
48
+ legacy: true,
49
+ },
50
+ ],
51
+ ['@babel/plugin-proposal-class-properties', { loose: true }],
52
+ ['@babel/plugin-proposal-private-methods', { loose: true }],
53
+ ['@babel/plugin-proposal-private-property-in-object', { loose: true }],
54
+ '@babel/plugin-proposal-export-default-from',
55
+ '@babel/plugin-syntax-dynamic-import',
56
+ ['@babel/plugin-proposal-object-rest-spread', { loose: true, useBuiltIns: true }],
57
+ 'babel-plugin-macros',
58
+ ['@emotion', { sourceMap: true, autoLabel: 'always' }],
59
+ ],
60
+ env: {
61
+ test: withTests,
62
+ },
63
+ overrides: [
64
+ {
65
+ test: './examples/vue-kitchen-sink',
66
+ presets: ['@vue/babel-preset-jsx'],
67
+ env: {
68
+ test: withTests,
69
+ },
70
+ },
71
+ {
72
+ test: './lib',
73
+ presets: [
74
+ [
75
+ '@babel/preset-env',
76
+ {
77
+ shippedProposals: true,
78
+ useBuiltIns: 'usage',
79
+ corejs: '3',
80
+ modules,
81
+ targets,
82
+ },
83
+ ],
84
+ '@babel/preset-react',
85
+ ],
86
+ plugins: [
87
+ ['@babel/plugin-proposal-object-rest-spread', { loose: true, useBuiltIns: true }],
88
+ '@babel/plugin-proposal-export-default-from',
89
+ '@babel/plugin-syntax-dynamic-import',
90
+ ['@babel/plugin-proposal-private-property-in-object', { loose: true }],
91
+ ['@babel/plugin-proposal-class-properties', { loose: true }],
92
+ 'babel-plugin-macros',
93
+ ['@emotion', { sourceMap: true, autoLabel: 'always' }],
94
+ 'babel-plugin-add-react-displayname',
95
+ ],
96
+ env: {
97
+ test: withTests,
98
+ },
99
+ },
100
+ {
101
+ test: [
102
+ './lib/node-logger',
103
+ './lib/core',
104
+ './lib/core-common',
105
+ './lib/core-server',
106
+ './lib/builder-webpack4',
107
+ './lib/builder-webpack5',
108
+ './lib/codemod',
109
+ './addons/storyshots',
110
+ '**/src/server/**',
111
+ '**/src/bin/**',
112
+ ],
113
+ presets: [
114
+ [
115
+ '@babel/preset-env',
116
+ {
117
+ shippedProposals: true,
118
+ useBuiltIns: 'usage',
119
+ targets: {
120
+ node: '10',
121
+ },
122
+ modules,
123
+ corejs: '3',
124
+ },
125
+ ],
126
+ ],
127
+ plugins: [
128
+ '@emotion',
129
+ 'babel-plugin-macros',
130
+ '@babel/plugin-transform-arrow-functions',
131
+ '@babel/plugin-transform-shorthand-properties',
132
+ '@babel/plugin-transform-block-scoping',
133
+ '@babel/plugin-transform-destructuring',
134
+ ['@babel/plugin-proposal-private-property-in-object', { loose: true }],
135
+ ['@babel/plugin-proposal-class-properties', { loose: true }],
136
+ '@babel/plugin-proposal-object-rest-spread',
137
+ '@babel/plugin-proposal-export-default-from',
138
+ ],
139
+ env: {
140
+ test: withTests,
141
+ },
142
+ },
143
+ {
144
+ test: ['**/virtualModuleEntry.template.js'],
145
+ presets: [
146
+ [
147
+ '@babel/preset-env',
148
+ {
149
+ shippedProposals: true,
150
+ useBuiltIns: 'usage',
151
+ targets: {
152
+ node: '10',
153
+ },
154
+ corejs: '3',
155
+ modules: false,
156
+ },
157
+ ],
158
+ ],
159
+ },
160
+ ],
161
161
  };
@@ -0,0 +1,23 @@
1
+ plugins:
2
+ - '@semantic-release/commit-analyzer'
3
+ - '@semantic-release/release-notes-generator'
4
+ - '@semantic-release/changelog'
5
+ - '@semantic-release/npm'
6
+ - '@semantic-release/exec'
7
+ - - '@semantic-release/git'
8
+ - assets:
9
+ - package.json
10
+ - CHANGELOG.md
11
+ message: |-
12
+ chore(release): ${nextRelease.version} [skip ci]
13
+
14
+ ${nextRelease.notes}
15
+ branches:
16
+ - '+([0-9])?(.{+([0-9]),x}).x'
17
+ - main
18
+ - next
19
+ - next-major
20
+ - name: beta
21
+ prerelease: true
22
+ - name: alpha
23
+ prerelease: true
package/CHANGELOG.md ADDED
@@ -0,0 +1,6 @@
1
+ ## [0.1.1](https://github.com/shko-online/dataverse-odata/compare/v0.1.0...v0.1.1) (2023-02-11)
2
+
3
+
4
+ ### Bug Fixes
5
+
6
+ * improved documentation and type exports ([26c0b2f](https://github.com/shko-online/dataverse-odata/commit/26c0b2f8f6146007ed4f51a03ae64adbd3cf6ca5))
package/README.md ADDED
@@ -0,0 +1,3 @@
1
+ # @shko.online/dataverse-odata
2
+ This package will help parse OData strings (only the Microsoft Dataverse subset). It can be used as a validator, or you can build a javascript library which consumes the output of this library. We are using this to mock the `WebAPI` on the `@shko.online/componentframework-mock` package.
3
+
package/jest.config.ts CHANGED
@@ -1,12 +1,12 @@
1
- import { JestConfigWithTsJest } from 'ts-jest';
2
-
3
- export default {
4
- testMatch: [' **/tests/**/*.[jt]s?(x)', '**/?(*.)+(spec|test).[tj]s?(x)'],
5
- clearMocks: true,
6
- collectCoverage: true,
7
- coverageDirectory: 'coverage',
8
- coverageProvider: 'v8',
9
- preset: 'ts-jest',
10
- testEnvironment: 'jsdom',
11
- coverageReporters: ['cobertura', 'text', 'html']
12
- } as JestConfigWithTsJest;
1
+ import { JestConfigWithTsJest } from 'ts-jest';
2
+
3
+ export default {
4
+ testMatch: [' **/tests/**/*.[jt]s?(x)', '**/?(*.)+(spec|test).[tj]s?(x)'],
5
+ clearMocks: true,
6
+ collectCoverage: true,
7
+ coverageDirectory: 'coverage',
8
+ coverageProvider: 'v8',
9
+ preset: 'ts-jest',
10
+ testEnvironment: 'jsdom',
11
+ coverageReporters: ['cobertura', 'text', 'html']
12
+ } as JestConfigWithTsJest;
@@ -5,9 +5,9 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.getExpandFromParser = void 0;
7
7
  var _getSelectFromParser = require("./getSelectFromParser");
8
- /**
9
- * Parses the $expand query
10
- * @returns Returns true when the parse has an error
8
+ /**
9
+ * Parses the $expand query
10
+ * @returns Returns true when the parse has an error
11
11
  */
12
12
  const getExpandFromParser = (parser, result) => {
13
13
  const $expand = parser.get('$expand');
@@ -4,9 +4,9 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.getFetchXmlFromParser = void 0;
7
- /**
8
- * Parses the $fetchXml query
9
- * @returns Returns true when the parse has an error
7
+ /**
8
+ * Parses the fetchXml query
9
+ * @returns Returns true when the parse has an error
10
10
  */
11
11
  const getFetchXmlFromParser = (parser, result) => {
12
12
  const fetchXml = parser.get('fetchXml');
@@ -4,9 +4,9 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.getSelectFromParser = void 0;
7
- /**
8
- * Parses the $select query
9
- * @returns Returns true when the parse has an error
7
+ /**
8
+ * Parses the $select query
9
+ * @returns Returns true when the parse has an error
10
10
  */
11
11
  const getSelectFromParser = (parser, result) => {
12
12
  const $select = parser.get('$select');
@@ -4,9 +4,9 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.getTopFromParser = void 0;
7
- /**
8
- * Parses the $top query
9
- * @returns Returns true when the parse has an error
7
+ /**
8
+ * Parses the $top query
9
+ * @returns Returns true when the parse has an error
10
10
  */
11
11
  const getTopFromParser = (parser, result) => {
12
12
  const $topValue = parser.get('$top');
@@ -8,6 +8,11 @@ var _getTopFromParser = require("./getTopFromParser");
8
8
  var _getSelectFromParser = require("./getSelectFromParser");
9
9
  var _getExpandFromParser = require("./getExpandFromParser");
10
10
  var _getFetchXmlFromParser = require("./getFetchXmlFromParser");
11
+ /**
12
+ * parses the OData query and applies some Dataverse validations
13
+ * @param query The OData query
14
+ * @returns The parsed OData query
15
+ */
11
16
  const parseOData = query => {
12
17
  const parser = new URLSearchParams(query);
13
18
  const result = {};
@@ -1,8 +1,8 @@
1
1
  import { getSelectFromParser } from './getSelectFromParser';
2
2
 
3
- /**
4
- * Parses the $expand query
5
- * @returns Returns true when the parse has an error
3
+ /**
4
+ * Parses the $expand query
5
+ * @returns Returns true when the parse has an error
6
6
  */
7
7
  export const getExpandFromParser = (parser, result) => {
8
8
  const $expand = parser.get('$expand');
@@ -1,6 +1,6 @@
1
- /**
2
- * Parses the $fetchXml query
3
- * @returns Returns true when the parse has an error
1
+ /**
2
+ * Parses the fetchXml query
3
+ * @returns Returns true when the parse has an error
4
4
  */
5
5
  export const getFetchXmlFromParser = (parser, result) => {
6
6
  const fetchXml = parser.get('fetchXml');
@@ -1,6 +1,6 @@
1
- /**
2
- * Parses the $select query
3
- * @returns Returns true when the parse has an error
1
+ /**
2
+ * Parses the $select query
3
+ * @returns Returns true when the parse has an error
4
4
  */
5
5
  export const getSelectFromParser = (parser, result) => {
6
6
  const $select = parser.get('$select');
@@ -1,6 +1,6 @@
1
- /**
2
- * Parses the $top query
3
- * @returns Returns true when the parse has an error
1
+ /**
2
+ * Parses the $top query
3
+ * @returns Returns true when the parse has an error
4
4
  */
5
5
  export const getTopFromParser = (parser, result) => {
6
6
  const $topValue = parser.get('$top');
@@ -2,6 +2,12 @@ import { getTopFromParser } from './getTopFromParser';
2
2
  import { getSelectFromParser } from './getSelectFromParser';
3
3
  import { getExpandFromParser } from './getExpandFromParser';
4
4
  import { getFetchXmlFromParser } from './getFetchXmlFromParser';
5
+
6
+ /**
7
+ * parses the OData query and applies some Dataverse validations
8
+ * @param query The OData query
9
+ * @returns The parsed OData query
10
+ */
5
11
  export const parseOData = query => {
6
12
  const parser = new URLSearchParams(query);
7
13
  const result = {};
@@ -1,7 +1,7 @@
1
- import type { ODataQuery } from './OData.types';
2
- /**
3
- * Parses the $expand query
4
- * @returns Returns true when the parse has an error
5
- */
6
- export declare const getExpandFromParser: (parser: URLSearchParams, result: ODataQuery) => boolean;
1
+ import type { ODataQuery } from './OData.types';
2
+ /**
3
+ * Parses the $expand query
4
+ * @returns Returns true when the parse has an error
5
+ */
6
+ export declare const getExpandFromParser: (parser: URLSearchParams, result: ODataQuery) => boolean;
7
7
  //# sourceMappingURL=getExpandFromParser.d.ts.map