angular-odata 0.120.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 (70) 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 +14 -15
  5. package/esm2020/lib/models/collection.mjs +76 -46
  6. package/esm2020/lib/models/model.mjs +26 -8
  7. package/esm2020/lib/models/options.mjs +97 -39
  8. package/esm2020/lib/module.mjs +4 -4
  9. package/esm2020/lib/options.mjs +1 -1
  10. package/esm2020/lib/resources/path/handlers.mjs +8 -8
  11. package/esm2020/lib/resources/path/segments.mjs +6 -6
  12. package/esm2020/lib/resources/query/builder.mjs +1 -1
  13. package/esm2020/lib/resources/query/expressions/count.mjs +5 -5
  14. package/esm2020/lib/resources/query/expressions/expand.mjs +18 -18
  15. package/esm2020/lib/resources/query/handlers.mjs +45 -45
  16. package/esm2020/lib/resources/query/options.mjs +27 -27
  17. package/esm2020/lib/resources/request.mjs +1 -1
  18. package/esm2020/lib/resources/resource.mjs +11 -9
  19. package/esm2020/lib/resources/types/action.mjs +5 -7
  20. package/esm2020/lib/resources/types/batch.mjs +3 -3
  21. package/esm2020/lib/resources/types/count.mjs +4 -4
  22. package/esm2020/lib/resources/types/entity-set.mjs +5 -7
  23. package/esm2020/lib/resources/types/entity.mjs +5 -5
  24. package/esm2020/lib/resources/types/function.mjs +5 -7
  25. package/esm2020/lib/resources/types/media.mjs +3 -3
  26. package/esm2020/lib/resources/types/metadata.mjs +3 -3
  27. package/esm2020/lib/resources/types/navigation-property.mjs +7 -9
  28. package/esm2020/lib/resources/types/property.mjs +5 -7
  29. package/esm2020/lib/resources/types/reference.mjs +3 -3
  30. package/esm2020/lib/resources/types/singleton.mjs +4 -4
  31. package/esm2020/lib/resources/types/value.mjs +3 -3
  32. package/esm2020/lib/schema/parsers/edm.mjs +18 -17
  33. package/esm2020/lib/schema/parsers/enum-type.mjs +1 -1
  34. package/esm2020/lib/schema/parsers/structured-type.mjs +31 -19
  35. package/esm2020/lib/schema/structured-type.mjs +7 -1
  36. package/esm2020/lib/services/factory.mjs +3 -3
  37. package/esm2020/lib/settings.mjs +1 -1
  38. package/esm2020/lib/types.mjs +101 -32
  39. package/esm2020/lib/utils/enums.mjs +2 -2
  40. package/fesm2015/angular-odata.mjs +510 -328
  41. package/fesm2015/angular-odata.mjs.map +1 -1
  42. package/fesm2020/angular-odata.mjs +510 -326
  43. package/fesm2020/angular-odata.mjs.map +1 -1
  44. package/lib/api.d.ts +3 -3
  45. package/lib/client.d.ts +4 -6
  46. package/lib/models/collection.d.ts +21 -13
  47. package/lib/models/model.d.ts +8 -3
  48. package/lib/models/options.d.ts +19 -6
  49. package/lib/options.d.ts +2 -2
  50. package/lib/resources/path/handlers.d.ts +2 -2
  51. package/lib/resources/path/segments.d.ts +2 -2
  52. package/lib/resources/query/builder.d.ts +4 -1
  53. package/lib/resources/query/handlers.d.ts +3 -3
  54. package/lib/resources/query/options.d.ts +21 -21
  55. package/lib/resources/request.d.ts +4 -4
  56. package/lib/resources/resource.d.ts +4 -6
  57. package/lib/resources/types/entity-set.d.ts +8 -8
  58. package/lib/resources/types/entity.d.ts +5 -5
  59. package/lib/resources/types/navigation-property.d.ts +11 -11
  60. package/lib/resources/types/property.d.ts +4 -4
  61. package/lib/resources/types/reference.d.ts +5 -5
  62. package/lib/resources/types/singleton.d.ts +5 -5
  63. package/lib/schema/parsers/edm.d.ts +2 -2
  64. package/lib/schema/parsers/enum-type.d.ts +2 -2
  65. package/lib/schema/parsers/structured-type.d.ts +7 -6
  66. package/lib/schema/structured-type.d.ts +3 -1
  67. package/lib/services/entity-set.d.ts +1 -6
  68. package/lib/settings.d.ts +2 -2
  69. package/lib/types.d.ts +45 -3
  70. package/package.json +1 -1
