Code Monkey home page Code Monkey logo

oci-typescript-sdk's Introduction

Oracle Cloud Infrastructure SDK for TypeScript and JavaScript

wercker status

This is Oracle Cloud Infrastructure SDK for TypeScript and JavaScript. This project is open source and maintained by Oracle Corp. The home page for the project is Oracle Cloud Infrastructure SDK for TypeScript and JavaScript.

Installation

Use the following command to install this SDK:

npm install oci-sdk

Alternatively you can git clone this repo.

Working with the SDK for TypeScript and JavaScript

To start working with the SDK for TypeScript and JavaScript, you import the service package, create a client, and then use that client to make calls. Refer to examples section for examples on how to make requests.

Configuring

Before using the SDK, set up a config file with the required credentials. See SDK and Tool Configuration for instructions.

Organization of the SDK

The oci-typescript-sdk contains the following:

  • Service packages: All packages except common and any other package found inside lib. These packages represent the Oracle Cloud Infrastructure services supported by the SDK for TypeScript and JavaScript. Each package represents a service. These packages include methods to interact with the service, structs that model input and output parameters, and a client struct that acts as receiver for the above methods.

  • Common package: Found in the common directory. The common package provides supporting functions and structs used by service packages. Includes HTTP request/response (de)serialization, request signing, JSON parsing, pointer to reference and other helper functions. Most of the functions in this package are meant to be used by the service packages.

Examples

Examples can be found in the examples section

Documentation

Full documentation can be found on the sdk for typescript and javascript documentation site.

Versions Supported

The SDK for TypeScript and JavaScript currently supports NodeJS version 14, 16, 20 and TypeScript version 4.1.3.

Node & Browser Support

The SDK for TypeScript and JavaScript currently supports NodeJS but does not have browser support.

Help

Contributing

oci-typescript-sdk welcomes contributions from the community. Before submitting a pull request, please review our contribution guide

Oracle gratefully acknowledges the contributions to oci-typescript-sdk that have been made by the community.

Security

Please consult the security guide for our responsible security vulnerability disclosure process

License

Copyright (c) 2020, Oracle and/or its affiliates. All rights reserved. This software is dual-licensed to you under the Universal Permissive License (UPL) 1.0 as shown at https://oss.oracle.com/licenses/upl or Apache License 2.0 as shown at http://www.apache.org/licenses/LICENSE-2.0. You may choose either license.

See LICENSE for more details.

Changes

See CHANGELOG.

Known Issues

  • You can find information on any known issues with the SDK at Oracle Cloud Infrastructure Known Issues and under the Issues tab of this project's GitHub repository.
  • JavaScript numbers have rounding issues for number greater than Number.MAX_SAFE_INTEGER, APIs with responses that contain number greater than Number.MAX_SAFE_INTEGER may result in rounding issues.

oci-typescript-sdk's People

Contributors

bhagwatvyas avatar cfjedimaster avatar davidkhala avatar joshunter avatar jyotisaini avatar oci-dex-release-bot avatar omkarvijay5 avatar recursivecodes avatar rkumarpa avatar spavlusieva avatar swkrkris avatar waruwaruwaru avatar y-chandra avatar ziyaoqiao avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

oci-typescript-sdk's Issues

Error: Too many requests for the user

I'm trying to list all the boot volumes from an account and save it in a database, but i'm receiving this error:

All retry attempts have exhausted. Total Attempts : 1. Last exception occurred : Error: Too many requests for the user
Error: Too many requests for the user
at Object.handleErrorResponse (/home/matheus/Área de Trabalho/lib/helper.ts:41:12)
at GenericRetrier. (/home/matheus/Área de Trabalho/lib/retrier.ts:223:31)
at Generator.next ()
at fulfilled (/home/matheus/Área de Trabalho/teste-boot/node_modules/oci-common/lib/retrier.js:9:58)
at processTicksAndRejections (node:internal/process/task_queues:95:5)
[ERROR] 16:20:43 Error: Too many requests for the user
All retry attempts have exhausted. Total Attempts : 1. Last exception occurred : Error: Too many requests for the user

Is it an error on my code, or OCI limits the amount of requests ?

How to contribute?

I wrote an example to list instances for a compartment in a new branch.

I tried to push it but it was denied. My thought process of contributing is like this.

  • Create a new branch locally.
  • Work on the code. Test it locally.
  • Commit the change.
  • Push it and create a PR out of it.
  • Get it reviewed.
  • Make changes as necessary.
  • PR gets approved.
  • Merged to master.

How does your team accept PRs? Could someone explain it please?

No matching version found for [email protected]

Environment:
Windows 10 Pro -> WSL Ubuntu 20
node version: v10.19.0
npm version: 6.14.4

Doing npm install oci-sdk causes npm dependency error:

Error:
npm ERR! code ETARGET
npm ERR! notarget No matching version found for [email protected].
npm ERR! notarget In most cases you or one of your dependencies are requesting
npm ERR! notarget a package version that doesn't exist.
npm ERR! notarget
npm ERR! notarget It was specified as a dependency of 'oci-sdk'
npm ERR! notarget

ENOENT uuid node package

Hi. I am getting randomly this error. But the file exists. I tried cat /usr/src/app/.../node_modules/oci-common/node_modules/uuid/v1.js and content was there. The error appear after I rebuild and reload application.

