@sap-ux/axios-extension 1.11.8 → 1.12.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.
@@ -4,8 +4,9 @@ import { Ui5AbapRepositoryService } from './ui5-abap-repository-service';
4
4
  import { AppIndexService } from './app-index-service';
5
5
  import { ODataVersion } from '../base/odata-service';
6
6
  import { LayeredRepositoryService } from './lrep-service';
7
- import type { AtoSettings } from './types';
7
+ import type { AtoSettings, BusinessObject } from './types';
8
8
  import { AdtService } from './adt-catalog/services';
9
+ import { UiServiceGenerator } from './adt-catalog/generators/ui-service-generator';
9
10
  /**
10
11
  * Extension of the service provider for ABAP services.
11
12
  */
@@ -96,5 +97,26 @@ export declare class AbapServiceProvider extends ServiceProvider {
96
97
  * @returns Subclass type of class AdtService
97
98
  */
98
99
  getAdtService<T extends AdtService>(adtServiceSubclass: typeof AdtService): Promise<T | null>;
100
+ /**
101
+ * Create a UI Service generator for the given business object.
102
+ *
103
+ * @param bo - business object
104
+ * @returns a UI Service generator
105
+ */
106
+ getUiServiceGenerator(bo: BusinessObject): Promise<UiServiceGenerator>;
107
+ /**
108
+ * Get the service URL from the generator config.
109
+ *
110
+ * @param config - generator config
111
+ * @returns the service URL
112
+ */
113
+ private getServiceUrlFromConfig;
114
+ /**
115
+ * Create a service provider to lock a binding path.
116
+ *
117
+ * @param path - service binding path
118
+ * @returns a service provider instance to lock the service binding
119
+ */
120
+ createLockServiceBindingGenerator(path: string): Promise<UiServiceGenerator>;
99
121
  }
100
122
  //# sourceMappingURL=abap-service-provider.d.ts.map
@@ -21,6 +21,7 @@ const types_1 = require("./types");
21
21
  // Can't use an `import type` here. We need the classname at runtime to create object instances:
22
22
  // eslint-disable-next-line @typescript-eslint/consistent-type-imports
23
23
  const services_1 = require("./adt-catalog/services");
24
+ const ui_service_generator_1 = require("./adt-catalog/generators/ui-service-generator");
24
25
  /**
25
26
  * Extension of the service provider for ABAP services.
26
27
  */
@@ -203,6 +204,51 @@ class AbapServiceProvider extends service_provider_1.ServiceProvider {
203
204
  return this.services[subclassName];
204
205
  });
205
206
  }
207
+ /**
208
+ * Create a UI Service generator for the given business object.
209
+ *
210
+ * @param bo - business object
211
+ * @returns a UI Service generator
212
+ */
213
+ getUiServiceGenerator(bo) {
214
+ return __awaiter(this, void 0, void 0, function* () {
215
+ const generatorService = yield this.getAdtService(services_1.GeneratorService);
216
+ if (!generatorService) {
217
+ throw new Error('Generators are not support on this system');
218
+ }
219
+ const config = yield generatorService.getUIServiceGeneratorConfig(bo.name);
220
+ const gen = this.createService(this.getServiceUrlFromConfig(config), ui_service_generator_1.UiServiceGenerator);
221
+ gen.configure(config, bo);
222
+ return gen;
223
+ });
224
+ }
225
+ /**
226
+ * Get the service URL from the generator config.
227
+ *
228
+ * @param config - generator config
229
+ * @returns the service URL
230
+ */
231
+ getServiceUrlFromConfig(config) {
232
+ var _a;
233
+ // make code in this function defensive against undefined href
234
+ if (Array.isArray(config.link) && !((_a = config.link[0]) === null || _a === void 0 ? void 0 : _a.href)) {
235
+ throw new Error('No service URL found in the generator config');
236
+ }
237
+ const endIndex = config.link[0].href.indexOf(config.id) + config.id.length;
238
+ return config.link[0].href.substring(0, endIndex);
239
+ }
240
+ /**
241
+ * Create a service provider to lock a binding path.
242
+ *
243
+ * @param path - service binding path
244
+ * @returns a service provider instance to lock the service binding
245
+ */
246
+ createLockServiceBindingGenerator(path) {
247
+ return __awaiter(this, void 0, void 0, function* () {
248
+ const gen = this.createService(path, ui_service_generator_1.UiServiceGenerator);
249
+ return gen;
250
+ });
251
+ }
206
252
  }
