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
28 changes: 23 additions & 5 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,14 @@ jobs:
- name: Set up node
uses: actions/setup-node@v3

- name: Install pnpm
uses: pnpm/action-setup@v4

- name: Install dependencies
run: pnpm install

- name: Compile
run: yarn && yarn build
run: pnpm build

test:
runs-on: ubuntu-latest
Expand All @@ -25,9 +31,15 @@ jobs:

- name: Set up node
uses: actions/setup-node@v3

- name: Install pnpm
uses: pnpm/action-setup@v4

- name: Compile
run: yarn && yarn test
- name: Install dependencies
run: pnpm install

- name: Test
run: pnpm test

publish:
needs: [ compile, test ]
Expand All @@ -36,12 +48,18 @@ jobs:
steps:
- name: Checkout repo
uses: actions/checkout@v4

- name: Set up node
uses: actions/setup-node@v3

- name: Install pnpm
uses: pnpm/action-setup@v4

- name: Install dependencies
run: yarn install
run: pnpm install

- name: Build
run: yarn build
run: pnpm build

- name: Publish to npm
run: |
Expand Down
2 changes: 1 addition & 1 deletion .npmignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ tests
.gitignore
.github
.fernignore
.prettierrc.yml
biome.json
tsconfig.json
yarn.lock
pnpm-lock.yaml
2 changes: 0 additions & 2 deletions .prettierrc.yml

This file was deleted.

31 changes: 15 additions & 16 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ import { LatticeClient } from "@anduril-industries/lattice-sdk";

const client = new LatticeClient({ token: "YOUR_TOKEN" });
await client.entities.longPollEntityEvents({
sessionToken: "sessionToken",
sessionToken: "sessionToken"
});
```

Expand Down Expand Up @@ -91,39 +91,36 @@ await client.objects.uploadObject(new File(['binary data'], 'file.mp3'), ...);
await client.objects.uploadObject(new ArrayBuffer(8), ...);
await client.objects.uploadObject(new Uint8Array([0, 1, 2]), ...);
```

The client accepts a variety of types for file upload parameters:

- Stream types: `fs.ReadStream`, `stream.Readable`, and `ReadableStream`
- Buffered types: `Buffer`, `Blob`, `File`, `ArrayBuffer`, `ArrayBufferView`, and `Uint8Array`
* Stream types: `fs.ReadStream`, `stream.Readable`, and `ReadableStream`
* Buffered types: `Buffer`, `Blob`, `File`, `ArrayBuffer`, `ArrayBufferView`, and `Uint8Array`

### Metadata

You can configure metadata when uploading a file:

```typescript
const file: Uploadable.WithMetadata = {
data: createReadStream("path/to/file"),
filename: "my-file", // optional
filename: "my-file", // optional
contentType: "audio/mpeg", // optional
contentLength: 1949, // optional
contentLength: 1949, // optional
};
```

Alternatively, you can upload a file directly from a file path:

```typescript
const file: Uploadable.FromPath = {
const file : Uploadable.FromPath = {
path: "path/to/file",
filename: "my-file", // optional
contentType: "audio/mpeg", // optional
contentLength: 1949, // optional
filename: "my-file", // optional
contentType: "audio/mpeg", // optional
contentLength: 1949, // optional
};
```

The metadata is used to set the `Content-Length`, `Content-Type`, and `Content-Disposition` headers. If not provided, the client will attempt to determine them automatically.
For example, `fs.ReadStream` has a `path` property which the SDK uses to retrieve the file size from the filesystem without loading it into memory.


## Binary Response

