angular-odata 0.140.1 → 0.141.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 (58) hide show
  1. package/fesm2022/angular-odata.mjs +36 -24
  2. package/fesm2022/angular-odata.mjs.map +1 -1
  3. package/index.d.ts +212 -176
  4. package/package.json +1 -1
  5. package/schematics/apigen/angular/api-config.d.ts +2 -1
  6. package/schematics/apigen/angular/api-config.js +9 -3
  7. package/schematics/apigen/angular/api-config.js.map +1 -1
  8. package/schematics/apigen/angular/base.d.ts +12 -3
  9. package/schematics/apigen/angular/base.js +87 -5
  10. package/schematics/apigen/angular/base.js.map +1 -1
  11. package/schematics/apigen/angular/collection.d.ts +23 -0
  12. package/schematics/apigen/angular/collection.js +79 -0
  13. package/schematics/apigen/angular/collection.js.map +1 -0
  14. package/schematics/apigen/angular/entity.d.ts +8 -2
  15. package/schematics/apigen/angular/entity.js +45 -14
  16. package/schematics/apigen/angular/entity.js.map +1 -1
  17. package/schematics/apigen/angular/enum.d.ts +2 -1
  18. package/schematics/apigen/angular/enum.js +2 -2
  19. package/schematics/apigen/angular/enum.js.map +1 -1
  20. package/schematics/apigen/angular/model.d.ts +40 -0
  21. package/schematics/apigen/angular/model.js +265 -0
  22. package/schematics/apigen/angular/model.js.map +1 -0
  23. package/schematics/apigen/angular/module.d.ts +3 -1
  24. package/schematics/apigen/angular/module.js +3 -2
  25. package/schematics/apigen/angular/module.js.map +1 -1
  26. package/schematics/apigen/angular/package.d.ts +38 -0
  27. package/schematics/apigen/angular/package.js +169 -0
  28. package/schematics/apigen/angular/package.js.map +1 -0
  29. package/schematics/apigen/angular/service.d.ts +2 -1
  30. package/schematics/apigen/angular/service.js +2 -2
  31. package/schematics/apigen/angular/service.js.map +1 -1
  32. package/schematics/apigen/files/api-config/__fileName__.ts +9 -2
  33. package/schematics/apigen/files/collection/__fileName__.ts +20 -0
  34. package/schematics/apigen/files/entity/__fileName__.ts +2 -1
  35. package/schematics/apigen/files/model/__fileName__.ts +31 -0
  36. package/schematics/apigen/index.js +6 -88
  37. package/schematics/apigen/index.js.map +1 -1
  38. package/schematics/apigen/metadata/csdl/csdl-entity-set.js +1 -1
  39. package/schematics/apigen/metadata/csdl/csdl-entity-set.js.map +1 -1
  40. package/schematics/apigen/metadata/csdl/csdl-function-action.d.ts +1 -0
  41. package/schematics/apigen/metadata/csdl/csdl-function-action.js +6 -0
  42. package/schematics/apigen/metadata/csdl/csdl-function-action.js.map +1 -1
  43. package/schematics/apigen/metadata/csdl/csdl-navigation-property-binding.d.ts +9 -1
  44. package/schematics/apigen/metadata/csdl/csdl-navigation-property-binding.js +34 -1
  45. package/schematics/apigen/metadata/csdl/csdl-navigation-property-binding.js.map +1 -1
  46. package/schematics/apigen/metadata/csdl/csdl-singleton.js +1 -1
  47. package/schematics/apigen/metadata/csdl/csdl-singleton.js.map +1 -1
  48. package/schematics/apigen/metadata/csdl/csdl-structural-property.d.ts +8 -3
  49. package/schematics/apigen/metadata/csdl/csdl-structural-property.js +11 -5
  50. package/schematics/apigen/metadata/csdl/csdl-structural-property.js.map +1 -1
  51. package/schematics/apigen/metadata/csdl/csdl-structured-type.d.ts +1 -0
  52. package/schematics/apigen/metadata/csdl/csdl-structured-type.js +16 -2
  53. package/schematics/apigen/metadata/csdl/csdl-structured-type.js.map +1 -1
  54. package/schematics/apigen/metadata/metadata.d.ts +12 -1
  55. package/schematics/apigen/metadata/metadata.js +44 -2
  56. package/schematics/apigen/metadata/metadata.js.map +1 -1
  57. package/schematics/apigen/schema.d.ts +1 -0
  58. package/schematics/apigen/schema.json +5 -0
@@ -2986,14 +2986,7 @@ class ODataStructuredType extends ODataParserSchemaElement {
2986
2986
  parserForType: (t) => this.api.parserForType(t),
2987
2987
  });
