Skip to content
Merged
Show file tree
Hide file tree
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
3 changes: 2 additions & 1 deletion .npmignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,5 @@ tests
.fernignore
.prettierrc.yml
tsconfig.json
yarn.lock
yarn.lock
pnpm-lock.yaml
30 changes: 26 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
# Anduril TypeScript Library
# Lattice SDK TypeScript Library

![](https://www.anduril.com/lattice-sdk/)

[![npm shield](https://img.shields.io/npm/v/@anduril-industries/lattice-sdk)](https://www.npmjs.com/package/@anduril-industries/lattice-sdk)

The Lattice SDK TypeScript library provides convenient access to the Lattice API from TypeScript.
The Lattice SDK TypeScript library provides convenient access to the Lattice SDK APIs from TypeScript.

## Documentation

Expand Down Expand Up @@ -522,13 +522,23 @@ List endpoints are paginated. The SDK provides an iterator so that you can simpl
import { LatticeClient } from "@anduril-industries/lattice-sdk";

const client = new LatticeClient({ token: "YOUR_TOKEN" });
const response = await client.objects.listObjects();
const response = await client.objects.listObjects({
prefix: "prefix",
sinceTimestamp: "2024-01-15T09:30:00Z",
pageToken: "pageToken",
allObjectsInMesh: true,
});
for await (const item of response) {
console.log(item);
}

// Or you can manually iterate page-by-page
let page = await client.objects.listObjects();
let page = await client.objects.listObjects({
prefix: "prefix",
sinceTimestamp: "2024-01-15T09:30:00Z",
pageToken: "pageToken",
allObjectsInMesh: true,
});
while (page.hasNextPage()) {
page = page.getNextPage();
}
Expand All @@ -548,6 +558,18 @@ const response = await client.entities.longPollEntityEvents(..., {
});
```

### Additional Query String Parameters

If you would like to send additional query string parameters as part of the request, use the `queryParams` request option.

```typescript
const response = await client.entities.longPollEntityEvents(..., {
queryParams: {
'customQueryParamKey': 'custom query param value'
}
});
```

### Retries

The SDK is instrumented with automatic retries with exponential backoff. A request will be retried as long
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@anduril-industries/lattice-sdk",
"version": "2.2.0",
"version": "2.3.0",
"private": false,
"repository": "github:anduril/lattice-sdk-javascript",
"license": "See LICENSE",
Expand Down
85 changes: 83 additions & 2 deletions reference.md
Original file line number Diff line number Diff line change
Expand Up @@ -757,13 +757,23 @@ Lists objects in your environment. You can define a prefix to list a subset of y
<dd>

```typescript
const response = await client.objects.listObjects();
const response = await client.objects.listObjects({
prefix: "prefix",
sinceTimestamp: "2024-01-15T09:30:00Z",
pageToken: "pageToken",
allObjectsInMesh: true,
});
for await (const item of response) {
console.log(item);
}

// Or you can manually iterate page-by-page
let page = await client.objects.listObjects();
let page = await client.objects.listObjects({
prefix: "prefix",
sinceTimestamp: "2024-01-15T09:30:00Z",
pageToken: "pageToken",
allObjectsInMesh: true,
});
while (page.hasNextPage()) {
page = page.getNextPage();
}
Expand Down Expand Up @@ -801,6 +811,77 @@ while (page.hasNextPage()) {
</dl>
</details>

<details><summary><code>client.objects.<a href="/src/api/resources/objects/client/Client.ts">getObject</a>(objectPath, { ...params }) -> core.BinaryResponse</code></summary>
<dl>
<dd>

#### 📝 Description

<dl>
<dd>

<dl>
<dd>

Fetches an object from your environment using the objectPath path parameter.

</dd>
</dl>
</dd>
</dl>

#### 🔌 Usage

<dl>
<dd>

<dl>
<dd>

```typescript
await client.objects.getObject("objectPath");
```

</dd>
</dl>
</dd>
</dl>

#### ⚙️ Parameters

<dl>
<dd>

<dl>
<dd>

**objectPath:** `string` — The path of the object to fetch.

</dd>
</dl>

<dl>
<dd>

**request:** `Lattice.GetObjectRequest`

</dd>
</dl>

<dl>
<dd>

**requestOptions:** `Objects.RequestOptions`

</dd>
</dl>
</dd>
</dl>

</dd>
</dl>
</details>

<details><summary><code>client.objects.<a href="/src/api/resources/objects/client/Client.ts">deleteObject</a>(objectPath) -> void</code></summary>
<dl>
<dd>
Expand Down
10 changes: 6 additions & 4 deletions src/Client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export declare namespace LatticeClient {
baseUrl?: core.Supplier<string>;
token?: core.Supplier<core.BearerToken | undefined>;
/** Additional headers to include in requests. */
headers?: Record<string, string | core.Supplier<string | undefined> | undefined>;
headers?: Record<string, string | core.Supplier<string | null | undefined> | null | undefined>;
}

export interface RequestOptions {
Expand All @@ -26,8 +26,10 @@ export declare namespace LatticeClient {
maxRetries?: number;
/** A hook to abort the request. */
abortSignal?: AbortSignal;
/** Additional query string parameters to include in the request. */
queryParams?: Record<string, unknown>;
/** Additional headers to include in the request. */
headers?: Record<string, string | core.Supplier<string | undefined> | undefined>;
headers?: Record<string, string | core.Supplier<string | null | undefined> | null | undefined>;
}
}

Expand All @@ -44,8 +46,8 @@ export class LatticeClient {
{
"X-Fern-Language": "JavaScript",
"X-Fern-SDK-Name": "@anduril-industries/lattice-sdk",
"X-Fern-SDK-Version": "2.2.0",
"User-Agent": "@anduril-industries/lattice-sdk/2.2.0",
"X-Fern-SDK-Version": "2.3.0",
"User-Agent": "@anduril-industries/lattice-sdk/2.3.0",
"X-Fern-Runtime": core.RUNTIME.type,
"X-Fern-Runtime-Version": core.RUNTIME.version,
},
Expand Down
78 changes: 46 additions & 32 deletions src/api/resources/entities/client/Client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export declare namespace Entities {
baseUrl?: core.Supplier<string>;
token?: core.Supplier<core.BearerToken | undefined>;
/** Additional headers to include in requests. */
headers?: Record<string, string | core.Supplier<string | undefined> | undefined>;
headers?: Record<string, string | core.Supplier<string | null | undefined> | null | undefined>;
}

export interface RequestOptions {
Expand All @@ -25,8 +25,10 @@ export declare namespace Entities {
maxRetries?: number;
/** A hook to abort the request. */
abortSignal?: AbortSignal;
/** Additional query string parameters to include in the request. */
queryParams?: Record<string, unknown>;
/** Additional headers to include in the request. */
headers?: Record<string, string | core.Supplier<string | undefined> | undefined>;
headers?: Record<string, string | core.Supplier<string | null | undefined> | null | undefined>;
}
}

Expand Down Expand Up @@ -69,6 +71,11 @@ export class Entities {
request: Lattice.Entity,
requestOptions?: Entities.RequestOptions,
): Promise<core.WithRawResponse<Lattice.Entity>> {
let _headers: core.Fetcher.Args["headers"] = mergeHeaders(
this._options?.headers,
mergeOnlyDefinedHeaders({ Authorization: await this._getAuthorizationHeader() }),
requestOptions?.headers,
);
const _response = await core.fetcher({
url: core.url.join(
(await core.Supplier.get(this._options.baseUrl)) ??
Expand All @@ -77,12 +84,9 @@ export class Entities {
"api/v1/entities",
),
method: "PUT",
headers: mergeHeaders(
this._options?.headers,
mergeOnlyDefinedHeaders({ Authorization: await this._getAuthorizationHeader() }),
requestOptions?.headers,
),
headers: _headers,
contentType: "application/json",
queryParameters: requestOptions?.queryParams,
requestType: "json",
body: request,
timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000,
Expand Down Expand Up @@ -147,6 +151,11 @@ export class Entities {
entityId: string,
requestOptions?: Entities.RequestOptions,
): Promise<core.WithRawResponse<Lattice.Entity>> {
let _headers: core.Fetcher.Args["headers"] = mergeHeaders(
this._options?.headers,
mergeOnlyDefinedHeaders({ Authorization: await this._getAuthorizationHeader() }),
requestOptions?.headers,
);
const _response = await core.fetcher({
url: core.url.join(
(await core.Supplier.get(this._options.baseUrl)) ??
Expand All @@ -155,11 +164,8 @@ export class Entities {
`api/v1/entities/${encodeURIComponent(entityId)}`,
),
method: "GET",
headers: mergeHeaders(
this._options?.headers,
mergeOnlyDefinedHeaders({ Authorization: await this._getAuthorizationHeader() }),
requestOptions?.headers,
),
headers: _headers,
queryParameters: requestOptions?.queryParams,
timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000,
maxRetries: requestOptions?.maxRetries,
abortSignal: requestOptions?.abortSignal,
Expand Down Expand Up @@ -240,6 +246,11 @@ export class Entities {
request: Lattice.EntityOverride = {},
requestOptions?: Entities.RequestOptions,
): Promise<core.WithRawResponse<Lattice.Entity>> {
let _headers: core.Fetcher.Args["headers"] = mergeHeaders(
this._options?.headers,
mergeOnlyDefinedHeaders({ Authorization: await this._getAuthorizationHeader() }),
requestOptions?.headers,
);
const _response = await core.fetcher({
url: core.url.join(
(await core.Supplier.get(this._options.baseUrl)) ??
Expand All @@ -248,12 +259,9 @@ export class Entities {
`api/v1/entities/${encodeURIComponent(entityId)}/override/${encodeURIComponent(fieldPath)}`,
),
method: "PUT",
headers: mergeHeaders(
this._options?.headers,
mergeOnlyDefinedHeaders({ Authorization: await this._getAuthorizationHeader() }),
requestOptions?.headers,
),
headers: _headers,
contentType: "application/json",
queryParameters: requestOptions?.queryParams,
requestType: "json",
body: request,
timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000,
Expand Down Expand Up @@ -327,6 +335,11 @@ export class Entities {
fieldPath: string,
requestOptions?: Entities.RequestOptions,
): Promise<core.WithRawResponse<Lattice.Entity>> {
let _headers: core.Fetcher.Args["headers"] = mergeHeaders(
this._options?.headers,
mergeOnlyDefinedHeaders({ Authorization: await this._getAuthorizationHeader() }),
requestOptions?.headers,
);
const _response = await core.fetcher({
url: core.url.join(
(await core.Supplier.get(this._options.baseUrl)) ??
Expand All @@ -335,11 +348,8 @@ export class Entities {
`api/v1/entities/${encodeURIComponent(entityId)}/override/${encodeURIComponent(fieldPath)}`,
),
method: "DELETE",
headers: mergeHeaders(
this._options?.headers,
mergeOnlyDefinedHeaders({ Authorization: await this._getAuthorizationHeader() }),
requestOptions?.headers,
),
headers: _headers,
queryParameters: requestOptions?.queryParams,
timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000,
maxRetries: requestOptions?.maxRetries,
abortSignal: requestOptions?.abortSignal,
Expand Down Expand Up @@ -420,6 +430,11 @@ export class Entities {
request: Lattice.EntityEventRequest,
requestOptions?: Entities.RequestOptions,
): Promise<core.WithRawResponse<Lattice.EntityEventResponse>> {
let _headers: core.Fetcher.Args["headers"] = mergeHeaders(
this._options?.headers,
mergeOnlyDefinedHeaders({ Authorization: await this._getAuthorizationHeader() }),
requestOptions?.headers,
);
const _response = await core.fetcher({
url: core.url.join(
(await core.Supplier.get(this._options.baseUrl)) ??
Expand All @@ -428,12 +443,9 @@ export class Entities {
"api/v1/entities/events",
),
method: "POST",
headers: mergeHeaders(
this._options?.headers,
mergeOnlyDefinedHeaders({ Authorization: await this._getAuthorizationHeader() }),
requestOptions?.headers,
),
headers: _headers,
contentType: "application/json",
queryParameters: requestOptions?.queryParams,
requestType: "json",
body: request,
timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000,
Expand Down Expand Up @@ -496,6 +508,11 @@ export class Entities {
request: Lattice.EntityStreamRequest = {},
requestOptions?: Entities.RequestOptions,
): Promise<core.WithRawResponse<core.Stream<Lattice.StreamEntitiesResponse>>> {
let _headers: core.Fetcher.Args["headers"] = mergeHeaders(
this._options?.headers,
mergeOnlyDefinedHeaders({ Authorization: await this._getAuthorizationHeader() }),
requestOptions?.headers,
);
const _response = await core.fetcher<ReadableStream>({
url: core.url.join(
(await core.Supplier.get(this._options.baseUrl)) ??
Expand All @@ -504,12 +521,9 @@ export class Entities {
"api/v1/entities/stream",
),
method: "POST",
headers: mergeHeaders(
this._options?.headers,
mergeOnlyDefinedHeaders({ Authorization: await this._getAuthorizationHeader() }),
requestOptions?.headers,
),
headers: _headers,
contentType: "application/json",
queryParameters: requestOptions?.queryParams,
requestType: "json",
body: request,
responseType: "sse",
Expand Down
Loading