{"analyzedAt":"2022-07-06T01:52:47.311Z","collected":{"metadata":{"name":"@sapmentors/cds-scp-api","scope":"sapmentors","version":"1.0.4","description":"CDS Extension for External Service Consumption","keywords":["sap","cap","cds","axios"],"date":"2021-02-18T17:59:20.682Z","author":{"name":"SAP Mentors & Friends"},"publisher":{"username":"gregorwolf","email":"gregor.wolf@gmail.com"},"maintainers":[{"username":"vobu","email":"volker.buzek@js-soft.com"},{"username":"gregorwolf","email":"gregor.wolf@gmail.com"}],"repository":{"type":"git","url":"git://github.com/sapmentors/cds-scp-api.git"},"links":{"npm":"https://www.npmjs.com/package/%40sapmentors%2Fcds-scp-api","homepage":"https://github.com/sapmentors/cds-scp-api#readme","repository":"https://github.com/sapmentors/cds-scp-api","bugs":"https://github.com/sapmentors/cds-scp-api/issues"},"license":"MIT","dependencies":{"@sap/xsenv":"^3.1.0","@sap/cds":"^4.5.2","@sap-cloud-sdk/core":"1.37.1","axios-oauth-client":"^1.4.0","axios-token-interceptor":"^0.2.0","axios":"^0.21.1","cfenv":"^1.2.3","tunnel":"^0.0.6"},"devDependencies":{"axios-mock-adapter":"^1.19.0","eslint":"^7.20.0","lodash":"^4.17.20","mocha":"^8.3.0","standard-version":"^9.1.1"},"releases":[{"from":"2022-06-06T00:00:00.000Z","to":"2022-07-06T00:00:00.000Z","count":0},{"from":"2022-04-07T00:00:00.000Z","to":"2022-07-06T00:00:00.000Z","count":0},{"from":"2022-01-07T00:00:00.000Z","to":"2022-07-06T00:00:00.000Z","count":1},{"from":"2021-07-06T00:00:00.000Z","to":"2022-07-06T00:00:00.000Z","count":1},{"from":"2020-07-06T00:00:00.000Z","to":"2022-07-06T00:00:00.000Z","count":4}],"hasTestScript":true,"readme":"# CDS-SCP-API Node Module \n\n## CDS Extension for SAP Cloud Platform API Consumption\nThe node module CDS-SCP-API simplifies the consuming external API from SAP OnPremise & Cloud APIs, Microsoft Office 365 APIs, Google Cloud Platform APIs, and other REST APIs in a Cloud Application Programming (CAP) Model on the SAP Cloud Platform. The module provides:\n- Fluent API consumption concept\n- Endpoint and Configuration using SAP Cloud Platform Destination and Connectivity services\n- Support of all kind of APIs including SAP OnPremise & Cloud OData and Rest APIs, Microsoft Office 365 APIs, Google Cloud Platform APIs and other REST APIs \n- Easy API http request configuration based on Axios config options \n\n## History\nJhodel Cailan initially started the CDS Extension concept. SAP Mentor Robert Eijpe created a similar concept integrating Microsoft Azure and Google Cloud APIs into a CDS external services concept. The SAP Devtoberfest 2020 challenge brought concepts together. And this results in a CDS-SCP-API Node Module for the community, making SAP developers' lives better.\n\n## Installation\n\nUsing npm:\n\n```swift\n> npm install @sapmentors/cds-scp-api\n```\n\n## Javascript/Node.js Code\n```javascript\n// Load the module\nconst cdsapi = require(\"cds-scp-api\");\n\n// Create a connection\nconst service = await cdsapi.connect.to(\"SCPDestination\");\n\n// Request the API using Axios Config\nlet result = await service.run({\n               url: \"/pathOfService\"\n             })\n\n```\n## Example Programs\n\nClick [here](./examples/readme.md) for examples and environment setup\n\n## Supported Destination Types\n\n- Internet Destinations with No Authentication \n- Internet Destinations with Basic Authentication\n- Internet Destinations with Client Credentials Authentication (including Microsoft Azure)\n- Internet Destinations with JWT token Authentication (currently only Google Cloud Platform)\n- OnPremise Destination and Connectivity via Cloud Connector with No Authentication \n- OnPremise Destinations and Connectivity via Cloud Connector with Basic Authentication\n\n## SCP Destination Configuration Examples\n\n- [SAP Cloud Platform Internet Destinations with No Authentication](./docs/InternetAPIwithNoAuthentication.md)\n- [SAP Cloud Platform Internet Destinations with Basic Authentication](./docs/InternetAPIwithBasicAuthentication.md)\n- [SAP Cloud Platform Internet Destinations for Microsoft 365/Azure via MSGraph ](./docs/InternetAPIforAzure.md)\n- [SAP Cloud Platform Internet Destinations for GSuite/Google Cloud Platform ](./docs/InternetAPIforGCP.md)\n\n## CDS-SCP-API Config Settings\nThe CDS-SCP-API is an SAP Cloud Platform layer on top of Axios. The configuration settings of the CDS-SCP-API **service.run** code is simular to Axios options, which are documented [here](https://github.com/axios/axios#request-config). CDS-SCP-API will ignore the Axios config settings for the authentification, the proxy settings, and the baseURL. The CDS-SCP-API retrieves these settings from the SAP Cloud Platform Destination & Connectivity services. \n\n### Compare Axios with CDS-SCP-API\n- Axios implementation\n  ```javascript\n  async function AxiosGetRequestwithBasicAuthentication() {\n\t  return await axios({\n\t  \turl: 'https://sapes5.sapdevcenter.com/sap/opu/odata/sap/EPM_REF_APPS_SHOP_SRV/Products?$top=2',\n\t\t  auth: {\n\t\t\t  username: '<SAP S-number>',\n\t\t\t  password: '<My password>'\n\t\t  }\n\t  })\n  }\n  ```\n\n- CDS-SCP-API implementation\n  ```javascript\n  async function InternetAPIGetRequestwithBasicAuthentication() {\n\t  const service = await cdsapi.connect.to(\"ES5\");\n\t  return await service.run({\n\t\t  url: \"/sap/opu/odata/sap/EPM_REF_APPS_SHOP_SRV/Products?$top=2\"\n\t  })\n  }  \n  ```\nCDS-SCP-API implementation uses relative URLs, and authorization is configured in the SAP Cloud Platform and handled by the CDS-SCP-API implementation.\n\n### Post requests with CSRF token protection\n  ```javascript\nasync function InternetAPIPostRequestwithBasicAuthentication() {\n\tconst product = {\n\t\t\"ProductID\": \"NL4B-101\",\n\t\t\"TypeCode\": \"PR\",\n\t\t\"Category\": \"Notebooks\",\n\t\t\"Name\": \"Psychiatric Help\",\n\t\t\"NameLanguage\": \"EN\",\n\t\t\"Description\": \"\",\n\t\t\"DescriptionLanguage\": \"\",\n\t\t\"SupplierID\": \"0100000000\",\n\t\t\"SupplierName\": \"SAP\",\n\t\t\"TaxTarifCode\": 1,\n\t\t\"MeasureUnit\": \"EA\",\n\t\t\"WeightMeasure\": \"0.000\",\n\t\t\"WeightUnit\": \"\",\n\t\t\"CurrencyCode\": \"EUR\",\n\t\t\"Price\": \"0.05\",\n\t\t\"Width\": \"0.000\",\n\t\t\"Depth\": \"0.000\",\n\t\t\"Height\": \"0.000\",\n\t\t\"DimUnit\": \"\",\n\t\t\"CreatedAt\": \"\\/Date(1602106635169)\\/\",\n\t\t\"ChangedAt\": \"\\/Date(1602106635169)\\/\"\n\t}\n\n\tconst service = await cdsapi.connect.to(\"ES5\");\n\treturn await service.run({\n\t\turl: \"/sap/opu/odata/IWBEP/GWSAMPLE_BASIC/ProductSet\",\n\t\tmethod: \"post\",\n\t\theaders: {\n\t\t\t'content-type': 'application/json'\n\t\t},\n\t\tdata: product,\n\t\tcsrfProtection: true\n\t})\n}\n  ```\nWhen request needs a X-CSRF token to fulfill, you can easily add the setting **csrfProtection: true**\n\n### Simultaneous requests\n  ```javascript\nasync function SimultaneousRequests() {\n\tconst service = await cdsapi.connect.to(\"ES5\")\n\taxios.all([\n\t\tservice.run({\n\t\t\turl: \"/sap/opu/odata/sap/EPM_REF_APPS_SHOP_SRV/Products?$top=2\"\n\t\t}),\n\t\tservice.run({\n\t\t\turl: \"/sap/opu/odata/sap/EPM_REF_APPS_SHOP_SRV/Products?$top=3\"\n\t\t})\n\t])\n\t\t.then(axios.spread((request1, request2) => {\n\t\t\tconsole.log('Results request1: ', request1.d.results[0].Name);\n\t\t\tconsole.log('Results request2: ', request2.d.results[0].Name);\n\t\t}));\n\n}\n  ```"},"npm":{"downloads":[{"from":"2022-07-05T00:00:00.000Z","to":"2022-07-06T00:00:00.000Z","count":0},{"from":"2022-06-29T00:00:00.000Z","to":"2022-07-06T00:00:00.000Z","count":29},{"from":"2022-06-06T00:00:00.000Z","to":"2022-07-06T00:00:00.000Z","count":191},{"from":"2022-04-07T00:00:00.000Z","to":"2022-07-06T00:00:00.000Z","count":714},{"from":"2022-01-07T00:00:00.000Z","to":"2022-07-06T00:00:00.000Z","count":1652},{"from":"2021-07-06T00:00:00.000Z","to":"2022-07-06T00:00:00.000Z","count":2325}],"starsCount":0},"github":{"starsCount":13,"forksCount":3,"subscribersCount":17,"issues":{"count":6,"openCount":5,"distribution":{"3600":1,"10800":0,"32400":0,"97200":0,"291600":0,"874800":0,"2624400":0,"7873200":1,"23619600":0,"70858800":4,"212576400":0},"isDisabled":false},"contributors":[{"username":"raeijpe","commitsCount":65},{"username":"gregorwolf","commitsCount":7}],"commits":[{"from":"2022-06-29T00:00:00.000Z","to":"2022-07-06T00:00:00.000Z","count":0},{"from":"2022-06-06T00:00:00.000Z","to":"2022-07-06T00:00:00.000Z","count":0},{"from":"2022-04-07T00:00:00.000Z","to":"2022-07-06T00:00:00.000Z","count":0},{"from":"2022-01-07T00:00:00.000Z","to":"2022-07-06T00:00:00.000Z","count":0},{"from":"2021-07-06T00:00:00.000Z","to":"2022-07-06T00:00:00.000Z","count":1}]},"source":{"files":{"readmeSize":5383,"testsSize":2873,"hasNpmIgnore":true,"hasChangelog":true},"linters":["eslint"],"outdatedDependencies":{"@sap/cds":{"required":"^4.5.2","stable":"6.0.1","latest":"6.0.1"},"axios":{"required":"^0.21.1","stable":"0.27.2","latest":"1.0.0-alpha.1"},"@sap-cloud-sdk/core":{"required":"1.37.1","stable":"1.54.2","latest":"2.0.0-20211027112336.0"}}}},"evaluation":{"quality":{"carefulness":0.9999999999999999,"tests":0.6,"health":0.5,"branding":0},"popularity":{"communityInterest":35,"downloadsCount":238,"downloadsAcceleration":0.7011796042617957,"dependentsCount":0},"maintenance":{"releasesFrequency":0.9,"commitsFrequency":0.9,"openIssues":0.9,"issuesDistribution":0.9}},"score":{"final":0.6118474151836786,"detail":{"quality":0.7871334724424675,"popularity":0.07356880447358394,"maintenance":0.9998808339576686}}}