Error: ENOENT: no such file or directory, open '/usr/src/app/.../node_modules/oci-common/node_modules/uuid/v1.js'
    at Object.openSync (node:fs:590:3)
    at Object.readFileSync (node:fs:458:35)
    at Object.Module._extensions..js (node:internal/modules/cjs/loader:1172:18)
    at Module.load (node:internal/modules/cjs/loader:1033:32)
    at Function.Module._load (node:internal/modules/cjs/loader:868:12)
    at Module.require (node:internal/modules/cjs/loader:1057:19)
    at require (node:internal/modules/cjs/helpers:103:18)
    at Object.<anonymous> (/usr/src/app/.../node_modules/oci-common/lib/headers.js:11:16)
    at Module._compile (node:internal/modules/cjs/loader:1155:14)
    at Object.Module._extensions..js (node:internal/modules/cjs/loader:1209:10)
    at Module.load (node:internal/modules/cjs/loader:1033:32)
    at Function.Module._load (node:internal/modules/cjs/loader:868:12)
    at Module.require (node:internal/modules/cjs/loader:1057:19)
    at require (node:internal/modules/cjs/helpers:103:18)
    at Object.<anonymous> (/usr/src/app/.../node_modules/oci-common/lib/helper.js:19:19)
    at Module._compile (node:internal/modules/cjs/loader:1155:14)
    at Object.Module._extensions..js (node:internal/modules/cjs/loader:1209:10)
    at Module.load (node:internal/modules/cjs/loader:1033:32)
    at Function.Module._load (node:internal/modules/cjs/loader:868:12)
    at Module.require (node:internal/modules/cjs/loader:1057:19)
    at require (node:internal/modules/cjs/helpers:103:18)
    at Object.<anonymous> (/usr/src/app/.../node_modules/oci-common/lib/signer.js:17:18)
    at Module._compile (node:internal/modules/cjs/loader:1155:14)
    at Object.Module._extensions..js (node:internal/modules/cjs/loader:1209:10)
    at Module.load (node:internal/modules/cjs/loader:1033:32)
    at Function.Module._load (node:internal/modules/cjs/loader:868:12)
    at Module.require (node:internal/modules/cjs/loader:1057:19)
    at require (node:internal/modules/cjs/helpers:103:18)
    at Object.<anonymous> (/usr/src/app/.../node_modules/oci-common/index.js:32:29)
    at Module._compile (node:internal/modules/cjs/loader:1155:14)
    at Object.Module._extensions..js (node:internal/modules/cjs/loader:1209:10)
    at Module.load (node:internal/modules/cjs/loader:1033:32)
    at Function.Module._load (node:internal/modules/cjs/loader:868:12)
    at Module.require (node:internal/modules/cjs/loader:1057:19)
    at require (node:internal/modules/cjs/helpers:103:18)
    at Object.<anonymous> (/usr/src/app/.../node_modules/oci-objectstorage/lib/client.js:47:16)
    at Module._compile (node:internal/modules/cjs/loader:1155:14)
    at Object.Module._extensions..js (node:internal/modules/cjs/loader:1209:10)
    at Module.load (node:internal/modules/cjs/loader:1033:32)
    at Function.Module._load (node:internal/modules/cjs/loader:868:12)
    at Module.require (node:internal/modules/cjs/loader:1057:19)
    at require (node:internal/modules/cjs/helpers:103:18)
    at Object.<anonymous> (/usr/src/app/.../node_modules/oci-objectstorage/index.js:44:29)
    at Module._compile (node:internal/modules/cjs/loader:1155:14)
    at Object.Module._extensions..js (node:internal/modules/cjs/loader:1209:10)
    at Module.load (node:internal/modules/cjs/loader:1033:32)
    at Function.Module._load (node:internal/modules/cjs/loader:868:12)
    at Module.require (node:internal/modules/cjs/loader:1057:19)
    at require (node:internal/modules/cjs/helpers:103:18)
    at Object.55753 (eval at run (/usr/src/app/.../Engine/UserServer.js:56:25), <anonymous>:432:20349)
    at n (eval at run (/usr/src/app/.../Engine/UserServer.js:56:25), <anonymous>:432:1248067)
    at Object.36754 (eval at run (/usr/src/app/.../Engine/UserServer.js:56:25), <anonymous>:432:86497)
    at n (eval at run (/usr/src/app/.../Engine/UserServer.js:56:25), <anonymous>:432:1248067)
    at eval (eval at run (/usr/src/app/.../Engine/UserServer.js:56:25), <anonymous>:432:1248583)
    at eval (eval at run (/usr/src/app/.../Engine/UserServer.js:56:25), <anonymous>:432:1248593)
    at UserServer.run (/usr/src/app/.../Engine/UserServer.js:56:25)
    at Engine.startUserServer (/usr/src/app/.../Engine/index.js:395:42)
    at Engine.restartApp (/usr/src/app/.../Engine/index.js:334:28)
    at runMicrotasks (<anonymous>)
    at processTicksAndRejections (node:internal/process/task_queues:96:5) {
  errno: -2,
  syscall: 'open',
  code: 'ENOENT',
  path: '/usr/src/app/.../node_modules/oci-common/node_modules/uuid/v1.js'
}

Email Service Example

A Customer reached out to me for an example to use oci-email service to send emails. Creating an issue for tracking purposes.

Found line with no key-value pair: -----BEGIN RSA PRIVATE KEY-----

export class OciMediaUploadFactory {
	authenticationDetailsProvider = new common.ConfigFileAuthenticationDetailsProvider('~/.oci/oci_api_key.pem');
	client = new os.ObjectStorageClient({ authenticationDetailsProvider: this.authenticationDetailsProvider });
	async uploadMedia({ file, fileName }: { file: any; fileName: string }) {
		const request: os.requests.GetNamespaceRequest = {};
		const response = await this.client.getNamespace(request);
		const namespace = response.value;

		const putObjectRequest: os.requests.PutObjectRequest = {
			namespaceName: namespace,
			bucketName: '---------',
			putObjectBody: file.buffer,
			objectName: fileName,
			contentLength: file.size,
		};

		return this.client.putObject(putObjectRequest);
	}
}

I am getting the following error

[Nest] 111916   - 05/27/2022, 4:51:09 PM   [ExceptionHandler] Found line with no key-value pair: -----BEGIN RSA PRIVATE KEY-----
Error: Found line with no key-value pair: -----BEGIN RSA PRIVATE KEY-----
    at ConfigAccumulator.accept (/home/shanurrahman/lib/config-file-reader.ts:188:13)
    at /home/shanurrahman/lib/config-file-reader.ts:104:19
    at Array.forEach (<anonymous>)
    at Function.parse (/home/shanurrahman/lib/config-file-reader.ts:103:11)
    at Function.parseFileFromPath (/home/shanurrahman/lib/config-file-reader.ts:95:31)
    at new ConfigFileAuthenticationDetailsProvider (/home/shanurrahman/lib/auth/config-file-auth.ts:38:26)
    at new OciMediaUploadFactory (/home/shanurrahman/penny/apps/api-v2/dist/webpack:/libs/api-utils/providers/oci/storage.ts:5:34)
    at new MediaUploadFactory (/home/shanurrahman/penny/apps/api-v2/dist/webpack:/libs/api-utils/base/factory/media-upload.factory.ts:21:13)
    at Injector.instantiateClass (/home/shanurrahman/penny/node_modules/@nestjs/core/injector/injector.js:286:19)
    at callback (/home/shanurrahman/penny/node_modules/@nestjs/core/injector/injector.js:42:41)
    at processTicksAndRejections (internal/process/task_queues.js:95:5)
    at Injector.resolveConstructorParams (/home/shanurrahman/penny/node_modules/@nestjs/core/injector/injector.js:114:24)
    at Injector.loadInstance (/home/shanurrahman/penny/node_modules/@nestjs/core/injector/injector.js:46:9)
    at Injector.loadProvider (/home/shanurrahman/penny/node_modules/@nestjs/core/injector/injector.js:68:9)
    at async Promise.all (index 4)

image

Trying to List Instances

I am trying to get a list of instances. I am just starting to get into OCI SDK for JavaScript (TypeScript) so I am exploring the APIs right now.

