@cap-js/ord 1.3.13 → 1.3.14

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 (2) hide show
  1. package/lib/interopCsn.js +25 -0
  2. package/package.json +2 -2
package/lib/interopCsn.js CHANGED
@@ -4,6 +4,7 @@ const localize = require("@sap/cds/lib/i18n/localize");
4
4
  function interopCSN(csn) {
5
5
  if (typeof csn != "object" || csn === null) return csn; // handle non-object inputs early
6
6
  add_i18n_texts(csn);
7
+ remove_localized_assoc(csn);
7
8
  map_annotations(csn);
8
9
  add_meta_info(csn);
9
10
  return csn;
@@ -61,6 +62,30 @@ function add_i18n_texts(csn) {
61
62
  }
62
63
  }
63
64
 
65
+ //
66
+ // remove association "localized" for localized texts
67
+ //
68
+ // The "localized" association for localized elements contains a reference to $user.locale
69
+ // and is specific to the CAP. It needs to be removed from the interop CSN.
70
+ //
71
+ function remove_localized_assoc(csn) {
72
+ // how to detect "localized" association?
73
+ // - name is "localized"
74
+ // - type is "cds.Association"
75
+ // - target name is source name + ".texts"
76
+ // - there is an ON condition
77
+ for (let n1 in csn.definitions) {
78
+ let def = csn.definitions[n1];
79
+ if (def.kind === "entity")
80
+ for (let n2 in def.elements) {
81
+ let el = def.elements[n2];
82
+ if (n2 === "localized" && el.type === "cds.Association" && el.target === `${n1}.texts` && el.on) {
83
+ delete def.elements[n2];
84
+ }
85
+ }
86
+ }
87
+ }
88
+
64
89
  //
65
90
  // annotation mapping/replacement
66
91
  //
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cap-js/ord",
3
- "version": "1.3.13",
3
+ "version": "1.3.14",
4
4
  "description": "CAP Plugin for generating ORD document.",
5
5
  "repository": "cap-js/ord",
6
6
  "author": "SAP SE (https://www.sap.com)",
@@ -29,7 +29,7 @@
29
29
  "eslint": "^9.2.0",
30
30
  "jest": "^30.0.0",
31
31
  "prettier": "3.6.2",
32
- "supertest": "^6.3.4"
32
+ "supertest": "^7.0.0"
33
33
  },
34
34
  "peerDependencies": {
35
35
  "@sap/cds": ">=8.9.4",