207
253
  exports.AbapServiceProvider = AbapServiceProvider;
208
254
  //# sourceMappingURL=abap-service-provider.js.map
@@ -0,0 +1,9 @@
1
+ export interface GeneratorEntry {
2
+ id: string;
3
+ link: {
4
+ href: string;
5
+ rel: string;
6
+ type: string;
7
+ }[];
8
+ }
9
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1,39 @@
1
+ import type { Logger } from '@sap-ux/logger';
2
+ import type { GeneratorEntry } from './types';
3
+ import type { BusinessObject } from '../../types';
4
+ import { AdtService } from '../services';
5
+ /**
6
+ *
7
+ */
8
+ export declare class UiServiceGenerator extends AdtService {
9
+ log: Logger;
10
+ protected bo: BusinessObject;
11
+ /**
12
+ * Configure the UI service generator.
13
+ *
14
+ * @param _config - The generator configuration.
15
+ * @param bo - The business object.
16
+ */
17
+ configure(_config: GeneratorEntry, bo: BusinessObject): void;
18
+ /**
19
+ * Get the content of the service binding.
20
+ *
21
+ * @param pckg - The package name.
22
+ * @returns The content of the service binding.
23
+ */
24
+ getContent(pckg: string): Promise<string>;
25
+ /**
26
+ * Generate the service binding.
27
+ *
28
+ * @param content - The content of the service binding.
29
+ * @param transport - The transport.
30
+ * @returns The object references.
31
+ */
32
+ generate(content: string, transport: string): Promise<any>;
33
+ /**
34
+ * Lock the service binding. The class should be configured with the uri of the service binding
35
+ * The uri is returned from the generate method.
36
+ */
37
+ lockServiceBinding(): Promise<void>;
38
+ }
39
+ //# sourceMappingURL=ui-service-generator.d.ts.map
@@ -0,0 +1,98 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.UiServiceGenerator = void 0;
13
+ const services_1 = require("../services");
14
+ /**
15
+ *
16
+ */
17
+ class UiServiceGenerator extends services_1.AdtService {
18
+ /**
19
+ * Configure the UI service generator.
20
+ *
21
+ * @param _config - The generator configuration.
22
+ * @param bo - The business object.
23
+ */
24
+ configure(_config, bo) {
25
+ this.bo = bo;
26
+ }
27
+ /**
28
+ * Get the content of the service binding.
29
+ *
30
+ * @param pckg - The package name.
31
+ * @returns The content of the service binding.
32
+ */
33
+ getContent(pckg) {
34
+ return __awaiter(this, void 0, void 0, function* () {
35
+ const response = yield this.get('/content', {
36
+ headers: {
37
+ Accept: 'application/vnd.sap.adt.repository.generator.content.v1+json'
38
+ },
39
+ params: {
40
+ referencedObject: this.bo.uri,
41
+ package: pckg
42
+ }
43
+ });
44
+ const content = response.data;
45
+ const contentObj = JSON.parse(content);
46
+ if (!contentObj['metadata']) {
47
+ contentObj['metadata'] = {
48
+ package: pckg
49
+ };
50
+ }
51
+ return JSON.stringify(contentObj);
52
+ });
53
+ }
54
+ /**
55
+ * Generate the service binding.
56
+ *
57
+ * @param content - The content of the service binding.
58
+ * @param transport - The transport.
59
+ * @returns The object references.
60
+ */
61
+ generate(content, transport) {
62
+ return __awaiter(this, void 0, void 0, function* () {
63
+ const response = yield this.post('', content, {
64
+ headers: {
65
+ 'Content-Type': 'application/vnd.sap.adt.repository.generator.content.v1+json',
66
+ Accept: 'application/vnd.sap.adt.repository.generator.v1+json, application/vnd.sap.as+xml;charset=UTF-8;dataname=com.sap.adt.StatusMessage'
67
+ },
68
+ params: {
69
+ referencedObject: this.bo.uri,
70
+ corrNr: transport
71
+ }
72
+ });
73
+ // Service binding is in XML format, ready to be used for the subsequent activation and publish.
74
+ const data = this.parseResponse(response.data);
75
+ return data.objectReferences;
76
+ });
77
+ }
78
+ /**
79
+ * Lock the service binding. The class should be configured with the uri of the service binding
80
+ * The uri is returned from the generate method.
81
+ */
82
+ lockServiceBinding() {
83
+ return __awaiter(this, void 0, void 0, function* () {
84
+ yield this.post('', '', {
85
+ headers: {
86
+ Accept: 'application/*,application/vnd.sap.as+xml;charset=UTF-8;dataname=com.sap.adt.lock.result',
87
+ 'x-sap-adt-sessiontype': 'stateful'
88
+ },
89
+ params: {
90
+ _action: `LOCK`,
91
+ accessMode: 'MODIFY'
92
+ }
93
+ });
94
+ });
95
+ }
96
+ }
97
+ exports.UiServiceGenerator = UiServiceGenerator;
98
+ //# sourceMappingURL=ui-service-generator.js.map
@@ -29,6 +29,13 @@ export declare abstract class AdtService extends Axios implements AdtServiceExte
29
29
  * @param serviceSchema ADT schema for this particular ADT service catalog.
