Oracle Cloud Infrastructure
npm i @pi-r/oci
Storage
Interface
import type { ConfigurationOptions } from "aws-sdk/lib/core";
interface OCIStorage extends CloudStorage {
service: "oci";
credential: string | OCIStorageCredential;
bucket: string;
}
interface OCIStorageCredential extends ConfigurationOptions {
accessKeyId: string;
secretAccessKey: string;
region?: string;
endpoint?: string;
namespace?: string;
}
Authentication
{
"dataSource": {
"credential": "main", // squared.cloud.json
/* OR */
"credential": {
"accessKeyId": "**********",
"secretAccessKey": "**********",
/* OR */
"namespace": "nodejs", // Unofficial
"region": "ap-tokyo-1",
/* OR */
"endpoint": "https://<namespace>.compat.objectstorage.<region>.oraclecloud.com"
}
}
}
Example usage
{
"selector": "html", // Any resource
"cloudStorage": [{
"service": "oci",
"bucket": "nodejs-001",
"credential": {/* Authentication */},
"admin": {
/* Same as AWS */
"configBucket": {/* Except "policy" | "website" | "cors" | "lifecycle" | "retentionPolicy" */}
},
"upload": {/* Same as AWS - Except "tags" */},
"download": {/* Same as AWS */}
}]
}
Database
Important
Thick mode environment variables are shared with @pi/oracle.
Interface
import type { BindParameters, ConnectionAttributes, ExecuteOptions, InitialiseOptions } from "oracledb";
interface OCIDatabaseQuery extends CloudDatabase {
source: "cloud";
service: "oci";
credential: string | OCIDatabaseCredential;
table?: string;
query?: string | Record<string, any>;
options?: ExecuteOptions;
params?: BindParameters;
update?: Record<string, any>;
streamRow?: boolean;
}
interface OCIDatabaseCredential extends ConnectionAttributes, InitialiseOptions {/* Empty */}
Authentication
{
"dataSource": {
"credential": "main", // squared.cloud.json
/* OR */
"credential": {
"user": "nodejs",
"password": "**********",
"walletLocation": "/home/user/oracle/wallet", // Optional
"walletPassword": "**********",
"connectString": "tcps://adb.ap-tokyo-1.oraclecloud.com:1522/abcdefghijklmno_nodejs_high.adb.oraclecloud.com"
},
/* OR */
"credential": {
"connectString": "nodejs_high",
"configDir": "/opt/oracle/config", // Location of user tnsnames.ora
"libDir": "/opt/oracle/instantclient_19_11" // Not recommended
}
}
}
Warning
Property libDir is ignored without NODE_ORACLEDB_DRIVER_MODE = "thick"
. See @pi-r/oracle.
Example usage
Tip
SELECT queries are compatible with the @pi-r/oracle plugin.
{
"selector": "h1",
"type": "text",
"dataSource": {
"source": "cloud",
"service": "oci",
"credential": {/* Authentication */},
"table": "demo",
/* AND */
"id": "1", // SODA.key
/* OR */
"query": { "id": { "$eq": "1" } }, // SODA.filter
"query": "SELECT * FROM demo WHERE id = :id AND value = :value", // oracledb.execute
"params": [1, "escaped"],
"options": {/* ExecuteOptions */},
/* OR */
"query": "SELECT d.* from demo NESTED json_document COLUMNS(id, title, description) d WHERE d.id = :id", // SODA.execute ("thick" mode)
"params": [1],
"options": {/* ExecuteOptions */},
"value": "<b>${title}</b>: ${description}",
"update": {/* Record<string, any> */}, // SODA.replaceOne
"id": "1" // Same as item being retrieved
}
}
Note
Column names might be UPPERCASED when using the query syntax.
@pi-r/oci
Added in version 0.7.0:
CLOUD_UPLOAD_STREAM attribute in ICloudServiceClient was enabled.
CLOUD_UPLOAD_CHUNK attribute in ICloudServiceClient was enabled.
configBucket.tags using PutBucketTaggingRequest was implemented.
Removed in version 0.7.0:
OCIDatabaseCredential property username is a duplicate of property user.