You can consume binary data from endpoints using the `BinaryResponse` type which lets you choose how to consume the data:
Expand All @@ -138,7 +135,6 @@ const stream: ReadableStream<Uint8Array> = response.stream();
// If you want to check if the response body has been used, you can use the following property.
const bodyUsed = response.bodyUsed;
```

<details>
<summary>Save binary response to a file</summary>

Expand Down Expand Up @@ -526,7 +522,7 @@ const response = await client.objects.listObjects({
prefix: "prefix",
sinceTimestamp: "2024-01-15T09:30:00Z",
pageToken: "pageToken",
allObjectsInMesh: true,
allObjectsInMesh: true
});
for await (const item of response) {
console.log(item);
Expand All @@ -537,7 +533,7 @@ let page = await client.objects.listObjects({
prefix: "prefix",
sinceTimestamp: "2024-01-15T09:30:00Z",
pageToken: "pageToken",
allObjectsInMesh: true,
allObjectsInMesh: true
});
while (page.hasNextPage()) {
page = page.getNextPage();
Expand Down Expand Up @@ -626,8 +622,11 @@ console.log(rawResponse.headers['X-My-Header']);

### Runtime Compatibility


The SDK works in the following runtimes:



- Node.js 18+
- Vercel
- Cloudflare Workers
Expand Down
69 changes: 69 additions & 0 deletions biome.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
{
"$schema": "https://biomejs.dev/schemas/2.2.5/schema.json",
"root": true,
"vcs": {
"enabled": false
},
"files": {
"ignoreUnknown": true,
"includes": [
"./**",
"!dist",
"!lib",
"!*.tsbuildinfo",
"!_tmp_*",
"!*.tmp",
"!.tmp/",
"!*.log",
"!.DS_Store",
"!Thumbs.db"
]
},
"formatter": {
"enabled": true,
"indentStyle": "space",
"indentWidth": 4,
"lineWidth": 120
},
"javascript": {
"formatter": {
"quoteStyle": "double"
}
},
"assist": {
"enabled": true,
"actions": {
"source": {
"organizeImports": "on"
}
}
},
"linter": {
"rules": {
"style": {
"useNodejsImportProtocol": "off"
},
"suspicious": {
"noAssignInExpressions": "warn",
"noUselessEscapeInString": {
"level": "warn",
"fix": "none",
"options": {}
},
"noThenProperty": "warn",
"useIterableCallbackReturn": "warn",
"noShadowRestrictedNames": "warn",
"noTsIgnore": {
"level": "warn",
"fix": "none",
"options": {}
},
"noConfusingVoidType": {
"level": "warn",
"fix": "none",
"options": {}
}
}
}
}
}
42 changes: 0 additions & 42 deletions jest.config.mjs

This file was deleted.

27 changes: 12 additions & 15 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@anduril-industries/lattice-sdk",
"version": "2.3.0",
"version": "3.0.0",
"private": false,
"repository": "github:anduril/lattice-sdk-javascript",
"license": "See LICENSE",
Expand Down Expand Up @@ -30,26 +30,23 @@
"LICENSE"
],
"scripts": {
"format": "prettier . --write --ignore-unknown",
"build": "yarn build:cjs && yarn build:esm",
"format": "biome format --write --skip-parse-errors --no-errors-on-unmatched --max-diagnostics=none",
"check": "biome check --skip-parse-errors --no-errors-on-unmatched --max-diagnostics=none",
"check:fix": "biome check --fix --unsafe --skip-parse-errors --no-errors-on-unmatched --max-diagnostics=none",
"build": "pnpm build:cjs && pnpm build:esm",
"build:cjs": "tsc --project ./tsconfig.cjs.json",
"build:esm": "tsc --project ./tsconfig.esm.json && node scripts/rename-to-esm-files.js dist/esm",
"test": "jest --config jest.config.mjs",
"test:unit": "jest --selectProjects unit",
"test:browser": "jest --selectProjects browser",
"test:wire": "jest --selectProjects wire"
"test": "vitest",
"test:unit": "vitest --project unit",
"test:wire": "vitest --project wire"
},
"devDependencies": {
"webpack": "^5.97.1",
"ts-loader": "^9.5.1",
"jest": "^29.7.0",
"@jest/globals": "^29.7.0",
"@types/jest": "^29.5.14",
"ts-jest": "^29.3.4",
"jest-environment-jsdom": "^29.7.0",
"msw": "^2.8.4",
"vitest": "^3.2.4",
"msw": "2.11.2",
"@types/node": "^18.19.70",
"prettier": "^3.4.2",
"@biomejs/biome": "2.2.5",
"typescript": "~5.7.2"
},
"browser": {
Expand All @@ -58,7 +55,7 @@
"path": false,
"stream": false
},
"packageManager": "[email protected]",
"packageManager": "[email protected]",
"engines": {
"node": ">=18.0.0"
},
Expand Down
Loading