30
30
  */
31
31
  attachAdtSchema(serviceSchema: AdtCollection): void;
32
+ /**
33
+ * Parse an XML document for ATO (Adaptation Transport Organizer) settings.
34
+ *
35
+ * @param xml xml document containing ATO settings
36
+ * @returns parsed ATO settings
37
+ */
38
+ protected parseResponse<T>(xml: string): T;
32
39
  }
33
40
  export {};
34
41
  //# sourceMappingURL=adt-service.d.ts.map
@@ -2,6 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.AdtService = void 0;
4
4
  const axios_1 = require("axios");
5
+ const fast_xml_parser_1 = require("fast-xml-parser");
5
6
  /**
6
7
  * AdtService provides abstraction of AdtService implementations. Each specific ADT service
7
8
  * should be implemented as subclass of AdtService.
@@ -24,6 +25,27 @@ class AdtService extends axios_1.Axios {
24
25
  attachAdtSchema(serviceSchema) {
25
26
  this.serviceSchema = serviceSchema;
26
27
  }
28
+ /**
29
+ * Parse an XML document for ATO (Adaptation Transport Organizer) settings.
30
+ *
31
+ * @param xml xml document containing ATO settings
32
+ * @returns parsed ATO settings
33
+ */
34
+ parseResponse(xml) {
35
+ if (fast_xml_parser_1.XMLValidator.validate(xml) !== true) {
36
+ this.log.warn(`Invalid XML: ${xml}`);
37
+ return {};
38
+ }
39
+ const options = {
40
+ attributeNamePrefix: '',
41
+ ignoreAttributes: false,
42
+ ignoreNameSpace: true,
43
+ parseAttributeValue: true,
44
+ removeNSPrefix: true
45
+ };
46
+ const parser = new fast_xml_parser_1.XMLParser(options);
47
+ return parser.parse(xml, true);
48
+ }
27
49
  }
28
50
  exports.AdtService = AdtService;
29
51
  //# sourceMappingURL=adt-service.js.map
