angular-odata 0.99.5 → 0.100.0
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/esm2020/lib/api.mjs +2 -2
- package/esm2020/lib/models/options.mjs +1 -1
- package/esm2020/lib/options.mjs +4 -3
- package/esm2020/lib/resources/query/builder.mjs +3 -6
- package/esm2020/lib/resources/resource.mjs +22 -61
- package/esm2020/lib/resources/responses/options.mjs +1 -2
- package/esm2020/lib/resources/types/entity-set.mjs +1 -1
- package/esm2020/lib/resources/types/function.mjs +8 -1
- package/esm2020/lib/schema/callable.mjs +6 -2
- package/esm2020/lib/schema/enum-type.mjs +2 -2
- package/esm2020/lib/schema/parsers/callable.mjs +3 -2
- package/esm2020/lib/schema/parsers/enum-type.mjs +6 -5
- package/esm2020/lib/schema/parsers/structured-type.mjs +1 -1
- package/esm2020/lib/schema/structured-type.mjs +1 -1
- package/esm2020/lib/types.mjs +1 -1
- package/fesm2015/angular-odata.mjs +46 -75
- package/fesm2015/angular-odata.mjs.map +1 -1
- package/fesm2020/angular-odata.mjs +46 -75
- package/fesm2020/angular-odata.mjs.map +1 -1
- package/lib/models/options.d.ts +4 -4
- package/lib/options.d.ts +4 -4
- package/lib/resources/resource.d.ts +1 -0
- package/lib/resources/responses/options.d.ts +2 -3
- package/lib/resources/types/entity-set.d.ts +1 -1
- package/lib/resources/types/function.d.ts +3 -0
- package/lib/schema/callable.d.ts +4 -4
- package/lib/schema/enum-type.d.ts +4 -4
- package/lib/schema/parsers/callable.d.ts +9 -7
- package/lib/schema/parsers/enum-type.d.ts +7 -5
- package/lib/schema/parsers/structured-type.d.ts +7 -7
- package/lib/schema/structured-type.d.ts +4 -4
- package/lib/types.d.ts +5 -5
- package/package.json +1 -1
|
@@ -391,7 +391,7 @@ function buildPathAndQuery({ select, search, skiptoken, format, top, skip, filte
|
|
|
391
391
|
}
|
|
392
392
|
if (func) {
|
|
393
393
|
if (typeof func === 'string') {
|
|
394
|
-
path += `/${func}`;
|
|
394
|
+
path += `/${func}()`;
|
|
395
395
|
}
|
|
396
396
|
else if (typeof func === 'object') {
|
|
397
397
|
const [funcName] = Object.keys(func);
|
|
@@ -399,10 +399,7 @@ function buildPathAndQuery({ select, search, skiptoken, format, top, skip, filte
|
|
|
399
399
|
aliases,
|
|
400
400
|
escape,
|
|
401
401
|
});
|
|
402
|
-
path += `/${funcName}`;
|
|
403
|
-
if (funcArgs !== '') {
|
|
404
|
-
path += `(${funcArgs})`;
|
|
405
|
-
}
|
|
402
|
+
path += `/${funcName}(${funcArgs})`;
|
|
406
403
|
}
|
|
407
404
|
}
|
|
408
405
|
if (aliases.length > 0) {
|
|
@@ -3530,7 +3527,7 @@ class ODataApiOptions {
|
|
|
3530
3527
|
constructor(config) {
|
|
3531
3528
|
this.etag = { ifMatch: true, ifNoneMatch: false };
|
|
3532
3529
|
this.version = config.version || DEFAULT_VERSION;
|
|
3533
|
-
this.stringAsEnum = config.stringAsEnum;
|
|
3530
|
+
this.stringAsEnum = config.stringAsEnum || false;
|
|
3534
3531
|
this.params = config.params || {};
|
|
3535
3532
|
this.headers = config.headers || {};
|
|
3536
3533
|
this.withCredentials = config.withCredentials;
|
|
@@ -3541,6 +3538,8 @@ class ODataApiOptions {
|
|
|
3541
3538
|
Object.assign(this.etag, config.etag || {});
|
|
3542
3539
|
this.prefer = config.prefer;
|
|
3543
3540
|
this.deleteRefBy = config.deleteRefBy || 'path';
|
|
3541
|
+
this.nonParenthesisForEmptyParameterFunction =
|
|
3542
|
+
config.nonParenthesisForEmptyParameterFunction || false;
|
|
3544
3543
|
}
|
|
3545
3544
|
get helper() {
|
|
3546
3545
|
return ODataHelper[this.version];
|
|
@@ -3549,7 +3548,6 @@ class ODataApiOptions {
|
|
|
3549
3548
|
class ODataParserOptions {
|
|
3550
3549
|
constructor(config) {
|
|
3551
3550
|
this.version = config.version || DEFAULT_VERSION;
|
|
3552
|
-
this.stringAsEnum = config.stringAsEnum;
|
|
3553
3551
|
}
|
|
3554
3552
|
get helper() {
|
|
3555
3553
|
return ODataHelper[this.version];
|
|
@@ -3585,7 +3583,8 @@ class ODataEnumTypeParser extends ODataAnnotatable {
|
|
|
3585
3583
|
ttitelize(term) {
|
|
3586
3584
|
return (term && this.annotatedValue(term)) || Strings.titleCase(this.name);
|
|
3587
3585
|
}
|
|
3588
|
-
configure({ options }) {
|
|
3586
|
+
configure({ stringAsEnum, options }) {
|
|
3587
|
+
this.stringAsEnum = stringAsEnum;
|
|
3589
3588
|
this.optionsHelper = options;
|
|
3590
3589
|
}
|
|
3591
3590
|
isTypeOf(type) {
|
|
@@ -3616,13 +3615,13 @@ class ODataEnumTypeParser extends ODataAnnotatable {
|
|
|
3616
3615
|
: this.optionsHelper;
|
|
3617
3616
|
if (this.flags) {
|
|
3618
3617
|
const names = Enums.toNames(this.members, value);
|
|
3619
|
-
return !
|
|
3618
|
+
return !this.stringAsEnum
|
|
3620
3619
|
? `${this.namespace}.${this.name}'${names.join(', ')}'`
|
|
3621
3620
|
: names.join(', ');
|
|
3622
3621
|
}
|
|
3623
3622
|
else {
|
|
3624
3623
|
const name = Enums.toName(this.members, value);
|
|
3625
|
-
return !
|
|
3624
|
+
return !this.stringAsEnum
|
|
3626
3625
|
? `${this.namespace}.${this.name}'${name}'`
|
|
3627
3626
|
: name;
|
|
3628
3627
|
}
|
|
@@ -3633,7 +3632,7 @@ class ODataEnumTypeParser extends ODataAnnotatable {
|
|
|
3633
3632
|
? new ODataParserOptions(options)
|
|
3634
3633
|
: this.optionsHelper;
|
|
3635
3634
|
const serialized = this.serialize(value, parserOptions);
|
|
3636
|
-
return
|
|
3635
|
+
return this.stringAsEnum
|
|
3637
3636
|
? raw(`'${serialized}'`)
|
|
3638
3637
|
: raw(serialized);
|
|
3639
3638
|
}
|
|
@@ -4161,7 +4160,8 @@ class ODataCallableParser {
|
|
|
4161
4160
|
[p.name]: p.encode(params[p.name], parserOptions),
|
|
4162
4161
|
}), {});
|
|
4163
4162
|
}
|
|
4164
|
-
configure({ parserForType, options, }) {
|
|
4163
|
+
configure({ nonParenthesisForEmptyParameterFunction, parserForType, options, }) {
|
|
4164
|
+
this.nonParenthesisForEmptyParameterFunction = nonParenthesisForEmptyParameterFunction;
|
|
4165
4165
|
this.optionsHelper = options;
|
|
4166
4166
|
if (this.return)
|
|
4167
4167
|
this.parser = parserForType(this.return.type) || NONE_PARSER;
|
|
@@ -4194,7 +4194,11 @@ class ODataCallable extends ODataSchemaElement {
|
|
|
4194
4194
|
return path;
|
|
4195
4195
|
}
|
|
4196
4196
|
configure({ parserForType, }) {
|
|
4197
|
-
this.parser.configure({
|
|
4197
|
+
this.parser.configure({
|
|
4198
|
+
nonParenthesisForEmptyParameterFunction: this.api.options.nonParenthesisForEmptyParameterFunction,
|
|
4199
|
+
options: this.api.options,
|
|
4200
|
+
parserForType
|
|
4201
|
+
});
|
|
4198
4202
|
}
|
|
4199
4203
|
/**
|
|
4200
4204
|
* Deseialize the given value from the callable.
|
|
@@ -4254,7 +4258,7 @@ class ODataEnumType extends ODataSchemaElement {
|
|
|
4254
4258
|
this.parser = new ODataEnumTypeParser(config, schema.namespace, schema.alias);
|
|
4255
4259
|
}
|
|
4256
4260
|
configure() {
|
|
4257
|
-
this.parser.configure({ options: this.api.options });
|
|
4261
|
+
this.parser.configure({ stringAsEnum: this.api.options.stringAsEnum, options: this.api.options });
|
|
4258
4262
|
}
|
|
4259
4263
|
/**
|
|
4260
4264
|
* Returns the fields of the enum type.
|
|
@@ -4694,29 +4698,28 @@ class ODataResource {
|
|
|
4694
4698
|
query: this.cloneQuery(),
|
|
4695
4699
|
});
|
|
4696
4700
|
}
|
|
4701
|
+
__parser(value, options, type) {
|
|
4702
|
+
const dataType = options !== undefined && Types.isPlainObject(value)
|
|
4703
|
+
? options.helper.type(value)
|
|
4704
|
+
: undefined;
|
|
4705
|
+
if (dataType !== undefined) {
|
|
4706
|
+
// Parser from data type
|
|
4707
|
+
return this.api.parserForType(dataType);
|
|
4708
|
+
}
|
|
4709
|
+
else if (this.schema !== undefined && 'parser' in this.schema) {
|
|
4710
|
+
// Parser from resource schema
|
|
4711
|
+
return this.schema.parser;
|
|
4712
|
+
}
|
|
4713
|
+
else if (type !== undefined) {
|
|
4714
|
+
// Parser from resource type
|
|
4715
|
+
return this.api.parserForType(type);
|
|
4716
|
+
}
|
|
4717
|
+
return undefined;
|
|
4718
|
+
}
|
|
4697
4719
|
deserialize(value, options) {
|
|
4698
4720
|
const resourceType = this.returnType();
|
|
4699
|
-
const resourceSchema = this.schema;
|
|
4700
|
-
const _p = (value, options) => {
|
|
4701
|
-
const dataType = Types.isPlainObject(value)
|
|
4702
|
-
? options.helper.type(value)
|
|
4703
|
-
: undefined;
|
|
4704
|
-
if (dataType !== undefined) {
|
|
4705
|
-
// Parser from data type
|
|
4706
|
-
return this.api.parserForType(dataType);
|
|
4707
|
-
}
|
|
4708
|
-
else if (resourceSchema !== undefined && 'parser' in resourceSchema) {
|
|
4709
|
-
// Parser from resource schema
|
|
4710
|
-
return resourceSchema.parser;
|
|
4711
|
-
}
|
|
4712
|
-
else if (resourceType !== undefined) {
|
|
4713
|
-
// Parser from resource type
|
|
4714
|
-
return this.api.parserForType(resourceType);
|
|
4715
|
-
}
|
|
4716
|
-
return undefined;
|
|
4717
|
-
};
|
|
4718
4721
|
const _d = (value, options) => {
|
|
4719
|
-
const parser =
|
|
4722
|
+
const parser = this.__parser(value, options, resourceType);
|
|
4720
4723
|
return parser !== undefined && 'deserialize' in parser
|
|
4721
4724
|
? parser.deserialize(value, options)
|
|
4722
4725
|
: value;
|
|
@@ -4727,27 +4730,8 @@ class ODataResource {
|
|
|
4727
4730
|
}
|
|
4728
4731
|
serialize(value, options) {
|
|
4729
4732
|
const resourceType = this.type();
|
|
4730
|
-
const resourceSchema = this.schema;
|
|
4731
|
-
const _p = (value, options) => {
|
|
4732
|
-
const dataType = Types.isPlainObject(value)
|
|
4733
|
-
? options.helper.type(value)
|
|
4734
|
-
: undefined;
|
|
4735
|
-
if (dataType !== undefined) {
|
|
4736
|
-
// Parser from data type
|
|
4737
|
-
return this.api.parserForType(dataType);
|
|
4738
|
-
}
|
|
4739
|
-
else if (resourceSchema !== undefined && 'parser' in resourceSchema) {
|
|
4740
|
-
// Parser from resource schema
|
|
4741
|
-
return resourceSchema.parser;
|
|
4742
|
-
}
|
|
4743
|
-
else if (resourceType !== undefined) {
|
|
4744
|
-
// Parser from resource type
|
|
4745
|
-
return this.api.parserForType(resourceType);
|
|
4746
|
-
}
|
|
4747
|
-
return undefined;
|
|
4748
|
-
};
|
|
4749
4733
|
const _s = (value, options) => {
|
|
4750
|
-
const parser =
|
|
4734
|
+
const parser = this.__parser(value, options, resourceType);
|
|
4751
4735
|
return parser !== undefined && 'serialize' in parser
|
|
4752
4736
|
? parser.serialize(value, options)
|
|
4753
4737
|
: value;
|
|
@@ -4758,27 +4742,8 @@ class ODataResource {
|
|
|
4758
4742
|
}
|
|
4759
4743
|
encode(value, options) {
|
|
4760
4744
|
const resourceType = this.type();
|
|
4761
|
-
const resourceSchema = this.schema;
|
|
4762
|
-
const _p = (value, options) => {
|
|
4763
|
-
const dataType = Types.isPlainObject(value)
|
|
4764
|
-
? options.helper.type(value)
|
|
4765
|
-
: undefined;
|
|
4766
|
-
if (dataType !== undefined) {
|
|
4767
|
-
// Parser from data type
|
|
4768
|
-
return this.api.parserForType(dataType);
|
|
4769
|
-
}
|
|
4770
|
-
else if (resourceSchema !== undefined && 'parser' in resourceSchema) {
|
|
4771
|
-
// Parser from resource schema
|
|
4772
|
-
return resourceSchema.parser;
|
|
4773
|
-
}
|
|
4774
|
-
else if (resourceType !== undefined) {
|
|
4775
|
-
// Parser from resource type
|
|
4776
|
-
return this.api.parserForType(resourceType);
|
|
4777
|
-
}
|
|
4778
|
-
return undefined;
|
|
4779
|
-
};
|
|
4780
4745
|
const _e = (value, options) => {
|
|
4781
|
-
const parser =
|
|
4746
|
+
const parser = this.__parser(value, options, resourceType);
|
|
4782
4747
|
return parser !== undefined && 'encode' in parser
|
|
4783
4748
|
? parser.encode(value, options)
|
|
4784
4749
|
: value;
|
|
@@ -5116,7 +5081,6 @@ class ODataEntitiesAnnotations extends ODataAnnotations {
|
|
|
5116
5081
|
class ODataResponseOptions {
|
|
5117
5082
|
constructor(config) {
|
|
5118
5083
|
this.version = config.version || DEFAULT_VERSION;
|
|
5119
|
-
this.stringAsEnum = config.stringAsEnum;
|
|
5120
5084
|
}
|
|
5121
5085
|
get helper() {
|
|
5122
5086
|
return ODataHelper[this.version];
|
|
@@ -6499,6 +6463,13 @@ class ODataFunctionResource extends ODataResource {
|
|
|
6499
6463
|
? this.schema.parser.return?.type
|
|
6500
6464
|
: undefined;
|
|
6501
6465
|
}
|
|
6466
|
+
pathAndParams(escape = false) {
|
|
6467
|
+
let [path, params] = super.pathAndParams(escape);
|
|
6468
|
+
if (path.endsWith('()') && this.api.options.nonParenthesisForEmptyParameterFunction) {
|
|
6469
|
+
path = path.substring(0, path.length - 2);
|
|
6470
|
+
}
|
|
6471
|
+
return [path, params];
|
|
6472
|
+
}
|
|
6502
6473
|
parameters(params, { alias } = {}) {
|
|
6503
6474
|
let parameters = params !== null ? this.encode(params) : null;
|
|
6504
6475
|
if (alias && parameters !== null) {
|