angular-odata 0.100.1 → 0.102.5

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 (88) hide show
  1. package/esm2020/lib/api.mjs +84 -64
  2. package/esm2020/lib/cache/cache.mjs +56 -4
  3. package/esm2020/lib/cache/memory.mjs +16 -6
  4. package/esm2020/lib/cache/storage.mjs +23 -4
  5. package/esm2020/lib/client.mjs +3 -3
  6. package/esm2020/lib/constants.mjs +2 -1
  7. package/esm2020/lib/models/collection.mjs +103 -43
  8. package/esm2020/lib/models/model.mjs +17 -4
  9. package/esm2020/lib/models/options.mjs +200 -122
  10. package/esm2020/lib/module.mjs +5 -5
  11. package/esm2020/lib/options.mjs +3 -8
  12. package/esm2020/lib/resources/query/builder.mjs +1 -1
  13. package/esm2020/lib/resources/query/expressions/compute.mjs +5 -5
  14. package/esm2020/lib/resources/query/expressions/expand.mjs +6 -6
  15. package/esm2020/lib/resources/query/expressions/filter.mjs +9 -9
  16. package/esm2020/lib/resources/query/expressions/index.mjs +3 -1
  17. package/esm2020/lib/resources/query/expressions/orderby.mjs +5 -5
  18. package/esm2020/lib/resources/query/expressions/search.mjs +3 -3
  19. package/esm2020/lib/resources/query/expressions/select.mjs +7 -7
  20. package/esm2020/lib/resources/query/expressions/syntax.mjs +1 -1
  21. package/esm2020/lib/resources/query/handlers.mjs +208 -22
  22. package/esm2020/lib/resources/query/options.mjs +16 -13
  23. package/esm2020/lib/resources/request.mjs +31 -36
  24. package/esm2020/lib/resources/resource.mjs +27 -11
  25. package/esm2020/lib/resources/responses/annotations.mjs +1 -1
  26. package/esm2020/lib/resources/responses/metadata.mjs +1 -1
  27. package/esm2020/lib/resources/responses/options.mjs +1 -1
  28. package/esm2020/lib/resources/responses/response.mjs +2 -2
  29. package/esm2020/lib/resources/types/batch.mjs +108 -97
  30. package/esm2020/lib/resources/types/navigation-property.mjs +5 -3
  31. package/esm2020/lib/resources/types/options.mjs +1 -1
  32. package/esm2020/lib/resources/types/property.mjs +4 -4
  33. package/esm2020/lib/schema/callable.mjs +3 -3
  34. package/esm2020/lib/schema/enum-type.mjs +13 -26
  35. package/esm2020/lib/schema/parsers/callable.mjs +15 -20
  36. package/esm2020/lib/schema/parsers/enum-type.mjs +35 -18
  37. package/esm2020/lib/schema/parsers/structured-type.mjs +132 -66
  38. package/esm2020/lib/schema/structured-type.mjs +31 -39
  39. package/esm2020/lib/services/base.mjs +1 -1
  40. package/esm2020/lib/services/factory.mjs +3 -3
  41. package/esm2020/lib/types.mjs +1 -1
  42. package/esm2020/lib/utils/arrays.mjs +10 -0
  43. package/esm2020/lib/utils/enums.mjs +3 -3
  44. package/esm2020/lib/utils/objects.mjs +11 -6
  45. package/esm2020/lib/utils/types.mjs +6 -7
  46. package/fesm2015/angular-odata.mjs +3451 -2918
  47. package/fesm2015/angular-odata.mjs.map +1 -1
  48. package/fesm2020/angular-odata.mjs +3454 -2919
  49. package/fesm2020/angular-odata.mjs.map +1 -1
  50. package/{angular-odata.d.ts → index.d.ts} +0 -0
  51. package/lib/api.d.ts +2 -4
  52. package/lib/cache/cache.d.ts +62 -1
  53. package/lib/cache/memory.d.ts +10 -0
  54. package/lib/cache/storage.d.ts +19 -0
  55. package/lib/constants.d.ts +1 -0
  56. package/lib/models/collection.d.ts +14 -9
  57. package/lib/models/model.d.ts +10 -7
  58. package/lib/models/options.d.ts +31 -22
  59. package/lib/options.d.ts +3 -7
  60. package/lib/resources/query/builder.d.ts +1 -1
  61. package/lib/resources/query/expressions/compute.d.ts +7 -6
  62. package/lib/resources/query/expressions/expand.d.ts +17 -32
  63. package/lib/resources/query/expressions/filter.d.ts +11 -10
  64. package/lib/resources/query/expressions/index.d.ts +2 -0
  65. package/lib/resources/query/expressions/orderby.d.ts +7 -6
  66. package/lib/resources/query/expressions/search.d.ts +5 -4
  67. package/lib/resources/query/expressions/select.d.ts +7 -6
  68. package/lib/resources/query/handlers.d.ts +158 -33
  69. package/lib/resources/query/options.d.ts +14 -12
  70. package/lib/resources/request.d.ts +2 -1
  71. package/lib/resources/resource.d.ts +7 -6
  72. package/lib/resources/responses/options.d.ts +2 -2
  73. package/lib/resources/types/batch.d.ts +8 -11
  74. package/lib/resources/types/options.d.ts +4 -2
  75. package/lib/schema/callable.d.ts +4 -4
  76. package/lib/schema/enum-type.d.ts +11 -23
  77. package/lib/schema/parsers/callable.d.ts +11 -10
  78. package/lib/schema/parsers/enum-type.d.ts +22 -14
  79. package/lib/schema/parsers/structured-type.d.ts +58 -14
  80. package/lib/schema/structured-type.d.ts +23 -23
  81. package/lib/services/base.d.ts +9 -9
  82. package/lib/types.d.ts +11 -13
  83. package/lib/utils/arrays.d.ts +3 -0
  84. package/lib/utils/enums.d.ts +2 -2
  85. package/lib/utils/objects.d.ts +1 -1
  86. package/lib/utils/strings.d.ts +1 -1
  87. package/lib/utils/types.d.ts +1 -1
  88. package/package.json +5 -5
