@sap/async-xsjs 1.0.2

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.
Files changed (178) hide show
  1. package/CHANGELOG.md +26 -0
  2. package/LICENSE +37 -0
  3. package/README.md +445 -0
  4. package/differences.md +162 -0
  5. package/docs/$.Application.html +262 -0
  6. package/docs/$.Session.html +674 -0
  7. package/docs/$.db.CallableStatement.html +2524 -0
  8. package/docs/$.db.Connection.html +511 -0
  9. package/docs/$.db.ParameterMetaData.html +805 -0
  10. package/docs/$.db.PreparedStatement.html +1796 -0
  11. package/docs/$.db.ResultSet.html +1308 -0
  12. package/docs/$.db.ResultSetMetaData.html +800 -0
  13. package/docs/$.db.SQLException.html +259 -0
  14. package/docs/$.db.html +773 -0
  15. package/docs/$.hdb.ColumnMetadata.html +438 -0
  16. package/docs/$.hdb.Connection.html +663 -0
  17. package/docs/$.hdb.ProcedureResult.html +280 -0
  18. package/docs/$.hdb.ResultSet.html +324 -0
  19. package/docs/$.hdb.ResultSetIterator.html +315 -0
  20. package/docs/$.hdb.ResultSetMetaData.html +259 -0
  21. package/docs/$.hdb.SQLException.html +259 -0
  22. package/docs/$.hdb.html +557 -0
  23. package/docs/$.html +471 -0
  24. package/docs/$.jobs.Job.html +783 -0
  25. package/docs/$.jobs.JobLog.html +380 -0
  26. package/docs/$.jobs.JobSchedules.html +852 -0
  27. package/docs/$.jobs.html +238 -0
  28. package/docs/$.net.Destination.html +304 -0
  29. package/docs/$.net.Mail.Part.html +510 -0
  30. package/docs/$.net.Mail.html +504 -0
  31. package/docs/$.net.SMTPConnection.html +347 -0
  32. package/docs/$.net.html +749 -0
  33. package/docs/$.net.http.Client.html +562 -0
  34. package/docs/$.net.http.Destination.html +237 -0
  35. package/docs/$.net.http.Request.html +567 -0
  36. package/docs/$.net.http.html +292 -0
  37. package/docs/$.security.AntiVirus.html +361 -0
  38. package/docs/$.security.Store.html +636 -0
  39. package/docs/$.security.crypto.html +414 -0
  40. package/docs/$.security.html +247 -0
  41. package/docs/$.security.x509.html +373 -0
  42. package/docs/$.text.analysis.Session.html +983 -0
  43. package/docs/$.text.analysis.html +242 -0
  44. package/docs/$.text.html +246 -0
  45. package/docs/$.text.mining.Session.html +2018 -0
  46. package/docs/$.text.mining.html +242 -0
  47. package/docs/$.trace.html +525 -0
  48. package/docs/$.util.SAXParser.html +955 -0
  49. package/docs/$.util.Zip.html +474 -0
  50. package/docs/$.util.codec.html +414 -0
  51. package/docs/$.util.compression.html +357 -0
  52. package/docs/$.util.html +325 -0
  53. package/docs/$.util.sql.html +290 -0
  54. package/docs/$.web.Body.html +333 -0
  55. package/docs/$.web.EntityList.html +296 -0
  56. package/docs/$.web.TupelList.html +496 -0
  57. package/docs/$.web.WebEntityRequest.html +393 -0
  58. package/docs/$.web.WebEntityResponse.html +392 -0
  59. package/docs/$.web.WebRequest.html +560 -0
  60. package/docs/$.web.WebResponse.html +609 -0
  61. package/docs/$.web.html +246 -0
  62. package/docs/Copyright-SAP.html +39 -0
  63. package/docs/Disclaimer-SAP.html +55 -0
  64. package/docs/index.html +232 -0
  65. package/docs/styles/jsdoc-default.css +382 -0
  66. package/lib/AppConfig.js +36 -0
  67. package/lib/AuditLogger.js +41 -0
  68. package/lib/cacert.js +26 -0
  69. package/lib/ctypes.js +153 -0
  70. package/lib/destinations/dest-provider.js +57 -0
  71. package/lib/index.js +235 -0
  72. package/lib/jobs/Action.js +40 -0
  73. package/lib/jobs/Job.js +100 -0
  74. package/lib/jobs/JobManager.js +150 -0
  75. package/lib/jobs/JobsRuntime.js +133 -0
  76. package/lib/jobs/SqlScriptJobRunner.js +36 -0
  77. package/lib/jobs/XsjsJobRunner.js +78 -0
  78. package/lib/jobs/index.js +11 -0
  79. package/lib/logging.js +16 -0
  80. package/lib/middleware.js +125 -0
  81. package/lib/odata/ODataService.js +125 -0
  82. package/lib/odata/index.js +7 -0
  83. package/lib/odata/service-factory.js +26 -0
  84. package/lib/passport-noauth.js +17 -0
  85. package/lib/routes.js +115 -0
  86. package/lib/runtime.js +740 -0
  87. package/lib/sandbox.js +40 -0
  88. package/lib/utils/XsJsFunctionRunner.js +57 -0
  89. package/lib/utils/XsJsLibFunctionRunner.js +57 -0
  90. package/lib/utils/buffer-utils.js +77 -0
  91. package/lib/utils/compression-utils.js +14 -0
  92. package/lib/utils/date-utils.js +104 -0
  93. package/lib/utils/errors/HttpError.js +20 -0
  94. package/lib/utils/errors/wrap-app-error.js +18 -0
  95. package/lib/utils/index.js +17 -0
  96. package/lib/utils/xs-function-runner.js +51 -0
  97. package/lib/utils/xs-types.js +21 -0
  98. package/lib/utils/xspath.js +36 -0
  99. package/lib/utils/xsstack.js +28 -0
  100. package/lib/views/error.html +28 -0
  101. package/lib/xsjs/Application.js +28 -0
  102. package/lib/xsjs/Locale.js +53 -0
  103. package/lib/xsjs/Session.js +31 -0
  104. package/lib/xsjs/constants.js +71 -0
  105. package/lib/xsjs/db/common/DbBase.js +85 -0
  106. package/lib/xsjs/db/common/DbOptions.js +163 -0
  107. package/lib/xsjs/db/common/arguments-validation.js +102 -0
  108. package/lib/xsjs/db/common/connection.js +12 -0
  109. package/lib/xsjs/db/common/enums.js +93 -0
  110. package/lib/xsjs/db/common/execute-batch.js +38 -0
  111. package/lib/xsjs/db/common/parse-time.js +139 -0
  112. package/lib/xsjs/db/dbapi/CallableStatement.js +192 -0
  113. package/lib/xsjs/db/dbapi/Connection.js +78 -0
  114. package/lib/xsjs/db/dbapi/DB.js +39 -0
  115. package/lib/xsjs/db/dbapi/ParameterMetaData.js +118 -0
  116. package/lib/xsjs/db/dbapi/PreparedStatement.js +78 -0
  117. package/lib/xsjs/db/dbapi/ResultSet.js +220 -0
  118. package/lib/xsjs/db/dbapi/ResultSetMetaData.js +116 -0
  119. package/lib/xsjs/db/dbapi/Statement.js +514 -0
  120. package/lib/xsjs/db/dbapi/conversions.js +113 -0
  121. package/lib/xsjs/db/dbapi/fetch-rows.js +32 -0
  122. package/lib/xsjs/db/hdbapi/Connection.js +525 -0
  123. package/lib/xsjs/db/hdbapi/HDB.js +32 -0
  124. package/lib/xsjs/db/hdbapi/ResultSetIterator.js +40 -0
  125. package/lib/xsjs/db/hdbapi/convert.js +77 -0
  126. package/lib/xsjs/db/hdbapi/table-string-parser.js +52 -0
  127. package/lib/xsjs/db/index.js +4 -0
  128. package/lib/xsjs/index.js +13 -0
  129. package/lib/xsjs/jobs/Job.js +228 -0
  130. package/lib/xsjs/jobs/Jobs.js +11 -0
  131. package/lib/xsjs/jobs/Logs.js +127 -0
  132. package/lib/xsjs/jobs/Schedule.js +110 -0
  133. package/lib/xsjs/jobs/Schedules.js +108 -0
  134. package/lib/xsjs/net/Destination.js +43 -0
  135. package/lib/xsjs/net/http/Client.js +220 -0
  136. package/lib/xsjs/net/http/HTTP.js +72 -0
  137. package/lib/xsjs/net/index.js +5 -0
  138. package/lib/xsjs/net/smtp/Mail.js +38 -0
  139. package/lib/xsjs/net/smtp/Part.js +30 -0
  140. package/lib/xsjs/net/smtp/SMTPConnection.js +39 -0
  141. package/lib/xsjs/net/smtp/index.js +18 -0
  142. package/lib/xsjs/net/smtp/nodemailer-util.js +77 -0
  143. package/lib/xsjs/require.js +39 -0
  144. package/lib/xsjs/security/AntiVirus.js +31 -0
  145. package/lib/xsjs/security/Store.js +119 -0
  146. package/lib/xsjs/security/crypto.js +23 -0
  147. package/lib/xsjs/security/index.js +5 -0
  148. package/lib/xsjs/security/x509.js +12 -0
  149. package/lib/xsjs/text/analysis/Session.js +128 -0
  150. package/lib/xsjs/text/index.js +30 -0
  151. package/lib/xsjs/text/mining/Session.js +82 -0
  152. package/lib/xsjs/trace/trace.js +41 -0
  153. package/lib/xsjs/util/SAXParser.js +174 -0
  154. package/lib/xsjs/util/Zip.js +220 -0
  155. package/lib/xsjs/util/codec.js +33 -0
  156. package/lib/xsjs/util/compression.js +24 -0
  157. package/lib/xsjs/util/index.js +22 -0
  158. package/lib/xsjs/web/BasicWebEntity.js +41 -0
  159. package/lib/xsjs/web/EntityList.js +11 -0
  160. package/lib/xsjs/web/TupelLists/CookiesTupelList.js +47 -0
  161. package/lib/xsjs/web/TupelLists/HeadersTupelList.js +55 -0
  162. package/lib/xsjs/web/TupelLists/ParametersTupelList.js +83 -0
  163. package/lib/xsjs/web/TupelLists/TupelListBase.js +45 -0
  164. package/lib/xsjs/web/WebBody.js +135 -0
  165. package/lib/xsjs/web/WebEntityRequest.js +40 -0
  166. package/lib/xsjs/web/WebEntityResponse.js +26 -0
  167. package/lib/xsjs/web/WebRequest.js +209 -0
  168. package/lib/xsjs/web/WebResponse.js +183 -0
  169. package/lib/xsjs/web/index.js +4 -0
  170. package/lib/xsjs/web/utils/HeadersParser.js +53 -0
  171. package/lib/xsjs/web/utils/HttpRequestParser.js +93 -0
  172. package/lib/xsjs/web/utils/MultipartParser.js +163 -0
  173. package/lib/xsjs/web/utils/MultipartResponseBuilder.js +73 -0
  174. package/lib/xsjs/web/utils/SetCookieParser.js +32 -0
  175. package/lib/xsjslib/TextBundleWrapper.js +46 -0
  176. package/lib/xsjslib/index.js +11 -0
  177. package/npm-shrinkwrap.json +11540 -0
  178. package/package.json +84 -0
