angular-odata 0.115.0 → 0.121.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.
Files changed (86) hide show
  1. package/README.md +4 -2
  2. package/esm2020/lib/api.mjs +7 -7
  3. package/esm2020/lib/cache/cache.mjs +3 -3
  4. package/esm2020/lib/client.mjs +33 -27
  5. package/esm2020/lib/index.mjs +2 -2
  6. package/esm2020/lib/loaders.mjs +33 -0
  7. package/esm2020/lib/models/collection.mjs +79 -48
  8. package/esm2020/lib/models/model.mjs +35 -9
  9. package/esm2020/lib/models/options.mjs +99 -39
  10. package/esm2020/lib/module.mjs +21 -17
  11. package/esm2020/lib/options.mjs +4 -3
  12. package/esm2020/lib/resources/path/handlers.mjs +8 -8
  13. package/esm2020/lib/resources/path/segments.mjs +6 -6
  14. package/esm2020/lib/resources/query/builder.mjs +1 -1
  15. package/esm2020/lib/resources/query/expressions/count.mjs +5 -5
  16. package/esm2020/lib/resources/query/expressions/expand.mjs +18 -18
  17. package/esm2020/lib/resources/query/handlers.mjs +45 -45
  18. package/esm2020/lib/resources/query/options.mjs +27 -27
  19. package/esm2020/lib/resources/request.mjs +1 -1
  20. package/esm2020/lib/resources/resource.mjs +11 -9
  21. package/esm2020/lib/resources/responses/annotations.mjs +1 -1
  22. package/esm2020/lib/resources/types/action.mjs +16 -7
  23. package/esm2020/lib/resources/types/batch.mjs +135 -31
  24. package/esm2020/lib/resources/types/count.mjs +4 -4
  25. package/esm2020/lib/resources/types/entity-set.mjs +5 -7
  26. package/esm2020/lib/resources/types/entity.mjs +5 -5
  27. package/esm2020/lib/resources/types/function.mjs +16 -7
  28. package/esm2020/lib/resources/types/media.mjs +3 -3
  29. package/esm2020/lib/resources/types/metadata.mjs +3 -3
  30. package/esm2020/lib/resources/types/navigation-property.mjs +7 -9
  31. package/esm2020/lib/resources/types/options.mjs +1 -1
  32. package/esm2020/lib/resources/types/property.mjs +6 -10
  33. package/esm2020/lib/resources/types/reference.mjs +3 -3
  34. package/esm2020/lib/resources/types/singleton.mjs +4 -4
  35. package/esm2020/lib/resources/types/value.mjs +3 -3
  36. package/esm2020/lib/schema/parsers/edm.mjs +18 -17
  37. package/esm2020/lib/schema/parsers/enum-type.mjs +1 -1
  38. package/esm2020/lib/schema/parsers/structured-type.mjs +31 -19
  39. package/esm2020/lib/schema/structured-type.mjs +7 -1
  40. package/esm2020/lib/services/factory.mjs +3 -3
  41. package/esm2020/lib/settings.mjs +2 -2
  42. package/esm2020/lib/types.mjs +101 -32
  43. package/esm2020/lib/utils/enums.mjs +20 -20
  44. package/esm2020/lib/utils/strings.mjs +2 -2
  45. package/fesm2015/angular-odata.mjs +761 -406
  46. package/fesm2015/angular-odata.mjs.map +1 -1
  47. package/fesm2020/angular-odata.mjs +763 -404
  48. package/fesm2020/angular-odata.mjs.map +1 -1
  49. package/lib/api.d.ts +3 -3
  50. package/lib/client.d.ts +8 -7
  51. package/lib/index.d.ts +1 -1
  52. package/lib/loaders.d.ts +15 -0
  53. package/lib/models/collection.d.ts +21 -13
  54. package/lib/models/model.d.ts +10 -5
  55. package/lib/models/options.d.ts +20 -7
  56. package/lib/module.d.ts +12 -6
  57. package/lib/options.d.ts +6 -2
  58. package/lib/resources/path/handlers.d.ts +2 -2
  59. package/lib/resources/path/segments.d.ts +2 -2
  60. package/lib/resources/query/builder.d.ts +4 -1
  61. package/lib/resources/query/handlers.d.ts +3 -3
  62. package/lib/resources/query/options.d.ts +21 -21
  63. package/lib/resources/request.d.ts +4 -4
  64. package/lib/resources/resource.d.ts +4 -6
  65. package/lib/resources/types/action.d.ts +19 -2
  66. package/lib/resources/types/batch.d.ts +16 -5
  67. package/lib/resources/types/entity-set.d.ts +8 -8
  68. package/lib/resources/types/entity.d.ts +5 -5
  69. package/lib/resources/types/function.d.ts +17 -2
  70. package/lib/resources/types/navigation-property.d.ts +11 -11
  71. package/lib/resources/types/options.d.ts +0 -3
  72. package/lib/resources/types/property.d.ts +4 -4
  73. package/lib/resources/types/reference.d.ts +5 -5
  74. package/lib/resources/types/singleton.d.ts +5 -5
  75. package/lib/schema/parsers/edm.d.ts +2 -2
  76. package/lib/schema/parsers/enum-type.d.ts +2 -2
  77. package/lib/schema/parsers/structured-type.d.ts +8 -7
  78. package/lib/schema/structured-type.d.ts +3 -1
  79. package/lib/services/entity-set.d.ts +1 -6
  80. package/lib/settings.d.ts +3 -3
  81. package/lib/types.d.ts +46 -3
  82. package/lib/utils/enums.d.ts +18 -6
  83. package/lib/utils/strings.d.ts +4 -1
  84. package/package.json +1 -1
  85. package/esm2020/lib/tokens.mjs +0 -3
  86. package/lib/tokens.d.ts +0 -3
