@sap-ux/ui-service-sub-generator 0.0.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/LICENSE ADDED
@@ -0,0 +1,201 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "[]"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright [yyyy] [name of copyright owner]
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.
package/README.md ADDED
@@ -0,0 +1,16 @@
1
+ # @sap-ux/ui-service-sub-generator
2
+
3
+ ## Features
4
+
5
+ The SAP UI Service sub-generator enables users to create a new ui service that can be used in SAP Fiori applications
6
+
7
+ ## Installation
8
+
9
+ The SAP UI Service sub-generator is installed as part of the [@sap/generator-fiori](https://www.npmjs.com/package/@sap/generator-fiori) generator and cannot be used stand alone. Furthermore, usage requires that the [SAP Fiori Tools Extension](https://marketplace.visualstudio.com/items?itemName=SAPSE.sap-ux-fiori-tools-extension-pack) pack is installed from the VSCode marketplace.
10
+
11
+ ## Launch the SAP Reuse Library sub-generator
12
+
13
+ Open the Command Palette in MS Visual Studio Code ( CMD/CTRL + Shift + P ) and execute the Fiori: Generate UI Service command.
14
+
15
+ ## Keywords
16
+ SAP Fiori Generator
@@ -0,0 +1,29 @@
1
+ import { AppWizard, Prompts } from '@sap-devx/yeoman-ui-types';
2
+ import type { ServiceConfig, SystemSelectionAnswers, UiServiceAnswers } from '@sap-ux/ui-service-inquirer';
3
+ import Generator from 'yeoman-generator';
4
+ /**
5
+ * Generator for creating a new UI Service.
6
+ *
7
+ * @extends Generator
8
+ */
9
+ export default class extends Generator {
10
+ answers: UiServiceAnswers;
11
+ prompts: Prompts;
12
+ appWizard: AppWizard;
13
+ vscode: unknown;
14
+ systemSelectionAnswers: SystemSelectionAnswers;
15
+ serviceConfigAnswers: ServiceConfig;
16
+ setPromptsCallback: (fn: any) => void;
17
+ /**
18
+ * Constructor for the generator.
19
+ *
20
+ * @param args - arguments passed to the generator
21
+ * @param opts - options passed to the generator
22
+ */
23
+ constructor(args: string | string[], opts: Generator.GeneratorOptions);
24
+ initializing(): Promise<void>;
25
+ private _initSteps;
26
+ prompting(): Promise<void>;
27
+ end(): Promise<void>;
28
+ }
29
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1,161 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ const yeoman_ui_types_1 = require("@sap-devx/yeoman-ui-types");
7
+ const feature_toggle_1 = require("@sap-ux/feature-toggle");
8
+ const fiori_generator_shared_1 = require("@sap-ux/fiori-generator-shared");
9
+ const ui_service_inquirer_1 = require("@sap-ux/ui-service-inquirer");
10
+ const yeoman_generator_1 = __importDefault(require("yeoman-generator"));
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");
16
+ /**
17
+ * Generator for creating a new UI Service.
18
+ *
19
+ * @extends Generator
20
+ */
21
+ class default_1 extends yeoman_generator_1.default {
22
+ answers = {
23
+ url: '',
24
+ package: ''
25
+ };
26
+ prompts;
27
+ appWizard;
28
+ vscode;
29
+ systemSelectionAnswers = {};
30
+ serviceConfigAnswers = {
31
+ content: '',
32
+ serviceName: ''
33
+ };
34
+ setPromptsCallback;
35
+ /**
36
+ * Constructor for the generator.
37
+ *
38
+ * @param args - arguments passed to the generator
39
+ * @param opts - options passed to the generator
40
+ */
41
+ constructor(args, opts) {
42
+ super(args, opts);
43
+ if (this.env.conflicter) {
44
+ this.env.conflicter.force = true;
45
+ }
46
+ this.appWizard = yeoman_ui_types_1.AppWizard.create(opts);
47
+ this.vscode = opts.vscode;
48
+ logger_1.default.configureLogging(this.options.logger, this.rootGeneratorName(), this.log, this.options.vscode, this.options.logLevel);
49
+ const steps = utils_1.prompts;
50
+ // if options.data is present, skip the first step
51
+ // options.data is passeed from BAS service center
52
+ if (this.options.data?.systemName) {
53
+ steps.shift();
54
+ }
55
+ this.appWizard = yeoman_ui_types_1.AppWizard.create(opts);
56
+ if (!this.appWizard[utils_1.UI_SERVICE_CACHE]) {
57
+ this.appWizard[utils_1.UI_SERVICE_CACHE] = {};
58
+ }
59
+ this.appWizard.setHeaderTitle('UI Service Generator');
60
+ this.prompts = new yeoman_ui_types_1.Prompts(steps);
61
+ this.setPromptsCallback = (fn) => {
62
+ if (this.prompts) {
63
+ this.prompts.setCallback(fn);
64
+ }
65
+ };
66
+ }
67
+ async initializing() {
68
+ await fiori_generator_shared_1.TelemetryHelper.initTelemetrySettings({
69
+ consumerModule: {
70
+ name: '@sap/generator-fiori-ui-service',
71
+ version: this.rootGeneratorVersion()
72
+ },
73
+ internalFeature: (0, feature_toggle_1.isInternalFeaturesSettingEnabled)(),
74
+ watchTelemetrySettingStore: false
75
+ });
76
+ await (0, utils_1.initI18n)();
77
+ if (this.options.data?.systemName) {
78
+ logger_1.default.logger.debug('Options passed into generator: ' + JSON.stringify(this.options.data));
79
+ await this._initSteps();
80
+ }
81
+ }
82
+ async _initSteps() {
83
+ await (0, utils_2.authenticateInputData)(this.options.data, this.systemSelectionAnswers);
84
+ if (this.systemSelectionAnswers.connectedSystem?.serviceProvider) {
85
+ try {
86
+ if (this.options.data.id && this.options.data.type) {
87
+ // new BAS service center data interface, for BO and CDS
88
+ const objectUri = this.options.data.type === types_1.BAS_OBJECT.BUSINESS_OBJECT ? utils_1.boUri : utils_1.cdsUri;
89
+ this.systemSelectionAnswers.objectGenerator = await this.systemSelectionAnswers.connectedSystem.serviceProvider.getUiServiceGenerator({
90
+ name: this.options.data.id,
91
+ uri: `${objectUri}${this.options.data.id.toLowerCase()}`
92
+ });
93
+ }
94
+ else {
95
+ // old interface, for BO only
96
+ // to be removed once BAS release new interface
97
+ this.systemSelectionAnswers.objectGenerator = await this.systemSelectionAnswers.connectedSystem.serviceProvider.getUiServiceGenerator({
98
+ name: this.options.data.businessObject,
99
+ uri: `${utils_1.boUri}${this.options.data.businessObject.toLowerCase()}`
100
+ });
101
+ }
102
+ this.systemSelectionAnswers.connectedSystem.destination = {
103
+ Name: this.options.data.systemName
104
+ };
105
+ }
106
+ catch (error) {
107
+ logger_1.default.logger.error((0, utils_1.t)('error.fetchingGenerator', { error: error.message }));
108
+ }
109
+ }
110
+ }
111
+ async prompting() {
112
+ // SAP System step
113
+ if (!this.options.data?.systemName) {
114
+ // prompt system selection
115
+ const systemPrompts = await (0, ui_service_inquirer_1.getSystemSelectionPrompts)(...(0, utils_2.getFromCache)(this.appWizard), logger_1.default.logger);
116
+ const systemSelectionAnswers = await this.prompt(systemPrompts.prompts);
117
+ Object.assign(this.answers, systemSelectionAnswers);
118
+ Object.assign(this.systemSelectionAnswers, systemPrompts.answers);
119
+ (0, utils_2.addToCache)(this.appWizard, this.systemSelectionAnswers, this.answers);
120
+ }
121
+ // UI Service configuration step
122
+ (0, utils_2.setToolbarMessage)(this.options.data, this.systemSelectionAnswers, this.appWizard);
123
+ // prompt service configuration
124
+ const configPrompts = await (0, ui_service_inquirer_1.getConfigPrompts)(this.systemSelectionAnswers, logger_1.default.logger);
125
+ const configAnswers = await this.prompt(configPrompts.prompts);
126
+ Object.assign(this.answers, configAnswers);
127
+ Object.assign(this.serviceConfigAnswers, configPrompts.answers);
128
+ }
129
+ async end() {
130
+ // UI Service Generation
131
+ this.appWizard.showWarning((0, utils_1.t)('info.generatingUiService'), yeoman_ui_types_1.MessageType.prompt);
132
+ const transportReqNumber = this.answers.transportFromList ?? this.answers.transportManual ?? this.answers.transportCreated ?? '';
133
+ fiori_generator_shared_1.TelemetryHelper.createTelemetryData({
134
+ ...(0, telemetryHelper_1.getTelemetryData)(this.answers, this.options.data)
135
+ });
136
+ fiori_generator_shared_1.TelemetryHelper.markAppGenStartTime();
137
+ await (0, utils_2.generateService)(this.systemSelectionAnswers.objectGenerator, this.serviceConfigAnswers.content, transportReqNumber, this.appWizard).then(async (res) => {
138
+ if (res) {
139
+ (0, fiori_generator_shared_1.sendTelemetry)(utils_1.SERVICE_GENERATION_SUCCESS, fiori_generator_shared_1.TelemetryHelper.telemetryData).catch((error) => {
140
+ logger_1.default.logger.error((0, utils_1.t)('error.sendingTelemetry', { error: error.message }));
141
+ });
142
+ // check if data passed from BAS service center to write BAS .service.metadata file
143
+ if (this.options.data?.path && this.options.data?.providerSystem) {
144
+ await (0, utils_2.writeBASMetadata)(this.serviceConfigAnswers, this.fs, this.appWizard, this.options.data, this.systemSelectionAnswers.connectedSystem.serviceProvider);
145
+ }
146
+ else {
147
+ this.appWizard.showInformation((0, utils_1.t)('info.generationSuccessful', { serviceName: this.serviceConfigAnswers.serviceName }), yeoman_ui_types_1.MessageType.notification);
148
+ logger_1.default.logger.info(`Generation of service ${this.serviceConfigAnswers.serviceName} successful`);
149
+ logger_1.default.logger.debug(`Generation response: ${JSON.stringify(res)}`);
150
+ }
151
+ logger_1.default.logger.info('Generation completed');
152
+ if (this.answers.launchAppGen && this.systemSelectionAnswers.connectedSystem) {
153
+ logger_1.default.logger.info('Running post generation hook');
154
+ await (0, utils_2.runPostGenHook)(this.options, (0, utils_2.getAppGenSystemData)(this.systemSelectionAnswers), this.serviceConfigAnswers.content, this.systemSelectionAnswers.connectedSystem?.serviceProvider);
155
+ }
156
+ }
157
+ });
158
+ }
159
+ }
160
+ exports.default = default_1;
161
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1,12 @@
1
+ import type { UiServiceAnswers } from '@sap-ux/ui-service-inquirer';
2
+ import type { TelemetryProperties } from '@sap-ux/telemetry';
3
+ import type { PromptOptions } from './types';
4
+ /**
5
+ * Get the telemetry data for the UI Service generator event.
6
+ *
7
+ * @param answers - the answers to the UI Service prompts
8
+ * @param optionsData - the options passed to the generator
9
+ * @returns the telemetry data
10
+ */
11
+ export declare function getTelemetryData(answers: UiServiceAnswers, optionsData?: PromptOptions): TelemetryProperties;
12
+ //# sourceMappingURL=telemetryHelper.d.ts.map
@@ -0,0 +1,28 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getTelemetryData = void 0;
4
+ const ui_service_inquirer_1 = require("@sap-ux/ui-service-inquirer");
5
+ /**
6
+ * Get the telemetry data for the UI Service generator event.
7
+ *
8
+ * @param answers - the answers to the UI Service prompts
9
+ * @param optionsData - the options passed to the generator
10
+ * @returns the telemetry data
11
+ */
12
+ function getTelemetryData(answers, optionsData) {
13
+ let source;
14
+ if (optionsData?.path) {
15
+ source = 'Storyboard';
16
+ }
17
+ else if (optionsData?.providerSystem) {
18
+ source = 'ServiceCenter';
19
+ }
20
+ return {
21
+ ...(!!source && { LaunchSource: source }), // only add source if it exists, same as app gen telemetry
22
+ ObjectType: answers.businessObjectInterface ? ui_service_inquirer_1.ObjectType.BUSINESS_OBJECT : ui_service_inquirer_1.ObjectType.CDS_VIEW,
23
+ DraftEnabled: !!answers.draftEnabled,
24
+ LaunchAppGen: !!answers.launchAppGen
25
+ };
26
+ }
27
+ exports.getTelemetryData = getTelemetryData;
28
+ //# sourceMappingURL=telemetryHelper.js.map
@@ -0,0 +1,44 @@
1
+ import type { AppWizard } from '@sap-devx/yeoman-ui-types';
2
+ import type { ProviderSystem } from '@sap/service-provider-apis';
3
+ import type { BusinessObjectType, CDSType } from '@sap/subaccount-destination-service-provider';
4
+ import type { UI_SERVICE_CACHE } from '../utils';
5
+ export interface PromptOptions {
6
+ systemName: string;
7
+ businessObject: string;
8
+ path?: string;
9
+ user?: string;
10
+ password?: string;
11
+ providerSystem?: ProviderSystem;
12
+ type?: BusinessObjectType | CDSType;
13
+ id?: string;
14
+ }
15
+ export type AppGenSystemSystemData = {
16
+ name?: string;
17
+ url?: string;
18
+ client?: string;
19
+ destination?: string;
20
+ };
21
+ export interface AppGenData {
22
+ type: string;
23
+ system: AppGenSystemSystemData;
24
+ service: {
25
+ url: string;
26
+ metadata: string;
27
+ };
28
+ project?: {
29
+ targetPath: string;
30
+ name: string;
31
+ };
32
+ }
33
+ export type ReqAuth = {
34
+ username: string;
35
+ password: string;
36
+ };
37
+ export declare const BAS_OBJECT: {
38
+ BUSINESS_OBJECT: "BO INTERFACE";
39
+ CDS: "CDS VIEW";
40
+ };
41
+ export interface AppWizardWithCache extends AppWizard {
42
+ [UI_SERVICE_CACHE]?: any;
43
+ }
44
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1,8 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.BAS_OBJECT = void 0;
4
+ exports.BAS_OBJECT = {
5
+ BUSINESS_OBJECT: 'BO INTERFACE',
6
+ CDS: 'CDS VIEW'
7
+ };
8
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1,115 @@
1
+ import { type AppWizard } from '@sap-devx/yeoman-ui-types';
2
+ import type { AbapServiceProvider, ServiceProvider, UiServiceGenerator } from '@sap-ux/axios-extension';
3
+ import type { ServiceConfig, SystemSelectionAnswers, UiServiceAnswers } from '@sap-ux/ui-service-inquirer';
4
+ import type { ProviderSystem, ServiceConnectivityData } from '@sap/service-provider-apis';
5
+ import type { Editor } from 'mem-fs-editor';
6
+ import type { GeneratorOptions } from 'yeoman-generator';
7
+ import type { AppGenSystemSystemData, PromptOptions, ReqAuth } from './types';
8
+ /**
9
+ * Generate the service.
10
+ *
11
+ * @param objectGeneator - the backend object generator for the object type
12
+ * @param content - the suggested content used to generate the service
13
+ * @param transportReqNumber - the transport request number
14
+ * @param appWizard - the app wizard reference
15
+ * @returns the generated service response
16
+ */
17
+ export declare function generateService(objectGeneator: UiServiceGenerator, content: string, transportReqNumber: string, appWizard: AppWizard): Promise<unknown>;
18
+ /**
19
+ * Write the service metadata file into the BAS Storyboard project.
20
+ *
21
+ * @param serviceConfig - the service name and content object
22
+ * @param fs - the file system
23
+ * @param appWizard - the app wizard reference
24
+ * @param inputData - the input data provider to the service generator from BAS
25
+ * @param provider - the service provider
26
+ */
27
+ export declare function writeBASMetadata(serviceConfig: ServiceConfig, fs: Editor, appWizard: AppWizard, inputData: PromptOptions, provider: ServiceProvider): Promise<void>;
28
+ /**
29
+ * Get the relative URL from the service content.
30
+ *
31
+ * @param content - the suggested service content
32
+ * @returns the relative odata service URL
33
+ */
34
+ export declare function getRelativeUrlFromContent(content: string): string;
35
+ /**
36
+ * Get the metadata for the service url provided. Has a 5 second retry if the metadata is not fetched on first attempt.
37
+ *
38
+ * @param relativeURL - the relative URL of the service
39
+ * @param provider - the service provider
40
+ * @param retry - whether retry should be attempted
41
+ * @returns the service metadata content as string
42
+ */
43
+ export declare function getMetadata(relativeURL: string, provider: ServiceProvider, retry?: boolean): Promise<string>;
44
+ /**
45
+ * Get the service metadata content to be written to the .service.metadata file.
46
+ *
47
+ * @param providerSystem - the provider system
48
+ * @param relativeURL - the relative URL of the service
49
+ * @param metadata - the metadata content
50
+ * @param contentJson - the suggested service content as JSON
51
+ * @returns the service connectivity data object in form of .service.metadata file
52
+ */
53
+ export declare function getServiceMedadataContent(providerSystem: ProviderSystem, relativeURL: string, metadata: string, contentJson: any): ServiceConnectivityData;
54
+ /**
55
+ * Run the post generation hook to open the application generator via command with specific payload.
56
+ *
57
+ * @param options - options passed to the generator
58
+ * @param systemData - the system data
59
+ * @param content - the suggested service content
60
+ * @param provider - the service provider
61
+ */
62
+ export declare function runPostGenHook(options: GeneratorOptions, systemData: AppGenSystemSystemData, content: string, provider: ServiceProvider): Promise<void>;
63
+ /**
64
+ * Get the system data for the application generator.
65
+ *
66
+ * @param system - the system selection answers
67
+ * @returns the system data to be passed to the application generator
68
+ */
69
+ export declare function getAppGenSystemData(system: SystemSelectionAnswers): AppGenSystemSystemData;
70
+ /**
71
+ * Authenticate the auth input data provided by BAS Service Center.
72
+ *
73
+ * @param data - the input data from BAS Service Center
74
+ * @param system - the system selection answers
75
+ */
76
+ export declare function authenticateInputData(data: PromptOptions, system: SystemSelectionAnswers): Promise<void>;
77
+ /**
78
+ * Validate the connection to the system.
79
+ *
80
+ * @param systemName - the system name
81
+ * @param system - the system selection answers
82
+ * @param reqAuth - the auth, user and password, provided by BAS Service Center
83
+ */
84
+ export declare function validateConnection(systemName: string, system: SystemSelectionAnswers, reqAuth?: ReqAuth): Promise<void>;
85
+ /**
86
+ * Check the connection to the system.
87
+ *
88
+ * @param provider - the service provider
89
+ * @returns whether the connection is successful
90
+ */
91
+ export declare function checkConnection(provider: AbapServiceProvider): Promise<boolean>;
92
+ /**
93
+ * Set the Yeoman UI (AppWizard) toolbar message based on the input data.
94
+ *
95
+ * @param data - the prompt options passed in from BAS Service Center
96
+ * @param systemSelectionAnswers - the system selection answers
97
+ * @param appWizard - the app wizard reference
98
+ */
99
+ export declare function setToolbarMessage(data: PromptOptions, systemSelectionAnswers: SystemSelectionAnswers, appWizard: AppWizard): void;
100
+ /**
101
+ * Add the system selection and object answers to the cache.
102
+ *
103
+ * @param appWizard - the app wizard reference
104
+ * @param systemSelectionAnswers - the system selection answers
105
+ * @param objectAnswers - the remaining prompt answers from system selection step
106
+ */
107
+ export declare function addToCache(appWizard: AppWizard, systemSelectionAnswers: SystemSelectionAnswers, objectAnswers: UiServiceAnswers): void;
108
+ /**
109
+ * Get the system selection answers and system name from the cache.
110
+ *
111
+ * @param appWizard - the app wizard reference
112
+ * @returns the system selection answers and system name
113
+ */
114
+ export declare function getFromCache(appWizard: AppWizard): [UiServiceAnswers, string];
115
+ //# sourceMappingURL=utils.d.ts.map
@@ -0,0 +1,285 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.getFromCache = exports.addToCache = exports.setToolbarMessage = exports.checkConnection = exports.validateConnection = exports.authenticateInputData = exports.getAppGenSystemData = exports.runPostGenHook = exports.getServiceMedadataContent = exports.getMetadata = exports.getRelativeUrlFromContent = exports.writeBASMetadata = exports.generateService = void 0;
7
+ const yeoman_ui_types_1 = require("@sap-devx/yeoman-ui-types");
8
+ const btp_utils_1 = require("@sap-ux/btp-utils");
9
+ const fiori_generator_shared_1 = require("@sap-ux/fiori-generator-shared");
10
+ const system_access_1 = require("@sap-ux/system-access");
11
+ const service_provider_apis_1 = require("@sap/service-provider-apis");
12
+ const path_1 = require("path");
13
+ const utils_1 = require("../utils");
14
+ const i18n_1 = require("../utils/i18n");
15
+ const logger_1 = __importDefault(require("../utils/logger"));
16
+ /**
17
+ * Generate the service.
18
+ *
19
+ * @param objectGeneator - the backend object generator for the object type
20
+ * @param content - the suggested content used to generate the service
21
+ * @param transportReqNumber - the transport request number
22
+ * @param appWizard - the app wizard reference
23
+ * @returns the generated service response
24
+ */
25
+ async function generateService(objectGeneator, content, transportReqNumber, appWizard) {
26
+ return await objectGeneator.generate(content, transportReqNumber).catch((error) => {
27
+ appWizard.showError(`${(0, i18n_1.t)('error.generatingService')}`, yeoman_ui_types_1.MessageType.notification);
28
+ logger_1.default.logger.error(`Error generating service: ${error.message}`);
29
+ logger_1.default.logger.error(`${error.code} ${error.response?.status} ${error.response?.data}`);
30
+ fiori_generator_shared_1.TelemetryHelper.createTelemetryData({
31
+ ErrorMessage: error.message,
32
+ ErrorCode: error.code,
33
+ ResponseStatus: error.response?.status
34
+ });
35
+ (0, fiori_generator_shared_1.sendTelemetry)(utils_1.SERVICE_GENERATION_FAIL, fiori_generator_shared_1.TelemetryHelper.telemetryData).catch((error) => {
36
+ logger_1.default.logger.error(`Error sending telemetry: ${error.message}`);
37
+ });
38
+ });
39
+ }
40
+ exports.generateService = generateService;
41
+ /**
42
+ * Write the service metadata file into the BAS Storyboard project.
43
+ *
44
+ * @param serviceConfig - the service name and content object
45
+ * @param fs - the file system
46
+ * @param appWizard - the app wizard reference
47
+ * @param inputData - the input data provider to the service generator from BAS
48
+ * @param provider - the service provider
49
+ */
50
+ async function writeBASMetadata(serviceConfig, fs, appWizard, inputData, provider) {
51
+ const relativeURL = getRelativeUrlFromContent(serviceConfig.content);
52
+ let metadata = await getMetadata(relativeURL, provider);
53
+ if (!metadata) {
54
+ // wait for 5 seconds and try again
55
+ await new Promise((resolve) => setTimeout(resolve, 5000));
56
+ metadata = await getMetadata(relativeURL, provider, true);
57
+ }
58
+ if (metadata) {
59
+ const serviceMetadataContent = getServiceMedadataContent(inputData.providerSystem, relativeURL, metadata, JSON.parse(serviceConfig.content));
60
+ // path was already validated in calling function
61
+ fs.writeJSON((0, path_1.join)(inputData.path, '.service.metadata'), serviceMetadataContent);
62
+ appWizard.showInformation((0, i18n_1.t)('info.generationSuccessfulWriteFile', { serviceName: serviceConfig.serviceName }), yeoman_ui_types_1.MessageType.notification);
63
+ logger_1.default.logger.info((0, i18n_1.t)('info.generationSuccessfulWriteFile', { serviceName: serviceConfig.serviceName }));
64
+ }
65
+ else {
66
+ appWizard.showInformation((0, i18n_1.t)('info.generationSuccessfulMetadataFail', { serviceName: serviceConfig.serviceName }), yeoman_ui_types_1.MessageType.notification);
67
+ logger_1.default.logger.info((0, i18n_1.t)('info.generationSuccessfulMetadataFail', { serviceName: serviceConfig.serviceName }));
68
+ }
69
+ }
70
+ exports.writeBASMetadata = writeBASMetadata;
71
+ /**
72
+ * Get the relative URL from the service content.
73
+ *
74
+ * @param content - the suggested service content
75
+ * @returns the relative odata service URL
76
+ */
77
+ function getRelativeUrlFromContent(content) {
78
+ const contentJson = JSON.parse(content);
79
+ return `/sap/opu/odata4/sap/${contentJson.businessService.serviceBinding.serviceBindingName}/srvd/sap/${contentJson.businessService.serviceDefinition.serviceDefinitionName}/0001/`;
80
+ }
81
+ exports.getRelativeUrlFromContent = getRelativeUrlFromContent;
82
+ /**
83
+ * Get the metadata for the service url provided. Has a 5 second retry if the metadata is not fetched on first attempt.
84
+ *
85
+ * @param relativeURL - the relative URL of the service
86
+ * @param provider - the service provider
87
+ * @param retry - whether retry should be attempted
88
+ * @returns the service metadata content as string
89
+ */
90
+ async function getMetadata(relativeURL, provider, retry = false) {
91
+ return await provider
92
+ .get(`${relativeURL}/$metadata`)
93
+ .then((res) => {
94
+ return res.data;
95
+ })
96
+ .catch((error) => {
97
+ if (retry) {
98
+ logger_1.default.logger.error(`Error fetching metadata for generated service: ${error.message}`);
99
+ }
100
+ return '';
101
+ });
102
+ }
103
+ exports.getMetadata = getMetadata;
104
+ /**
105
+ * Get the service metadata content to be written to the .service.metadata file.
106
+ *
107
+ * @param providerSystem - the provider system
108
+ * @param relativeURL - the relative URL of the service
109
+ * @param metadata - the metadata content
110
+ * @param contentJson - the suggested service content as JSON
111
+ * @returns the service connectivity data object in form of .service.metadata file
112
+ */
113
+ function getServiceMedadataContent(providerSystem, relativeURL, metadata, contentJson) {
114
+ return {
115
+ providerSystem: providerSystem,
116
+ relativeURL: relativeURL,
117
+ metadata: {
118
+ odataContent: metadata
119
+ },
120
+ serviceName: contentJson.businessService.serviceBinding.serviceBindingName,
121
+ providerType: service_provider_apis_1.ProviderType.SapSystem
122
+ };
123
+ }
124
+ exports.getServiceMedadataContent = getServiceMedadataContent;
125
+ /**
126
+ * Run the post generation hook to open the application generator via command with specific payload.
127
+ *
128
+ * @param options - options passed to the generator
129
+ * @param systemData - the system data
130
+ * @param content - the suggested service content
131
+ * @param provider - the service provider
132
+ */
133
+ async function runPostGenHook(options, systemData, content, provider) {
134
+ const relativeUrl = getRelativeUrlFromContent(content);
135
+ const appGenData = {
136
+ type: 'SERVICE_GEN_DATA',
137
+ system: systemData,
138
+ service: {
139
+ url: relativeUrl,
140
+ metadata: await getMetadata(relativeUrl, provider)
141
+ }
142
+ };
143
+ if (options.data?.path) {
144
+ Object.assign(appGenData, {
145
+ project: {
146
+ targetPath: (0, path_1.dirname)(options.data?.path),
147
+ name: (0, path_1.basename)(options.data?.path)
148
+ }
149
+ });
150
+ }
151
+ logger_1.default.logger.info(`Launching App Generator with data: ${JSON.stringify(appGenData)} and command ${options.data?.appGenLaunchCommand}`);
152
+ setTimeout(() => {
153
+ options.vscode?.commands?.executeCommand?.(options.data?.appGenLaunchCommand ?? 'sap.ux.service.generated.handler', appGenData);
154
+ }, 500);
155
+ }
156
+ exports.runPostGenHook = runPostGenHook;
157
+ /**
158
+ * Get the system data for the application generator.
159
+ *
160
+ * @param system - the system selection answers
161
+ * @returns the system data to be passed to the application generator
162
+ */
163
+ function getAppGenSystemData(system) {
164
+ return (0, btp_utils_1.isAppStudio)()
165
+ ? { destination: system.connectedSystem?.destination?.Name ?? '' }
166
+ : {
167
+ name: system.connectedSystem?.backendSystem?.name ?? '',
168
+ url: system.connectedSystem?.backendSystem?.url ?? '',
169
+ client: system.connectedSystem?.backendSystem?.client ?? ''
170
+ };
171
+ }
172
+ exports.getAppGenSystemData = getAppGenSystemData;
173
+ /**
174
+ * Authenticate the auth input data provided by BAS Service Center.
175
+ *
176
+ * @param data - the input data from BAS Service Center
177
+ * @param system - the system selection answers
178
+ */
179
+ async function authenticateInputData(data, system) {
180
+ const reqAuth = data.user && data.password ? { username: data.user, password: data.password } : undefined;
181
+ await validateConnection(data.systemName, system, reqAuth);
182
+ }
183
+ exports.authenticateInputData = authenticateInputData;
184
+ /**
185
+ * Validate the connection to the system.
186
+ *
187
+ * @param systemName - the system name
188
+ * @param system - the system selection answers
189
+ * @param reqAuth - the auth, user and password, provided by BAS Service Center
190
+ */
191
+ async function validateConnection(systemName, system, reqAuth) {
192
+ const target = {
193
+ destination: systemName
194
+ };
195
+ const provider = (await (0, system_access_1.createAbapServiceProvider)(target, { ignoreCertErrors: true, auth: reqAuth }, false, logger_1.default.logger));
196
+ try {
197
+ await checkConnection(provider);
198
+ Object.assign(system, {
199
+ connectedSystem: {
200
+ serviceProvider: provider,
201
+ destination: {
202
+ Name: systemName
203
+ }
204
+ }
205
+ });
206
+ return;
207
+ }
208
+ catch (e) {
209
+ logger_1.default.logger.error((0, i18n_1.t)('error.connectionFailed', { system: systemName }));
210
+ return;
211
+ }
212
+ }
213
+ exports.validateConnection = validateConnection;
214
+ /**
215
+ * Check the connection to the system.
216
+ *
217
+ * @param provider - the service provider
218
+ * @returns whether the connection is successful
219
+ */
220
+ async function checkConnection(provider) {
221
+ try {
222
+ await provider.get('/sap/bc/adt/discovery', {
223
+ headers: {
224
+ Accept: 'application/atomsvc+xml'
225
+ }
226
+ });
227
+ return true;
228
+ }
229
+ catch {
230
+ return false;
231
+ }
232
+ }
233
+ exports.checkConnection = checkConnection;
234
+ /**
235
+ * Set the Yeoman UI (AppWizard) toolbar message based on the input data.
236
+ *
237
+ * @param data - the prompt options passed in from BAS Service Center
238
+ * @param systemSelectionAnswers - the system selection answers
239
+ * @param appWizard - the app wizard reference
240
+ */
241
+ function setToolbarMessage(data, systemSelectionAnswers, appWizard) {
242
+ if (data?.systemName && !systemSelectionAnswers.connectedSystem?.serviceProvider) {
243
+ // Could not authenticate with the system provided in the input data
244
+ appWizard.showError((0, i18n_1.t)('error.authentication'), yeoman_ui_types_1.MessageType.prompt);
245
+ }
246
+ else if (data?.systemName && !systemSelectionAnswers.objectGenerator) {
247
+ // Could not fetch the generator for the business object provided in the input data
248
+ appWizard.showError((0, i18n_1.t)('error.noGeneratorFoundBo'), yeoman_ui_types_1.MessageType.prompt);
249
+ }
250
+ else {
251
+ appWizard.showWarning((0, i18n_1.t)('info.generationWarning'), yeoman_ui_types_1.MessageType.prompt);
252
+ }
253
+ }
254
+ exports.setToolbarMessage = setToolbarMessage;
255
+ /**
256
+ * Add the system selection and object answers to the cache.
257
+ *
258
+ * @param appWizard - the app wizard reference
259
+ * @param systemSelectionAnswers - the system selection answers
260
+ * @param objectAnswers - the remaining prompt answers from system selection step
261
+ */
262
+ function addToCache(appWizard, systemSelectionAnswers, objectAnswers) {
263
+ if (appWizard[utils_1.UI_SERVICE_CACHE]) {
264
+ Object.assign(appWizard[utils_1.UI_SERVICE_CACHE], {
265
+ systemSelectionAnswers: objectAnswers,
266
+ systemName: systemSelectionAnswers.connectedSystem?.destination?.Name ??
267
+ systemSelectionAnswers.connectedSystem?.backendSystem?.name
268
+ });
269
+ }
270
+ }
271
+ exports.addToCache = addToCache;
272
+ /**
273
+ * Get the system selection answers and system name from the cache.
274
+ *
275
+ * @param appWizard - the app wizard reference
276
+ * @returns the system selection answers and system name
277
+ */
278
+ function getFromCache(appWizard) {
279
+ return [
280
+ appWizard[utils_1.UI_SERVICE_CACHE].systemSelectionAnswers,
281
+ appWizard[utils_1.UI_SERVICE_CACHE].systemName
282
+ ];
283
+ }
284
+ exports.getFromCache = getFromCache;
285
+ //# sourceMappingURL=utils.js.map
@@ -0,0 +1,17 @@
1
+ {
2
+ "error": {
3
+ "fetchingGenerator": "Error fetching generator: {{error}}",
4
+ "sendingTelemetry": "Error sending telemetry event",
5
+ "connectionFailed": "Connection to the discovery service on backend system {{system}} failed.",
6
+ "authentication": "Authentication failed with system data provided, unable to continue with UI Service generation.",
7
+ "generatingService": "The UI Service failed to create successfully. Please see the log in 'Application Wizard.Generators' output for more details.",
8
+ "noGeneratorFoundBo": "No generator found for the selected business object interface"
9
+ },
10
+ "info": {
11
+ "generationSuccessful": "UI Service {{serviceName}} was generated successfully",
12
+ "generationSuccessfulWriteFile": "UI Service {{serviceName}} has been created successfully and has been added to your project",
13
+ "generationSuccessfulMetadataFail": "UI Service {{serviceName}} has been created successfully, but could not be added to your project",
14
+ "generationWarning": "Generation of UI Service might take a few minutes. Please be patient.",
15
+ "generatingUiService": "Generating UI service..."
16
+ }
17
+ }
@@ -0,0 +1,14 @@
1
+ export declare const STEP_SAP_SYSTEM_CONFIG = "SAP_SYSTEM_CONFIG";
2
+ export declare const STEP_SERVICE_CONFIG = "SERVICE_CONFIG";
3
+ export declare const prompts: {
4
+ key: string;
5
+ name: string;
6
+ description: string;
7
+ order: number;
8
+ }[];
9
+ export declare const boUri = "/sap/bc/adt/bo/behaviordefinitions/";
10
+ export declare const cdsUri = "/sap/bc/adt/ddic/ddl/sources/";
11
+ export declare const UI_SERVICE_CACHE = "$ui-service-cache";
12
+ export declare const SERVICE_GENERATION_SUCCESS = "SERVICE_GENERATION_SUCCESS";
13
+ export declare const SERVICE_GENERATION_FAIL = "SERVICE_GENERATION_FAIL";
14
+ //# sourceMappingURL=constants.d.ts.map
@@ -0,0 +1,20 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.SERVICE_GENERATION_FAIL = exports.SERVICE_GENERATION_SUCCESS = exports.UI_SERVICE_CACHE = exports.cdsUri = exports.boUri = exports.prompts = exports.STEP_SERVICE_CONFIG = exports.STEP_SAP_SYSTEM_CONFIG = void 0;
4
+ exports.STEP_SAP_SYSTEM_CONFIG = 'SAP_SYSTEM_CONFIG';
5
+ exports.STEP_SERVICE_CONFIG = 'SERVICE_CONFIG';
6
+ exports.prompts = [
7
+ {
8
+ key: exports.STEP_SAP_SYSTEM_CONFIG,
9
+ name: 'SAP System selection',
10
+ description: '',
11
+ order: 0
12
+ },
13
+ { key: exports.STEP_SERVICE_CONFIG, name: 'UI Service Configuration', description: '', order: 1 }
14
+ ];
15
+ exports.boUri = '/sap/bc/adt/bo/behaviordefinitions/';
16
+ exports.cdsUri = '/sap/bc/adt/ddic/ddl/sources/';
17
+ exports.UI_SERVICE_CACHE = '$ui-service-cache';
18
+ exports.SERVICE_GENERATION_SUCCESS = 'SERVICE_GENERATION_SUCCESS';
19
+ exports.SERVICE_GENERATION_FAIL = 'SERVICE_GENERATION_FAIL';
20
+ //# sourceMappingURL=constants.js.map
@@ -0,0 +1,11 @@
1
+ import type { TOptions } from 'i18next';
2
+ export declare function initI18n(): Promise<void>;
3
+ /**
4
+ * Helper function facading the call to i18next. Unless a namespace option is provided the local namespace will be used.
5
+ *
6
+ * @param key i18n key
7
+ * @param options additional options
8
+ * @returns {string} localized string stored for the given key
9
+ */
10
+ export declare function t(key: string, options?: TOptions): string;
11
+ //# sourceMappingURL=i18n.d.ts.map
@@ -0,0 +1,31 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.t = exports.initI18n = void 0;
7
+ const i18next_1 = __importDefault(require("i18next"));
8
+ const ui_service_generator_i18n_json_1 = __importDefault(require("../translations/ui-service-generator.i18n.json"));
9
+ const uiServiceGeneratorNs = 'ui-service-generator';
10
+ async function initI18n() {
11
+ await i18next_1.default.init({ lng: 'en', fallbackLng: 'en' }, () => i18next_1.default.addResourceBundle('en', uiServiceGeneratorNs, ui_service_generator_i18n_json_1.default));
12
+ }
13
+ exports.initI18n = initI18n;
14
+ /**
15
+ * Helper function facading the call to i18next. Unless a namespace option is provided the local namespace will be used.
16
+ *
17
+ * @param key i18n key
18
+ * @param options additional options
19
+ * @returns {string} localized string stored for the given key
20
+ */
21
+ function t(key, options) {
22
+ if (!options?.ns) {
23
+ options = Object.assign(options ?? {}, { ns: uiServiceGeneratorNs });
24
+ }
25
+ return i18next_1.default.t(key, options);
26
+ }
27
+ exports.t = t;
28
+ initI18n().catch(() => {
29
+ // Needed for lint
30
+ });
31
+ //# sourceMappingURL=i18n.js.map
@@ -0,0 +1,4 @@
1
+ export * from './constants';
2
+ export * from './logger';
3
+ export * from './i18n';
4
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1,20 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
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);
20
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1,32 @@
1
+ import { type ILogWrapper } from '@sap-ux/fiori-generator-shared';
2
+ import type { IVSCodeExtLogger, LogLevel } from '@vscode-logging/logger';
3
+ import type { Logger } from 'yeoman-environment';
4
+ /**
5
+ * Static logger prevents passing of logger references through all functions, as this is a cross-cutting concern.
6
+ */
7
+ export default class UiServiceGenLogger {
8
+ private static _logger;
9
+ /**
10
+ * Get the logger.
11
+ *
12
+ * @returns the logger
13
+ */
14
+ static get logger(): ILogWrapper;
15
+ /**
16
+ * Set the logger.
17
+ *
18
+ * @param value the logger to set
19
+ */
20
+ static set logger(value: ILogWrapper);
21
+ /**
22
+ * Configures the vscode logger.
23
+ *
24
+ * @param vscLogger - the vscode logger
25
+ * @param loggerName - the logger name
26
+ * @param yoLogger - the yeoman logger
27
+ * @param vscode - the vscode instance
28
+ * @param logLevel - the log level
29
+ */
30
+ static configureLogging(vscLogger: IVSCodeExtLogger, loggerName: string, yoLogger: Logger, vscode?: unknown, logLevel?: LogLevel): void;
31
+ }
32
+ //# sourceMappingURL=logger.d.ts.map
@@ -0,0 +1,40 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const fiori_generator_shared_1 = require("@sap-ux/fiori-generator-shared");
4
+ /**
5
+ * Static logger prevents passing of logger references through all functions, as this is a cross-cutting concern.
6
+ */
7
+ class UiServiceGenLogger {
8
+ static _logger = fiori_generator_shared_1.DefaultLogger;
9
+ /**
10
+ * Get the logger.
11
+ *
12
+ * @returns the logger
13
+ */
14
+ static get logger() {
15
+ return UiServiceGenLogger._logger;
16
+ }
17
+ /**
18
+ * Set the logger.
19
+ *
20
+ * @param value the logger to set
21
+ */
22
+ static set logger(value) {
23
+ UiServiceGenLogger._logger = value;
24
+ }
25
+ /**
26
+ * Configures the vscode logger.
27
+ *
28
+ * @param vscLogger - the vscode logger
29
+ * @param loggerName - the logger name
30
+ * @param yoLogger - the yeoman logger
31
+ * @param vscode - the vscode instance
32
+ * @param logLevel - the log level
33
+ */
34
+ static configureLogging(vscLogger, loggerName, yoLogger, vscode, logLevel) {
35
+ const logWrapper = new fiori_generator_shared_1.LogWrapper(loggerName, yoLogger, logLevel, vscLogger, vscode);
36
+ UiServiceGenLogger.logger = logWrapper;
37
+ }
38
+ }
39
+ exports.default = UiServiceGenLogger;
40
+ //# sourceMappingURL=logger.js.map
package/package.json ADDED
@@ -0,0 +1,67 @@
1
+ {
2
+ "name": "@sap-ux/ui-service-sub-generator",
3
+ "description": "Generator for creating UI Service",
4
+ "version": "0.0.1",
5
+ "repository": {
6
+ "type": "git",
7
+ "url": "https://github.com/SAP/open-ux-tools.git",
8
+ "directory": "packages/ui-service-sub-generator"
9
+ },
10
+ "bugs": {
11
+ "url": "https://github.com/SAP/open-ux-tools/issues?q=is%3Aopen+is%3Aissue"
12
+ },
13
+ "license": "Apache-2.0",
14
+ "main": "generators/app/index.js",
15
+ "files": [
16
+ "LICENSE",
17
+ "generators",
18
+ "!generators/*.map",
19
+ "!generators/**/*.map"
20
+ ],
21
+ "dependencies": {
22
+ "@sap-devx/yeoman-ui-types": "1.16.9",
23
+ "i18next": "23.5.1",
24
+ "yeoman-generator": "5.10.0",
25
+ "@sap-ux/axios-extension": "1.19.1",
26
+ "@sap-ux/feature-toggle": "0.2.3",
27
+ "@sap-ux/fiori-generator-shared": "0.9.9",
28
+ "@sap-ux/btp-utils": "1.0.2",
29
+ "@sap-ux/inquirer-common": "0.6.29",
30
+ "@sap-ux/logger": "0.6.0",
31
+ "@sap-ux/system-access": "0.5.33",
32
+ "@sap-ux/telemetry": "0.5.70",
33
+ "@sap-ux/ui-service-inquirer": "0.0.1"
34
+ },
35
+ "devDependencies": {
36
+ "@sap/service-provider-apis": "2.1.5",
37
+ "@sap/subaccount-destination-service-provider": "2.4.2",
38
+ "@types/mem-fs": "1.1.2",
39
+ "@types/yeoman-test": "4.0.6",
40
+ "@types/mem-fs-editor": "7.0.1",
41
+ "@types/yeoman-environment": "2.10.11",
42
+ "@types/yeoman-generator": "5.2.11",
43
+ "@vscode-logging/logger": "2.0.0",
44
+ "jest-extended": "4.0.2",
45
+ "mem-fs": "2.1.0",
46
+ "mem-fs-editor": "9.4.0",
47
+ "rimraf": "5.0.5",
48
+ "typescript": "5.3.3",
49
+ "yeoman-test": "6.3.0",
50
+ "@sap-ux/jest-file-matchers": "0.2.1",
51
+ "@sap-ux/store": "1.0.0"
52
+ },
53
+ "engines": {
54
+ "node": ">=18.x"
55
+ },
56
+ "scripts": {
57
+ "build": "tsc --build",
58
+ "clean": "rimraf --glob generators test/test-output coverage *.tsbuildinfo",
59
+ "watch": "tsc --watch",
60
+ "lint": "eslint . --ext .ts",
61
+ "lint:fix": "eslint . --ext .ts --fix",
62
+ "test": "jest --ci --forceExit --detectOpenHandles --colors --passWithNoTests",
63
+ "test-u": "jest --ci --forceExit --detectOpenHandles --colors -u",
64
+ "link": "pnpm link --global",
65
+ "unlink": "pnpm unlink --global"
66
+ }
67
+ }