File without changes
package/lib/api.d.ts CHANGED
@@ -20,9 +20,7 @@ export declare class ODataApi {
20
20
  options: ODataApiOptions;
21
21
  cache: ODataCache;
22
22
  errorHandler?: (error: any, caught: Observable<any>) => Observable<never>;
23
- parsers: {
24
- [type: string]: Parser<any>;
25
- };
23
+ parsers: Map<string, Parser<any>>;
26
24
  schemas: ODataSchema[];
27
25
  constructor(config: ApiConfig);
28
26
  configure(settings?: {
@@ -96,5 +94,5 @@ export declare class ODataApi {
96
94
  findCollectionByName(name: string): typeof ODataCollection | undefined;
97
95
  findServiceByName(name: string): typeof ODataEntityService | undefined;
98
96
  parserForType<T>(type: string, bindingType?: string): Parser<T>;
99
- findOptionsForType<T>(type: string): ODataModelOptions<T> | undefined;
97
+ findOptionsForType<T>(type: string): ODataModelOptions<any> | ODataModelOptions<T> | undefined;
100
98
  }
@@ -1,6 +1,13 @@
1
1
  import { Observable } from 'rxjs';
2
2
  import { ODataRequest, ODataResponse } from '../resources';
3
3
  import { Cache } from '../types';
4
+ /**
5
+ * A cache entry that holds a payload, a last read time, and a timeout for the entry.
6
+ * @param payload The payload to cache.
7
+ * @param lastRead The last read time.
8
+ * @param timeout The timeout.
9
+ * @param tags Some tags to identify the entry.
10
+ */
4
11
  export interface ODataCacheEntry<T> {
5
12
  payload: T;
6
13
  lastRead: number;
@@ -15,28 +22,82 @@ export declare abstract class ODataCache implements Cache {
15
22
  });
16
23
  abstract getResponse(req: ODataRequest<any>): ODataResponse<any> | undefined;
17
24
  abstract putResponse(req: ODataRequest<any>, res: ODataResponse<any>): void;
25
+ /**
26
+ * Using the resource on the request build an array of string to identify the scope of the request
27
+ * @param req The request with the resource to build the scope
28
+ * @returns Array of string to identify the scope of the request
29
+ */
18
30
  scope(req: ODataRequest<any>): string[];
19
- tags(req: ODataRequest<any>, res: ODataResponse<any>): string[];
31
+ /**
32
+ * Using the odata context on the response build an array of string to identify the tags of the response
33
+ * @param res The response to build the tags
34
+ * @returns Array of string to identify the tags of the response
35
+ */
36
+ tags(res: ODataResponse<any>): string[];
37
+ /**
38
+ * Build an entry from a payload and some options
39
+ * @param payload The payload to store in the cache
40
+ * @param timeout The timeout for the entry
41
+ * @param tags The tags for the entry
42
+ * @returns The entry to store in the cache
43
+ */
20
44
  buildEntry<T>(payload: T, { timeout, tags }: {
21
45
  timeout?: number;
22
46
  tags?: string[];
23
47
  }): ODataCacheEntry<T>;
48
+ /**
49
+ * Build a key from store an entry in the cache
50
+ * @param names The names of the entry
51
+ * @returns The key for the entry
52
+ */
24
53
  buildKey(names: string[]): string;
54
+ /**
55
+ * Put some payload in the cache
56
+ * @param name The name for the entry
57
+ * @param payload The payload to store in the cache
58
+ * @param timeout The timeout for the entry
59
+ * @param scope The scope for the entry
60
+ * @param tags The tags for the entry
61
+ */
25
62
  put<T>(name: string, payload: T, { timeout, scope, tags, }?: {
26
63
  timeout?: number;
27
64
  scope?: string[];
28
65
  tags?: string[];
29
66
  }): void;
67
+ /**
68
+ * Return the payload from the cache if it exists and is not expired
69
+ * @param name The name of the entry
70
+ * @param scope The scope of the entry
71
+ * @returns The payload of the entry
72
+ */
30
73
  get<T>(name: string, { scope }?: {
31
74
  scope?: string[];
32
75
  }): T;
76
+ /**
77
+ * Remove all cache entries that are matching with the given options
78
+ * @param options The options to forget
79
+ */
33
80
  forget({ name, scope, tags, }?: {
34
81
  name?: string;
35
82
  scope?: string[];
36
83
  tags?: string[];
37
84
  }): void;
85
+ /**
86
+ * Remove all cache entries
87
+ */
38
88
  flush(): void;
89
+ /**
90
+ * Check if the entry is expired
91
+ * @param entry The cache entry
92
+ * @returns Boolean indicating if the entry is expired
93
+ */
39
94
  isExpired(entry: ODataCacheEntry<any>): boolean;
95
+ /**
96
+ * Using the request, handle the fetching of the response
97
+ * @param req The request to fetch
98
+ * @param res$ Observable of the response
99
+ * @returns
100
+ */
40
101
  handleRequest(req: ODataRequest<any>, res$: Observable<ODataResponse<any>>): Observable<ODataResponse<any>>;
41
102
  private handleFetch;
42
103
  private handleMutate;
@@ -4,6 +4,16 @@ export declare class ODataInMemoryCache extends ODataCache {
4
4
  constructor({ timeout }?: {
5
5
  timeout?: number;
6
6
  });
7
+ /**
8
+ * Store the response in the cache
9
+ * @param req The request with the resource to store the response
10
+ * @param res The response to store in the cache
11
+ */
7
12
  putResponse(req: ODataRequest<any>, res: ODataResponse<any>): void;
13
+ /**
14
+ * Restore the response from the cache
15
+ * @param req The request with the resource to get the response
16
+ * @returns The response from the cache
17
+ */
8
18
  getResponse(req: ODataRequest<any>): ODataResponse<any> | undefined;
9
19
  }
@@ -8,9 +8,28 @@ export declare class ODataInStorageCache extends ODataCache {
8
8
  name: string;
9
9
  storage?: Storage;
10
10
  });
11
+ /**
12
+ * Store the cache in the storage
13
+ */
11
14
  store(): void;
15
+ /**
16
+ * Restore the cache from the storage
17
+ */
12
18
  restore(): void;
19
+ /**
20
+ * Flush the cache and clean the storage
21
+ */
13
22
  flush(): void;
23
+ /**
24
+ * Store the response in the cache
25
+ * @param req The request with the resource to store the response
26
+ * @param res The response to store in the cache
27
+ */
14
28
  putResponse(req: ODataRequest<any>, res: ODataResponse<any>): void;
29
+ /**
30
+ * Restore the response from the cache
31
+ * @param req The request with the resource to get the response
32
+ * @returns The response from the cache
33
+ */
15
34
  getResponse(req: ODataRequest<any>): ODataResponse<any> | undefined;
16
35
  }
@@ -42,6 +42,7 @@ export declare const BINARY = "binary";
42
42
  export declare const BOUNDARY_PREFIX_SUFFIX = "--";
43
43
  export declare const BATCH_PREFIX = "batch_";
44
44
  export declare const CHANGESET_PREFIX = "changeset_";
45
+ export declare const DEFAULT_METADATA = "minimal";
45
46
  export declare const DEFAULT_STRIP_METADATA = "full";
46
47
  export declare const DEFAULT_FETCH_POLICY = "network-only";
47
48
  export declare const DEFAULT_TIMEOUT = 60;
@@ -1,6 +1,7 @@
1
1
  import { EventEmitter } from '@angular/core';
2
2
  import { Observable } from 'rxjs';
3
- import { ODataEntitiesAnnotations, ODataEntitySetResource, ODataNavigationPropertyResource, ODataOptions, ODataPropertyResource, ODataQueryArgumentsOptions, ODataQueryOptionsHandler, ODataResource } from '../resources';
3
+ import { ODataActionOptions, ODataEntitiesAnnotations, ODataEntitySetResource, ODataFunctionOptions, ODataNavigationPropertyResource, ODataOptions, ODataPropertyResource, ODataQueryOptionsHandler, ODataResource } from '../resources';
4
+ import { ODataStructuredType } from '../schema/structured-type';
4
5
  import { ODataModel } from './model';
5
6
  import { ODataModelEntry, ODataModelEvent, ODataModelField } from './options';
6
7
  export declare class ODataCollection<T, M extends ODataModel<T>> implements Iterable<M> {
@@ -68,19 +69,20 @@ export declare class ODataCollection<T, M extends ODataModel<T>> implements Iter
68
69
  private addReference;
69
70
  private _addModel;
70
71
  private addModel;
71
- add(model: M, { silent, reparent, server, position, }?: {
72
+ add(model: M, { silent, reparent, server, merge, position, }?: {
72
73
  silent?: boolean;
73
74
  reparent?: boolean;
74
75
  server?: boolean;
76
+ merge?: boolean;
75
77
  position?: number;
76
- }): Observable<this>;
78
+ }): Observable<M>;
77
79
  private removeReference;
78
80
  private _removeModel;
79
81
  private removeModel;
80
82
  remove(model: M, { silent, server, }?: {
81
83
  silent?: boolean;
82
84
  server?: boolean;
83
- }): Observable<this>;
85
+ }): Observable<M>;
84
86
  create(attrs?: T, { silent, server, }?: {
85
87
  silent?: boolean;
86
88
  server?: boolean;
@@ -92,6 +94,9 @@ export declare class ODataCollection<T, M extends ODataModel<T>> implements Iter
92
94
  path?: string | string[];
93
95
  silent?: boolean;
94
96
  }): void;
