Skip to content
Open
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
2 changes: 1 addition & 1 deletion .release-please-manifest.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
".": "3.0.0-alpha.27"
".": "3.0.0-alpha.28"
}
8 changes: 4 additions & 4 deletions .stats.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
configured_endpoints: 12
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/supermemory--inc%2Fsupermemory-new-f181eaeb22a42d197dbd9c45fa61bf9a9b78a91d3334fc0f841494dc73d1a203.yml
openapi_spec_hash: bb8262ebcdea53979cf1cafbc2c68dc8
config_hash: 9b9291a6c872b063900a46386729ba3c
configured_endpoints: 18
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/supermemory--inc%2Fsupermemory-new-b7bf8402df5372a3fac3cb55e083d7c09867328639cb7e2ceb7826de125ccff7.yml
openapi_spec_hash: a91c06034ad9e8a7315927d6f2e18521
config_hash: 2737bce9823a13e0263c0fa2701821fa
15 changes: 15 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,20 @@
# Changelog

## 3.0.0-alpha.28 (2025-09-20)

Full Changelog: [v3.0.0-alpha.27...v3.0.0-alpha.28](https://github.com/supermemoryai/sdk-ts/compare/v3.0.0-alpha.27...v3.0.0-alpha.28)

### Features

* **api:** api update ([290de9a](https://github.com/supermemoryai/sdk-ts/commit/290de9a3602efcf37588ffd2ad21f70201d4bd4c))
* **api:** api update ([6d81959](https://github.com/supermemoryai/sdk-ts/commit/6d8195908aad3dfe3825cb48be754c3fab439248))
* **api:** manual updates ([e3de154](https://github.com/supermemoryai/sdk-ts/commit/e3de154f75866468f20ebc89b32d03c16eb1a83f))


### Chores

* do not install brew dependencies in ./scripts/bootstrap by default ([7484585](https://github.com/supermemoryai/sdk-ts/commit/7484585d8e2972c4ac75c2c593e12eb07f727fb3))

## 3.0.0-alpha.27 (2025-09-15)

Full Changelog: [v3.0.0-alpha.26...v3.0.0-alpha.27](https://github.com/supermemoryai/sdk-ts/compare/v3.0.0-alpha.26...v3.0.0-alpha.27)
Expand Down
46 changes: 36 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,12 +43,40 @@ const client = new Supermemory({
apiKey: process.env['SUPERMEMORY_API_KEY'], // This is the default and can be omitted
});

const params: Supermemory.SearchDocumentsParams = { q: 'machine learning concepts' };
const response: Supermemory.SearchDocumentsResponse = await client.search.documents(params);
const memory: Supermemory.MemoryUpdateResponse = await client.memories.update('id');
```

Documentation for each method, request param, and response field are available in docstrings and will appear on hover in most modern editors.

## File uploads

Request parameters that correspond to file uploads can be passed in many different forms:

- `File` (or an object with the same structure)
- a `fetch` `Response` (or an object with the same structure)
- an `fs.ReadStream`
- the return value of our `toFile` helper

```ts
import fs from 'fs';
import Supermemory, { toFile } from 'supermemory';

const client = new Supermemory();

// If you have access to Node `fs` we recommend using `fs.createReadStream()`:
await client.memories.uploadFile({ file: fs.createReadStream('/path/to/file') });

// Or if you have the web `File` API you can pass a `File` instance:
await client.memories.uploadFile({ file: new File(['my bytes'], 'file') });

// You can also pass a `fetch` `Response`:
await client.memories.uploadFile({ file: await fetch('https://somesite/file') });

// Finally, if none of the above are convenient, you can use our `toFile` helper:
await client.memories.uploadFile({ file: await toFile(Buffer.from('my bytes'), 'file') });
await client.memories.uploadFile({ file: await toFile(new Uint8Array([0, 1, 2]), 'file') });
```

## Handling errors

When the library is unable to connect to the API,
Expand All @@ -57,7 +85,7 @@ a subclass of `APIError` will be thrown:

<!-- prettier-ignore -->
```ts
const response = await client.search.documents({ q: 'machine learning concepts' }).catch(async (err) => {
const memory = await client.memories.update('id').catch(async (err) => {
if (err instanceof Supermemory.APIError) {
console.log(err.status); // 400
console.log(err.name); // BadRequestError
Expand Down Expand Up @@ -97,7 +125,7 @@ const client = new Supermemory({
});

// Or, configure per-request:
await client.search.documents({ q: 'machine learning concepts' }, {
await client.memories.update('id', {
maxRetries: 5,
});
```
Expand All @@ -114,7 +142,7 @@ const client = new Supermemory({
});

// Override per-request:
await client.search.documents({ q: 'machine learning concepts' }, {
await client.memories.update('id', {
timeout: 5 * 1000,
});
```
Expand All @@ -137,15 +165,13 @@ Unlike `.asResponse()` this method consumes the body, returning once it is parse
```ts
const client = new Supermemory();

const response = await client.search.documents({ q: 'machine learning concepts' }).asResponse();
const response = await client.memories.update('id').asResponse();
console.log(response.headers.get('X-My-Header'));
console.log(response.statusText); // access the underlying Response object

const { data: response, response: raw } = await client.search
.documents({ q: 'machine learning concepts' })
.withResponse();
const { data: memory, response: raw } = await client.memories.update('id').withResponse();
console.log(raw.headers.get('X-My-Header'));
console.log(response.results);
console.log(memory.id);
```

### Logging
Expand Down
36 changes: 36 additions & 0 deletions api.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,41 @@
# Memories

Types:

- <code><a href="./src/resources/memories.ts">MemoryUpdateResponse</a></code>
- <code><a href="./src/resources/memories.ts">MemoryListResponse</a></code>
- <code><a href="./src/resources/memories.ts">MemoryAddResponse</a></code>
- <code><a href="./src/resources/memories.ts">MemoryGetResponse</a></code>
- <code><a href="./src/resources/memories.ts">MemoryUploadFileResponse</a></code>

Methods:

- <code title="patch /v3/documents/{id}">client.memories.<a href="./src/resources/memories.ts">update</a>(id, { ...params }) -> MemoryUpdateResponse</code>
- <code title="post /v3/documents/list">client.memories.<a href="./src/resources/memories.ts">list</a>({ ...params }) -> MemoryListResponse</code>
- <code title="delete /v3/documents/{id}">client.memories.<a href="./src/resources/memories.ts">delete</a>(id) -> void</code>
- <code title="post /v3/documents">client.memories.<a href="./src/resources/memories.ts">add</a>({ ...params }) -> MemoryAddResponse</code>
- <code title="get /v3/documents/{id}">client.memories.<a href="./src/resources/memories.ts">get</a>(id) -> MemoryGetResponse</code>
- <code title="post /v3/documents/file">client.memories.<a href="./src/resources/memories.ts">uploadFile</a>({ ...params }) -> MemoryUploadFileResponse</code>

# Documents

Types:

- <code><a href="./src/resources/documents.ts">DocumentUpdateResponse</a></code>
- <code><a href="./src/resources/documents.ts">DocumentListResponse</a></code>
- <code><a href="./src/resources/documents.ts">DocumentAddResponse</a></code>
- <code><a href="./src/resources/documents.ts">DocumentGetResponse</a></code>
- <code><a href="./src/resources/documents.ts">DocumentUploadFileResponse</a></code>

Methods:

- <code title="patch /v3/documents/{id}">client.documents.<a href="./src/resources/documents.ts">update</a>(id, { ...params }) -> DocumentUpdateResponse</code>
- <code title="post /v3/documents/list">client.documents.<a href="./src/resources/documents.ts">list</a>({ ...params }) -> DocumentListResponse</code>
- <code title="delete /v3/documents/{id}">client.documents.<a href="./src/resources/documents.ts">delete</a>(id) -> void</code>
- <code title="post /v3/documents">client.documents.<a href="./src/resources/documents.ts">add</a>({ ...params }) -> DocumentAddResponse</code>
- <code title="get /v3/documents/{id}">client.documents.<a href="./src/resources/documents.ts">get</a>(id) -> DocumentGetResponse</code>
- <code title="post /v3/documents/file">client.documents.<a href="./src/resources/documents.ts">uploadFile</a>({ ...params }) -> DocumentUploadFileResponse</code>

# Search

Types:
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": "supermemory",
"version": "3.0.0-alpha.27",
"version": "3.0.0-alpha.28",
"description": "The official TypeScript library for the Supermemory API",
"author": "Supermemory <[email protected]>",
"types": "dist/index.d.ts",
Expand Down
14 changes: 11 additions & 3 deletions scripts/bootstrap
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,18 @@ set -e

cd "$(dirname "$0")/.."

if [ -f "Brewfile" ] && [ "$(uname -s)" = "Darwin" ] && [ "$SKIP_BREW" != "1" ]; then
if [ -f "Brewfile" ] && [ "$(uname -s)" = "Darwin" ] && [ "$SKIP_BREW" != "1" ] && [ -t 0 ]; then
brew bundle check >/dev/null 2>&1 || {
echo "==> Installing Homebrew dependencies…"
brew bundle
echo -n "==> Install Homebrew dependencies? (y/N): "
read -r response
case "$response" in
[yY][eE][sS]|[yY])
brew bundle
;;
*)
;;
esac
echo
}
fi

Expand Down
53 changes: 51 additions & 2 deletions src/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,30 @@ import {
ConnectionListResponse,
Connections,
} from './resources/connections';
import { Memories } from './resources/memories';
import {
DocumentAddParams,
DocumentAddResponse,
DocumentGetResponse,
DocumentListParams,
DocumentListResponse,
DocumentUpdateParams,
DocumentUpdateResponse,
DocumentUploadFileParams,
DocumentUploadFileResponse,
Documents,
} from './resources/documents';
import {
Memories,
MemoryAddParams,
MemoryAddResponse,
MemoryGetResponse,
MemoryListParams,
MemoryListResponse,
MemoryUpdateParams,
MemoryUpdateResponse,
MemoryUploadFileParams,
MemoryUploadFileResponse,
} from './resources/memories';
import {
Search,
SearchDocumentsParams,
Expand Down Expand Up @@ -747,20 +770,46 @@ export class Supermemory {
static toFile = Uploads.toFile;

memories: API.Memories = new API.Memories(this);
documents: API.Documents = new API.Documents(this);
search: API.Search = new API.Search(this);
settings: API.Settings = new API.Settings(this);
connections: API.Connections = new API.Connections(this);
}

Supermemory.Memories = Memories;
Supermemory.Documents = Documents;
Supermemory.Search = Search;
Supermemory.Settings = Settings;
Supermemory.Connections = Connections;

export declare namespace Supermemory {
export type RequestOptions = Opts.RequestOptions;

export { Memories as Memories };
export {
Memories as Memories,
type MemoryUpdateResponse as MemoryUpdateResponse,
type MemoryListResponse as MemoryListResponse,
type MemoryAddResponse as MemoryAddResponse,
type MemoryGetResponse as MemoryGetResponse,
type MemoryUploadFileResponse as MemoryUploadFileResponse,
type MemoryUpdateParams as MemoryUpdateParams,
type MemoryListParams as MemoryListParams,
type MemoryAddParams as MemoryAddParams,
type MemoryUploadFileParams as MemoryUploadFileParams,
};

export {
Documents as Documents,
type DocumentUpdateResponse as DocumentUpdateResponse,
type DocumentListResponse as DocumentListResponse,
type DocumentAddResponse as DocumentAddResponse,
type DocumentGetResponse as DocumentGetResponse,
type DocumentUploadFileResponse as DocumentUploadFileResponse,
type DocumentUpdateParams as DocumentUpdateParams,
type DocumentListParams as DocumentListParams,
type DocumentAddParams as DocumentAddParams,
type DocumentUploadFileParams as DocumentUploadFileParams,
};

export {
Search as Search,
Expand Down
Loading