When I try to execute the following code just to try, I do get the instances but the test doesn't seem to work for me. It succeeds no matter what. I may be missing something but I am wondering what I could do to get over the issue. It may be my lack of understandings of callbacks...

test('gets the list of instances in a compartment.', () => {
  const provider = getProvider(CONFIG_FILEPATH, PROFILE);
  const computeClient = new core.ComputeClient({
    authenticationDetailsProvider: provider,
  });
  computeClient.region = common.Region.US_ASHBURN_1;
  const listInstancesRequest = {
    compartmentId: testConfigData.tenancy_id,
  };
  computeClient.listInstances(listInstancesRequest).then(({ items }) => {
    expect(items[0].id).toEqual('adsf');
  });
});

How to get the value of an ORACLE Vault Secret?

I would like to get the value of an Oracle Vault Secret from inside an Oracle Function .
Like this: in Java or this in Python

In the examples I find only one example, if I send the encrypted value as a request.
But in the above case the encrypted value is stored in the vault...

issue with meta data response

There is an issue on response opcMeta in clients.js file. Please fix it if possible thanks.

 line 1988                  Object.assign(opcMeta, { k: v });  it should be  Object.assign(opcMeta, { [k]: v });

Question about authentication provider to use object storage.

Hi,
I'm using oci api library to make my application access object storage. I followed examples and accomplished my mission. But, I had to provide authencation information in file form. Examples use ConfigFileAuthenticationDetailsProvider() to provide authencation information.

But, I want to inject all of these properties in string form(environment variables - kubernetes configmap).
Do you have any alternative APIs to meet my needs?

Thank you

Failed to parse (unnamed) on Private Key

Hello, we just moved our stack to Oracle Cloud and I'm setting up the deployment to object-storage.
When I pass the configuration i get this error, I don't know if it is a bug or I'm doing something stupid.

Note that I tried both with Oracle generated pem and with local generated rsa

KeyParseError: Failed to parse (unnamed) as a valid auto format key: Failed to auto-detect format of key
    at Object.PrivateKey.parse [as parsePrivateKey] (/Users/user/Angular/frontend/node_modules/sshpk/lib/private-key.js:197:10)

const TENANCY = 'ocid1.tenancy.oc1........'
const USER = 'ocid1.user.oc1........'
const REGION = 'us-ashburn-1'
const FINGERPRINT = 'f7:40:4d:96:79..............'
const KEY_FILE = '~/Desktop/oracle/user/-09-29-10-43.pem'

const client = new ObjectStorage.ObjectStorageClient({
    authenticationDetailsProvider:
        new common.SimpleAuthenticationDetailsProvider(
            TENANCY,
            USER,
            FINGERPRINT,
            KEY_FILE,
            undefined,
            common.Region.fromRegionId(REGION),
        ),
})

[feat] kms.getKey return the SigningAlgorithm used in key creation

Currently, the returned info from kms.getKey come in following format

{
...
  definedTags: {},
  displayName: 'ec',
  freeformTags: {},

  keyShape: { algorithm: 'ECDSA', length: 32, curveId: 'NIST_P256' },
  protectionMode: 'SOFTWARE',
  lifecycleState: 'ENABLED',
  timeCreated: '2022-07-07T08:04:11.437Z',
  timeOfDeletion: null,
  restoredFromKeyId: null,
  replicaDetails: undefined,
  isPrimary: true,
  autoKeyRotationSchedule: null,
  autoKeyRotationStatus: null,
  externalKeyReference: null
}

While we can guess and map it back to enum SigningAlgorithm, can we let it return exactly same with the SigningAlgorithm string?

enum SigningAlgorithm {
        Sha224RsaPkcsPss = "SHA_224_RSA_PKCS_PSS",
        Sha256RsaPkcsPss = "SHA_256_RSA_PKCS_PSS",
        Sha384RsaPkcsPss = "SHA_384_RSA_PKCS_PSS",
        Sha512RsaPkcsPss = "SHA_512_RSA_PKCS_PSS",
        Sha224RsaPkcs1V15 = "SHA_224_RSA_PKCS1_V1_5",
        Sha256RsaPkcs1V15 = "SHA_256_RSA_PKCS1_V1_5",
        Sha384RsaPkcs1V15 = "SHA_384_RSA_PKCS1_V1_5",
        Sha512RsaPkcs1V15 = "SHA_512_RSA_PKCS1_V1_5",
        EcdsaSha256 = "ECDSA_SHA_256",
        EcdsaSha384 = "ECDSA_SHA_384",
        EcdsaSha512 = "ECDSA_SHA_512"
    }

Conflict with Kubernetes client

It is generally considered bad practice to mutate the prototype of a native object, probably because it often causes unintended far-reaching side-effects.

https://github.com/oracle/oci-typescript-sdk/blob/v1.10.0/lib/common/lib/waiter.ts#L13

In my case, it breaks the Kubernetes client's JSON serializer. As a matter of fact, them iterating over Arrays and Objects using for..in is not much better, but adding an enumerable property to the Array prototype is definitely worse.

I don't know what this method is used for, so I can't give a definitive solution, but a quick workaround would be to define the method as a non-enumerable property instead, so that it is at least not listed in for..in loops.

Steps for reproduction

  1. Create a minimal project with @kubernetes/client-node and oci-sdk as dependencies.
  2. Make sure you have a Kubernetes cluster running (maybe in OCI Container Engine).
  3. Import both clients, then attempt to query K8s API for any resource. Notice in this case that map-like objects list an additional undefined property with undefined value that should not exist. Also notice that list-like objects list an additional empty element that should not exist.
  4. Import both clients (if not already), then attempt to create a resource in K8s API. The operation will likely fail, because map-like objects will include an additional undefined property with an undefined value (unlikely to be rejected, but possible), and list-like objects will include an extra empty element (which is likely to be rejected).

What is expected

Accessing Kubernetes API with or without the OCI client in the same application should yield the same results. Namely, K8s resources should not list an additional invalid property, nor additional empty elements. In other words, accessing Kubernetes API in OCI Container Engine and other resources in OCI (perhaps to manage them as Kubernetes resources) from the same application should work properly.

For the record, this is their serializer:

https://github.com/kubernetes-client/javascript/blob/0.13.2/src/gen/model/models.ts#L1823

oci-sdk conflicts with @here/olp-sdk-authentication

I am not sure in which package the issue is, but when @here/olp-sdk-authentication is imported before oci package, all requests to Oracle Cloud return 404 Not Found error.

Request cannot be retried. Not Retrying. Exception occurred : Error: Not Found

Example:

const olpSdkAuthentication = require("@here/olp-sdk-authentication");
const { ConfigFileAuthenticationDetailsProvider } = require("oci-common");
const { StreamClient, models } = require("oci-streaming");

