From 1c39a53d1f91333e4b67d26e73b80233c7eaed18 Mon Sep 17 00:00:00 2001 From: skyflow-vivek Date: Wed, 17 Jan 2024 12:34:57 +0530 Subject: [PATCH] SK-1379 Fix broken links in README - Add sample response for Insert upsert example --- README.md | 46 +++++++++++++++++++++++++++++++--------------- samples/README.md | 40 +++++++++++++++++++++++++--------------- 2 files changed, 56 insertions(+), 30 deletions(-) diff --git a/README.md b/README.md index 3121cb8..3031bf2 100644 --- a/README.md +++ b/README.md @@ -56,7 +56,7 @@ import { Skyflow, generateBearerToken } from 'skyflow-node'; ``` ### Service Account Bearer Token Generation -The [service account](https://github.com/skyflowapi/skyflow-node/tree/master/src/service-account) module uses a credentials file to generate service account tokens. See [API Authentication](https://docs.skyflow.com/developer-portal/getting-started/api-authentication/#step-1-create-a-service-account--assign-a-role) for instructions on creating a service account. +The [service account](https://github.com/skyflowapi/skyflow-node/tree/master/src/service-account) module uses a credentials file to generate service account tokens. See [API Authentication](https://docs.skyflow.com/api-authentication/#create-a-service-account) for instructions on creating a service account. The token generated from this module is valid for 60 minutes and lets you make API calls to the Data API as well as the Management API based on the permissions of the service account. @@ -544,21 +544,21 @@ Insert call [example](https://github.com/skyflowapi/skyflow-node/blob/master/sam ```javascript const response = client.insert({ - records: [{ - fields: { - expiry_date: '12/2026', - card_number: '411111111111111', - }, - table: 'cards', - }, ], + records: [{ + fields: { + expiry_date: '12/2026', + card_number: '411111111111111', + }, + table: 'cards', + }], }, { - tokens: true, - upsert: [ - { - table: 'cards', - column: 'card_number', - } - ] + tokens: true, + upsert: [ + { + table: 'cards', + column: 'card_number', + } + ] }); response.then( @@ -573,6 +573,22 @@ response.then( }); ``` +Samples Response: +```json +{ + "records": [ + { + "table": "cards", + "fields": { + "skyflow_id": "16419435-aa63-4823-aae7-19c6a2d6a19f", + "card_number": "f3907186-e7e2-466f-91e5-48e12c2bcbc1", + "cvv": "1989cb56-63da-4482-a2df-1f74cd0dd1a5", + }, + } + ] +} +``` + Insert call [example](https://github.com/skyflowapi/skyflow-node/blob/master/samples/vault-api/InsertWithContinueOnError.ts) with contiueOnError support: ```javascript diff --git a/samples/README.md b/samples/README.md index ec33ead..0b2cd32 100644 --- a/samples/README.md +++ b/samples/README.md @@ -7,8 +7,9 @@ Test the SDK by adding `VAULT-ID`, `VAULT-URL`, and `SERVICE-ACCOUNT` details in ## Prepare - Install the Node SDK: - - npm install skyflow-node +```bash +npm install skyflow-node +``` ### Create the vault 1. In a browser, navigate to Skyflow Studio. @@ -23,7 +24,7 @@ Test the SDK by adding `VAULT-ID`, `VAULT-URL`, and `SERVICE-ACCOUNT` details in ## The samples ### Detokenize -Detokenize a data token from the vault. Make sure the specified token is for data that exists in the vault. If you need a valid token, use [Insert.ts](Insert.ts) to insert the data, then use this data's token for detokenization. +Detokenize a data token from the vault. Make sure the specified token is for data that exists in the vault. If you need a valid token, use [Insert.ts](./vault-api/Insert.ts) to insert the data, then use this data's token for detokenization. #### Configure 1. Replace **** with **VAULT ID** 2. Replace **** with **VAULT URL**. @@ -35,8 +36,9 @@ Detokenize a data token from the vault. Make sure the specified token is for dat 8. Replace **** with relative path of **SERVICE ACCOUNT CREDENTIAL FILE**. #### Run the sample - - ts-node Detokenize.ts +```bash +ts-node Detokenize.ts +``` ### GetById Get data using skyflow id. @@ -49,8 +51,10 @@ Get data using skyflow id. 6. Replace **** with relative path of **SERVICE ACCOUNT CREDENTIAL FILE**. 7. Replace **** with **credit_cards**. #### Run the sample - - ts-node GetById.ts +```bash +ts-node GetById.ts +``` + ### Insert Insert data in the vault. #### Configure @@ -61,8 +65,10 @@ Insert data in the vault. 5. Replace **** with **column name**. 6. Replace **** with **valid value corresponding to column name**. #### Run the sample - - ts-node Insert.ts +```bash +ts-node Insert.ts +``` + ### InvokeConnection Skyflow Connections is a gateway service that uses Skyflow's underlying tokenization capabilities to securely connect to first-party and third-party services. This way, your infrastructure is never directly exposed to sensitive data, and you offload security and compliance requirements to Skyflow. #### Configure @@ -74,16 +80,19 @@ Skyflow Connections is a gateway service that uses Skyflow's underlying tokeniza 6. Replace value of **requestBody** with your's request body content. #### Run the sample - - ts-node InvokeConnection.ts +```bash +ts-node InvokeConnection.ts +``` + ### Service account token generation Generates a service account Bearer token using the file path of credentials.json. #### Configure 1. Replace **** with relative path of **SERVICE ACCOUNT CREDENTIAL FILE**. #### Run the sample - - ts-node TokenGenerationExample.ts +```bash +ts-node TokenGenerationExample.ts +``` ### Generate Bearer Token From Credentails Generates a service account bearer token using the JSON content of a credentials file. @@ -91,5 +100,6 @@ Generates a service account bearer token using the JSON content of a credentials 1. Replace **credentials*** with json data of downloaded credentials file while creation Service account. #### Run the sample - - ts-node TokenGenerationUsingCredContent.ts \ No newline at end of file +```bash +ts-node TokenGenerationUsingCredContent.ts +``` \ No newline at end of file