angular-odata 0.143.0 → 0.144.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/fesm2022/angular-odata.mjs +65 -52
- package/fesm2022/angular-odata.mjs.map +1 -1
- package/package.json +1 -1
- package/types/angular-odata.d.ts +37 -41
|
@@ -107,16 +107,16 @@ var EdmType;
|
|
|
107
107
|
//Edm.GeometryCollection Collection of arbitrary Geometry values
|
|
108
108
|
EdmType["GeometryCollection"] = "Edm.GeometryCollection";
|
|
109
109
|
})(EdmType || (EdmType = {}));
|
|
110
|
-
var
|
|
111
|
-
(function (
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
})(
|
|
110
|
+
var JsonSchemaType;
|
|
111
|
+
(function (JsonSchemaType) {
|
|
112
|
+
JsonSchemaType["string"] = "string";
|
|
113
|
+
JsonSchemaType["number"] = "number";
|
|
114
|
+
JsonSchemaType["integer"] = "integer";
|
|
115
|
+
JsonSchemaType["object"] = "object";
|
|
116
|
+
JsonSchemaType["array"] = "array";
|
|
117
|
+
JsonSchemaType["boolean"] = "boolean";
|
|
118
|
+
JsonSchemaType["null"] = "null";
|
|
119
|
+
})(JsonSchemaType || (JsonSchemaType = {}));
|
|
120
120
|
const NONE_PARSER = {
|
|
121
121
|
deserialize: (value) => value,
|
|
122
122
|
serialize: (value) => value,
|
|
@@ -1168,7 +1168,7 @@ const Durations = {
|
|
|
1168
1168
|
v.months ? v.months + 'M' : '',
|
|
1169
1169
|
v.weeks ? v.weeks + 'W' : '',
|
|
1170
1170
|
v.days ? v.days + 'D' : '',
|
|
1171
|
-
'T',
|
|
1171
|
+
(v.hours || v.minutes || v.seconds) ? 'T' : '',
|
|
1172
1172
|
v.hours ? v.hours + 'H' : '',
|
|
1173
1173
|
v.minutes ? v.minutes + 'M' : '',
|
|
1174
1174
|
v.seconds ? v.seconds + 'S' : '',
|
|
@@ -2131,19 +2131,23 @@ class ODataEnumTypeParser extends ODataAnnotatable {
|
|
|
2131
2131
|
return parserOptions?.stringAsEnum ? raw(`'${serialized}'`) : raw(serialized);
|
|
2132
2132
|
}
|
|
2133
2133
|
// Json Schema
|
|
2134
|
-
toJsonSchema() {
|
|
2135
|
-
|
|
2134
|
+
toJsonSchema(options, parent) {
|
|
2135
|
+
let schema = (this.flags
|
|
2136
2136
|
? {
|
|
2137
2137
|
title: this.name,
|
|
2138
|
-
type:
|
|
2138
|
+
type: JsonSchemaType.array,
|
|
2139
2139
|
items: {
|
|
2140
|
-
type:
|
|
2140
|
+
type: JsonSchemaType.integer,
|
|
2141
2141
|
},
|
|
2142
2142
|
}
|
|
2143
2143
|
: {
|
|
2144
|
-
type:
|
|
2144
|
+
type: JsonSchemaType.integer,
|
|
2145
2145
|
enum: this._fields.map((f) => f.value),
|
|
2146
|
-
};
|
|
2146
|
+
});
|
|
2147
|
+
if (options?.map !== undefined) {
|
|
2148
|
+
schema = options.map(schema, parent);
|
|
2149
|
+
}
|
|
2150
|
+
return schema;
|
|
2147
2151
|
}
|
|
2148
2152
|
validate(value, { method, navigation = false, } = {}) {
|
|
2149
2153
|
if (this.flags) {
|
|
@@ -2305,39 +2309,39 @@ class ODataStructuredTypeFieldParser extends ODataAnnotatable {
|
|
|
2305
2309
|
}
|
|
2306
2310
|
//#region Json Schema
|
|
2307
2311
|
// https://json-schema.org/
|
|
2308
|
-
toJsonSchema(options
|
|
2312
|
+
toJsonSchema(options, parent) {
|
|
2309
2313
|
let schema = this.parser instanceof ODataStructuredTypeFieldParser ||
|
|
2310
2314
|
this.parser instanceof ODataStructuredTypeParser ||
|
|
2311
2315
|
this.parser instanceof ODataEnumTypeParser
|
|
2312
|
-
? this.parser.toJsonSchema(options)
|
|
2313
|
-
: { title: this.name
|
|
2316
|
+
? this.parser.toJsonSchema(options, parent)
|
|
2317
|
+
: { title: this.name };
|
|
2314
2318
|
switch (this.type) {
|
|
2315
2319
|
case EdmType.String:
|
|
2316
|
-
schema.type =
|
|
2320
|
+
schema.type = JsonSchemaType.string;
|
|
2317
2321
|
break;
|
|
2318
2322
|
case EdmType.Guid:
|
|
2319
|
-
schema.type =
|
|
2323
|
+
schema.type = JsonSchemaType.string;
|
|
2320
2324
|
schema.pattern =
|
|
2321
2325
|
'^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$';
|
|
2322
2326
|
break;
|
|
2323
2327
|
case EdmType.Binary:
|
|
2324
|
-
schema.type =
|
|
2328
|
+
schema.type = JsonSchemaType.string;
|
|
2325
2329
|
schema.contentEncoding = 'base64';
|
|
2326
2330
|
break;
|
|
2327
2331
|
case EdmType.Date:
|
|
2328
|
-
schema.type =
|
|
2332
|
+
schema.type = JsonSchemaType.string;
|
|
2329
2333
|
schema.format = 'date';
|
|
2330
2334
|
break;
|
|
2331
2335
|
case EdmType.TimeOfDay:
|
|
2332
|
-
schema.type =
|
|
2336
|
+
schema.type = JsonSchemaType.string;
|
|
2333
2337
|
schema.format = 'time';
|
|
2334
2338
|
break;
|
|
2335
2339
|
case EdmType.DateTimeOffset:
|
|
2336
|
-
schema.type =
|
|
2340
|
+
schema.type = JsonSchemaType.string;
|
|
2337
2341
|
schema.format = 'date-time';
|
|
2338
2342
|
break;
|
|
2339
2343
|
case EdmType.Duration:
|
|
2340
|
-
schema.type =
|
|
2344
|
+
schema.type = JsonSchemaType.string;
|
|
2341
2345
|
schema.format = 'duration';
|
|
2342
2346
|
break;
|
|
2343
2347
|
case EdmType.Byte:
|
|
@@ -2346,15 +2350,15 @@ class ODataStructuredTypeFieldParser extends ODataAnnotatable {
|
|
|
2346
2350
|
case EdmType.Int32:
|
|
2347
2351
|
case EdmType.Int64:
|
|
2348
2352
|
//TODO: Range
|
|
2349
|
-
schema.type =
|
|
2353
|
+
schema.type = JsonSchemaType.integer;
|
|
2350
2354
|
break;
|
|
2351
2355
|
case EdmType.Single:
|
|
2352
2356
|
case EdmType.Double:
|
|
2353
2357
|
case EdmType.Decimal:
|
|
2354
|
-
schema.type =
|
|
2358
|
+
schema.type = JsonSchemaType.number;
|
|
2355
2359
|
break;
|
|
2356
2360
|
case EdmType.Boolean:
|
|
2357
|
-
schema.type =
|
|
2361
|
+
schema.type = JsonSchemaType.boolean;
|
|
2358
2362
|
break;
|
|
2359
2363
|
}
|
|
2360
2364
|
if (this.maxLength)
|
|
@@ -2362,13 +2366,16 @@ class ODataStructuredTypeFieldParser extends ODataAnnotatable {
|
|
|
2362
2366
|
if (this.default)
|
|
2363
2367
|
schema.default = this.default;
|
|
2364
2368
|
if (this.nullable)
|
|
2365
|
-
schema.type = [schema.type,
|
|
2369
|
+
schema.type = [schema.type, JsonSchemaType.null];
|
|
2366
2370
|
if (this.collection)
|
|
2367
2371
|
schema = {
|
|
2368
|
-
type:
|
|
2372
|
+
type: JsonSchemaType.array,
|
|
2369
2373
|
items: schema,
|
|
2370
2374
|
additionalItems: false,
|
|
2371
2375
|
};
|
|
2376
|
+
if (options?.map !== undefined) {
|
|
2377
|
+
schema = options.map(schema, parent);
|
|
2378
|
+
}
|
|
2372
2379
|
return schema;
|
|
2373
2380
|
}
|
|
2374
2381
|
//#endregion
|
|
@@ -2627,40 +2634,43 @@ class ODataStructuredTypeParser extends ODataAnnotatable {
|
|
|
2627
2634
|
};
|
|
2628
2635
|
}
|
|
2629
2636
|
// Json Schema
|
|
2630
|
-
toJsonSchema(options
|
|
2637
|
+
toJsonSchema(options, parent) {
|
|
2631
2638
|
let schema = {
|
|
2632
2639
|
$schema: 'http://json-schema.org/draft-07/schema#',
|
|
2633
2640
|
$id: `${this.namespace}.${this.name}`,
|
|
2634
2641
|
title: this.titleize(DESCRIPTION),
|
|
2635
2642
|
description: this.annotatedValue(LONG_DESCRIPTION),
|
|
2636
|
-
type:
|
|
2643
|
+
type: JsonSchemaType.object,
|
|
2637
2644
|
properties: {},
|
|
2638
2645
|
required: [],
|
|
2639
2646
|
};
|
|
2640
2647
|
const fields = this.fields({
|
|
2641
2648
|
include_navigation: true,
|
|
2642
2649
|
include_parents: true,
|
|
2643
|
-
}).filter((f) => (!f.navigation || (options
|
|
2644
|
-
(!options
|
|
2645
|
-
schema.properties = Object.assign({}, schema.properties, fields
|
|
2646
|
-
.map((f) => {
|
|
2647
|
-
let expand = options.expand && f.name in options.expand
|
|
2648
|
-
? options.expand[f.name]
|
|
2649
|
-
: undefined;
|
|
2650
|
-
let schema = f.toJsonSchema(expand);
|
|
2651
|
-
if (options.custom && f.name in options.custom)
|
|
2652
|
-
schema = options.custom[f.name](schema, f);
|
|
2653
|
-
return { [f.name]: schema };
|
|
2654
|
-
})
|
|
2655
|
-
.reduce((acc, v) => Object.assign(acc, v), {}));
|
|
2650
|
+
}).filter((f) => (!f.navigation || (options?.expand && f.name in options?.expand)) &&
|
|
2651
|
+
(!options?.select || (options?.select).indexOf(f.name) !== -1));
|
|
2656
2652
|
schema.required = [
|
|
2657
|
-
...schema.required,
|
|
2653
|
+
...(schema.required ?? []),
|
|
2658
2654
|
...fields
|
|
2659
|
-
.filter((f) => options
|
|
2660
|
-
? options
|
|
2655
|
+
.filter((f) => options?.required && f.name in options?.required
|
|
2656
|
+
? options?.required[f.name]
|
|
2661
2657
|
: !f.nullable)
|
|
2662
2658
|
.map((f) => f.name),
|
|
2663
2659
|
];
|
|
2660
|
+
schema.properties = Object.assign({}, schema.properties, fields
|
|
2661
|
+
.map((f) => {
|
|
2662
|
+
let expand = options?.expand && f.name in options?.expand
|
|
2663
|
+
? (options?.expand)[f.name]
|
|
2664
|
+
: undefined;
|
|
2665
|
+
let child = f.toJsonSchema({ ...expand, map: options?.map }, schema);
|
|
2666
|
+
if (options?.custom && f.name in options?.custom)
|
|
2667
|
+
child = (options?.custom[f.name])(child, f);
|
|
2668
|
+
return { [f.name]: child };
|
|
2669
|
+
})
|
|
2670
|
+
.reduce((acc, v) => Object.assign(acc, v), {}));
|
|
2671
|
+
if (options?.map !== undefined) {
|
|
2672
|
+
schema = options.map(schema, parent);
|
|
2673
|
+
}
|
|
2664
2674
|
return schema;
|
|
2665
2675
|
}
|
|
2666
2676
|
validate(attrs, { method, navigation = false, } = {}) {
|
|
@@ -3157,7 +3167,7 @@ class ODataStructuredType extends ODataParserSchemaElement {
|
|
|
3157
3167
|
* @param options Options for json schema
|
|
3158
3168
|
* @returns Json Schema
|
|
3159
3169
|
*/
|
|
3160
|
-
toJsonSchema(options
|
|
3170
|
+
toJsonSchema(options) {
|
|
3161
3171
|
return this.parser.toJsonSchema(options);
|
|
3162
3172
|
}
|
|
3163
3173
|
/**
|
|
@@ -12000,6 +12010,9 @@ class ODataModelOptions {
|
|
|
12000
12010
|
isTypeOf(type) {
|
|
12001
12011
|
return this.structuredType.type() === type;
|
|
12002
12012
|
}
|
|
12013
|
+
toJsonSchema(options) {
|
|
12014
|
+
return this.structuredType.toJsonSchema(options);
|
|
12015
|
+
}
|
|
12003
12016
|
isModelFor(entity) {
|
|
12004
12017
|
// Resolve By Type
|
|
12005
12018
|
const type = this.api.options.helper.type(entity);
|
|
@@ -14148,5 +14161,5 @@ class ODataInStorageCache extends ODataBaseCache {
|
|
|
14148
14161
|
* Generated bundle index. Do not edit.
|
|
14149
14162
|
*/
|
|
14150
14163
|
|
|
14151
|
-
export { Aggregate, ApplyExpression, ArithmeticFunctions, ArithmeticOperators, BUBBLES, CollectionFunctions, ComputeExpression, ConditionalFunctions, DateAndTimeFunctions, Dates, Durations, EDM_PARSERS, EdmType, Enums, ExpandExpression, ExpandField, Expression, FieldFactory, FilterExpression, Function, GeoFunctions, GroupBy, GroupByTransformations, Grouping, GroupingOperators, Http, INCLUDE_DEEP, INCLUDE_SHALLOW, ITEM_ROOT,
|
|
14164
|
+
export { Aggregate, ApplyExpression, ArithmeticFunctions, ArithmeticOperators, BUBBLES, CollectionFunctions, ComputeExpression, ConditionalFunctions, DateAndTimeFunctions, Dates, Durations, EDM_PARSERS, EdmType, Enums, ExpandExpression, ExpandField, Expression, FieldFactory, FilterExpression, Function, GeoFunctions, GroupBy, GroupByTransformations, Grouping, GroupingOperators, Http, INCLUDE_DEEP, INCLUDE_SHALLOW, ITEM_ROOT, JsonSchemaType, Lambda, LambdaOperators, LogicalOperators, Model, ModelField, NONE_PARSER, ODATA_CONFIG, OData, ODataActionResource, ODataAnnotations, ODataApi, ODataBaseCache, ODataBaseService, ODataBatchRequest, ODataBatchResource, ODataCallable, ODataCallableParser, ODataClient, ODataCollection, ODataConfigAsyncLoader, ODataConfigLoader, ODataConfigSyncLoader, ODataCountResource, ODataEntitiesAnnotations, ODataEntityAnnotations, ODataEntityContainer, ODataEntityResource, ODataEntitySet, ODataEntitySetResource, ODataEntitySetService, ODataEntityTypeKey, ODataEnumType, ODataEnumTypeFieldParser, ODataEnumTypeParser, ODataFunctionResource, ODataFunctions, ODataInMemoryCache, ODataInStorageCache, ODataMediaResource, ODataMetadata, ODataMetadataLoader, ODataMetadataParser, ODataMetadataResource, ODataModel, ODataModelAttribute, ODataModelEvent, ODataModelEventEmitter, ODataModelEventType, ODataModelField, ODataModelOptions, ODataModelState, ODataModule, ODataNavigationPropertyResource, ODataOperators, ODataParameterParser, ODataPathSegments, ODataPathSegmentsHandler, ODataPropertyAnnotations, ODataPropertyResource, ODataQueryOptionHandler, ODataQueryOptions, ODataQueryOptionsHandler, ODataReferenceResource, ODataReferential, ODataRequest, ODataResource, ODataResponse, ODataSchema, ODataServiceFactory, ODataSettings, ODataSingleton, ODataSingletonResource, ODataSingletonService, ODataStructuredType, ODataStructuredTypeFieldParser, ODataStructuredTypeParser, ODataSyntax, ODataTransformations, ODataValueResource, Objects, Operator, OrderByExpression, OrderByField, PathSegment, QueryCustomTypes, QueryOption, RenderableFactory, SearchExpression, SearchTerm, SegmentHandler, SelectExpression, StandardAggregateMethods, StringAndCollectionFunctions, StringFunctions, Strings, Transformations, Type, TypeFunctions, Types, Urls, alias, binary, buildPathAndQuery, createSyncLoader, duration, encode, functions, isQueryCustomType, isRawType, normalizeValue, operators, pathAndParamsFromQueryOptions, pathAndParamsFromSegments, provideODataClient, raw, render, resolve, syntax, transformations };
|
|
14152
14165
|
//# sourceMappingURL=angular-odata.mjs.map
|