diff --git a/docs/guide/connectors/ecf/node-js.mdx b/docs/guide/connectors/ecf/node-js.mdx index 7f49c4fd..4793abb6 100644 --- a/docs/guide/connectors/ecf/node-js.mdx +++ b/docs/guide/connectors/ecf/node-js.mdx @@ -1,5 +1,13 @@ # Tutorial - Custom connector development in Node-JS + + +Target Audience: + +This tutorial is intended for developers familiar with JavaScript and the basics of working with APIs. We'll assume you have a Google Cloud project set up and a Google Sheet containing role entitlement data. + + + This tutorial guides you through creating a Node.js-based web server that adheres to the ECF specification. By following these steps, you'll establish a connection between EIC and your target application, enabling data exchange and task execution. ## Pre-requisite(s) @@ -436,15 +444,13 @@ readData(0, 2); ### Role Entitlement Import: +The provided image shows a sample role entitlement table in a Google Sheet. Each row represents a role, and columns contain details like role name, description, child entitlements (which are other roles), and owners (users or groups with access). Consider below is role entitlement data stored in sheet. ![](../../../../static/img/ECF_Role_Ent_Import.png) -below is sample code to read and return this data in ECF format: +The code below reads the data in the sheet and transforms it into a response as per the API spec defined by ECF. -
- Entitlement import - Role data -

```javascript const { google } = require('googleapis'); const fs = require('fs'); @@ -528,9 +534,19 @@ if (rows.length) { // Call the function with offset and pageSize readData(0, 2); ``` -

-
+Explanation: + +This code reads role entitlement data from a Google Sheet and converts it into a JSON format suitable for ECF (External Connector Framework). + +Here's a breakdown of the steps: + * Authentication: It authenticates with the Google Sheets API using a service account. + * Data Retrieval: It retrieves data from a specified Google Sheet and defines the starting row and number of rows to read. + * Header Processing: It extracts the header row names from the sheet. + * Data Processing: It iterates through each data row and creates a role object. + * Multi-valued Data Handling: It handles comma-separated values in specific columns (child entitlements and owners) by converting them into arrays. + * Output: It converts the processed data (including offset, total count, and roles) into JSON format and logs it to the console. + * Error Handling: It includes basic error handling to log any issues during the process. ### Role-Accounts membership import: