@balena/odata-parser 3.1.0 → 3.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.
- package/.versionbot/CHANGELOG.yml +19 -1
- package/CHANGELOG.md +6 -0
- package/odata-parser.js +476 -503
- package/odata-parser.pegjs +25 -16
- package/package.json +2 -2
- package/test/expand.js +27 -1
- package/test/resource_parsing.js +4 -0
package/odata-parser.pegjs
CHANGED
|
@@ -420,12 +420,16 @@ ResourceMethodCall =
|
|
|
420
420
|
PropertyPathList =
|
|
421
421
|
PropertyPath|1..,','|
|
|
422
422
|
PropertyPath =
|
|
423
|
-
|
|
424
|
-
|
|
423
|
+
result:(
|
|
424
|
+
name:ResourceName
|
|
425
|
+
{ return { name } }
|
|
426
|
+
)
|
|
427
|
+
(
|
|
425
428
|
'/'
|
|
426
|
-
|
|
429
|
+
property:PropertyPath
|
|
430
|
+
{ result.property = property }
|
|
427
431
|
)?
|
|
428
|
-
|
|
432
|
+
(
|
|
429
433
|
'/$count'
|
|
430
434
|
optionsObj:(
|
|
431
435
|
'('
|
|
@@ -435,30 +439,35 @@ PropertyPath =
|
|
|
435
439
|
)
|
|
436
440
|
')'
|
|
437
441
|
)?
|
|
438
|
-
{
|
|
442
|
+
{ result.count = true; result.options = optionsObj }
|
|
439
443
|
)?
|
|
440
|
-
{ return
|
|
444
|
+
{ return result }
|
|
441
445
|
ExpandPropertyPathList =
|
|
442
446
|
ExpandPropertyPath|1..,','|
|
|
443
447
|
ExpandPropertyPath =
|
|
444
|
-
|
|
445
|
-
|
|
448
|
+
result:(
|
|
449
|
+
name:ResourceName
|
|
450
|
+
{ return { name } }
|
|
451
|
+
)
|
|
452
|
+
(
|
|
446
453
|
'/$count'
|
|
447
|
-
{
|
|
454
|
+
{ result.count = true }
|
|
448
455
|
)?
|
|
449
|
-
|
|
456
|
+
(
|
|
450
457
|
'('
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
458
|
+
(
|
|
459
|
+
options:QueryOption|1..,[&;]|
|
|
460
|
+
{ result.options = CollapseObjectArray(options) }
|
|
461
|
+
/ ''
|
|
454
462
|
)
|
|
455
463
|
')'
|
|
456
464
|
)?
|
|
457
|
-
|
|
465
|
+
(
|
|
458
466
|
'/'
|
|
459
|
-
|
|
467
|
+
next:PropertyPath
|
|
468
|
+
{ result.property = next }
|
|
460
469
|
)?
|
|
461
|
-
{ return
|
|
470
|
+
{ return result }
|
|
462
471
|
|
|
463
472
|
LambdaPropertyPath =
|
|
464
473
|
resource:ResourceName
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@balena/odata-parser",
|
|
3
|
-
"version": "3.1.
|
|
3
|
+
"version": "3.1.1",
|
|
4
4
|
"description": "An OData parser written in OMeta",
|
|
5
5
|
"main": "odata-parser.js",
|
|
6
6
|
"scripts": {
|
|
@@ -39,6 +39,6 @@
|
|
|
39
39
|
"npm": ">=8.1.0"
|
|
40
40
|
},
|
|
41
41
|
"versionist": {
|
|
42
|
-
"publishedAt": "2024-10-
|
|
42
|
+
"publishedAt": "2024-10-04T15:26:18.354Z"
|
|
43
43
|
}
|
|
44
44
|
}
|
package/test/expand.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import * as assert from 'assert';
|
|
2
|
+
import { expect } from 'chai';
|
|
2
3
|
import $test from './test';
|
|
3
4
|
import filterby from './filterby';
|
|
4
5
|
import format from './format';
|
|
@@ -23,18 +24,43 @@ const testExpands = function (test, nested = 1) {
|
|
|
23
24
|
'Suppliers',
|
|
24
25
|
);
|
|
25
26
|
});
|
|
27
|
+
it('should not have a nested property on Suppliers', () => {
|
|
28
|
+
expect(
|
|
29
|
+
result.options.$expand.properties[0].property,
|
|
30
|
+
).to.not.have.property('property');
|
|
31
|
+
});
|
|
26
32
|
});
|
|
27
33
|
|
|
28
|
-
test('$expand=Products,Suppliers', function (result) {
|
|
34
|
+
test('$expand=Products,Suppliers()', function (result) {
|
|
29
35
|
it('has an $expand value', () => {
|
|
30
36
|
assert.notEqual(result.options.$expand, null);
|
|
31
37
|
});
|
|
32
38
|
it('has a resource of Products', () => {
|
|
33
39
|
assert.equal(result.options.$expand.properties[0].name, 'Products');
|
|
34
40
|
});
|
|
41
|
+
it('not have count set on Products', () => {
|
|
42
|
+
expect(result.options.$expand.properties[0]).to.not.have.property(
|
|
43
|
+
'count',
|
|
44
|
+
);
|
|
45
|
+
});
|
|
46
|
+
it('not have options set on Products', () => {
|
|
47
|
+
expect(result.options.$expand.properties[0]).to.not.have.property(
|
|
48
|
+
'options',
|
|
49
|
+
);
|
|
50
|
+
});
|
|
51
|
+
it('should not have a nested property on Products', () => {
|
|
52
|
+
expect(result.options.$expand.properties[0]).to.not.have.property(
|
|
53
|
+
'property',
|
|
54
|
+
);
|
|
55
|
+
});
|
|
35
56
|
it('has a resource of Suppliers', () => {
|
|
36
57
|
assert.equal(result.options.$expand.properties[1].name, 'Suppliers');
|
|
37
58
|
});
|
|
59
|
+
it('not have options set on Suppliers', () => {
|
|
60
|
+
expect(result.options.$expand.properties[1]).to.not.have.property(
|
|
61
|
+
'options',
|
|
62
|
+
);
|
|
63
|
+
});
|
|
38
64
|
});
|
|
39
65
|
|
|
40
66
|
test('$expand=Products/$count', function (result) {
|
package/test/resource_parsing.js
CHANGED
|
@@ -282,6 +282,10 @@ describe('Resource Parsing', function () {
|
|
|
282
282
|
assert.equal(result.options.$filter[1].name, 'id');
|
|
283
283
|
});
|
|
284
284
|
|
|
285
|
+
it('lhr should not have a property', () => {
|
|
286
|
+
expect(result.options.$filter[1]).to.not.have.property('property');
|
|
287
|
+
});
|
|
288
|
+
|
|
285
289
|
it('rhr should be $0', () => {
|
|
286
290
|
assert.equal(result.options.$filter[2].bind, 0);
|
|
287
291
|
});
|