angular-odata 0.101.0 → 0.102.6

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 (67) hide show
  1. package/esm2020/lib/api.mjs +83 -63
  2. package/esm2020/lib/cache/cache.mjs +1 -1
  3. package/esm2020/lib/cache/memory.mjs +3 -3
  4. package/esm2020/lib/cache/storage.mjs +3 -3
  5. package/esm2020/lib/client.mjs +3 -3
  6. package/esm2020/lib/models/collection.mjs +5 -6
  7. package/esm2020/lib/models/model.mjs +1 -3
  8. package/esm2020/lib/models/options.mjs +84 -44
  9. package/esm2020/lib/module.mjs +5 -5
  10. package/esm2020/lib/resources/query/builder.mjs +1 -1
  11. package/esm2020/lib/resources/query/expressions/compute.mjs +5 -5
  12. package/esm2020/lib/resources/query/expressions/expand.mjs +6 -6
  13. package/esm2020/lib/resources/query/expressions/filter.mjs +9 -9
  14. package/esm2020/lib/resources/query/expressions/index.mjs +3 -1
  15. package/esm2020/lib/resources/query/expressions/orderby.mjs +5 -5
  16. package/esm2020/lib/resources/query/expressions/search.mjs +3 -3
  17. package/esm2020/lib/resources/query/expressions/select.mjs +7 -7
  18. package/esm2020/lib/resources/query/handlers.mjs +140 -22
  19. package/esm2020/lib/resources/query/options.mjs +16 -13
  20. package/esm2020/lib/resources/request.mjs +31 -36
  21. package/esm2020/lib/resources/resource.mjs +15 -3
  22. package/esm2020/lib/resources/types/navigation-property.mjs +5 -3
  23. package/esm2020/lib/resources/types/options.mjs +1 -1
  24. package/esm2020/lib/resources/types/property.mjs +4 -4
  25. package/esm2020/lib/schema/enum-type.mjs +9 -25
  26. package/esm2020/lib/schema/parsers/callable.mjs +6 -1
  27. package/esm2020/lib/schema/parsers/enum-type.mjs +23 -3
  28. package/esm2020/lib/schema/parsers/structured-type.mjs +120 -42
  29. package/esm2020/lib/schema/structured-type.mjs +26 -38
  30. package/esm2020/lib/services/base.mjs +1 -1
  31. package/esm2020/lib/services/factory.mjs +3 -3
  32. package/esm2020/lib/types.mjs +1 -1
  33. package/esm2020/lib/utils/objects.mjs +2 -2
  34. package/esm2020/lib/utils/types.mjs +2 -7
  35. package/fesm2015/angular-odata.mjs +601 -342
  36. package/fesm2015/angular-odata.mjs.map +1 -1
  37. package/fesm2020/angular-odata.mjs +593 -335
  38. package/fesm2020/angular-odata.mjs.map +1 -1
  39. package/{angular-odata.d.ts → index.d.ts} +0 -0
  40. package/lib/api.d.ts +2 -4
  41. package/lib/models/collection.d.ts +5 -4
  42. package/lib/models/model.d.ts +4 -4
  43. package/lib/models/options.d.ts +20 -12
  44. package/lib/resources/query/builder.d.ts +1 -1
  45. package/lib/resources/query/expressions/compute.d.ts +7 -6
  46. package/lib/resources/query/expressions/expand.d.ts +17 -32
  47. package/lib/resources/query/expressions/filter.d.ts +11 -10
  48. package/lib/resources/query/expressions/index.d.ts +2 -0
  49. package/lib/resources/query/expressions/orderby.d.ts +7 -6
  50. package/lib/resources/query/expressions/search.d.ts +5 -4
  51. package/lib/resources/query/expressions/select.d.ts +7 -6
  52. package/lib/resources/query/handlers.d.ts +39 -33
  53. package/lib/resources/query/options.d.ts +14 -12
  54. package/lib/resources/request.d.ts +2 -1
  55. package/lib/resources/resource.d.ts +3 -2
  56. package/lib/resources/types/options.d.ts +4 -2
  57. package/lib/schema/enum-type.d.ts +7 -19
  58. package/lib/schema/parsers/callable.d.ts +1 -0
  59. package/lib/schema/parsers/enum-type.d.ts +18 -10
  60. package/lib/schema/parsers/structured-type.d.ts +47 -3
  61. package/lib/schema/structured-type.d.ts +19 -19
  62. package/lib/services/base.d.ts +9 -9
  63. package/lib/types.d.ts +5 -5
  64. package/lib/utils/objects.d.ts +1 -1
  65. package/lib/utils/strings.d.ts +1 -1
  66. package/lib/utils/types.d.ts +0 -1
  67. package/package.json +5 -5