@@ -0,0 +1,32 @@
1
+ import { AdtService } from './adt-service';
2
+ import type { AdtCategory, BusinessObject } from '../../types';
3
+ /**
4
+ * BusinessObjectsService implements ADT requests to obtain the list of business objects.
5
+ */
6
+ export declare class BusinessObjectsService extends AdtService {
7
+ /**
8
+ * @see AdtService.getAdtCatagory()
9
+ */
10
+ private static adtCategory;
11
+ /**
12
+ * Get ADT scheme ID.
13
+ *
14
+ * @returns AdtCategory
15
+ */
16
+ static getAdtCatagory(): AdtCategory;
17
+ /**
18
+ * Get all business objects from ADT service.
19
+ *
20
+ * @param maxResults - The maximum number of business objects to be returned.
21
+ * @returns A list of business objects.
22
+ */
23
+ getBusinessObjects(maxResults?: number): Promise<BusinessObject[]>;
24
+ /**
25
+ * Parse the XML document of business object entries from ADT service.
26
+ *
27
+ * @param xml xml document containing business object entries.
28
+ * @returns A list of business object names.
29
+ */
30
+ private parseBOResponse;
31
+ }
32
+ //# sourceMappingURL=businessobjects-service.d.ts.map
@@ -0,0 +1,82 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.BusinessObjectsService = void 0;
13
+ const adt_service_1 = require("./adt-service");
14
+ /**
15
+ * BusinessObjectsService implements ADT requests to obtain the list of business objects.
16
+ */
17
+ class BusinessObjectsService extends adt_service_1.AdtService {
18
+ /**
19
+ * Get ADT scheme ID.
20
+ *
21
+ * @returns AdtCategory
22
+ */
23
+ static getAdtCatagory() {
24
+ return BusinessObjectsService.adtCategory;
25
+ }
26
+ /**
27
+ * Get all business objects from ADT service.
28
+ *
29
+ * @param maxResults - The maximum number of business objects to be returned.
30
+ * @returns A list of business objects.
31
+ */
32
+ getBusinessObjects(maxResults) {
33
+ return __awaiter(this, void 0, void 0, function* () {
34
+ const config = {
35
+ headers: {
36
+ Accept: 'application/xml'
37
+ },
38
+ params: {
39
+ operation: 'quickSearch',
40
+ query: `*`,
41
+ maxResults: maxResults || 10000,
42
+ objectType: 'BDEF',
43
+ releaseStatus: 'USE_IN_CLOUD_DEVELOPMENT'
44
+ }
45
+ };
46
+ const response = yield this.get('', config);
47
+ return this.parseBOResponse(response.data);
48
+ });
49
+ }
50
+ /**
51
+ * Parse the XML document of business object entries from ADT service.
52
+ *
53
+ * @param xml xml document containing business object entries.
54
+ * @returns A list of business object names.
55
+ */
56
+ parseBOResponse(xml) {
57
+ var _a;
58
+ const parsed = this.parseResponse(xml);
59
+ let boArray = [];
60
+ if ((_a = parsed === null || parsed === void 0 ? void 0 : parsed.objectReferences) === null || _a === void 0 ? void 0 : _a.objectReference) {
61
+ if (Array.isArray(parsed.objectReferences.objectReference)) {
62
+ boArray = parsed.objectReferences.objectReference;
63
+ }
64
+ else {
65
+ boArray = [parsed.objectReferences.objectReference];
66
+ }
67
+ }
68
+ return boArray.map((item) => {
69
+ const { name, uri, description } = item;
70
+ return { name, uri, description };
71
+ });
72
+ }
73
+ }
74
+ exports.BusinessObjectsService = BusinessObjectsService;
75
+ /**
76
+ * @see AdtService.getAdtCatagory()
77
+ */
78
+ BusinessObjectsService.adtCategory = {
79
+ scheme: 'http://www.sap.com/adt/categories/respository',
80
+ term: 'search'
81
+ };
82
+ //# sourceMappingURL=businessobjects-service.js.map
@@ -0,0 +1,27 @@
1
+ import { AdtService } from './adt-service';
2
+ import type { AdtCategory } from '../../types';
3
+ import type { GeneratorEntry } from '../generators/types';
4
+ /**
5
+ *
6
+ */
7
+ export declare class GeneratorService extends AdtService {
8
+ /**
9
+ * @see AdtService.getAdtCatagory()
10
+ */
11
+ private static adtCategory;
12
+ /**
13
+ * Get ADT scheme ID.
14
+ *
15
+ * @returns AdtCategory
16
+ */
17
+ static getAdtCatagory(): AdtCategory;
18
+ private id;
19
+ /**
20
+ * Get the UI service generator for the given business object.
21
+ *
22
+ * @param businessObjectName - The business object name.
23
+ * @returns TBD
24
+ */
25
+ getUIServiceGeneratorConfig(businessObjectName: string): Promise<GeneratorEntry>;
26
+ }
27
+ //# sourceMappingURL=generator-service.d.ts.map
@@ -0,0 +1,61 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.GeneratorService = void 0;
13
+ const adt_service_1 = require("./adt-service");
14
+ /**
15
+ *
16
+ */
17
+ class GeneratorService extends adt_service_1.AdtService {
18
+ /**
19
+ * Get ADT scheme ID.
20
+ *
21
+ * @returns AdtCategory
22
+ */
23
+ static getAdtCatagory() {
24
+ return GeneratorService.adtCategory;
25
+ }
26
+ /**
27
+ * Get the UI service generator for the given business object.
28
+ *
29
+ * @param businessObjectName - The business object name.
30
+ * @returns TBD
31
+ */
32
+ getUIServiceGeneratorConfig(businessObjectName) {
33
+ var _a;
34
+ return __awaiter(this, void 0, void 0, function* () {
35
+ const response = yield this.get('', {
36
+ headers: {
37
+ Accept: 'application/atom+xml;type=feed'
38
+ },
39
+ params: {
40
+ referencedObject: `/sap/bc/adt/bo/behaviordefinitions/${businessObjectName.toLocaleLowerCase()}`
41
+ }
42
+ });
43
+ const data = (_a = this.parseResponse(response.data).feed) === null || _a === void 0 ? void 0 : _a.entry;
44
+ if ((data === null || data === void 0 ? void 0 : data.id) === 'ui-service' || (data === null || data === void 0 ? void 0 : data.id) === 'uiservice') {
45
+ return data;
46
+ }
47
+ else {
48
+ throw new Error('UI Service Generator not found');
49
+ }
50
+ });
51
+ }
52
+ }
53
+ exports.GeneratorService = GeneratorService;
54
+ /**
55
+ * @see AdtService.getAdtCatagory()
56
+ */
57
+ GeneratorService.adtCategory = {
58
+ scheme: 'http://www.sap.com/adt/categories/respository',
59
+ term: 'generators'
60
+ };
61
+ //# sourceMappingURL=generator-service.js.map
@@ -4,4 +4,7 @@ export { TransportChecksService } from './transportcheck-service';
4
4
  export { TransportRequestService, NewUi5ObjectRequestParams } from './transportrequest-service';
