-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
“amith-skyflow”
committed
Oct 24, 2024
1 parent
d5a2961
commit 9ef2642
Showing
23 changed files
with
684 additions
and
543 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
SKYFLOW_CREDENTIALS={ clientID: '<YOUR_CLIENT_ID>', clientName: '<YOUR_CLIENT_NAME>', keyID: '<YOUR_KEY_ID>', tokenURI: '<YOUR_TOKEN_URI>', privateKey: '<YOUR_PEM_PRIVATE_KEY>', } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,58 +1,53 @@ | ||
/* | ||
Copyright (c) 2023 Skyflow, Inc. | ||
*/ | ||
import { | ||
Skyflow, | ||
generateBearerToken, | ||
isExpired, | ||
setLogLevel, | ||
LogLevel, | ||
} from "skyflow-node"; | ||
import { DeleteRequest, Env, LogLevel, Skyflow } from "skyflow-node"; | ||
|
||
const filePath = "<YOUR_CREDENTIAL_FILE>"; | ||
setLogLevel(LogLevel.INFO); | ||
let bearerToken = ""; | ||
// To generate Bearer Token from credentials string. | ||
const cred = { | ||
clientID: '<YOUR_CLIENT_ID>', | ||
clientName: '<YOUR_CLIENT_NAME>', | ||
keyID: '<YOUR_KEY_ID>', | ||
tokenURI: '<YOUR_TOKEN_URI>', | ||
privateKey: '<YOUR_PEM_PRIVATE_KEY>', | ||
}; | ||
|
||
const skyflow = Skyflow.init({ | ||
vaultID: "<VAULT_ID>", | ||
vaultURL: "<VAULT_URL>", | ||
getBearerToken: () => { | ||
return new Promise((resolve, reject) => { | ||
if (!isExpired(bearerToken)) { | ||
resolve(bearerToken); | ||
} else { | ||
generateBearerToken(filePath) | ||
.then((response) => { | ||
bearerToken = response.accessToken; | ||
resolve(bearerToken); | ||
}) | ||
.catch((err) => { | ||
reject(err); | ||
}); | ||
} | ||
}); | ||
}, | ||
}); | ||
// please pass one of apiKey, token, credentialsString & path | ||
const skyflowCredentials = { | ||
credentialsString: JSON.stringify(cred) | ||
} | ||
|
||
// please pass one of apiKey, token, credentialsString & path | ||
const credentials = { | ||
apiKey: "API_KEY", // Api Key | ||
} | ||
|
||
const result = skyflow.delete({ | ||
records: [ | ||
{ | ||
id: "<SKYFLOW_ID_1>", | ||
table: "<TABLE_NAME", | ||
}, | ||
{ | ||
id: "<SKYFLOW_ID_2>", | ||
table: "<TABLE_NAME", | ||
}, | ||
], | ||
const skyflow_client = 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 | ||
} | ||
], | ||
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 | ||
}); | ||
|
||
result | ||
.then((response) => { | ||
console.log("delete result:"); | ||
console.log(JSON.stringify(response)); | ||
}) | ||
.catch((error) => { | ||
console.log("delete error: "); | ||
console.log(JSON.stringify(error)); | ||
}); | ||
const deleteIds = [ | ||
'SKYFLOW_ID1', | ||
'SKYFLOW_ID2', | ||
'SKYFLOW_ID3', | ||
] | ||
|
||
const deleteRequest = new DeleteRequest( | ||
"TABLE_NAME", // TABLE_NAME | ||
deleteIds | ||
); | ||
|
||
// will return first Vault ID | ||
skyflow_client.vault().delete( | ||
deleteRequest | ||
).then(resp=>{ | ||
console.log(resp); | ||
}).catch(err=>{ | ||
console.log(JSON.stringify(err)); | ||
}); |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,63 +1,56 @@ | ||
/* | ||
Copyright (c) 2022 Skyflow, Inc. | ||
*/ | ||
import { | ||
Skyflow, | ||
generateBearerToken, | ||
isExpired, | ||
setLogLevel, | ||
LogLevel, | ||
} from 'skyflow-node'; | ||
|
||
const filePath = '<YOUR_CREDENTIAL_FILE>'; | ||
setLogLevel(LogLevel.INFO); | ||
let bearerToken = ''; | ||
|
||
const skyflow = Skyflow.init({ | ||
vaultID: '<VAULT_ID>', | ||
vaultURL: '<VAULT_URL>', | ||
getBearerToken: () => { | ||
return new Promise((resolve, reject) => { | ||
if (!isExpired(bearerToken)) { | ||
resolve(bearerToken); | ||
} else { | ||
generateBearerToken(filePath) | ||
.then(response => { | ||
bearerToken = response.accessToken; | ||
resolve(bearerToken); | ||
}) | ||
.catch(err => { | ||
reject(err); | ||
}); | ||
} | ||
}); | ||
}, | ||
}); | ||
import { Env, GetOptions, GetRequest, LogLevel, Skyflow } from "skyflow-node"; | ||
|
||
// To generate Bearer Token from credentials string. | ||
const cred = { | ||
clientID: '<YOUR_CLIENT_ID>', | ||
clientName: '<YOUR_CLIENT_NAME>', | ||
keyID: '<YOUR_KEY_ID>', | ||
tokenURI: '<YOUR_TOKEN_URI>', | ||
privateKey: '<YOUR_PEM_PRIVATE_KEY>', | ||
}; | ||
|
||
// please pass one of apiKey, token, credentialsString & path | ||
const skyflowCredentials = { | ||
credentialsString: JSON.stringify(cred), | ||
} | ||
|
||
// please pass one of apiKey, token, credentialsString & path | ||
const credentials = { | ||
path: "PATH_TO_CREDENTIALS_JSON", // bearer token | ||
} | ||
|
||
const result = skyflow.get({ | ||
records: [ | ||
// To to get records using skyflow_ids. | ||
{ | ||
ids: ['<ID1>', '<ID2>'], | ||
redaction: Skyflow.RedactionType.PLAIN_TEXT, | ||
table: 'cards', | ||
}, | ||
// To get records using unique column name and values. | ||
{ | ||
redaction : Skyflow.RedactionType.PLAIN_TEXT, | ||
table: 'persons', | ||
columnName: 'card_id', | ||
columnValues: ['123', '456'], | ||
} | ||
], | ||
const skyflow_client = 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 | ||
} | ||
], | ||
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 | ||
}); | ||
|
||
result | ||
.then(response => { | ||
console.log('get result:'); | ||
console.log(JSON.stringify(response)); | ||
}) | ||
.catch(error => { | ||
console.log('get error: '); | ||
const getIds = [ | ||
'SKYFLOW_ID1', | ||
'SKYFLOW_ID2', | ||
] | ||
|
||
const getRequest = new GetRequest( | ||
"TABLE_NAME", | ||
getIds | ||
) | ||
|
||
const getOptions = new GetOptions() | ||
//use setters of setting options refer to skyflow docs for more options | ||
getOptions.setReturnTokens(true); | ||
|
||
skyflow_client.vault("VAULT_ID").get( | ||
getRequest, | ||
getOptions | ||
).then(response => { | ||
console.log(response); | ||
}).catch(error => { | ||
console.log(JSON.stringify(error)); | ||
}); | ||
}); |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.