Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update README.md #8

Merged
merged 1 commit into from
Aug 7, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.



````