5
5
  export { ListPackageService } from './list-package-service';
6
6
  export { FileStoreService } from './filestore-service';
7
+ export { GeneratorService } from './generator-service';
8
+ export { PublishService } from './publish-service';
9
+ export { BusinessObjectsService } from './businessobjects-service';
7
10
  //# sourceMappingURL=index.d.ts.map
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.FileStoreService = exports.ListPackageService = exports.TransportRequestService = exports.TransportChecksService = exports.AtoService = exports.AdtService = void 0;
3
+ exports.BusinessObjectsService = exports.PublishService = exports.GeneratorService = exports.FileStoreService = exports.ListPackageService = exports.TransportRequestService = exports.TransportChecksService = exports.AtoService = exports.AdtService = void 0;
4
4
  var adt_service_1 = require("./adt-service");
5
5
  Object.defineProperty(exports, "AdtService", { enumerable: true, get: function () { return adt_service_1.AdtService; } });
6
6
  var ato_service_1 = require("./ato-service");
@@ -13,4 +13,10 @@ var list_package_service_1 = require("./list-package-service");
13
13
  Object.defineProperty(exports, "ListPackageService", { enumerable: true, get: function () { return list_package_service_1.ListPackageService; } });
14
14
  var filestore_service_1 = require("./filestore-service");
15
15
  Object.defineProperty(exports, "FileStoreService", { enumerable: true, get: function () { return filestore_service_1.FileStoreService; } });
16
+ var generator_service_1 = require("./generator-service");
17
+ Object.defineProperty(exports, "GeneratorService", { enumerable: true, get: function () { return generator_service_1.GeneratorService; } });
18
+ var publish_service_1 = require("./publish-service");
19
+ Object.defineProperty(exports, "PublishService", { enumerable: true, get: function () { return publish_service_1.PublishService; } });
20
+ var businessobjects_service_1 = require("./businessobjects-service");
21
+ Object.defineProperty(exports, "BusinessObjectsService", { enumerable: true, get: function () { return businessobjects_service_1.BusinessObjectsService; } });
16
22
  //# sourceMappingURL=index.js.map