97
+ clear({ silent }?: {
98
+ silent?: boolean;
99
+ }): void;
95
100
  assign(objects: Partial<T>[] | {
96
101
  [name: string]: any;
97
102
  }[] | M[], { reset, reparent, silent, }?: {
@@ -99,11 +104,11 @@ export declare class ODataCollection<T, M extends ODataModel<T>> implements Iter
99
104
  reparent?: boolean;
100
105
  silent?: boolean;
101
106
  }): void;
102
- query(func: (q: ODataQueryOptionsHandler<T>) => void): this;
103
- callFunction<P, R>(name: string, params: P | null, responseType: 'property' | 'model' | 'collection' | 'none', { ...options }?: {} & ODataQueryArgumentsOptions<R>): Observable<R | ODataModel<R> | ODataCollection<R, ODataModel<R>> | null>;
104
- callAction<P, R>(name: string, params: P | null, responseType: 'property' | 'model' | 'collection' | 'none', { ...options }?: {} & ODataQueryArgumentsOptions<R>): Observable<R | ODataModel<R> | ODataCollection<R, ODataModel<R>> | null>;
105
- private _unsubscribe;
106
- private _subscribe;
107
+ query(func: (q: ODataQueryOptionsHandler<T>, s?: ODataStructuredType<T>) => void): this;
108
+ 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>;
109
+ 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>;
110
+ private _unlink;
111
+ private _link;
107
112
  private _findEntry;