@@ -5,7 +5,7 @@ import { ODataSchema } from './schema';
5
5
  export declare class ODataEnumType<E> extends ODataSchemaElement {
6
6
  parser: ODataEnumTypeParser<E>;
7
7
  members: {
8
- [name: string]: number;
8
+ [name: string]: E;
9
9
  } | {
10
10
  [value: number]: string;
11
11
  };
@@ -15,31 +15,19 @@ export declare class ODataEnumType<E> extends ODataSchemaElement {
15
15
  * Returns the fields of the enum type.
16
16
  * @returns The fields of the enum type.
17
17
  */
18
- fields(): ODataEnumTypeFieldParser[];
18
+ fields(value?: E): ODataEnumTypeFieldParser<E>[];
19
19
  /**
20
- * Find a field by name.
21
- * @param name The name of the field
22
- * @returns The field with the given name
20
+ * Find a field by name or value.
21
+ * @param enu The name or value of the field
22
+ * @returns The field with the given name or value
23
23
  */
24
- findFieldByName(name: string): ODataEnumTypeFieldParser | undefined;
25
- /**
26
- * Find a field by value.
27
- * @param value The value of the field
28
- * @returns The field with the given value
29
- */
30
- findFieldByValue(value: number): ODataEnumTypeFieldParser | undefined;
31
- /**
32
- * Find a fields by flag.
33
- * @param value The value of the field
34
- * @returns The fields with the given flag
35
- */
36
- findFieldsByValue(value: number): ODataEnumTypeFieldParser[];
24
+ field(enu: string | E): ODataEnumTypeFieldParser<E>;
37
25
  /**
38
26
  * Map the fields of the enum type.
39
27
  * @param mapper Function that maps the value to the new value
40
28
  * @returns The fields mapped by the mapper
41
29
  */
42
- mapFields<T>(mapper: (field: ODataEnumTypeFieldParser) => T): T[];
30
+ mapFields<T>(mapper: (field: ODataEnumTypeFieldParser<E>) => T): T[];
43
31
  /**
44
32
  * Deseialize the given value from the enum type.
45
33
  * @param value Value to deserialize
@@ -20,6 +20,7 @@ export declare class ODataParameterParser<T> {
20
20
  enum(): ODataEnumTypeParser<T>;
21
21
  isStructuredType(): boolean;
22
22
  structured(): ODataStructuredTypeParser<T>;
23
+ field<F>(name: string): import("./structured-type").ODataStructuredTypeFieldParser<F>;
23
24
  }
24
25
  export declare class ODataCallableParser<R> implements Parser<R> {
25
26
  name: string;
@@ -1,25 +1,25 @@
1
1
  import { EnumTypeConfig, EnumTypeFieldConfig, ParserOptions, Parser } from '../../types';
2
2
  import { ODataAnnotatable } from '../annotation';
3
- export declare class ODataEnumTypeFieldParser extends ODataAnnotatable {
3
+ export declare class ODataEnumTypeFieldParser<E> extends ODataAnnotatable {
4
4
  name: string;
5
- value: number;
6
- constructor(name: string, field: EnumTypeFieldConfig);
5
+ value: E;
6
+ constructor(name: string, field: EnumTypeFieldConfig<E>);
7
7
  titleize(term?: string | RegExp): string;
8
8
  }
9
- export declare class ODataEnumTypeParser<T> extends ODataAnnotatable implements Parser<T> {
9
+ export declare class ODataEnumTypeParser<E> extends ODataAnnotatable implements Parser<E> {
10
10
  name: string;
11
11
  namespace: string;
12
12
  alias?: string;
13
13
  flags?: boolean;
14
14
  members: {
15
- [name: string]: number;
15
+ [name: string]: E;
16
16
  } | {
17
17
  [value: number]: string;
18
18
  };
19
- fields: ODataEnumTypeFieldParser[];
19
+ private _fields;
20
20
  stringAsEnum?: boolean;
21
21
  parserOptions?: ParserOptions;
22
- constructor(config: EnumTypeConfig<T>, namespace: string, alias?: string);
22
+ constructor(config: EnumTypeConfig<E>, namespace: string, alias?: string);
23
23
  /**
24
24
  * Create a nicer looking title.
25
25
  * Titleize is meant for creating pretty output.
@@ -32,9 +32,17 @@ export declare class ODataEnumTypeParser<T> extends ODataAnnotatable implements
32
32
  options: ParserOptions;
33
33
  }): void;
34
34
  isTypeOf(type: string): boolean;
35
- deserialize(value: string, options?: ParserOptions): T;
36
- serialize(value: T, options?: ParserOptions): string | undefined;
37
- encode(value: T, options?: ParserOptions): any;
35
+ fields(value?: E): ODataEnumTypeFieldParser<E>[];
36
+ field(nameValue: string | E): ODataEnumTypeFieldParser<E>;
37
+ /**
38
+ * Map the fields of the enum type.
39
+ * @param mapper Function that maps the value to the new value
40
+ * @returns The fields mapped by the mapper
41
+ */
42
+ mapFields<R>(mapper: (field: ODataEnumTypeFieldParser<E>) => R): R[];
43
+ deserialize(value: string, options?: ParserOptions): E;
44
+ serialize(value: E, options?: ParserOptions): string | undefined;
45
+ encode(value: E, options?: ParserOptions): any;
38
46
  toJsonSchema(): any;
39
47
  validate(member: string | number, { method, navigation, }?: {
40
48
  method?: 'create' | 'update' | 'modify';
@@ -73,6 +73,7 @@ export declare class ODataStructuredTypeFieldParser<T> extends ODataAnnotatable
73
73
  enum(): ODataEnumTypeParser<T>;
74
74
  isStructuredType(): boolean;
75
75
  structured(): ODataStructuredTypeParser<T>;
76
+ field<F>(name: string): ODataStructuredTypeFieldParser<F>;
76
77
  }
77
78
  export declare class ODataStructuredTypeParser<T> extends ODataAnnotatable implements Parser<T> {
78
79
  name: string;
@@ -82,8 +83,8 @@ export declare class ODataStructuredTypeParser<T> extends ODataAnnotatable imple
82
83
  alias?: string;
83
84
  base?: string;
84
85
  parent?: ODataStructuredTypeParser<any>;
85
- keys?: ODataEntityTypeKey[];
86
- fields: ODataStructuredTypeFieldParser<any>[];
86
+ private _keys?;
87
+ private _fields;
87
88
  parserOptions?: ParserOptions;
88
89
  constructor(config: StructuredTypeConfig<T>, namespace: string, alias?: string);
89
90
  /**
@@ -104,7 +105,50 @@ export declare class ODataStructuredTypeParser<T> extends ODataAnnotatable imple
104
105
  parserForType: (type: string) => Parser<any>;
105
106
  options: ParserOptions;
106
107
  }): void;
107
- resolveKey(value: any): any;
108
+ /**
109
+ * Returns all fields of the structured type.
110
+ * @param include_navigation Include navigation properties in the result.
111
+ * @param include_parents Include the parent types in the result.
112
+ * @returns All fields of the structured type.
113
+ */
114
+ fields({ include_navigation, include_parents, }: {
115
+ include_parents: boolean;
116
+ include_navigation: boolean;
117
+ }): ODataStructuredTypeFieldParser<any>[];
118
+ /**
119
+ * Returns the keys of the structured type.
120
+ * @param include_parents Include the parent fields
121
+ * @returns The keys of the structured type
122
+ */
123
+ keys({ include_parents, }: {
124
+ include_parents: boolean;
125
+ }): ODataEntityTypeKey[];
126
+ /**
127
+ * Find the field parser for the given field name.
128
+ * @param name Name of the field
129
+ * @returns The field parser
130
+ */
131
+ field<F>(name: keyof T): ODataStructuredTypeFieldParser<F>;
132
+ /**
133
+ * Picks the fields from attributes.
134
+ * @param attrs
135
+ * @param include_parents Include the parent fields
136
+ * @param include_navigation Include the navigation fields
137
+ * @param include_etag Include the etag field
138
+ * @returns The picked fields
139
+ */
140
+ pick(attrs: {
141
+ [name: string]: any;
142
+ }, { include_parents, include_navigation, include_etag, options, }?: {
143
+ include_parents?: boolean;
144
+ include_navigation?: boolean;
145
+ include_etag?: boolean;
146
+ options?: ParserOptions;
147
+ }): Partial<T>;
148
+ resolveKey(value: any, { resolve, single, }?: {
149
+ resolve?: boolean;
150
+ single?: boolean;
151
+ }): any;
108
152
  defaults(): {
109
153
  [name: string]: any;
110
154
  };
@@ -44,7 +44,7 @@ export declare class ODataStructuredType<T> extends ODataSchemaElement {
44
44
  * @param name Name of the field
45
45
  * @returns The field parser
46
46
  */
47
- findFieldByName<F>(name: keyof T): ODataStructuredTypeFieldParser<F> | undefined;
47
+ field<F>(name: keyof T): ODataStructuredTypeFieldParser<F>;
48
48
  /**
49
49
  * Find a parent schema of the structured type.
50
50
  * @param predicate Function for evaluate the schemas in the hierarchy.
@@ -57,24 +57,6 @@ export declare class ODataStructuredType<T> extends ODataSchemaElement {
57
57
  * @returns The schema of the field
58
58
  */
59
59
  findSchemaForField<E>(field: ODataStructuredTypeFieldParser<any>): ODataStructuredType<E>;
60
- /**
61
- * Returns all fields of the structured type.
62
- * @param include_navigation Include navigation properties in the result.
63
- * @param include_parents Include the parent types in the result.
64
- * @returns All fields of the structured type.
65
- */
66
- fields({ include_navigation, include_parents, }: {
67
- include_parents: boolean;
68
- include_navigation: boolean;
69
- }): ODataStructuredTypeFieldParser<any>[];
70
- /**
71
- * Returns the keys of the structured type.
72
- * @param include_parents Include the parent fields
73
- * @returns The keys of the structured type
74
- */
75
- keys({ include_parents, }?: {
76
- include_parents?: boolean;
77
- }): ODataEntityTypeKey[];
78
60
  /**
79
61
  * Picks the fields from attributes.
80
62
  * @param attrs
@@ -111,6 +93,24 @@ export declare class ODataStructuredType<T> extends ODataSchemaElement {
111
93
  * @returns Encoded value
112
94
  */
113
95
  encode(value: T, options?: ParserOptions): any;
96
+ /**
97
+ * Returns all fields of the structured type.
98
+ * @param include_navigation Include navigation properties in the result.
99
+ * @param include_parents Include the parent types in the result.
100
+ * @returns All fields of the structured type.
101
+ */
102
+ fields({ include_navigation, include_parents, }: {
103
+ include_parents: boolean;
104
+ include_navigation: boolean;
105
+ }): ODataStructuredTypeFieldParser<any>[];
106
+ /**
107
+ * Returns the keys of the structured type.
108
+ * @param include_parents Include the parent fields
109
+ * @returns The keys of the structured type
110
+ */
111
+ keys({ include_parents, }?: {
112
+ include_parents?: boolean;
113
+ }): ODataEntityTypeKey[];
114
114
  /**
115
115
  * Resolve the key of the structured type for the given value.
116
116
  * @param attrs Attributes of the value
@@ -1,20 +1,20 @@
1
1
  import { Observable } from 'rxjs';
2
2
  import { ODataClient } from '../client';
3
- import { ODataActionResource, ODataEntities, ODataEntity, ODataFunctionResource, ODataNavigationPropertyResource, ODataProperty, ODataQueryArgumentsOptions } from '../resources';
3
+ import { ODataActionOptions, ODataActionResource, ODataEntities, ODataEntity, ODataFunctionOptions, ODataFunctionResource, ODataNavigationPropertyResource, ODataProperty, ODataQueryArgumentsOptions } from '../resources';
4
4
  export declare abstract class ODataBaseService {
5
5
  protected client: ODataClient;
6
6
  protected name: string;
7
7
  protected apiNameOrEntityType?: string | undefined;
8
8
  constructor(client: ODataClient, name: string, apiNameOrEntityType?: string | undefined);
9
9
  get api(): import("angular-odata").ODataApi;
10
- protected callFunction<P, R>(params: P | null, resource: ODataFunctionResource<P, R>, responseType: 'entity', options?: ODataQueryArgumentsOptions<R>): Observable<ODataEntity<R>>;
11
- protected callFunction<P, R>(params: P | null, resource: ODataFunctionResource<P, R>, responseType: 'entities', options?: ODataQueryArgumentsOptions<R>): Observable<ODataEntities<R>>;
12
- protected callFunction<P, R>(params: P | null, resource: ODataFunctionResource<P, R>, responseType: 'property', options?: ODataQueryArgumentsOptions<R>): Observable<ODataProperty<R>>;
13
- protected callFunction<P, R>(params: P | null, resource: ODataFunctionResource<P, R>, responseType: 'none', options?: ODataQueryArgumentsOptions<R>): Observable<null>;
14
- protected callAction<P, R>(params: P | null, resource: ODataActionResource<P, R>, responseType: 'entity', options?: ODataQueryArgumentsOptions<R>): Observable<ODataEntity<R>>;
15
- protected callAction<P, R>(params: P | null, resource: ODataActionResource<P, R>, responseType: 'entities', options?: ODataQueryArgumentsOptions<R>): Observable<ODataEntities<R>>;
16
- protected callAction<P, R>(params: P | null, resource: ODataActionResource<P, R>, responseType: 'property', options?: ODataQueryArgumentsOptions<R>): Observable<ODataProperty<R>>;
17
- protected callAction<P, R>(params: P | null, resource: ODataActionResource<P, R>, responseType: 'none', options?: ODataQueryArgumentsOptions<R>): Observable<null>;
10
+ protected callFunction<P, R>(params: P | null, resource: ODataFunctionResource<P, R>, responseType: 'entity', options?: ODataFunctionOptions<R>): Observable<ODataEntity<R>>;
11
+ protected callFunction<P, R>(params: P | null, resource: ODataFunctionResource<P, R>, responseType: 'entities', options?: ODataFunctionOptions<R>): Observable<ODataEntities<R>>;
12
+ protected callFunction<P, R>(params: P | null, resource: ODataFunctionResource<P, R>, responseType: 'property', options?: ODataFunctionOptions<R>): Observable<ODataProperty<R>>;
13
+ protected callFunction<P, R>(params: P | null, resource: ODataFunctionResource<P, R>, responseType: 'none', options?: ODataFunctionOptions<R>): Observable<null>;
14
+ protected callAction<P, R>(params: P | null, resource: ODataActionResource<P, R>, responseType: 'entity', options?: ODataActionOptions<R>): Observable<ODataEntity<R>>;
15
+ protected callAction<P, R>(params: P | null, resource: ODataActionResource<P, R>, responseType: 'entities', options?: ODataActionOptions<R>): Observable<ODataEntities<R>>;
16
+ protected callAction<P, R>(params: P | null, resource: ODataActionResource<P, R>, responseType: 'property', options?: ODataActionOptions<R>): Observable<ODataProperty<R>>;
17
+ protected callAction<P, R>(params: P | null, resource: ODataActionResource<P, R>, responseType: 'none', options?: ODataActionOptions<R>): Observable<null>;
18
18
  protected fetchNavigationProperty<S>(resource: ODataNavigationPropertyResource<S>, responseType: 'entity', options?: ODataQueryArgumentsOptions<S>): Observable<ODataEntity<S>>;
19
19
  protected fetchNavigationProperty<S>(resource: ODataNavigationPropertyResource<S>, responseType: 'entities', options?: ODataQueryArgumentsOptions<S>): Observable<ODataEntities<S>>;
20
20
  }
package/lib/types.d.ts CHANGED
@@ -124,21 +124,21 @@ export declare type EntityContainerConfig = {
124
124
  annotations?: AnnotationConfig[];
125
125
  entitySets?: EntitySetConfig[];
126
126
  };
127
- export declare type EnumTypeFieldConfig = {
128
- value: number;
127
+ export declare type EnumTypeFieldConfig<E> = {
128
+ value: E;
129
129
  annotations?: AnnotationConfig[];
130
130
  };
131
- export declare type EnumTypeConfig<T> = {
131
+ export declare type EnumTypeConfig<E> = {
132
132
  name: string;
133
133
  flags?: boolean;
134
134
  annotations?: AnnotationConfig[];
135
135
  members: {
136
- [name: string]: number;
136
+ [name: string]: E;
137
137
  } | {
138
138
  [value: number]: string;
139
139
  };
140
140
  fields: {
141
- [member: string]: EnumTypeFieldConfig;
141
+ [member: string]: EnumTypeFieldConfig<E>;
142
142
  };
143
143
  };
144
144
  export declare type StructuredTypeFieldConfig = {
@@ -19,5 +19,5 @@ export declare const Objects: {
19
19
  resolveKey(key: any, { single }?: {
20
20
  single?: boolean | undefined;
21
21
  }): any;
22
- clone(target: any, map?: WeakMap<object, any> | undefined): any;
22
+ clone(target: any, map?: WeakMap<object, any>): any;
23
23
  };
@@ -1,4 +1,4 @@
1
1
  export declare const Strings: {
2
- uniqueId(prefix?: string | undefined, suffix?: string | undefined): string;
2
+ uniqueId(prefix?: string, suffix?: string): string;
3
3
  titleCase(text: string): string;
4
4
  };
@@ -1,6 +1,5 @@
1
1
  export declare const Types: {
2
2
  rawType(value: any): string;
3
- isObject(value: any): boolean;
4
3
  isPlainObject(value: any): boolean;
5
4
  isFunction(value: any): boolean;
6
5
  isArray(value: any): boolean;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "angular-odata",
3
- "version": "0.101.0",
3
+ "version": "0.102.6",
4
4
  "license": "MIT",
5
5
  "description": "Client side OData typescript library for Angular",
6
6
  "repository": {
@@ -25,8 +25,8 @@
25
25
  "homepage": "https://github.com/diegomvh/angular-odata",
26
26
  "private": false,
27
27
  "peerDependencies": {
28
- "@angular/common": "^13.3.0",
29
- "@angular/core": "^13.3.0"
28
+ "@angular/common": ">=13.0.0",
29
+ "@angular/core": ">=13.0.0"
30
30
  },
31
31
  "dependencies": {
32
32
  "tslib": "^2.3.0"
@@ -36,13 +36,13 @@
36
36
  "esm2020": "esm2020/angular-odata.mjs",
37
37
  "fesm2020": "fesm2020/angular-odata.mjs",
38
38
  "fesm2015": "fesm2015/angular-odata.mjs",
39
- "typings": "angular-odata.d.ts",
39
+ "typings": "index.d.ts",
40
40
  "exports": {
41
41
  "./package.json": {
42
42
  "default": "./package.json"
43
43
  },
44
44
  ".": {
45
- "types": "./angular-odata.d.ts",
45
+ "types": "./index.d.ts",
46
46
  "esm2020": "./esm2020/angular-odata.mjs",
47
47
  "es2020": "./fesm2020/angular-odata.mjs",
48
48
  "es2015": "./fesm2015/angular-odata.mjs",