@@ -0,0 +1,34 @@
1
+ import { AdtService } from './adt-service';
2
+ import type { AdtCategory, PublishResponse } from '../../types';
3
+ /**
4
+ *
5
+ */
6
+ export declare class PublishService extends AdtService {
7
+ /**
8
+ * @see AdtService.getAdtCatagory()
9
+ */
10
+ private static adtCategory;
11
+ /**
12
+ * Get ADT scheme ID.
13
+ *
14
+ * @returns AdtCategory
15
+ */
16
+ static getAdtCatagory(): AdtCategory;
17
+ /**
18
+ * Build the service binding content, used in the publish request.
19
+ *
20
+ * @param serviceType - The service type.
21
+ * @param serviceBindingName - The service binding name.
22
+ * @returns The service binding content.
23
+ */
24
+ private buildServiceBindingContent;
25
+ /**
26
+ * Publish the service binding.
27
+ *
28
+ * @param type - The type of the service binding.
29
+ * @param bindingName - The name of the service binding.
30
+ * @returns The response status message.
31
+ */
32
+ publish(type: string, bindingName: string): Promise<PublishResponse>;
33
+ }
34
+ //# sourceMappingURL=publish-service.d.ts.map
@@ -0,0 +1,65 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.PublishService = void 0;
13
+ const adt_service_1 = require("./adt-service");
14
+ /**
15
+ *
16
+ */
17
+ class PublishService extends adt_service_1.AdtService {
18
+ /**
19
+ * Get ADT scheme ID.
20
+ *
21
+ * @returns AdtCategory
22
+ */
23
+ static getAdtCatagory() {
24
+ return PublishService.adtCategory;
25
+ }
26
+ /**
27
+ * Build the service binding content, used in the publish request.
28
+ *
29
+ * @param serviceType - The service type.
30
+ * @param serviceBindingName - The service binding name.
31
+ * @returns The service binding content.
32
+ */
33
+ buildServiceBindingContent(serviceType, serviceBindingName) {
34
+ return `<?xml version="1.0" encoding="UTF-8"?><adtcore:objectReferences xmlns:adtcore="http://www.sap.com/adt/core"><adtcore:objectReference adtcore:type="${serviceType}" adtcore:name="${serviceBindingName}"/></adtcore:objectReferences>`;
35
+ }
36
+ /**
37
+ * Publish the service binding.
38
+ *
39
+ * @param type - The type of the service binding.
40
+ * @param bindingName - The name of the service binding.
41
+ * @returns The response status message.
42
+ */
43
+ publish(type, bindingName) {
44
+ return __awaiter(this, void 0, void 0, function* () {
45
+ const content = this.buildServiceBindingContent(type, bindingName);
46
+ const response = yield this.post(`/publishjobs`, content, {
47
+ headers: {
48
+ 'Content-Type': 'application/xml',
49
+ Accept: 'application/xml, application/vnd.sap.as+xml;charset=UTF-8;dataname=com.sap.adt.StatusMessage'
50
+ }
51
+ });
52
+ const data = this.parseResponse(response.data);
53
+ return data['abap']['values']['DATA'];
54
+ });
55
+ }
56
+ }
57
+ exports.PublishService = PublishService;
58
+ /**
59
+ * @see AdtService.getAdtCatagory()
60
+ */
61
+ PublishService.adtCategory = {
62
+ scheme: 'http://www.sap.com/categories/servicebindings/bindingtypes',
63
+ term: 'ODataV4'
64
+ };
65
+ //# sourceMappingURL=publish-service.js.map
@@ -114,4 +114,14 @@ export interface ArchiveFileNode {
114
114
  }
115
115
  export type ArchiveFileNodeType = 'file' | 'folder';
116
116
  export type ArchiveFileContentType<T> = T extends 'file' ? string : T extends 'folder' ? ArchiveFileNode[] : never;
117
+ export type BusinessObject = {
118
+ name: string;
119
+ uri: string;
120
+ description?: string;
121
+ };
122
+ export type PublishResponse = {
123
+ SEVERITY: string;
124
+ SHORT_TEXT: string;
125
+ LONG_TEXT: string;
126
+ };
117
127
  //# sourceMappingURL=adt-types.d.ts.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sap-ux/axios-extension",
3
- "version": "1.11.8",
3
+ "version": "1.12.0",
4
4
  "description": "Extension of the Axios module adding convenience methods to interact with SAP systems especially with OData services.",
5
5
  "repository": {
6
6
  "type": "git",
@@ -22,7 +22,7 @@
22
22
  "qs": "6.7.3",
23
23
  "xpath": "0.0.33",
24
24
  "@xmldom/xmldom": "0.8.10",
25
- "@sap-ux/btp-utils": "0.14.3",
25
+ "@sap-ux/btp-utils": "0.14.4",
26
26
  "@sap-ux/logger": "0.5.1"
27
27
  },
28
28
  "devDependencies": {