-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
c75300e
commit 937ca18
Showing
1 changed file
with
63 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,64 @@ | ||
# anduril-javascript | ||
|
||
### .npmrc | ||
Create a file in the package directory | ||
|
||
``` | ||
@anduril:registry=https://npm.pkg.github.com | ||
//npm.pkg.github.com/:_authToken=<TOKEN> | ||
``` | ||
|
||
### package.json | ||
Create a file in the package directory | ||
|
||
```json | ||
{ | ||
"dependencies": { | ||
"@anduril/anduril-javascript": "1.0.6", | ||
"@connectrpc/connect-node": "1.4.0" | ||
} | ||
} | ||
``` | ||
|
||
### Index.ts | ||
|
||
``` | ||
import { EntityManagerAPI } from "@anduril/anduril-javascript/src/anduril/entitymanager/v1/entity_manager_api.pub_connect"; | ||
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"; | ||
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: [], | ||
}); | ||
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); | ||
} | ||
void main(); | ||
```` |