angular-odata 0.146.1 → 0.147.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "angular-odata",
3
- "version": "0.146.1",
3
+ "version": "0.147.0",
4
4
  "license": "MIT",
5
5
  "description": "Client side OData typescript library for Angular",
6
6
  "repository": {
@@ -1,7 +1,7 @@
1
1
  import * as json_schema from 'json-schema';
2
2
  import { JSONSchema7 } from 'json-schema';
3
3
  import { Observable, Subject, Subscription } from 'rxjs';
4
- import { HttpContext, HttpHeaders, HttpParams, HttpResponseBase, HttpErrorResponse, HttpResponse, HttpClient, HttpEvent } from '@angular/common/http';
4
+ import { HttpContext, HttpHeaders, HttpParams, HttpResponseBase, HttpErrorResponse, HttpResponse, HttpEvent, HttpClient } from '@angular/common/http';
5
5
  import * as angular_odata from 'angular-odata';
6
6
  import * as i0 from '@angular/core';
7
7
  import { EventEmitter, Provider, InjectionToken, EnvironmentProviders, ModuleWithProviders } from '@angular/core';
@@ -3804,8 +3804,8 @@ declare class ODataModel<T> {
3804
3804
  asEntity<R>(ctx: (model: this) => R): R;
3805
3805
  callFunction<P, R>(name: string, params: P | null, responseType: 'property' | 'model' | 'collection' | 'none' | 'blob' | 'arraybuffer', options?: ODataFunctionOptions<R>): Observable<R | ODataModel<R> | ODataCollection<R, ODataModel<R>> | null | Blob | ArrayBuffer>;
3806
3806
  callAction<P, R>(name: string, params: P | null, responseType?: 'property' | 'model' | 'collection' | 'none' | 'blob' | 'arraybuffer', { ...options }?: {} & ODataActionOptions<R>): Observable<R | ODataModel<R> | ODataCollection<R, ODataModel<R>> | null | Blob | ArrayBuffer>;
3807
- cast<S>(type: string, ModelType?: typeof ODataModel): ODataModel<T> & ModelInterface<T>;
3808
- cast<S, M extends ODataModel<S>>(type: string, ModelType?: typeof ODataModel): M;
3807
+ cast<S>(type: string, ModelType?: typeof ODataModel<S>): ODataModel<S> & ModelInterface<S>;
3808
+ cast<S, M extends ODataModel<S>>(type: string, ModelType?: typeof ODataModel<S>): M;
3809
3809
  fetchNavigationProperty<S>(name: keyof T | string, responseType: 'model' | 'collection', options?: ODataQueryArgumentsOptions<S>): Observable<ODataModel<S> | ODataCollection<S, ODataModel<S>> | null>;
3810
3810
  fetchAttribute<P>(name: keyof T, options?: ODataQueryArgumentsOptions<P>): Observable<P | ODataModel<P> | ODataCollection<P, ODataModel<P>> | null>;
3811
3811
  getAttribute<P>(name: keyof T | string): P | ODataModel<P> | ODataCollection<P, ODataModel<P>> | null;
@@ -4047,13 +4047,13 @@ declare class ODataStructuredType<T> extends ODataParserSchemaElement<T, ODataSt
4047
4047
  * @returns The schema that matches the predicate.
4048
4048
  */
4049
4049
  findParentSchema(predicate: (p: ODataStructuredType<any>) => boolean): ODataStructuredType<any> | undefined;
4050
- findChildSchema(predicate: (p: ODataStructuredType<any>) => boolean): ODataStructuredType<any> | undefined;
4051
4050
  /**
4052
4051
  * Find a parent schema of the structured type for the given field.
4053
4052
  * @param field Field that belongs to the structured type
4054
4053
  * @returns The schema of the field
4055
4054
  */
4056
4055
  findParentSchemaForField<E>(field: ODataStructuredTypeFieldParser<any>): ODataStructuredType<E>;
4056
+ findChildSchema(predicate: (p: ODataStructuredType<any>) => boolean): ODataStructuredType<any> | undefined;
4057
4057
  /**
4058
4058
  * Picks the fields from attributes.
4059
4059
  * @param attrs
@@ -4284,11 +4284,6 @@ declare class ODataModelField<F> {
4284
4284
  field: string;
4285
4285
  parser: ODataStructuredTypeFieldParser<F>;
4286
4286
  options: ODataModelOptions<any>;
4287
- optionsForType?: (type: string) => ODataModelOptions<any> | undefined;
4288
- modelForType?: (t: string) => typeof ODataModel<any> | undefined;
4289
- collectionForType?: (t: string) => typeof ODataCollection<any, ODataModel<any>> | undefined;
4290
- enumForType?: (t: string) => ODataEnumType<F> | undefined;
4291
- structuredForType?: (t: string) => ODataStructuredType<F> | undefined;
4292
4287
  default?: any;
4293
4288
  required: boolean;
4294
4289
  concurrency: boolean;
@@ -4303,12 +4298,7 @@ declare class ODataModelField<F> {
4303
4298
  get navigation(): boolean;
4304
4299
  get collection(): boolean;
4305
4300
  annotatedValue<T>(term: string | RegExp): T | undefined;
4306
- configure({ optionsForType, modelForType, collectionForType, enumForType, structuredForType, concurrency, options, }: {
4307
- optionsForType: (type: string) => ODataModelOptions<any> | undefined;
4308
- modelForType: (t: string) => typeof ODataModel<any> | undefined;
4309
- collectionForType: (t: string) => typeof ODataCollection<any, any> | undefined;
4310
- enumForType: (t: string) => ODataEnumType<any> | undefined;
4311
- structuredForType: (t: string) => ODataStructuredType<any> | undefined;
4301
+ configure({ concurrency, options, }: {
4312
4302
  concurrency: boolean;
4313
4303
  options: ParserOptions;
4314
4304
  }): void;
@@ -4316,10 +4306,10 @@ declare class ODataModelField<F> {
4316
4306
  hasReferentials(): boolean;
4317
4307
  get referentials(): angular_odata.ODataReferential[];
4318
4308
  isStructuredType(): boolean;
4319
- structuredType(): ODataStructuredType<F>;
4309
+ structuredType(): ODataStructuredType<any> | ODataStructuredType<unknown>;
4320
4310
  isEnumType(): boolean;
4321
4311
  isEdmType(): boolean;
4322
- enumType(): ODataEnumType<F>;
4312
+ enumType(): ODataEnumType<any> | ODataEnumType<unknown>;
4323
4313
  validate(value: any, { method, navigation, }?: {
4324
4314
  method?: 'create' | 'update' | 'modify';
4325
4315
  navigation?: boolean;
@@ -4545,6 +4535,43 @@ declare class ODataModelOptions<T> {
4545
4535
  private _link;
4546
4536
  }
4547
4537
 
4538
+ declare class ODataInclude {
4539
+ namespace: string;
4540
+ alias?: string;
4541
+ reference: ODataReference;
4542
+ constructor(config: {
4543
+ namespace: string;
4544
+ alias?: string;
4545
+ }, reference: ODataReference);
4546
+ configure({ options }: {
4547
+ options: ParserOptions;
4548
+ }): void;
4549
+ }
4550
+ declare class ODataIncludeAnnotation {
4551
+ termNamespace: string;
4552
+ qualifier?: string;
4553
+ targetNamespace?: string;
4554
+ reference: ODataReference;
4555
+ constructor(config: {
4556
+ termNamespace: string;
4557
+ qualifier?: string;
4558
+ targetNamespace?: string;
4559
+ }, reference: ODataReference);
4560
+ configure({ options }: {
4561
+ options: ParserOptions;
4562
+ }): void;
4563
+ }
4564
+ declare class ODataReference extends ODataAnnotatable {
4565
+ api: ODataApi;
4566
+ uri: string;
4567
+ includes: ODataInclude[];
4568
+ includeAnnotations: ODataIncludeAnnotation[];
4569
+ constructor(config: ODataReferenceConfig, api: ODataApi);
4570
+ configure({ options }: {
4571
+ options: ParserOptions;
4572
+ }): void;
4573
+ }
4574
+
4548
4575
  /**
4549
4576
  * Api abstraction for consuming OData services.
4550
4577
  */
@@ -4560,7 +4587,9 @@ declare class ODataApi {
4560
4587
  cache?: ODataCache;
4561
4588
  errorHandler?: (error: any, caught: Observable<any>) => Observable<never>;
4562
4589
  parsers: Map<string, Parser<any>>;
4590
+ populateFromMetadata: boolean;
4563
4591
  schemas: ODataSchema[];
4592
+ references: ODataReference[];
4564
4593
  models: {
4565
4594
  [type: string]: typeof ODataModel<any>;
4566
4595
  };
@@ -4568,10 +4597,8 @@ declare class ODataApi {
4568
4597
  [type: string]: typeof ODataCollection<any, ODataModel<any>>;
4569
4598
  };
4570
4599
  constructor(config: ODataApiConfig);
4571
- configure(settings?: {
4572
- requester?: (request: ODataRequest<any>) => Observable<any>;
4573
- }): void;
4574
- populate(metadata: ODataMetadata): void;
4600
+ initialize(requester: (request: ODataRequest<any>) => Observable<any>): Promise<boolean>;
4601
+ populate(metadata: ODataMetadata): boolean;
4575
4602
  fromJson<P, R>(json: {
4576
4603
  segments: ODataSegment[];
4577
4604
  options: {
@@ -4632,12 +4659,12 @@ declare class ODataApi {
4632
4659
  /**
4633
4660
  * Using the request, handle the fetching of the response
4634
4661
  * @param req The request to fetch
4635
- * @param res$ Observable of the response
4636
4662
  * @returns
4637
4663
  */
4638
4664
  private handleRequest;
4639
- private handleFetch;
4640
- private handleMutate;
4665
+ private handleRequester;
4666
+ private handleCacheFetch;
4667
+ private handleCacheMutate;
4641
4668
  private memo;
4642
4669
  createSchema(config: ODataSchemaConfig): ODataSchema;
4643
4670
  findSchema(type: string): ODataSchema | undefined;
@@ -4793,6 +4820,7 @@ declare class ODataResource<T> {
4793
4820
  escape?: boolean;
4794
4821
  }): string;
4795
4822
  clone(): ODataResource<T>;
4823
+ cast<C>(type: string): ODataResource<C>;
4796
4824
  private __parser;
4797
4825
  deserialize(value: any, options?: ParserOptions): any;
4798
4826
  serialize(value: any, options?: ParserOptions): any;
@@ -5120,6 +5148,7 @@ type ODataApiConfig = {
5120
5148
  parsers?: {
5121
5149
  [type: string]: Parser<any>;
5122
5150
  };
5151
+ populateFromMetadata?: boolean;
5123
5152
  schemas?: ODataSchemaConfig[];
5124
5153
  references?: ODataReferenceConfig[];
5125
5154
  models?: {
@@ -5143,12 +5172,16 @@ type ODataAnnotationConfig = {
5143
5172
  };
5144
5173
  type ODataReferenceConfig = {
5145
5174
  uri: string;
5146
- includes?: string;
5147
5175
  annotations?: ODataAnnotationConfig[];
5148
- enums?: ODataEnumTypeConfig[];
5149
- entities?: ODataStructuredTypeConfig[];
5150
- callables?: ODataCallableConfig[];
5151
- containers?: ODataEntityContainerConfig[];
5176
+ includes?: {
5177
+ namespace: string;
5178
+ alias?: string;
5179
+ }[];
5180
+ includeAnnotations?: {
5181
+ termNamespace: string;
5182
+ qualifier?: string;
5183
+ targetNamespace?: string;
5184
+ }[];
5152
5185
  };
5153
5186
  type ODataSchemaConfig = {
5154
5187
  namespace: string;
@@ -5257,9 +5290,7 @@ type ODataSingletonConfig = {
5257
5290
  declare class ODataSettings {
5258
5291
  apis: ODataApi[];
5259
5292
  constructor(configs: ODataApiConfig[]);
5260
- configure(settings: {
5261
- requester?: (request: ODataRequest<any>) => Observable<any>;
5262
- }): void;
5293
+ initialize(requester: (request: ODataRequest<any>) => Observable<any>): Promise<boolean[]>;
5263
5294
  defaultApi(): ODataApi;
5264
5295
  findApiByName(name: string): ODataApi | undefined;
5265
5296
  apiByName(name: string): ODataApi;
@@ -5275,31 +5306,46 @@ declare class ODataSettings {
5275
5306
  collectionForType(type: string): typeof ODataCollection;
5276
5307
  }
5277
5308
 
5278
- declare abstract class ODataConfigLoader {
5279
- abstract loadConfigs(): Observable<ODataApiConfig[]>;
5309
+ declare abstract class ODataLoader {
5310
+ abstract load(): Promise<{
5311
+ configs: ODataApiConfig[];
5312
+ requester: (req: ODataRequest<any>) => Observable<any>;
5313
+ }>;
5280
5314
  }
5281
- declare class ODataConfigSyncLoader implements ODataConfigLoader {
5315
+ declare class ODataSyncLoader implements ODataLoader {
5282
5316
  private readonly passedConfigs;
5283
- constructor(passedConfigs: ODataApiConfig | ODataApiConfig[]);
5284
- loadConfigs(): Observable<ODataApiConfig[]>;
5317
+ private readonly requester;
5318
+ constructor(passedConfigs: ODataApiConfig | ODataApiConfig[], requester: (req: ODataRequest<any>) => Observable<any>);
5319
+ load(): Promise<{
5320
+ configs: ODataApiConfig[];
5321
+ requester: (req: ODataRequest<any>) => Observable<any>;
5322
+ }>;
5285
5323
  }
5286
- declare class ODataConfigAsyncLoader implements ODataConfigLoader {
5324
+ declare class ODataAsyncLoader implements ODataLoader {
5287
5325
  private readonly configs$;
5288
- constructor(configs$: Observable<ODataApiConfig>[] | Observable<ODataApiConfig | ODataApiConfig[]>);
5289
- loadConfigs(): Observable<ODataApiConfig[]>;
5326
+ private readonly requester;
5327
+ constructor(configs$: Observable<ODataApiConfig>[] | Observable<ODataApiConfig | ODataApiConfig[]>, requester: (req: ODataRequest<any>) => Observable<any>);
5328
+ load(): Promise<{
5329
+ configs: ODataApiConfig[];
5330
+ requester: (req: ODataRequest<any>) => Observable<any>;
5331
+ }>;
5290
5332
  }
5291
- declare class ODataMetadataLoader implements ODataConfigLoader {
5333
+ declare class ODataMetadataLoader implements ODataLoader {
5292
5334
  private readonly sources$;
5293
5335
  private readonly baseConfigs;
5294
- constructor(sources$: Observable<string | string[]>, baseConfigs: ODataApiConfig | ODataApiConfig[]);
5295
- loadConfigs(): Observable<ODataApiConfig[]>;
5336
+ private readonly requester;
5337
+ constructor(sources$: Observable<string | string[]>, baseConfigs: ODataApiConfig | ODataApiConfig[], requester: (req: ODataRequest<any>) => Observable<any>);
5338
+ load(): Promise<{
5339
+ configs: ODataApiConfig[];
5340
+ requester: (req: ODataRequest<any>) => Observable<any>;
5341
+ }>;
5296
5342
  }
5297
5343
 
5298
5344
  declare class ODataClient {
5299
- private http;
5300
5345
  private loader;
5301
5346
  settings?: ODataSettings;
5302
- constructor(http: HttpClient, loader: ODataConfigLoader);
5347
+ constructor(loader: ODataLoader);
5348
+ initialize(): Promise<boolean>;
5303
5349
  /**
5304
5350
  * Resolve the api for the given value.
5305
5351
  * Where value is: string type or an string name or an instance of resource.
@@ -5905,8 +5951,8 @@ interface PassedInitialConfig {
5905
5951
  config?: ODataApiConfig | ODataApiConfig[];
5906
5952
  loader?: Provider;
5907
5953
  }
5908
- declare const ODATA_CONFIG: InjectionToken<ODataApiConfig>;
5909
- declare function createSyncLoader(passedConfig: PassedInitialConfig): ODataConfigSyncLoader;
5954
+ declare const ODATA_CONFIG: InjectionToken<ODataApiConfig | ODataApiConfig[]>;
5955
+ declare function defaultHttpSyncLoader(config: ODataApiConfig | ODataApiConfig[], http: HttpClient): ODataSyncLoader;
5910
5956
  declare function provideODataClient(passedConfig: PassedInitialConfig): EnvironmentProviders;
5911
5957
  declare class ODataModule {
5912
5958
  static forRoot(passedConfig: PassedInitialConfig): ModuleWithProviders<ODataModule>;
@@ -6574,5 +6620,5 @@ declare class ODataMetadataParser {
6574
6620
  protected propertyValueToDate(attributeValue?: string): Date | undefined;
6575
6621
  }
6576
6622
 
6577
- export { Aggregate, ApplyExpression, ArithmeticFunctions, ArithmeticOperators, BUBBLES, Casting, CastingOperators, 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, ODataIndexedDBCache, 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, 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, transformations };
6623
+ export { Aggregate, ApplyExpression, ArithmeticFunctions, ArithmeticOperators, BUBBLES, Casting, CastingOperators, 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, ODataAsyncLoader, ODataBaseCache, ODataBaseService, ODataBatchRequest, ODataBatchResource, ODataCallable, ODataCallableParser, ODataClient, ODataCollection, ODataCountResource, ODataEntitiesAnnotations, ODataEntityAnnotations, ODataEntityContainer, ODataEntityResource, ODataEntitySet, ODataEntitySetResource, ODataEntitySetService, ODataEntityTypeKey, ODataEnumType, ODataEnumTypeFieldParser, ODataEnumTypeParser, ODataFunctionResource, ODataFunctions, ODataInMemoryCache, ODataInStorageCache, ODataIndexedDBCache, ODataLoader, 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, ODataSyncLoader, 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, defaultHttpSyncLoader, duration, encode, functions, isQueryCustomType, isRawType, normalizeValue, operators, pathAndParamsFromQueryOptions, pathAndParamsFromSegments, provideODataClient, raw, render, resolve, transformations };
6578
6624
  export type { AggregateMethod, AggregateType, ApplyExpressionBuilder, CacheCacheability, ComputeExpressionBuilder, Duration, EntityKey, Expand, ExpandExpressionBuilder, ExpandObject, ExpandOptions, ExpandType, FetchPolicy, FieldParser, Filter, FilterConnector, FilterExpressionBuilder, FilterType, GroupByType, JsonSchemaCustom, JsonSchemaExpand, JsonSchemaFieldOptions, JsonSchemaOptions, JsonSchemaRequired, JsonSchemaSelect, LooseUnion, ModelFieldOptions, ModelInterface, ModelOptions, NestedExpandOptions, NestedOrderBy, Normalize, ODataActionOptions, ODataAnnotationConfig, ODataApiConfig, ODataApiConfigOptions, ODataCache, ODataCacheEntry, ODataCallableConfig, ODataEntities, ODataEntitiesOptions, ODataEntity, ODataEntityContainerConfig, ODataEntityOptions, ODataEntitySetConfig, ODataEnumTypeConfig, ODataEnumTypeFieldConfig, ODataFunctionOptions, ODataMetadataType, ODataModelEntry, ODataModelFieldOptions, ODataOptions, ODataParameterConfig, ODataProperty, ODataPropertyOptions, ODataQueryArguments, ODataQueryArgumentsOptions, ODataReferenceConfig, ODataResponseJson, ODataSchemaConfig, ODataSegment, ODataSingletonConfig, ODataStructuredTypeConfig, ODataStructuredTypeFieldConfig, ODataVersion, ObjectValues, OrderAttribute, OrderBy, OrderByExpressionBuilder, OrderByObject, OrderByType, Parser, ParserOptions, PassedInitialConfig, QueryCustomType, QueryOptions, Renderable, ResponseOptions, SearchConnector, SearchExpressionBuilder, Select, SelectExpressionBuilder, SelectType, StructuredTypeFieldOptions, Transform, Unpacked, Value };