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
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.26"
".": "3.0.0-alpha.27"
}
6 changes: 3 additions & 3 deletions .stats.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
configured_endpoints: 18
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/supermemory--inc%2Fsupermemory-new-de994787885a5ec28fb19f069715a257ea4e4f1bcff2b25c4b33e928779c6454.yml
openapi_spec_hash: 7b831b4614b8d9b8caddcaa096bf3817
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
23 changes: 23 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,28 @@
# Changelog

## 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)

### Features

* **api:** api update ([4fd4c3f](https://github.com/supermemoryai/sdk-ts/commit/4fd4c3fda1bb0b9abc88c35e7d6ed3423242da9f))
* **api:** api update ([931f06e](https://github.com/supermemoryai/sdk-ts/commit/931f06ec191b9265a5b616ad464f13196b5323e8))
* **api:** api update ([1867027](https://github.com/supermemoryai/sdk-ts/commit/1867027fbf09579e83274f56662a9f52bfde7980))
* **api:** api update ([ba68418](https://github.com/supermemoryai/sdk-ts/commit/ba684187bac42ee1c631fda0018759923f1ceb64))
* **api:** api update ([e1af8d2](https://github.com/supermemoryai/sdk-ts/commit/e1af8d2c434a9aef933486a21a9a290b17ce44cd))


### Bug Fixes

* coerce nullable values to undefined ([d3d7567](https://github.com/supermemoryai/sdk-ts/commit/d3d75676732fa48be0847fbbcc542489bc8cff1a))


### Chores

* ci build action ([e1f58f5](https://github.com/supermemoryai/sdk-ts/commit/e1f58f5b24257a252c8e6fc13d9befc25ea42538))
* **internal:** update global Error reference ([5c8e529](https://github.com/supermemoryai/sdk-ts/commit/5c8e529624c921433b81cbcc975acacb5cd9aa2c))

## 3.0.0-alpha.26 (2025-08-26)

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

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

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 @@ -85,7 +57,7 @@ a subclass of `APIError` will be thrown:

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

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

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

const response = await client.memories.add().asResponse();
const response = await client.search.documents({ q: 'machine learning concepts' }).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.memories.add().withResponse();
const { data: response, response: raw } = await client.search
.documents({ q: 'machine learning concepts' })
.withResponse();
console.log(raw.headers.get('X-My-Header'));
console.log(response.id);
console.log(response.results);
```

### Logging
Expand Down
17 changes: 0 additions & 17 deletions api.md
Original file line number Diff line number Diff line change
@@ -1,22 +1,5 @@
# 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/memories/{id}">client.memories.<a href="./src/resources/memories.ts">update</a>(id, { ...params }) -> MemoryUpdateResponse</code>
- <code title="post /v3/memories/list">client.memories.<a href="./src/resources/memories.ts">list</a>({ ...params }) -> MemoryListResponse</code>
- <code title="delete /v3/memories/{id}">client.memories.<a href="./src/resources/memories.ts">delete</a>(id) -> void</code>
- <code title="post /v3/memories">client.memories.<a href="./src/resources/memories.ts">add</a>({ ...params }) -> MemoryAddResponse</code>
- <code title="get /v3/memories/{id}">client.memories.<a href="./src/resources/memories.ts">get</a>(id) -> MemoryGetResponse</code>
- <code title="post /v3/memories/file">client.memories.<a href="./src/resources/memories.ts">uploadFile</a>({ ...params }) -> MemoryUploadFileResponse</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.26",
"version": "3.0.0-alpha.27",
"description": "The official TypeScript library for the Supermemory API",
"author": "Supermemory <[email protected]>",
"types": "dist/index.d.ts",
Expand Down
2 changes: 1 addition & 1 deletion scripts/utils/upload-artifact.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ if [[ "$SIGNED_URL" == "null" ]]; then
exit 1
fi

UPLOAD_RESPONSE=$(tar -cz "${BUILD_PATH:-dist}" | curl -v -X PUT \
UPLOAD_RESPONSE=$(tar "${BASE_PATH:+-C$BASE_PATH}" -cz "${ARTIFACT_PATH:-dist}" | curl -v -X PUT \
-H "Content-Type: application/gzip" \
--data-binary @- "$SIGNED_URL" 2>&1)

Expand Down
28 changes: 3 additions & 25 deletions src/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,18 +33,7 @@ import {
ConnectionListResponse,
Connections,
} from './resources/connections';
import {
Memories,
MemoryAddParams,
MemoryAddResponse,
MemoryGetResponse,
MemoryListParams,
MemoryListResponse,
MemoryUpdateParams,
MemoryUpdateResponse,
MemoryUploadFileParams,
MemoryUploadFileResponse,
} from './resources/memories';
import { Memories } from './resources/memories';
import {
Search,
SearchDocumentsParams,
Expand Down Expand Up @@ -411,7 +400,7 @@ export class Supermemory {
const response = await this.fetchWithTimeout(url, req, timeout, controller).catch(castToError);
const headersTime = Date.now();

if (response instanceof Error) {
if (response instanceof globalThis.Error) {
const retryMessage = `retrying, ${retriesRemaining} attempts remaining`;
if (options.signal?.aborted) {
throw new Errors.APIUserAbortError();
Expand Down Expand Up @@ -771,18 +760,7 @@ Supermemory.Connections = Connections;
export declare namespace Supermemory {
export type RequestOptions = Opts.RequestOptions;

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 { Memories as Memories };

export {
Search as Search,
Expand Down
6 changes: 3 additions & 3 deletions src/internal/utils/values.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,21 +76,21 @@ export const coerceBoolean = (value: unknown): boolean => {
};

export const maybeCoerceInteger = (value: unknown): number | undefined => {
if (value === undefined) {
if (value == null) {
return undefined;
}
return coerceInteger(value);
};

export const maybeCoerceFloat = (value: unknown): number | undefined => {
if (value === undefined) {
if (value == null) {
return undefined;
}
return coerceFloat(value);
};

export const maybeCoerceBoolean = (value: unknown): boolean | undefined => {
if (value === undefined) {
if (value == null) {
return undefined;
}
return coerceBoolean(value);
Expand Down
13 changes: 1 addition & 12 deletions src/resources/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,18 +17,7 @@ export {
type ConnectionImportParams,
type ConnectionListDocumentsParams,
} from './connections';
export {
Memories,
type MemoryUpdateResponse,
type MemoryListResponse,
type MemoryAddResponse,
type MemoryGetResponse,
type MemoryUploadFileResponse,
type MemoryUpdateParams,
type MemoryListParams,
type MemoryAddParams,
type MemoryUploadFileParams,
} from './memories';
export { Memories } from './memories';
export {
Search,
type SearchDocumentsResponse,
Expand Down
Loading