(async () => {
    const provider = new ConfigFileAuthenticationDetailsProvider();

    const client = new StreamClient({ authenticationDetailsProvider: provider });

    client.endpoint = '<endpoint>';
    const streamId = '<stream-id>';

    const response = await client.createGroupCursor({
        createGroupCursorDetails: {
            groupName: 'default',
            type: models.CreateGroupCursorDetails.Type.TrimHorizon,
            commitOnGet: true,
            },
        streamId: streamId
    });

    console.log("response.cursor.value", response.cursor.value);
})();

Node version: v10.24.1
npm version: 6.14.12

The issue is not happening if @here/olp-sdk-authentication is imported after the oci sdk.

cc @OleksiiZubko, to investigate, maybe the problem is on heremaps sdk side.

oci-objectstorage putObject with files larger than 128K

We are uploading files to OCI object storage from file streams (created with fs.createReadStream) using the oci-objectstorage putObject method. This is failing for files larger than 128K with the error message:

request to https://objectstorage.us-phoenix-1.oraclecloud.com/n/xxxxxxxxxxxx/b/xxxxx/o/file.bin failed, reason: socket hang up

According to the official example at https://github.com/oracle/oci-typescript-sdk/blob/master/examples/javascript/objectstorage.js we should use a NodeFSBlob object with the highWatermark parameter set to the file size.

Doing this resolves the error message above for >128K files but at the expense of loading the entire file into memory, which causes problems for large files. For example, a 1.7G file causes the Node process to be killed with an out of memory error.

Equally, using fs.createReadStream(path, {highWaterMark: stats.size}) and passing this stream to putObject gives the same behavior as described in the previous paragraph.

In any case, we don't want to load the entirety of files that we're about to upload to OCI OS into memory first, which is why we were using streams.

Our situation is that we are in the progress of migrating our Node.js code from the AWS SDK (S3 compatibility mode) to the native OCI SDK - we did not have this issue when using the AWS SDK.

Node version: 12.18.2
oci-objectstorage version: 1.14.0

"OciError: unknown reason." during headBucket request

Hello,

I wrote my application creating bucket and creating preauthenciated request with you examples.
And it works alright.
This time, I wanted to check if the bucket already exists. So I added code snippets below.

try {
    const bucketName = config.services.storagemgmt.bucketPrefix + reqSvc;
    console.log('bucketName ', bucketName);
    const headBucketReq: os.requests.HeadBucketRequest = {
          namespaceName: this.namespace,
          bucketName
    };
    console.log('headBucketReq --------', headBucketReq);
    const hb = await this.client.headBucket(headBucketReq);
    console.log('hb-----------------------', hb);
} catch (e) {
    console.error('error caught...------', e);
    return null;
}

and its output is

headBucketReq -------- { namespaceName: 'cnkxfskwuk3c', bucketName: 'cronghomedevicemgmt' }
Cannot parse data into JSON
error caught...------
OciError: unknown reason.
    at Object.handleErrorResponse (/Users/cronglee/project/smartwork/svc/storagemgmtservice/src/node_modules/oci-common/lib/helper.js:41:16)
    at GenericRetrier.<anonymous> (/Users/cronglee/project/smartwork/svc/storagemgmtservice/src/node_modules/oci-common/lib/retrier.js:76:54)
    at Generator.next (<anonymous>)
    at fulfilled (/Users/cronglee/project/smartwork/svc/storagemgmtservice/src/node_modules/oci-common/lib/retrier.js:9:58)
    at processTicksAndRejections (internal/process/task_queues.js:97:5) {
  statusCode: 404,
  serviceCode: 'unknown code',
  opcRequestId: 'icn-1:5NfTpujr6Ds0INSN1FyWQXTNF9_S8RFK-3Npexsnb-Uyj75BrKzGKYfRKq-iRxJW'
}

I compared my code with the example in https://docs.oracle.com/en-us/iaas/tools/typescript-sdk-examples/1.10.0/objectstorage/HeadBucket.ts.html. But I don't see any big difference.

What is wrong with me?

Thank you.

Unable to use version 2.10.0 of the SDK

Scenario
In Dec 20, 2021, I try to bump my npm dependency to latest

"dependencies": {
    "oci-sdk": "latest"
  },

I see error like

npm ERR! code ETARGET
npm ERR! notarget No matching version found for [email protected].
npm ERR! notarget In most cases you or one of your dependencies are requesting
npm ERR! notarget a package version that doesn't exist.

oci-objectstorage Upload Manager doesn't work with empty files

When trying to use upload manager to upload an empty file we receive the error:

node 12.16.1
oci-sdk versions 1.19.5 & 2.3.1

Failed due to RangeError [ERR_OUT_OF_RANGE]: The value of "end" is out of range. It must be >= 0 and <= 2 ** 53 - 1. Received -1

getZone returns 'only absolute urls are supported'

I've encountered a problem with the getZone function that I could use some input on. Here's a quick and dirty example from the OCI Cloud Shell:

james_hart@cloudshell:~ (us-ashburn-1)$ node
> const oci = require("oci-sdk");
undefined
> const authenticationProvider = new oci.common.ConfigFileAuthenticationDetailsProvider();
undefined
> const client = new oci.dns.DnsClient({authenticationProvider});
undefined
> var getZoneRequest = {
... zoneNameOrId: "elcaro.io"
... }
undefined
> const getZoneResponse = client.getZone(getZoneRequest);
undefined
> (node:885) UnhandledPromiseRejectionWarning: Error: only absolute urls are supported

I've tried passing an OCID instead of the name with the same result. This payload works fine with the OCI CLI or the Python SDK. Any thoughts?

Upload Manager error on multiple files

During the deployment I have to upload a folder with 1000+ files

;(function () {
   // walk is a function to recursively read sundirectories and files
    walk('./build', async (err, res) => {
        for (const entry of res) {
            const objectName = `${entry[0]}`

            try {
                uploadManager
                    .upload({
                        content: {
                            filePath: join('./build', entry[0]),
                        },
                        requestDetails: {
                            bucketName: BUCKET,
                            objectName: objectName,
                            namespaceName: NAMESPACE
                        },
                    })
                    .then(() => console.log(`Uploaded ${objectName}`))
            } catch (err) {
                console.log(err)
            }
        }
    })
})()

in console I have this output for almost every file


putObject failed, will retry. Last known error: Error: request to https://objectstorage.us-ashburn-1.oraclecloud.com/n/id93c1ew8b1b/b/frontend-build-it/o/assets%2Fimages%2Fflags%2F4x3%2Fgm.svg failed, reason: Client network socket disconnected before secure TLS connection was established
All retry attempts have exhausted. Total Attempts : 1. Last exception occurred : Error: request to https://objectstorage.us-ashburn-1.oraclecloud.com/n/id93c1ew8b1b/b/frontend-build-it/o/assets%2Fimages%2Fflags%2F4x3%2Far.svg failed, reason: Client network socket disconnected before secure TLS connection was established

