@sap-ux/axios-extension 1.13.1 → 1.14.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.
@@ -1,6 +1,6 @@
1
1
  import type { Logger } from '@sap-ux/logger';
2
2
  import type { GeneratorEntry } from './types';
3
- import type { BusinessObject } from '../../types';
3
+ import type { BusinessObject, ValidationResponse } from '../../types';
4
4
  import { AdtService } from '../services';
5
5
  /**
6
6
  *
@@ -15,6 +15,12 @@ export declare class UiServiceGenerator extends AdtService {
15
15
  * @param bo - The business object.
16
16
  */
17
17
  configure(_config: GeneratorEntry, bo: BusinessObject): void;
18
+ /**
19
+ * Get the schema of the service binding.
20
+ *
21
+ * @returns The schema of the service binding.
22
+ */
23
+ getSchema(): Promise<any>;
18
24
  /**
19
25
  * Get the content of the service binding.
20
26
  *
@@ -22,6 +28,20 @@ export declare class UiServiceGenerator extends AdtService {
22
28
  * @returns The content of the service binding.
23
29
  */
24
30
  getContent(pckg: string): Promise<string>;
31
+ /**
32
+ * Validate the package before generation.
33
+ *
34
+ * @param pckg - The package to be validated.
35
+ * @returns The response of the validation.
36
+ */
37
+ validatePackage(pckg: string): Promise<any>;
38
+ /**
39
+ * Validate the service content and package before generation.
40
+ *
41
+ * @param content - The content to be validated.
42
+ * @returns The response of the validation.
43
+ */
44
+ validateContent(content: string): Promise<ValidationResponse>;
25
45
  /**
26
46
  * Generate the service binding.
27
47
  *
@@ -29,11 +49,6 @@ export declare class UiServiceGenerator extends AdtService {
29
49
  * @param transport - The transport.
30
50
  * @returns The object references.
31
51
  */
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>;
52
+ generate(content: string, transport: string): Promise<unknown>;
38
53
  }
39
54
  //# sourceMappingURL=ui-service-generator.d.ts.map