package/lib/api.d.ts CHANGED
@@ -5,7 +5,7 @@ import { ODataApiOptions } from './options';
5
5
  import { ODataActionResource, ODataBatchResource, ODataEntityResource, ODataEntitySetResource, ODataFunctionResource, ODataMetadataResource, ODataNavigationPropertyResource, ODataOptions, ODataRequest, ODataResource, ODataSegment, ODataSingletonResource } from './resources/index';
6
6
  import { ODataCallable, ODataEntitySet, ODataEnumType, ODataSchema, ODataStructuredType } from './schema';
7
7
  import { ODataEntityService } from './services/entity';
8
- import { ApiConfig, Parser, QueryOptionNames } from './types';
8
+ import { ApiConfig, EdmType, Parser, QueryOption } from './types';
9
9
  /**
10
10
  * Api abstraction for consuming OData services.
11
11
  */
@@ -78,7 +78,7 @@ export declare class ODataApi {
78
78
  responseType?: 'arraybuffer' | 'blob' | 'json' | 'text' | 'value' | 'property' | 'entity' | 'entities';
79
79
  observe?: 'body' | 'events' | 'response';
80
80
  withCount?: boolean;
81
- bodyQueryOptions?: QueryOptionNames[];
81
+ bodyQueryOptions?: QueryOption[];
82
82
  }): Observable<any>;
83
83
  private memo;
84
84
  private findSchemaForType;
@@ -100,6 +100,6 @@ export declare class ODataApi {
100
100
  findModelByName(name: string): typeof ODataModel | undefined;
101
101
  findCollectionByName(name: string): typeof ODataCollection | undefined;
102
102
  findServiceByName(name: string): typeof ODataEntityService | undefined;
103
- parserForType<T>(type: string, bindingType?: string): Parser<T>;
103
+ parserForType<T>(type: string | EdmType, bindingType?: string): Parser<T>;
104
104
  findOptionsForType<T>(type: string): ODataModelOptions<any> | ODataModelOptions<T> | undefined;
105
105
  }
package/lib/client.d.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  import { HttpClient, HttpEvent } from '@angular/common/http';
2
- import { Injector } from '@angular/core';
3
2
  import { Observable } from 'rxjs';
4
3
  import { ODataApi } from './api';
4
+ import { ODataConfigLoader } from './loaders';
5
5
  import { ODataCollection, ODataModel } from './models/index';
6
6
  import { ODataActionResource, ODataBatchResource, ODataEntityResource, ODataEntitySetResource, ODataFunctionResource, ODataMetadataResource, ODataNavigationPropertyResource, ODataOptions, ODataResource, ODataResponse, ODataSegment, ODataSingletonResource } from './resources/index';
7
7
  import { ODataEntityService } from './services/entity';
@@ -9,9 +9,9 @@ import { ODataSettings } from './settings';
9
9
  import * as i0 from "@angular/core";
