@sap-ux/project-access 1.17.3 → 1.17.5

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.
@@ -125,7 +125,7 @@ class ApplicationAccessImp {
125
125
  /**
126
126
  * For a given app in project, retrieves i18n bundles for 'sap.app' namespace,`models` of `sap.ui5` namespace and service for cap services.
127
127
  *
128
- * @returns i18n bundles or exception
128
+ * @returns i18n bundles or exception captured in optional errors object
129
129
  */
130
130
  getI18nBundles() {
131
131
  return (0, i18n_1.getI18nBundles)(this.project.root, this.app.i18n, this.project.projectType, this.fs);
@@ -9,7 +9,7 @@ import type { Editor } from 'mem-fs-editor';
9
9
  * @param fs optional `mem-fs-editor` instance. If provided, `mem-fs-editor` api is used instead of `fs` of node.
10
10
  * In case of CAP project, some CDS APIs are used internally which depends on `fs` of node and not `mem-fs-editor`.
11
11
  * When calling this function, adding or removing a CDS file in memory or changing CDS configuration will not be considered until present on real file system.
12
- * @returns i18n bundles or exception
12
+ * @returns i18n bundles or exception captured in optional errors object
13
13
  */
14
14
  export declare function getI18nBundles(root: string, i18nPropertiesPaths: I18nPropertiesPaths, projectType?: ProjectType, fs?: Editor): Promise<I18nBundles>;
15
15
  /**
@@ -12,6 +12,19 @@ Object.defineProperty(exports, "__esModule", { value: true });
12
12
  exports.getCapI18nFolderNames = exports.getI18nBundles = void 0;
13
13
  const i18n_1 = require("@sap-ux/i18n");
14
14
  const __1 = require("..");
15
+ /**
16
+ * Add error to optional errors object.
17
+ *
18
+ * @param result i18n bundles
19
+ * @param key key to associate with the error
20
+ * @param error error to add
21
+ */
22
+ function addToErrors(result, key, error) {
23
+ if (!result.errors) {
24
+ result.errors = {};
25
+ }
26
+ result.errors[key] = error;
27
+ }
15
28
  /**
16
29
  * For a given app in project, retrieves i18n bundles for 'sap.app' namespace,`models` of `sap.ui5` namespace and service for cap services.
17
30
  *
@@ -21,7 +34,7 @@ const __1 = require("..");
21
34
  * @param fs optional `mem-fs-editor` instance. If provided, `mem-fs-editor` api is used instead of `fs` of node.
22
35
  * In case of CAP project, some CDS APIs are used internally which depends on `fs` of node and not `mem-fs-editor`.
23
36
  * When calling this function, adding or removing a CDS file in memory or changing CDS configuration will not be considered until present on real file system.
24
- * @returns i18n bundles or exception
37
+ * @returns i18n bundles or exception captured in optional errors object
25
38
  */
26
39
  function getI18nBundles(root, i18nPropertiesPaths, projectType, fs) {
27
40
  return __awaiter(this, void 0, void 0, function* () {
@@ -30,14 +43,31 @@ function getI18nBundles(root, i18nPropertiesPaths, projectType, fs) {
30
43
  models: {},
31
44
  service: {}
32
45
  };
33
- result['sap.app'] = yield (0, i18n_1.getPropertiesI18nBundle)(i18nPropertiesPaths['sap.app'], fs);
46
+ try {
47
+ result['sap.app'] = yield (0, i18n_1.getPropertiesI18nBundle)(i18nPropertiesPaths['sap.app'], fs);
48
+ }
49
+ catch (error) {
50
+ addToErrors(result, 'sap.app', error);
51
+ }
34
52
  for (const key of Object.keys(i18nPropertiesPaths.models)) {
35
- result.models[key] = yield (0, i18n_1.getPropertiesI18nBundle)(i18nPropertiesPaths.models[key].path, fs);
53
+ try {
54
+ result.models[key] = yield (0, i18n_1.getPropertiesI18nBundle)(i18nPropertiesPaths.models[key].path, fs);
55
+ }
56
+ catch (error) {
57
+ // add models key with empty model
58
+ result.models[key] = {};
59
+ addToErrors(result, `models.${key}`, error);
60
+ }
36
61
  }
37
62
  if (projectType === 'CAPNodejs') {
38
- const env = yield (0, __1.getCapEnvironment)(root);
39
- const cdsFiles = yield (0, __1.getCdsFiles)(root, true);
40
- result.service = yield (0, i18n_1.getCapI18nBundle)(root, env, cdsFiles, fs);
63
+ try {
64
+ const env = yield (0, __1.getCapEnvironment)(root);
65
+ const cdsFiles = yield (0, __1.getCdsFiles)(root, true);
66
+ result.service = yield (0, i18n_1.getCapI18nBundle)(root, env, cdsFiles, fs);
67
+ }
68
+ catch (error) {
69
+ addToErrors(result, 'service', error);
70
+ }
41
71
  }
42
72
  return result;
43
73
  });
@@ -8,13 +8,89 @@ interface BaseAccess {
8
8
  }
9
9
  export interface ApplicationAccess extends BaseAccess {
10
10
  readonly app: ApplicationStructure;
11
+ /**
12
+ * Maintains new translation entries in an existing i18n file or in a new i18n properties file if it does not exist.
13
+ *
14
+ * @param newEntries - translation entries to write in the `.properties` file
15
+ * @returns - boolean or exception
16
+ * @description It also update `manifest.json` file if `@i18n` entry is missing from `"sap.ui5":{"models": {}}`
17
+ * as
18
+ * ```JSON
19
+ * {
20
+ * "sap.ui5": {
21
+ * "models": {
22
+ * "@i18n": {
23
+ * "type": "sap.ui.model.resource.ResourceModel",
24
+ * "uri": "i18n/i18n.properties"
25
+ * }
26
+ * }
27
+ * }
28
+ * }
29
+ * ```
30
+ */
11
31
  createAnnotationI18nEntries(newEntries: NewI18nEntry[]): Promise<boolean>;
32
+ /**
33
+ * Maintains new translation entries in an existing i18n file or in a new i18n properties file if it does not exist.
34
+ *
35
+ * @param newEntries - translation entries to write in the `.properties` file
36
+ * @param modelKey - i18n model key. Default key is `i18n`
37
+ * @returns boolean or exception
38
+ * @description It also update `manifest.json` file if `<modelKey>` entry is missing from `"sap.ui5":{"models": {}}`
39
+ * as
40
+ * ```JSON
41
+ * {
42
+ * "sap.ui5": {
43
+ * "models": {
44
+ * "<modelKey>": {
45
+ * "type": "sap.ui.model.resource.ResourceModel",
46
+ * "uri": "i18n/i18n.properties"
47
+ * }
48
+ * }
49
+ * }
50
+ * }
51
+ * ```
52
+ */
12
53
  createUI5I18nEntries(newEntries: NewI18nEntry[], modelKey?: string): Promise<boolean>;
54
+ /**
55
+ * Maintains new translation entries in an existing i18n file or in a new i18n properties file if it does not exist.
56
+ *
57
+ * @param newEntries translation entries to write in the `.properties` file
58
+ * @returns boolean or exception
59
+ * @description If `i18n` entry is missing from `"sap.app":{}`, default `i18n/i18n.properties` is used. Update of `manifest.json` file is not needed.
60
+ */
13
61
  createManifestI18nEntries(newEntries: NewI18nEntry[]): Promise<boolean>;
62
+ /**
63
+ * Maintains new translation entries in CAP i18n files.
64
+ *
65
+ * @param filePath file in which the translation entry will be used.
66
+ * @param newI18nEntries translation entries to write in the i18n file.
67
+ * @returns boolean or exception
68
+ */
14
69
  createCapI18nEntries(filePath: string, newI18nEntries: NewI18nEntry[]): Promise<boolean>;
70
+ /**
71
+ * Return the application id of this app, which is the relative path from the project root
72
+ * to the app root.
73
+ *
74
+ * @returns - Application root path
75
+ */
15
76
  getAppId(): string;
77
+ /**
78
+ * Return the absolute application root path.
79
+ *
80
+ * @returns - Application root path
81
+ */
16
82
  getAppRoot(): string;
83
+ /**
84
+ * For a given app in project, retrieves i18n bundles for 'sap.app' namespace,`models` of `sap.ui5` namespace and service for cap services.
85
+ *
86
+ * @returns i18n bundles or exception
87
+ */
17
88
  getI18nBundles(): Promise<I18nBundles>;
89
+ /**
90
+ * Return absolute paths to i18n.properties files from manifest.
91
+ *
92
+ * @returns absolute paths to i18n.properties
93
+ */
18
94
  getI18nPropertiesPaths(): Promise<I18nPropertiesPaths>;
19
95
  }
20
96
  export interface ProjectAccess extends BaseAccess {
@@ -129,6 +129,12 @@ interface Entity extends Struct {
129
129
  };
130
130
  }
131
131
  interface LinkedDefinition {
132
+ /**
133
+ * Checks if the definition is of the specified kind or has the 'Association' or 'Composition' kind.
134
+ *
135
+ * @param {kind | 'Association' | 'Composition'} kind - The kind to check for.
136
+ * @returns {boolean} - True if the definition is of the specified kind or has the 'Association' or 'Composition' kind, false otherwise.
137
+ */
132
138
  is(kind: kind | 'Association' | 'Composition'): boolean;
133
139
  name: string;
134
140
  }
@@ -14,5 +14,9 @@ export interface I18nBundles {
14
14
  * i18n bundle for cap services
15
15
  */
16
16
  service: I18nBundle;
17
+ /**
18
+ * Optional errors object containing error records of i18n bundles
19
+ */
20
+ errors?: Record<string, Error>;
17
21
  }
18
22
  //# sourceMappingURL=index.d.ts.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sap-ux/project-access",
3
- "version": "1.17.3",
3
+ "version": "1.17.5",
4
4
  "description": "Library to access SAP Fiori tools projects",
5
5
  "repository": {
6
6
  "type": "git",
@@ -20,22 +20,21 @@
20
20
  "!dist/**/*.map"
21
21
  ],
22
22
  "engines": {
23
- "pnpm": ">=6.26.1 < 7.0.0 || >=7.1.0",
24
23
  "node": ">=18.x"
25
24
  },
26
25
  "dependencies": {
27
26
  "findit2": "2.2.3",
28
27
  "mem-fs": "2.1.0",
29
28
  "mem-fs-editor": "9.4.0",
30
- "@sap-ux/i18n": "0.0.3",
31
- "@sap-ux/ui5-config": "0.21.0"
29
+ "@sap-ux/i18n": "0.0.4",
30
+ "@sap-ux/ui5-config": "0.21.1"
32
31
  },
33
32
  "devDependencies": {
34
33
  "@types/mem-fs": "1.1.2",
35
34
  "@types/mem-fs-editor": "7.0.1",
36
35
  "@ui5/manifest": "1.61.0",
37
36
  "vscode-uri": "3.0.7",
38
- "@sap-ux/logger": "0.5.0"
37
+ "@sap-ux/logger": "0.5.1"
39
38
  },
40
39
  "scripts": {
41
40
  "build": "tsc --build",