@@ -24,6 +24,24 @@ class UiServiceGenerator extends services_1.AdtService {
24
24
  configure(_config, bo) {
25
25
  this.bo = bo;
26
26
  }
27
+ /**
28
+ * Get the schema of the service binding.
29
+ *
30
+ * @returns The schema of the service binding.
31
+ */
32
+ getSchema() {
33
+ return __awaiter(this, void 0, void 0, function* () {
34
+ const response = yield this.get('/schema', {
35
+ headers: {
36
+ Accept: 'application/vnd.sap.adt.repository.generator.schema.v1+json'
37
+ },
38
+ params: {
39
+ referencedObject: this.bo.uri
40
+ }
41
+ });
42
+ return JSON.parse(response.data);
43
+ });
44
+ }
27
45
  /**
28
46
  * Get the content of the service binding.
29
47
  *
@@ -52,45 +70,69 @@ class UiServiceGenerator extends services_1.AdtService {
52
70
  });
53
71
  }
54
72
  /**
55
- * Generate the service binding.
73
+ * Validate the package before generation.
56
74
  *
57
- * @param content - The content of the service binding.
58
- * @param transport - The transport.
59
- * @returns The object references.
75
+ * @param pckg - The package to be validated.
76
+ * @returns The response of the validation.
60
77
  */
61
- generate(content, transport) {
78
+ validatePackage(pckg) {
62
79
  return __awaiter(this, void 0, void 0, function* () {
63
- const response = yield this.post('', content, {
80
+ const response = yield this.get('/validation', {
81
+ headers: {
82
+ Accept: 'application/vnd.sap.adt.validationMessages.v1+xml'
83
+ },
84
+ params: {
85
+ referencedObject: this.bo.uri,
86
+ package: pckg,
87
+ checks: 'package'
88
+ }
89
+ });
90
+ return this.parseResponse(response.data);
91
+ });
92
+ }
93
+ /**
94
+ * Validate the service content and package before generation.
95
+ *
96
+ * @param content - The content to be validated.
97
+ * @returns The response of the validation.
98
+ */
99
+ validateContent(content) {
100
+ var _a;
101
+ return __awaiter(this, void 0, void 0, function* () {
102
+ const response = yield this.post('/validation', content, {
64
103
  headers: {
65
104
  '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'
105
+ Accept: 'application/vnd.sap.adt.validationMessages.v1+xml'
67
106
  },
68
107
  params: {
69
108
  referencedObject: this.bo.uri,
70
- corrNr: transport
109
+ checks: 'package,referencedobject,authorization'
71
110
  }
72
111
  });
73
- // Service binding is in XML format, ready to be used for the subsequent activation and publish.
74
112
  const data = this.parseResponse(response.data);
75
- return data.objectReferences;
113
+ return (_a = data.validationMessages) === null || _a === void 0 ? void 0 : _a.validationMessage;
76
114
  });
77
115
  }
78
116
  /**
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.
117
+ * Generate the service binding.
118
+ *
119
+ * @param content - The content of the service binding.
120
+ * @param transport - The transport.
121
+ * @returns The object references.
81
122
  */
82
- lockServiceBinding() {
123
+ generate(content, transport) {
83
124
  return __awaiter(this, void 0, void 0, function* () {
84
- yield this.post('', '', {
125
+ const response = yield this.post('', content, {
85
126
  headers: {
86
- Accept: 'application/*,application/vnd.sap.as+xml;charset=UTF-8;dataname=com.sap.adt.lock.result',
87
- 'x-sap-adt-sessiontype': 'stateful'
127
+ 'Content-Type': 'application/vnd.sap.adt.repository.generator.content.v1+json',
128
+ Accept: 'application/vnd.sap.adt.repository.generator.v1+json, application/vnd.sap.as+xml;charset=UTF-8;dataname=com.sap.adt.StatusMessage'
88
129
  },
89
130
  params: {
90
- _action: `LOCK`,
91
- accessMode: 'MODIFY'
131
+ referencedObject: this.bo.uri,
132
+ corrNr: transport
92
133
  }
93
134
  });
135
+ return JSON.parse(response.data);
94
136
  });
95
137
  }
96
138
  }
@@ -37,11 +37,12 @@ class GeneratorService extends adt_service_1.AdtService {
37
37
  Accept: 'application/atom+xml;type=feed'
38
38
  },
39
39
  params: {
40
- referencedObject: `/sap/bc/adt/bo/behaviordefinitions/${businessObjectName.toLocaleLowerCase()}`
40
+ referencedObject: `/sap/bc/adt/bo/behaviordefinitions/${businessObjectName.toLocaleLowerCase()}`,
41
+ type: 'webapi'
41
42
  }
42
43
  });
43
44
  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
+ if ((data === null || data === void 0 ? void 0 : data.id) === 'published-ui-service') {
45
46
  return data;
46
47
  }
47
48
  else {
@@ -5,6 +5,5 @@ export { TransportRequestService, NewUi5ObjectRequestParams } from './transportr
5
5
  export { ListPackageService } from './list-package-service';
6
6
  export { FileStoreService } from './filestore-service';
7
7
  export { GeneratorService } from './generator-service';
8
- export { PublishService } from './publish-service';
9
8
  export { BusinessObjectsService } from './businessobjects-service';
10
9
  //# sourceMappingURL=index.d.ts.map
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.BusinessObjectsService = exports.PublishService = exports.GeneratorService = exports.FileStoreService = exports.ListPackageService = exports.TransportRequestService = exports.TransportChecksService = exports.AtoService = exports.AdtService = void 0;
3
+ exports.BusinessObjectsService = 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");
@@ -15,8 +15,6 @@ var filestore_service_1 = require("./filestore-service");
15
15
  Object.defineProperty(exports, "FileStoreService", { enumerable: true, get: function () { return filestore_service_1.FileStoreService; } });
16
16
  var generator_service_1 = require("./generator-service");
17
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
18
  var businessobjects_service_1 = require("./businessobjects-service");
21
19
  Object.defineProperty(exports, "BusinessObjectsService", { enumerable: true, get: function () { return businessobjects_service_1.BusinessObjectsService; } });
22
20
  //# sourceMappingURL=index.js.map
@@ -124,4 +124,9 @@ export type PublishResponse = {
124
124
  SHORT_TEXT: string;
125
125
  LONG_TEXT: string;
126
126
  };
127
+ export type ValidationResponse = {
128
+ severity: string;
129
+ short_text: string;
130
+ long_text: string;
131
+ };
127
132
  //# 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.13.1",
3
+ "version": "1.14.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",
@@ -29,7 +29,7 @@
29
29
  "@types/lodash": "4.14.202",
30
30
  "nock": "13.4.0",
31
31
  "supertest": "6.3.3",
32
- "@sap-ux/project-access": "1.21.1"
32
+ "@sap-ux/project-access": "1.22.2"
33
33
  },
34
34
  "files": [
35
35
  "dist",
@@ -1,34 +0,0 @@
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
@@ -1,65 +0,0 @@
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