Oracle Cloud Infrastructure

  • npm i @pi-r/oci

Storage

Note

Uses S3 [1] compatibility API (AWS v2) and signature v4.

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 */}
  }]
}

Attention

OCI does not permit creating new public buckets through the S3 [1] compatibility layer.

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;
    id?: string | string[];
    query?: string | Record<string, any>;
    options?: ExecuteOptions;
    params?: BindParameters;
    update?: Record<string, any> | Record<string, any>[];
    updateType?: 0 | 1 | 2 | 3;
    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
    "id": ["1", "2"],
    /* 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> */},
    "updateType": 0, // SODA.replaceOne (append)
    "updateType": 1, // SODA.insertOneAndGet
    "updateType": 2, // SODA.replaceOne
    "id": "1", // Same as item being retrieved
    "id": ["1", "2"] // Only first one is updated

    /* SODA.createCollection */
    "update": [
      {/* Record<string, any> */},
      {/* Record<string, any> */}
    ],
    /* OR */
    "update": {/* Record<string, any> */},
    "updateType": 3 // SODA.insertOne
  }
}

Note

Column names might be UPPERCASED when using the query syntax.

@pi-r/oci

Changed in version 0.12.0:

  • BREAKING There is no special handling when uploading the file extension “.map”. CloudStorageUpload property descendantsGroup as [“.map”] can be used to restore the old behavior.

Added in version 0.11.0:

  • OCIStorage properties upload | download extended CopyObjectAction as copyObject | copyObject[].

Added in version 0.10.0:

  • OCIDatabaseQuery property update for SODA.insertMany as Record<string, any>[] was implemented.

  • OCIDatabaseQuery property updateType for SODA.insertOne as 3 was implemented.

Added in version 0.8.2:

  • OCIDatabaseQuery property id for multiple keys as string[] was implemented.

  • OCIDatabaseQuery property updateType for invoked replacement method was created.

Added in version 0.8.0:

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.