108
113
  equals(other: ODataCollection<T, ODataModel<T>>): boolean;
109
114
  get [Symbol.toStringTag](): string;
@@ -1,6 +1,6 @@
1
1
  import { EventEmitter } from '@angular/core';
2
2
  import { Observable } from 'rxjs';
3
- import { EntityKey, ODataEntityAnnotations, ODataEntityResource, ODataNavigationPropertyResource, ODataOptions, ODataPropertyResource, ODataQueryArgumentsOptions, ODataQueryOptionsHandler, ODataResource, ODataSingletonResource } from '../resources';
3
+ import { EntityKey, ODataActionOptions, ODataEntityAnnotations, ODataEntityResource, ODataFunctionOptions, ODataNavigationPropertyResource, ODataOptions, ODataPropertyResource, ODataQueryArgumentsOptions, ODataQueryOptionsHandler, ODataResource, ODataSingletonResource } from '../resources';
4
4
  import { ODataStructuredType } from '../schema';
5
5
  import { ODataCollection } from './collection';
6
6
  import { ModelOptions, ODataModelEvent, ODataModelField, ODataModelOptions, ODataModelRelation } from './options';
@@ -55,13 +55,13 @@ export declare class ODataModel<T> {
55
55
  resolve?: boolean;
56
56
  }): {
57
57
  [name: string]: any;
58
- } | undefined;
58
+ } | null | undefined;
59
59
  referenced(field: ODataModelField<any>, { field_mapping, resolve, }?: {
60
60
  field_mapping?: boolean;
61
61
  resolve?: boolean;
62
62
  }): {
63
63
  [name: string]: any;
64
- } | undefined;
64
+ } | null | undefined;
65
65
  _errors?: {
66
66
  [key: string]: any;
67
67
  };
@@ -109,6 +109,9 @@ export declare class ODataModel<T> {
109
109
  path?: string | string[];
110
110
  silent?: boolean;
111
111
  }): void;