I've tried with the await uploadManager()... as in the example files, it works but for my use case it takes hours to upload the entire folder

Idea: Add Cloudflare workers support

Hi! First of all thanks for such a great sdk. It's very easy to set up a project from scratch with it, but I have an idea for authors, It would be great to have the sdk works on cloudflare workers or at least some of the libraries like nosql, database or objectstorage similarly like it was done for aws sdk. What do you think?

isomorphic-fetch - outdated - denial of service

isomorphic-fetch relies on a vulnerable version of node-fetch. It should be updated. See below for details.

node-fetch <=2.6.0 || 3.0.0-beta.1 - 3.0.0-beta.8
Denial of Service - https://npmjs.com/advisories/1556

isomorphic-fetch 2.0.0 - 2.2.1
Depends on vulnerable versions of node-fetch
node_modules/isomorphic-fetch
oci-common *
Depends on vulnerable versions of isomorphic-fetch

oci-objectstorage Upload Manager doesn't work with large files

Follow up from issue: #50

This library is still not useable for us for uploading files to object storage, as it appears that the entire file is being loaded into memory, which causes problems for large files. For example, a 1.5G file causes the Node process to be killed with an out of memory error.

Here is my test code:

const storageClient = new OciObjectStorage.ObjectStorageClient({
  authenticationDetailsProvider: new OciCommon.SimpleAuthenticationDetailsProvider(
    config.OBJECT_STORAGE.TENANCY,
    config.OBJECT_STORAGE.USER_ID,
    config.OBJECT_STORAGE.FINGERPRINT,
    config.OBJECT_STORAGE.PRIVATE_KEY,
    undefined, // no passphrase
    OciCommon.Region.fromRegionId(config.OBJECT_STORAGE.REGION)
  ),
});

const uploadManager = new OciObjectStorage.UploadManager(storageClient);

uploadManager.upload({
  content: {
    filePath: '/tmp/file.bin',
  },
  requestDetails: {
    namespaceName: config.OBJECT_STORAGE.NAMESPACE,
    bucketName: 'dev',
    objectName: 'exports/file.bin',
  },
}).then((value) => {
  console.log(value);
});

This results in high memory usage for the process (which looks like the whole file is being loaded into memory), and the following error message:

error from defaultErrorFunction:  Error: Timed out after 10000ms
    at buildError (/opt/skulk/node_modules/opossum/lib/circuit.js:699:17)
    at Timeout.<anonymous> (/opt/skulk/node_modules/opossum/lib/circuit.js:504:29)
    at listOnTimeout (internal/timers.js:555:17)
    at processTimers (internal/timers.js:498:7) {
  code: 'ETIMEDOUT',
  [Symbol(our-error)]: true
}
Request failed with Exception : Error: Timed out after 10000ms

Node.js version: 14.17.0
oci-typescript-sdk version: 2.1.0

Default Retries and Default Circuit breakers in the SDK versions 2.0.0+

Retries by default

Starting with version 2.0.0, the SDK for Typescript and Javascript will support default retries. This means that if you are using the SDK to call service API operations, and the operations fail with a retry-able error, then the SDK by default will retry the operation according to the default retry policy.

