@sap/cds-dk 7.0.3 → 7.1.1
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.
- package/bin/bind.js +5 -6
- package/bin/build.js +2 -7
- package/bin/cds.js +2 -5
- package/bin/subscribe.js +4 -4
- package/bin/unsubscribe.js +4 -4
- package/bin/upgrade.js +4 -4
- package/lib/bind/cfKeyProvider.js +9 -10
- package/lib/bind/index.js +1 -3
- package/lib/build/buildTaskEngine.js +10 -22
- package/lib/build/buildTaskFactory.js +18 -27
- package/lib/build/buildTaskHandler.js +4 -7
- package/lib/build/index.js +12 -3
- package/lib/build/provider/buildTaskProviderInternal.js +23 -15
- package/lib/build/provider/fiori/index.js +4 -3
- package/lib/build/provider/java/index.js +2 -2
- package/lib/build/provider/mtx/index.js +8 -2
- package/lib/build/util.js +13 -0
- package/lib/client/activate.js +7 -7
- package/lib/client/auth_manager.js +5 -5
- package/lib/client/base_command.js +5 -5
- package/lib/client/extend.js +2 -2
- package/lib/client/helper/logging.js +7 -2
- package/lib/client/params.js +2 -3
- package/lib/client/pull.js +3 -3
- package/lib/client/push.js +3 -3
- package/lib/client/settings_manager.js +7 -8
- package/lib/client/tenant_action.js +3 -3
- package/lib/deploy/to-hana/hana.js +1 -2
- package/lib/import/common.js +3 -0
- package/lib/import/message.js +8 -2
- package/lib/import/odata/metadataconverter/MetadataConverter.js +13 -9
- package/lib/import/odata/v4parser.js +111 -107
- package/lib/init/constants.js +1 -1
- package/lib/init/index.js +24 -11
- package/lib/init/template/cf-manifest/files/manifest.yml.hbs +1 -1
- package/lib/init/template/data/index.js +2 -3
- package/lib/init/template/lint/index.js +5 -6
- package/lib/init/template/nodejs/index.js +2 -3
- package/lib/init/template/pipeline/index.js +1 -2
- package/lib/init/util/indent.js +1 -1
- package/lib/init/util/merge.js +3 -3
- package/lib/init/util/mvn.js +17 -22
- package/lib/util/cfUtil.js +1 -2
- package/npm-shrinkwrap.json +51 -53
- package/package.json +3 -2
- package/lib/client/helper/errors.js +0 -26
- package/lib/util/version.js +0 -27
package/lib/client/activate.js
CHANGED
|
@@ -5,7 +5,7 @@ const axios = require('axios');
|
|
|
5
5
|
const cds = require('../cds');
|
|
6
6
|
const DEBUG = cds.debug('cli');
|
|
7
7
|
const { collectFileContent, collectFiles, toUnixPath } = require('./helper/fs_helper');
|
|
8
|
-
const {
|
|
8
|
+
const { getMessage } = require('./helper/logging');
|
|
9
9
|
|
|
10
10
|
const AuthManager = require('./auth_manager');
|
|
11
11
|
const BaseCommand = require('./base_command');
|
|
@@ -30,7 +30,7 @@ async function checkFinished(jobId, statusUrl, params, finisher) {
|
|
|
30
30
|
finisher.finished = true;
|
|
31
31
|
clearInterval(finisher.timer);
|
|
32
32
|
if (status === JOB_STATUS.FAILED) {
|
|
33
|
-
return finisher.reject(
|
|
33
|
+
return finisher.reject(getMessage(`Job ${jobId} failed`, { error }));
|
|
34
34
|
}
|
|
35
35
|
console.log('Extension active');
|
|
36
36
|
finisher.resolve();
|
|
@@ -58,7 +58,7 @@ module.exports = class Activate extends BaseCommand {
|
|
|
58
58
|
}
|
|
59
59
|
|
|
60
60
|
if (!await this.checkProject(params.get('projectFolder'))) {
|
|
61
|
-
throw
|
|
61
|
+
throw params.get('projectFolder') + ' is not a valid extension project';
|
|
62
62
|
}
|
|
63
63
|
|
|
64
64
|
try {
|
|
@@ -133,7 +133,7 @@ module.exports = class Activate extends BaseCommand {
|
|
|
133
133
|
try {
|
|
134
134
|
pkgJson = await fs.readFile(path.join(absoluteFolder, 'package.json'), 'utf-8');
|
|
135
135
|
} catch (error) {
|
|
136
|
-
throw
|
|
136
|
+
throw getMessage('No package.json file found', { error });
|
|
137
137
|
}
|
|
138
138
|
allFiles.set('package.json', pkgJson);
|
|
139
139
|
|
|
@@ -182,11 +182,11 @@ module.exports = class Activate extends BaseCommand {
|
|
|
182
182
|
const { jobID: jobId, statusPath } = response.data;
|
|
183
183
|
|
|
184
184
|
if (jobId === undefined) {
|
|
185
|
-
throw
|
|
185
|
+
throw 'Activation failed: did not receive job ID';
|
|
186
186
|
}
|
|
187
187
|
|
|
188
188
|
if (!statusPath) {
|
|
189
|
-
throw
|
|
189
|
+
throw `Job ${jobId} failed: did not receive job-status path`;
|
|
190
190
|
}
|
|
191
191
|
|
|
192
192
|
DEBUG?.(`Job ID: ${jobId}`);
|
|
@@ -199,7 +199,7 @@ module.exports = class Activate extends BaseCommand {
|
|
|
199
199
|
finished: false,
|
|
200
200
|
timer: null
|
|
201
201
|
};
|
|
202
|
-
finisher.timer = setInterval(checkFinished.bind(undefined, jobId, statusUrl, params, finisher), 250)
|
|
202
|
+
finisher.timer = setInterval(checkFinished.bind(undefined, jobId, statusUrl, params, finisher), 250);
|
|
203
203
|
});
|
|
204
204
|
});
|
|
205
205
|
}
|
|
@@ -4,7 +4,7 @@ const cds = require('../cds');
|
|
|
4
4
|
const DEBUG = cds.debug('cli');
|
|
5
5
|
const { SettingsManager } = require('./settings_manager');
|
|
6
6
|
const { ParamCollection } = require('./params');
|
|
7
|
-
const {
|
|
7
|
+
const { getMessage } = require('./helper/logging');
|
|
8
8
|
|
|
9
9
|
function addTokenInfo(params, authData) {
|
|
10
10
|
params.set('token', authData.access_token);
|
|
@@ -79,14 +79,14 @@ async function retrieveTokenOrPasscodeUrl(params) {
|
|
|
79
79
|
if (error.response?.status === 404) { // may represent 405 in case of wrong method
|
|
80
80
|
continue;
|
|
81
81
|
}
|
|
82
|
-
throw
|
|
82
|
+
throw getMessage('Failed to get authentication token', { error });
|
|
83
83
|
}
|
|
84
84
|
if (response) {
|
|
85
85
|
break;
|
|
86
86
|
}
|
|
87
87
|
}
|
|
88
88
|
if (!response) {
|
|
89
|
-
throw
|
|
89
|
+
throw 'Failed to get authentication token';
|
|
90
90
|
}
|
|
91
91
|
authData = response.data;
|
|
92
92
|
|
|
@@ -115,9 +115,9 @@ module.exports = class AuthManager {
|
|
|
115
115
|
if (params.get('saveData')) {
|
|
116
116
|
await SettingsManager.saveSettings(params);
|
|
117
117
|
}
|
|
118
|
-
throw
|
|
118
|
+
throw `Failed to login: no valid token or passcode provided. Get a passcode${
|
|
119
119
|
params.get('passcodeUrl') ? ' from ' + params.get('passcodeUrl') : ''
|
|
120
|
-
} and supply the code when re-running the command
|
|
120
|
+
} and supply the code when re-running the command`;
|
|
121
121
|
}
|
|
122
122
|
params.set('reqAuth', { headers: { Authorization: 'Bearer ' + params.get('token') } });
|
|
123
123
|
}
|
|
@@ -3,7 +3,7 @@ const fs = require('fs').promises;
|
|
|
3
3
|
|
|
4
4
|
require('../util/pruneAxiosErrors');
|
|
5
5
|
|
|
6
|
-
const {
|
|
6
|
+
const { getMessage } = require('./helper/logging');
|
|
7
7
|
|
|
8
8
|
const MTX_URL_PATH_PREFIX = 'mtx/v1/model/';
|
|
9
9
|
const CUSTOM_FILE_URL_SUFFIX = 'customTenantContent';
|
|
@@ -22,16 +22,16 @@ module.exports = class BaseCommand {
|
|
|
22
22
|
const prefix = `Request to ${url} failed`;
|
|
23
23
|
switch (error.response?.status) {
|
|
24
24
|
case 401:
|
|
25
|
-
throw
|
|
25
|
+
throw getMessage(`${prefix}: invalid authentication.\nRetry with valid passcode${
|
|
26
26
|
params.has('passcodeUrl') ? ` from ${params.get('passcodeUrl')}` : ''
|
|
27
27
|
} or username/password (required if SaaS app is configured with mocked-auth).`, { error, command });
|
|
28
28
|
case 403:
|
|
29
|
-
throw
|
|
29
|
+
throw getMessage(prefix + ': insufficient authorization. Ensure client has all necessary roles.', { error, command });
|
|
30
30
|
case 404:
|
|
31
|
-
throw
|
|
31
|
+
throw getMessage(prefix + ': resource not found.', { error, command });
|
|
32
32
|
case 422:
|
|
33
33
|
// Compilation or native-extension error.
|
|
34
|
-
throw
|
|
34
|
+
throw getMessage(prefix + '.', { error, command });
|
|
35
35
|
default:
|
|
36
36
|
// Unexpected error should be transparent to user.
|
|
37
37
|
throw error;
|
package/lib/client/extend.js
CHANGED
|
@@ -6,7 +6,7 @@ const AuthManager = require('./auth_manager');
|
|
|
6
6
|
const BaseCommand = require('./base_command');
|
|
7
7
|
const { normalizePath, isParent } = require('./helper/fs_helper');
|
|
8
8
|
const Question = require('./helper/question');
|
|
9
|
-
const {
|
|
9
|
+
const { getMessage } = require('./helper/logging');
|
|
10
10
|
|
|
11
11
|
const COMMAND_URL_SUFFIX = 'content';
|
|
12
12
|
const CUSTOM_FILE_FOLDERS = ['wsdl'];
|
|
@@ -87,7 +87,7 @@ module.exports = class Extend extends BaseCommand {
|
|
|
87
87
|
|
|
88
88
|
const runOnExistingProject = await Extend.checkProject(params.get('projectFolder'));
|
|
89
89
|
if (runOnExistingProject && !(params.get('force') || params.get('templates'))) {
|
|
90
|
-
throw
|
|
90
|
+
throw getMessage(folderExists(params.get('projectFolder')), { command: 'extend' });
|
|
91
91
|
}
|
|
92
92
|
|
|
93
93
|
try {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/* eslint-disable no-console */
|
|
2
2
|
|
|
3
|
-
function getMessage(errorText, { error, help } = {}) {
|
|
3
|
+
function getMessage(errorText, { error, command, help = command && getCommandHelp(command) } = {}) {
|
|
4
4
|
let message = errorText ? errorText : '';
|
|
5
5
|
if (error) {
|
|
6
6
|
message += '\n' + (
|
|
@@ -8,7 +8,7 @@ function getMessage(errorText, { error, help } = {}) {
|
|
|
8
8
|
|| error.response?.data?.error?.message // response body == { error }
|
|
9
9
|
|| error.message // no response attached
|
|
10
10
|
);
|
|
11
|
-
if (
|
|
11
|
+
if (error.stack && require('../../cds').debug('cli')) {
|
|
12
12
|
message += '\n' + error.stack;
|
|
13
13
|
}
|
|
14
14
|
}
|
|
@@ -18,6 +18,11 @@ function getMessage(errorText, { error, help } = {}) {
|
|
|
18
18
|
return message;
|
|
19
19
|
}
|
|
20
20
|
|
|
21
|
+
function getCommandHelp(command) {
|
|
22
|
+
const cli = require('../../../bin/cds');
|
|
23
|
+
return cli?.load(command, () => ({ help: '' }))?.help ?? '';
|
|
24
|
+
}
|
|
25
|
+
|
|
21
26
|
module.exports = {
|
|
22
27
|
getMessage
|
|
23
28
|
};
|
package/lib/client/params.js
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
const cds = require('../cds');
|
|
2
2
|
const DEBUG = cds.debug('cli');
|
|
3
3
|
const { escapeRegex } = require('./helper/string_helper');
|
|
4
|
-
const { CliError } = require('./helper/errors');
|
|
5
4
|
|
|
6
5
|
|
|
7
6
|
// PARAM BASE TYPES
|
|
@@ -106,10 +105,10 @@ class Param {
|
|
|
106
105
|
expectedType = typeof this.allowedValues[0];
|
|
107
106
|
}
|
|
108
107
|
if (typeof val !== expectedType) {
|
|
109
|
-
throw
|
|
108
|
+
throw `Failed to set '${(this.name)}' = ${JSON.stringify(val)}: expected value of type ${expectedType}`;
|
|
110
109
|
}
|
|
111
110
|
if (this.allowedValues && !(this.allowedValues).includes(val)) {
|
|
112
|
-
throw
|
|
111
|
+
throw `Failed to set '${(this.name)}' = ${JSON.stringify(val)}: expected one of ${JSON.stringify(this.allowedValues)}`;
|
|
113
112
|
}
|
|
114
113
|
}
|
|
115
114
|
|
package/lib/client/pull.js
CHANGED
|
@@ -7,13 +7,13 @@ const axios = require('axios');
|
|
|
7
7
|
|
|
8
8
|
const { login } = require('./auth_manager');
|
|
9
9
|
const BaseCommand = require('./base_command');
|
|
10
|
-
const {
|
|
10
|
+
const { getMessage } = require('./helper/logging');
|
|
11
11
|
|
|
12
12
|
module.exports = class Pull extends BaseCommand {
|
|
13
13
|
|
|
14
14
|
static async run(paramValues) {
|
|
15
15
|
if (!tar) {
|
|
16
|
-
throw
|
|
16
|
+
throw `cds pull requires @sap/cds version >= 6.2. Current version is ${cds.version}\n`;
|
|
17
17
|
}
|
|
18
18
|
|
|
19
19
|
const params = await login(paramValues);
|
|
@@ -59,7 +59,7 @@ module.exports = class Pull extends BaseCommand {
|
|
|
59
59
|
try {
|
|
60
60
|
packageContents = JSON.parse(fs.readFileSync(packageJson, { encoding: 'utf-8' }));
|
|
61
61
|
} catch (error) {
|
|
62
|
-
throw
|
|
62
|
+
throw getMessage('package.json missing or unreadable', { error });
|
|
63
63
|
}
|
|
64
64
|
fs.writeFileSync(packageJson, JSON.stringify({
|
|
65
65
|
...packageContents,
|
package/lib/client/push.js
CHANGED
|
@@ -5,7 +5,7 @@ const axios = require('axios');
|
|
|
5
5
|
|
|
6
6
|
const { login } = require('./auth_manager');
|
|
7
7
|
const BaseCommand = require('./base_command');
|
|
8
|
-
const {
|
|
8
|
+
const { getMessage } = require('./helper/logging');
|
|
9
9
|
const { schemaRegex } = require('./helper/url_helper');
|
|
10
10
|
const buildSystem = require('../build')
|
|
11
11
|
|
|
@@ -39,7 +39,7 @@ module.exports = class Push extends BaseCommand {
|
|
|
39
39
|
src = local(src);
|
|
40
40
|
} else {
|
|
41
41
|
if (!schemaRegex.test(src)) {
|
|
42
|
-
throw
|
|
42
|
+
throw getMessage(`Nonexistent path: ${src}`, { command: 'push' });
|
|
43
43
|
}
|
|
44
44
|
try {
|
|
45
45
|
content = (await axios.get(src, { responseEncoding: 'base64' })).data;
|
|
@@ -54,7 +54,7 @@ module.exports = class Push extends BaseCommand {
|
|
|
54
54
|
try {
|
|
55
55
|
return require(join(projectFolder, 'package.json')).name;
|
|
56
56
|
} catch (error) {
|
|
57
|
-
throw
|
|
57
|
+
throw getMessage(`Extension project at ${projectFolder} is missing package.json file`, { error, command: 'push' });
|
|
58
58
|
}
|
|
59
59
|
}
|
|
60
60
|
|
|
@@ -9,7 +9,6 @@ const { requireGlobal } = require('./helper/dependency_helper');
|
|
|
9
9
|
const { getAppFromSuggestions, getSubdomain } = require('./helper/cf_helper');
|
|
10
10
|
const isBas = require('./helper/env_helper');
|
|
11
11
|
const Question = require('./helper/question');
|
|
12
|
-
const { CliError } = require('./helper/errors');
|
|
13
12
|
const { httpSchema, httpsSchema, schemaRegex, localhostRegex } = require('./helper/url_helper');
|
|
14
13
|
const { capitalize } = require('./helper/string_helper');
|
|
15
14
|
|
|
@@ -95,7 +94,7 @@ async function getTokenBaseUrl(params, renewUrl) {
|
|
|
95
94
|
return params.get('tokenUrl');
|
|
96
95
|
}
|
|
97
96
|
if (!params.has('appUrl')) {
|
|
98
|
-
throw
|
|
97
|
+
throw 'Failed to determine token URL: app URL not given';
|
|
99
98
|
}
|
|
100
99
|
const baseUrl = new URL(params.get('appUrl'));
|
|
101
100
|
const cleanPathname = pathname => baseUrl.pathname.replace(/\/?$/, pathname);
|
|
@@ -237,7 +236,7 @@ class SettingsManager {
|
|
|
237
236
|
|
|
238
237
|
// Check required param: appUrl
|
|
239
238
|
if (!params.has('appUrl')) {
|
|
240
|
-
throw
|
|
239
|
+
throw 'App URL not given. Please specify it or log in to Cloud Foundry and repeat this command.';
|
|
241
240
|
}
|
|
242
241
|
}
|
|
243
242
|
async function renewTokenUrl() {
|
|
@@ -273,8 +272,8 @@ class SettingsManager {
|
|
|
273
272
|
|
|
274
273
|
if (params.get('tokenStorage') === 'keyring' && params.get('saveData')) {
|
|
275
274
|
// Explicit login w/o plain-text storage enabled
|
|
276
|
-
throw
|
|
277
|
-
'Run `npm install -g keytar` or switch to ' + TOKEN_STORAGE_DESC.plain + ' by adding `--plain` (discouraged).'
|
|
275
|
+
throw capitalize(TOKEN_STORAGE_DESC.keyring) + ' requested but keytar not installed. ' +
|
|
276
|
+
'Run `npm install -g keytar` or switch to ' + TOKEN_STORAGE_DESC.plain + ' by adding `--plain` (discouraged).';
|
|
278
277
|
}
|
|
279
278
|
|
|
280
279
|
const doLog = params.get('saveData') || logout
|
|
@@ -296,14 +295,14 @@ class SettingsManager {
|
|
|
296
295
|
params.set('clientsecret', await Question.askQuestion('clientsecret: ', undefined, true));
|
|
297
296
|
console.log();
|
|
298
297
|
if (params.get('clientsecret') === '') {
|
|
299
|
-
throw
|
|
298
|
+
throw 'Clientsecret cannot be empty';
|
|
300
299
|
}
|
|
301
300
|
}
|
|
302
301
|
async function addKey() {
|
|
303
302
|
params.set('key', await Question.askQuestion('key: ', undefined, true));
|
|
304
303
|
console.log();
|
|
305
304
|
if (params.get('key') === '') {
|
|
306
|
-
throw
|
|
305
|
+
throw 'Key cannot be empty';
|
|
307
306
|
}
|
|
308
307
|
}
|
|
309
308
|
async function addPasscode() {
|
|
@@ -311,7 +310,7 @@ class SettingsManager {
|
|
|
311
310
|
params.set('passcode', (await Question.askQuestion(prompt, undefined, true)).trim());
|
|
312
311
|
console.log();
|
|
313
312
|
if (params.get('passcode') === '') {
|
|
314
|
-
throw
|
|
313
|
+
throw 'Passcode cannot be empty';
|
|
315
314
|
}
|
|
316
315
|
}
|
|
317
316
|
function setRelevantAuth(auth) {
|
|
@@ -2,7 +2,7 @@ const cds = require('../cds');
|
|
|
2
2
|
const DEBUG = cds.debug('cli');
|
|
3
3
|
|
|
4
4
|
const BaseCommand = require('./base_command');
|
|
5
|
-
const {
|
|
5
|
+
const { getMessage } = require('./helper/logging');
|
|
6
6
|
const { ParamCollection } = require('./params');
|
|
7
7
|
const AuthManager = require('./auth_manager');
|
|
8
8
|
const { capitalize } = require('./helper/string_helper');
|
|
@@ -65,13 +65,13 @@ module.exports = class TenantAction extends BaseCommand {
|
|
|
65
65
|
libPath = require.resolve(libId);
|
|
66
66
|
DEBUG?.(`Using cds-mtxs from ${libPath}`);
|
|
67
67
|
} catch (error) {
|
|
68
|
-
throw
|
|
68
|
+
throw getMessage('@sap/cds-mtxs not found or outdated. Have you changed into the directory of your SaaS app? If so, please upgrade to @sap/cds-mtxs@>=1.7.0', { error, command: this.command });
|
|
69
69
|
}
|
|
70
70
|
}
|
|
71
71
|
|
|
72
72
|
const { cds_mtx } = require(libPath);
|
|
73
73
|
if (!cds_mtx) {
|
|
74
|
-
throw
|
|
74
|
+
throw '@sap/cds-mtxs outdated. Please upgrade to @sap/cds-mtxs@>=1.7.0 and re-run this command.';
|
|
75
75
|
}
|
|
76
76
|
return cds_mtx(this.command, tenant);
|
|
77
77
|
}
|
|
@@ -15,7 +15,6 @@ const gitUtil = require('../../util/gitUtil');
|
|
|
15
15
|
const mtaUtil = require('./mtaUtil');
|
|
16
16
|
|
|
17
17
|
const { bold, info } = require('../../util/term');
|
|
18
|
-
const { CliError } = require('../../client/helper/errors');
|
|
19
18
|
|
|
20
19
|
const { bind } = require('../../bind');
|
|
21
20
|
|
|
@@ -49,7 +48,7 @@ class HanaDeployer {
|
|
|
49
48
|
let { model, serviceName, tunnelAddress, vcapFile, undeployWhitelist, hdiOptions } = options;
|
|
50
49
|
|
|
51
50
|
if (model) {
|
|
52
|
-
throw
|
|
51
|
+
throw 'Specifying a model for hana deployment is not supported.';
|
|
53
52
|
}
|
|
54
53
|
|
|
55
54
|
console.log(`${bold('Starting deploy to SAP HANA ...')}`);
|
package/lib/import/common.js
CHANGED
package/lib/import/message.js
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
const messages = {
|
|
4
4
|
INVALID_EDMX_METADATA: 'The OData model is not valid. Specify the correct OData model.',
|
|
5
|
+
INVALID_EDMX_METADATA_VERSION: 'The OData version is not valid. Specify the correct OData version.',
|
|
5
6
|
INVALID_OUTPUT_FILE: 'Please provide an output file with one of these [cds, csn, json] file extension.',
|
|
6
7
|
SPECIFY_INPUT_FILE: 'Specify an input file that exists.',
|
|
7
8
|
SPECIFY_OUTPUT_FILE: 'Specify an output file or correct the output file path provided.',
|
|
@@ -26,9 +27,14 @@ const messages = {
|
|
|
26
27
|
BOUNDED_ACTION_COLLISION: 'For Bounded Action, combination of action name and binding parameter type should be unique.',
|
|
27
28
|
STREAM_NO_COLLECTION: `'Edm.Stream' cannot be of Collection type.`,
|
|
28
29
|
UNSUPPORTED_PROPERTY_TYPE: 'Property cannot be of EntityType. Check the type: ',
|
|
29
|
-
|
|
30
|
+
UNRESOLVED_SCHEMA_NAMESPACE: `Could not resolve the schema `,
|
|
30
31
|
INVALID_DATATYPE: `Invalid Data Type `,
|
|
31
|
-
ELEMENT_NAME_COLLISION: 'Collision between EntityContainer Element Name and Schema Element Name is currenlty not supported. Please check the element name: '
|
|
32
|
+
ELEMENT_NAME_COLLISION: 'Collision between EntityContainer Element Name and Schema Element Name is currenlty not supported. Please check the element name: ',
|
|
33
|
+
NO_DEFAULT_FOR_COLLECTIONS: 'WARNING: Collection type cannot have a Default value.',
|
|
34
|
+
BINARY_MAXLENGTH: 'WARNING: MaxLength for type Edm.Binary should not exceed 5000.',
|
|
35
|
+
SCALE_GT_PRECISION: 'WARNING: Scale value should not be greater than Precision value.',
|
|
36
|
+
FIXED_PRECISION_VARIABLE_SCALE: 'WARNING: Fixed Precision with Variable or Floating Scale is not supported in CDS.',
|
|
37
|
+
NULLABLE_KEY: 'WARNING: Key element cannot be Nullable.'
|
|
32
38
|
};
|
|
33
39
|
|
|
34
40
|
function getMessages() {
|
|
@@ -450,22 +450,26 @@ class Expression {
|
|
|
450
450
|
XML: If no value is specified, the Scale facet defaults to zero.
|
|
451
451
|
JSON: If no value is specified, the Scale facet defaults to zero
|
|
452
452
|
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
0
|
|
458
|
-
|
|
453
|
+
OLD NEW
|
|
454
|
+
XML | JSON XML | JSON
|
|
455
|
+
--------------------- -----------------------
|
|
456
|
+
variable | variable variable | variable
|
|
457
|
+
1-* | 1-* 0-* | 0-*
|
|
458
|
+
0 | undefined undefined | undefined
|
|
459
|
+
undefined | undefined
|
|
460
|
+
|
|
461
|
+
* In case EDMX doesn't specify Scale, we are not adding default `0` for it anymore
|
|
462
|
+
* beause we want to easily identify and preserve the explicitly mentioned Scale="0" in EDMX
|
|
459
463
|
*/
|
|
460
464
|
if (args.includes('$Scale') && (target.$Type === 'Edm.Decimal' || target.$UnderlyingType === 'Edm.Decimal')) {
|
|
461
465
|
if (attribs.Scale != null) {
|
|
462
466
|
if (attribs.Scale === 'variable' || attribs.Scale === 'floating') {
|
|
463
467
|
target.$Scale = attribs.Scale;
|
|
464
|
-
}
|
|
468
|
+
}
|
|
469
|
+
// for now considering only non-negative integers
|
|
470
|
+
else if (Number(attribs.Scale) >= 0) {
|
|
465
471
|
target.$Scale = parseInt(attribs.Scale, 10);
|
|
466
472
|
}
|
|
467
|
-
} else {
|
|
468
|
-
target.$Scale = 0;
|
|
469
473
|
}
|
|
470
474
|
}
|
|
471
475
|
|