2988
2988
  if (this.model !== undefined) {
2989
- this.model.meta = this.api.optionsForType(this.type(), {
2990
- config: this.model.options,
2991
- structuredType: this,
2992
- });
2993
- if (this.model.meta !== undefined) {
2994
- // Configure
2995
- this.model.meta.configure({ options });
2996
- }
2989
+ this.api.configureModel(this, this.model);
2997
2990
  if (this.collection !== undefined) {
2998
2991
  this.collection.model = this.model;
2999
2992
  }
@@ -9186,7 +9179,7 @@ class ODataMetadataParser {
9186
9179
  try {
9187
9180
  const parser = new DOMParser();
9188
9181
  this.document = parser.parseFromString(xml, 'text/xml');
9189
- this.checkVersion(document);
9182
+ this.checkVersion(this.document);
9190
9183
  }
9191
9184
  catch (error) {
9192
9185
  throw new Error('Unable to parse metadata, ' + error);
@@ -9216,9 +9209,9 @@ class ODataMetadataParser {
9216
9209
  ]);
9217
9210
  return new ODataMetadata(version, references, schemas);
9218
9211
  }
9219
- checkVersion(document) {
9212
+ checkVersion(doc) {
9220
9213
  // check version
9221
- const attributes = document.documentElement.attributes;
9214
+ const attributes = doc.documentElement.attributes;
9222
9215
  if (!attributes) {
9223
9216
  throw new Error('OData version is not specified in the metadata');
9224
9217
  }
@@ -12798,6 +12791,10 @@ class ODataApi {
12798
12791
  parsers;
12799
12792
  // Schemas
12800
12793
  schemas;
12794
+ // Models
12795
+ models = {};
12796
+ // Collections
12797
+ collections = {};
12801
12798
  constructor(config) {
12802
12799
  this.serviceRootUrl = config.serviceRootUrl;
12803
12800
  if (this.serviceRootUrl.includes('?'))
@@ -12817,6 +12814,8 @@ class ODataApi {
12817
12814
  this.errorHandler = config.errorHandler;
12818
12815
  this.parsers = new Map(Object.entries(config.parsers ?? EDM_PARSERS));
12819
12816
  this.schemas = (config.schemas ?? []).map((schema) => new ODataSchema(schema, this));
12817
+ this.models = (config.models ?? {});
12818
+ this.collections = (config.collections ?? {});
12820
12819
  }
12821
12820
  configure(settings = {}) {
12822
12821
  this.requester = settings.requester;
@@ -12825,6 +12824,16 @@ class ODataApi {
12825
12824
  options: this.options.parserOptions,
12826
12825
  });
12827
12826
  });
12827
+ Object.entries(this.models).forEach(([type, model]) => {
12828
+ const structured = this.findStructuredType(type);
12829
+ if (structured !== undefined) {
12830
+ this.configureModel(structured, model);
12831
+ const collection = this.collections[type];
12832
+ if (collection !== undefined) {
12833
+ collection.model = model;
12834
+ }
12835
+ }
12836
+ });
12828
12837
  }
12829
12838
  populate(metadata) {
12830
12839
  const config = metadata.toConfig();
@@ -13093,8 +13102,18 @@ class ODataApi {
13093
13102
  return singleton;
13094
13103
  }
13095
13104
  //#endregion
13105
+ configureModel(structured, model) {
13106
+ model.meta = this.optionsForType(structured.type(), {
13107
+ config: model.options,
13108
+ structuredType: structured,
13109
+ });
13110
+ if (model.meta !== undefined) {
13111
+ // Configure
13112
+ model.meta.configure({ options: this.options.parserOptions });
13113
+ }
13114
+ }
13096
13115
  findModel(type) {
13097
- return this.findStructuredType(type)?.model;
13116
+ return (this.models[type] ?? this.findStructuredType(type)?.model);
13098
13117
  }
13099
13118
  createModel(structured) {
13100
13119
  if (structured.model !== undefined)
@@ -13102,17 +13121,7 @@ class ODataApi {
13102
13121
  // Build Ad-hoc model
13103
13122
  const Model = class extends ODataModel {
13104
13123
  };
13105
- // Build Meta
13106
- Model.meta = this.optionsForType(structured.type(), {
13107
- structuredType: structured,
13108
- });
13109
- if (Model.meta !== undefined) {
13110
- // Configure
13111
- Model.meta.configure({
13112
- options: this.options.parserOptions,
13113
- });
13114
- }
13115
- // Store New Model for next time
13124
+ // Store New Model structured for next time
13116
13125
  structured.model = Model;
13117
13126
  return Model;
13118
13127
  }
@@ -13123,20 +13132,23 @@ class ODataApi {
13123
13132
  if (structured === undefined)
13124
13133
  throw Error(`No structured type for ${type}`);
13125
13134
  Model = this.createModel(structured);
13135
+ this.configureModel(structured, Model);
13126
13136
  }
13127
13137
  return Model;
13128
13138
  }
13129
13139
  findCollection(type) {
13130
- return this.findStructuredType(type)?.collection;
13140
+ return (this.collections[type] ?? this.findStructuredType(type)?.collection);
13131
13141
  }
13132
13142
  createCollection(structured, model) {
13133
13143
  if (structured.collection !== undefined)
13134
13144
  return structured.collection;
13135
13145
  if (model === undefined)
13136
13146
  model = this.createModel(structured);
13147
+ // Build Ad-hoc collection
13137
13148
  const Collection = class extends ODataCollection {
13138
13149
  static model = model;
13139
13150
  };
13151
+ // Store New Collection structured for next time
13140
13152
  structured.collection = Collection;
13141
13153
  return Collection;
13142
13154
  }