diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 0000000..059887f --- /dev/null +++ b/.github/workflows/test.yml @@ -0,0 +1,18 @@ +name: test + +on: + pull_request: + +permissions: + contents: read + pull-requests: write + +jobs: + unit: + runs-on: ubuntu-latest + timeout-minutes: 5 + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-node@v4 + - run: npm install + - run: npm test \ No newline at end of file diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..fe03b2b --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +node_modules +output \ No newline at end of file diff --git a/.npmrc b/.npmrc new file mode 100644 index 0000000..537f81f --- /dev/null +++ b/.npmrc @@ -0,0 +1 @@ +ignore-scripts=true \ No newline at end of file diff --git a/abap_transpile.json b/abap_transpile.json new file mode 100644 index 0000000..6557eff --- /dev/null +++ b/abap_transpile.json @@ -0,0 +1,19 @@ +{ + "input_folder": "src", + "input_filter": [], + "libs": [{ + "url": "https://github.com/open-abap/open-abap-core" + }], + "output_folder": "output", + "write_unit_tests": true, + "write_source_map": true, + "options": { + "ignoreSyntaxCheck": false, + "addFilenames": true, + "addCommonJS": true, + "setup": { + "filename": "../setup.mjs", + "preFunction": "setup" + } + } +} \ No newline at end of file diff --git a/abaplint.jsonc b/abaplint.jsonc index 6ec4a7b..18b394b 100644 --- a/abaplint.jsonc +++ b/abaplint.jsonc @@ -546,11 +546,7 @@ "skipNames": [] }, "unused_methods": true, - "unused_types": { - "exclude": [], - "severity": "Error", - "skipNames": [] - }, + "unused_types": false, "unused_variables": { "exclude": [], "severity": "Error", diff --git a/package-lock.json b/package-lock.json new file mode 100644 index 0000000..e48b0ad --- /dev/null +++ b/package-lock.json @@ -0,0 +1,88 @@ +{ + "name": "open-abap-xco", + "version": "1.0.0", + "lockfileVersion": 3, + "requires": true, + "packages": { + "": { + "name": "open-abap-xco", + "version": "1.0.0", + "license": "ISC", + "dependencies": { + "@abaplint/cli": "^2.113.222", + "@abaplint/database-sqlite": "^2.11.78", + "@abaplint/runtime": "^2.12.2", + "@abaplint/transpiler-cli": "^2.12.2" + } + }, + "node_modules/@abaplint/cli": { + "version": "2.113.222", + "resolved": "https://registry.npmjs.org/@abaplint/cli/-/cli-2.113.222.tgz", + "integrity": "sha512-TkQK8KiqUjajwAgiKqumRI6FH6Ya304bYWySSTeICXxDzwjIRDG3Uf+ytKLy3YnMKHkabE5yo6tgYlJ0dlI00w==", + "license": "MIT", + "bin": { + "abaplint": "abaplint" + }, + "engines": { + "node": ">=12.0.0" + }, + "funding": { + "url": "https://github.com/sponsors/larshp" + } + }, + "node_modules/@abaplint/database-sqlite": { + "version": "2.11.78", + "resolved": "https://registry.npmjs.org/@abaplint/database-sqlite/-/database-sqlite-2.11.78.tgz", + "integrity": "sha512-1s5GhhwzcupKQhK2lZW7GKIvsz/WukgjuLk2oHmlSXWGFtapLYO9wJCtUSmSNTMNuXXaVt8ks2t2RH8SVj6hCg==", + "license": "MIT", + "dependencies": { + "sql.js": "^1.11.0" + } + }, + "node_modules/@abaplint/runtime": { + "version": "2.12.2", + "resolved": "https://registry.npmjs.org/@abaplint/runtime/-/runtime-2.12.2.tgz", + "integrity": "sha512-GSu9LQzb2PN7Zgw8ojiBLXQaI1xWx29jtu+ezhK9L8Qm/D0AU8jo+AsF9y6Wy1mldEmQcgM9goebfwuTucnIew==", + "license": "MIT", + "dependencies": { + "temporal-polyfill": "^0.3.0" + }, + "funding": { + "url": "https://github.com/sponsors/larshp" + } + }, + "node_modules/@abaplint/transpiler-cli": { + "version": "2.12.2", + "resolved": "https://registry.npmjs.org/@abaplint/transpiler-cli/-/transpiler-cli-2.12.2.tgz", + "integrity": "sha512-fj+mkRvwtWa86I5Ne53Gsapqvl7YkiGZrSeRP9kROthOO+rKrLLonBMdllF74C9Tdz38E+JIX3GwpdegBqER5w==", + "license": "MIT", + "bin": { + "abap_transpile": "abap_transpile" + }, + "funding": { + "url": "https://github.com/sponsors/larshp" + } + }, + "node_modules/sql.js": { + "version": "1.13.0", + "resolved": "https://registry.npmjs.org/sql.js/-/sql.js-1.13.0.tgz", + "integrity": "sha512-RJbVP1HRDlUUXahJ7VMTcu9Rm1Nzw+EBpoPr94vnbD4LwR715F3CcxE2G2k45PewcaZ57pjetYa+LoSJLAASgA==", + "license": "MIT" + }, + "node_modules/temporal-polyfill": { + "version": "0.3.0", + "resolved": "https://registry.npmjs.org/temporal-polyfill/-/temporal-polyfill-0.3.0.tgz", + "integrity": "sha512-qNsTkX9K8hi+FHDfHmf22e/OGuXmfBm9RqNismxBrnSmZVJKegQ+HYYXT+R7Ha8F/YSm2Y34vmzD4cxMu2u95g==", + "license": "MIT", + "dependencies": { + "temporal-spec": "0.3.0" + } + }, + "node_modules/temporal-spec": { + "version": "0.3.0", + "resolved": "https://registry.npmjs.org/temporal-spec/-/temporal-spec-0.3.0.tgz", + "integrity": "sha512-n+noVpIqz4hYgFSMOSiINNOUOMFtV5cZQNCmmszA6GiVFVRt3G7AqVyhXjhCSmowvQn+NsGn+jMDMKJYHd3bSQ==", + "license": "ISC" + } + } +} diff --git a/package.json b/package.json new file mode 100644 index 0000000..6d230ea --- /dev/null +++ b/package.json @@ -0,0 +1,32 @@ +{ + "name": "open-abap-xco", + "version": "1.0.0", + "description": "XCO", + "main": "index.js", + "scripts": { + "lint": "abaplint", + "unit": "rm -rf output && abap_transpile && echo RUNNING && node --expose-gc output/index.mjs && echo OK", + "flame": "0x -o -- node --expose-gc test/performance.mjs", + "performance": "rm -rf output && abap_transpile ./abap_transpile_test.json && node --expose-gc test/performance.mjs", + "integration": "rm -rf output && abap_transpile ./abap_transpile_test.json && node --expose-gc output/index.mjs", + "postgres:init": "cat test/adbc/init.sql | docker exec -i postgresql psql -U postgres -d postgres", + "docker:start": "docker compose -p open-abap -f test/stack.yml up -d --wait && npm run postgres:init", + "test": "npm run lint && npm run unit" + }, + "repository": { + "type": "git", + "url": "git+https://github.com/open-abap/open-abap-xco.git" + }, + "author": "", + "license": "ISC", + "bugs": { + "url": "https://github.com/open-abap/open-abap-xco/issues" + }, + "homepage": "https://github.com/open-abap/open-abap-xco#readme", + "dependencies": { + "@abaplint/cli": "^2.113.222", + "@abaplint/runtime": "^2.12.2", + "@abaplint/database-sqlite": "^2.11.78", + "@abaplint/transpiler-cli": "^2.12.2" + } +} diff --git a/setup.mjs b/setup.mjs new file mode 100644 index 0000000..e87b65f --- /dev/null +++ b/setup.mjs @@ -0,0 +1,8 @@ +import {SQLiteDatabaseClient} from "@abaplint/database-sqlite"; + +export async function setup(abap, schemas, insert) { + abap.context.databaseConnections["DEFAULT"] = new SQLiteDatabaseClient(); + await abap.context.databaseConnections["DEFAULT"].connect(); + await abap.context.databaseConnections["DEFAULT"].execute(schemas.sqlite); + await abap.context.databaseConnections["DEFAULT"].execute(insert); +} \ No newline at end of file diff --git a/src/if_xco_cp_software_component_f.intf.abap b/src/if_xco_cp_software_component_f.intf.abap new file mode 100644 index 0000000..5904ff4 --- /dev/null +++ b/src/if_xco_cp_software_component_f.intf.abap @@ -0,0 +1,10 @@ +INTERFACE if_xco_cp_software_component_f PUBLIC. + + METHODS + for_name + IMPORTING + iv_name TYPE if_xco_software_component=>tv_name + RETURNING + VALUE(ro_software_component) TYPE REF TO if_xco_software_component. + +ENDINTERFACE. \ No newline at end of file diff --git a/src/if_xco_cp_software_component_f.intf.xml b/src/if_xco_cp_software_component_f.intf.xml new file mode 100644 index 0000000..fadf9ff --- /dev/null +++ b/src/if_xco_cp_software_component_f.intf.xml @@ -0,0 +1,15 @@ + + + + + + IF_XCO_CP_SOFTWARE_COMPONENT_F + E + IF_XCO_CP_SOFTWARE_COMPONENT_F + 2 + 1 + X + + + + \ No newline at end of file diff --git a/src/if_xco_software_component.intf.abap b/src/if_xco_software_component.intf.abap new file mode 100644 index 0000000..0713ce3 --- /dev/null +++ b/src/if_xco_software_component.intf.abap @@ -0,0 +1,5 @@ +INTERFACE if_xco_software_component PUBLIC. + + TYPES tv_name TYPE c LENGTH 30. + +ENDINTERFACE. \ No newline at end of file diff --git a/src/if_xco_software_component.intf.xml b/src/if_xco_software_component.intf.xml new file mode 100644 index 0000000..002ac8c --- /dev/null +++ b/src/if_xco_software_component.intf.xml @@ -0,0 +1,15 @@ + + + + + + IF_XCO_SOFTWARE_COMPONENT + E + IF_XCO_SOFTWARE_COMPONENT + 2 + 1 + X + + + + \ No newline at end of file diff --git a/src/xco_cp_system.clas.abap b/src/xco_cp_system.clas.abap new file mode 100644 index 0000000..680f003 --- /dev/null +++ b/src/xco_cp_system.clas.abap @@ -0,0 +1,13 @@ +CLASS xco_cp_system DEFINITION PUBLIC. + PUBLIC SECTION. + CLASS-DATA software_component TYPE REF TO if_xco_cp_software_component_f READ-ONLY. + + CLASS-METHODS class_constructor. +ENDCLASS. + +CLASS xco_cp_system IMPLEMENTATION. + METHOD class_constructor. + CREATE OBJECT software_component TYPE lcl_software_component. + ENDMETHOD. + +ENDCLASS. \ No newline at end of file diff --git a/src/xco_cp_system.clas.locals.abap b/src/xco_cp_system.clas.locals.abap new file mode 100644 index 0000000..1898a28 --- /dev/null +++ b/src/xco_cp_system.clas.locals.abap @@ -0,0 +1,15 @@ +CLASS lcl_software_component DEFINITION. + PUBLIC SECTION. + INTERFACES if_xco_cp_software_component_f. + INTERFACES if_xco_software_component. + PROTECTED SECTION. + PRIVATE SECTION. +ENDCLASS. + +CLASS lcl_software_component IMPLEMENTATION. + + METHOD if_xco_cp_software_component_f~for_name. + CREATE OBJECT ro_software_component TYPE lcl_software_component. + ENDMETHOD. + +ENDCLASS. \ No newline at end of file diff --git a/src/xco_cp_system.clas.xml b/src/xco_cp_system.clas.xml new file mode 100644 index 0000000..8e9d625 --- /dev/null +++ b/src/xco_cp_system.clas.xml @@ -0,0 +1,16 @@ + + + + + + XCO_CP_SYSTEM + E + XCO_CP_SYSTEM + 1 + X + X + X + + + + \ No newline at end of file