angular-odata 0.101.0 → 0.102.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 (34) hide show
  1. package/esm2020/lib/cache/memory.mjs +3 -3
  2. package/esm2020/lib/cache/storage.mjs +3 -3
  3. package/esm2020/lib/client.mjs +3 -3
  4. package/esm2020/lib/models/collection.mjs +2 -3
  5. package/esm2020/lib/models/model.mjs +1 -3
  6. package/esm2020/lib/models/options.mjs +47 -25
  7. package/esm2020/lib/module.mjs +5 -5
  8. package/esm2020/lib/resources/query/builder.mjs +1 -1
  9. package/esm2020/lib/resources/query/handlers.mjs +139 -19
  10. package/esm2020/lib/resources/query/options.mjs +15 -11
  11. package/esm2020/lib/resources/request.mjs +24 -35
  12. package/esm2020/lib/resources/resource.mjs +15 -3
  13. package/esm2020/lib/resources/types/navigation-property.mjs +4 -2
  14. package/esm2020/lib/resources/types/options.mjs +1 -1
  15. package/esm2020/lib/services/base.mjs +1 -1
  16. package/esm2020/lib/services/factory.mjs +3 -3
  17. package/fesm2015/angular-odata.mjs +251 -105
  18. package/fesm2015/angular-odata.mjs.map +1 -1
  19. package/fesm2020/angular-odata.mjs +250 -105
  20. package/fesm2020/angular-odata.mjs.map +1 -1
  21. package/{angular-odata.d.ts → index.d.ts} +0 -0
  22. package/lib/models/collection.d.ts +3 -3
  23. package/lib/models/model.d.ts +4 -4
  24. package/lib/models/options.d.ts +11 -6
  25. package/lib/resources/query/builder.d.ts +1 -1
  26. package/lib/resources/query/handlers.d.ts +32 -3
  27. package/lib/resources/query/options.d.ts +14 -12
  28. package/lib/resources/request.d.ts +2 -1
  29. package/lib/resources/resource.d.ts +3 -2
  30. package/lib/resources/types/options.d.ts +4 -2
  31. package/lib/services/base.d.ts +9 -9
  32. package/lib/utils/objects.d.ts +1 -1
  33. package/lib/utils/strings.d.ts +1 -1
  34. package/package.json +5 -5
