Skip to content

Commit

Permalink
Merge pull request #163 from skyflowapi/SK-1621-node-sdk-v2
Browse files Browse the repository at this point in the history
SK-1621: node sdk v2
  • Loading branch information
amith-skyflow authored Nov 4, 2024
2 parents 1cdba74 + 7ba9262 commit 25f4418
Show file tree
Hide file tree
Showing 31 changed files with 561 additions and 406 deletions.
37 changes: 19 additions & 18 deletions samples/vault-api/client-operations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,43 +10,43 @@ try {
privateKey: '<YOUR_PEM_PRIVATE_KEY>',
};

// please pass one of apiKey, token, credentialsString & path
// please pass one of apiKey, token, credentialsString & path as credentials
const skyflowCredentials = {
credentialsString: JSON.stringify(cred),
}

// please pass one of apiKey, token, credentialsString & path
// please pass one of apiKey, token, credentialsString & path as credentials
const credentials = {
token: "BEARER_TOKEN", // bearer token
}

const skyflow_client = new Skyflow({
const skyflowClient = new Skyflow({
vaultConfigs: [
{
vaultId: "VAULT_ID1", // primary vault
clusterId: "CLUSTER_ID1", // ID from your vault URL Eg https://{clusterId}.vault.skyflowapis.com
env: Env.PROD, // Env by deault it is set to PROD
credentials: credentials // indiviudal credentails
env: Env.PROD, // Env by default it is set to PROD
credentials: credentials // individual credentials
}
],
skyflowCredentials: skyflowCredentials, // skyflow credentials will be used if no individual creds are passed
logLevel: LogLevel.ERROR // set loglevel by deault it is set to PROD
skyflowCredentials: skyflowCredentials, // skyflow credentials will be used if no individual credentials are passed
logLevel: LogLevel.ERROR // set log level by default it is set to PROD
});

//add vault config on the go
skyflow_client.addVaultConfig(
//add vault config on the fly
skyflowClient.addVaultConfig(
{
vaultId: "VAULT_ID2", // secondary vault
clusterId: "CLUSTER_ID2", // ID from your vault URL Eg https://{clusterId}.vault.skyflowapis.com
env: Env.PROD, // Env by deault it is set to PROD
// if you dont specify individual creds, skyflow creds will be used
env: Env.PROD, // Env by default it is set to PROD
// if you don't specify individual credentials, skyflow credentials will be used
}
);

//add vault config on the go
skyflow_client.updateVaultConfig(
//update vault config on the fly
skyflowClient.updateVaultConfig(
{
vaultId: "VAULT_ID2", // vault Id and cluster id is unique
vaultId: "VAULT_ID2", // vault Id and cluster Id is unique
clusterId: "CLUSTER_ID2", // ID from your vault URL Eg https://{clusterId}.vault.skyflowapis.com
credentials: credentials, //update credentials
}
Expand All @@ -55,18 +55,19 @@ try {
//perform operations
const deleteIds = [
"SKYLFOW_ID1",
"SKYLFOW_ID1"
"SKYLFOW_ID2"
]

const deleteRequest = new DeleteRequest(
"TABLE_NAME",
deleteIds
);

//perform delete call if you dont specify valut() it will return the first valid vault
skyflow_client.vault("VALUT_ID2").delete(deleteRequest);
//perform delete call if you don't specify vault() it will return the first valid vault
skyflowClient.vault("VAULT_ID2").delete(deleteRequest);

skyflow_client.removeVaultConfig("VAULT_ID");
//remove vault on the fly
skyflowClient.removeVaultConfig("VAULT_ID");
} catch (err) {
console.log(JSON.stringify(err));
}
18 changes: 9 additions & 9 deletions samples/vault-api/credentials-options.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,34 +10,34 @@ try {
privateKey: '<YOUR_PEM_PRIVATE_KEY>',
};

// please pass one of apiKey, token, credentialsString & path
// please pass one of apiKey, token, credentialsString & path as credentials
const skyflowCredentials = {
credentialsString: JSON.stringify(cred)
}

const credentials = {
token: "BEARER_TOKEN", // bearer token
// apiKey: "API_KEY", //API_KEY
// path: "PATH", //PATH to credentials json
// path: "PATH", //path to credentials file
// credentialsString: "CREDENTIAL_STRING", // credentials as string
}

const skyflow_client = new Skyflow({
const skyflowClient = new Skyflow({
vaultConfigs: [
{
vaultId: "VAULT_ID1", // primary vault
clusterId: "CLUSTER_ID1", // ID from your vault URL Eg https://{clusterId}.vault.skyflowapis.com
env: Env.PROD, // Env by deault it is set to PROD
env: Env.PROD, // Env by default it is set to PROD
},
{
vaultId: "VAULT_ID2", // primary vault
clusterId: "CLUSTER_ID2", // ID from your vault URL Eg https://{clusterId}.vault.skyflowapis.com
env: Env.PROD, // Env by deault it is set to PROD
env: Env.PROD, // Env by default it is set to PROD
credentials: credentials,
}
],
skyflowCredentials: skyflowCredentials, // skyflow credentials will be used if no individual creds are passed
logLevel: LogLevel.ERROR // set loglevel by deault it is set to PROD
skyflowCredentials: skyflowCredentials, // skyflow credentials will be used if no individual credentials are passed
logLevel: LogLevel.ERROR // set log level by default it is set to PROD
});

const primaryDeleteIds = [
Expand All @@ -52,7 +52,7 @@ try {
);

// VAULT_ID1 will use skyflowCredentials if you don't specify individual credentials at config level
skyflow_client.vault("VAULT_ID1").delete(
skyflowClient.vault("VAULT_ID1").delete(
primaryDeleteRequest
).then(resp => {
console.log(resp);
Expand All @@ -72,7 +72,7 @@ try {
);

// VAULT_ID1 will use individual credentials at config level
skyflow_client.vault("VAULT_ID2").delete(
skyflowClient.vault("VAULT_ID2").delete(
secondaryDeleteRequest
).then(resp => {
console.log(resp);
Expand Down
28 changes: 14 additions & 14 deletions samples/vault-api/data-residency.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,52 +10,52 @@ try {
privateKey: '<YOUR_PEM_PRIVATE_KEY>',
};

// please pass one of apiKey, token, credentialsString & path
// please pass one of apiKey, token, credentialsString & path as credentials
const skyflowCredentials = {
credentialsString: JSON.stringify(cred),
}

// please pass one of apiKey, token, credentialsString & path
// please pass one of apiKey, token, credentialsString & path as credentials
const credentials = {
token: "BEARER_TOKEN", // bearer token
}

const skyflow_client = new Skyflow({
const skyflowClient = new Skyflow({
vaultConfigs: [
{
vaultId: "VAULT_ID1", // primary vault
clusterId: "CLUSTER_ID1", // ID from your vault URL Eg https://{clusterId}.vault.skyflowapis.com
env: Env.PROD, // Env by deault it is set to PROD
credentials: credentials // indiviudal credentails
env: Env.PROD, // Env by default it is set to PROD
credentials: credentials // individual credentials
}
],
skyflowCredentials: skyflowCredentials, // skyflow credentials will be used if no individual creds are passed
logLevel: LogLevel.ERROR // set loglevel by deault it is set to PROD
skyflowCredentials: skyflowCredentials, // skyflow credentials will be used if no individual credentials are passed
logLevel: LogLevel.ERROR // set log level by default it is set to PROD
});

//add vault config from prod env
skyflow_client.addVaultConfig(
skyflowClient.addVaultConfig(
{
vaultId: "VAULT_ID2", // secondary vault
clusterId: "CLUSTER_ID2", // ID from your vault URL Eg https://{clusterId}.vault.skyflowapis.com
env: Env.PROD, // Env by deault it is set to PROD
// if you dont specify individual creds, skyflow creds will be used
env: Env.PROD, // Env by default it is set to PROD
// if you dont specify individual credentials, skyflow credentials will be used
}
);

//perform operations
const getIds = [
"SKYLFOW_ID1",
"SKYLFOW_ID1"
"SKYLFOW_ID2"
]

const getRequest = new GetRequest(
"TABLE_NAME",
getIds
);

//perform delete call if you dont specify valut() it will return the first valid vault
skyflow_client.vault("VALUT_ID1").get(getRequest)
//perform delete call if you dont specify vault() it will return the first valid vault
skyflowClient.vault("VAULT_ID1").get(getRequest)
.then(response => {
//
const getResponse: GetResponse = response as GetResponse;
Expand All @@ -67,7 +67,7 @@ try {
"TABLE_NAME",
insertData!,
);
skyflow_client.vault("VAULT_ID2").insert(
skyflowClient.vault("VAULT_ID2").insert(
insertRequest
).then(resp => {
console.log(resp);
Expand Down
18 changes: 9 additions & 9 deletions samples/vault-api/delete-records.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,27 +10,27 @@ try {
privateKey: '<YOUR_PEM_PRIVATE_KEY>',
};

// please pass one of apiKey, token, credentialsString & path
// please pass one of apiKey, token, credentialsString & path as credentials
const skyflowCredentials = {
credentialsString: JSON.stringify(cred)
}

// please pass one of apiKey, token, credentialsString & path
// please pass one of apiKey, token, credentialsString & path as credentials
const credentials = {
apiKey: "API_KEY", // Api Key
apiKey: "API_KEY", // API Key
}

const skyflow_client = new Skyflow({
const skyflowClient = new Skyflow({
vaultConfigs: [
{
vaultId: "VAULT_ID", // primary vault
clusterId: "CLUSTER_ID", // ID from your vault URL Eg https://{clusterId}.vault.skyflowapis.com
env: Env.PROD, // Env by deault it is set to PROD
credentials: credentials // indiviudal credentails
env: Env.PROD, // Env by default it is set to PROD
credentials: credentials // individual credentials
}
],
skyflowCredentials: skyflowCredentials, // skyflow credentials will be used if no individual creds are passed
logLevel: LogLevel.ERROR // set loglevel by deault it is set to PROD
skyflowCredentials: skyflowCredentials, // skyflow credentials will be used if no individual credentials are passed
logLevel: LogLevel.ERROR // set log level by default it is set to PROD
});

const deleteIds = [
Expand All @@ -45,7 +45,7 @@ try {
);

// will return first Vault ID
skyflow_client.vault().delete(
skyflowClient.vault().delete(
deleteRequest
).then(resp => {
console.log(resp);
Expand Down
16 changes: 8 additions & 8 deletions samples/vault-api/detokenzie-records.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,27 +10,27 @@ try {
privateKey: '<YOUR_PEM_PRIVATE_KEY>',
};

// please pass one of apiKey, token, credentialsString & path
// please pass one of apiKey, token, credentialsString & path as credentials
const skyflowCredentials = {
credentialsString: JSON.stringify(cred)
}

// please pass one of apiKey, token, credentialsString & path
// please pass one of apiKey, token, credentialsString & path as credentials
const credentials = {
token: "TOKEN", // bearer token
}

const skyflow_client = new Skyflow({
const skyflowClient = new Skyflow({
vaultConfigs: [
{
vaultId: "VAULT_ID", // primary vault
clusterId: "CLUSTER_ID", // ID from your vault URL Eg https://{clusterId}.vault.skyflowapis.com
env: Env.PROD, // Env by deault it is set to PROD
credentials: credentials // indiviudal credentails
env: Env.PROD, // Env by default it is set to PROD
credentials: credentials // individual credentials
}
],
skyflowCredentials: skyflowCredentials, // skyflow credentials will be used if no individual creds are passed
logLevel: LogLevel.ERROR // set loglevel by deault it is set to PROD
skyflowCredentials: skyflowCredentials, // skyflow credentials will be used if no individual credentials are passed
logLevel: LogLevel.ERROR // set log level by default it is set to PROD
});

const detokenizeData = [
Expand All @@ -50,7 +50,7 @@ try {

detokenizeOptions.setDownloadURL(false);

skyflow_client.vault("VAULT_ID").detokenize(
skyflowClient.vault("VAULT_ID").detokenize(
detokenizeRequest,
detokenizeOptions
).then(response => {
Expand Down
18 changes: 9 additions & 9 deletions samples/vault-api/file-upload.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,27 +11,27 @@ try {
privateKey: '<YOUR_PEM_PRIVATE_KEY>',
};

// please pass one of apiKey, token, credentialsString & path
// please pass one of apiKey, token, credentialsString & path as credentials
const skyflowCredentials = {
credentialsString: JSON.stringify(cred),
}

// please pass one of apiKey, token, credentialsString & path
// please pass one of apiKey, token, credentialsString & path as credentials
const credentials = {
path: "PATH_TO_CREDENTIALS_JSON", // bearer token
path: "PATH_TO_CREDENTIALS_JSON", // path to credentials file
}

const skyflow_client = new Skyflow({
const skyflowClient = new Skyflow({
vaultConfigs: [
{
vaultId: "VAULT_ID", // primary vault
clusterId: "CLUSTER_ID", // ID from your vault URL Eg https://{clusterId}.vault.skyflowapis.com
env: Env.PROD, // Env by deault it is set to PROD
credentials: credentials // indiviudal credentails
env: Env.PROD, // Env by default it is set to PROD
credentials: credentials // individual credentials
}
],
skyflowCredentials: skyflowCredentials, // skyflow credentials will be used if no individual creds are passed
logLevel: LogLevel.ERROR // set loglevel by deault it is set to PROD
skyflowCredentials: skyflowCredentials, // skyflow credentials will be used if no individual credentials are passed
logLevel: LogLevel.ERROR // set log level by default it is set to PROD
});

const uploadReq = new FileUploadRequest(
Expand All @@ -41,7 +41,7 @@ try {
"FILE_PATH"
);

skyflow_client.vault("VAULT_ID").uploadFile(
skyflowClient.vault("VAULT_ID").uploadFile(
uploadReq
).then(response => {
console.log(response);
Expand Down
18 changes: 9 additions & 9 deletions samples/vault-api/get-column-values.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,27 +10,27 @@ try {
privateKey: '<YOUR_PEM_PRIVATE_KEY>',
};

// please pass one of apiKey, token, credentialsString & path
// please pass one of apiKey, token, credentialsString & path as credentials
const skyflowCredentials = {
credentialsString: JSON.stringify(cred),
}

// please pass one of apiKey, token, credentialsString & path
// please pass one of apiKey, token, credentialsString & path as credentials
const credentials = {
path: "PATH_TO_CREDENTIALS_JSON", // bearer token
path: "PATH_TO_CREDENTIALS_JSON", // path to credentials file
}

const skyflow_client = new Skyflow({
const skyflowClient = new Skyflow({
vaultConfigs: [
{
vaultId: "VAULT_ID", // primary vault
clusterId: "CLUSTER_ID", // ID from your vault URL Eg https://{clusterId}.vault.skyflowapis.com
env: Env.PROD, // Env by deault it is set to PROD
credentials: credentials // indiviudal credentails
env: Env.PROD, // Env by default it is set to PROD
credentials: credentials // individual credentials
}
],
skyflowCredentials: skyflowCredentials, // skyflow credentials will be used if no individual creds are passed
logLevel: LogLevel.ERROR // set loglevel by deault it is set to PROD
skyflowCredentials: skyflowCredentials, // skyflow credentials will be used if no individual credentials are passed
logLevel: LogLevel.ERROR // set log level by default it is set to PROD
});

const columnValues = [
Expand All @@ -48,7 +48,7 @@ try {
//use setters of setting options refer to skyflow docs for more options
getOptions.setReturnTokens(true);

skyflow_client.vault("VAULT_ID").get(
skyflowClient.vault("VAULT_ID").get(
getRequest,
getOptions
).then(response => {
Expand Down
Loading

0 comments on commit 25f4418

Please sign in to comment.