@sap-ux/ui-service-sub-generator 0.2.7 → 1.0.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.
- package/generators/app/index.js +47 -53
- package/generators/app/telemetryHelper.d.ts +1 -1
- package/generators/app/telemetryHelper.js +3 -6
- package/generators/app/types.d.ts +1 -1
- package/generators/app/types.js +1 -4
- package/generators/app/utils.d.ts +2 -2
- package/generators/app/utils.js +52 -70
- package/generators/utils/constants.js +11 -14
- package/generators/utils/i18n.js +9 -19
- package/generators/utils/index.d.ts +3 -3
- package/generators/utils/index.js +3 -19
- package/generators/utils/logger.js +4 -7
- package/package.json +16 -14
package/generators/app/index.js
CHANGED
|
@@ -1,24 +1,19 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
};
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
const utils_1 = require("../utils");
|
|
12
|
-
const logger_1 = __importDefault(require("../utils/logger"));
|
|
13
|
-
const telemetryHelper_1 = require("./telemetryHelper");
|
|
14
|
-
const types_1 = require("./types");
|
|
15
|
-
const utils_2 = require("./utils");
|
|
1
|
+
import { AppWizard, Prompts, MessageType } from '@sap-devx/yeoman-ui-types';
|
|
2
|
+
import { isInternalFeaturesSettingEnabled } from '@sap-ux/feature-toggle';
|
|
3
|
+
import { sendTelemetry, setYeomanEnvConflicterForce, TelemetryHelper } from '@sap-ux/fiori-generator-shared';
|
|
4
|
+
import { getConfigPrompts, getSystemSelectionPrompts, ObjectType } from '@sap-ux/ui-service-inquirer';
|
|
5
|
+
import Generator from 'yeoman-generator';
|
|
6
|
+
import { boUri, cdsUri, initI18n, prompts, SERVICE_GENERATION_SUCCESS, t, UI_SERVICE_CACHE } from '../utils/index.js';
|
|
7
|
+
import UiServiceGenLogger from '../utils/logger.js';
|
|
8
|
+
import { getTelemetryData } from './telemetryHelper.js';
|
|
9
|
+
import { BAS_OBJECT } from './types.js';
|
|
10
|
+
import { addToCache, authenticateInputData, generateService, getAppGenSystemData, getFromCache, runPostGenHook, setToolbarMessage, writeBASMetadata } from './utils.js';
|
|
16
11
|
/**
|
|
17
12
|
* Generator for creating a new UI Service.
|
|
18
13
|
*
|
|
19
14
|
* @extends Generator
|
|
20
15
|
*/
|
|
21
|
-
class
|
|
16
|
+
export default class extends Generator {
|
|
22
17
|
answers = {
|
|
23
18
|
url: '',
|
|
24
19
|
package: ''
|
|
@@ -41,22 +36,22 @@ class default_1 extends yeoman_generator_1.default {
|
|
|
41
36
|
*/
|
|
42
37
|
constructor(args, opts) {
|
|
43
38
|
super(args, opts);
|
|
44
|
-
|
|
45
|
-
this.appWizard =
|
|
39
|
+
setYeomanEnvConflicterForce(this.env, this.options.force);
|
|
40
|
+
this.appWizard = AppWizard.create(opts);
|
|
46
41
|
this.vscode = opts.vscode;
|
|
47
|
-
|
|
48
|
-
const steps =
|
|
42
|
+
UiServiceGenLogger.configureLogging(this.options.logger, this.rootGeneratorName(), this.log, this.options.vscode, this.options.logLevel);
|
|
43
|
+
const steps = prompts;
|
|
49
44
|
// if options.data is present, skip the first step
|
|
50
45
|
// options.data is passeed from BAS service center
|
|
51
46
|
if (this.options.data?.systemName) {
|
|
52
47
|
steps.shift();
|
|
53
48
|
}
|
|
54
|
-
this.appWizard =
|
|
55
|
-
if (!this.appWizard[
|
|
56
|
-
this.appWizard[
|
|
49
|
+
this.appWizard = AppWizard.create(opts);
|
|
50
|
+
if (!this.appWizard[UI_SERVICE_CACHE]) {
|
|
51
|
+
this.appWizard[UI_SERVICE_CACHE] = {};
|
|
57
52
|
}
|
|
58
53
|
this.appWizard.setHeaderTitle('UI Service Generator');
|
|
59
|
-
this.prompts = new
|
|
54
|
+
this.prompts = new Prompts(steps);
|
|
60
55
|
this.setPromptsCallback = (fn) => {
|
|
61
56
|
if (this.prompts) {
|
|
62
57
|
this.prompts.setCallback(fn);
|
|
@@ -64,27 +59,27 @@ class default_1 extends yeoman_generator_1.default {
|
|
|
64
59
|
};
|
|
65
60
|
}
|
|
66
61
|
async initializing() {
|
|
67
|
-
await
|
|
62
|
+
await TelemetryHelper.initTelemetrySettings({
|
|
68
63
|
consumerModule: {
|
|
69
64
|
name: '@sap/generator-fiori-ui-service',
|
|
70
65
|
version: this.rootGeneratorVersion()
|
|
71
66
|
},
|
|
72
|
-
internalFeature:
|
|
67
|
+
internalFeature: isInternalFeaturesSettingEnabled(),
|
|
73
68
|
watchTelemetrySettingStore: false
|
|
74
69
|
});
|
|
75
|
-
await
|
|
70
|
+
await initI18n();
|
|
76
71
|
if (this.options.data?.systemName) {
|
|
77
|
-
|
|
72
|
+
UiServiceGenLogger.logger.debug('Options passed into generator: ' + JSON.stringify(this.options.data));
|
|
78
73
|
await this._initSteps();
|
|
79
74
|
}
|
|
80
75
|
}
|
|
81
76
|
async _initSteps() {
|
|
82
|
-
await
|
|
77
|
+
await authenticateInputData(this.options.data, this.systemSelectionAnswers);
|
|
83
78
|
if (this.systemSelectionAnswers.connectedSystem?.serviceProvider) {
|
|
84
79
|
try {
|
|
85
80
|
if (this.options.data.id && this.options.data.type) {
|
|
86
81
|
// new BAS service center data interface, for BO and CDS
|
|
87
|
-
const objectUri = this.options.data.type ===
|
|
82
|
+
const objectUri = this.options.data.type === BAS_OBJECT.BUSINESS_OBJECT ? boUri : cdsUri;
|
|
88
83
|
this.systemSelectionAnswers.objectGenerator = await this.systemSelectionAnswers.connectedSystem.serviceProvider.getUiServiceGenerator({
|
|
89
84
|
name: this.options.data.id,
|
|
90
85
|
uri: `${objectUri}${this.options.data.id.toLowerCase()}`
|
|
@@ -95,7 +90,7 @@ class default_1 extends yeoman_generator_1.default {
|
|
|
95
90
|
// to be removed once BAS release new interface
|
|
96
91
|
this.systemSelectionAnswers.objectGenerator = await this.systemSelectionAnswers.connectedSystem.serviceProvider.getUiServiceGenerator({
|
|
97
92
|
name: this.options.data.businessObject,
|
|
98
|
-
uri: `${
|
|
93
|
+
uri: `${boUri}${this.options.data.businessObject.toLowerCase()}`
|
|
99
94
|
});
|
|
100
95
|
}
|
|
101
96
|
this.systemSelectionAnswers.connectedSystem.destination = {
|
|
@@ -103,7 +98,7 @@ class default_1 extends yeoman_generator_1.default {
|
|
|
103
98
|
};
|
|
104
99
|
}
|
|
105
100
|
catch (error) {
|
|
106
|
-
|
|
101
|
+
UiServiceGenLogger.logger.error(t('error.fetchingGenerator', { error: error.message }));
|
|
107
102
|
}
|
|
108
103
|
}
|
|
109
104
|
}
|
|
@@ -111,52 +106,51 @@ class default_1 extends yeoman_generator_1.default {
|
|
|
111
106
|
// SAP System step
|
|
112
107
|
if (!this.options.data?.systemName) {
|
|
113
108
|
// prompt system selection
|
|
114
|
-
const systemPrompts = await
|
|
109
|
+
const systemPrompts = await getSystemSelectionPrompts(...getFromCache(this.appWizard), UiServiceGenLogger.logger);
|
|
115
110
|
const systemSelectionAnswers = await this.prompt(systemPrompts.prompts);
|
|
116
111
|
Object.assign(this.answers, systemSelectionAnswers);
|
|
117
112
|
Object.assign(this.systemSelectionAnswers, systemPrompts.answers);
|
|
118
|
-
|
|
113
|
+
addToCache(this.appWizard, this.systemSelectionAnswers, this.answers);
|
|
119
114
|
}
|
|
120
115
|
// UI Service configuration step
|
|
121
|
-
|
|
116
|
+
setToolbarMessage(this.options.data, this.systemSelectionAnswers, this.appWizard);
|
|
122
117
|
// prompt service configuration
|
|
123
|
-
const configPrompts = await
|
|
124
|
-
useDraftEnabled: !(this.answers.objectType ===
|
|
125
|
-
},
|
|
118
|
+
const configPrompts = await getConfigPrompts(this.systemSelectionAnswers, {
|
|
119
|
+
useDraftEnabled: !(this.answers.objectType === ObjectType.CDS_VIEW || this.options.data?.type === BAS_OBJECT.CDS)
|
|
120
|
+
}, UiServiceGenLogger.logger);
|
|
126
121
|
const configAnswers = await this.prompt(configPrompts.prompts);
|
|
127
122
|
Object.assign(this.answers, configAnswers);
|
|
128
123
|
Object.assign(this.serviceConfigAnswers, configPrompts.answers);
|
|
129
124
|
}
|
|
130
125
|
async end() {
|
|
131
126
|
// UI Service Generation
|
|
132
|
-
this.appWizard.showWarning(
|
|
127
|
+
this.appWizard.showWarning(t('info.generatingUiService'), MessageType.prompt);
|
|
133
128
|
const transportReqNumber = this.answers.transportFromList ?? this.answers.transportManual ?? this.answers.transportCreated ?? '';
|
|
134
|
-
|
|
135
|
-
...
|
|
129
|
+
TelemetryHelper.createTelemetryData({
|
|
130
|
+
...getTelemetryData(this.answers, this.options.data)
|
|
136
131
|
});
|
|
137
|
-
|
|
138
|
-
await
|
|
132
|
+
TelemetryHelper.markAppGenStartTime();
|
|
133
|
+
await generateService(this.systemSelectionAnswers.objectGenerator, this.serviceConfigAnswers.content, transportReqNumber, this.appWizard).then(async (res) => {
|
|
139
134
|
if (res) {
|
|
140
|
-
|
|
141
|
-
|
|
135
|
+
sendTelemetry(SERVICE_GENERATION_SUCCESS, TelemetryHelper.telemetryData).catch((error) => {
|
|
136
|
+
UiServiceGenLogger.logger.error(t('error.sendingTelemetry', { error: error.message }));
|
|
142
137
|
});
|
|
143
138
|
// check if data passed from BAS service center to write BAS .service.metadata file
|
|
144
139
|
if (this.options.data?.path && this.options.data?.providerSystem) {
|
|
145
|
-
await
|
|
140
|
+
await writeBASMetadata(this.serviceConfigAnswers, this.fs, this.appWizard, this.options.data, this.systemSelectionAnswers.connectedSystem.serviceProvider);
|
|
146
141
|
}
|
|
147
142
|
else {
|
|
148
|
-
this.appWizard.showInformation(
|
|
149
|
-
|
|
150
|
-
|
|
143
|
+
this.appWizard.showInformation(t('info.generationSuccessful', { serviceName: this.serviceConfigAnswers.serviceName }), MessageType.notification);
|
|
144
|
+
UiServiceGenLogger.logger.info(`Generation of service ${this.serviceConfigAnswers.serviceName} successful`);
|
|
145
|
+
UiServiceGenLogger.logger.debug(`Generation response: ${JSON.stringify(res)}`);
|
|
151
146
|
}
|
|
152
|
-
|
|
147
|
+
UiServiceGenLogger.logger.info('Generation completed');
|
|
153
148
|
if (this.answers.launchAppGen && this.systemSelectionAnswers.connectedSystem) {
|
|
154
|
-
|
|
155
|
-
await
|
|
149
|
+
UiServiceGenLogger.logger.info('Running post generation hook');
|
|
150
|
+
await runPostGenHook(this.options, getAppGenSystemData(this.systemSelectionAnswers), this.serviceConfigAnswers.content, this.systemSelectionAnswers.connectedSystem?.serviceProvider);
|
|
156
151
|
}
|
|
157
152
|
}
|
|
158
153
|
});
|
|
159
154
|
}
|
|
160
155
|
}
|
|
161
|
-
exports.default = default_1;
|
|
162
156
|
//# sourceMappingURL=index.js.map
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { UiServiceAnswers } from '@sap-ux/ui-service-inquirer';
|
|
2
2
|
import type { TelemetryProperties } from '@sap-ux/telemetry';
|
|
3
|
-
import type { PromptOptions } from './types';
|
|
3
|
+
import type { PromptOptions } from './types.js';
|
|
4
4
|
/**
|
|
5
5
|
* Get the telemetry data for the UI Service generator event.
|
|
6
6
|
*
|
|
@@ -1,7 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getTelemetryData = getTelemetryData;
|
|
4
|
-
const ui_service_inquirer_1 = require("@sap-ux/ui-service-inquirer");
|
|
1
|
+
import { ObjectType } from '@sap-ux/ui-service-inquirer';
|
|
5
2
|
/**
|
|
6
3
|
* Get the telemetry data for the UI Service generator event.
|
|
7
4
|
*
|
|
@@ -9,7 +6,7 @@ const ui_service_inquirer_1 = require("@sap-ux/ui-service-inquirer");
|
|
|
9
6
|
* @param optionsData - the options passed to the generator
|
|
10
7
|
* @returns the telemetry data
|
|
11
8
|
*/
|
|
12
|
-
function getTelemetryData(answers, optionsData) {
|
|
9
|
+
export function getTelemetryData(answers, optionsData) {
|
|
13
10
|
let source;
|
|
14
11
|
if (optionsData?.path) {
|
|
15
12
|
source = 'Storyboard';
|
|
@@ -19,7 +16,7 @@ function getTelemetryData(answers, optionsData) {
|
|
|
19
16
|
}
|
|
20
17
|
return {
|
|
21
18
|
...(!!source && { LaunchSource: source }), // only add source if it exists, same as app gen telemetry
|
|
22
|
-
ObjectType: answers.businessObjectInterface ?
|
|
19
|
+
ObjectType: answers.businessObjectInterface ? ObjectType.BUSINESS_OBJECT : ObjectType.CDS_VIEW,
|
|
23
20
|
DraftEnabled: !!answers.draftEnabled,
|
|
24
21
|
LaunchAppGen: !!answers.launchAppGen
|
|
25
22
|
};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { AppWizard } from '@sap-devx/yeoman-ui-types';
|
|
2
2
|
import type { ProviderSystem } from '@sap/service-provider-apis';
|
|
3
3
|
import type { BusinessObjectType, CDSType } from '@sap/subaccount-destination-service-provider';
|
|
4
|
-
import type { UI_SERVICE_CACHE } from '../utils';
|
|
4
|
+
import type { UI_SERVICE_CACHE } from '../utils/index.js';
|
|
5
5
|
export interface PromptOptions {
|
|
6
6
|
systemName: string;
|
|
7
7
|
businessObject: string;
|
package/generators/app/types.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { AppWizard } from '@sap-devx/yeoman-ui-types';
|
|
2
2
|
import type { AbapServiceProvider, ServiceProvider, UiServiceGenerator } from '@sap-ux/axios-extension';
|
|
3
3
|
import type { ServiceConfig, SystemSelectionAnswers, UiServiceAnswers } from '@sap-ux/ui-service-inquirer';
|
|
4
4
|
import type { ProviderSystem, ServiceConnectivityData } from '@sap/service-provider-apis';
|
|
5
5
|
import type { Editor } from 'mem-fs-editor';
|
|
6
6
|
import type { GeneratorOptions } from 'yeoman-generator';
|
|
7
|
-
import type { AppGenSystemSystemData, PromptOptions, ReqAuth } from './types';
|
|
7
|
+
import type { AppGenSystemSystemData, PromptOptions, ReqAuth } from './types.js';
|
|
8
8
|
/**
|
|
9
9
|
* Generate the service.
|
|
10
10
|
*
|
package/generators/app/utils.js
CHANGED
|
@@ -1,30 +1,12 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
};
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
exports.getServiceMedadataContent = getServiceMedadataContent;
|
|
11
|
-
exports.runPostGenHook = runPostGenHook;
|
|
12
|
-
exports.getAppGenSystemData = getAppGenSystemData;
|
|
13
|
-
exports.authenticateInputData = authenticateInputData;
|
|
14
|
-
exports.validateConnection = validateConnection;
|
|
15
|
-
exports.checkConnection = checkConnection;
|
|
16
|
-
exports.setToolbarMessage = setToolbarMessage;
|
|
17
|
-
exports.addToCache = addToCache;
|
|
18
|
-
exports.getFromCache = getFromCache;
|
|
19
|
-
const yeoman_ui_types_1 = require("@sap-devx/yeoman-ui-types");
|
|
20
|
-
const btp_utils_1 = require("@sap-ux/btp-utils");
|
|
21
|
-
const fiori_generator_shared_1 = require("@sap-ux/fiori-generator-shared");
|
|
22
|
-
const system_access_1 = require("@sap-ux/system-access");
|
|
23
|
-
const service_provider_apis_1 = require("@sap/service-provider-apis");
|
|
24
|
-
const node_path_1 = require("node:path");
|
|
25
|
-
const utils_1 = require("../utils");
|
|
26
|
-
const i18n_1 = require("../utils/i18n");
|
|
27
|
-
const logger_1 = __importDefault(require("../utils/logger"));
|
|
1
|
+
import { MessageType } from '@sap-devx/yeoman-ui-types';
|
|
2
|
+
import { isAppStudio } from '@sap-ux/btp-utils';
|
|
3
|
+
import { sendTelemetry, TelemetryHelper } from '@sap-ux/fiori-generator-shared';
|
|
4
|
+
import { createAbapServiceProvider } from '@sap-ux/system-access';
|
|
5
|
+
import { ProviderType } from '@sap/service-provider-apis';
|
|
6
|
+
import { basename, dirname, join } from 'node:path';
|
|
7
|
+
import { SAP_NAMESPACE, SERVICE_GENERATION_FAIL, UI_SERVICE_CACHE } from '../utils/index.js';
|
|
8
|
+
import { t } from '../utils/i18n.js';
|
|
9
|
+
import UiServiceGenLogger from '../utils/logger.js';
|
|
28
10
|
/**
|
|
29
11
|
* Generate the service.
|
|
30
12
|
*
|
|
@@ -34,20 +16,20 @@ const logger_1 = __importDefault(require("../utils/logger"));
|
|
|
34
16
|
* @param appWizard - the app wizard reference
|
|
35
17
|
* @returns the generated service response
|
|
36
18
|
*/
|
|
37
|
-
async function generateService(objectGeneator, content, transportReqNumber, appWizard) {
|
|
19
|
+
export async function generateService(objectGeneator, content, transportReqNumber, appWizard) {
|
|
38
20
|
return await objectGeneator.generate(content, transportReqNumber).catch((error) => {
|
|
39
|
-
appWizard.showError(`${
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
21
|
+
appWizard.showError(`${t('error.generatingService')}`, MessageType.notification);
|
|
22
|
+
UiServiceGenLogger.logger.error(`Error generating service: ${error.message}`);
|
|
23
|
+
UiServiceGenLogger.logger.error(`${error.code} ${error.response?.status} ${error.response?.data}`);
|
|
24
|
+
UiServiceGenLogger.logger?.error(JSON.stringify(error, null, 2));
|
|
25
|
+
UiServiceGenLogger.logger?.error(JSON.stringify(error.response, null, 2));
|
|
26
|
+
TelemetryHelper.createTelemetryData({
|
|
45
27
|
ErrorMessage: error.message,
|
|
46
28
|
ErrorCode: error.code,
|
|
47
29
|
ResponseStatus: error.response?.status
|
|
48
30
|
});
|
|
49
|
-
|
|
50
|
-
|
|
31
|
+
sendTelemetry(SERVICE_GENERATION_FAIL, TelemetryHelper.telemetryData).catch((error) => {
|
|
32
|
+
UiServiceGenLogger.logger.error(`Error sending telemetry: ${error.message}`);
|
|
51
33
|
});
|
|
52
34
|
});
|
|
53
35
|
}
|
|
@@ -60,7 +42,7 @@ async function generateService(objectGeneator, content, transportReqNumber, appW
|
|
|
60
42
|
* @param inputData - the input data provider to the service generator from BAS
|
|
61
43
|
* @param provider - the service provider
|
|
62
44
|
*/
|
|
63
|
-
async function writeBASMetadata(serviceConfig, fs, appWizard, inputData, provider) {
|
|
45
|
+
export async function writeBASMetadata(serviceConfig, fs, appWizard, inputData, provider) {
|
|
64
46
|
const relativeURL = getRelativeUrlFromContent(serviceConfig.content);
|
|
65
47
|
let metadata = await getMetadata(relativeURL, provider);
|
|
66
48
|
if (!metadata) {
|
|
@@ -71,13 +53,13 @@ async function writeBASMetadata(serviceConfig, fs, appWizard, inputData, provide
|
|
|
71
53
|
if (metadata) {
|
|
72
54
|
const serviceMetadataContent = getServiceMedadataContent(inputData.providerSystem, relativeURL, metadata, JSON.parse(serviceConfig.content));
|
|
73
55
|
// path was already validated in calling function
|
|
74
|
-
fs.writeJSON(
|
|
75
|
-
appWizard.showInformation(
|
|
76
|
-
|
|
56
|
+
fs.writeJSON(join(inputData.path, '.service.metadata'), serviceMetadataContent);
|
|
57
|
+
appWizard.showInformation(t('info.generationSuccessfulWriteFile', { serviceName: serviceConfig.serviceName }), MessageType.notification);
|
|
58
|
+
UiServiceGenLogger.logger.info(t('info.generationSuccessfulWriteFile', { serviceName: serviceConfig.serviceName }));
|
|
77
59
|
}
|
|
78
60
|
else {
|
|
79
|
-
appWizard.showInformation(
|
|
80
|
-
|
|
61
|
+
appWizard.showInformation(t('info.generationSuccessfulMetadataFail', { serviceName: serviceConfig.serviceName }), MessageType.notification);
|
|
62
|
+
UiServiceGenLogger.logger.info(t('info.generationSuccessfulMetadataFail', { serviceName: serviceConfig.serviceName }));
|
|
81
63
|
}
|
|
82
64
|
}
|
|
83
65
|
/**
|
|
@@ -86,13 +68,13 @@ async function writeBASMetadata(serviceConfig, fs, appWizard, inputData, provide
|
|
|
86
68
|
* @param content - the suggested service content
|
|
87
69
|
* @returns the relative odata service URL
|
|
88
70
|
*/
|
|
89
|
-
function getRelativeUrlFromContent(content) {
|
|
71
|
+
export function getRelativeUrlFromContent(content) {
|
|
90
72
|
const contentJson = JSON.parse(content);
|
|
91
73
|
let serviceBinding = contentJson?.businessService?.serviceBinding?.serviceBindingName?.replace(/^\/|\/$/g, '');
|
|
92
74
|
let serviceDefinitionName = contentJson?.businessService?.serviceDefinition?.serviceDefinitionName?.replace(/^\/|\/$/g, '');
|
|
93
75
|
if (!contentJson.general?.namespace?.startsWith('/')) {
|
|
94
|
-
serviceBinding = `${
|
|
95
|
-
serviceDefinitionName = `${
|
|
76
|
+
serviceBinding = `${SAP_NAMESPACE}/${serviceBinding}`;
|
|
77
|
+
serviceDefinitionName = `${SAP_NAMESPACE}/${serviceDefinitionName}`;
|
|
96
78
|
}
|
|
97
79
|
return `/sap/opu/odata4/${serviceBinding}/srvd/${serviceDefinitionName}/0001/`;
|
|
98
80
|
}
|
|
@@ -104,7 +86,7 @@ function getRelativeUrlFromContent(content) {
|
|
|
104
86
|
* @param retry - whether retry should be attempted
|
|
105
87
|
* @returns the service metadata content as string
|
|
106
88
|
*/
|
|
107
|
-
async function getMetadata(relativeURL, provider, retry = false) {
|
|
89
|
+
export async function getMetadata(relativeURL, provider, retry = false) {
|
|
108
90
|
return await provider
|
|
109
91
|
.get(`${relativeURL}/$metadata`)
|
|
110
92
|
.then((res) => {
|
|
@@ -112,7 +94,7 @@ async function getMetadata(relativeURL, provider, retry = false) {
|
|
|
112
94
|
})
|
|
113
95
|
.catch((error) => {
|
|
114
96
|
if (retry) {
|
|
115
|
-
|
|
97
|
+
UiServiceGenLogger.logger.error(`Error fetching metadata for generated service: ${error.message}`);
|
|
116
98
|
}
|
|
117
99
|
return '';
|
|
118
100
|
});
|
|
@@ -126,7 +108,7 @@ async function getMetadata(relativeURL, provider, retry = false) {
|
|
|
126
108
|
* @param contentJson - the suggested service content as JSON
|
|
127
109
|
* @returns the service connectivity data object in form of .service.metadata file
|
|
128
110
|
*/
|
|
129
|
-
function getServiceMedadataContent(providerSystem, relativeURL, metadata, contentJson) {
|
|
111
|
+
export function getServiceMedadataContent(providerSystem, relativeURL, metadata, contentJson) {
|
|
130
112
|
return {
|
|
131
113
|
providerSystem: providerSystem,
|
|
132
114
|
relativeURL: relativeURL,
|
|
@@ -134,7 +116,7 @@ function getServiceMedadataContent(providerSystem, relativeURL, metadata, conten
|
|
|
134
116
|
odataContent: metadata
|
|
135
117
|
},
|
|
136
118
|
serviceName: contentJson.businessService.serviceBinding.serviceBindingName,
|
|
137
|
-
providerType:
|
|
119
|
+
providerType: ProviderType.SapSystem
|
|
138
120
|
};
|
|
139
121
|
}
|
|
140
122
|
/**
|
|
@@ -145,7 +127,7 @@ function getServiceMedadataContent(providerSystem, relativeURL, metadata, conten
|
|
|
145
127
|
* @param content - the suggested service content
|
|
146
128
|
* @param provider - the service provider
|
|
147
129
|
*/
|
|
148
|
-
async function runPostGenHook(options, systemData, content, provider) {
|
|
130
|
+
export async function runPostGenHook(options, systemData, content, provider) {
|
|
149
131
|
const relativeUrl = getRelativeUrlFromContent(content);
|
|
150
132
|
const appGenData = {
|
|
151
133
|
type: 'SERVICE_GEN_DATA',
|
|
@@ -158,12 +140,12 @@ async function runPostGenHook(options, systemData, content, provider) {
|
|
|
158
140
|
if (options.data?.path) {
|
|
159
141
|
Object.assign(appGenData, {
|
|
160
142
|
project: {
|
|
161
|
-
targetPath:
|
|
162
|
-
name:
|
|
143
|
+
targetPath: dirname(options.data?.path),
|
|
144
|
+
name: basename(options.data?.path)
|
|
163
145
|
}
|
|
164
146
|
});
|
|
165
147
|
}
|
|
166
|
-
|
|
148
|
+
UiServiceGenLogger.logger.info(`Launching App Generator with data: ${JSON.stringify(appGenData)} and command ${options.data?.appGenLaunchCommand}`);
|
|
167
149
|
setTimeout(() => {
|
|
168
150
|
options.vscode?.commands?.executeCommand?.(options.data?.appGenLaunchCommand ?? 'sap.ux.service.generated.handler', appGenData);
|
|
169
151
|
}, 500);
|
|
@@ -174,8 +156,8 @@ async function runPostGenHook(options, systemData, content, provider) {
|
|
|
174
156
|
* @param system - the system selection answers
|
|
175
157
|
* @returns the system data to be passed to the application generator
|
|
176
158
|
*/
|
|
177
|
-
function getAppGenSystemData(system) {
|
|
178
|
-
return
|
|
159
|
+
export function getAppGenSystemData(system) {
|
|
160
|
+
return isAppStudio()
|
|
179
161
|
? { destination: system.connectedSystem?.destination?.Name ?? '' }
|
|
180
162
|
: {
|
|
181
163
|
name: system.connectedSystem?.backendSystem?.name ?? '',
|
|
@@ -189,7 +171,7 @@ function getAppGenSystemData(system) {
|
|
|
189
171
|
* @param data - the input data from BAS Service Center
|
|
190
172
|
* @param system - the system selection answers
|
|
191
173
|
*/
|
|
192
|
-
async function authenticateInputData(data, system) {
|
|
174
|
+
export async function authenticateInputData(data, system) {
|
|
193
175
|
const reqAuth = data.user && data.password ? { username: data.user, password: data.password } : undefined;
|
|
194
176
|
await validateConnection(data.systemName, system, reqAuth);
|
|
195
177
|
}
|
|
@@ -200,11 +182,11 @@ async function authenticateInputData(data, system) {
|
|
|
200
182
|
* @param system - the system selection answers
|
|
201
183
|
* @param reqAuth - the auth, user and password, provided by BAS Service Center
|
|
202
184
|
*/
|
|
203
|
-
async function validateConnection(systemName, system, reqAuth) {
|
|
185
|
+
export async function validateConnection(systemName, system, reqAuth) {
|
|
204
186
|
const target = {
|
|
205
187
|
destination: systemName
|
|
206
188
|
};
|
|
207
|
-
const provider = (await
|
|
189
|
+
const provider = (await createAbapServiceProvider(target, { ignoreCertErrors: true, auth: reqAuth }, false, UiServiceGenLogger.logger));
|
|
208
190
|
try {
|
|
209
191
|
await checkConnection(provider);
|
|
210
192
|
Object.assign(system, {
|
|
@@ -218,7 +200,7 @@ async function validateConnection(systemName, system, reqAuth) {
|
|
|
218
200
|
return;
|
|
219
201
|
}
|
|
220
202
|
catch (e) {
|
|
221
|
-
|
|
203
|
+
UiServiceGenLogger.logger.error(t('error.connectionFailed', { system: systemName }));
|
|
222
204
|
return;
|
|
223
205
|
}
|
|
224
206
|
}
|
|
@@ -228,7 +210,7 @@ async function validateConnection(systemName, system, reqAuth) {
|
|
|
228
210
|
* @param provider - the service provider
|
|
229
211
|
* @returns whether the connection is successful
|
|
230
212
|
*/
|
|
231
|
-
async function checkConnection(provider) {
|
|
213
|
+
export async function checkConnection(provider) {
|
|
232
214
|
try {
|
|
233
215
|
await provider.get('/sap/bc/adt/discovery', {
|
|
234
216
|
headers: {
|
|
@@ -248,17 +230,17 @@ async function checkConnection(provider) {
|
|
|
248
230
|
* @param systemSelectionAnswers - the system selection answers
|
|
249
231
|
* @param appWizard - the app wizard reference
|
|
250
232
|
*/
|
|
251
|
-
function setToolbarMessage(data, systemSelectionAnswers, appWizard) {
|
|
233
|
+
export function setToolbarMessage(data, systemSelectionAnswers, appWizard) {
|
|
252
234
|
if (data?.systemName && !systemSelectionAnswers.connectedSystem?.serviceProvider) {
|
|
253
235
|
// Could not authenticate with the system provided in the input data
|
|
254
|
-
appWizard.showError(
|
|
236
|
+
appWizard.showError(t('error.authentication'), MessageType.prompt);
|
|
255
237
|
}
|
|
256
238
|
else if (data?.systemName && !systemSelectionAnswers.objectGenerator) {
|
|
257
239
|
// Could not fetch the generator for the business object provided in the input data
|
|
258
|
-
appWizard.showError(
|
|
240
|
+
appWizard.showError(t('error.noGeneratorFoundBo'), MessageType.prompt);
|
|
259
241
|
}
|
|
260
242
|
else {
|
|
261
|
-
appWizard.showWarning(
|
|
243
|
+
appWizard.showWarning(t('info.generationWarning'), MessageType.prompt);
|
|
262
244
|
}
|
|
263
245
|
}
|
|
264
246
|
/**
|
|
@@ -268,9 +250,9 @@ function setToolbarMessage(data, systemSelectionAnswers, appWizard) {
|
|
|
268
250
|
* @param systemSelectionAnswers - the system selection answers
|
|
269
251
|
* @param objectAnswers - the remaining prompt answers from system selection step
|
|
270
252
|
*/
|
|
271
|
-
function addToCache(appWizard, systemSelectionAnswers, objectAnswers) {
|
|
272
|
-
if (appWizard[
|
|
273
|
-
Object.assign(appWizard[
|
|
253
|
+
export function addToCache(appWizard, systemSelectionAnswers, objectAnswers) {
|
|
254
|
+
if (appWizard[UI_SERVICE_CACHE]) {
|
|
255
|
+
Object.assign(appWizard[UI_SERVICE_CACHE], {
|
|
274
256
|
systemSelectionAnswers: objectAnswers,
|
|
275
257
|
systemName: systemSelectionAnswers.connectedSystem?.destination?.Name ??
|
|
276
258
|
systemSelectionAnswers.connectedSystem?.backendSystem?.name
|
|
@@ -283,10 +265,10 @@ function addToCache(appWizard, systemSelectionAnswers, objectAnswers) {
|
|
|
283
265
|
* @param appWizard - the app wizard reference
|
|
284
266
|
* @returns the system selection answers and system name
|
|
285
267
|
*/
|
|
286
|
-
function getFromCache(appWizard) {
|
|
268
|
+
export function getFromCache(appWizard) {
|
|
287
269
|
return [
|
|
288
|
-
appWizard[
|
|
289
|
-
appWizard[
|
|
270
|
+
appWizard[UI_SERVICE_CACHE].systemSelectionAnswers,
|
|
271
|
+
appWizard[UI_SERVICE_CACHE].systemName
|
|
290
272
|
];
|
|
291
273
|
}
|
|
292
274
|
//# sourceMappingURL=utils.js.map
|
|
@@ -1,21 +1,18 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
exports.STEP_SAP_SYSTEM_CONFIG = 'SAP_SYSTEM_CONFIG';
|
|
5
|
-
exports.STEP_SERVICE_CONFIG = 'SERVICE_CONFIG';
|
|
6
|
-
exports.prompts = [
|
|
1
|
+
export const STEP_SAP_SYSTEM_CONFIG = 'SAP_SYSTEM_CONFIG';
|
|
2
|
+
export const STEP_SERVICE_CONFIG = 'SERVICE_CONFIG';
|
|
3
|
+
export const prompts = [
|
|
7
4
|
{
|
|
8
|
-
key:
|
|
5
|
+
key: STEP_SAP_SYSTEM_CONFIG,
|
|
9
6
|
name: 'SAP System selection',
|
|
10
7
|
description: '',
|
|
11
8
|
order: 0
|
|
12
9
|
},
|
|
13
|
-
{ key:
|
|
10
|
+
{ key: STEP_SERVICE_CONFIG, name: 'UI Service Configuration', description: '', order: 1 }
|
|
14
11
|
];
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
12
|
+
export const boUri = '/sap/bc/adt/bo/behaviordefinitions/';
|
|
13
|
+
export const cdsUri = '/sap/bc/adt/ddic/ddl/sources/';
|
|
14
|
+
export const UI_SERVICE_CACHE = '$ui-service-cache';
|
|
15
|
+
export const SERVICE_GENERATION_SUCCESS = 'SERVICE_GENERATION_SUCCESS';
|
|
16
|
+
export const SERVICE_GENERATION_FAIL = 'SERVICE_GENERATION_FAIL';
|
|
17
|
+
export const SAP_NAMESPACE = 'sap';
|
|
21
18
|
//# sourceMappingURL=constants.js.map
|
package/generators/utils/i18n.js
CHANGED
|
@@ -1,22 +1,14 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.i18n = void 0;
|
|
7
|
-
exports.initI18n = initI18n;
|
|
8
|
-
exports.t = t;
|
|
9
|
-
const i18next_1 = __importDefault(require("i18next"));
|
|
10
|
-
const ui_service_generator_i18n_json_1 = __importDefault(require("../translations/ui-service-generator.i18n.json"));
|
|
1
|
+
import i18next from 'i18next';
|
|
2
|
+
import translations from '../translations/ui-service-generator.i18n.json' with { type: 'json' };
|
|
11
3
|
const uiServiceGeneratorNs = 'ui-service-generator';
|
|
12
|
-
|
|
13
|
-
async function initI18n() {
|
|
14
|
-
await
|
|
4
|
+
export const i18n = i18next.createInstance();
|
|
5
|
+
export async function initI18n() {
|
|
6
|
+
await i18n.init({
|
|
15
7
|
lng: 'en',
|
|
16
8
|
fallbackLng: 'en',
|
|
17
9
|
showSupportNotice: false
|
|
18
10
|
});
|
|
19
|
-
|
|
11
|
+
i18n.addResourceBundle('en', uiServiceGeneratorNs, translations);
|
|
20
12
|
}
|
|
21
13
|
/**
|
|
22
14
|
* Helper function facading the call to i18next. Unless a namespace option is provided the local namespace will be used.
|
|
@@ -25,13 +17,11 @@ async function initI18n() {
|
|
|
25
17
|
* @param options additional options
|
|
26
18
|
* @returns {string} localized string stored for the given key
|
|
27
19
|
*/
|
|
28
|
-
function t(key, options) {
|
|
20
|
+
export function t(key, options) {
|
|
29
21
|
if (!options?.ns) {
|
|
30
22
|
options = Object.assign(options ?? {}, { ns: uiServiceGeneratorNs });
|
|
31
23
|
}
|
|
32
|
-
return
|
|
24
|
+
return i18n.t(key, options);
|
|
33
25
|
}
|
|
34
|
-
initI18n().catch(() =>
|
|
35
|
-
// Needed for lint
|
|
36
|
-
});
|
|
26
|
+
void initI18n().catch(() => undefined);
|
|
37
27
|
//# sourceMappingURL=i18n.js.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export * from './constants';
|
|
2
|
-
export * from './logger';
|
|
3
|
-
export * from './i18n';
|
|
1
|
+
export * from './constants.js';
|
|
2
|
+
export * from './logger.js';
|
|
3
|
+
export * from './i18n.js';
|
|
4
4
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1,20 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
-
};
|
|
16
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
__exportStar(require("./constants"), exports);
|
|
18
|
-
__exportStar(require("./logger"), exports);
|
|
19
|
-
__exportStar(require("./i18n"), exports);
|
|
1
|
+
export * from './constants.js';
|
|
2
|
+
export * from './logger.js';
|
|
3
|
+
export * from './i18n.js';
|
|
20
4
|
//# sourceMappingURL=index.js.map
|
|
@@ -1,11 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const fiori_generator_shared_1 = require("@sap-ux/fiori-generator-shared");
|
|
1
|
+
import { DefaultLogger, LogWrapper } from '@sap-ux/fiori-generator-shared';
|
|
4
2
|
/**
|
|
5
3
|
* Static logger prevents passing of logger references through all functions, as this is a cross-cutting concern.
|
|
6
4
|
*/
|
|
7
|
-
class UiServiceGenLogger {
|
|
8
|
-
static _logger =
|
|
5
|
+
export default class UiServiceGenLogger {
|
|
6
|
+
static _logger = DefaultLogger;
|
|
9
7
|
/**
|
|
10
8
|
* Get the logger.
|
|
11
9
|
*
|
|
@@ -32,9 +30,8 @@ class UiServiceGenLogger {
|
|
|
32
30
|
* @param logLevel - the log level
|
|
33
31
|
*/
|
|
34
32
|
static configureLogging(vscLogger, loggerName, yoLogger, vscode, logLevel) {
|
|
35
|
-
const logWrapper = new
|
|
33
|
+
const logWrapper = new LogWrapper(loggerName, yoLogger, logLevel, vscLogger, vscode);
|
|
36
34
|
UiServiceGenLogger.logger = logWrapper;
|
|
37
35
|
}
|
|
38
36
|
}
|
|
39
|
-
exports.default = UiServiceGenLogger;
|
|
40
37
|
//# sourceMappingURL=logger.js.map
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sap-ux/ui-service-sub-generator",
|
|
3
3
|
"description": "Generator for creating UI Service",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "1.0.0",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
7
7
|
"url": "https://github.com/SAP/open-ux-tools.git",
|
|
@@ -10,6 +10,7 @@
|
|
|
10
10
|
"bugs": {
|
|
11
11
|
"url": "https://github.com/SAP/open-ux-tools/issues?q=is%3Aopen+is%3Aissue"
|
|
12
12
|
},
|
|
13
|
+
"type": "module",
|
|
13
14
|
"license": "Apache-2.0",
|
|
14
15
|
"main": "generators/app/index.js",
|
|
15
16
|
"files": [
|
|
@@ -22,17 +23,18 @@
|
|
|
22
23
|
"@sap-devx/yeoman-ui-types": "1.25.0",
|
|
23
24
|
"i18next": "25.10.10",
|
|
24
25
|
"yeoman-generator": "5.10.0",
|
|
25
|
-
"@sap-ux/axios-extension": "
|
|
26
|
-
"@sap-ux/btp-utils": "
|
|
27
|
-
"@sap-ux/feature-toggle": "0.
|
|
28
|
-
"@sap-ux/fiori-generator-shared": "0.
|
|
29
|
-
"@sap-ux/inquirer-common": "0.
|
|
30
|
-
"@sap-ux/logger": "0.
|
|
31
|
-
"@sap-ux/system-access": "0.
|
|
32
|
-
"@sap-ux/telemetry": "0.
|
|
33
|
-
"@sap-ux/ui-service-inquirer": "0.
|
|
26
|
+
"@sap-ux/axios-extension": "2.0.0",
|
|
27
|
+
"@sap-ux/btp-utils": "2.0.0",
|
|
28
|
+
"@sap-ux/feature-toggle": "1.0.0",
|
|
29
|
+
"@sap-ux/fiori-generator-shared": "1.0.0",
|
|
30
|
+
"@sap-ux/inquirer-common": "1.0.0",
|
|
31
|
+
"@sap-ux/logger": "1.0.0",
|
|
32
|
+
"@sap-ux/system-access": "1.0.0",
|
|
33
|
+
"@sap-ux/telemetry": "1.0.0",
|
|
34
|
+
"@sap-ux/ui-service-inquirer": "1.0.0"
|
|
34
35
|
},
|
|
35
36
|
"devDependencies": {
|
|
37
|
+
"@jest/globals": "30.3.0",
|
|
36
38
|
"@sap/service-provider-apis": "2.10.0",
|
|
37
39
|
"@sap/subaccount-destination-service-provider": "2.16.0",
|
|
38
40
|
"@types/mem-fs": "1.1.2",
|
|
@@ -47,8 +49,8 @@
|
|
|
47
49
|
"rimraf": "6.1.3",
|
|
48
50
|
"yeoman-environment": "3.19.3",
|
|
49
51
|
"yeoman-test": "6.3.0",
|
|
50
|
-
"@sap-ux/jest-file-matchers": "0.
|
|
51
|
-
"@sap-ux/store": "
|
|
52
|
+
"@sap-ux/jest-file-matchers": "1.0.0",
|
|
53
|
+
"@sap-ux/store": "2.0.0"
|
|
52
54
|
},
|
|
53
55
|
"engines": {
|
|
54
56
|
"node": ">=22.x"
|
|
@@ -59,8 +61,8 @@
|
|
|
59
61
|
"watch": "tsc --watch",
|
|
60
62
|
"lint": "eslint",
|
|
61
63
|
"lint:fix": "eslint --fix",
|
|
62
|
-
"test": "jest --ci --forceExit --detectOpenHandles --colors",
|
|
63
|
-
"test-u": "jest --ci --forceExit --detectOpenHandles --colors -u",
|
|
64
|
+
"test": "cross-env NODE_OPTIONS='--experimental-vm-modules' jest --ci --forceExit --detectOpenHandles --colors",
|
|
65
|
+
"test-u": "cross-env NODE_OPTIONS='--experimental-vm-modules' jest --ci --forceExit --detectOpenHandles --colors -u",
|
|
64
66
|
"link": "pnpm link --global",
|
|
65
67
|
"unlink": "pnpm unlink --global"
|
|
66
68
|
}
|