@@ -311,7 +311,7 @@ class ODataInMemoryCache extends ODataCache {
311
311
  putResponse(req, res) {
312
312
  let scope = this.scope(req);
313
313
  let tags = this.tags(res);
314
- this.put(req.pathWithParams, res, {
314
+ this.put(req.cacheKey, res, {
315
315
  timeout: res.options.maxAge,
316
316
  scope,
317
317
  tags,
@@ -324,7 +324,7 @@ class ODataInMemoryCache extends ODataCache {
324
324
  */
325
325
  getResponse(req) {
326
326
  let scope = this.scope(req);
327
- return this.get(req.pathWithParams, { scope });
327
+ return this.get(req.cacheKey, { scope });
328
328
  }
329
329
  }
330
330
 
@@ -2522,8 +2522,9 @@ class ODataQueryOptionHandler {
2522
2522
  */
2523
2523
  remove(value) {
2524
2524
  this.o.set(this.n, this.assertArray().filter((v) => v !== value));
2525
- // If only one... down to value
2526
- if (this.o.get(this.n).length === 1)
2525
+ // If only one and not is array... down to value
2526
+ if (this.o.get(this.n).length === 1 &&
2527
+ !Types.isArray(this.o.get(this.n)[0]))
2527
2528
  this.o.set(this.n, this.o.get(this.n)[0]);
2528
2529
  }
2529
2530
  /**
@@ -2534,6 +2535,15 @@ class ODataQueryOptionHandler {
2534
2535
  at(index) {
2535
2536
  return this.assertArray()[index];
2536
2537
  }
2538
+ some(predicate) {
2539
+ return this.assertArray().some(predicate);
2540
+ }
2541
+ every(predicate) {
2542
+ return this.assertArray().every(predicate);
2543
+ }
2544
+ find(predicate) {
2545
+ return this.assertArray().find(predicate);
2546
+ }
2537
2547
  //#endregion
2538
2548
  //#region HashMap Value
2539
2549
  assertObject(create) {
@@ -2611,6 +2621,14 @@ class ODataQueryOptionsHandler {
2611
2621
  constructor(options) {
2612
2622
  this.options = options;
2613
2623
  }
2624
+ /**
2625
+ * Create a raw odata value
2626
+ * @param value The value to raw
2627
+ * @returns The raw value
2628
+ */
2629
+ raw(value) {
2630
+ return raw(value);
2631
+ }
2614
2632
  /**
2615
2633
  * Create a new odata alias parameter
2616
2634
  * @link https://docs.oasis-open.org/odata/odata/v4.01/odata-v4.01-part2-url-conventions.html#sec_ParameterAliases
@@ -2621,6 +2639,22 @@ class ODataQueryOptionsHandler {
2621
2639
  alias(value, name) {
2622
2640
  return alias(value, name);
2623
2641
  }
2642
+ /**
2643
+ * Create a duration odata value
2644
+ * @param value The value to duration
2645
+ * @returns The duration value
2646
+ */
2647
+ duration(value) {
2648
+ return duration(value);
2649
+ }
2650
+ /**
2651
+ * Create a binary odata value
2652
+ * @param value The value to binary
2653
+ * @returns The binary value
2654
+ */
2655
+ binary(value) {
2656
+ return binary(value);
2657
+ }
2624
2658
  /**
2625
2659
  * Normalize the given value to a valid odata value
2626
2660
  * @param value The value to normalize
@@ -2685,20 +2719,50 @@ class ODataQueryOptionsHandler {
2685
2719
  * @param param0 skip or top or skiptoken
2686
2720
  */
2687
2721
  paging({ skip, skiptoken, top, } = {}) {
2688
- if (skiptoken !== undefined)
2689
- this.skiptoken(skiptoken);
2690
- else if (skip !== undefined)
2691
- this.skip(skip);
2692
- if (top !== undefined)
2693
- this.top(top);
2722
+ if (skiptoken !== undefined) {
2723
+ if (skiptoken !== null) {
2724
+ this.skiptoken(skiptoken);
2725
+ }
2726
+ else {
2727
+ this.options.remove(QueryOptionNames.skiptoken);
2728
+ }
2729
+ }
2730
+ if (skip !== undefined) {
2731
+ if (skip !== null) {
2732
+ this.skip(skip);
2733
+ }
2734
+ else {
2735
+ this.options.remove(QueryOptionNames.skip);
2736
+ }
2737
+ }
2738
+ if (top !== undefined) {
2739
+ if (top !== null) {
2740
+ this.top(top);
2741
+ }
2742
+ else {
2743
+ this.options.remove(QueryOptionNames.top);
2744
+ }
2745
+ }
2694
2746
  }
2695
2747
  /**
2696
2748
  * Shortcut for clear pagination by unset $top, $skip, $skiptoken.
2697
2749
  */
2698
2750
  clearPaging() {
2699
- this.skip().clear();
2700
- this.top().clear();
2701
- this.skiptoken().clear();
2751
+ this.options.remove(QueryOptionNames.skip);
2752
+ this.options.remove(QueryOptionNames.top);
2753
+ this.options.remove(QueryOptionNames.skiptoken);
2754
+ }
2755
+ /**
2756
+ * Shortcut for clear query.
2757
+ */
2758
+ clear() {
2759
+ this.options.clear();
2760
+ }
2761
+ /**
2762
+ * Retrun the query.
2763
+ */
2764
+ query() {
2765
+ return this.options.toQueryArguments();
2702
2766
  }
2703
2767
  /**
2704
2768
  * Apply the given query options to the current query.
@@ -2706,22 +2770,78 @@ class ODataQueryOptionsHandler {
2706
2770
  */
2707
2771
  apply(query) {
2708
2772
  if (query.select !== undefined) {
2709
- this.options.option(QueryOptionNames.select, query.select);
2773
+ if (query.select instanceof SelectExpression) {
2774
+ this.options.expression(QueryOptionNames.select, query.select);
2775
+ }
2776
+ else if (query.select !== null) {
2777
+ this.options.option(QueryOptionNames.select, query.select);
2778
+ }
2779
+ else {
2780
+ this.options.remove(QueryOptionNames.select);
2781
+ }
2710
2782
  }
2711
2783
  if (query.expand !== undefined) {
2712
- this.options.option(QueryOptionNames.expand, query.expand);
2784
+ if (query.expand instanceof ExpandExpression) {
2785
+ this.options.expression(QueryOptionNames.expand, query.expand);
2786
+ }
2787
+ else if (query.expand !== null) {
2788
+ this.options.option(QueryOptionNames.expand, query.expand);
2789
+ }
2790
+ else {
2791
+ this.options.remove(QueryOptionNames.expand);
2792
+ }
2793
+ }
2794
+ if (query.compute !== undefined) {
2795
+ if (query.compute instanceof ComputeExpression) {
2796
+ this.options.expression(QueryOptionNames.compute, query.compute);
2797
+ }
2798
+ else if (query.compute !== null) {
2799
+ this.options.option(QueryOptionNames.compute, query.compute);
2800
+ }
2801
+ else {
2802
+ this.options.remove(QueryOptionNames.compute);
2803
+ }
2713
2804
  }
2714
2805
  if (query.transform !== undefined) {
2715
- this.options.option(QueryOptionNames.transform, query.transform);
2806
+ if (query.transform !== null) {
2807
+ this.options.option(QueryOptionNames.transform, query.transform);
2808
+ }
2809
+ else {
2810
+ this.options.remove(QueryOptionNames.transform);
2811
+ }
2716
2812
  }
2717
2813
  if (query.search !== undefined) {
2718
- this.options.option(QueryOptionNames.search, query.search);
2814
+ if (query.search instanceof SearchExpression) {
2815
+ this.options.expression(QueryOptionNames.search, query.search);
2816
+ }
2817
+ else if (query.search !== null) {
2818
+ this.options.option(QueryOptionNames.search, query.search);
2819
+ }
2820
+ else {
2821
+ this.options.remove(QueryOptionNames.search);
2822
+ }
2719
2823
  }
2720
2824
  if (query.filter !== undefined) {
2721
- this.options.option(QueryOptionNames.filter, query.filter);
2825
+ if (query.filter instanceof FilterExpression) {
2826
+ this.options.expression(QueryOptionNames.filter, query.filter);
2827
+ }
2828
+ else if (query.filter !== null) {
2829
+ this.options.option(QueryOptionNames.filter, query.filter);
2830
+ }
2831
+ else {
2832
+ this.options.remove(QueryOptionNames.filter);
2833
+ }
2722
2834
  }
2723
2835
  if (query.orderBy !== undefined) {
2724
- this.options.option(QueryOptionNames.orderBy, query.orderBy);
2836
+ if (query.orderBy instanceof OrderByExpression) {
2837
+ this.options.expression(QueryOptionNames.orderBy, query.orderBy);
2838
+ }
2839
+ else if (query.orderBy !== null) {
2840
+ this.options.option(QueryOptionNames.orderBy, query.orderBy);
2841
+ }
2842
+ else {
2843
+ this.options.remove(QueryOptionNames.orderBy);
2844
+ }
2725
2845
  }
2726
2846
  this.paging(query);
2727
2847
  }
@@ -2749,6 +2869,8 @@ class ODataQueryOptions {
2749
2869
  QueryOptionNames.skiptoken,
2750
2870
  QueryOptionNames.expand,
2751
2871
  QueryOptionNames.format,
2872
+ QueryOptionNames.levels,
2873
+ QueryOptionNames.count,
2752
2874
  ]
2753
2875
  .filter((key) => !Types.isEmpty(this.values.get(key)))
2754
2876
  .reduce((acc, key) => {
@@ -2778,16 +2900,18 @@ class ODataQueryOptions {
2778
2900
  }
2779
2901
  toQueryArguments() {
2780
2902
  return {
2781
- select: this.values.get(QueryOptionNames.select),
2782
- expand: this.values.get(QueryOptionNames.expand),
2783
- transform: this.values.get(QueryOptionNames.transform),
2784
- compute: this.values.get(QueryOptionNames.compute),
2785
- search: this.values.get(QueryOptionNames.search),
2786
- filter: this.values.get(QueryOptionNames.filter),
2787
- orderBy: this.values.get(QueryOptionNames.orderBy),
2788
- top: this.values.get(QueryOptionNames.top),
2789
- skip: this.values.get(QueryOptionNames.skip),
2790
- skiptoken: this.values.get(QueryOptionNames.skiptoken),
2903
+ select: this.values.get(QueryOptionNames.select) || null,
2904
+ expand: this.values.get(QueryOptionNames.expand) || null,
2905
+ transform: this.values.get(QueryOptionNames.transform) || null,
2906
+ compute: this.values.get(QueryOptionNames.compute) || null,
2907
+ search: this.values.get(QueryOptionNames.search) || null,
2908
+ filter: this.values.get(QueryOptionNames.filter) || null,
2909
+ orderBy: this.values.get(QueryOptionNames.orderBy) || null,
2910
+ top: this.values.get(QueryOptionNames.top) || null,
2911
+ skip: this.values.get(QueryOptionNames.skip) || null,
2912
+ skiptoken: this.values.get(QueryOptionNames.skiptoken) || null,
2913
+ levels: this.values.get(QueryOptionNames.levels) || null,
2914
+ count: this.values.get(QueryOptionNames.count) || null,
2791
2915
  };
2792
2916
  }
2793
2917
  clone() {
@@ -3035,7 +3159,7 @@ class ODataRequest {
3035
3159
  : init.withCredentials;
3036
3160
  this.fetchPolicy = init.fetchPolicy || this.api.options.fetchPolicy;
3037
3161
  this.bodyQueryOptions =
3038
- init.bodyQueryOptions || this.api.options.bodyQueryOptions;
3162
+ [...(this.api.options.bodyQueryOptions || []), ...(init.bodyQueryOptions || [])];
3039
3163
  // The Path and Params from resource
3040
3164
  const [resourcePath, resourceParams] = this.resource.pathAndParams();
3041
3165
  this._path = resourcePath;
@@ -3112,10 +3236,6 @@ class ODataRequest {
3112
3236
  ])
3113
3237
  : params;
3114
3238
  //#endregion
3115
- this._queryBody =
3116
- this._method === 'GET' &&
3117
- this.bodyQueryOptions.length > 0 &&
3118
- this.bodyQueryOptions.some((name) => this._params.has(`$${name}`));
3119
3239
  }
3120
3240
  get responseType() {
3121
3241
  return this._responseType &&
@@ -3126,52 +3246,45 @@ class ODataRequest {
3126
3246
  : this._responseType;
3127
3247
  }
3128
3248
  get path() {
3129
- return this._queryBody ? `${this._path}/${$QUERY}` : this._path;
3249
+ return this.isQueryBody() ? `${this._path}/${$QUERY}` : this._path;
3130
3250
  }
3131
3251
  get method() {
3132
- return this._queryBody ? 'POST' : this._method;
3252
+ return this.isQueryBody() ? 'POST' : this._method;
3133
3253
  }
3134
3254
  get body() {
3135
- if (this._queryBody) {
3136
- let [, bodyParams] = Http.splitHttpParams(this._params, this.bodyQueryOptions.map((name) => `$${name}`));
3137
- return bodyParams.toString();
3138
- }
3139
- else {
3140
- return this._body;
3141
- }
3255
+ return (this.isQueryBody()) ?
3256
+ Http.splitHttpParams(this._params, this.bodyQueryOptions.map((name) => `$${name}`))[1].toString() :
3257
+ this._body;
3142
3258
  }
3143
3259
  get params() {
3144
- if (this._queryBody) {
3145
- let [queryParams] = Http.splitHttpParams(this._params, this.bodyQueryOptions.map((name) => `$${name}`));
3146
- return queryParams;
3147
- }
3148
- else {
3149
- return this._params;
3150
- }
3260
+ return (this.isQueryBody()) ?
3261
+ Http.splitHttpParams(this._params, this.bodyQueryOptions.map((name) => `$${name}`))[0] :
3262
+ this._params;
3151
3263
  }
3152
3264
  get headers() {
3153
- if (this._queryBody) {
3154
- return Http.mergeHttpHeaders(this._headers, { CONTENT_TYPE: TEXT_PLAIN });
3155
- }
3156
- else {
3157
- return this._headers;
3158
- }
3265
+ return (this.isQueryBody()) ?
3266
+ Http.mergeHttpHeaders(this._headers, { CONTENT_TYPE: TEXT_PLAIN }) :
3267
+ this._headers;
3159
3268
  }
3160
3269
  get pathWithParams() {
3161
- let path = this._path;
3162
- if (this._params.keys().length > 0) {
3163
- path = `${path}?${this._params}`;
3164
- }
3165
- return path;
3270
+ return (this.params.keys().length > 0) ? `${this.path}?${this.params}` : this.path;
3166
3271
  }
3167
3272
  get url() {
3168
- return `${this.api.serviceRootUrl}${this._path}`;
3273
+ return `${this.api.serviceRootUrl}${this.path}`;
3169
3274
  }
3170
3275
  get urlWithParams() {
3171
3276
  return `${this.api.serviceRootUrl}${this.pathWithParams}`;
3172
3277
  }
3278
+ get cacheKey() {
3279
+ return (this._params.keys().length > 0) ? `${this._path}?${this._params}` : this._path;
3280
+ }
3281
+ isQueryBody() {
3282
+ return this._method === 'GET' &&
3283
+ this.bodyQueryOptions.length > 0 &&
3284
+ this.bodyQueryOptions.some((name) => this._params.has(`$${name}`));
3285
+ }
3173
3286
  isBatch() {
3174
- return this._path.endsWith($BATCH);
3287
+ return this.path.endsWith($BATCH);
3175
3288
  }
3176
3289
  isFetch() {
3177
3290
  return ['GET'].indexOf(this._method) !== -1;
@@ -4711,6 +4824,10 @@ class ODataResource {
4711
4824
  var _a;
4712
4825
  return Boolean((_a = this.pathSegments.last({ key: true })) === null || _a === void 0 ? void 0 : _a.hasKey());
4713
4826
  }
4827
+ hasEntityKey() {
4828
+ var _a;
4829
+ return Boolean((_a = this.pathSegments.get(PathSegmentNames.entitySet)) === null || _a === void 0 ? void 0 : _a.hasKey());
4830
+ }
4714
4831
  clearKey() {
4715
4832
  var _a;
4716
4833
  return (_a = this.pathSegments.last({ key: true })) === null || _a === void 0 ? void 0 : _a.clearKey();
@@ -4873,7 +4990,11 @@ class ODataResource {
4873
4990
  * @returns ODataActionResource
4874
4991
  */
4875
4992
  segment(f) {
4876
- f(new ODataPathSegmentsHandler(this.pathSegments));
4993
+ /*
4994
+ const type = this.type();
4995
+ const schema = type ? this.api.findStructuredTypeForType<T>(type) : undefined;
4996
+ */
4997
+ f(new ODataPathSegmentsHandler(this.pathSegments), this.schema instanceof ODataStructuredType ? this.schema : undefined);
4877
4998
  return this;
4878
4999
  }
4879
5000
  /**
@@ -4882,7 +5003,11 @@ class ODataResource {
4882
5003
  * @param f Function context for handle the query options
4883
5004
  */
4884
5005
  query(f) {
4885
- f(new ODataQueryOptionsHandler(this.queryOptions));
5006
+ /*
5007
+ const type = this.returnType();
5008
+ const schema = type ? this.api.findStructuredTypeForType<T>(type) : undefined;
5009
+ */
5010
+ f(new ODataQueryOptionsHandler(this.queryOptions), this.schema instanceof ODataStructuredType ? this.schema : undefined);
4886
5011
  return this;
4887
5012
  }
4888
5013
  static resolveKey(value, schema) {
@@ -6053,6 +6178,8 @@ class ODataNavigationPropertyResource extends ODataResource {
6053
6178
  return this.delete(options);
6054
6179
  }
6055
6180
  fetch(options = {}) {
6181
+ if (!this.hasEntityKey())
6182
+ return throwError(() => new Error('fetch: Navigation resource without entity key'));
6056
6183
  return this.get(options);
6057
6184
  }
6058
6185
  /**
@@ -7612,7 +7739,7 @@ class ODataInStorageCache extends ODataCache {
7612
7739
  putResponse(req, res) {
7613
7740
  const scope = this.scope(req);
7614
7741
  const tags = this.tags(res);
7615
- this.put(req.pathWithParams, res.toJSON(), {
7742
+ this.put(req.cacheKey, res.toJSON(), {
7616
7743
  timeout: res.options.maxAge,
7617
7744
  scope,
7618
7745
  tags,
@@ -7625,13 +7752,13 @@ class ODataInStorageCache extends ODataCache {
7625
7752
  */
7626
7753
  getResponse(req) {
7627
7754
  const scope = this.scope(req);
7628
- const data = this.get(req.pathWithParams, { scope });
7755
+ const data = this.get(req.cacheKey, { scope });
7629
7756
  return data !== undefined ? ODataResponse.fromJSON(req, data) : undefined;
7630
7757
  }
7631
7758
  }
7632
7759
 
7633
7760
  class ODataModelEvent {
7634
- constructor(name, { model, collection, previous, value, track, options, } = {}) {
7761
+ constructor(name, { model, collection, previous, value, field, options, } = {}) {
7635
7762
  this.bubbling = true;
7636
7763
  this.name = name;
7637
7764
  this.model = model;
@@ -7642,15 +7769,24 @@ class ODataModelEvent {
7642
7769
  this.chain = [
7643
7770
  [
7644
7771
  (this.collection || this.model),
7645
- track || null,
7772
+ field || null,
7646
7773
  ],
7647
7774
  ];
7648
7775
  }
7649
7776
  stopPropagation() {
7650
7777
  this.bubbling = false;
7651
7778
  }
7652
- push(model, track) {
7653
- this.chain.splice(0, 0, [model, track]);
7779
+ push(model, field) {
7780
+ let event = new ODataModelEvent(this.name, {
7781
+ model: this.model,
7782
+ collection: this.collection,
7783
+ previous: this.previous,
7784
+ value: this.value,
7785
+ options: this.options,
7786
+ });
7787
+ event.chain = [...this.chain];
7788
+ event.chain.splice(0, 0, [model, field]);
7789
+ return event;
7654
7790
  }
7655
7791
  visited(model) {
7656
7792
  return (this.chain.some((c) => c[0] === model) &&
@@ -7658,12 +7794,12 @@ class ODataModelEvent {
7658
7794
  }
7659
7795
  get path() {
7660
7796
  return this.chain
7661
- .map(([, track], index) => typeof track === 'number'
7662
- ? `[${track}]`
7663
- : typeof track === 'string'
7797
+ .map(([, field], index) => typeof field === 'number'
7798
+ ? `[${field}]`
7799
+ : field instanceof ODataModelField
7664
7800
  ? index === 0
7665
- ? track
7666
- : `.${track}`
7801
+ ? field.name
7802
+ : `.${field.name}`
7667
7803
  : '')
7668
7804
  .join('');
7669
7805
  }
@@ -7916,12 +8052,25 @@ class ODataModelOptions {
7916
8052
  get api() {
7917
8053
  return this.schema.api;
7918
8054
  }
7919
- type() {
7920
- return this.schema.type();
8055
+ type({ alias = false } = {}) {
8056
+ return this.schema.type({ alias });
7921
8057
  }
7922
8058
  isTypeOf(type) {
7923
8059
  return this.schema.isTypeOf(type);
7924
8060
  }
8061
+ isModelFor(entity) {
8062
+ // Resolve By Type
8063
+ let type = this.api.options.helper.type(entity);
8064
+ if (type && this.isTypeOf(type))
8065
+ return true;
8066
+ // Resolve By fields
8067
+ let keys = Object.keys(entity);
8068
+ let names = this.fields({
8069
+ include_navigation: true,
8070
+ include_parents: true,
8071
+ }).map((f) => f.name);
8072
+ return keys.every((key) => names.includes(key));
8073
+ }
7925
8074
  findChildOptions(predicate) {
7926
8075
  if (predicate(this))
7927
8076
  return this;
@@ -8543,7 +8692,7 @@ class ODataModelOptions {
8543
8692
  if (!ODataModelOptions.isCollection(relation.model)) {
8544
8693
  let ref = (_a = field.meta) === null || _a === void 0 ? void 0 : _a.resolveReferential(relation.model, field);
8545
8694
  if (ref !== null && ref !== undefined) {
8546
- Object.entries(ref).forEach(([k, v]) => this._setValue(self, k, v, false));
8695
+ Object.assign(self, ref);
8547
8696
  }
8548
8697
  }
8549
8698
  // Update state and emit event
@@ -8553,7 +8702,7 @@ class ODataModelOptions {
8553
8702
  : ODataModelState.Changed;
8554
8703
  if (!self._silent && changed) {
8555
8704
  self.events$.emit(new ODataModelEvent('change', {
8556
- track: field.name,
8705
+ field: field,
8557
8706
  model: self,
8558
8707
  value: relation.model,
8559
8708
  previous: current,
@@ -8567,21 +8716,22 @@ class ODataModelOptions {
8567
8716
  include_concurrency: true,
8568
8717
  include_computed: true,
8569
8718
  });
8570
- const currentValue = attrs[field];
8719
+ const name = field.name;
8720
+ const currentValue = attrs[name];
8571
8721
  changed = !Types.isEqual(currentValue, value);
8572
8722
  if (self._reset) {
8573
- self._changes.delete(field);
8574
- self._attributes.set(field, value);
8723
+ self._changes.delete(name);
8724
+ self._attributes.set(name, value);
8575
8725
  }
8576
- else if (Types.isEqual(value, self._attributes.get(field))) {
8577
- self._changes.delete(field);
8726
+ else if (Types.isEqual(value, self._attributes.get(name))) {
8727
+ self._changes.delete(name);
8578
8728
  }
8579
8729
  else if (changed) {
8580
- self._changes.set(field, value);
8730
+ self._changes.set(name, value);
8581
8731
  }
8582
8732
  if (!self._silent && changed) {
8583
8733
  self.events$.emit(new ODataModelEvent('change', {
8584
- track: field,
8734
+ field: field,
8585
8735
  model: self,
8586
8736
  value,
8587
8737
  previous: currentValue,
@@ -8593,7 +8743,7 @@ class ODataModelOptions {
8593
8743
  _set(self, field, value) {
8594
8744
  return field.isStructuredType()
8595
8745
  ? this._setStructured(self, field, value)
8596
- : this._setValue(self, field.name, value, field.isKey());
8746
+ : this._setValue(self, field, value, field.isKey());
8597
8747
  }
8598
8748
  _unlink(self, relation) {
8599
8749
  if (relation.subscription !== undefined) {
@@ -8624,12 +8774,11 @@ class ODataModelOptions {
8624
8774
  ((_a = event.options) === null || _a === void 0 ? void 0 : _a.key)) {
8625
8775
  let ref = relation.model.referential(relation.field);
8626
8776
  if (ref !== null && ref !== undefined) {
8627
- Object.entries(ref).forEach(([k, v]) => this._setValue(self, k, v, false));
8777
+ Object.assign(self, ref);
8628
8778
  }
8629
8779
  }
8630
8780
  }
8631
- event.push(self, relation.field.name);
8632
- self.events$.emit(event);
8781
+ self.events$.emit(event.push(self, relation.field));
8633
8782
  }
8634
8783
  });
8635
8784
  }
@@ -9296,8 +9445,7 @@ class ODataCollection {
9296
9445
  }
9297
9446
  }
9298
9447
  const index = this.models().indexOf(entry.model);
9299
- event.push(this, index);
9300
- this.events$.emit(event);
9448
+ this.events$.emit(event.push(this, index));
9301
9449
  }
9302
9450
  });
9303
9451
  }
@@ -9660,8 +9808,6 @@ class ODataModel {
9660
9808
  return throwError(() => new Error('fetch: Resource is undefined'));
9661
9809
  let obs$;
9662
9810
  if (resource instanceof ODataEntityResource) {
9663
- if (!resource.hasKey())
9664
- return throwError(() => new Error("fetch: Can't fetch model without key"));
9665
9811
  obs$ = resource.fetch(options);
9666
9812
  }
9667
9813
  else if (resource instanceof ODataNavigationPropertyResource) {
@@ -10698,9 +10844,9 @@ class ODataClient {
10698
10844
  return this.request('PUT', resource, addBody(options, body));
10699
10845
  }
10700
10846
  }
10701
- ODataClient.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.6", ngImport: i0, type: ODataClient, deps: [{ token: i1.HttpClient }, { token: ODataSettings }, { token: i0.Injector }], target: i0.ɵɵFactoryTarget.Injectable });
10702
- ODataClient.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.3.6", ngImport: i0, type: ODataClient, providedIn: 'root' });
10703
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.6", ngImport: i0, type: ODataClient, decorators: [{
10847
+ ODataClient.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.0.1", ngImport: i0, type: ODataClient, deps: [{ token: i1.HttpClient }, { token: ODataSettings }, { token: i0.Injector }], target: i0.ɵɵFactoryTarget.Injectable });
10848
+ ODataClient.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "14.0.1", ngImport: i0, type: ODataClient, providedIn: 'root' });
10849
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.0.1", ngImport: i0, type: ODataClient, decorators: [{
10704
10850
  type: Injectable,
10705
10851
  args: [{
10706
10852
  providedIn: 'root',
@@ -10952,9 +11098,9 @@ class ODataServiceFactory {
10952
11098
  })(this.client, singletonName, apiNameOrEntityType);
10953
11099
  }
10954
11100
  }
10955
- ODataServiceFactory.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.6", ngImport: i0, type: ODataServiceFactory, deps: [{ token: ODataClient }], target: i0.ɵɵFactoryTarget.Injectable });
10956
- ODataServiceFactory.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.3.6", ngImport: i0, type: ODataServiceFactory });
10957
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.6", ngImport: i0, type: ODataServiceFactory, decorators: [{
11101
+ ODataServiceFactory.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.0.1", ngImport: i0, type: ODataServiceFactory, deps: [{ token: ODataClient }], target: i0.ɵɵFactoryTarget.Injectable });
11102
+ ODataServiceFactory.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "14.0.1", ngImport: i0, type: ODataServiceFactory });
11103
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.0.1", ngImport: i0, type: ODataServiceFactory, decorators: [{
10958
11104
  type: Injectable
10959
11105
  }], ctorParameters: function () { return [{ type: ODataClient }]; } });
10960
11106
 
@@ -10978,10 +11124,10 @@ class ODataModule {
10978
11124
  };
10979
11125
  }
10980
11126
  }
10981
- ODataModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.6", ngImport: i0, type: ODataModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
10982
- ODataModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "13.3.6", ngImport: i0, type: ODataModule, imports: [HttpClientModule] });
10983
- ODataModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "13.3.6", ngImport: i0, type: ODataModule, providers: [ODataClient, ODataServiceFactory], imports: [[HttpClientModule]] });
10984
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.6", ngImport: i0, type: ODataModule, decorators: [{
11127
+ ODataModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.0.1", ngImport: i0, type: ODataModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
11128
+ ODataModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "14.0.1", ngImport: i0, type: ODataModule, imports: [HttpClientModule] });
11129
+ ODataModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "14.0.1", ngImport: i0, type: ODataModule, providers: [ODataClient, ODataServiceFactory], imports: [HttpClientModule] });
11130
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.0.1", ngImport: i0, type: ODataModule, decorators: [{
10985
11131
  type: NgModule,
10986
11132
  args: [{
10987
11133
  imports: [HttpClientModule],