mirror of
https://github.com/langchain-ai/langgraphjs.git
synced 2026-07-22 09:05:28 -04:00
feat(checkpoint-mongodb): append client metadata for mongodb (#1777)
Co-authored-by: Hunter Lovell <40191806+hntrl@users.noreply.github.com>
This commit is contained in:
@@ -0,0 +1,5 @@
|
||||
---
|
||||
"@langchain/langgraph-checkpoint-mongodb": minor
|
||||
---
|
||||
|
||||
Updates the checkpoint-mongodb to append client metadata
|
||||
@@ -394,6 +394,7 @@ Under the hood, checkpointing is powered by checkpointer objects that conform to
|
||||
* `@langchain/langgraph-checkpoint`: The base interface for checkpointer savers ([BaseCheckpointSaver](/langgraphjs/reference/classes/checkpoint.BaseCheckpointSaver.html)) and serialization/deserialization interface ([SerializerProtocol](/langgraphjs/reference/interfaces/checkpoint.SerializerProtocol.html)). Includes in-memory checkpointer implementation ([MemorySaver](/langgraphjs/reference/classes/checkpoint.MemorySaver.html)) for experimentation. LangGraph comes with `@langchain/langgraph-checkpoint` included.
|
||||
* `@langchain/langgraph-checkpoint-sqlite`: An implementation of LangGraph checkpointer that uses SQLite database ([SqliteSaver](/langgraphjs/reference/classes/checkpoint_sqlite.SqliteSaver.html)). Ideal for experimentation and local workflows. Needs to be installed separately.
|
||||
* `@langchain/langgraph-checkpoint-postgres`: An advanced checkpointer that uses a Postgres database ([PostgresSaver](/langgraphjs/reference/classes/checkpoint_postgres.PostgresSaver.html)), used in LangGraph Cloud. Ideal for using in production. Needs to be installed separately.
|
||||
* `@langchain/langgraph-checkpoint-mongodb`: Another advanced checkpointer that uses a MongoDB database ([MongoDBSaver](/langgraphjs/reference/classes/checkpoint_mongodb.MongoDBSaver.html)). Can be used with [MongoDB Atlas](https://www.mongodb.com/products/platform/atlas-database) in production. Needs to be installed separately.
|
||||
|
||||
### Checkpointer interface
|
||||
|
||||
|
||||
@@ -31,7 +31,7 @@
|
||||
"author": "LangChain",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"mongodb": "^6.8.0"
|
||||
"mongodb": "^6.21.0"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"@langchain/core": "^1.0.1",
|
||||
|
||||
@@ -41,6 +41,9 @@ export class MongoDBSaver extends BaseCheckpointSaver {
|
||||
) {
|
||||
super(serde);
|
||||
this.client = client;
|
||||
this.client.appendMetadata({
|
||||
name: "langgraphjs_checkpoint_saver",
|
||||
});
|
||||
this.db = this.client.db(dbName);
|
||||
this.checkpointCollectionName =
|
||||
checkpointCollectionName ?? this.checkpointCollectionName;
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
import { describe, it, expect, vi } from "vitest";
|
||||
import { type MongoClient } from "mongodb";
|
||||
import { MongoDBSaver } from "../index.js";
|
||||
|
||||
const client = {
|
||||
appendMetadata: vi.fn(),
|
||||
db: vi.fn(() => ({})),
|
||||
};
|
||||
|
||||
describe("MongoDBSaver", () => {
|
||||
it("should set client metadata", async () => {
|
||||
// eslint-disable-next-line no-new
|
||||
new MongoDBSaver({ client: client as unknown as MongoClient });
|
||||
expect(client.appendMetadata).toHaveBeenCalledWith({
|
||||
name: "langgraphjs_checkpoint_saver",
|
||||
});
|
||||
});
|
||||
});
|
||||
@@ -62,7 +62,7 @@
|
||||
"eslint-plugin-import": "^2.29.1",
|
||||
"eslint-plugin-no-instanceof": "^1.0.1",
|
||||
"eslint-plugin-prettier": "^4.2.1",
|
||||
"mongodb": "^6.8.0",
|
||||
"mongodb": "^6.21.0",
|
||||
"pg": "^8.12.0",
|
||||
"prettier": "^2.8.3",
|
||||
"rollup": "^4.37.0",
|
||||
|
||||
@@ -1943,7 +1943,7 @@ __metadata:
|
||||
eslint-plugin-import: "npm:^2.29.1"
|
||||
eslint-plugin-no-instanceof: "npm:^1.0.1"
|
||||
eslint-plugin-prettier: "npm:^4.2.1"
|
||||
mongodb: "npm:^6.8.0"
|
||||
mongodb: "npm:^6.21.0"
|
||||
prettier: "npm:^2.8.3"
|
||||
rollup: "npm:^4.37.0"
|
||||
tsx: "npm:^4.19.3"
|
||||
@@ -2075,7 +2075,7 @@ __metadata:
|
||||
eslint-plugin-import: "npm:^2.29.1"
|
||||
eslint-plugin-no-instanceof: "npm:^1.0.1"
|
||||
eslint-plugin-prettier: "npm:^4.2.1"
|
||||
mongodb: "npm:^6.8.0"
|
||||
mongodb: "npm:^6.21.0"
|
||||
pg: "npm:^8.12.0"
|
||||
prettier: "npm:^2.8.3"
|
||||
rollup: "npm:^4.37.0"
|
||||
@@ -2525,12 +2525,12 @@ __metadata:
|
||||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
"@mongodb-js/saslprep@npm:^1.1.5":
|
||||
version: 1.1.8
|
||||
resolution: "@mongodb-js/saslprep@npm:1.1.8"
|
||||
"@mongodb-js/saslprep@npm:^1.3.0":
|
||||
version: 1.3.2
|
||||
resolution: "@mongodb-js/saslprep@npm:1.3.2"
|
||||
dependencies:
|
||||
sparse-bitfield: "npm:^3.0.3"
|
||||
checksum: 10/ff3ed794370aab2d941b6d28bd5fb523782221e2e996db56604278b13829ee10d0b6875b1d6e02023277121c71ca53aabdee8f72cf23cf50741cd7ec694a4868
|
||||
checksum: 10/c26e35ed9927e4e2fe33c19bdb410de7f7da3057040291e85a33846bc5c907c6a132cf438f8589b522f374ed5184459f8de1278ad5443941d08d75d70e5fe33f
|
||||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
@@ -5963,10 +5963,10 @@ __metadata:
|
||||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
"bson@npm:^6.7.0":
|
||||
version: 6.8.0
|
||||
resolution: "bson@npm:6.8.0"
|
||||
checksum: 10/e73784ae891a30388e69e6f7a5b5962c34c180e0c1dc570c1e13815cdb1076d2253362f6e20e24a419bd1aa2aaf9f388a51049a1fcd19e8b947faec90edd2979
|
||||
"bson@npm:^6.10.4":
|
||||
version: 6.10.4
|
||||
resolution: "bson@npm:6.10.4"
|
||||
checksum: 10/8a79a452219a13898358a5abc93e32bc3805236334f962661da121ce15bd5cade27718ba3310ee2a143ff508489b08467eed172ecb2a658cb8d2e94fdb76b215
|
||||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
@@ -10836,30 +10836,30 @@ __metadata:
|
||||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
"mongodb-connection-string-url@npm:^3.0.0":
|
||||
version: 3.0.1
|
||||
resolution: "mongodb-connection-string-url@npm:3.0.1"
|
||||
"mongodb-connection-string-url@npm:^3.0.2":
|
||||
version: 3.0.2
|
||||
resolution: "mongodb-connection-string-url@npm:3.0.2"
|
||||
dependencies:
|
||||
"@types/whatwg-url": "npm:^11.0.2"
|
||||
whatwg-url: "npm:^13.0.0"
|
||||
checksum: 10/f58918305637995c69a9a765ce3b442695195bb387d4deabfd9f1700bddc9d74e66136ff78e1d4aa24eb6877ae9b0f80c2699ebac8cadb0475b272da44a2623a
|
||||
whatwg-url: "npm:^14.1.0 || ^13.0.0"
|
||||
checksum: 10/99ac939a67cc963b90cfe70a8e45250a8386c531be7d22ffa5d1f3e5dd2406b149fb823b91ac161e4a4a29dfac754b49bca8f6dd786cfc66ae0ca80db5f5f23d
|
||||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
"mongodb@npm:^6.8.0":
|
||||
version: 6.8.0
|
||||
resolution: "mongodb@npm:6.8.0"
|
||||
"mongodb@npm:^6.21.0":
|
||||
version: 6.21.0
|
||||
resolution: "mongodb@npm:6.21.0"
|
||||
dependencies:
|
||||
"@mongodb-js/saslprep": "npm:^1.1.5"
|
||||
bson: "npm:^6.7.0"
|
||||
mongodb-connection-string-url: "npm:^3.0.0"
|
||||
"@mongodb-js/saslprep": "npm:^1.3.0"
|
||||
bson: "npm:^6.10.4"
|
||||
mongodb-connection-string-url: "npm:^3.0.2"
|
||||
peerDependencies:
|
||||
"@aws-sdk/credential-providers": ^3.188.0
|
||||
"@mongodb-js/zstd": ^1.1.0
|
||||
"@mongodb-js/zstd": ^1.1.0 || ^2.0.0
|
||||
gcp-metadata: ^5.2.0
|
||||
kerberos: ^2.0.1
|
||||
mongodb-client-encryption: ">=6.0.0 <7"
|
||||
snappy: ^7.2.2
|
||||
snappy: ^7.3.2
|
||||
socks: ^2.7.1
|
||||
peerDependenciesMeta:
|
||||
"@aws-sdk/credential-providers":
|
||||
@@ -10876,7 +10876,7 @@ __metadata:
|
||||
optional: true
|
||||
socks:
|
||||
optional: true
|
||||
checksum: 10/c9adf8b694e8e510421c8e6e44c337fe6d58e7d33374dc28b355095df92a807fb5a3c691eaf376a87ae693f6ec0779e8aae41a32bbdc63f2961289c616bcbb9a
|
||||
checksum: 10/28d2cab1c55c4cf58e410529ac6ae4c79a233adeb2147ba872d912819a0b496ee2dc5b9819ccbf0527618ced3b841e733b221fd1c627901e8e87ae60a8dc0553
|
||||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
@@ -12400,7 +12400,7 @@ __metadata:
|
||||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
"punycode@npm:^2.1.0, punycode@npm:^2.1.1, punycode@npm:^2.3.0, punycode@npm:^2.3.1":
|
||||
"punycode@npm:^2.1.0, punycode@npm:^2.1.1, punycode@npm:^2.3.1":
|
||||
version: 2.3.1
|
||||
resolution: "punycode@npm:2.3.1"
|
||||
checksum: 10/febdc4362bead22f9e2608ff0171713230b57aff9dddc1c273aa2a651fbd366f94b7d6a71d78342a7c0819906750351ca7f2edd26ea41b626d87d6a13d1bd059
|
||||
@@ -14201,15 +14201,6 @@ __metadata:
|
||||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
"tr46@npm:^4.1.1":
|
||||
version: 4.1.1
|
||||
resolution: "tr46@npm:4.1.1"
|
||||
dependencies:
|
||||
punycode: "npm:^2.3.0"
|
||||
checksum: 10/ca811409c46de84618e4e7f90469184b50d16618b2f027a5ebeccb0d83ee7f51eca229e71f5b15cdec008ca247ad2ccabfdd3daf861604fcc7e341d0c35c30ca
|
||||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
"tr46@npm:^5.1.0":
|
||||
version: 5.1.1
|
||||
resolution: "tr46@npm:5.1.1"
|
||||
@@ -15351,17 +15342,7 @@ __metadata:
|
||||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
"whatwg-url@npm:^13.0.0":
|
||||
version: 13.0.0
|
||||
resolution: "whatwg-url@npm:13.0.0"
|
||||
dependencies:
|
||||
tr46: "npm:^4.1.1"
|
||||
webidl-conversions: "npm:^7.0.0"
|
||||
checksum: 10/1675f5b786bbc2809de8bde5e0c99790cd50c36227942c851b1c2445cc1860a26fd15a4d6eca2cd996882bfde93b66fbc88864cd9b84f2c725427afd81e0f024
|
||||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
"whatwg-url@npm:^14.0.0, whatwg-url@npm:^14.1.1":
|
||||
"whatwg-url@npm:^14.0.0, whatwg-url@npm:^14.1.0 || ^13.0.0, whatwg-url@npm:^14.1.1":
|
||||
version: 14.2.0
|
||||
resolution: "whatwg-url@npm:14.2.0"
|
||||
dependencies:
|
||||
|
||||
Reference in New Issue
Block a user