@@ -2,7 +2,7 @@ import { Observable } from 'rxjs';
2
2
  import { ODataApi } from '../../api';
3
3
  import { ODataCollection, ODataModel } from '../../models';
4
4
  import { ODataStructuredType } from '../../schema';
5
- import { QueryOptionNames } from '../../types';
5
+ import { QueryOption } from '../../types';
6
6
  import { ODataPathSegments } from '../path';
7
7
  import { ODataQueryOptions } from '../query';
8
8
  import { ODataResource } from '../resource';
@@ -68,14 +68,14 @@ export declare class ODataPropertyResource<T> extends ODataResource<T> {
68
68
  }): Observable<C | null>;
69
69
  fetchOne(options?: ODataOptions & {
70
70
  withCount?: boolean;
71
- bodyQueryOptions?: QueryOptionNames[];
71
+ bodyQueryOptions?: QueryOption[];
72
72
  }): Observable<{
73
73
  entity: T | null;
74
74
  annots: ODataEntitiesAnnotations<T>;
75
75
  }>;
76
76
  fetchMany(top: number, options?: ODataOptions & {
77
77
  withCount?: boolean;
78
- bodyQueryOptions?: QueryOptionNames[];
78
+ bodyQueryOptions?: QueryOption[];
79
79
  }): Observable<{
80
80
  entities: T[];
81
81
  annots: ODataEntitiesAnnotations<T>;
@@ -87,7 +87,7 @@ export declare class ODataPropertyResource<T> extends ODataResource<T> {
87
87
  */
88
88
  fetchAll(options?: ODataOptions & {
89
89
  withCount?: boolean;
90
- bodyQueryOptions?: QueryOptionNames[];
90
+ bodyQueryOptions?: QueryOption[];
91
91
  }): Observable<{
92
92
  entities: T[];
93
93
  annots: ODataEntitiesAnnotations<T>;
@@ -1,6 +1,6 @@
1
1
  import { Observable } from 'rxjs';
2
2
  import { ODataApi } from '../../api';
3
- import { QueryOptionNames } from '../../types';
3
+ import { QueryOption } from '../../types';
4
4
  import { ODataPathSegments } from '../path';
5
5
  import { ODataQueryOptions } from '../query';
6
6
  import { ODataResource } from '../resource';
@@ -52,10 +52,10 @@ export declare class ODataReferenceResource<T> extends ODataResource<T> {
52
52
  * @return An observable of the entity or entities with annotations
53
53
  */
54
54
  fetch(options?: ODataEntityOptions & {
55
- bodyQueryOptions?: QueryOptionNames[];
55
+ bodyQueryOptions?: QueryOption[];
56
56
  }): Observable<ODataEntity<T>>;
57
57
  fetch(options?: ODataEntitiesOptions & {
58
- bodyQueryOptions?: QueryOptionNames[];
58
+ bodyQueryOptions?: QueryOption[];
59
59
  }): Observable<ODataEntities<T>>;
60
60
  /**
61
61
  * Fetch the entity
@@ -63,7 +63,7 @@ export declare class ODataReferenceResource<T> extends ODataResource<T> {
63
63
  * @returns The entity
64
64
  */
65
65
  fetchEntity(options?: ODataOptions & {
66
- bodyQueryOptions?: QueryOptionNames[];
66
+ bodyQueryOptions?: QueryOption[];
67
67
  }): Observable<T | null>;
68
68
  /**
69
69
  * Fetch entities
@@ -71,6 +71,6 @@ export declare class ODataReferenceResource<T> extends ODataResource<T> {
71
71
  * @returns The entities
72
72
  */
73
73
  fetchEntities(options?: ODataOptions & {
74
- bodyQueryOptions?: QueryOptionNames[];
74
+ bodyQueryOptions?: QueryOption[];
75
75
  }): Observable<T[] | null>;
76
76
  }
@@ -2,7 +2,7 @@ import { Observable } from 'rxjs';
2
2
  import { ODataApi } from '../../api';
3
3
  import { ODataModel } from '../../models';
4
4
  import { ODataStructuredType } from '../../schema';
5
- import { QueryOptionNames } from '../../types';
5
+ import { QueryOption } from '../../types';
6
6
  import { ODataQueryOptions } from '../query';
7
7
  import { ODataResource } from '../resource';
8
8
  import { ODataEntity } from '../responses';
@@ -29,7 +29,7 @@ export declare class ODataSingletonResource<T> extends ODataResource<T> {
29
29
  protected patch(attrs: Partial<T>, options?: ODataOptions): Observable<any>;
30
30
  protected delete(options?: ODataOptions): Observable<any>;
31
31
  protected get(options?: ODataOptions & {
32
- bodyQueryOptions?: QueryOptionNames[];
32
+ bodyQueryOptions?: QueryOption[];
33
33
  }): Observable<any>;
34
34
  /**
35
35
  * Creates a new entity.
@@ -64,7 +64,7 @@ export declare class ODataSingletonResource<T> extends ODataResource<T> {
64
64
  * @returns Observable of the entity with the annotations.
65
65
  */
66
66
  fetch(options?: ODataOptions & {
67
- bodyQueryOptions?: QueryOptionNames[];
67
+ bodyQueryOptions?: QueryOption[];
68
68
  }): Observable<ODataEntity<T>>;
69
69
  /**
70
70
  * Fetch an existing entity.
@@ -72,7 +72,7 @@ export declare class ODataSingletonResource<T> extends ODataResource<T> {
72
72
  * @returns Observable of the entity.
73
73
  */
74
74
  fetchEntity(options?: ODataOptions & {
75
- bodyQueryOptions?: QueryOptionNames[];
75
+ bodyQueryOptions?: QueryOption[];
76
76
  }): Observable<T | null>;
77
77
  /**
78
78
  * Fetch an existing entity and return a model.
@@ -80,6 +80,6 @@ export declare class ODataSingletonResource<T> extends ODataResource<T> {
80
80
  * @returns Observable of the entity.
81
81
  */
82
82
  fetchModel<M extends ODataModel<T>>(options?: ODataOptions & {
83
- bodyQueryOptions?: QueryOptionNames[];
83
+ bodyQueryOptions?: QueryOption[];
84
84
  }): Observable<M | null>;
85
85
  }
@@ -1,4 +1,4 @@
1
- import { Parser } from '../../types';
1
+ import { FieldParser } from '../../types';
2
2
  export declare const EDM_PARSERS: {
3
- [type: string]: Parser<any>;
3
+ [type: string]: FieldParser<any>;
4
4
  };
@@ -1,4 +1,4 @@
1
- import { EnumTypeConfig, EnumTypeFieldConfig, ParserOptions, Parser } from '../../types';
1
+ import { EnumTypeConfig, EnumTypeFieldConfig, ParserOptions, Parser, FieldParser } from '../../types';
2
2
  import { ODataAnnotatable } from '../annotation';
3
3
  export declare class ODataEnumTypeFieldParser<E> extends ODataAnnotatable {
4
4
  name: string;
@@ -6,7 +6,7 @@ export declare class ODataEnumTypeFieldParser<E> extends ODataAnnotatable {
6
6
  constructor(name: string, field: EnumTypeFieldConfig<E>);
7
7
  titleize(term?: string | RegExp): string;
8
8
  }
9
- export declare class ODataEnumTypeParser<E> extends ODataAnnotatable implements Parser<E> {
9
+ export declare class ODataEnumTypeParser<E> extends ODataAnnotatable implements FieldParser<E> {
10
10
  name: string;
11
11
  namespace: string;
12
12
  alias?: string;
@@ -1,4 +1,4 @@
1
- import { ParserOptions, Parser, StructuredTypeConfig, StructuredTypeFieldConfig } from '../../types';
1
+ import { ParserOptions, Parser, StructuredTypeConfig, StructuredTypeFieldConfig, FieldParser, EdmType } from '../../types';
2
2
  import { ODataAnnotatable } from '../annotation';
3
3
  import { ODataEnumTypeParser } from './enum-type';
4
4
  declare type JsonSchemaSelect<T> = Array<keyof T>;
@@ -33,16 +33,16 @@ export declare class ODataReferential {
33
33
  referencedProperty: string;
34
34
  });
35
35
  }
36
- export declare class ODataStructuredTypeFieldParser<T> extends ODataAnnotatable implements Parser<T> {
36
+ export declare class ODataStructuredTypeFieldParser<T> extends ODataAnnotatable implements FieldParser<T> {
37
37
  name: string;
38
38
  private structuredType;
39
- type: string;
39
+ type: string | EdmType;
40
40
  private parser;
41
- default?: any;
42
- maxLength?: number;
43
41
  collection: boolean;
44
- nullable: boolean;
45
42
  navigation: boolean;
43
+ nullable?: boolean;
44
+ default?: any;
45
+ maxLength?: number;
46
46
  precision?: number;
47
47
  scale?: number | 'variable';
48
48
  referentials: ODataReferential[];
@@ -88,6 +88,7 @@ export declare class ODataStructuredTypeParser<T> extends ODataAnnotatable imple
88
88
  private _fields;
89
89
  parserOptions?: ParserOptions;
90
90
  constructor(config: StructuredTypeConfig<T>, namespace: string, alias?: string);
91
+ addField<F>(name: string, config: StructuredTypeFieldConfig): ODataStructuredTypeFieldParser<F>;
91
92
  /**
92
93
  * Create a nicer looking title.
93
94
  * Titleize is meant for creating pretty output.
@@ -1,6 +1,6 @@
1
1
  import { ODataCollection } from '../models';
2
2
  import { ODataModel } from '../models/model';
3
- import { Parser, ParserOptions, StructuredTypeConfig } from '../types';
3
+ import { Parser, ParserOptions, StructuredTypeConfig, StructuredTypeFieldConfig } from '../types';
4
4
  import { ODataSchemaElement } from './element';
5
5
  import { JsonSchemaOptions, ODataEntityTypeKey, ODataStructuredTypeFieldParser, ODataStructuredTypeParser } from './parsers';
6
6
  import { ODataSchema } from './schema';
@@ -40,12 +40,14 @@ export declare class ODataStructuredType<T> extends ODataSchemaElement {
40
40
  * @returns True if the structured type has a compound key.
41
41
  */
42
42
  isCompoundKey(): boolean;
43
+ isOpenType(): boolean;
43
44
  /**
44
45
  * Find the field parser for the given field name.
45
46
  * @param name Name of the field
46
47
  * @returns The field parser
47
48
  */
48
49
  field<F>(name: keyof T): ODataStructuredTypeFieldParser<F>;
50
+ addField<F>(name: string, config: StructuredTypeFieldConfig): ODataStructuredTypeFieldParser<F>;
49
51
  /**
50
52
  * Find a parent schema of the structured type.
51
53
  * @param predicate Function for evaluate the schemas in the hierarchy.
@@ -28,12 +28,7 @@ export declare class ODataEntitySetService<T> extends ODataEntityService<T> {
28
28
  * @param options The options for the request.
29
29
  */
30
30
  fetchAll(options?: ODataOptions): Observable<{
31
- entities: T[]; /**
32
- * Delete an entity in the entity set.
33
- * @param key The entity key.
34
- * @param etag The etag for the entity.
35
- * @param options The options for the request.
36
- */
31
+ entities: T[];
37
32
  annots: import("../resources").ODataEntitiesAnnotations<T>;
38
33
  }>;
39
34
  /**
package/lib/settings.d.ts CHANGED
@@ -4,7 +4,7 @@ import { ODataCollection, ODataModel } from './models';
4
4
  import { ODataRequest } from './resources';
5
5
  import { ODataCallable, ODataEntitySet, ODataEnumType, ODataStructuredType } from './schema';
6
6
  import { ODataEntityService } from './services/entity';
7
- import { ApiConfig, Parser } from './types';
7
+ import { ApiConfig, EdmType, Parser } from './types';
8
8
  export declare class ODataSettings {
9
9
  apis: ODataApi[];
10
10
  constructor(configs: ApiConfig[]);
@@ -21,7 +21,7 @@ export declare class ODataSettings {
21
21
  structuredTypeForType<T>(type: string): ODataStructuredType<T>;
22
22
  callableForType<T>(type: string, bindingType?: string): ODataCallable<T>;
23
23
  entitySetForType(type: string): ODataEntitySet;
24
- parserForType<T>(type: string): Parser<T>;
24
+ parserForType<T>(type: string | EdmType): Parser<T>;
25
25
  modelForType(type: string): typeof ODataModel;
26
26
  collectionForType(type: string): typeof ODataCollection;
27
27
  serviceForType(type: string): typeof ODataEntityService;
package/lib/types.d.ts CHANGED
@@ -3,7 +3,7 @@ export declare type ODataVersion = '2.0' | '3.0' | '4.0';
3
3
  export declare type FetchPolicy = 'cache-first' | 'cache-and-network' | 'network-only' | 'no-cache' | 'cache-only';
4
4
  export declare type ODataMetadataType = 'minimal' | 'full' | 'none';
5
5
  export declare type CacheCacheability = 'public' | 'private' | 'no-cache' | 'no-store';
6
- export declare enum PathSegmentNames {
6
+ export declare enum PathSegment {
7
7
  batch = "batch",
8
8
  metadata = "metadata",
9
9
  entitySet = "entitySet",
@@ -17,7 +17,7 @@ export declare enum PathSegmentNames {
17
17
  function = "function",
18
18
  action = "action"
19
19
  }
20
- export declare enum QueryOptionNames {
20
+ export declare enum QueryOption {
21
21
  select = "select",
22
22
  expand = "expand",
23
23
  compute = "compute",
@@ -32,6 +32,41 @@ export declare enum QueryOptionNames {
32
32
  levels = "levels",
33
33
  count = "count"
34
34
  }
35
+ export declare enum EdmType {
36
+ Guid = "Edm.Guid",
37
+ Int16 = "Edm.Int16",
38
+ String = "Edm.String",
39
+ Boolean = "Edm.Boolean",
40
+ Byte = "Edm.Byte",
41
+ SByte = "Edm.SByte",
42
+ Int32 = "Edm.Int32",
43
+ Int64 = "Edm.Int64",
44
+ Date = "Edm.Date",
45
+ TimeOfDay = "Edm.TimeOfDay",
46
+ DateTimeOffset = "Edm.DateTimeOffset",
47
+ Duration = "Edm.Duration",
48
+ Decimal = "Edm.Decimal",
49
+ Double = "Edm.Double",
50
+ Single = "Edm.Single",
51
+ Binary = "Edm.Binary",
52
+ Stream = "Edm.Stream",
53
+ Geography = "Edm.Geography",
54
+ GeographyPoint = "Edm.GeographyPoint",
55
+ GeographyLineString = "Edm.GeographyLineString",
56
+ GeographyPolygon = "Edm.GeographyPolygon",
57
+ GeographyMultiPoint = "Edm.GeographyMultiPoint",
58
+ GeographyMultiLineString = "Edm.GeographyMultiLineString",
59
+ GeographyMultiPolygon = "Edm.GeographyMultiPolygon",
60
+ GeographyCollection = "Edm.GeographyCollection",
61
+ Geometry = "Edm.Geometry",
62
+ GeometryPoint = "Edm.GeometryPoint",
63
+ GeometryLineString = "Edm.GeometryLineString",
64
+ GeometryPolygon = "Edm.GeometryPolygon",
65
+ GeometryMultiPoint = "Edm.GeometryMultiPoint",
66
+ GeometryMultiLineString = "Edm.GeometryMultiLineString",
67
+ GeometryMultiPolygon = "Edm.GeometryMultiPolygon",
68
+ GeometryCollection = "Edm.GeometryCollection"
69
+ }
35
70
  export interface ApiOptions {
36
71
  version?: ODataVersion;
37
72
  params?: {
@@ -59,7 +94,7 @@ export interface ApiOptions {
59
94
  };
60
95
  stripMetadata?: ODataMetadataType;
61
96
  fetchPolicy?: FetchPolicy;
62
- bodyQueryOptions?: QueryOptionNames[];
97
+ bodyQueryOptions?: QueryOption[];
63
98
  stringAsEnum?: boolean;
64
99
  deleteRefBy?: 'path' | 'id';
65
100
  nonParenthesisForEmptyParameterFunction?: boolean;
@@ -87,6 +122,13 @@ export interface Parser<T> {
87
122
  serialize(value: any, options?: ParserOptions | StructuredTypeFieldOptions): any;
88
123
  encode(value: any, options?: ParserOptions | StructuredTypeFieldOptions): any;
89
124
  }
125
+ export interface FieldParser<T> extends Parser<T> {
126
+ nullable?: boolean;
127
+ default?: any;
128
+ maxLength?: number;
129
+ precision?: number;
130
+ scale?: number | 'variable';
131
+ }
90
132
  export declare const NONE_PARSER: Parser<any>;
91
133
  export interface Cache {
92
134
  put<T>(key: string, payload: T, ...opts: any[]): void;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "angular-odata",
3
- "version": "0.120.0",
3
+ "version": "0.121.0",
4
4
  "license": "MIT",
5
5
  "description": "Client side OData typescript library for Angular",
6
6
  "repository": {