10
10
  export declare class ODataClient {
11
11
  private http;
12
- private settings;
13
- private injector;
14
- constructor(http: HttpClient, settings: ODataSettings, injector: Injector);
12
+ private loader;
13
+ settings?: ODataSettings;
14
+ constructor(http: HttpClient, loader: ODataConfigLoader);
15
15
  /**
16
16
  * Resolve the api for the given value.
17
17
  * Where value is: string type or an string name or an instance of resource.
@@ -19,6 +19,7 @@ export declare class ODataClient {
19
19
  * @returns The api for the value.
20
20
  */
21
21
  apiFor(value?: ODataResource<any> | string): ODataApi;
22
+ defaultApi(): ODataApi;
22
23
  /**
23
24
  * Resolve the parser for the given string type.
24
25
  * @param type The string type of the parser.
@@ -66,20 +67,20 @@ export declare class ODataClient {
66
67
  * @param type The string type of the service.
67
68
  * @returns The service for the given type.
68
69
  */
69
- serviceForType(type: string): ODataEntityService<any>;
70
+ serviceForType(type: string): ODataEntityService<any> | undefined;
70
71
  /**
71
72
  * Resolve the service for the given string entity type.
72
73
  * @param type The string entity type binding to the service.
73
74
  * @returns The service for the given entity type.
74
75
  */
75
- serviceForEntityType(type: string): ODataEntityService<any>;
76
+ serviceForEntityType(type: string): ODataEntityService<any> | undefined;
76
77
  enumTypeByName<T>(name: string): import("angular-odata").ODataEnumType<T>;
77
78
  structuredTypeByName<T>(name: string): import("angular-odata").ODataStructuredType<T>;
78
79
  callableByName<T>(name: string): import("angular-odata").ODataCallable<T>;
79
80
  entitySetByName(name: string): import("angular-odata").ODataEntitySet;
80
81
  modelByName(name: string): typeof ODataModel;
81
82
  collectionByName(name: string): typeof ODataCollection;
82
- serviceByName(name: string): ODataEntityService<any>;
83
+ serviceByName(name: string): ODataEntityService<any> | undefined;
83
84
  fromJSON<E>(json: {
84
85
  segments: ODataSegment[];
85
86
  options: {
package/lib/index.d.ts CHANGED
@@ -2,8 +2,8 @@ export * from './types';
2
2
  export * from './settings';
3
3
  export * from './api';
4
4
  export * from './client';
5
- export * from './tokens';
6
5
  export * from './module';
6
+ export * from './loaders';
7
7
  export * from './utils/index';
8
8
  export * from './services/index';
9
9
  export * from './schema/index';
@@ -0,0 +1,15 @@
1
+ import { Observable } from 'rxjs';
2
+ import { ApiConfig } from './types';
3
+ export declare abstract class ODataConfigLoader {
4
+ abstract loadConfigs(): Observable<ApiConfig[]>;
5
+ }
6
+ export declare class ODataConfigSyncLoader implements ODataConfigLoader {
7
+ private readonly passedConfigs;
8
+ constructor(passedConfigs: ApiConfig | ApiConfig[]);
9
+ loadConfigs(): Observable<ApiConfig[]>;
10
+ }
11
+ export declare class ODataConfigAsyncLoader implements ODataConfigLoader {
12
+ private readonly configs$;
13
+ constructor(configs$: Observable<ApiConfig> | Observable<ApiConfig>[] | Observable<ApiConfig[]>);
14
+ loadConfigs(): Observable<ApiConfig[]>;
15
+ }
@@ -3,7 +3,7 @@ import { Observable } from 'rxjs';
3
3
  import { ODataActionOptions, ODataEntitiesAnnotations, ODataEntitySetResource, ODataFunctionOptions, ODataNavigationPropertyResource, ODataOptions, ODataPropertyResource, ODataQueryOptionsHandler, ODataResource } from '../resources';
4
4
  import { ODataStructuredType } from '../schema/structured-type';
5
5
  import { ODataModel } from './model';
6
- import { ODataModelEntry, ODataModelEvent, ODataModelField } from './options';
6
+ import { ModelFieldOptions, ODataModelEntry, ODataModelEvent, ODataModelField } from './options';
7
7
  export declare class ODataCollection<T, M extends ODataModel<T>> implements Iterable<M> {
8
8
  static model: typeof ODataModel | null;
9
9
  _parent: [
@@ -41,7 +41,8 @@ export declare class ODataCollection<T, M extends ODataModel<T>> implements Iter
41
41
  resource: ODataEntitySetResource<T> | ODataNavigationPropertyResource<T> | ODataPropertyResource<T> | null;
42
42
  } | undefined;
43
43
  attach(resource: ODataEntitySetResource<T> | ODataNavigationPropertyResource<T> | ODataPropertyResource<T>): void;
44
- asEntitySet<R>(func: (collection: this) => R): R;
44
+ withResource<R>(resource: ODataEntitySetResource<T> | ODataNavigationPropertyResource<T> | ODataPropertyResource<T>, ctx: (collection: this) => R): R;
45
+ asEntitySet<R>(ctx: (collection: this) => R): R;
45
46
  annots(): ODataEntitiesAnnotations<T>;
46
47
  private modelFactory;
47
48
  toEntities({ client_id, include_navigation, include_concurrency, include_computed, include_key, include_non_field, changes_only, field_mapping, chain, }?: {
@@ -65,18 +66,22 @@ export declare class ODataCollection<T, M extends ODataModel<T>> implements Iter
65
66
  }): boolean;
66
67
  clone<C extends ODataCollection<T, M>>(): C;
67
68
  private _request;
68
- fetch({ withCount, ...options }?: ODataOptions & {
69
+ fetch({ withCount, remove, ...options }?: ODataOptions & {
70
+ remove?: boolean;
69
71
  withCount?: boolean;
70
- }): Observable<this>;
71
- fetchAll({ withCount, ...options }?: ODataOptions & {
72
+ }): Observable<M[]>;
73
+ fetchAll({ withCount, remove, ...options }?: ODataOptions & {
74
+ remove?: boolean;
72
75
  withCount?: boolean;
73
- }): Observable<this>;
74
- fetchMany(top: number, { withCount, ...options }?: ODataOptions & {
76
+ }): Observable<M[]>;
77
+ fetchMany(top: number, { withCount, remove, ...options }?: ODataOptions & {
78
+ remove?: boolean;
75
79
  withCount?: boolean;
76
- }): Observable<this>;
77
- fetchOne({ withCount, ...options }?: ODataOptions & {
80
+ }): Observable<M[]>;
81
+ fetchOne({ withCount, remove, ...options }?: ODataOptions & {
82
+ remove?: boolean;
78
83
  withCount?: boolean;
79
- }): Observable<M | null>;
84
+ }): Observable<M>;
80
85
  /**
81
86
  * Save all models in the collection
82
87
  * @param relModel The model is relationship
@@ -104,13 +109,15 @@ export declare class ODataCollection<T, M extends ODataModel<T>> implements Iter
104
109
  silent?: boolean;
105
110
  server?: boolean;
106
111
  }): Observable<M>;
112
+ private _moveModel;
107
113
  create(attrs?: T, { silent, server, }?: {
108
114
  silent?: boolean;
109
115
  server?: boolean;
110
116
  }): Observable<M>;
111
- set(path: string | string[], value: any): any;
117
+ set(path: string | string[], value: any, {}: {} & ModelFieldOptions): any;
112
118
  get(path: number): M | undefined;
113
119
  get(path: string | string[]): any;
120
+ has(path: number | string | string[]): boolean;
114
121
  reset({ path, silent, }?: {
115
122
  path?: string | string[];
116
123
  silent?: boolean;
@@ -120,12 +127,13 @@ export declare class ODataCollection<T, M extends ODataModel<T>> implements Iter
120
127
  }): void;
121
128
  assign(objects: Partial<T>[] | {
122
129
  [name: string]: any;
123
- }[] | M[], { reset, reparent, silent, }?: {
130
+ }[] | M[], { remove, reset, reparent, silent, }?: {
131
+ remove?: boolean;
124
132
  reset?: boolean;
125
133
  reparent?: boolean;
126
134
  silent?: boolean;
127
135
  }): void;
128
- query(func: (q: ODataQueryOptionsHandler<T>, s?: ODataStructuredType<T>) => void): this;
136
+ query(ctx: (q: ODataQueryOptionsHandler<T>, s?: ODataStructuredType<T>) => void): this;
129
137
  callFunction<P, R>(name: string, params: P | null, responseType: 'property' | 'model' | 'collection' | 'none', { ...options }?: {} & ODataFunctionOptions<R>): Observable<R | ODataModel<R> | ODataCollection<R, ODataModel<R>> | null>;
130
138
  callAction<P, R>(name: string, params: P | null, responseType: 'property' | 'model' | 'collection' | 'none', { ...options }?: {} & ODataActionOptions<R>): Observable<R | ODataModel<R> | ODataCollection<R, ODataModel<R>> | null>;
131
139
  private _unlink;
@@ -60,6 +60,7 @@ export declare class ODataModel<T> {
60
60
  }): EntityKey<T> | {
61
61
  [name: string]: any;
62
62
  } | undefined;
63
+ isOpenModel(): boolean;
63
64
  isParentOf(child: ODataModel<any> | ODataCollection<any, ODataModel<any>>): boolean;
64
65
  referential(field: ODataModelField<any>, { field_mapping, resolve, }?: {
65
66
  field_mapping?: boolean;
@@ -112,8 +113,11 @@ export declare class ODataModel<T> {
112
113
  }): {
113
114
  [name: string]: any;
114
115
  };
115
- set(path: string | string[], value: any): any;
116
+ set(path: string | string[], value: any, { type }?: {
117
+ type?: string;
118
+ }): any;
116
119
  get(path: string | string[]): any;
120
+ has(path: string | string[]): boolean;
117
121
  reset({ path, silent, }?: {
118
122
  path?: string | string[];
119
123
  silent?: boolean;
@@ -144,9 +148,9 @@ export declare class ODataModel<T> {
144
148
  }): Observable<this>;
145
149
  /**
146
150
  * Create an execution context for change the internal query of a resource
147
- * @param func Function to execute
151
+ * @param ctx Function to execute
148
152
  */
149
- query(func: (q: ODataQueryOptionsHandler<T>, s?: ODataStructuredType<T>) => void): this;
153
+ query(ctx: (q: ODataQueryOptionsHandler<T>, s?: ODataStructuredType<T>) => void): this;
150
154
  /**
151
155
  * Perform a check on the internal state of the model and return true if the model is changed.
152
156
  * @param include_navigation Check in navigation properties
@@ -156,14 +160,15 @@ export declare class ODataModel<T> {
156
160
  include_navigation?: boolean;
157
161
  }): boolean;
158
162
  isNew(): boolean;
163
+ withResource<R>(resource: any, ctx: (model: this) => R): R;
159
164
  /**
160
165
  * Create an execution context for a given function, where the model is bound to its entity endpoint
161
166
  * @param ctx Context function
162
167
  * @returns The result of the context
163
168
  */
164
169
  asEntity<R>(ctx: (model: this) => R): R;
165
- callFunction<P, R>(name: string, params: P | null, responseType: 'property' | 'model' | 'collection' | 'none', { ...options }?: {} & ODataFunctionOptions<R>): Observable<R | ODataModel<R> | ODataCollection<R, ODataModel<R>> | null>;
166
- callAction<P, R>(name: string, params: P | null, responseType: 'property' | 'model' | 'collection' | 'none', { ...options }?: {} & ODataActionOptions<R>): Observable<R | ODataModel<R> | ODataCollection<R, ODataModel<R>> | null>;
170
+ 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>;
171
+ 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>;
167
172
  cast<S>(type: string): ODataModel<S>;
168
173
  fetchNavigationProperty<S>(name: keyof T | string, responseType: 'model' | 'collection', { ...options }?: {} & ODataQueryArgumentsOptions<S>): Observable<ODataModel<S> | ODataCollection<S, ODataModel<S>> | null>;
169
174
  getValue<P>(name: keyof T | string, options?: ODataOptions): Observable<P | ODataModel<P> | ODataCollection<P, ODataModel<P>> | null>;
@@ -1,7 +1,7 @@
1
1
  import { Subscription } from 'rxjs';
2
2
  import { EntityKey, ODataEntitiesAnnotations, ODataEntityAnnotations, ODataEntityResource, ODataEntitySetResource, ODataNavigationPropertyResource, ODataPropertyResource, ODataQueryOptions, ODataQueryOptionsHandler, ODataResource, ODataSingletonResource } from '../resources';
3
3
  import { ODataEntitySet, ODataStructuredType, ODataStructuredTypeFieldParser } from '../schema';
4
- import { Parser, ParserOptions } from '../types';
4
+ import { EdmType, Parser, ParserOptions } from '../types';
5
5
  import type { ODataCollection } from './collection';
6
6
  import type { ODataModel } from './model';
7
7
  export declare type ODataModelEventType = 'change' | 'reset' | 'update' | 'destroy' | 'add' | 'remove' | 'invalid' | 'request' | 'sync' | 'attach';
@@ -59,6 +59,7 @@ export declare type ModelOptions = {
59
59
  };
60
60
  export declare type ModelFieldOptions = {
61
61
  field?: string;
62
+ parser?: ODataStructuredTypeFieldParser<any>;
62
63
  default?: any;
63
64
  required?: boolean;
64
65
  concurrency?: boolean;
@@ -136,7 +137,7 @@ export declare class ODataModelField<F> {
136
137
  [name: string]: any;
137
138
  }[];
138
139
  reset?: boolean;
139
- }): ODataModel<F> | ODataCollection<F, ODataModel<F>>;
140
+ }): ODataCollection<F, ODataModel<F>>;
140
141
  }
141
142
  export declare type ODataModelRelation<T> = {
142
143
  state: ODataModelState;
@@ -170,6 +171,7 @@ export declare class ODataModelOptions<T> {
170
171
  type({ alias }?: {
171
172
  alias?: boolean;
172
173
  }): string;
174
+ isOpenType(): boolean;
173
175
  isTypeOf(type: string): boolean;
174
176
  isModelFor(entity: T | {
175
177
  [name: string]: any;
@@ -185,6 +187,10 @@ export declare class ODataModelOptions<T> {
185
187
  include_navigation: boolean;
186
188
  }): ODataModelField<any>[];
187
189
  field<F>(name: keyof T | string): ODataModelField<F>;
190
+ findField<F>(name: keyof T | string): ODataModelField<F> | undefined;
191
+ addField<F>(name: string, options: ModelFieldOptions): ODataModelField<F>;
192
+ tsToEdm: Record<string, EdmType>;
193
+ private modelFieldFactory;
188
194
  attach(self: ODataModel<T>, resource: ODataEntityResource<T> | ODataNavigationPropertyResource<T> | ODataPropertyResource<T> | ODataSingletonResource<T>): void;
189
195
  static chain(child: ODataModel<any> | ODataCollection<any, ODataModel<any>>): [
190
196
  ODataModel<any> | ODataCollection<any, ODataModel<any>>,
@@ -243,7 +249,8 @@ export declare class ODataModelOptions<T> {
243
249
  include_navigation?: boolean;
244
250
  }): boolean;
245
251
  hasKey(self: ODataModel<T>): boolean;
246
- asEntity<R, M extends ODataModel<T>>(self: M, func: (model: M) => R): R;
252
+ withResource<R, M extends ODataModel<T>>(self: M, resource: ODataEntityResource<T> | ODataPropertyResource<T> | ODataNavigationPropertyResource<T> | ODataSingletonResource<T>, ctx: (model: M) => R): R;
253
+ asEntity<R, M extends ODataModel<T>>(self: M, ctx: (model: M) => R): R;
247
254
  toEntity(self: ODataModel<T>, { client_id, include_navigation, include_concurrency, include_computed, include_key, include_non_field, changes_only, field_mapping, chain, }?: {
248
255
  client_id?: boolean;
249
256
  include_navigation?: boolean;
@@ -279,12 +286,18 @@ export declare class ODataModelOptions<T> {
279
286
  }): void;
280
287
  static isModel(obj: any): boolean;
281
288
  static isCollection(obj: any): boolean;
282
- private updateCollection;
283
- private updateModel;
284
- private _get;
289
+ private _updateCollection;
290
+ private _updateModel;
291
+ get<F>(self: ODataModel<T>, field: ODataModelField<F> | string): F | ODataModel<F> | ODataCollection<F, ODataModel<F>> | null | undefined;
285
292
  private _setStructured;
286
293
  private _setValue;
287
- private _set;
294
+ set<F>(self: ODataModel<T>, field: ODataModelField<F> | string, value: F | F[] | {
295
+ [name: string]: any;
296
+ } | {
297
+ [name: string]: any;
298
+ }[] | ODataModel<F> | ODataCollection<F, ODataModel<F>> | null, { type }?: {
299
+ type?: string;
300
+ }): boolean;
288
301
  private _unlink;
289
302
  private _link;
290
303
  }
package/lib/module.d.ts CHANGED
@@ -1,12 +1,18 @@
1
- import { ModuleWithProviders } from '@angular/core';
2
- import { ODataSettings } from './settings';
1
+ import { InjectionToken, ModuleWithProviders, Provider } from '@angular/core';
2
+ import { ODataConfigSyncLoader } from './loaders';
3
3
  import { ApiConfig } from './types';
4
4
  import * as i0 from "@angular/core";
5
- import * as i1 from "@angular/common/http";
6
- export declare function createSettings(configs: ApiConfig[]): ODataSettings;
5
+ import * as i1 from "@angular/common";
6
+ import * as i2 from "@angular/common/http";
7
+ export interface PassedInitialConfig {
8
+ config?: ApiConfig | ApiConfig[];
9
+ loader?: Provider;
10
+ }
11
+ export declare const ODATA_CONFIG: InjectionToken<ApiConfig>;
12
+ export declare function createSyncLoader(passedConfig: PassedInitialConfig): ODataConfigSyncLoader;
7
13
  export declare class ODataModule {
8
- static forRoot(...configs: ApiConfig[]): ModuleWithProviders<ODataModule>;
14
+ static forRoot(passedConfig: PassedInitialConfig): ModuleWithProviders<ODataModule>;
9
15
  static ɵfac: i0.ɵɵFactoryDeclaration<ODataModule, never>;
10
- static ɵmod: i0.ɵɵNgModuleDeclaration<ODataModule, never, [typeof i1.HttpClientModule], never>;
16
+ static ɵmod: i0.ɵɵNgModuleDeclaration<ODataModule, never, [typeof i1.CommonModule, typeof i2.HttpClientModule], never>;
11
17
  static ɵinj: i0.ɵɵInjectorDeclaration<ODataModule>;
12
18
  }
package/lib/options.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { ApiOptions, FetchPolicy, ODataMetadataType, ODataVersion, ParserOptions, QueryOptionNames } from './types';
1
+ import { ApiOptions, FetchPolicy, ODataMetadataType, ODataVersion, ParserOptions, QueryOption } from './types';
2
2
  export declare class ODataApiOptions implements ApiOptions {
3
3
  /**
4
4
  * Default OData version
@@ -20,6 +20,10 @@ export declare class ODataApiOptions implements ApiOptions {
20
20
  * Strip metadata from the response
21
21
  */
22
22
  stripMetadata: ODataMetadataType;
23
+ /**
24
+ * Use JSON Batch Format
25
+ */
26
+ jsonBatchFormat: boolean;
23
27
  /**
24
28
  * Cache fetch policy
25
29
  */
@@ -43,7 +47,7 @@ export declare class ODataApiOptions implements ApiOptions {
43
47
  /**
44
48
  * Send query options in the request body
45
49
  */
46
- bodyQueryOptions: QueryOptionNames[];
50
+ bodyQueryOptions: QueryOption[];
47
51
  /**
48
52
  * Customize accept header with OData options
49
53
  * @link http://docs.oasis-open.org/odata/odata-json-format/v4.01/odata-json-format-v4.01.html#sec_RequestingtheJSONFormat
@@ -1,10 +1,10 @@
1
- import { PathSegmentNames } from '../../types';
1
+ import { PathSegment } from '../../types';
2
2
  import { EntityKey } from '../resource';
3
3
  import type { ODataPathSegments, ODataSegment } from './segments';
4
4
  export declare class SegmentHandler {
5
5
  private segment;
6
6
  constructor(segment: ODataSegment);
7
- get name(): PathSegmentNames;
7
+ get name(): PathSegment;
8
8
  type(value?: string): string | undefined;
9
9
  path(value?: string): string;
10
10
  key<T>(value?: EntityKey<T>): EntityKey<T>;
@@ -1,8 +1,8 @@
1
- import { PathSegmentNames } from '../../types';
1
+ import { PathSegment } from '../../types';
2
2
  import { EntityKey } from '../resource';
3
3
  import { SegmentHandler } from './handlers';
4
4
  export declare type ODataSegment = {
5
- name: PathSegmentNames;
5
+ name: PathSegment;
6
6
  path: string;
7
7
  type?: string;
8
8
  key?: any;
@@ -20,7 +20,10 @@ export declare type Aggregate = string | {
20
20
  };
21
21
  export declare type OrderBy<T> = OrderByType<T> | OrderByType<T>[];
22
22
  export declare type OrderByType<T> = string | OrderByObject<T>;
23
- export declare type OrderByObject<T> = keyof T | [keyof T | string, 'asc' | 'desc'];
23
+ export declare type OrderByObject<T> = keyof T | [keyof T | string, 'asc' | 'desc'] | NestedOrderBy<T>;
24
+ export declare type NestedOrderBy<T> = {
25
+ [P in keyof T]?: T[P] extends Array<infer E> ? OrderBy<E> : OrderBy<T[P]>;
26
+ };
24
27
  export declare type Expand<T> = ExpandType<T> | ExpandType<T>[];
25
28
  export declare type ExpandType<T> = string | ExpandObject<T>;
26
29
  export declare type ExpandObject<T> = keyof T | NestedExpandOptions<T>;
@@ -1,15 +1,15 @@
1
- import { QueryOptionNames } from '../../types';
1
+ import { QueryOption } from '../../types';
2
2
  import { Expand, Filter, OrderBy, Select, Transform } from './builder';
3
3
  import { ComputeExpression, ComputeExpressionBuilder, FilterExpression, FilterExpressionBuilder, OrderByExpression, OrderByExpressionBuilder, SearchExpression, SearchExpressionBuilder, ExpandExpression, ExpandExpressionBuilder, SelectExpression, SelectExpressionBuilder } from './expressions';
4
4
  import type { ODataQueryArguments, ODataQueryOptions } from './options';
5
5
  export declare class ODataQueryOptionHandler<T> {
6
6
  private o;
7
7
  private n;
8
- constructor(o: Map<QueryOptionNames, any>, n: QueryOptionNames);
8
+ constructor(o: Map<QueryOption, any>, n: QueryOption);
9
9
  /**
10
10
  * The name of the managed odata query option.
11
11
  */
12
- get name(): QueryOptionNames;
12
+ get name(): QueryOption;
13
13
  /**
14
14
  * Converts the managed odata query option to a json object.
15
15
  * @returns {any}
@@ -1,27 +1,27 @@
1
- import { QueryOptionNames } from '../../types';
1
+ import { QueryOption } from '../../types';
2
2
  import { Expand, Filter, OrderBy, Select, Transform } from './builder';
3
3
  import { ComputeExpression, Expression, FilterExpression, OrderByExpression, SearchExpression } from './expressions';
4
4
  import { ExpandExpression } from './expressions/expand';
5
5
  import { SelectExpression } from './expressions/select';
6
6
  import { ODataQueryOptionHandler } from './handlers';
7
7
  export declare type ODataQueryArguments<T> = {
8
- [QueryOptionNames.select]?: Select<T> | SelectExpression<T> | null;
9
- [QueryOptionNames.expand]?: Expand<T> | ExpandExpression<T> | null;
10
- [QueryOptionNames.compute]?: string | ComputeExpression<T> | null;
11
- [QueryOptionNames.filter]?: Filter<T> | FilterExpression<T> | null;
12
- [QueryOptionNames.search]?: string | SearchExpression<T> | null;
13
- [QueryOptionNames.transform]?: Transform<T> | null;
14
- [QueryOptionNames.orderBy]?: OrderBy<T> | OrderByExpression<T> | null;
15
- [QueryOptionNames.top]?: number | null;
16
- [QueryOptionNames.skip]?: number | null;
17
- [QueryOptionNames.skiptoken]?: string | null;
18
- [QueryOptionNames.format]?: string | null;
19
- [QueryOptionNames.levels]?: number | 'max' | null;
20
- [QueryOptionNames.count]?: boolean | null;
8
+ [QueryOption.select]?: Select<T> | SelectExpression<T> | null;
9
+ [QueryOption.expand]?: Expand<T> | ExpandExpression<T> | null;
10
+ [QueryOption.compute]?: string | ComputeExpression<T> | null;
11
+ [QueryOption.filter]?: Filter<T> | FilterExpression<T> | null;
12
+ [QueryOption.search]?: string | SearchExpression<T> | null;
13
+ [QueryOption.transform]?: Transform<T> | null;
14
+ [QueryOption.orderBy]?: OrderBy<T> | OrderByExpression<T> | null;
15
+ [QueryOption.top]?: number | null;
16
+ [QueryOption.skip]?: number | null;
17
+ [QueryOption.skiptoken]?: string | null;
18
+ [QueryOption.format]?: string | null;
19
+ [QueryOption.levels]?: number | 'max' | null;
20
+ [QueryOption.count]?: boolean | null;
21
21
  };
22
22
  export declare class ODataQueryOptions<T> {
23
- values: Map<QueryOptionNames, any>;
24
- constructor(values?: Map<QueryOptionNames, any> | {
23
+ values: Map<QueryOption, any>;
24
+ constructor(values?: Map<QueryOption, any> | {
25
25
  [name: string]: any;
26
26
  });
27
27
  pathAndParams(escape?: boolean): [string, {
@@ -31,10 +31,10 @@ export declare class ODataQueryOptions<T> {
31
31
  toJSON(): {};
32
32
  toQueryArguments(): ODataQueryArguments<T>;
33
33
  clone<O>(): ODataQueryOptions<O>;
34
- expression(key: QueryOptionNames, exp?: Expression<T>): any;
35
- option<O>(key: QueryOptionNames, opts?: O): ODataQueryOptionHandler<O>;
36
- has(key: QueryOptionNames): boolean;
37
- remove(...keys: QueryOptionNames[]): void;
38
- keep(...keys: QueryOptionNames[]): void;
34
+ expression(key: QueryOption, exp?: Expression<T>): any;
35
+ option<O>(key: QueryOption, opts?: O): ODataQueryOptionHandler<O>;
36
+ has(key: QueryOption): boolean;
37
+ remove(...keys: QueryOption[]): void;
38
+ keep(...keys: QueryOption[]): void;
39
39
  clear(): void;
40
40
  }
@@ -1,6 +1,6 @@
1
1
  import { HttpContext, HttpHeaders, HttpParams } from '@angular/common/http';
2
2
  import { ODataApi } from '../api';
3
- import { QueryOptionNames } from '../types';
3
+ import { QueryOption } from '../types';
4
4
  import { ODataResource } from './resource';
5
5
  import { ODataOptions } from './types';
6
6
  export declare class ODataRequest<T> {
@@ -9,7 +9,7 @@ export declare class ODataRequest<T> {
9
9
  readonly context?: HttpContext;
10
10
  readonly reportProgress?: boolean;
11
11
  readonly withCredentials?: boolean;
12
- readonly bodyQueryOptions: QueryOptionNames[];
12
+ readonly bodyQueryOptions: QueryOption[];
13
13
  readonly fetchPolicy: 'cache-first' | 'cache-and-network' | 'network-only' | 'no-cache' | 'cache-only';
14
14
  readonly resource: ODataResource<T>;
15
15
  private readonly _responseType?;
@@ -36,7 +36,7 @@ export declare class ODataRequest<T> {
36
36
  responseType?: 'arraybuffer' | 'blob' | 'json' | 'text' | 'value' | 'property' | 'entity' | 'entities';
37
37
  fetchPolicy?: 'cache-first' | 'cache-and-network' | 'network-only' | 'no-cache' | 'cache-only';
38
38
  withCredentials?: boolean;
39
- bodyQueryOptions?: QueryOptionNames[];
39
+ bodyQueryOptions?: QueryOption[];
40
40
  });
41
41
  static factory(api: ODataApi, method: string, resource: ODataResource<any>, options: ODataOptions & {
42
42
  body?: any;
@@ -44,7 +44,7 @@ export declare class ODataRequest<T> {
44
44
  responseType?: 'arraybuffer' | 'blob' | 'json' | 'text' | 'value' | 'property' | 'entity' | 'entities';
45
45
  observe: 'events' | 'response';
46
46
  withCount?: boolean;
47
- bodyQueryOptions?: QueryOptionNames[];
47
+ bodyQueryOptions?: QueryOption[];
48
48
  }): ODataRequest<any>;
49
49
  get responseType(): 'arraybuffer' | 'blob' | 'json' | 'text';
50
50
  get path(): string;
@@ -3,7 +3,7 @@ import { ODataApi } from '../api';
3
3
  import { ODataCollection, ODataModel } from '../models';
4
4
  import { ODataStructuredType } from '../schema';
5
5
  import { ODataSchemaElement } from '../schema/element';
6
- import { ParserOptions, QueryOptionNames } from '../types';
6
+ import { ParserOptions, QueryOption } from '../types';
7
7
  import { ODataPathSegments, ODataPathSegmentsHandler } from './path';
8
8
  import { ODataQueryOptions, ODataQueryOptionsHandler, QueryCustomType } from './query';
9
9
  import { ODataEntitiesAnnotations, ODataEntityAnnotations } from './responses/index';
@@ -41,15 +41,13 @@ export declare class ODataResource<T> {
41
41
  clearKey(): void | undefined;
42
42
  asModel<M extends ODataModel<T>>(entity?: Partial<T> | {
43
43
  [name: string]: any;
44
- }, { annots, reset, }?: {
44
+ }, { annots }?: {
45
45
  annots?: ODataEntityAnnotations<T>;
46
- reset?: boolean;
47
46
  }): M;
48
47
  asCollection<M extends ODataModel<T>, C extends ODataCollection<T, M>>(entities?: Partial<T>[] | {
49
48
  [name: string]: any;
50
- }[], { annots, reset, }?: {
49
+ }[], { annots }?: {
51
50
  annots?: ODataEntitiesAnnotations<T>;
52
- reset?: boolean;
53
51
  }): C;
54
52
  isSubtypeOf(other: ODataResource<any>): boolean;
55
53
  isSupertypeOf(other: ODataResource<any>): boolean;
@@ -90,7 +88,7 @@ export declare class ODataResource<T> {
90
88
  etag?: string;
91
89
  responseType?: 'arraybuffer' | 'blob' | 'json' | 'text' | 'value' | 'property' | 'entity' | 'entities';
92
90
  withCount?: boolean;
93
- bodyQueryOptions?: QueryOptionNames[];
91
+ bodyQueryOptions?: QueryOption[];
94
92
  }): Observable<any>;
95
93
  protected post(body: any, options?: ODataOptions & {
96
94
  responseType?: 'arraybuffer' | 'blob' | 'json' | 'text' | 'value' | 'property' | 'entity' | 'entities';
@@ -6,7 +6,7 @@ import { ODataPathSegments } from '../path';
6
6
  import { ODataQueryOptions } from '../query';
7
7
  import { ODataResource } from '../resource';
8
8
  import { ODataEntities, ODataEntity, ODataProperty } from '../responses';
9
- import { ODataEntitiesOptions, ODataEntityOptions, ODataNoneOptions, ODataOptions, ODataPropertyOptions } from './options';
9
+ import { ODataEntitiesOptions, ODataEntityOptions, ODataOptions, ODataPropertyOptions } from './options';
10
10
  export declare class ODataActionResource<P, R> extends ODataResource<R> {
11
11
  static factory<P, R>(api: ODataApi, { path, schema, segments, query, }: {
12
12
  path?: string;
@@ -26,7 +26,18 @@ export declare class ODataActionResource<P, R> extends ODataResource<R> {
26
26
  call(params: P | null, options?: ODataEntityOptions): Observable<ODataEntity<R>>;
27
27
  call(params: P | null, options?: ODataEntitiesOptions): Observable<ODataEntities<R>>;
28
28
  call(params: P | null, options?: ODataPropertyOptions): Observable<ODataProperty<R>>;
29
- call(params: P | null, options?: ODataNoneOptions): Observable<null>;
29
+ call(params: P | null, options?: {
30
+ alias?: boolean;
31
+ responseType?: 'blob';
32
+ } & ODataOptions): Observable<Blob>;
33
+ call(params: P | null, options?: {
34
+ alias?: boolean;
35
+ responseType?: 'arraybuffer';
36
+ } & ODataOptions): Observable<ArrayBuffer>;
37
+ call(params: P | null, options?: {
38
+ alias?: boolean;
39
+ responseType?: 'none';
40
+ } & ODataOptions): Observable<null>;
30
41
  /**
31
42
  * Execute the action and return the result as a property
32
43
  * @param params Parameters for the action
@@ -62,4 +73,10 @@ export declare class ODataActionResource<P, R> extends ODataResource<R> {
62
73
  * @returns Observable of the result of the action
63
74
  */
64
75
  callCollection<M extends ODataModel<R>, C extends ODataCollection<R, M>>(params: P | null, options?: ODataOptions): Observable<C | null>;
76
+ callArraybuffer(params: P | null, { alias, ...options }?: {
77
+ alias?: boolean;
78
+ } & ODataOptions): Observable<ArrayBuffer>;
79
+ callBlob(params: P | null, { alias, ...options }?: {
80
+ alias?: boolean;
81
+ } & ODataOptions): Observable<Blob>;
65
82
  }