Skip to content

Commit

Permalink
Merge pull request #8 from anduril/andurilchao-patch-1
Browse files Browse the repository at this point in the history
Update README.md
  • Loading branch information
chao-anduril authored Aug 7, 2024
2 parents dac7b38 + 320ff93 commit fbc8617
Showing 1 changed file with 45 additions and 32 deletions.
77 changes: 45 additions & 32 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,24 @@
# anduril-javascript
# Anduril SDK Javascript

The official [Anduril](https://www.anduril.com/) client library.

## Requirements

[Active LTS Node.js version](https://nodejs.org/en/about/previous-releases)
08/24: Node.js 20 or later

## Installation

### Authentication

To authenticate with the Github package repository, you will need to generate a [personal access token](https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/managing-your-personal-access-tokens#creating-a-personal-access-token-classic). This should have at least `read:packages` scope. Please keep the token safe for the next stage of the setup procedure.

### .npmrc
Create a file in the package directory

```
@anduril:registry=https://npm.pkg.github.com
//npm.pkg.github.com/:_authToken=<TOKEN>
//npm.pkg.github.com/:_authToken=<GITHUB_PERSONAL_ACCESS_TOKEN>
```

### package.json
Expand All @@ -20,45 +33,45 @@ Create a file in the package directory
}
```

### Index.ts
## Usage

Index.ts

```ts
import { EntityManagerAPI } from "@anduril/anduril-javascript/src/anduril/entitymanager/v1/entity_manager_api.pub_connect";
```javascript
import { EntityManagerAPI } from "@anduril/anduril-javascript/src/anduril/entitymanager/v1/entity_manager_api.pub_connect.js";
import { createGrpcTransport } from "@connectrpc/connect-node";
import { createPromiseClient } from "@connectrpc/connect";
import { PublishEntitiesRequest } from "@anduril/anduril-javascript/src/anduril/entitymanager/v1/entity_manager_api.pub_pb";
import { Entity } from "@anduril/anduril-javascript/src/anduril/entitymanager/v1/entity.pub_pb";
import { createWritableIterable } from "@connectrpc/connect/protocol";
import { PartialMessage } from "@bufbuild/protobuf";
import { Entity } from "@anduril/anduril-javascript/src/anduril/entitymanager/v1/entity.pub_pb.js";

const transport = createGrpcTransport({
// Requests will be made to <baseUrl>/<package>.<service>/method
baseUrl: "https://desert-guardian.anduril.com",
// You have to tell the Node.js http API which HTTP version to use.
httpVersion: "2",
// Interceptors apply to all calls running through this transport.
interceptors: [],
});
// Requests will be made to <baseUrl>/<package>.<service>/method
baseUrl: "https://desert-guardian.anduril.com",

// You have to tell the Node.js http API which HTTP version to use.
httpVersion: "2",

// Interceptors apply to all calls running through this transport.
interceptors: [],
});

async function main() {
const client = createPromiseClient(EntityManagerAPI, transport);
const headers = new Headers();
headers.set("Authorization", "Bearer <BEARER TOKEN>");

const entity = new Entity({
entityId: "asdasd",
isLive: true,
description: "A new entity",
})

const resPut = await client.putEntity(request,{ headers: headers });
console.log(resPut);
const client = createPromiseClient(EntityManagerAPI, transport);
const headers = new Headers();
headers.set("Authorization", "Bearer <YOUR BEAERER TOKEN>");

const response = await client.getEntity(
{ entityId: "<ENTITY ID>" },
{ headers: headers },
);
console.log(response);
}

void main();

```

## Support

For support with this library please [file an issue](https://github.com/anduril/anduril-javascript/issues/new) or reach out to your Anduril representative.



````

0 comments on commit fbc8617

Please sign in to comment.