@abaplint/runtime 1.7.1 → 1.7.5
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/build/src/compare/index.d.ts +1 -0
- package/build/src/compare/index.js +1 -0
- package/build/src/compare/na.d.ts +3 -0
- package/build/src/compare/na.js +9 -0
- package/build/src/statements/modify_internal.js +19 -5
- package/build/src/statements/read_table.d.ts +5 -1
- package/build/src/statements/read_table.js +34 -1
- package/package.json +42 -42
|
@@ -25,6 +25,7 @@ __exportStar(require("./initial"), exports);
|
|
|
25
25
|
__exportStar(require("./le"), exports);
|
|
26
26
|
__exportStar(require("./lt"), exports);
|
|
27
27
|
__exportStar(require("./ne"), exports);
|
|
28
|
+
__exportStar(require("./na"), exports);
|
|
28
29
|
__exportStar(require("./ns"), exports);
|
|
29
30
|
var in_1 = require("./in");
|
|
30
31
|
Object.defineProperty(exports, "in", { enumerable: true, get: function () { return in_1.compareIn; } });
|
|
@@ -1,12 +1,26 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.modifyInternal = void 0;
|
|
4
|
+
const types_1 = require("../types");
|
|
5
|
+
const delete_internal_1 = require("./delete_internal");
|
|
6
|
+
const insert_internal_1 = require("./insert_internal");
|
|
7
|
+
const read_table_1 = require("./read_table");
|
|
4
8
|
function modifyInternal(table, options) {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
table.
|
|
9
|
-
|
|
9
|
+
let found = false;
|
|
10
|
+
if (options.index) {
|
|
11
|
+
const index = options.index.get() - 1;
|
|
12
|
+
found = table.array()[index] !== undefined;
|
|
13
|
+
if (found) {
|
|
14
|
+
table.deleteIndex(index);
|
|
15
|
+
table.insertIndex(options.from, index);
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
else if (options.from) {
|
|
19
|
+
const readResult = (0, read_table_1.readTable)(table, { from: options.from });
|
|
20
|
+
if (readResult.subrc === 0) {
|
|
21
|
+
(0, delete_internal_1.deleteInternal)(table, { index: new types_1.Integer().set(readResult.foundIndex) });
|
|
22
|
+
}
|
|
23
|
+
(0, insert_internal_1.insertInternal)({ table, data: options.from });
|
|
10
24
|
}
|
|
11
25
|
const subrc = found ? 0 : 4;
|
|
12
26
|
// @ts-ignore
|
|
@@ -5,7 +5,11 @@ export interface IReadTableOptions {
|
|
|
5
5
|
index?: INumeric | number;
|
|
6
6
|
withKey?: (i: any) => boolean;
|
|
7
7
|
into?: INumeric | ICharacter | Structure | Table | DataReference;
|
|
8
|
+
from?: INumeric | ICharacter | Structure | Table | DataReference;
|
|
8
9
|
referenceInto?: DataReference;
|
|
9
10
|
assigning?: FieldSymbol;
|
|
10
11
|
}
|
|
11
|
-
export declare function readTable(table: Table | FieldSymbol, options?: IReadTableOptions):
|
|
12
|
+
export declare function readTable(table: Table | FieldSymbol, options?: IReadTableOptions): {
|
|
13
|
+
subrc: number;
|
|
14
|
+
foundIndex: number;
|
|
15
|
+
};
|
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.readTable = void 0;
|
|
4
|
+
const compare_1 = require("../compare");
|
|
4
5
|
const types_1 = require("../types");
|
|
5
6
|
function readTable(table, options) {
|
|
7
|
+
var _a;
|
|
6
8
|
let found = undefined;
|
|
7
9
|
let foundIndex = 0;
|
|
8
10
|
const arr = table.array();
|
|
@@ -30,10 +32,40 @@ function readTable(table, options) {
|
|
|
30
32
|
foundIndex = 0;
|
|
31
33
|
}
|
|
32
34
|
}
|
|
35
|
+
else if (options === null || options === void 0 ? void 0 : options.from) {
|
|
36
|
+
if (table instanceof types_1.Table && options.from instanceof types_1.Structure) {
|
|
37
|
+
const keys = (_a = table.getOptions()) === null || _a === void 0 ? void 0 : _a.keyFields;
|
|
38
|
+
const isStructured = arr[0] instanceof types_1.Structure;
|
|
39
|
+
if (keys !== undefined && isStructured === true) {
|
|
40
|
+
// console.dir(keys);
|
|
41
|
+
// console.dir(options.from.get()[keys[0].toLowerCase()]);
|
|
42
|
+
for (const a of arr) {
|
|
43
|
+
foundIndex++;
|
|
44
|
+
let matches = true;
|
|
45
|
+
for (const k of keys) {
|
|
46
|
+
if ((0, compare_1.eq)(a.get()[k.toLowerCase()], options.from.get()[k.toLowerCase()]) === false) {
|
|
47
|
+
matches = false;
|
|
48
|
+
break;
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
if (matches === true) {
|
|
52
|
+
found = arr;
|
|
53
|
+
break;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
if (found === undefined) {
|
|
59
|
+
foundIndex = 0;
|
|
60
|
+
}
|
|
61
|
+
}
|
|
33
62
|
else {
|
|
34
63
|
throw new Error("runtime, readTable, unexpected input");
|
|
35
64
|
}
|
|
36
|
-
|
|
65
|
+
let subrc = found ? 0 : 4;
|
|
66
|
+
if ((options === null || options === void 0 ? void 0 : options.from) && subrc === 4) {
|
|
67
|
+
subrc = 8;
|
|
68
|
+
}
|
|
37
69
|
// @ts-ignore
|
|
38
70
|
abap.builtin.sy.get().subrc.set(subrc);
|
|
39
71
|
// @ts-ignore
|
|
@@ -55,6 +87,7 @@ function readTable(table, options) {
|
|
|
55
87
|
else if (options.assigning && found) {
|
|
56
88
|
options.assigning.assign(found);
|
|
57
89
|
}
|
|
90
|
+
return { subrc, foundIndex };
|
|
58
91
|
}
|
|
59
92
|
exports.readTable = readTable;
|
|
60
93
|
//# sourceMappingURL=read_table.js.map
|
package/package.json
CHANGED
|
@@ -1,42 +1,42 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "@abaplint/runtime",
|
|
3
|
-
"version": "1.7.
|
|
4
|
-
"description": "Transpiler - Runtime",
|
|
5
|
-
"main": "build/src/index.js",
|
|
6
|
-
"typings": "build/src/index.d.ts",
|
|
7
|
-
"repository": {
|
|
8
|
-
"type": "git",
|
|
9
|
-
"url": "git+https://github.com/abaplint/transpiler.git"
|
|
10
|
-
},
|
|
11
|
-
"scripts": {
|
|
12
|
-
"compile": "tsc",
|
|
13
|
-
"publish:minor": "npm --no-git-tag-version version minor && rm -rf build && npm install && npm run test && npm publish --access public",
|
|
14
|
-
"publish:patch": "npm --no-git-tag-version version patch && rm -rf build && npm install && npm run test && npm publish --access public",
|
|
15
|
-
"test": "npm run compile && mocha"
|
|
16
|
-
},
|
|
17
|
-
"mocha": {
|
|
18
|
-
"recursive": true,
|
|
19
|
-
"reporter": "progress",
|
|
20
|
-
"spec": "build/test/**/*.js",
|
|
21
|
-
"require": "source-map-support/register"
|
|
22
|
-
},
|
|
23
|
-
"keywords": [
|
|
24
|
-
"ABAP",
|
|
25
|
-
"abaplint"
|
|
26
|
-
],
|
|
27
|
-
"author": "abaplint",
|
|
28
|
-
"license": "MIT",
|
|
29
|
-
"dependencies": {
|
|
30
|
-
"hdb": "^0.19.1",
|
|
31
|
-
"sql.js": "^1.6.2"
|
|
32
|
-
},
|
|
33
|
-
"devDependencies": {
|
|
34
|
-
"@types/chai": "^4.3.0",
|
|
35
|
-
"@types/mocha": "^9.0.0",
|
|
36
|
-
"@types/sql.js": "^1.4.3",
|
|
37
|
-
"chai": "^4.3.4",
|
|
38
|
-
"mocha": "^9.1.3",
|
|
39
|
-
"source-map-support": "^0.5.21",
|
|
40
|
-
"typescript": "^4.5.4"
|
|
41
|
-
}
|
|
42
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"name": "@abaplint/runtime",
|
|
3
|
+
"version": "1.7.5",
|
|
4
|
+
"description": "Transpiler - Runtime",
|
|
5
|
+
"main": "build/src/index.js",
|
|
6
|
+
"typings": "build/src/index.d.ts",
|
|
7
|
+
"repository": {
|
|
8
|
+
"type": "git",
|
|
9
|
+
"url": "git+https://github.com/abaplint/transpiler.git"
|
|
10
|
+
},
|
|
11
|
+
"scripts": {
|
|
12
|
+
"compile": "tsc",
|
|
13
|
+
"publish:minor": "npm --no-git-tag-version version minor && rm -rf build && npm install && npm run test && npm publish --access public",
|
|
14
|
+
"publish:patch": "npm --no-git-tag-version version patch && rm -rf build && npm install && npm run test && npm publish --access public",
|
|
15
|
+
"test": "npm run compile && mocha"
|
|
16
|
+
},
|
|
17
|
+
"mocha": {
|
|
18
|
+
"recursive": true,
|
|
19
|
+
"reporter": "progress",
|
|
20
|
+
"spec": "build/test/**/*.js",
|
|
21
|
+
"require": "source-map-support/register"
|
|
22
|
+
},
|
|
23
|
+
"keywords": [
|
|
24
|
+
"ABAP",
|
|
25
|
+
"abaplint"
|
|
26
|
+
],
|
|
27
|
+
"author": "abaplint",
|
|
28
|
+
"license": "MIT",
|
|
29
|
+
"dependencies": {
|
|
30
|
+
"hdb": "^0.19.1",
|
|
31
|
+
"sql.js": "^1.6.2"
|
|
32
|
+
},
|
|
33
|
+
"devDependencies": {
|
|
34
|
+
"@types/chai": "^4.3.0",
|
|
35
|
+
"@types/mocha": "^9.0.0",
|
|
36
|
+
"@types/sql.js": "^1.4.3",
|
|
37
|
+
"chai": "^4.3.4",
|
|
38
|
+
"mocha": "^9.1.3",
|
|
39
|
+
"source-map-support": "^0.5.21",
|
|
40
|
+
"typescript": "^4.5.4"
|
|
41
|
+
}
|
|
42
|
+
}
|