package/CHANGELOG.md ADDED
@@ -0,0 +1,26 @@
1
+ # Change Log
2
+ All notable changes to this project will be documented in this file.
3
+
4
+ This project adheres to [Semantic Versioning](http://semver.org/).
5
+
6
+ The format is based on [Keep a Changelog](http://keepachangelog.com/).
7
+
8
+ <a name="1.0.2"></a>
9
+ ## 1.0.2 - 2023-01-31
10
+
11
+ ### Updated
12
+ - Updated xsodata to v8.0.2
13
+
14
+ ### Fixed
15
+ - Way to require method isString from lodash
16
+
17
+ <a name="1.0.1"></a>
18
+ ## 1.0.1 - 2023-01-30
19
+
20
+ ### Added
21
+ - Docs folder
22
+
23
+ <a name="1.0.0"></a>
24
+ ## 1.0.0 - 2023-01-26
25
+
26
+ ### Initial release
package/LICENSE ADDED
@@ -0,0 +1,37 @@
1
+ SAP DEVELOPER LICENSE AGREEMENT
2
+
3
+ Version 3.1
4
+
5
+ Please scroll down and read the following Developer License Agreement carefully ("Developer Agreement"). By clicking "I Accept" or by attempting to download, or install, or use the SAP software and other materials that accompany this Developer Agreement ("SAP Materials"), You agree that this Developer Agreement forms a legally binding agreement between You ("You" or "Your") and SAP SE, for and on behalf of itself and its subsidiaries and affiliates (as defined in Section 15 of the German Stock Corporation Act) and You agree to be bound by all of the terms and conditions stated in this Developer Agreement. If You are trying to access or download the SAP Materials on behalf of Your employer or as a consultant or agent of a third party (either "Your Company"), You represent and warrant that You have the authority to act on behalf of and bind Your Company to the terms of this Developer Agreement and everywhere in this Developer Agreement that refers to 'You' or 'Your' shall also include Your Company. If You do not agree to these terms, do not click "I Accept", and do not attempt to access or use the SAP Materials.
6
+
7
+ 1. LICENSE: SAP grants You a non-exclusive, non-transferable, non-sublicensable, revocable, limited use license to copy, reproduce and distribute the application programming interfaces ("API"), documentation, plug-ins, templates, scripts and sample code ("Tools") on a desktop, laptop, tablet, smart phone, or other appropriate computer device that You own or control (any, a "Computer") to create new applications ("Customer Applications"). You agree that the Customer Applications will not: (a) unreasonably impair, degrade or reduce the performance or security of any SAP software applications, services or related technology ("Software"); (b) enable the bypassing or circumventing of SAP's license restrictions and/or provide users with access to the Software to which such users are not licensed; (c) render or provide, without prior written consent from SAP, any information concerning SAP software license terms, Software, or any other information related to SAP products; or (d) permit mass data extraction from an SAP product to a non-SAP product, including use, modification, saving or other processing of such data in the non-SAP product. In exchange for the right to develop Customer Applications under this Agreement, You covenant not to assert any Intellectual Property Rights in Customer Applications created by You against any SAP product, service, or future SAP development.
8
+
9
+ 2. INTELLECTUAL PROPERTY: (a) SAP or its licensors retain all ownership and intellectual property rights in the APIs, Tools and Software. You may not: a) remove or modify any marks or proprietary notices of SAP, b) provide or make the APIs, Tools or Software available to any third party, c) assign this Developer Agreement or give or transfer the APIs, Tools or Software or an interest in them to another individual or entity, d) decompile, disassemble or reverse engineer (except to the extent permitted by applicable law) the APIs Tools or Software, (e) create derivative works of or based on the APIs, Tools or Software, (f) use any SAP name, trademark or logo, or (g) use the APIs or Tools to modify existing Software or other SAP product functionality or to access the Software or other SAP products' source code or metadata.
10
+ (b) Subject to SAP's underlying rights in any part of the APIs, Tools or Software, You retain all ownership and intellectual property rights in Your Customer Applications.
11
+
12
+ 3. FREE AND OPEN SOURCE COMPONENTS: The SAP Materials may include certain third party free or open source components ("FOSS Components"). You may have additional rights in such FOSS Components that are provided by the third party licensors of those components.
13
+
14
+ 4. THIRD PARTY DEPENDENCIES: The SAP Materials may require certain third party software dependencies ("Dependencies") for the use or operation of such SAP Materials. These dependencies may be identified by SAP in Maven POM files, product documentation or by other means. SAP does not grant You any rights in or to such Dependencies under this Developer Agreement. You are solely responsible for the acquisition, installation and use of Dependencies. SAP DOES NOT MAKE ANY REPRESENTATIONS OR WARRANTIES IN RESPECT OF DEPENDENCIES, INCLUDING BUT NOT LIMITED TO IMPLIED WARRANTIES OF MERCHANTABILITY AND OF FITNESS FOR A PARTICULAR PURPOSE. IN PARTICULAR, SAP DOES NOT WARRANT THAT DEPENDENCIES WILL BE AVAILABLE, ERROR FREE, INTEROPERABLE WITH THE SAP MATERIALS, SUITABLE FOR ANY PARTICULAR PURPOSE OR NON-INFRINGING. YOU ASSUME ALL RISKS ASSOCIATED WITH THE USE OF DEPENDENCIES, INCLUDING WITHOUT LIMITATION RISKS RELATING TO QUALITY, AVAILABILITY, PERFORMANCE, DATA LOSS, UTILITY IN A PRODUCTION ENVIRONMENT, AND NON-INFRINGEMENT. IN NO EVENT WILL SAP BE LIABLE DIRECTLY OR INDIRECTLY IN RESPECT OF ANY USE OF DEPENDENCIES BY YOU.
15
+
16
+
17
+ 5. WARRANTY:
18
+ a) If You are located outside the US or Canada: AS THE API AND TOOLS ARE PROVIDED TO YOU FREE OF CHARGE, SAP DOES NOT GUARANTEE OR WARRANT ANY FEATURES OR QUALITIES OF THE TOOLS OR API OR GIVE ANY UNDERTAKING WITH REGARD TO ANY OTHER QUALITY. NO SUCH WARRANTY OR UNDERTAKING SHALL BE IMPLIED BY YOU FROM ANY DESCRIPTION IN THE API OR TOOLS OR ANY AVAILABLE DOCUMENTATION OR ANY OTHER COMMUNICATION OR ADVERTISEMENT. IN PARTICULAR, SAP DOES NOT WARRANT THAT THE SOFTWARE WILL BE AVAILABLE UNINTERRUPTED, ERROR FREE, OR PERMANENTLY AVAILABLE. FOR THE TOOLS AND API ALL WARRANTY CLAIMS ARE SUBJECT TO THE LIMITATION OF LIABILITY STIPULATED IN SECTION 4 BELOW.
19
+ b) If You are located in the US or Canada: THE API AND TOOLS ARE LICENSED TO YOU "AS IS", WITHOUT ANY WARRANTY, ESCROW, TRAINING, MAINTENANCE, OR SERVICE OBLIGATIONS WHATSOEVER ON THE PART OF SAP. SAP MAKES NO EXPRESS OR IMPLIED WARRANTIES OR CONDITIONS OF SALE OF ANY TYPE WHATSOEVER, INCLUDING BUT NOT LIMITED TO IMPLIED WARRANTIES OF MERCHANTABILITY AND OF FITNESS FOR A PARTICULAR PURPOSE. IN PARTICULAR, SAP DOES NOT WARRANT THAT THE SOFTWARE WILL BE AVAILABLE UNINTERRUPTED, ERROR FREE, OR PERMANENTLY AVAILABLE. YOU ASSUME ALL RISKS ASSOCIATED WITH THE USE OF THE API AND TOOLS, INCLUDING WITHOUT LIMITATION RISKS RELATING TO QUALITY, AVAILABILITY, PERFORMANCE, DATA LOSS, AND UTILITY IN A PRODUCTION ENVIRONMENT.
20
+
21
+ 6. LIMITATION OF LIABILITY:
22
+ a) If You are located outside the US or Canada: IRRESPECTIVE OF THE LEGAL REASONS, SAP SHALL ONLY BE LIABLE FOR DAMAGES UNDER THIS AGREEMENT IF SUCH DAMAGE (I) CAN BE CLAIMED UNDER THE GERMAN PRODUCT LIABILITY ACT OR (II) IS CAUSED BY INTENTIONAL MISCONDUCT OF SAP OR (III) CONSISTS OF PERSONAL INJURY. IN ALL OTHER CASES, NEITHER SAP NOR ITS EMPLOYEES, AGENTS AND SUBCONTRACTORS SHALL BE LIABLE FOR ANY KIND OF DAMAGE OR CLAIMS HEREUNDER.
23
+ b) If You are located in the US or Canada: IN NO EVENT SHALL SAP BE LIABLE TO YOU, YOUR COMPANY OR TO ANY THIRD PARTY FOR ANY DAMAGES IN AN AMOUNT IN EXCESS OF $100 ARISING IN CONNECTION WITH YOUR USE OF OR INABILITY TO USE THE TOOLS OR API OR IN CONNECTION WITH SAP'S PROVISION OF OR FAILURE TO PROVIDE SERVICES PERTAINING TO THE TOOLS OR API, OR AS A RESULT OF ANY DEFECT IN THE API OR TOOLS. THIS DISCLAIMER OF LIABILITY SHALL APPLY REGARDLESS OF THE FORM OF ACTION THAT MAY BE BROUGHT AGAINST SAP, WHETHER IN CONTRACT OR TORT, INCLUDING WITHOUT LIMITATION ANY ACTION FOR NEGLIGENCE. YOUR SOLE REMEDY IN THE EVENT OF BREACH OF THIS DEVELOPER AGREEMENT BY SAP OR FOR ANY OTHER CLAIM RELATED TO THE API OR TOOLS SHALL BE TERMINATION OF THIS AGREEMENT. NOTWITHSTANDING ANYTHING TO THE CONTRARY HEREIN, UNDER NO CIRCUMSTANCES SHALL SAP AND ITS LICENSORS BE LIABLE TO YOU OR ANY OTHER PERSON OR ENTITY FOR ANY SPECIAL, INCIDENTAL, CONSEQUENTIAL, OR INDIRECT DAMAGES, LOSS OF GOOD WILL OR BUSINESS PROFITS, WORK STOPPAGE, DATA LOSS, COMPUTER FAILURE OR MALFUNCTION, ANY AND ALL OTHER COMMERCIAL DAMAGES OR LOSS, OR EXEMPLARY OR PUNITIVE DAMAGES.
24
+
25
+ 7. INDEMNITY: You will fully indemnify, hold harmless and defend SAP against law suits based on any claim: (a) that any Customer Application created by You infringes or misappropriates any patent, copyright, trademark, trade secrets, or other proprietary rights of a third party, or (b) related to Your alleged violation of the terms of this Developer Agreement.
26
+
27
+ 8. EXPORT: The Tools and API are subject to German, EU and US export control regulations. You confirm that: a) You will not use the Tools or API for, and will not allow the Tools or API to be used for, any purposes prohibited by German, EU and US law, including, without limitation, for the development, design, manufacture or production of nuclear, chemical or biological weapons of mass destruction; b) You are not located in Cuba, Iran, Sudan, Iraq, North Korea, Syria, nor any other country to which the United States has prohibited export or that has been designated by the U.S. Government as a "terrorist supporting" country (any, an "US Embargoed Country"); c) You are not a citizen, national or resident of, and are not under the control of, a US Embargoed Country; d) You will not download or otherwise export or re-export the API or Tools, directly or indirectly, to a US Embargoed Country nor to citizens, nationals or residents of a US Embargoed Country; e) You are not listed on the United States Department of Treasury lists of Specially Designated Nationals, Specially Designated Terrorists, and Specially Designated Narcotic Traffickers, nor listed on the United States Department of Commerce Table of Denial Orders or any other U.S. government list of prohibited or restricted parties and f) You will not download or otherwise export or re-export the API or Tools , directly or indirectly, to persons on the above-mentioned lists.
28
+
29
+ 9. SUPPORT: Other than what is made available on the SAP Community Website (SCN) by SAP at its sole discretion and by SCN members, SAP does not offer support for the API or Tools which are the subject of this Developer Agreement.
30
+
31
+ 10. TERM AND TERMINATION: You may terminate this Developer Agreement by destroying all copies of the API and Tools on Your Computer(s). SAP may terminate Your license to use the API and Tools immediately if You fail to comply with any of the terms of this Developer Agreement, or, for SAP's convenience by providing you with ten (10) day's written notice of termination (including email). In case of termination or expiration of this Developer Agreement, You must destroy all copies of the API and Tools immediately. In the event Your Company or any of the intellectual property you create using the API, Tools or Software are acquired (by merger, purchase of stock, assets or intellectual property or exclusive license), or You become employed, by a direct competitor of SAP, then this Development Agreement and all licenses granted in this Developer Agreement shall immediately terminate upon the date of such acquisition.
32
+
33
+ 11. LAW/VENUE:
34
+ a) If You are located outside the US or Canada: This Developer Agreement is governed by and construed in accordance with the laws of the Germany. You and SAP agree to submit to the exclusive jurisdiction of, and venue in, the courts of Karlsruhe in Germany in any dispute arising out of or relating to this Developer Agreement.
35
+ b) If You are located in the US or Canada: This Developer Agreement shall be governed by and construed under the Commonwealth of Pennsylvania law without reference to its conflicts of law principles. In the event of any conflicts between foreign law, rules, and regulations, and United States of America law, rules, and regulations, United States of America law, rules, and regulations shall prevail and govern. The United Nations Convention on Contracts for the International Sale of Goods shall not apply to this Developer Agreement. The Uniform Computer Information Transactions Act as enacted shall not apply.
36
+
37
+ 12. MISCELLANEOUS: This Developer Agreement is the complete agreement for the API and Tools licensed (including reference to information/documentation contained in a URL). This Developer Agreement supersedes all prior or contemporaneous agreements or representations with regards to the subject matter of this Developer Agreement. If any term of this Developer Agreement is found to be invalid or unenforceable, the surviving provisions shall remain effective. SAP's failure to enforce any right or provisions stipulated in this Developer Agreement will not constitute a waiver of such provision, or any other provision of this Developer Agreement.
package/README.md ADDED
@@ -0,0 +1,445 @@
1
+ @sap/async-xsjs
2
+ ===========
3
+
4
+ Asynchronous compatibility layer for SAP HANA XS applications running on Node.js 16 and higher.
5
+ <!-- toc -->
6
+
7
+ - [Usage](#usage)
8
+ * [Options](#options)
9
+ + [hana](#hana)
10
+ + [secureStore](#securestore)
11
+ + [formData](#formdata)
12
+ + [mail](#mail)
13
+ + [destinationProvider](#destinationprovider)
14
+ + [auditLog](#auditlog)
15
+ + [context](#context)
16
+ + [libraryCache](#librarycache)
17
+ + [Multitenant usage](#multitenant-usage)
18
+ - [OData support](#odata-support)
19
+ * [Clear OData model cache](#clear-odata-model-cache)
20
+ - [NPM packages support](#npm-packages-support)
21
+ - [Destinations support](#destinations-support)
22
+ + [Via user provided services](#via-user-provided-services)
23
+ + [Via custom provider function](#via-custom-provider-function)
24
+ - [Accessing column values by index in *$.hdb.ResultSet* rows](#accessing-column-values-by-index-in-hdbresultset-rows)
25
+ - [Tracing via *$.trace* API](#tracing-via-trace-api)
26
+ - [Troubleshooting](#troubleshooting)
27
+ - [Differences with SAP HANA XS Classic](#differences-with-hana-xs-classic)
28
+
29
+ <!-- tocstop -->
30
+
31
+ For the API of the XS Engine:
32
+ * [SAP HANA XS JavaScript Reference](http://help.sap.com/hana/SAP_HANA_XS_JavaScript_API_Reference_en/)
33
+
34
+
35
+ ## Usage
36
+
37
+ ```js
38
+ 'use strict';
39
+
40
+ var xsenv = require('@sap/xsenv');
41
+ var async_xsjs = require('@sap/async-xsjs');
42
+
43
+ var port = process.env.PORT || 3000;
44
+ var options = xsenv.getServices({
45
+ uaa: 'xsuaa',
46
+ hana: 'hana-hdi',
47
+ jobs: 'scheduler',
48
+ mail: 'mail',
49
+ secureStore: 'secureStore',
50
+ auditLog: 'audit-log'
51
+ });
52
+ var xsjs_server = await async_xsjs(options);
53
+ await xsjs_server.listen(port);
54
+
55
+ console.log('Node XS server listening on port %d', port);
56
+ ```
57
+
58
+ The starting function takes an object that contains service credentials and application options.
59
+
60
+ You need to set up the Application Router for authentication.
61
+ To learn how, see:
62
+ [Configure the XS Advanced Application Router](https://help.sap.com/docs/SAP_HANA_PLATFORM/4505d0bdaf4948449b7f7379d24d0f0d/6ba89596e3a64a5480c3977d4ea7fdba.html)
63
+
64
+ For local testing, you can set `options.anonymous = true` to disable authentication.
65
+
66
+ ### Options
67
+
68
+ Here is a list of options you can provide:
69
+
70
+ | property | default | usage |
71
+ | -------- | ------- | ----- |
72
+ | rootDir | 'lib' | XSJS files location |
73
+ | rootDirs | | Same as above but array of directories can be provided. Overrides `rootDir` if provided. |
74
+ | uaa | | UAA configuration necessary to enable JWT token authentication and business user propagation to SAP HANA |
75
+ | [hana](#hana) | | Object containing SAP HANA DB connection parameters - used for DB connectivity |
76
+ | [secureStore](#secureStore) | | Object containing SAP HANA DB connection parameters - used for secure store connectivity |
77
+ | jobs | | Job Scheduler connection parameters - used for registering jobs during application startup, and later for updating job execution status when the job is finished |
78
+ | [mail](#mail) | | Mail options - used by $.net.Mail API |
79
+ | maxBodySize | '1mb' | Maximum body size accepted by _async-xsjs_. The value is passed to the [bytes library](https://www.npmjs.com/package/bytes) for parsing. |
80
+ | anonymous | false | Enables anonymous access - without credentials |
81
+ | [formData](#formdata) | | Special restrictions over form-data submitted to server |
82
+ | [destinationProvider](#destinationProvider) | | Custom function, synchronous or asynchronous, to be used when $.net.http.readDestination is called in the XSJS code. For more information on destination support, check the detailed description for this configuration option. |
83
+ | ca | certificates listed in the `XS_CACERT_PATH` env variable | Trusted SSL certificates for any outgoing HTTPS connections. Should be an array of loaded certificates. |
84
+ | compression | true | By default, text resources over 1K are compressed. |
85
+ | [auditLog](#auditlog) | | Object containing Audit Log service credentials. If not provided, audit logging will be disabled. If set to `{ logToConsole: true }` Audit Log messages will be written to the console (only suitable for non-productive setup, e.g. local development).|
86
+ | [context](#context) | {} | Extends the default context in `.xsjs` scripts |
87
+ | [libraryCache](#librarycache) | {} | Contains the `.xsjslibs` that should be cached |
88
+ | redirectUrl | | If specified, a redirect to this URL is triggered when the root path is requested. <br> **Note**: When _async-xsjs_ is performed behind a reverse proxy (for example, Application Router), the value of this property should be aligned with the path rewriting rules that may apply. |
89
+ | xsApplicationUser | true | If set to false, the session variable `XS_APPLICATIONUSER` will not be set. |
90
+
91
+ **Note:** When there are several `rootDirs` (for example, **repo1** and **repo2**) and their file structures are identical (_/repo1/hello.xsjs_ and _/repo2/hello.xsjs_), then:
92
+ * The file from the first directory, as listed in the `rootDirs` property, will be used (_/repo1/hello.xsjs_).
93
+ * The file from the second directory (_/repo2/hello.xsjs_) will be ignored with a warning message in the logs.
94
+
95
+ SAP HANA XS Advanced applications connect to SAP HANA with a fixed technical user provided via a Cloud Foundry service (environment variables). The actual (business) user of the application is retrieved from the JWT token and propagated to SAP HANA.
96
+
97
+ The connection to the Job Scheduler service is done by using a fixed technical user provided by the Cloud Foundry service binding.
98
+
99
+
100
+ #### hana
101
+
102
+ | property | mandatory | usage |
103
+ | -------- | ----- | -------- |
104
+ | host | x | DB host |
105
+ | port | x | DB port |
106
+ | user | x | Technical user used for a DB connection |
107
+ | password | x | Technical user password |
108
+ | schema | | If provided, it will be set as a current schema to DB connection |
109
+ | connectWithLoggedUser | | Possible values are `true` / `false`. Default is `false`. If provided, the DB connection will be done with the SAML assertion contained in the JWT token of the logged user. <br> **Note:** This option is provided only for the SAP HANA cockpit transition to SAP HANA XS Advanced. In general, this option should be avoided. |
110
+ | sqlcc | | Object containing all SQLCC configurations as properties with name after SQLCC name used in the XSJS code |
111
+ | ca | | Trusted SSL certificates explicitly for SAP HANA connection. Should be an array of loaded certificates. If not provided, certificate from the service binding will be used. If none are available, SAP HANA connection will not be encrypted. |
112
+
113
+ - `sqlcc` - referring to the example above. SQLCC property can be initialized from the bound services like this:
114
+
115
+ ```js
116
+ ...
117
+ options.hana.sqlcc = xsenv.getServices({
118
+ 'com.sap.my.sqlcc_config': 'SQLCC__NAME',
119
+ 'com.sap.my.other_sqlcc_config': 'OTHER_SQLCC_UPS_NAME'
120
+ });
121
+ ...
122
+ ```
123
+
124
+ and later used in an XSJS code like:
125
+ ```js
126
+ var connection = await $.db.getConnection('com.sap.my.sqlcc_config');
127
+ ```
128
+
129
+
130
+ #### secureStore
131
+
132
+ | property | mandatory | usage |
133
+ | -------- | ----- | -------- |
134
+ | host | x | DB host |
135
+ | port | x | DB port |
136
+ | user | x | Technical user used for DB connection |
137
+ | password | x | Technical user password |
138
+ | schema | | If provided, it will be set as a current schema to DB connection |
139
+
140
+
141
+
142
+ #### formData
143
+
144
+ Object with the following properties:
145
+
146
+ | property | default | usage |
147
+ | -------- | ------- | ----- |
148
+ | maxFilesSizeInBytes | `10485760` | It restricts the total size of all uploaded files. |
149
+
150
+
151
+ #### mail
152
+
153
+ Object with the following properties:
154
+
155
+ | property | mandatory | usage |
156
+ | -------- | ----- | -------- |
157
+ | host | x | SMTP server host |
158
+ | port | x | SMTP server port |
159
+ | ignoreTLS | | Can be `true` or `false`. Represents whether a STARTTLS command should be invoked, if available by the mail server. Default: `false` |
160
+ | secure | | Can be `true` or `false`. Represents whether the connection should be over TLS/SSL. Default: `false` |
161
+ | connectionTimeout | | Connection timeout in ms. Default: 60000 |
162
+ | authMethod | | Authentication method to use. Can be: `'PLAIN'` / `'LOGIN'` / `'CRAM-MD5'` |
163
+ | auth | | Authentication credentials. Example: `{user: 'user', pass: 'pass'}` Default: no authentication |
164
+
165
+
166
+ #### destinationProvider
167
+
168
+ If your application requires different mechanism for destination configuration - for example, dynamic configuration changes or dynamically adding new destinations to your application - you can provide your own function that retrieves these configurations from your storage.
169
+
170
+ For convenience, we support synchronous and asynchronous destination provider function. Depending on the number of parameters your function has, we call it synchronously or asynchronously.
171
+
172
+ Here are the signatures for both:
173
+
174
+ ```js
175
+ function getDestinationSync(packagename, objectname, dtDescriptor) {
176
+ }
177
+
178
+ function getDestinationAsync(packagename, objectname, dtDescriptor, callback) {
179
+ }
180
+ ```
181
+
182
+
183
+ | parameter | description |
184
+ | -------- | --------- |
185
+ | packagename | The package of the destination supplied to `$.net.http.readDestination` |
186
+ | objectname | The object name of the destination supplied to `$.net.http.readDestination` |
187
+ | dtDescriptor | Object containing all properties contained in the corresponding `.xshttpdest` file, if such file is available. Otherwise - __undefined__. |
188
+ | callback | Provided only in the asynchronous case - should be called by your provider function to return the destination or report an error. |
189
+
190
+ #### auditLog
191
+
192
+ This package generates audit log entries in the following cases:
193
+ - When the validation of the incoming JWT token fails
194
+ - When the token in the request used to trigger a job does not contain the required scope
195
+
196
+ Applications can also write audit log messages:
197
+
198
+ ```js
199
+ var async_xsjs = require('@sap/async-xsjs');
200
+ var xsenv = require('@sap/xsenv');
201
+ var auditLogging = require('@sap/audit-logging');
202
+
203
+ var port = process.env.PORT || 3000;
204
+ var options = xsenv.getServices({ auditLog: 'audit-log', uaa: 'xsuaa', hana: 'hana-hdi' });
205
+
206
+ // Using Audit Log REST API v2
207
+ var auditLog = await auditLogging.v2(options.auditLog);
208
+ options.context = { auditLog: auditLog };
209
+ (await async_xsjs(options)).listen(port);
210
+ ```
211
+
212
+ It is recommended to use Audit Log REST API v2.
213
+ For more information, refer to the documentation of the _@sap/audit-logging_ package.
214
+
215
+ The audit log client object can then be used as following:
216
+
217
+ ```js
218
+ await auditLog
219
+ .securityMessage('Content of the message')
220
+ .by($.session.getUsername())
221
+ .log();
222
+ ```
223
+
224
+ **Note**: `$.session.getUsername()` returns `undefined` in case `anonymous` mode is used. It is up to applications whether to use another string as a user or not to audit log at all.
225
+
226
+
227
+ #### context
228
+
229
+ This option can be used if you want to extend the XSJS scripts with additional global variables.
230
+
231
+ Example:
232
+
233
+ ```js
234
+ var async_xsjs = require('@sap/async_xsjs');
235
+ var options = {
236
+ anonymous: true,
237
+ context: { answer: 42 }
238
+ };
239
+ (await async_xsjs(options)).listen(3000);
240
+ ```
241
+
242
+ This configuration extends the context of XSJS scripts with one additional variable called `answer`.
243
+ Every time an XSJS script is executed, it will not only have the `$` variable in its context, but will also include the variable `answer` with value `42`.
244
+
245
+ Let's say we have a file `answer.xsjs` with the following content:
246
+ ```js
247
+ await $.response.setBody(answer);
248
+ ```
249
+ A request to `http://<your_domain>:3000/answer.xsjs` will respond with `42`.
250
+
251
+ With the `context` property set, you can expose Node.js packages and variables:
252
+ ```js
253
+ var options = {
254
+ anonymous: true,
255
+ context: { environment: process.env, _: require('lodash') }
256
+ };
257
+ ```
258
+
259
+ Currently, we are aware of a limitation which causes `<variable> instanceof <constructor_function>` used in an XSJS script to have odd behaviour.
260
+ Also, stubbing or mocking constructor functions such as `Date`, `String`, etc in an XSJS script won't affect other XSJS files.
261
+
262
+ The `context` property also finds usage in a workaround for this limitations.
263
+
264
+ Setting:
265
+ ```js
266
+ var options = {
267
+ anonymous: true,
268
+ context: { Array: Array, String: String }
269
+ };
270
+ ```
271
+ will fix these problems, but has the following side effects:
272
+
273
+ * Creating an array in an XSJS script and checking its instance will now return `false`:
274
+ ```js
275
+ var myArray = [1, 2, 3];
276
+ await $.response.setBody(myArray instanceof Array); // Responds with false
277
+ ```
278
+ * Monkey-patching built-in types won't work as expected if they are exposed through the `context` property:
279
+ ```js
280
+ String.prototype.contains = function(str) { return this.indexOf(str) >= 0; };
281
+ var stringLiteral = 'Abc';
282
+ var stringObject = new String('Abc');
283
+ console.log(stringLiteral.contains); // undefined
284
+ console.log(stringObject.contains); // [Function]
285
+ ```
286
+ Since there might be other side effects, **use this feature at your own risk.**
287
+
288
+ #### libraryCache
289
+
290
+ An object that contains the `.xsjslibs` that will be cached. Example:
291
+
292
+ ```js
293
+ {
294
+ 'my.libs.utility': 'global'
295
+ }
296
+ ```
297
+
298
+ In an XSJS code, the import looks like this:
299
+
300
+ ```js
301
+ var utility = await $.import('my.libs', 'utility');
302
+ ```
303
+
304
+ **Note:** It is recommended to use this feature only when necessary, because it keeps the cached content until the application is running.
305
+ It might have side effects in case the `.xsjslib` keeps state. It also leads to extensive memory consumption and this should be considered while calculating application memory limits.
306
+
307
+ #### Multitenant Usage
308
+
309
+ In multitenant scenarios, the `hana` and `secureStore` properties can contain an object with the credentials of a _managed-hana_ (Instance Manager) service (created with the appropriate service plan) instead of the credentials of the _hana_ service. In this case, the application will connect to a SAP HANA system, depending on the tenant (identity zone) of the incoming request.
310
+ A managed service instance for the particular tenant should be created in advance, and the corresponding database artefacts should be deployed prior to requesting the application with this tenant. Otherwise, the processing of the request will be terminated with an error.
311
+
312
+ **Note**: Currently, jobs are not multitenant-aware. They are shared between tenants, and a connection to a SAP HANA database cannot be established.
313
+ A job executing XSJS code can still connect to a specific SAP HANA service instance, by using SQLCC configuration.
314
+
315
+ ## OData Support
316
+
317
+ OData support is provided by OData package `@sap/xsodata`. Details on what features are provided can be found in the project itself. The compatibility layer scans for `.xsodata` files in the specified source directory and registers OData endpoints for each valid descriptor. Both JavaScript and SQL script exits are supported.
318
+
319
+ ### Clear OData model cache
320
+
321
+ For each OData service, the model is loaded and cached in memory upon first request.
322
+ In case the schema of the underlying DB objects is changed at runtime, it is necessary to reload the model. Here is an example:
323
+ ```js
324
+ var app = await xsjs(options);
325
+
326
+ function onSchemaChange(tenant) {
327
+ app.clearODataCache(tenant);
328
+ }
329
+ ```
330
+ * `clearODataCache(tenant)` clears the OData model cache for the given tenant.
331
+ * `tenant` argument is optional. If not provided, the cache for all tenants will be cleared.
332
+
333
+ **Note:** Each application instance contains a cache of OData models. Clearing the cache in one of those instances does not automatically trigger cache invalidation in the others. The application itself is responsible for calling `clearODataCache` in each instance. Since an HTTP request is received only by a single instance, it cannot be used to trigger clearing the cache in a consistent manner for the whole application. Other solutions, like messaging, are more suitable for that purpose.
334
+
335
+ ## NPM Package Support
336
+ As an extension in the dollar API, we included support for all the available NPM packages. <br />
337
+ For example, in your XSJS file you can add the following code:
338
+
339
+ ```js
340
+ var _ = $.require('underscore');
341
+ // Count to ten
342
+ var count = '';
343
+ _.range(11).forEach(function(number) {
344
+ count += number + ' ';
345
+ });
346
+ await $.response.setBody(count);
347
+ ```
348
+
349
+ You can also require a file relatively. The required file will execute in a Node.js context. This means, you will have access to global Node.js variables, such as `__dirname`, `process`, etc. in it.
350
+
351
+ For example, if we have a file called `myAPI.js` with content:
352
+
353
+ ```js
354
+ // myAPI.js
355
+ module.exports = {
356
+ getDirname: function() {
357
+ return __dirname;
358
+ }
359
+ };
360
+ ```
361
+
362
+ Let's say `myAPI.js` is located in a parent directory for the following XSJS file:
363
+ ```js
364
+ var myAPI = $.require('../myAPI.js');
365
+ await $.response.setBody(myAPI.getDirname());
366
+ ```
367
+
368
+ ## Destinations Support
369
+
370
+ #### Via user provided services
371
+ By default, the compatibility layer supports destination configuration via user-provided services. The destination name (the repo resource ID, e.g. package + '.' + xshttpdest name) is matched to a service name.
372
+
373
+ Example content of VCAP_SERVICES:
374
+
375
+ ```js
376
+ "VCAP_SERVICES": {
377
+ "user-provided": [
378
+ {
379
+ "label": "user-provided",
380
+ "name": "foobar.httpdest.mydest",
381
+ "credentials": {
382
+ "host": "some.host",
383
+ "port": 8088,
384
+ "username": "user",
385
+ "password": "secret"
386
+ }
387
+ }
388
+ ]
389
+ }
390
+ ```
391
+ Example usage in an XSJS code:
392
+ ```js
393
+ var destination = await $.net.http.readDestination('foobar.httpdest', 'mydest');
394
+ ```
395
+ If there is no service in VCAP_SERVICES with the same name as the destination requested, an exception is thrown.
396
+
397
+ When a destination is read, the content of the design time descriptor is merged with the properties provided in the user-provided service. Property values of the UP service override DT descriptor values.
398
+
399
+
400
+ #### Via custom provider function
401
+
402
+ If the default support is not enough for your use case, you can provide a custom destination provider function. For details how to do that, see the __destinationProvider__ configuration option explained above.
403
+
404
+ ## Accessing Column Values by Index in `$.hdb.ResultSet` Rows
405
+
406
+ Column values from within a row of `$.hdb.ResultSet` in XS Classic can be accessed either by column name or by column index.
407
+ If an application does not make use of accessing columns by index, then this capability can be turned off, which will result in an improved performance:
408
+
409
+ ```js
410
+ var connection = await $.hdb.getConnection({ enableColumnIndices: false });
411
+ ```
412
+
413
+ ## Tracing Via `$.trace` API
414
+
415
+ Each trace entry is associated with a location. The entry point being accessed is used as a location:
416
+ - All application trace entries produced during OData handling (entries produced by exits and the imported `.xsjslib` scripts, `@sap/xsodata` entries) use the location of the `.xsodata` service itself, e.g. '/odata/service.xsodata'.
417
+ - All application trace entries produced during job execution (entries from `.xsjs` scripts and the imported `.xsjslib` scripts) use the location of the `.xsjob` descriptor, e.g '/jobs/my-job.xsjob'.
418
+ - All application trace entries produced by `.xsjs` code (including the imported `.xsjslib` scripts) use the location of the `.xsjs` file itself, e.g. '/xsjs/service.xsjs'. The same applies to scripts referenced from `$.response.followUp`.
419
+
420
+ This allows easier change of the tracing level (only of the entry point - `.xsodata`, `.xsjob` or `.xsjs`) without doing so for every single script involved in the execution or by using wildcards. The trace message can be used to find the source line that has produced it.
421
+
422
+ **Note:** Regarding request-ids for jobs: the run-id received from the jobscheduler is used as the request-id instead of an auto-generated one.
423
+
424
+ ## Troubleshooting
425
+
426
+ This package uses `@sap/logging` package, so all of its features are available to control logging.
427
+ For example, to set all logging and tracing to the finest level, set `XS_APP_LOG_LEVEL` environment variable to `debug`.
428
+
429
+ If the application is deployed on XS Advanced On-Premise Runtime, you can change the log level without restarting the application.
430
+ For example, the following command will set all logging and tracing to the finest level.
431
+ ```sh
432
+ xs set-logging-level <application-name> "*" debug
433
+ ```
434
+ See the `@sap/logging` documentation for more information.
435
+
436
+ Some of the libraries used by this package employ other tracing mechanisms. For example, many use the popular [debug](https://www.npmjs.com/package/debug) package. This means that by setting `DEBUG` environment variable, you can enable additional traces. Set it to `*` to enable all of them, but be careful as the output may be overwhelming.
437
+
438
+ In addition, internal Node.js traces can be enabled via the `NODE_DEBUG` environment variable.
439
+
440
+ **Warning:** Enabling some of these options may trace security sensitive data, so use with caution.
441
+
442
+ ## Differences with SAP HANA XS Classic
443
+
444
+ See the differences [here](differences.md).
445
+ <br/>