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
@@ -310,7 +310,7 @@ class ODataInMemoryCache extends ODataCache {
310
310
  putResponse(req, res) {
311
311
  let scope = this.scope(req);
312
312
  let tags = this.tags(res);
313
- this.put(req.pathWithParams, res, {
313
+ this.put(req.cacheKey, res, {
314
314
  timeout: res.options.maxAge,
315
315
  scope,
316
316
  tags,
@@ -323,7 +323,7 @@ class ODataInMemoryCache extends ODataCache {
323
323
  */
324
324
  getResponse(req) {
325
325
  let scope = this.scope(req);
326
- return this.get(req.pathWithParams, { scope });
326
+ return this.get(req.cacheKey, { scope });
327
327
  }
328
328
  }
329
329
 
@@ -2521,8 +2521,9 @@ class ODataQueryOptionHandler {
2521
2521
  */
2522
2522
  remove(value) {
2523
2523
  this.o.set(this.n, this.assertArray().filter((v) => v !== value));
2524
- // If only one... down to value
2525
- if (this.o.get(this.n).length === 1)
2524
+ // If only one and not is array... down to value
2525
+ if (this.o.get(this.n).length === 1 &&
2526
+ !Types.isArray(this.o.get(this.n)[0]))
2526
2527
  this.o.set(this.n, this.o.get(this.n)[0]);
2527
2528
  }
2528
2529
  /**
@@ -2533,6 +2534,15 @@ class ODataQueryOptionHandler {
2533
2534
  at(index) {
2534
2535
  return this.assertArray()[index];
2535
2536
  }
2537
+ some(predicate) {
2538
+ return this.assertArray().some(predicate);
2539
+ }
2540
+ every(predicate) {
2541
+ return this.assertArray().every(predicate);
2542
+ }
2543
+ find(predicate) {
2544
+ return this.assertArray().find(predicate);
2545
+ }
2536
2546
  //#endregion
2537
2547
  //#region HashMap Value
2538
2548
  assertObject(create) {
@@ -2610,6 +2620,14 @@ class ODataQueryOptionsHandler {
2610
2620
  constructor(options) {
2611
2621
  this.options = options;
2612
2622
  }
2623
+ /**
2624
+ * Create a raw odata value
2625
+ * @param value The value to raw
2626
+ * @returns The raw value
2627
+ */
2628
+ raw(value) {
2629
+ return raw(value);
2630
+ }
2613
2631
  /**
2614
2632
  * Create a new odata alias parameter
2615
2633
  * @link https://docs.oasis-open.org/odata/odata/v4.01/odata-v4.01-part2-url-conventions.html#sec_ParameterAliases
@@ -2620,6 +2638,22 @@ class ODataQueryOptionsHandler {
2620
2638
  alias(value, name) {
2621
2639
  return alias(value, name);
2622
2640
  }
2641
+ /**
2642
+ * Create a duration odata value
2643
+ * @param value The value to duration
2644
+ * @returns The duration value
2645
+ */
2646
+ duration(value) {
2647
+ return duration(value);
2648
+ }
2649
+ /**
2650
+ * Create a binary odata value
2651
+ * @param value The value to binary
2652
+ * @returns The binary value
2653
+ */
2654
+ binary(value) {
2655
+ return binary(value);
2656
+ }
2623
2657
  /**
2624
2658
  * Normalize the given value to a valid odata value
2625
2659
  * @param value The value to normalize
@@ -2684,20 +2718,50 @@ class ODataQueryOptionsHandler {
2684
2718
  * @param param0 skip or top or skiptoken
2685
2719
  */
2686
2720
  paging({ skip, skiptoken, top, } = {}) {
2687
- if (skiptoken !== undefined)
2688
- this.skiptoken(skiptoken);
2689
- else if (skip !== undefined)
2690
- this.skip(skip);
2691
- if (top !== undefined)
2692
- this.top(top);
2721
+ if (skiptoken !== undefined) {
2722
+ if (skiptoken !== null) {
2723
+ this.skiptoken(skiptoken);
2724
+ }
2725
+ else {
2726
+ this.options.remove(QueryOptionNames.skiptoken);
2727
+ }
2728
+ }
2729
+ if (skip !== undefined) {
2730
+ if (skip !== null) {
2731
+ this.skip(skip);
2732
+ }
2733
+ else {
2734
+ this.options.remove(QueryOptionNames.skip);
2735
+ }
2736
+ }
2737
+ if (top !== undefined) {
2738
+ if (top !== null) {
2739
+ this.top(top);
2740
+ }
2741
+ else {
2742
+ this.options.remove(QueryOptionNames.top);
2743
+ }
2744
+ }
2693
2745
  }
2694
2746
  /**
2695
2747
  * Shortcut for clear pagination by unset $top, $skip, $skiptoken.
2696
2748
  */
2697
2749
  clearPaging() {
2698
- this.skip().clear();
2699
- this.top().clear();
2700
- this.skiptoken().clear();
2750
+ this.options.remove(QueryOptionNames.skip);
2751
+ this.options.remove(QueryOptionNames.top);
2752
+ this.options.remove(QueryOptionNames.skiptoken);
2753
+ }
2754
+ /**
2755
+ * Shortcut for clear query.
2756
+ */
2757
+ clear() {
2758
+ this.options.clear();
2759
+ }
2760
+ /**
2761
+ * Retrun the query.
2762
+ */
2763
+ query() {
2764
+ return this.options.toQueryArguments();
2701
2765
  }
2702
2766
  /**
2703
2767
  * Apply the given query options to the current query.
@@ -2705,22 +2769,78 @@ class ODataQueryOptionsHandler {
2705
2769
  */
2706
2770
  apply(query) {
2707
2771
  if (query.select !== undefined) {
2708
- this.options.option(QueryOptionNames.select, query.select);
2772
+ if (query.select instanceof SelectExpression) {
2773
+ this.options.expression(QueryOptionNames.select, query.select);
2774
+ }
2775
+ else if (query.select !== null) {
2776
+ this.options.option(QueryOptionNames.select, query.select);
2777
+ }
2778
+ else {
2779
+ this.options.remove(QueryOptionNames.select);
2780
+ }
2709
2781
  }
2710
2782
  if (query.expand !== undefined) {
2711
- this.options.option(QueryOptionNames.expand, query.expand);
2783
+ if (query.expand instanceof ExpandExpression) {
2784
+ this.options.expression(QueryOptionNames.expand, query.expand);
2785
+ }
2786
+ else if (query.expand !== null) {
2787
+ this.options.option(QueryOptionNames.expand, query.expand);
2788
+ }
2789
+ else {
2790
+ this.options.remove(QueryOptionNames.expand);
2791
+ }
2792
+ }
2793
+ if (query.compute !== undefined) {
2794
+ if (query.compute instanceof ComputeExpression) {
2795
+ this.options.expression(QueryOptionNames.compute, query.compute);
2796
+ }
2797
+ else if (query.compute !== null) {
2798
+ this.options.option(QueryOptionNames.compute, query.compute);
2799
+ }
2800
+ else {
2801
+ this.options.remove(QueryOptionNames.compute);
2802
+ }
2712
2803
  }
2713
2804
  if (query.transform !== undefined) {
2714
- this.options.option(QueryOptionNames.transform, query.transform);
2805
+ if (query.transform !== null) {
2806
+ this.options.option(QueryOptionNames.transform, query.transform);
2807
+ }
2808
+ else {
2809
+ this.options.remove(QueryOptionNames.transform);
2810
+ }
2715
2811
  }
2716
2812
  if (query.search !== undefined) {
2717
- this.options.option(QueryOptionNames.search, query.search);
2813
+ if (query.search instanceof SearchExpression) {
2814
+ this.options.expression(QueryOptionNames.search, query.search);
2815
+ }
2816
+ else if (query.search !== null) {
2817
+ this.options.option(QueryOptionNames.search, query.search);
2818
+ }
2819
+ else {
2820
+ this.options.remove(QueryOptionNames.search);
2821
+ }
2718
2822
  }
2719
2823
  if (query.filter !== undefined) {
2720
- this.options.option(QueryOptionNames.filter, query.filter);
2824
+ if (query.filter instanceof FilterExpression) {
2825
+ this.options.expression(QueryOptionNames.filter, query.filter);
2826
+ }
2827
+ else if (query.filter !== null) {
2828
+ this.options.option(QueryOptionNames.filter, query.filter);
2829
+ }
2830
+ else {
2831
+ this.options.remove(QueryOptionNames.filter);
2832
+ }
2721
2833
  }
2722
2834
  if (query.orderBy !== undefined) {
2723
- this.options.option(QueryOptionNames.orderBy, query.orderBy);
2835
+ if (query.orderBy instanceof OrderByExpression) {
2836
+ this.options.expression(QueryOptionNames.orderBy, query.orderBy);
2837
+ }
2838
+ else if (query.orderBy !== null) {
2839
+ this.options.option(QueryOptionNames.orderBy, query.orderBy);
2840
+ }
2841
+ else {
2842
+ this.options.remove(QueryOptionNames.orderBy);
2843
+ }
2724
2844
  }
2725
2845
  this.paging(query);
2726
2846
  }
@@ -2748,6 +2868,8 @@ class ODataQueryOptions {
2748
2868
  QueryOptionNames.skiptoken,
2749
2869
  QueryOptionNames.expand,
2750
2870
  QueryOptionNames.format,
2871
+ QueryOptionNames.levels,
2872
+ QueryOptionNames.count,
2751
2873
  ]
2752
2874
  .filter((key) => !Types.isEmpty(this.values.get(key)))
2753
2875
  .reduce((acc, key) => {
@@ -2777,16 +2899,18 @@ class ODataQueryOptions {
2777
2899
  }
2778
2900
  toQueryArguments() {
2779
2901
  return {
2780
- select: this.values.get(QueryOptionNames.select),
2781
- expand: this.values.get(QueryOptionNames.expand),
2782
- transform: this.values.get(QueryOptionNames.transform),
2783
- compute: this.values.get(QueryOptionNames.compute),
2784
- search: this.values.get(QueryOptionNames.search),
2785
- filter: this.values.get(QueryOptionNames.filter),
2786
- orderBy: this.values.get(QueryOptionNames.orderBy),
2787
- top: this.values.get(QueryOptionNames.top),
2788
- skip: this.values.get(QueryOptionNames.skip),
2789
- skiptoken: this.values.get(QueryOptionNames.skiptoken),
2902
+ select: this.values.get(QueryOptionNames.select) || null,
2903
+ expand: this.values.get(QueryOptionNames.expand) || null,
2904
+ transform: this.values.get(QueryOptionNames.transform) || null,
2905
+ compute: this.values.get(QueryOptionNames.compute) || null,
2906
+ search: this.values.get(QueryOptionNames.search) || null,
2907
+ filter: this.values.get(QueryOptionNames.filter) || null,
2908
+ orderBy: this.values.get(QueryOptionNames.orderBy) || null,
2909
+ top: this.values.get(QueryOptionNames.top) || null,
2910
+ skip: this.values.get(QueryOptionNames.skip) || null,
2911
+ skiptoken: this.values.get(QueryOptionNames.skiptoken) || null,
2912
+ levels: this.values.get(QueryOptionNames.levels) || null,
2913
+ count: this.values.get(QueryOptionNames.count) || null,
2790
2914
  };
2791
2915
  }
2792
2916
  clone() {
@@ -3033,7 +3157,7 @@ class ODataRequest {
3033
3157
  : init.withCredentials;
3034
3158
  this.fetchPolicy = init.fetchPolicy || this.api.options.fetchPolicy;
3035
3159
  this.bodyQueryOptions =
3036
- init.bodyQueryOptions || this.api.options.bodyQueryOptions;
3160
+ [...(this.api.options.bodyQueryOptions || []), ...(init.bodyQueryOptions || [])];
3037
3161
  // The Path and Params from resource
3038
3162
  const [resourcePath, resourceParams] = this.resource.pathAndParams();
3039
3163
  this._path = resourcePath;
@@ -3110,10 +3234,6 @@ class ODataRequest {
3110
3234
  ])
3111
3235
  : params;
3112
3236
  //#endregion
3113
- this._queryBody =
3114
- this._method === 'GET' &&
3115
- this.bodyQueryOptions.length > 0 &&
3116
- this.bodyQueryOptions.some((name) => this._params.has(`$${name}`));
3117
3237
  }
3118
3238
  get responseType() {
3119
3239
  return this._responseType &&
@@ -3124,52 +3244,45 @@ class ODataRequest {
3124
3244
  : this._responseType;
3125
3245
  }
3126
3246
  get path() {
3127
- return this._queryBody ? `${this._path}/${$QUERY}` : this._path;
3247
+ return this.isQueryBody() ? `${this._path}/${$QUERY}` : this._path;
3128
3248
  }
3129
3249
  get method() {
3130
- return this._queryBody ? 'POST' : this._method;
3250
+ return this.isQueryBody() ? 'POST' : this._method;
3131
3251
  }
3132
3252
  get body() {
3133
- if (this._queryBody) {
3134
- let [, bodyParams] = Http.splitHttpParams(this._params, this.bodyQueryOptions.map((name) => `$${name}`));
3135
- return bodyParams.toString();
3136
- }
3137
- else {
3138
- return this._body;
3139
- }
3253
+ return (this.isQueryBody()) ?
3254
+ Http.splitHttpParams(this._params, this.bodyQueryOptions.map((name) => `$${name}`))[1].toString() :
3255
+ this._body;
3140
3256
  }
3141
3257
  get params() {
3142
- if (this._queryBody) {
3143
- let [queryParams] = Http.splitHttpParams(this._params, this.bodyQueryOptions.map((name) => `$${name}`));
3144
- return queryParams;
3145
- }
3146
- else {
3147
- return this._params;
3148
- }
3258
+ return (this.isQueryBody()) ?
3259
+ Http.splitHttpParams(this._params, this.bodyQueryOptions.map((name) => `$${name}`))[0] :
3260
+ this._params;
3149
3261
  }
3150
3262
  get headers() {
3151
- if (this._queryBody) {
3152
- return Http.mergeHttpHeaders(this._headers, { CONTENT_TYPE: TEXT_PLAIN });
3153
- }
3154
- else {
3155
- return this._headers;
3156
- }
3263
+ return (this.isQueryBody()) ?
3264
+ Http.mergeHttpHeaders(this._headers, { CONTENT_TYPE: TEXT_PLAIN }) :
3265
+ this._headers;
3157
3266
  }
3158
3267
  get pathWithParams() {
3159
- let path = this._path;
3160
- if (this._params.keys().length > 0) {
3161
- path = `${path}?${this._params}`;
3162
- }
3163
- return path;
3268
+ return (this.params.keys().length > 0) ? `${this.path}?${this.params}` : this.path;
3164
3269
  }
3165
3270
  get url() {
3166
- return `${this.api.serviceRootUrl}${this._path}`;
3271
+ return `${this.api.serviceRootUrl}${this.path}`;
3167
3272
  }
3168
3273
  get urlWithParams() {
3169
3274
  return `${this.api.serviceRootUrl}${this.pathWithParams}`;
3170
3275
  }
3276
+ get cacheKey() {
3277
+ return (this._params.keys().length > 0) ? `${this._path}?${this._params}` : this._path;
3278
+ }
3279
+ isQueryBody() {
3280
+ return this._method === 'GET' &&
3281
+ this.bodyQueryOptions.length > 0 &&
3282
+ this.bodyQueryOptions.some((name) => this._params.has(`$${name}`));
3283
+ }
3171
3284
  isBatch() {
3172
- return this._path.endsWith($BATCH);
3285
+ return this.path.endsWith($BATCH);
3173
3286
  }
3174
3287
  isFetch() {
3175
3288
  return ['GET'].indexOf(this._method) !== -1;
@@ -4729,6 +4842,9 @@ class ODataResource {
4729
4842
  hasKey() {
4730
4843
  return Boolean(this.pathSegments.last({ key: true })?.hasKey());
4731
4844
  }
4845
+ hasEntityKey() {
4846
+ return Boolean(this.pathSegments.get(PathSegmentNames.entitySet)?.hasKey());
4847
+ }
4732
4848
  clearKey() {
4733
4849
  return this.pathSegments.last({ key: true })?.clearKey();
4734
4850
  }
@@ -4888,7 +5004,11 @@ class ODataResource {
4888
5004
  * @returns ODataActionResource
4889
5005
  */
4890
5006
  segment(f) {
4891
- f(new ODataPathSegmentsHandler(this.pathSegments));
5007
+ /*
5008
+ const type = this.type();
5009
+ const schema = type ? this.api.findStructuredTypeForType<T>(type) : undefined;
5010
+ */
5011
+ f(new ODataPathSegmentsHandler(this.pathSegments), this.schema instanceof ODataStructuredType ? this.schema : undefined);
4892
5012
  return this;
4893
5013
  }
4894
5014
  /**
@@ -4897,7 +5017,11 @@ class ODataResource {
4897
5017
  * @param f Function context for handle the query options
4898
5018
  */
4899
5019
  query(f) {
4900
- f(new ODataQueryOptionsHandler(this.queryOptions));
5020
+ /*
5021
+ const type = this.returnType();
5022
+ const schema = type ? this.api.findStructuredTypeForType<T>(type) : undefined;
5023
+ */
5024
+ f(new ODataQueryOptionsHandler(this.queryOptions), this.schema instanceof ODataStructuredType ? this.schema : undefined);
4901
5025
  return this;
4902
5026
  }
4903
5027
  static resolveKey(value, schema) {
@@ -6077,6 +6201,8 @@ class ODataNavigationPropertyResource extends ODataResource {
6077
6201
  return this.delete(options);
6078
6202
  }
6079
6203
  fetch(options = {}) {
6204
+ if (!this.hasEntityKey())
6205
+ return throwError(() => new Error('fetch: Navigation resource without entity key'));
6080
6206
  return this.get(options);
6081
6207
  }
6082
6208
  /**
@@ -7633,7 +7759,7 @@ class ODataInStorageCache extends ODataCache {
7633
7759
  putResponse(req, res) {
7634
7760
  const scope = this.scope(req);
7635
7761
  const tags = this.tags(res);
7636
- this.put(req.pathWithParams, res.toJSON(), {
7762
+ this.put(req.cacheKey, res.toJSON(), {
7637
7763
  timeout: res.options.maxAge,
7638
7764
  scope,
7639
7765
  tags,
@@ -7646,13 +7772,13 @@ class ODataInStorageCache extends ODataCache {
7646
7772
  */
7647
7773
  getResponse(req) {
7648
7774
  const scope = this.scope(req);
7649
- const data = this.get(req.pathWithParams, { scope });
7775
+ const data = this.get(req.cacheKey, { scope });
7650
7776
  return data !== undefined ? ODataResponse.fromJSON(req, data) : undefined;
7651
7777
  }
7652
7778
  }
7653
7779
 
7654
7780
  class ODataModelEvent {
7655
- constructor(name, { model, collection, previous, value, track, options, } = {}) {
7781
+ constructor(name, { model, collection, previous, value, field, options, } = {}) {
7656
7782
  this.bubbling = true;
7657
7783
  this.name = name;
7658
7784
  this.model = model;
@@ -7663,15 +7789,24 @@ class ODataModelEvent {
7663
7789
  this.chain = [
7664
7790
  [
7665
7791
  (this.collection || this.model),
7666
- track || null,
7792
+ field || null,
7667
7793
  ],
7668
7794
  ];
7669
7795
  }
7670
7796
  stopPropagation() {
7671
7797
  this.bubbling = false;
7672
7798
  }
7673
- push(model, track) {
7674
- this.chain.splice(0, 0, [model, track]);
7799
+ push(model, field) {
7800
+ let event = new ODataModelEvent(this.name, {
7801
+ model: this.model,
7802
+ collection: this.collection,
7803
+ previous: this.previous,
7804
+ value: this.value,
7805
+ options: this.options,
7806
+ });
7807
+ event.chain = [...this.chain];
7808
+ event.chain.splice(0, 0, [model, field]);
7809
+ return event;
7675
7810
  }
7676
7811
  visited(model) {
7677
7812
  return (this.chain.some((c) => c[0] === model) &&
@@ -7679,12 +7814,12 @@ class ODataModelEvent {
7679
7814
  }
7680
7815
  get path() {
7681
7816
  return this.chain
7682
- .map(([, track], index) => typeof track === 'number'
7683
- ? `[${track}]`
7684
- : typeof track === 'string'
7817
+ .map(([, field], index) => typeof field === 'number'
7818
+ ? `[${field}]`
7819
+ : field instanceof ODataModelField
7685
7820
  ? index === 0
7686
- ? track
7687
- : `.${track}`
7821
+ ? field.name
7822
+ : `.${field.name}`
7688
7823
  : '')
7689
7824
  .join('');
7690
7825
  }
@@ -7938,12 +8073,25 @@ class ODataModelOptions {
7938
8073
  get api() {
7939
8074
  return this.schema.api;
7940
8075
  }
7941
- type() {
7942
- return this.schema.type();
8076
+ type({ alias = false } = {}) {
8077
+ return this.schema.type({ alias });
7943
8078
  }
7944
8079
  isTypeOf(type) {
7945
8080
  return this.schema.isTypeOf(type);
7946
8081
  }
8082
+ isModelFor(entity) {
8083
+ // Resolve By Type
8084
+ let type = this.api.options.helper.type(entity);
8085
+ if (type && this.isTypeOf(type))
8086
+ return true;
8087
+ // Resolve By fields
8088
+ let keys = Object.keys(entity);
8089
+ let names = this.fields({
8090
+ include_navigation: true,
8091
+ include_parents: true,
8092
+ }).map((f) => f.name);
8093
+ return keys.every((key) => names.includes(key));
8094
+ }
7947
8095
  findChildOptions(predicate) {
7948
8096
  if (predicate(this))
7949
8097
  return this;
@@ -8565,7 +8713,7 @@ class ODataModelOptions {
8565
8713
  if (!ODataModelOptions.isCollection(relation.model)) {
8566
8714
  let ref = field.meta?.resolveReferential(relation.model, field);
8567
8715
  if (ref !== null && ref !== undefined) {
8568
- Object.entries(ref).forEach(([k, v]) => this._setValue(self, k, v, false));
8716
+ Object.assign(self, ref);
8569
8717
  }
8570
8718
  }
8571
8719
  // Update state and emit event
@@ -8575,7 +8723,7 @@ class ODataModelOptions {
8575
8723
  : ODataModelState.Changed;
8576
8724
  if (!self._silent && changed) {
8577
8725
  self.events$.emit(new ODataModelEvent('change', {
8578
- track: field.name,
8726
+ field: field,
8579
8727
  model: self,
8580
8728
  value: relation.model,
8581
8729
  previous: current,
@@ -8589,21 +8737,22 @@ class ODataModelOptions {
8589
8737
  include_concurrency: true,
8590
8738
  include_computed: true,
8591
8739
  });
8592
- const currentValue = attrs[field];
8740
+ const name = field.name;
8741
+ const currentValue = attrs[name];
8593
8742
  changed = !Types.isEqual(currentValue, value);
8594
8743
  if (self._reset) {
8595
- self._changes.delete(field);
8596
- self._attributes.set(field, value);
8744
+ self._changes.delete(name);
8745
+ self._attributes.set(name, value);
8597
8746
  }
8598
- else if (Types.isEqual(value, self._attributes.get(field))) {
8599
- self._changes.delete(field);
8747
+ else if (Types.isEqual(value, self._attributes.get(name))) {
8748
+ self._changes.delete(name);
8600
8749
  }
8601
8750
  else if (changed) {
8602
- self._changes.set(field, value);
8751
+ self._changes.set(name, value);
8603
8752
  }
8604
8753
  if (!self._silent && changed) {
8605
8754
  self.events$.emit(new ODataModelEvent('change', {
8606
- track: field,
8755
+ field: field,
8607
8756
  model: self,
8608
8757
  value,
8609
8758
  previous: currentValue,
@@ -8615,7 +8764,7 @@ class ODataModelOptions {
8615
8764
  _set(self, field, value) {
8616
8765
  return field.isStructuredType()
8617
8766
  ? this._setStructured(self, field, value)
8618
- : this._setValue(self, field.name, value, field.isKey());
8767
+ : this._setValue(self, field, value, field.isKey());
8619
8768
  }
8620
8769
  _unlink(self, relation) {
8621
8770
  if (relation.subscription !== undefined) {
@@ -8645,12 +8794,11 @@ class ODataModelOptions {
8645
8794
  event.options?.key) {
8646
8795
  let ref = relation.model.referential(relation.field);
8647
8796
  if (ref !== null && ref !== undefined) {
8648
- Object.entries(ref).forEach(([k, v]) => this._setValue(self, k, v, false));
8797
+ Object.assign(self, ref);
8649
8798
  }
8650
8799
  }
8651
8800
  }
8652
- event.push(self, relation.field.name);
8653
- self.events$.emit(event);
8801
+ self.events$.emit(event.push(self, relation.field));
8654
8802
  }
8655
8803
  });
8656
8804
  }
@@ -9318,8 +9466,7 @@ class ODataCollection {
9318
9466
  }
9319
9467
  }
9320
9468
  const index = this.models().indexOf(entry.model);
9321
- event.push(this, index);
9322
- this.events$.emit(event);
9469
+ this.events$.emit(event.push(this, index));
9323
9470
  }
9324
9471
  });
9325
9472
  }
@@ -9681,8 +9828,6 @@ class ODataModel {
9681
9828
  return throwError(() => new Error('fetch: Resource is undefined'));
9682
9829
  let obs$;
9683
9830
  if (resource instanceof ODataEntityResource) {
9684
- if (!resource.hasKey())
9685
- return throwError(() => new Error("fetch: Can't fetch model without key"));
9686
9831
  obs$ = resource.fetch(options);
9687
9832
  }
9688
9833
  else if (resource instanceof ODataNavigationPropertyResource) {
@@ -10699,9 +10844,9 @@ class ODataClient {
10699
10844
  return this.request('PUT', resource, addBody(options, body));
10700
10845
  }
10701
10846
  }
10702
- 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 });
10703
- ODataClient.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.3.6", ngImport: i0, type: ODataClient, providedIn: 'root' });
10704
- 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: [{
10705
10850
  type: Injectable,
10706
10851
  args: [{
10707
10852
  providedIn: 'root',
@@ -10957,9 +11102,9 @@ class ODataServiceFactory {
10957
11102
  })(this.client, singletonName, apiNameOrEntityType);
10958
11103
  }
10959
11104
  }
10960
- ODataServiceFactory.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.6", ngImport: i0, type: ODataServiceFactory, deps: [{ token: ODataClient }], target: i0.ɵɵFactoryTarget.Injectable });
10961
- ODataServiceFactory.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.3.6", ngImport: i0, type: ODataServiceFactory });
10962
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.6", ngImport: i0, type: ODataServiceFactory, decorators: [{
11105
+ ODataServiceFactory.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.0.1", ngImport: i0, type: ODataServiceFactory, deps: [{ token: ODataClient }], target: i0.ɵɵFactoryTarget.Injectable });
11106
+ ODataServiceFactory.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "14.0.1", ngImport: i0, type: ODataServiceFactory });
11107
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.0.1", ngImport: i0, type: ODataServiceFactory, decorators: [{
10963
11108
  type: Injectable
10964
11109
  }], ctorParameters: function () { return [{ type: ODataClient }]; } });
10965
11110
 
@@ -10983,10 +11128,10 @@ class ODataModule {
10983
11128
  };
10984
11129
  }
10985
11130
  }
10986
- ODataModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.6", ngImport: i0, type: ODataModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
10987
- ODataModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "13.3.6", ngImport: i0, type: ODataModule, imports: [HttpClientModule] });
10988
- ODataModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "13.3.6", ngImport: i0, type: ODataModule, providers: [ODataClient, ODataServiceFactory], imports: [[HttpClientModule]] });
10989
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.6", ngImport: i0, type: ODataModule, decorators: [{
11131
+ ODataModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.0.1", ngImport: i0, type: ODataModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
11132
+ ODataModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "14.0.1", ngImport: i0, type: ODataModule, imports: [HttpClientModule] });
11133
+ ODataModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "14.0.1", ngImport: i0, type: ODataModule, providers: [ODataClient, ODataServiceFactory], imports: [HttpClientModule] });
11134
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.0.1", ngImport: i0, type: ODataModule, decorators: [{
10990
11135
  type: NgModule,
10991
11136
  args: [{
10992
11137
  imports: [HttpClientModule],