112
+ clear({ silent }?: {
113
+ silent?: boolean;
114
+ }): void;
112
115
  assign(entity: Partial<T> | {
113
116
  [name: string]: any;
114
117
  }, { reset, reparent, silent, }?: {
@@ -134,7 +137,7 @@ export declare class ODataModel<T> {
134
137
  * Create an execution context for change the internal query of a resource
135
138
  * @param func Function to execute
136
139
  */
137
- query(func: (q: ODataQueryOptionsHandler<T>) => void): this;
140
+ query(func: (q: ODataQueryOptionsHandler<T>, s?: ODataStructuredType<T>) => void): this;
138
141
  /**
139
142
  * Perform a check on the internal state of the model and return true if the model is changed.
140
143
  * @param include_navigation Check in navigation properties
@@ -149,13 +152,13 @@ export declare class ODataModel<T> {
149
152
  * @returns The result of the context
150
153
  */
151
154
  asEntity<R>(ctx: (model: this) => R): R;
152
- callFunction<P, R>(name: string, params: P | null, responseType: 'property' | 'model' | 'collection' | 'none', { ...options }?: {} & ODataQueryArgumentsOptions<R>): Observable<R | ODataModel<R> | ODataCollection<R, ODataModel<R>> | null>;
153
- callAction<P, R>(name: string, params: P | null, responseType: 'property' | 'model' | 'collection' | 'none', { ...options }?: {} & ODataQueryArgumentsOptions<R>): Observable<R | ODataModel<R> | ODataCollection<R, ODataModel<R>> | null>;
155
+ 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>;
156
+ 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>;
154
157
  cast<S>(type: string): ODataModel<S>;
155
158
  fetchNavigationProperty<S>(name: keyof T | string, responseType: 'model' | 'collection', { ...options }?: {} & ODataQueryArgumentsOptions<S>): Observable<ODataModel<S> | ODataCollection<S, ODataModel<S>> | null>;
156
159
  getValue<P>(name: keyof T | string, options?: ODataOptions): Observable<P | ODataModel<P> | ODataCollection<P, ODataModel<P>> | null>;
157
160
  setReference<N>(name: keyof T | string, model: ODataModel<N> | ODataCollection<N, ODataModel<N>> | null, options?: ODataOptions): Observable<this>;
158
- getReference<P>(name: keyof T | string): ODataModel<P> | ODataCollection<P, ODataModel<P>>;
161
+ getReference<P>(name: keyof T | string): ODataModel<P> | ODataCollection<P, ODataModel<P>> | null;
159
162
  equals(other: ODataModel<T>): boolean;
160
163
  get [Symbol.toStringTag](): string;
161
164
  collection(): ODataCollection<T, ODataModel<T>> | undefined;
@@ -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 { OptionsHelper } from '../types';
4
+ import { 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';
@@ -10,10 +10,10 @@ export declare class ODataModelEvent<T> {
10
10
  value?: any;
11
11
  previous?: any;
12
12
  options?: any;
13
- constructor(name: ODataModelEventType, { model, collection, previous, value, track, options, }?: {
13
+ constructor(name: ODataModelEventType, { model, collection, previous, value, field, options, }?: {
14
14
  model?: ODataModel<T>;
15
15
  collection?: ODataCollection<T, ODataModel<T>>;
16
- track?: string | number;
16
+ field?: ODataModelField<any> | number;
17
17
  previous?: any;
18
18
  value?: any;
19
19
  options?: any;
@@ -22,9 +22,9 @@ export declare class ODataModelEvent<T> {
22
22
  stopPropagation(): void;
23
23
  chain: [
24
24
  ODataModel<any> | ODataCollection<any, ODataModel<any>>,
25
- string | number | null
25
+ ODataModelField<any> | number | null
26
26
  ][];
27
- push(model: ODataModel<any> | ODataCollection<any, ODataModel<any>>, track: string | number): void;
27
+ push(model: ODataModel<any> | ODataCollection<any, ODataModel<any>>, field: ODataModelField<any> | number): ODataModelEvent<T>;
28
28
  visited(model: ODataModel<any> | ODataCollection<any, ODataModel<any>>): boolean;
29
29
  get path(): string;
30
30
  model?: ODataModel<T>;
@@ -93,6 +93,7 @@ export declare class ODataModelField<F> {
93
93
  min?: number;
94
94
  max?: number;
95
95
  pattern?: RegExp;
96
+ parserOptions?: ParserOptions;
96
97
  constructor(options: ODataModelOptions<any>, { name, field, parser, ...opts }: ODataModelFieldOptions<F>);
97
98
  get api(): import("angular-odata").ODataApi;
98
99
  get type(): string;
@@ -102,7 +103,7 @@ export declare class ODataModelField<F> {
102
103
  configure({ findOptionsForType, concurrency, options, }: {
103
104
  findOptionsForType: (type: string) => ODataModelOptions<any> | undefined;
104
105
  concurrency: boolean;
105
- options: OptionsHelper;
106
+ options: ParserOptions;
106
107
  }): void;
107
108
  isKey(): boolean;
108
109
  hasReferentials(): boolean;
@@ -116,9 +117,9 @@ export declare class ODataModelField<F> {
116
117
  navigation?: boolean;
117
118
  }): any;
118
119
  defaults(): any;
119
- deserialize(value: any, options?: OptionsHelper): F;
120
- serialize(value: F, options?: OptionsHelper): any;
121
- encode(value: F, options?: OptionsHelper): any;
120
+ deserialize(value: any, options?: ParserOptions): F;
121
+ serialize(value: F, options?: ParserOptions): any;
122
+ encode(value: F, options?: ParserOptions): any;
122
123
  resourceFactory<T, F>(base: ODataResource<T>): ODataNavigationPropertyResource<F> | ODataPropertyResource<F>;
123
124
  annotationsFactory(base: ODataEntityAnnotations): ODataEntityAnnotations | ODataEntitiesAnnotations;
124
125
  schemaFactory<T, F>(base: ODataStructuredType<T>): ODataStructuredType<F> | undefined;
@@ -161,16 +162,21 @@ export declare class ODataModelOptions<T> {
161
162
  schema: ODataStructuredType<T>;
162
163
  });
163
164
  get api(): import("angular-odata").ODataApi;
164
- type(): string;
165
+ type({ alias }?: {
166
+ alias?: boolean;
167
+ }): string;
165
168
  isTypeOf(type: string): boolean;
169
+ isModelFor(entity: T | {
170
+ [name: string]: any;
171
+ }): boolean;
166
172
  findChildOptions(predicate: (options: ODataModelOptions<any>) => boolean): ODataModelOptions<any> | undefined;
167
173
  configure({ findOptionsForType, options, }: {
168
174
  findOptionsForType: (type: string) => ODataModelOptions<any> | undefined;
169
- options: OptionsHelper;
175
+ options: ParserOptions;
170
176
  }): void;
171
- fields({ include_navigation, include_parents, }?: {
172
- include_parents?: boolean;
173
- include_navigation?: boolean;
177
+ fields({ include_navigation, include_parents, }: {
178
+ include_parents: boolean;
179
+ include_navigation: boolean;
174
180
  }): ODataModelField<any>[];
175
181
  field<F>(name: keyof T | string): ODataModelField<F>;
176
182
  attach<R>(self: ODataModel<T>, resource: ODataEntityResource<R> | ODataNavigationPropertyResource<R> | ODataPropertyResource<R> | ODataSingletonResource<R>): void;
@@ -190,31 +196,34 @@ export declare class ODataModelOptions<T> {
190
196
  resource?: ODataResource<T>;
191
197
  annots?: ODataEntityAnnotations;
192
198
  }): void;
193
- query(self: ODataModel<T>, resource: ODataEntityResource<T> | ODataPropertyResource<T> | ODataNavigationPropertyResource<T> | ODataSingletonResource<T>, func: (q: ODataQueryOptionsHandler<T>) => void): ODataModel<T>;
199
+ query(self: ODataModel<T>, resource: ODataEntityResource<T> | ODataPropertyResource<T> | ODataNavigationPropertyResource<T> | ODataSingletonResource<T>, func: (q: ODataQueryOptionsHandler<T>, s?: ODataStructuredType<T>) => void): ODataModel<T>;
194
200
  resolveKey(value: ODataModel<T> | T | {
195
201
  [name: string]: any;
196
- }, { field_mapping, resolve, }?: {
202
+ }, { field_mapping, resolve, single, }?: {
197
203
  field_mapping?: boolean;
198
204
  resolve?: boolean;
205
+ single?: boolean;
199
206
  }): EntityKey<T> | {
200
207
  [name: string]: any;
201
208
  } | undefined;
202
209
  resolveReferential(value: ODataModel<T> | T | {
203
210
  [name: string]: any;
204
- } | null, field: ODataModelField<any>, { field_mapping, resolve, }?: {
211
+ } | null, field: ODataModelField<any>, { field_mapping, resolve, single, }?: {
205
212
  field_mapping?: boolean;
206
213
  resolve?: boolean;
214
+ single?: boolean;
207
215
  }): {
208
216
  [name: string]: any;
209
- } | undefined;
217
+ } | null | undefined;
210
218
  resolveReferenced(value: ODataModel<T> | T | {
211
219
  [name: string]: any;
212
- } | null, field: ODataModelField<any>, { field_mapping, resolve, }?: {
220
+ } | null, field: ODataModelField<any>, { field_mapping, resolve, single, }?: {
213
221
  field_mapping?: boolean;
214
222
  resolve?: boolean;
223
+ single?: boolean;
215
224
  }): {
216
225
  [name: string]: any;
217
- } | undefined;
226
+ } | null | undefined;
218
227
  validate(self: ODataModel<T>, { method, navigation, }?: {
219
228
  method?: 'create' | 'update' | 'modify';
220
229
  navigation?: boolean;
@@ -269,6 +278,6 @@ export declare class ODataModelOptions<T> {
269
278
  private _setStructured;
270
279
  private _setValue;
271
280
  private _set;
272
- private _unsubscribe;
273
- private _subscribe;
281
+ private _unlink;
282
+ private _link;
274
283
  }
package/lib/options.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { ApiOptions, FetchPolicy, ODataMetadataType, ODataVersion, OptionsHelper, QueryOptionNames } from './types';
2
- export declare class ODataApiOptions implements ApiOptions, OptionsHelper {
1
+ import { ApiOptions, FetchPolicy, ODataMetadataType, ODataVersion, ParserOptions, QueryOptionNames } from './types';
2
+ export declare class ODataApiOptions implements ApiOptions {
3
3
  /**
4
4
  * Default OData version
5
5
  */
@@ -77,10 +77,6 @@ export declare class ODataApiOptions implements ApiOptions, OptionsHelper {
77
77
  deleteRefBy: 'path' | 'id';
78
78
  nonParenthesisForEmptyParameterFunction: boolean;
79
79
  constructor(config: ApiOptions);
80
- get helper(): import("./helper").ODataVersionHelper;
81
- }
82
- export declare class ODataParserOptions implements OptionsHelper {
83
- version: ODataVersion;
84
- constructor(config: OptionsHelper);
80
+ get parserOptions(): ParserOptions;
85
81
  get helper(): import("./helper").ODataVersionHelper;
86
82
  }
@@ -59,7 +59,7 @@ export declare type QueryCustomType = {
59
59
  };
60
60
  export declare type Value = string | Date | number | boolean | QueryCustomType;
61
61
  export declare const raw: (value: string) => QueryCustomType;
62
- export declare const alias: (value: any, name?: string | undefined) => QueryCustomType;
62
+ export declare const alias: (value: any, name?: string) => QueryCustomType;
63
63
  export declare const duration: (value: string) => QueryCustomType;
64
64
  export declare const binary: (value: string) => QueryCustomType;
65
65
  export declare const isQueryCustomType: (value: any) => boolean;
@@ -1,18 +1,19 @@
1
1
  import type { QueryCustomType } from '../builder';
2
2
  import { Expression } from './base';
3
3
  import { ODataFunctions, ODataOperators, Renderable } from './syntax';
4
+ export declare type ComputeExpressionBuilder<T> = {
5
+ t: T;
6
+ e: () => ComputeExpression<T>;
7
+ };
4
8
  export declare class ComputeExpression<T> extends Expression<T> {
5
9
  names: string[];
6
10
  constructor({ children, names, }?: {
7
11
  children?: Renderable[];
8
12
  names?: string[];
9
13
  });
10
- static e<T>(): ComputeExpression<T>;
11
- static s<T extends object>(): T;
12
- static compute<T extends object>(opts: (builder: {
13
- s: T;
14
- e: () => ComputeExpression<T>;
15
- }, current?: ComputeExpression<T>) => ComputeExpression<T>, current?: ComputeExpression<T>): ComputeExpression<T>;
14
+ static expression<T>(): ComputeExpression<T>;
15
+ static type<T extends object>(): T;
16
+ static compute<T extends object>(opts: (builder: ComputeExpressionBuilder<T>, current?: ComputeExpression<T>) => ComputeExpression<T>, current?: ComputeExpression<T>): ComputeExpression<T>;
16
17
  render({ aliases, escape, prefix, }?: {
17
18
  aliases?: QueryCustomType[] | undefined;
18
19
  escape?: boolean | undefined;
@@ -1,10 +1,10 @@
1
1
  import type { QueryCustomType } from '../builder';
2
2
  import { Expression } from './base';
3
- import { FilterConnector, FilterExpression } from './filter';
4
- import { OrderByExpression } from './orderby';
5
- import { SearchConnector, SearchExpression } from './search';
6
- import { SelectExpression } from './select';
7
- import { ODataFunctions, ODataOperators, Renderable } from './syntax';
3
+ import { FilterExpression, FilterExpressionBuilder } from './filter';
4
+ import { OrderByExpression, OrderByExpressionBuilder } from './orderby';
5
+ import { SearchExpression, SearchExpressionBuilder } from './search';
6
+ import { SelectExpression, SelectExpressionBuilder } from './select';
7
+ import { Renderable } from './syntax';
8
8
  export declare class ExpandField<T> implements Renderable {
9
9
  protected field: any;
10
10
  private values;
@@ -21,42 +21,27 @@ export declare class ExpandField<T> implements Renderable {
21
21
  prefix?: string;
22
22
  }): string;
23
23
  clone(): ExpandField<unknown>;
24
- select<T extends object>(opts: (builder: {
25
- s: T;
26
- e: () => SelectExpression<T>;
27
- }, current?: SelectExpression<T>) => SelectExpression<T>): SelectExpression<T>;
28
- expand<T extends object>(opts: (builder: {
29
- s: T;
30
- e: () => ExpandExpression<T>;
31
- }, current?: ExpandExpression<T>) => ExpandExpression<T>): any;
32
- filter<T extends object>(opts: (builder: {
33
- s: T;
34
- e: (connector?: FilterConnector) => FilterExpression<T>;
35
- o: ODataOperators<T>;
36
- f: ODataFunctions<T>;
37
- }, current?: FilterExpression<T>) => FilterExpression<T>): any;
38
- search<T extends object>(opts: (builder: {
39
- e: (connector?: SearchConnector) => SearchExpression<T>;
40
- }) => SearchExpression<T>): any;
41
- orderBy<T extends object>(opts: (builder: {
42
- s: T;
43
- e: () => OrderByExpression<T>;
44
- }, current?: OrderByExpression<T>) => OrderByExpression<T>): any;
24
+ select<T extends object>(opts: (builder: SelectExpressionBuilder<T>, current?: SelectExpression<T>) => SelectExpression<T>): SelectExpression<T>;
25
+ expand<T extends object>(opts: (builder: ExpandExpressionBuilder<T>, current?: ExpandExpression<T>) => ExpandExpression<T>): any;
26
+ filter<T extends object>(opts: (builder: FilterExpressionBuilder<T>, current?: FilterExpression<T>) => FilterExpression<T>): any;
27
+ search<T extends object>(opts: (builder: SearchExpressionBuilder<T>) => SearchExpression<T>): any;
28
+ orderBy<T extends object>(opts: (builder: OrderByExpressionBuilder<T>, current?: OrderByExpression<T>) => OrderByExpression<T>): any;
45
29
  skip(n: number): any;
46
30
  top(n: number): any;
47
31
  levels(n: number | 'max'): any;
48
32
  private option;
49
33
  }
34
+ export declare type ExpandExpressionBuilder<T> = {
35
+ t: T;
36
+ e: () => ExpandExpression<T>;
37
+ };
50
38
  export declare class ExpandExpression<T> extends Expression<T> {
51
39
  constructor({ children, }?: {
52
40
  children?: Renderable[];
53
41
  });
54
- static e<T>(): ExpandExpression<T>;
55
- static s<T extends object>(): T;
56
- static expand<T extends object>(opts: (builder: {
57
- s: T;
58
- e: () => ExpandExpression<T>;
59
- }, current?: ExpandExpression<T>) => ExpandExpression<T>, current?: ExpandExpression<T>): ExpandExpression<T>;
42
+ static expression<T>(): ExpandExpression<T>;
43
+ static type<T extends object>(): T;
44
+ static expand<T extends object>(opts: (builder: ExpandExpressionBuilder<T>, current?: ExpandExpression<T>) => ExpandExpression<T>, current?: ExpandExpression<T>): ExpandExpression<T>;
60
45
  render({ aliases, escape, prefix, }?: {
61
46
  aliases?: QueryCustomType[] | undefined;
62
47
  escape?: boolean | undefined;
@@ -2,6 +2,12 @@ import type { QueryCustomType } from '../builder';
2
2
  import { Expression } from './base';
3
3
  import { ODataFunctions, ODataOperators, Renderable } from './syntax';
4
4
  export declare type FilterConnector = 'and' | 'or';
5
+ export declare type FilterExpressionBuilder<T> = {
6
+ t: T;
7
+ e: (connector?: FilterConnector) => FilterExpression<T>;
8
+ o: ODataOperators<T>;
9
+ f: ODataFunctions<T>;
10
+ };
5
11
  export declare class FilterExpression<F> extends Expression<F> {
6
12
  private _connector;
7
13
  private _negated;
@@ -10,14 +16,9 @@ export declare class FilterExpression<F> extends Expression<F> {
10
16
  connector?: FilterConnector;
11
17
  negated?: boolean;
12
18
  });
13
- static s<T extends object>(): T;
14
- static e<T>(connector?: FilterConnector): FilterExpression<T>;
15
- static filter<T extends object>(opts: (builder: {
16
- s: T;
17
- e: (connector?: FilterConnector) => FilterExpression<T>;
18
- o: ODataOperators<T>;
19
- f: ODataFunctions<T>;
20
- }, current?: FilterExpression<T>) => FilterExpression<T>, current?: FilterExpression<T>): FilterExpression<T>;
19
+ static type<T extends object>(): T;
20
+ static expression<T>(connector?: FilterConnector): FilterExpression<T>;
21
+ static filter<T extends object>(opts: (builder: FilterExpressionBuilder<T>, current?: FilterExpression<T>) => FilterExpression<T>, current?: FilterExpression<T>): FilterExpression<T>;
21
22
  toJSON(): {
22
23
  children: any[];
23
24
  connector: FilterConnector;
@@ -47,11 +48,11 @@ export declare class FilterExpression<F> extends Expression<F> {
47
48
  startsWith(left: any, right: any, normalize?: boolean): FilterExpression<F>;
48
49
  endsWith(left: any, right: any, normalize?: boolean): FilterExpression<F>;
49
50
  any<N extends object>(left: N[], opts: (e: {
50
- s: N;
51
51
  e: (connector?: FilterConnector) => FilterExpression<N>;
52
+ t: N;
52
53
  }) => FilterExpression<N>, alias?: string): FilterExpression<F>;
53
54
  all<N extends object>(left: N[], opts: (e: {
54
- s: N;
55
+ t: N;
55
56
  e: (connector?: FilterConnector) => FilterExpression<N>;
56
57
  }) => FilterExpression<N>, alias?: string): FilterExpression<F>;
57
58
  isof(type: string): FilterExpression<F>;
@@ -3,4 +3,6 @@ export * from './compute';
3
3
  export * from './filter';
4
4
  export * from './orderby';
5
5
  export * from './search';
6
+ export * from './select';
6
7
  export * from './syntax';
8
+ export * from './expand';
@@ -17,16 +17,17 @@ export declare class OrderByField implements Renderable {
17
17
  }): string;
18
18
  clone(): OrderByField;
19
19
  }
20
+ export declare type OrderByExpressionBuilder<T> = {
21
+ t: T;
22
+ e: () => OrderByExpression<T>;
23
+ };
20
24
  export declare class OrderByExpression<T> extends Expression<T> {
21
25
  constructor({ children, }?: {
22
26
  children?: Renderable[];
23
27
  });
24
- static e<T>(): OrderByExpression<T>;
25
- static s<T extends object>(): T;
26
- static orderBy<T extends object>(opts: (builder: {
27
- s: T;
28
- e: () => OrderByExpression<T>;
29
- }, current?: OrderByExpression<T>) => OrderByExpression<T>, current?: OrderByExpression<T>): OrderByExpression<T>;
28
+ static expression<T>(): OrderByExpression<T>;
29
+ static type<T extends object>(): T;
30
+ static orderBy<T extends object>(opts: (builder: OrderByExpressionBuilder<T>, current?: OrderByExpression<T>) => OrderByExpression<T>, current?: OrderByExpression<T>): OrderByExpression<T>;
30
31
  private _add;
31
32
  render({ aliases, escape, prefix, }?: {
32
33
  aliases?: QueryCustomType[] | undefined;