If you are using the OCI SDKs and have custom logic for retrying on failing operations and which does not use the retry policy feature (https://docs.oracle.com/en-us/iaas/Content/API/SDKDocs/typescriptsdkconcepts.htm#ariaid-title4), this would result in retries on top of retries. For users that would like to opt-out of the new default retries feature, the SDK provides an option to opt-out.

To opt out of SDK default retry, users can set the environment variable - OCI_SDK_DEFAULT_RETRY_ENABLED as false (lowercase)

Additionally, users can change the global default retry configuration programmatically by calling -

  let retryConfiguration : common.RetryConfiguration = {
    terminationStrategy : new common.MaxAttemptsTerminationStrategy(1)
	};
  common.GenericRetrier.defaultRetryConfiguration = retryConfiguration;

Overriding behavior for retries

Any retry configuration explicitly defined by the user at the request level will override the client level retry configuration or the global level default retry configuration and the environment variable override for the particular request. Any retry configuration explicitly defined at the client level will override the global default retry configuration and the environment variable level override for the particular client. Default retry configuration set at the global level programmatically will override the environment variable level override

Defaut Retry Configuration

For the default retry configuration and the list of errors that are treated as retry-able, check https://github.com/oracle/oci-typescript-sdk/blob/master/lib/common/lib/retrier.ts#L90

Circuit breakers by default

Starting with version 2.0.0, the SDK for Typescript and Javascript will support default circuit breakers. Circuit breakers in the SDKs are intended to prevent the client from overwhelming the service by blocking the requests from being sent to the service when a certain failure threshold has been reached. For default circuit breakers, all retry-able errors will be treated as failures for the circuit breakers.

For users that would like to opt-out of the new default circuit breaker feature, the SDK provides an option to opt-out.

To opt out of SDK default circuit breaker, users can set the environment variable - OCI_SDK_DEFAULT_CIRCUITBREAKER_ENABLED as false (lowercase)

This can also be achieved programmatically by calling -

common.CircuitBreaker.EnableGlobalCircuitBreaker = false

To change the default circuit breaker configuration at the global level :

let customDefaultCircuitBreakerConfig = {
    timeout: 10000, // If our function takes longer than 10 seconds, trigger a failure
    errorThresholdPercentage: 80, // When 80% of requests fail, trip the circuit
    resetTimeout: 30000, // After 30 seconds, try again.
    rollingCountTimeout: 120000, // the duration of the statistical rolling window, in milliseconds
    rollingCountBuckets: 120, // the number of buckets the rolling statistical window is divided into
    volumeThreshold: 10, // minimum number of failures in the circuit
    errorFilter: defaultErrorFilterFunction // defines the failure filter for the circuit
  };
common.CircuitBreaker.defaultConfiguration = customDefaultCircuitBreakerConfig;

For an example on how to change the default circuit breaker configuration at the client level, check https://github.com/oracle/oci-typescript-sdk/blob/master/examples/typescript/circuit-breaker.ts

Circuit Breaker and Default Circuit Breaker Configuration

For information on circuit breakers and the default circuit breaker configuration, check https://github.com/oracle/oci-typescript-sdk/blob/master/lib/common/lib/circuit-breaker.ts

Overriding behavior for circuit breaker

Any circuit breaker configuration explicitly defined at the client level will override the global default circuit breaker configuration and the environment level override for the particular client

How to add ssh keys when using launch_instance

Hey there Oracle team. I am using your Javascript SDK and have been successful in launching an instance on OCI. However, I am not able to figure out for the life of me how to add my ssh keys to the instance through the API. I need to add my SSH keys to the instance I am launching to complete my automation task.

In the Python SDK you can do this. Thank you for your help!

SDK 2.5 Multipart Upload Computed Hash Error on Large Files

Using SDK2.5.0 we are getting the following error on large files:

Request cannot be retried. Not Retrying. Exception occurred : Error: The computed MD5 hash (acBf4HGRKHDC1NO/O3QuZQ==) does not match the expected MD5 hash (4r81kp2g5acDaMwPI7WdXA==)
Upload part failed, will retry. Last known error: Error: The computed MD5 hash (acBf4HGRKHDC1NO/O3QuZQ==) does not match the expected MD5 hash (4r81kp2g5acDaMwPI7WdXA==)

OCI-objectstorage is too dependent on fs.createReadStream to transfer objects

Most App Dynos do not allow storage of even temporary files( even small ones) on their servers. Most use Amazon S3 as their primary way around this by sending the created file to S3 and then accessing the data, essentially what most of your Use Case requires. Also because the code is dependent on fs. the function will always add this header:
[ '----------------------------622545709057705753853273\r\nContent-
Disposition: form-data; name="file"; filename="tickets.pdf"\r\nContent-Type: application/pdf\r\n\r\n' to the blob data.

Obviously Object Storage is able to decipher this, I suggest an enhancement that will allow you to send either formData or as a generic blob object from the web app either client side or via backend to the storage and not be reliant on the fs feature to get data to your object store since fs requires a file path to work, if you can't store a file, you can't leverage fs.

If there is a work around of not having the createReadStream format in the putObjectBody: prop I would love to hear it.

Thanks

Brian

Are there any alternatives for OCI config file?

I'm receiving the credentials dynamically through HTTP, there is no config file. So, the following code won't work for me:

const provider: common.ConfigFileAuthenticationDetailsProvider = new common.ConfigFileAuthenticationDetailsProvider();
const client = new identity.IdentityClient({ authenticationDetailsProvider: provider });

I need to set up the ConfigFileAuthenticationDetailsProvider in another way.

I found this doc that says:

If you're using one of the Oracle SDKs or tools, supply the required credentials in either a configuration file or a config object in the code.

How could I authenticate by passing a config object instead of a config file?

Error get ReadableStream from ObjectStorageClient on nodejs 18.7.0

Hi on nodejs 18.7.0 bug from get ReadableStream from ObjectStorageClient.

I use the getObject function and get this message:

(node:12872) ExperimentalWarning: The Fetch API is an experimental feature. This feature could change at any time
(Use node --trace-warnings ... to show where the warning was created)

And I got this response
ReadableStream { locked: false, state: 'readable', supportsBYOB: false }

But if i use nodejs 16.16.+ version, i receive normal stream

PassThrough { _readableState: ReadableState { objectMode: false, highWaterMark: 16384, buffer: BufferList { head: [Object], tail: [Object], length: 1 }, length: 1956, pipes: [], flowing: null, ended: false, endEmitted: false, reading: true, constructed: true, sync: false, needReadable: true, emittedReadable: false, readableListening: false, resumeScheduled: false, errorEmitted: false, emitClose: true, autoDestroy: true, destroyed: false, errored: null, closed: false,

XMLHttpRequest is not defined

I'm trying to upload a file according to an example. But the oci-common uses the browser implementation of fetch pollyfil instead of node implementation and hence I get the error

ReferenceError: XMLHttpRequest is not defined
    at C:\...\node_modules\whatwg-fetch\dist\fetch.umd.js:514:17
    at new Promise (<anonymous>)
    at fetch (C:\...\node_modules\whatwg-fetch\dist\fetch.umd.js:507:12)
    at Function.<anonymous> (C:\...\node_modules\oci-common\lib\circuit-breaker.js:23:40)
    at Generator.next (<anonymous>)
    at C:\...\node_modules\oci-common\lib\circuit-breaker.js:12:71
    at new Promise (<anonymous>)
    at __awaiter (C:\...\node_modules\oci-common\lib\circuit-breaker.js:8:12)
    at C:\...\node_modules\oci-common\lib\circuit-breaker.js:21:49
    at new Promise (<anonymous>)
    at Function.<anonymous> (C:\...\node_modules\oci-common\lib\circuit-breaker.js:21:16)
    at Generator.next (<anonymous>)
    at C:\...\node_modules\oci-common\lib\circuit-breaker.js:12:71
    at new Promise (<anonymous>)
    at __awaiter (C:\...\node_modules\oci-common\lib\circuit-breaker.js:8:12)
    at Function.FetchWrapper (C:\...\node_modules\oci-common\lib\circuit-breaker.js:20:12)
    at C:\...\node_modules\opossum\lib\circuit.js:521:38
    at new Promise (<anonymous>)
    at CircuitBreaker.call (C:\...\node_modules\opossum\lib\circuit.js:497:12)
    at CircuitBreaker.fire (C:\...\node_modules\opossum\lib\circuit.js:415:22)
    at FetchHttpClient.<anonymous> (C:\...\node_modules\oci-common\lib\http.js:76:26)
    at Generator.next (<anonymous>)
    at fulfilled (C:\...\node_modules\oci-common\lib\http.js:28:58)
    at processTicksAndRejections (node:internal/process/task_queues:96:5)

Defer from using console related functions(eg: log, warn or error)

If I may suggest, drop the use of console related logs and add no-console eslint rule to the project. Use the logger that you already have. Make use of debug logging concept not the intrusive way.

One justifiable reason for this is, our implementors usually don't care the details we have in those console.logs/error/warn. If ever they care about it, they can turn on the debugging so that they will see these. Second, which I am currently facing, I am creating a cli prompt for the user, and the known errors like not found bucket distract the user experience.

oci-objectstorage TypeScript type definition error: Interface 'UploadableBlob' incorrectly extends interface 'Blob'

I'm getting this error when compiling a TypeScript application that uses oci-objectstorage:

node_modules/oci-objectstorage/lib/upload-manager/uploadable-blob.d.ts:6:18 - error TS2430: Interface 'UploadableBlob' incorrectly extends interface 'Blob'.
  The types returned by 'stream()' are incompatible between these types.
    Type 'ReadableStream<any>' is missing the following properties from type 'ReadableStream': readable, read, setEncoding, pause, and 22 more.

6 export interface UploadableBlob extends Blob {
                   ~~~~~~~~~~~~~~

Versions:

  • oci-common: ^2.6.1
  • oci-objectstorage: ^2.6.1
  • typescript: ^4.4.4

[fix][README] Feedback link deactivated.

The link on README is found deactivated.

Are you a Developer using the OCI SDK? If so, please fill out our survey to help us make the OCI SDK better for you. [Click here](https://oracle.questionpro.com/t/APeMlZka26?custom3=npmjs).

Believing that the survey has ended, it is time to remove it.

Incorrect types for usageapi

I was going to submit a PR, but the files say they're automatically generated at the top, so I don't know if this code is actually written by people. I can still submit a PR if you wish.

There are two problems with the types in the usageapi package.

First, the tags property of UsageSummary should not be optional. From what I can tell, tags are always returned. I tested this is the case in the following scenarios:

  • groupByTag is [{namespace: 'mycompany', key: 'project'}]
  • groupBy is ['service']
  • neither groupBy nor groupByTag is used
  • filter is {operator: 'NOT', tags: [{namespace: 'mycompany', key: 'project'}]

Second, the RequestSummarizedUsagesDetails interface doesn't include groupByTag. Obviously, it should. Since groupBy and groupByTag are mutually exclusive, you've got a couple options here:

  1. Set both to optional and handle the mutual exclusion in the client code (or, I suppose, just let the server reject it -- see below).
  2. Make a type that enforces only one or the other. You can do this with some unions and intersections that enforce never on the other property:
export interface GroupBy {
  /**
   * Aggregate the result by. Mutually exclusive with `groupByTag`.
   * example:
   *   `[\"service\"]`
   */
  "groupBy"?: Array<string>;
  "groupByTag"?: never;
}

export interface GroupByTag {
  /**
   * Group by a specific tag key. Provide the namespace and key in the tag object.
   * Only supports one tag in the list. Mutually exclusive with `groupBy`.
   * For example:
   * `[{"namespace":"oracle", "key":"createdBy"}]`
   */
  "groupByTag"?: Array<Tag>;
  "groupBy"?: never;
}

// Using Omit here to show you'd remove `groupBy` from the existing interface
export type RequestSummarizedUsagesDetailsActual = Omit<RequestSummarizedUsagesDetails, 'groupBy'> & (GroupBy | GroupByTag);

This is nice because an IDE will know it fails the type check, though tsc doesn't understand XORs natively so you end up with an error message like:

Type '{ granularity: RequestSummarizedUsagesDetails.Granularity.Daily; tenantId: string; timeUsageEnded: Date; timeUsageStarted: Date; groupBy: string[]; groupByTag: { ...; }[]; }' is not assignable to type 'RequestSummarizedUsagesDetailsActual'.
  Type '{ granularity: RequestSummarizedUsagesDetails.Granularity.Daily; tenantId: string; timeUsageEnded: Date; timeUsageStarted: Date; groupBy: string[]; groupByTag: { ...; }[]; }' is not assignable to type 'Pick<RequestSummarizedUsagesDetails, "granularity" | "queryType" | "tenantId" | "timeUsageEnded" | "timeUsageStarted" | "compartmentDepth" | "filter"> & GroupByTag'.
    Type '{ granularity: RequestSummarizedUsagesDetails.Granularity.Daily; tenantId: string; timeUsageEnded: Date; timeUsageStarted: Date; groupBy: string[]; groupByTag: { ...; }[]; }' is not assignable to type 'GroupByTag'.
      Types of property '"groupBy"' are incompatible.
        Type 'string[]' is not assignable to type 'undefined'.

Also worth mentioning: if you pass both groupBy and groupByTag to the API, you actually get an error message that references an incorrect parameter:

{
  "code" : "InvalidParameter",
  "message" : "groupBy must be null when groupByTagKey isn't empty"
}

Obviously, that should be groupByTag, not groupByTagKey. If you try to make a request that includes groupByTagKey, it rejects the request saying it's an invalid parameter.

Different Response Linux/Windows

Hi guys,

We test the oci-object-storage:2.50.0 npm on a new project to get saved objects to our customers. But we have a situation where the code works perfectly with windows and does not work when run over linux (ALPINE distro docker).

The code above gets different results on windows and linux:

const resp = await client.getObject({
bucketName,
namespaceName,
objectName
});

On Windows, the response has value (ReadableStream) and on linux has an empty object on value.

There's no exception occurring running over linux/windows, but the response are different.

WINDOWS RESPONSE:

{"value":{"_readableState":{"objectMode":false,"highWaterMark":16384,"buffer":{"head":{"data":{"type":"Buffer","data":[...DATA]},"next":null},"length":1},"length":1957,"pipes":[],"flowing":null,"ended":false,"endEmitted":false,"reading":true,"constructed":true,"sync":false,"needReadable":true,"emittedReadable":false,"readableListening":false,"resumeScheduled":false,"errorEmitted":false,"emitClose":true,"autoDestroy":true,"destroyed":false,"errored":null,"closed":false,"closeEmitted":false,"defaultEncoding":"utf8","awaitDrainWriters":null,"multiAwaitDrain":false,"readingMore":false,"dataEmitted":false,"decoder":null,"encoding":null},"_events":{"error":[null,null]},"_eventsCount":5,"_writableState":{"objectMode":false,"highWaterMark":16384,"finalCalled":false,"needDrain":false,"ending":false,"ended":false,"finished":false,"destroyed":false,"decodeStrings":true,"defaultEncoding":"utf8","length":0,"writing":false,"corked":0,"sync":false,"bufferProcessing":false,"writecb":null,"writelen":0,"afterWriteTickInfo":null,"buffered":[],"bufferedIndex":0,"allBuffers":true,"allNoop":true,"pendingcb":0,"constructed":true,"prefinished":false,"errorEmitted":false,"emitClose":true,"autoDestroy":true,"errored":null,"closed":false,"closeEmitted":false},"allowHalfOpen":true},"opcRequestId":"gru-1:xlSlsk_44ks7xNdU2eK9sEFtmpNMbhdV8CY63SrodPFjBE88B-TWTxB7ysUjgAL1","eTag":"765725ea-7266-4222-9a8c-bdf649f90b0f","contentLength":47478,"contentMd5":"rAxKXPwu/yG+abfX0C8tAQ==","contentType":"image/jpeg","cacheControl":"public, max-age=2555778733956","lastModified":"2022-12-27T15:32:14Z","storageTier":"Standard","versionId":"9f7a0ed1-28f9-4b25-9e40-1fee73f6d294","opcMeta":{}}

LINUX RESPONSE:

{"value":{},"opcRequestId":"gru-1:AGzNCaT7SjNJtYCazPfE2IsM16yd3EPhuvxgIds8xLYIoTZjaqN4p2j7gKC3zmvo","eTag":"765725ea-7266-4222-9a8c-bdf649f90b0f","contentLength":47478,"contentMd5":"rAxKXPwu/yG+abfX0C8tAQ==","contentType":"image/jpeg","cacheControl":"public, max-age=2555778733956","lastModified":"2022-12-
27T18:32:14Z","storageTier":"Standard","versionId":"9f7a0ed1-28f9-4b25-9e40-1fee73f6d294","opcMeta":{}}

Any idea what's going on?

How to execute examples

I've written Python scripts using OCI Python SDK quite a bit but I am relatively new to executing Typescript/Javascript though I have experiences in very old JavaScript. It would be great to show how to execute samples. And I think it would be great to mention to have the ~/.oci/config file ready or at least mention that OCI CLI setup is a prerequisite.

It would also be nice to learn how one can start to contribute. What are the prerequisites? What kind of environment would you recommend? If this is something I could contribute by doing research, I will do so. I would like to contribute! :)

Socket hangup when uploading multiple files.

Hello,

I am developing a application that scans a folder, and uploads any file to oracle-object-storage. The uploads run in parallel, and
very often i Run into this error:

OciError: request to [...] failed, reason: socket hang up
ora-object-storage-uploader_1 | at GenericRetrier. (/app/node_modules/oci-common/lib/retrier.js:83:38)
ora-object-storage-uploader_1 | at Generator.throw ()
ora-object-storage-uploader_1 | at rejected (/app/node_modules/oci-common/lib/retrier.js:10:65)
ora-object-storage-uploader_1 | at processTicksAndRejections (internal/process/task_queues.js:97:5) {
ora-object-storage-uploader_1 | statusCode: 'ECONNRESET',
ora-object-storage-uploader_1 | serviceCode: 'unknown code',
ora-object-storage-uploader_1 | opcRequestId: 'unknown'

Here is my code:

const common = require('oci-common');

const { ObjectStorageClient } = require('oci-objectstorage');
const { UploadManager } = require('oci-objectstorage');

const fs = require('fs');
const pathToWatch = '/x';
const watcher = chokidar.watch(pathToWatch, {
  persistent: true,
  ignoreInitial: false,
  followSymlinks: true,
  depth: 99,
  awaitWriteFinish: {
    pollInterval: 5000,
    stabilityThreshold: 10000,
  },
});

watcher.on('add', (path) => {
  console.log('new File found', path);
  upload(path, 1);
});

const provider = new common.ConfigFileAuthenticationDetailsProvider('./.ora-config');
const oraClient = new ObjectStorageClient({ authenticationDetailsProvider: provider });

function upload(path, tryCount) {
  const uploadManager = new UploadManager(oraClient, { enforceMD5: true });

  const loggerCallback = (res) => {
    console.log('Progress: ', res);
  };

  uploadManager
    .upload(
      {
        content: { filePath: path },
        requestDetails: {
          namespaceName: 'x',
          bucketName: 'x',
          objectName: path,
        },
      },
      loggerCallback,
    )
    .then(() => {
      console.log('SUCESS', path);
      fs.unlink(path, (err) => {
        if (err) {
          console.log('error removing file', path);
        } else {
          console.log('file removed:', path);
        }
      });
    })
    .catch((err) => {
      console.log('error uploading', err, path);
      console.log(`retrying  ${path}. Tentativa ${++tryCount}`);
      upload(path, tryCount);
    });
}

Am I doing something wrong, or there is something wrong with the api? Some files only succeed after five attempts.
Also note that this code uploads the files concurrently, sometimes running with 8 100mb files concurrently.

Ah, this code runs on oracle cloud region sa-saopaulo-1 on a E4.flex with 4 OCPU's and 4G RAM.

Thanks in advance.

Typescript compile error on object storage SDK

Hi, I'm introcuded recently to oracle cloud.
I'm trying to build a little application to prove my object storage management strategy concept. Before writing my own code, I just wanted to try SDK and know how to set credentials on it.
However, when I built the typescript example source file which is in example directory (https://github.com/oracle/oci-typescript-sdk/blob/master/examples/typescript/objectstorage.ts), error comes from node_modules/oci-objectstorage/lib/upload-manager/node-fs-blob.d.ts.

The error message is

node_modules/oci-objectstorage/lib/upload-manager/node-fs-blob.d.ts:8:22 - error TS2420: Class 'NodeFSBlob' incorrectly implements interface 'UploadableBlob'.
  Type 'NodeFSBlob' is missing the following properties from type 'UploadableBlob': arrayBuffer, stream, text

8 export declare class NodeFSBlob implements UploadableBlob {
                       ~~~~~~~~~~


Found 1 error.

Fortunately, objectstorate.ts file is successfully converted to javascript file and I could access object storage using SDK.

Do you mind check the error above out?

my packages.json is

{
  "scripts": {
    "clean": "rm -rf dist",
    "prebuild": "tslint -c tslint.json -p tsconfig.json --fix",
    "build": "yarn clean && tsc",
    "prestart": "yarn build",
    "start": "tsc --watch & nodemon dist/index.js",
    "start-service": "node dist/index.js",
    "test": "jest",
    "pre-commit": "yarn tslint && yarn build",
    "tslint": "tslint --project tsconfig.json",
    "tslint:fix": "tslint --project tsconfig.json --fix"
  },
  "dependencies": {
    "oci-objectstorage": "^1.10.0"
  },
  "devDependencies": {
    "tslint": "^5.20.1",
    "typescript": "^3.6.4"
  }
}

and node version is just the same as you mentioned in readme.md

$ node -v
v10.15.3

Thank you

Issue While Using the SDK-

Hi, I tried running one example under typescript(identity.js) . while running i am getting below error.

reason: getaddrinfo EAI_AGAIN identity.us-ashburn-1.oci.oraclecloud.com
at GenericRetrier. (c:\Codebase\oci-typescript-sdk-master\oci-typescript-sdk-master\lib\common\lib\retrier.ts:182:26)
at Generator.throw ()
at rejected (c:\Codebase\oci-typescript-sdk-master\oci-typescript-sdk-master\lib\common\lib\retrier.ts:10:65)
at processTicksAndRejections (node:internal/process/task_queues:96:5) {
statusCode: 'EAI_AGAIN',
serviceCode: 'unknown code',
opcRequestId: 'unknown'
}
Note: I have setup .oci\config details also under the home directory,
Can somebody provide some insight on how to resolve this issue. Thanks

Error with SimpleAuthenticationDetailsProvider

I'm creating a SimpleAuthenticationDetailsProvider because I'm using Vercel, but I'm getting an error.

Error:

{
  "code": undefined,
  "message": "Cannot parse host from url",
  "requestEndpoint": "GET /n/.../b/.../o",
  "troubleshootingPage": "See https://docs.oracle.com/en-us/iaas/Content/API/Concepts/sdk_troubleshooting.htm for help troubleshooting this error, or contact support and provide this full error message."
}

my function:

import * as os from "oci-objectstorage";
import * as common from "oci-common";
import path from "path";
import fs from "fs";

async function authUser() {
  const config = JSON.parse(await fs.promises.readFile(path.join(process.cwd(), "src/storage/oci.json"), "utf8"));
  const {
    tenancy,
    user,
    fingerprint,
    private_key,
    // region
  } = config;

  const provider = new common.SimpleAuthenticationDetailsProvider(tenancy, user, fingerprint, private_key, null);
  return new os.ObjectStorageClient({ authenticationDetailsProvider: provider });
}

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.