@langchain/langgraph-checkpoint-mongodb 1.1.5 → 1.1.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +2 -0
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/package.json +20 -20
package/dist/index.cjs
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
1
2
|
let _langchain_langgraph_checkpoint = require("@langchain/langgraph-checkpoint");
|
|
2
3
|
|
|
3
4
|
//#region src/index.ts
|
|
@@ -75,6 +76,7 @@ var MongoDBSaver = class extends _langchain_langgraph_checkpoint.BaseCheckpointS
|
|
|
75
76
|
if (config?.configurable?.thread_id) query.thread_id = config.configurable.thread_id;
|
|
76
77
|
if (config?.configurable?.checkpoint_ns !== void 0 && config?.configurable?.checkpoint_ns !== null) query.checkpoint_ns = config.configurable.checkpoint_ns;
|
|
77
78
|
if (filter) Object.entries(filter).forEach(([key, value]) => {
|
|
79
|
+
if (value !== null && typeof value === "object") throw new Error(`Invalid filter value for key "${key}": filter values must be primitives (string, number, boolean, or null)`);
|
|
78
80
|
query[`metadata.${key}`] = value;
|
|
79
81
|
});
|
|
80
82
|
if (before) query.checkpoint_id = { $lt: before.configurable?.checkpoint_id };
|
package/dist/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","names":["BaseCheckpointSaver"],"sources":["../src/index.ts"],"sourcesContent":["import { type MongoClient, type Db as MongoDatabase } from \"mongodb\";\nimport type { RunnableConfig } from \"@langchain/core/runnables\";\nimport {\n BaseCheckpointSaver,\n type Checkpoint,\n type CheckpointListOptions,\n type CheckpointTuple,\n type SerializerProtocol,\n type PendingWrite,\n type CheckpointMetadata,\n CheckpointPendingWrite,\n} from \"@langchain/langgraph-checkpoint\";\n\nexport type MongoDBSaverParams = {\n client: MongoClient;\n dbName?: string;\n checkpointCollectionName?: string;\n checkpointWritesCollectionName?: string;\n};\n\n/**\n * A LangGraph checkpoint saver backed by a MongoDB database.\n */\nexport class MongoDBSaver extends BaseCheckpointSaver {\n protected client: MongoClient;\n\n protected db: MongoDatabase;\n\n checkpointCollectionName = \"checkpoints\";\n\n checkpointWritesCollectionName = \"checkpoint_writes\";\n\n constructor(\n {\n client,\n dbName,\n checkpointCollectionName,\n checkpointWritesCollectionName,\n }: MongoDBSaverParams,\n serde?: SerializerProtocol\n ) {\n super(serde);\n this.client = client;\n this.client.appendMetadata({\n name: \"langgraphjs_checkpoint_saver\",\n });\n this.db = this.client.db(dbName);\n this.checkpointCollectionName =\n checkpointCollectionName ?? this.checkpointCollectionName;\n this.checkpointWritesCollectionName =\n checkpointWritesCollectionName ?? this.checkpointWritesCollectionName;\n }\n\n /**\n * Retrieves a checkpoint from the MongoDB database based on the\n * provided config. If the config contains a \"checkpoint_id\" key, the checkpoint with\n * the matching thread ID and checkpoint ID is retrieved. Otherwise, the latest checkpoint\n * for the given thread ID is retrieved.\n */\n async getTuple(config: RunnableConfig): Promise<CheckpointTuple | undefined> {\n const {\n thread_id,\n checkpoint_ns = \"\",\n checkpoint_id,\n } = config.configurable ?? {};\n let query;\n if (checkpoint_id) {\n query = {\n thread_id,\n checkpoint_ns,\n checkpoint_id,\n };\n } else {\n query = { thread_id, checkpoint_ns };\n }\n const result = await this.db\n .collection(this.checkpointCollectionName)\n .find(query)\n .sort(\"checkpoint_id\", -1)\n .limit(1)\n .toArray();\n if (result.length === 0) {\n return undefined;\n }\n const doc = result[0];\n const configurableValues = {\n thread_id,\n checkpoint_ns,\n checkpoint_id: doc.checkpoint_id,\n };\n const checkpoint = (await this.serde.loadsTyped(\n doc.type,\n doc.checkpoint.value(\"utf8\")\n )) as Checkpoint;\n const serializedWrites = await this.db\n .collection(this.checkpointWritesCollectionName)\n .find(configurableValues)\n .toArray();\n const pendingWrites: CheckpointPendingWrite[] = await Promise.all(\n serializedWrites.map(async (serializedWrite) => {\n return [\n serializedWrite.task_id,\n serializedWrite.channel,\n await this.serde.loadsTyped(\n serializedWrite.type,\n serializedWrite.value.value(\"utf8\")\n ),\n ] as CheckpointPendingWrite;\n })\n );\n return {\n config: { configurable: configurableValues },\n checkpoint,\n pendingWrites,\n metadata: (await this.serde.loadsTyped(\n doc.type,\n doc.metadata.value(\"utf8\")\n )) as CheckpointMetadata,\n parentConfig:\n doc.parent_checkpoint_id != null\n ? {\n configurable: {\n thread_id,\n checkpoint_ns,\n checkpoint_id: doc.parent_checkpoint_id,\n },\n }\n : undefined,\n };\n }\n\n /**\n * Retrieve a list of checkpoint tuples from the MongoDB database based\n * on the provided config. The checkpoints are ordered by checkpoint ID\n * in descending order (newest first).\n */\n async *list(\n config: RunnableConfig,\n options?: CheckpointListOptions\n ): AsyncGenerator<CheckpointTuple> {\n const { limit, before, filter } = options ?? {};\n const query: Record<string, unknown> = {};\n\n if (config?.configurable?.thread_id) {\n query.thread_id = config.configurable.thread_id;\n }\n\n if (\n config?.configurable?.checkpoint_ns !== undefined &&\n config?.configurable?.checkpoint_ns !== null\n ) {\n query.checkpoint_ns = config.configurable.checkpoint_ns;\n }\n\n if (filter) {\n Object.entries(filter).forEach(([key, value]) => {\n query[`metadata.${key}`] = value;\n });\n }\n\n if (before) {\n query.checkpoint_id = { $lt: before.configurable?.checkpoint_id };\n }\n\n let result = this.db\n .collection(this.checkpointCollectionName)\n .find(query)\n .sort(\"checkpoint_id\", -1);\n\n if (limit !== undefined) {\n result = result.limit(limit);\n }\n\n for await (const doc of result) {\n const checkpoint = (await this.serde.loadsTyped(\n doc.type,\n doc.checkpoint.value(\"utf8\")\n )) as Checkpoint;\n const metadata = (await this.serde.loadsTyped(\n doc.type,\n doc.metadata.value(\"utf8\")\n )) as CheckpointMetadata;\n\n yield {\n config: {\n configurable: {\n thread_id: doc.thread_id,\n checkpoint_ns: doc.checkpoint_ns,\n checkpoint_id: doc.checkpoint_id,\n },\n },\n checkpoint,\n metadata,\n parentConfig: doc.parent_checkpoint_id\n ? {\n configurable: {\n thread_id: doc.thread_id,\n checkpoint_ns: doc.checkpoint_ns,\n checkpoint_id: doc.parent_checkpoint_id,\n },\n }\n : undefined,\n };\n }\n }\n\n /**\n * Saves a checkpoint to the MongoDB database. The checkpoint is associated\n * with the provided config and its parent config (if any).\n */\n async put(\n config: RunnableConfig,\n checkpoint: Checkpoint,\n metadata: CheckpointMetadata\n ): Promise<RunnableConfig> {\n const thread_id = config.configurable?.thread_id;\n const checkpoint_ns = config.configurable?.checkpoint_ns ?? \"\";\n const checkpoint_id = checkpoint.id;\n if (thread_id === undefined) {\n throw new Error(\n `The provided config must contain a configurable field with a \"thread_id\" field.`\n );\n }\n const [\n [checkpointType, serializedCheckpoint],\n [metadataType, serializedMetadata],\n ] = await Promise.all([\n this.serde.dumpsTyped(checkpoint),\n this.serde.dumpsTyped(metadata),\n ]);\n\n if (checkpointType !== metadataType) {\n throw new Error(\"Mismatched checkpoint and metadata types.\");\n }\n const doc = {\n parent_checkpoint_id: config.configurable?.checkpoint_id,\n type: checkpointType,\n checkpoint: serializedCheckpoint,\n metadata: serializedMetadata,\n };\n const upsertQuery = {\n thread_id,\n checkpoint_ns,\n checkpoint_id,\n };\n await this.db\n .collection(this.checkpointCollectionName)\n .updateOne(upsertQuery, { $set: doc }, { upsert: true });\n\n return {\n configurable: {\n thread_id,\n checkpoint_ns,\n checkpoint_id,\n },\n };\n }\n\n /**\n * Saves intermediate writes associated with a checkpoint to the MongoDB database.\n */\n async putWrites(\n config: RunnableConfig,\n writes: PendingWrite[],\n taskId: string\n ): Promise<void> {\n const thread_id = config.configurable?.thread_id;\n const checkpoint_ns = config.configurable?.checkpoint_ns;\n const checkpoint_id = config.configurable?.checkpoint_id;\n if (\n thread_id === undefined ||\n checkpoint_ns === undefined ||\n checkpoint_id === undefined\n ) {\n throw new Error(\n `The provided config must contain a configurable field with \"thread_id\", \"checkpoint_ns\" and \"checkpoint_id\" fields.`\n );\n }\n\n const operations = await Promise.all(\n writes.map(async ([channel, value], idx) => {\n const upsertQuery = {\n thread_id,\n checkpoint_ns,\n checkpoint_id,\n task_id: taskId,\n idx,\n };\n\n const [type, serializedValue] = await this.serde.dumpsTyped(value);\n\n return {\n updateOne: {\n filter: upsertQuery,\n update: { $set: { channel, type, value: serializedValue } },\n upsert: true,\n },\n };\n })\n );\n\n await this.db\n .collection(this.checkpointWritesCollectionName)\n .bulkWrite(operations);\n }\n\n async deleteThread(threadId: string) {\n await this.db\n .collection(this.checkpointCollectionName)\n .deleteMany({ thread_id: threadId });\n\n await this.db\n .collection(this.checkpointWritesCollectionName)\n .deleteMany({ thread_id: threadId });\n }\n}\n"],"mappings":";;;;;;AAuBA,IAAa,eAAb,cAAkCA,oDAAoB;CACpD,AAAU;CAEV,AAAU;CAEV,2BAA2B;CAE3B,iCAAiC;CAEjC,YACE,EACE,QACA,QACA,0BACA,kCAEF,OACA;AACA,QAAM,MAAM;AACZ,OAAK,SAAS;AACd,OAAK,OAAO,eAAe,EACzB,MAAM,gCACP,CAAC;AACF,OAAK,KAAK,KAAK,OAAO,GAAG,OAAO;AAChC,OAAK,2BACH,4BAA4B,KAAK;AACnC,OAAK,iCACH,kCAAkC,KAAK;;;;;;;;CAS3C,MAAM,SAAS,QAA8D;EAC3E,MAAM,EACJ,WACA,gBAAgB,IAChB,kBACE,OAAO,gBAAgB,EAAE;EAC7B,IAAI;AACJ,MAAI,cACF,SAAQ;GACN;GACA;GACA;GACD;MAED,SAAQ;GAAE;GAAW;GAAe;EAEtC,MAAM,SAAS,MAAM,KAAK,GACvB,WAAW,KAAK,yBAAyB,CACzC,KAAK,MAAM,CACX,KAAK,iBAAiB,GAAG,CACzB,MAAM,EAAE,CACR,SAAS;AACZ,MAAI,OAAO,WAAW,EACpB;EAEF,MAAM,MAAM,OAAO;EACnB,MAAM,qBAAqB;GACzB;GACA;GACA,eAAe,IAAI;GACpB;EACD,MAAM,aAAc,MAAM,KAAK,MAA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C/B,OAAO,IAAI,OAAO,CAAC,SAAS,QAAQ,QAAQ;GAC1C,MAAM,cAAc;IAClB;IACA;IACA;IACA,SAAS;IACT;IACD;GAED,MAAM,CAAC,MAAM,mBAAmB,MAAM,KAAK,MAAM,WAAW,MAAM;AAElE,UAAO,EACL,WAAW;IACT,QAAQ;IACR,QAAQ,EAAE,MAAM;KAAE;KAAS;KAAM,OAAO;KAAiB,EAAE;IAC3D,QAAQ;IACT,EACF;IACD,CACH;AAED,QAAM,KAAK,GACR,WAAW,KAAK,+BAA+B,CAC/C,UAAU,WAAW;;CAG1B,MAAM,aAAa,UAAkB;AACnC,QAAM,KAAK,GACR,WAAW,KAAK,yBAAyB,CACzC,WAAW,EAAE,WAAW,UAAU,CAAC;AAEtC,QAAM,KAAK,GACR,WAAW,KAAK,+BAA+B,CAC/C,WAAW,EAAE,WAAW,UAAU,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.cjs","names":["BaseCheckpointSaver"],"sources":["../src/index.ts"],"sourcesContent":["import { type MongoClient, type Db as MongoDatabase } from \"mongodb\";\nimport type { RunnableConfig } from \"@langchain/core/runnables\";\nimport {\n BaseCheckpointSaver,\n type Checkpoint,\n type CheckpointListOptions,\n type CheckpointTuple,\n type SerializerProtocol,\n type PendingWrite,\n type CheckpointMetadata,\n CheckpointPendingWrite,\n} from \"@langchain/langgraph-checkpoint\";\n\nexport type MongoDBSaverParams = {\n client: MongoClient;\n dbName?: string;\n checkpointCollectionName?: string;\n checkpointWritesCollectionName?: string;\n};\n\n/**\n * A LangGraph checkpoint saver backed by a MongoDB database.\n */\nexport class MongoDBSaver extends BaseCheckpointSaver {\n protected client: MongoClient;\n\n protected db: MongoDatabase;\n\n checkpointCollectionName = \"checkpoints\";\n\n checkpointWritesCollectionName = \"checkpoint_writes\";\n\n constructor(\n {\n client,\n dbName,\n checkpointCollectionName,\n checkpointWritesCollectionName,\n }: MongoDBSaverParams,\n serde?: SerializerProtocol\n ) {\n super(serde);\n this.client = client;\n this.client.appendMetadata({\n name: \"langgraphjs_checkpoint_saver\",\n });\n this.db = this.client.db(dbName);\n this.checkpointCollectionName =\n checkpointCollectionName ?? this.checkpointCollectionName;\n this.checkpointWritesCollectionName =\n checkpointWritesCollectionName ?? this.checkpointWritesCollectionName;\n }\n\n /**\n * Retrieves a checkpoint from the MongoDB database based on the\n * provided config. If the config contains a \"checkpoint_id\" key, the checkpoint with\n * the matching thread ID and checkpoint ID is retrieved. Otherwise, the latest checkpoint\n * for the given thread ID is retrieved.\n */\n async getTuple(config: RunnableConfig): Promise<CheckpointTuple | undefined> {\n const {\n thread_id,\n checkpoint_ns = \"\",\n checkpoint_id,\n } = config.configurable ?? {};\n let query;\n if (checkpoint_id) {\n query = {\n thread_id,\n checkpoint_ns,\n checkpoint_id,\n };\n } else {\n query = { thread_id, checkpoint_ns };\n }\n const result = await this.db\n .collection(this.checkpointCollectionName)\n .find(query)\n .sort(\"checkpoint_id\", -1)\n .limit(1)\n .toArray();\n if (result.length === 0) {\n return undefined;\n }\n const doc = result[0];\n const configurableValues = {\n thread_id,\n checkpoint_ns,\n checkpoint_id: doc.checkpoint_id,\n };\n const checkpoint = (await this.serde.loadsTyped(\n doc.type,\n doc.checkpoint.value(\"utf8\")\n )) as Checkpoint;\n const serializedWrites = await this.db\n .collection(this.checkpointWritesCollectionName)\n .find(configurableValues)\n .toArray();\n const pendingWrites: CheckpointPendingWrite[] = await Promise.all(\n serializedWrites.map(async (serializedWrite) => {\n return [\n serializedWrite.task_id,\n serializedWrite.channel,\n await this.serde.loadsTyped(\n serializedWrite.type,\n serializedWrite.value.value(\"utf8\")\n ),\n ] as CheckpointPendingWrite;\n })\n );\n return {\n config: { configurable: configurableValues },\n checkpoint,\n pendingWrites,\n metadata: (await this.serde.loadsTyped(\n doc.type,\n doc.metadata.value(\"utf8\")\n )) as CheckpointMetadata,\n parentConfig:\n doc.parent_checkpoint_id != null\n ? {\n configurable: {\n thread_id,\n checkpoint_ns,\n checkpoint_id: doc.parent_checkpoint_id,\n },\n }\n : undefined,\n };\n }\n\n /**\n * Retrieve a list of checkpoint tuples from the MongoDB database based\n * on the provided config. The checkpoints are ordered by checkpoint ID\n * in descending order (newest first).\n */\n async *list(\n config: RunnableConfig,\n options?: CheckpointListOptions\n ): AsyncGenerator<CheckpointTuple> {\n const { limit, before, filter } = options ?? {};\n const query: Record<string, unknown> = {};\n\n if (config?.configurable?.thread_id) {\n query.thread_id = config.configurable.thread_id;\n }\n\n if (\n config?.configurable?.checkpoint_ns !== undefined &&\n config?.configurable?.checkpoint_ns !== null\n ) {\n query.checkpoint_ns = config.configurable.checkpoint_ns;\n }\n\n if (filter) {\n Object.entries(filter).forEach(([key, value]) => {\n // Prevent MongoDB operator injection - only allow primitive values\n if (value !== null && typeof value === \"object\") {\n throw new Error(\n `Invalid filter value for key \"${key}\": filter values must be primitives (string, number, boolean, or null)`\n );\n }\n query[`metadata.${key}`] = value;\n });\n }\n\n if (before) {\n query.checkpoint_id = { $lt: before.configurable?.checkpoint_id };\n }\n\n let result = this.db\n .collection(this.checkpointCollectionName)\n .find(query)\n .sort(\"checkpoint_id\", -1);\n\n if (limit !== undefined) {\n result = result.limit(limit);\n }\n\n for await (const doc of result) {\n const checkpoint = (await this.serde.loadsTyped(\n doc.type,\n doc.checkpoint.value(\"utf8\")\n )) as Checkpoint;\n const metadata = (await this.serde.loadsTyped(\n doc.type,\n doc.metadata.value(\"utf8\")\n )) as CheckpointMetadata;\n\n yield {\n config: {\n configurable: {\n thread_id: doc.thread_id,\n checkpoint_ns: doc.checkpoint_ns,\n checkpoint_id: doc.checkpoint_id,\n },\n },\n checkpoint,\n metadata,\n parentConfig: doc.parent_checkpoint_id\n ? {\n configurable: {\n thread_id: doc.thread_id,\n checkpoint_ns: doc.checkpoint_ns,\n checkpoint_id: doc.parent_checkpoint_id,\n },\n }\n : undefined,\n };\n }\n }\n\n /**\n * Saves a checkpoint to the MongoDB database. The checkpoint is associated\n * with the provided config and its parent config (if any).\n */\n async put(\n config: RunnableConfig,\n checkpoint: Checkpoint,\n metadata: CheckpointMetadata\n ): Promise<RunnableConfig> {\n const thread_id = config.configurable?.thread_id;\n const checkpoint_ns = config.configurable?.checkpoint_ns ?? \"\";\n const checkpoint_id = checkpoint.id;\n if (thread_id === undefined) {\n throw new Error(\n `The provided config must contain a configurable field with a \"thread_id\" field.`\n );\n }\n const [\n [checkpointType, serializedCheckpoint],\n [metadataType, serializedMetadata],\n ] = await Promise.all([\n this.serde.dumpsTyped(checkpoint),\n this.serde.dumpsTyped(metadata),\n ]);\n\n if (checkpointType !== metadataType) {\n throw new Error(\"Mismatched checkpoint and metadata types.\");\n }\n const doc = {\n parent_checkpoint_id: config.configurable?.checkpoint_id,\n type: checkpointType,\n checkpoint: serializedCheckpoint,\n metadata: serializedMetadata,\n };\n const upsertQuery = {\n thread_id,\n checkpoint_ns,\n checkpoint_id,\n };\n await this.db\n .collection(this.checkpointCollectionName)\n .updateOne(upsertQuery, { $set: doc }, { upsert: true });\n\n return {\n configurable: {\n thread_id,\n checkpoint_ns,\n checkpoint_id,\n },\n };\n }\n\n /**\n * Saves intermediate writes associated with a checkpoint to the MongoDB database.\n */\n async putWrites(\n config: RunnableConfig,\n writes: PendingWrite[],\n taskId: string\n ): Promise<void> {\n const thread_id = config.configurable?.thread_id;\n const checkpoint_ns = config.configurable?.checkpoint_ns;\n const checkpoint_id = config.configurable?.checkpoint_id;\n if (\n thread_id === undefined ||\n checkpoint_ns === undefined ||\n checkpoint_id === undefined\n ) {\n throw new Error(\n `The provided config must contain a configurable field with \"thread_id\", \"checkpoint_ns\" and \"checkpoint_id\" fields.`\n );\n }\n\n const operations = await Promise.all(\n writes.map(async ([channel, value], idx) => {\n const upsertQuery = {\n thread_id,\n checkpoint_ns,\n checkpoint_id,\n task_id: taskId,\n idx,\n };\n\n const [type, serializedValue] = await this.serde.dumpsTyped(value);\n\n return {\n updateOne: {\n filter: upsertQuery,\n update: { $set: { channel, type, value: serializedValue } },\n upsert: true,\n },\n };\n })\n );\n\n await this.db\n .collection(this.checkpointWritesCollectionName)\n .bulkWrite(operations);\n }\n\n async deleteThread(threadId: string) {\n await this.db\n .collection(this.checkpointCollectionName)\n .deleteMany({ thread_id: threadId });\n\n await this.db\n .collection(this.checkpointWritesCollectionName)\n .deleteMany({ thread_id: threadId });\n }\n}\n"],"mappings":";;;;;;;AAuBA,IAAa,eAAb,cAAkCA,oDAAoB;CACpD,AAAU;CAEV,AAAU;CAEV,2BAA2B;CAE3B,iCAAiC;CAEjC,YACE,EACE,QACA,QACA,0BACA,kCAEF,OACA;AACA,QAAM,MAAM;AACZ,OAAK,SAAS;AACd,OAAK,OAAO,eAAe,EACzB,MAAM,gCACP,CAAC;AACF,OAAK,KAAK,KAAK,OAAO,GAAG,OAAO;AAChC,OAAK,2BACH,4BAA4B,KAAK;AACnC,OAAK,iCACH,kCAAkC,KAAK;;;;;;;;CAS3C,MAAM,SAAS,QAA8D;EAC3E,MAAM,EACJ,WACA,gBAAgB,IAChB,kBACE,OAAO,gBAAgB,EAAE;EAC7B,IAAI;AACJ,MAAI,cACF,SAAQ;GACN;GACA;GACA;GACD;MAED,SAAQ;GAAE;GAAW;GAAe;EAEtC,MAAM,SAAS,MAAM,KAAK,GACvB,WAAW,KAAK,yBAAyB,CACzC,KAAK,MAAM,CACX,KAAK,iBAAiB,GAAG,CACzB,MAAM,EAAE,CACR,SAAS;AACZ,MAAI,OAAO,WAAW,EACpB;EAEF,MAAM,MAAM,OAAO;EACnB,MAAM,qBAAqB;GACzB;GACA;GACA,eAAe,IAAI;GACpB;EACD,MAAM,aAAc,MAAM,KAAK,MAAM,WACnC,IAAI,MACJ,IAAI,WAAW,MAAM,OAAO,CAC7B;EACD,MAAM,mBAAmB,MAAM,KAAK,GACjC,WAAW,KAAK,+BAA+B,CAC/C,KAAK,mBAAmB,CACxB,SAAS;EACZ,MAAM,gBAA0C,MAAM,QAAQ,IAC5D,iBAAiB,IAAI,OAAO,oBAAoB;AAC9C,UAAO;IACL,gBAAgB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AW,MAAM;AAElE,UAAO,EACL,WAAW;IACT,QAAQ;IACR,QAAQ,EAAE,MAAM;KAAE;KAAS;KAAM,OAAO;KAAiB,EAAE;IAC3D,QAAQ;IACT,EACF;IACD,CACH;AAED,QAAM,KAAK,GACR,WAAW,KAAK,+BAA+B,CAC/C,UAAU,WAAW;;CAG1B,MAAM,aAAa,UAAkB;AACnC,QAAM,KAAK,GACR,WAAW,KAAK,yBAAyB,CACzC,WAAW,EAAE,WAAW,UAAU,CAAC;AAEtC,QAAM,KAAK,GACR,WAAW,KAAK,+BAA+B,CAC/C,WAAW,EAAE,WAAW,UAAU,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -75,6 +75,7 @@ var MongoDBSaver = class extends BaseCheckpointSaver {
|
|
|
75
75
|
if (config?.configurable?.thread_id) query.thread_id = config.configurable.thread_id;
|
|
76
76
|
if (config?.configurable?.checkpoint_ns !== void 0 && config?.configurable?.checkpoint_ns !== null) query.checkpoint_ns = config.configurable.checkpoint_ns;
|
|
77
77
|
if (filter) Object.entries(filter).forEach(([key, value]) => {
|
|
78
|
+
if (value !== null && typeof value === "object") throw new Error(`Invalid filter value for key "${key}": filter values must be primitives (string, number, boolean, or null)`);
|
|
78
79
|
query[`metadata.${key}`] = value;
|
|
79
80
|
});
|
|
80
81
|
if (before) query.checkpoint_id = { $lt: before.configurable?.checkpoint_id };
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":[],"sources":["../src/index.ts"],"sourcesContent":["import { type MongoClient, type Db as MongoDatabase } from \"mongodb\";\nimport type { RunnableConfig } from \"@langchain/core/runnables\";\nimport {\n BaseCheckpointSaver,\n type Checkpoint,\n type CheckpointListOptions,\n type CheckpointTuple,\n type SerializerProtocol,\n type PendingWrite,\n type CheckpointMetadata,\n CheckpointPendingWrite,\n} from \"@langchain/langgraph-checkpoint\";\n\nexport type MongoDBSaverParams = {\n client: MongoClient;\n dbName?: string;\n checkpointCollectionName?: string;\n checkpointWritesCollectionName?: string;\n};\n\n/**\n * A LangGraph checkpoint saver backed by a MongoDB database.\n */\nexport class MongoDBSaver extends BaseCheckpointSaver {\n protected client: MongoClient;\n\n protected db: MongoDatabase;\n\n checkpointCollectionName = \"checkpoints\";\n\n checkpointWritesCollectionName = \"checkpoint_writes\";\n\n constructor(\n {\n client,\n dbName,\n checkpointCollectionName,\n checkpointWritesCollectionName,\n }: MongoDBSaverParams,\n serde?: SerializerProtocol\n ) {\n super(serde);\n this.client = client;\n this.client.appendMetadata({\n name: \"langgraphjs_checkpoint_saver\",\n });\n this.db = this.client.db(dbName);\n this.checkpointCollectionName =\n checkpointCollectionName ?? this.checkpointCollectionName;\n this.checkpointWritesCollectionName =\n checkpointWritesCollectionName ?? this.checkpointWritesCollectionName;\n }\n\n /**\n * Retrieves a checkpoint from the MongoDB database based on the\n * provided config. If the config contains a \"checkpoint_id\" key, the checkpoint with\n * the matching thread ID and checkpoint ID is retrieved. Otherwise, the latest checkpoint\n * for the given thread ID is retrieved.\n */\n async getTuple(config: RunnableConfig): Promise<CheckpointTuple | undefined> {\n const {\n thread_id,\n checkpoint_ns = \"\",\n checkpoint_id,\n } = config.configurable ?? {};\n let query;\n if (checkpoint_id) {\n query = {\n thread_id,\n checkpoint_ns,\n checkpoint_id,\n };\n } else {\n query = { thread_id, checkpoint_ns };\n }\n const result = await this.db\n .collection(this.checkpointCollectionName)\n .find(query)\n .sort(\"checkpoint_id\", -1)\n .limit(1)\n .toArray();\n if (result.length === 0) {\n return undefined;\n }\n const doc = result[0];\n const configurableValues = {\n thread_id,\n checkpoint_ns,\n checkpoint_id: doc.checkpoint_id,\n };\n const checkpoint = (await this.serde.loadsTyped(\n doc.type,\n doc.checkpoint.value(\"utf8\")\n )) as Checkpoint;\n const serializedWrites = await this.db\n .collection(this.checkpointWritesCollectionName)\n .find(configurableValues)\n .toArray();\n const pendingWrites: CheckpointPendingWrite[] = await Promise.all(\n serializedWrites.map(async (serializedWrite) => {\n return [\n serializedWrite.task_id,\n serializedWrite.channel,\n await this.serde.loadsTyped(\n serializedWrite.type,\n serializedWrite.value.value(\"utf8\")\n ),\n ] as CheckpointPendingWrite;\n })\n );\n return {\n config: { configurable: configurableValues },\n checkpoint,\n pendingWrites,\n metadata: (await this.serde.loadsTyped(\n doc.type,\n doc.metadata.value(\"utf8\")\n )) as CheckpointMetadata,\n parentConfig:\n doc.parent_checkpoint_id != null\n ? {\n configurable: {\n thread_id,\n checkpoint_ns,\n checkpoint_id: doc.parent_checkpoint_id,\n },\n }\n : undefined,\n };\n }\n\n /**\n * Retrieve a list of checkpoint tuples from the MongoDB database based\n * on the provided config. The checkpoints are ordered by checkpoint ID\n * in descending order (newest first).\n */\n async *list(\n config: RunnableConfig,\n options?: CheckpointListOptions\n ): AsyncGenerator<CheckpointTuple> {\n const { limit, before, filter } = options ?? {};\n const query: Record<string, unknown> = {};\n\n if (config?.configurable?.thread_id) {\n query.thread_id = config.configurable.thread_id;\n }\n\n if (\n config?.configurable?.checkpoint_ns !== undefined &&\n config?.configurable?.checkpoint_ns !== null\n ) {\n query.checkpoint_ns = config.configurable.checkpoint_ns;\n }\n\n if (filter) {\n Object.entries(filter).forEach(([key, value]) => {\n query[`metadata.${key}`] = value;\n });\n }\n\n if (before) {\n query.checkpoint_id = { $lt: before.configurable?.checkpoint_id };\n }\n\n let result = this.db\n .collection(this.checkpointCollectionName)\n .find(query)\n .sort(\"checkpoint_id\", -1);\n\n if (limit !== undefined) {\n result = result.limit(limit);\n }\n\n for await (const doc of result) {\n const checkpoint = (await this.serde.loadsTyped(\n doc.type,\n doc.checkpoint.value(\"utf8\")\n )) as Checkpoint;\n const metadata = (await this.serde.loadsTyped(\n doc.type,\n doc.metadata.value(\"utf8\")\n )) as CheckpointMetadata;\n\n yield {\n config: {\n configurable: {\n thread_id: doc.thread_id,\n checkpoint_ns: doc.checkpoint_ns,\n checkpoint_id: doc.checkpoint_id,\n },\n },\n checkpoint,\n metadata,\n parentConfig: doc.parent_checkpoint_id\n ? {\n configurable: {\n thread_id: doc.thread_id,\n checkpoint_ns: doc.checkpoint_ns,\n checkpoint_id: doc.parent_checkpoint_id,\n },\n }\n : undefined,\n };\n }\n }\n\n /**\n * Saves a checkpoint to the MongoDB database. The checkpoint is associated\n * with the provided config and its parent config (if any).\n */\n async put(\n config: RunnableConfig,\n checkpoint: Checkpoint,\n metadata: CheckpointMetadata\n ): Promise<RunnableConfig> {\n const thread_id = config.configurable?.thread_id;\n const checkpoint_ns = config.configurable?.checkpoint_ns ?? \"\";\n const checkpoint_id = checkpoint.id;\n if (thread_id === undefined) {\n throw new Error(\n `The provided config must contain a configurable field with a \"thread_id\" field.`\n );\n }\n const [\n [checkpointType, serializedCheckpoint],\n [metadataType, serializedMetadata],\n ] = await Promise.all([\n this.serde.dumpsTyped(checkpoint),\n this.serde.dumpsTyped(metadata),\n ]);\n\n if (checkpointType !== metadataType) {\n throw new Error(\"Mismatched checkpoint and metadata types.\");\n }\n const doc = {\n parent_checkpoint_id: config.configurable?.checkpoint_id,\n type: checkpointType,\n checkpoint: serializedCheckpoint,\n metadata: serializedMetadata,\n };\n const upsertQuery = {\n thread_id,\n checkpoint_ns,\n checkpoint_id,\n };\n await this.db\n .collection(this.checkpointCollectionName)\n .updateOne(upsertQuery, { $set: doc }, { upsert: true });\n\n return {\n configurable: {\n thread_id,\n checkpoint_ns,\n checkpoint_id,\n },\n };\n }\n\n /**\n * Saves intermediate writes associated with a checkpoint to the MongoDB database.\n */\n async putWrites(\n config: RunnableConfig,\n writes: PendingWrite[],\n taskId: string\n ): Promise<void> {\n const thread_id = config.configurable?.thread_id;\n const checkpoint_ns = config.configurable?.checkpoint_ns;\n const checkpoint_id = config.configurable?.checkpoint_id;\n if (\n thread_id === undefined ||\n checkpoint_ns === undefined ||\n checkpoint_id === undefined\n ) {\n throw new Error(\n `The provided config must contain a configurable field with \"thread_id\", \"checkpoint_ns\" and \"checkpoint_id\" fields.`\n );\n }\n\n const operations = await Promise.all(\n writes.map(async ([channel, value], idx) => {\n const upsertQuery = {\n thread_id,\n checkpoint_ns,\n checkpoint_id,\n task_id: taskId,\n idx,\n };\n\n const [type, serializedValue] = await this.serde.dumpsTyped(value);\n\n return {\n updateOne: {\n filter: upsertQuery,\n update: { $set: { channel, type, value: serializedValue } },\n upsert: true,\n },\n };\n })\n );\n\n await this.db\n .collection(this.checkpointWritesCollectionName)\n .bulkWrite(operations);\n }\n\n async deleteThread(threadId: string) {\n await this.db\n .collection(this.checkpointCollectionName)\n .deleteMany({ thread_id: threadId });\n\n await this.db\n .collection(this.checkpointWritesCollectionName)\n .deleteMany({ thread_id: threadId });\n }\n}\n"],"mappings":";;;;;;AAuBA,IAAa,eAAb,cAAkC,oBAAoB;CACpD,AAAU;CAEV,AAAU;CAEV,2BAA2B;CAE3B,iCAAiC;CAEjC,YACE,EACE,QACA,QACA,0BACA,kCAEF,OACA;AACA,QAAM,MAAM;AACZ,OAAK,SAAS;AACd,OAAK,OAAO,eAAe,EACzB,MAAM,gCACP,CAAC;AACF,OAAK,KAAK,KAAK,OAAO,GAAG,OAAO;AAChC,OAAK,2BACH,4BAA4B,KAAK;AACnC,OAAK,iCACH,kCAAkC,KAAK;;;;;;;;CAS3C,MAAM,SAAS,QAA8D;EAC3E,MAAM,EACJ,WACA,gBAAgB,IAChB,kBACE,OAAO,gBAAgB,EAAE;EAC7B,IAAI;AACJ,MAAI,cACF,SAAQ;GACN;GACA;GACA;GACD;MAED,SAAQ;GAAE;GAAW;GAAe;EAEtC,MAAM,SAAS,MAAM,KAAK,GACvB,WAAW,KAAK,yBAAyB,CACzC,KAAK,MAAM,CACX,KAAK,iBAAiB,GAAG,CACzB,MAAM,EAAE,CACR,SAAS;AACZ,MAAI,OAAO,WAAW,EACpB;EAEF,MAAM,MAAM,OAAO;EACnB,MAAM,qBAAqB;GACzB;GACA;GACA,eAAe,IAAI;GACpB;EACD,MAAM,aAAc,MAAM,KAAK,MAAM,WACnC,IAAI,MACJ,IAAI,WAAW,MA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QAAQ,QAAQ;GAC1C,MAAM,cAAc;IAClB;IACA;IACA;IACA,SAAS;IACT;IACD;GAED,MAAM,CAAC,MAAM,mBAAmB,MAAM,KAAK,MAAM,WAAW,MAAM;AAElE,UAAO,EACL,WAAW;IACT,QAAQ;IACR,QAAQ,EAAE,MAAM;KAAE;KAAS;KAAM,OAAO;KAAiB,EAAE;IAC3D,QAAQ;IACT,EACF;IACD,CACH;AAED,QAAM,KAAK,GACR,WAAW,KAAK,+BAA+B,CAC/C,UAAU,WAAW;;CAG1B,MAAM,aAAa,UAAkB;AACnC,QAAM,KAAK,GACR,WAAW,KAAK,yBAAyB,CACzC,WAAW,EAAE,WAAW,UAAU,CAAC;AAEtC,QAAM,KAAK,GACR,WAAW,KAAK,+BAA+B,CAC/C,WAAW,EAAE,WAAW,UAAU,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../src/index.ts"],"sourcesContent":["import { type MongoClient, type Db as MongoDatabase } from \"mongodb\";\nimport type { RunnableConfig } from \"@langchain/core/runnables\";\nimport {\n BaseCheckpointSaver,\n type Checkpoint,\n type CheckpointListOptions,\n type CheckpointTuple,\n type SerializerProtocol,\n type PendingWrite,\n type CheckpointMetadata,\n CheckpointPendingWrite,\n} from \"@langchain/langgraph-checkpoint\";\n\nexport type MongoDBSaverParams = {\n client: MongoClient;\n dbName?: string;\n checkpointCollectionName?: string;\n checkpointWritesCollectionName?: string;\n};\n\n/**\n * A LangGraph checkpoint saver backed by a MongoDB database.\n */\nexport class MongoDBSaver extends BaseCheckpointSaver {\n protected client: MongoClient;\n\n protected db: MongoDatabase;\n\n checkpointCollectionName = \"checkpoints\";\n\n checkpointWritesCollectionName = \"checkpoint_writes\";\n\n constructor(\n {\n client,\n dbName,\n checkpointCollectionName,\n checkpointWritesCollectionName,\n }: MongoDBSaverParams,\n serde?: SerializerProtocol\n ) {\n super(serde);\n this.client = client;\n this.client.appendMetadata({\n name: \"langgraphjs_checkpoint_saver\",\n });\n this.db = this.client.db(dbName);\n this.checkpointCollectionName =\n checkpointCollectionName ?? this.checkpointCollectionName;\n this.checkpointWritesCollectionName =\n checkpointWritesCollectionName ?? this.checkpointWritesCollectionName;\n }\n\n /**\n * Retrieves a checkpoint from the MongoDB database based on the\n * provided config. If the config contains a \"checkpoint_id\" key, the checkpoint with\n * the matching thread ID and checkpoint ID is retrieved. Otherwise, the latest checkpoint\n * for the given thread ID is retrieved.\n */\n async getTuple(config: RunnableConfig): Promise<CheckpointTuple | undefined> {\n const {\n thread_id,\n checkpoint_ns = \"\",\n checkpoint_id,\n } = config.configurable ?? {};\n let query;\n if (checkpoint_id) {\n query = {\n thread_id,\n checkpoint_ns,\n checkpoint_id,\n };\n } else {\n query = { thread_id, checkpoint_ns };\n }\n const result = await this.db\n .collection(this.checkpointCollectionName)\n .find(query)\n .sort(\"checkpoint_id\", -1)\n .limit(1)\n .toArray();\n if (result.length === 0) {\n return undefined;\n }\n const doc = result[0];\n const configurableValues = {\n thread_id,\n checkpoint_ns,\n checkpoint_id: doc.checkpoint_id,\n };\n const checkpoint = (await this.serde.loadsTyped(\n doc.type,\n doc.checkpoint.value(\"utf8\")\n )) as Checkpoint;\n const serializedWrites = await this.db\n .collection(this.checkpointWritesCollectionName)\n .find(configurableValues)\n .toArray();\n const pendingWrites: CheckpointPendingWrite[] = await Promise.all(\n serializedWrites.map(async (serializedWrite) => {\n return [\n serializedWrite.task_id,\n serializedWrite.channel,\n await this.serde.loadsTyped(\n serializedWrite.type,\n serializedWrite.value.value(\"utf8\")\n ),\n ] as CheckpointPendingWrite;\n })\n );\n return {\n config: { configurable: configurableValues },\n checkpoint,\n pendingWrites,\n metadata: (await this.serde.loadsTyped(\n doc.type,\n doc.metadata.value(\"utf8\")\n )) as CheckpointMetadata,\n parentConfig:\n doc.parent_checkpoint_id != null\n ? {\n configurable: {\n thread_id,\n checkpoint_ns,\n checkpoint_id: doc.parent_checkpoint_id,\n },\n }\n : undefined,\n };\n }\n\n /**\n * Retrieve a list of checkpoint tuples from the MongoDB database based\n * on the provided config. The checkpoints are ordered by checkpoint ID\n * in descending order (newest first).\n */\n async *list(\n config: RunnableConfig,\n options?: CheckpointListOptions\n ): AsyncGenerator<CheckpointTuple> {\n const { limit, before, filter } = options ?? {};\n const query: Record<string, unknown> = {};\n\n if (config?.configurable?.thread_id) {\n query.thread_id = config.configurable.thread_id;\n }\n\n if (\n config?.configurable?.checkpoint_ns !== undefined &&\n config?.configurable?.checkpoint_ns !== null\n ) {\n query.checkpoint_ns = config.configurable.checkpoint_ns;\n }\n\n if (filter) {\n Object.entries(filter).forEach(([key, value]) => {\n // Prevent MongoDB operator injection - only allow primitive values\n if (value !== null && typeof value === \"object\") {\n throw new Error(\n `Invalid filter value for key \"${key}\": filter values must be primitives (string, number, boolean, or null)`\n );\n }\n query[`metadata.${key}`] = value;\n });\n }\n\n if (before) {\n query.checkpoint_id = { $lt: before.configurable?.checkpoint_id };\n }\n\n let result = this.db\n .collection(this.checkpointCollectionName)\n .find(query)\n .sort(\"checkpoint_id\", -1);\n\n if (limit !== undefined) {\n result = result.limit(limit);\n }\n\n for await (const doc of result) {\n const checkpoint = (await this.serde.loadsTyped(\n doc.type,\n doc.checkpoint.value(\"utf8\")\n )) as Checkpoint;\n const metadata = (await this.serde.loadsTyped(\n doc.type,\n doc.metadata.value(\"utf8\")\n )) as CheckpointMetadata;\n\n yield {\n config: {\n configurable: {\n thread_id: doc.thread_id,\n checkpoint_ns: doc.checkpoint_ns,\n checkpoint_id: doc.checkpoint_id,\n },\n },\n checkpoint,\n metadata,\n parentConfig: doc.parent_checkpoint_id\n ? {\n configurable: {\n thread_id: doc.thread_id,\n checkpoint_ns: doc.checkpoint_ns,\n checkpoint_id: doc.parent_checkpoint_id,\n },\n }\n : undefined,\n };\n }\n }\n\n /**\n * Saves a checkpoint to the MongoDB database. The checkpoint is associated\n * with the provided config and its parent config (if any).\n */\n async put(\n config: RunnableConfig,\n checkpoint: Checkpoint,\n metadata: CheckpointMetadata\n ): Promise<RunnableConfig> {\n const thread_id = config.configurable?.thread_id;\n const checkpoint_ns = config.configurable?.checkpoint_ns ?? \"\";\n const checkpoint_id = checkpoint.id;\n if (thread_id === undefined) {\n throw new Error(\n `The provided config must contain a configurable field with a \"thread_id\" field.`\n );\n }\n const [\n [checkpointType, serializedCheckpoint],\n [metadataType, serializedMetadata],\n ] = await Promise.all([\n this.serde.dumpsTyped(checkpoint),\n this.serde.dumpsTyped(metadata),\n ]);\n\n if (checkpointType !== metadataType) {\n throw new Error(\"Mismatched checkpoint and metadata types.\");\n }\n const doc = {\n parent_checkpoint_id: config.configurable?.checkpoint_id,\n type: checkpointType,\n checkpoint: serializedCheckpoint,\n metadata: serializedMetadata,\n };\n const upsertQuery = {\n thread_id,\n checkpoint_ns,\n checkpoint_id,\n };\n await this.db\n .collection(this.checkpointCollectionName)\n .updateOne(upsertQuery, { $set: doc }, { upsert: true });\n\n return {\n configurable: {\n thread_id,\n checkpoint_ns,\n checkpoint_id,\n },\n };\n }\n\n /**\n * Saves intermediate writes associated with a checkpoint to the MongoDB database.\n */\n async putWrites(\n config: RunnableConfig,\n writes: PendingWrite[],\n taskId: string\n ): Promise<void> {\n const thread_id = config.configurable?.thread_id;\n const checkpoint_ns = config.configurable?.checkpoint_ns;\n const checkpoint_id = config.configurable?.checkpoint_id;\n if (\n thread_id === undefined ||\n checkpoint_ns === undefined ||\n checkpoint_id === undefined\n ) {\n throw new Error(\n `The provided config must contain a configurable field with \"thread_id\", \"checkpoint_ns\" and \"checkpoint_id\" fields.`\n );\n }\n\n const operations = await Promise.all(\n writes.map(async ([channel, value], idx) => {\n const upsertQuery = {\n thread_id,\n checkpoint_ns,\n checkpoint_id,\n task_id: taskId,\n idx,\n };\n\n const [type, serializedValue] = await this.serde.dumpsTyped(value);\n\n return {\n updateOne: {\n filter: upsertQuery,\n update: { $set: { channel, type, value: serializedValue } },\n upsert: true,\n },\n };\n })\n );\n\n await this.db\n .collection(this.checkpointWritesCollectionName)\n .bulkWrite(operations);\n }\n\n async deleteThread(threadId: string) {\n await this.db\n .collection(this.checkpointCollectionName)\n .deleteMany({ thread_id: threadId });\n\n await this.db\n .collection(this.checkpointWritesCollectionName)\n .deleteMany({ thread_id: threadId });\n }\n}\n"],"mappings":";;;;;;AAuBA,IAAa,eAAb,cAAkC,oBAAoB;CACpD,AAAU;CAEV,AAAU;CAEV,2BAA2B;CAE3B,iCAAiC;CAEjC,YACE,EACE,QACA,QACA,0BACA,kCAEF,OACA;AACA,QAAM,MAAM;AACZ,OAAK,SAAS;AACd,OAAK,OAAO,eAAe,EACzB,MAAM,gCACP,CAAC;AACF,OAAK,KAAK,KAAK,OAAO,GAAG,OAAO;AAChC,OAAK,2BACH,4BAA4B,KAAK;AACnC,OAAK,iCACH,kCAAkC,KAAK;;;;;;;;CAS3C,MAAM,SAAS,QAA8D;EAC3E,MAAM,EACJ,WACA,gBAAgB,IAChB,kBACE,OAAO,gBAAgB,EAAE;EAC7B,IAAI;AACJ,MAAI,cACF,SAAQ;GACN;GACA;GACA;GACD;MAED,SAAQ;GAAE;GAAW;GAAe;EAEtC,MAAM,SAAS,MAAM,KAAK,GACvB,WAAW,KAAK,yBAAyB,CACzC,KAAK,MAAM,CACX,KAAK,iBAAiB,GAAG,CACzB,MAAM,EAAE,CACR,SAAS;AACZ,MAAI,OAAO,WAAW,EACpB;EAEF,MAAM,MAAM,OAAO;EACnB,MAAM,qBAAqB;GACzB;GACA;GACA,eAAe,IAAI;GACpB;EACD,MAAM,aAAc,MAAM,KAAK,MAAM,WACnC,IAAI,MACJ,IAAI,WAAW,MAAM,OAAO,CAC7B;EACD,MAAM,mBAAmB,MAAM,KAAK,GACjC,WAAW,KAAK,+BAA+B,CAC/C,KAAK,mBAAmB,CACxB,SAAS;EACZ,MAAM,gBAA0C,MAAM,QAAQ,IAC5D,iBAAiB,IAAI,OAAO,oBAAoB;AAC9C,UAAO;IACL,gBAAgB;IAChB,gBAAgB;IAChB,MAAM,KAAK,MAAM,WACf,gBAAgB,M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,EAAE,MAAM;KAAE;KAAS;KAAM,OAAO;KAAiB,EAAE;IAC3D,QAAQ;IACT,EACF;IACD,CACH;AAED,QAAM,KAAK,GACR,WAAW,KAAK,+BAA+B,CAC/C,UAAU,WAAW;;CAG1B,MAAM,aAAa,UAAkB;AACnC,QAAM,KAAK,GACR,WAAW,KAAK,yBAAyB,CACzC,WAAW,EAAE,WAAW,UAAU,CAAC;AAEtC,QAAM,KAAK,GACR,WAAW,KAAK,+BAA+B,CAC/C,WAAW,EAAE,WAAW,UAAU,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@langchain/langgraph-checkpoint-mongodb",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.7",
|
|
4
4
|
"description": "LangGraph",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"engines": {
|
|
@@ -13,21 +13,6 @@
|
|
|
13
13
|
"url": "git+ssh://git@github.com/langchain-ai/langgraphjs.git",
|
|
14
14
|
"directory": "libs/checkpoint-mongodb"
|
|
15
15
|
},
|
|
16
|
-
"scripts": {
|
|
17
|
-
"build": "yarn turbo:command build:internal --filter=@langchain/langgraph-checkpoint-mongodb",
|
|
18
|
-
"build:internal": "yarn workspace @langchain/build compile @langchain/langgraph-checkpoint-mongodb",
|
|
19
|
-
"clean": "rm -rf dist/ dist-cjs/ .turbo/",
|
|
20
|
-
"lint:eslint": "NODE_OPTIONS=--max-old-space-size=4096 eslint --cache --ext .ts,.js src/",
|
|
21
|
-
"lint:dpdm": "dpdm --exit-code circular:1 --no-warning --no-tree src/*.ts src/**/*.ts",
|
|
22
|
-
"lint": "yarn lint:eslint && yarn lint:dpdm",
|
|
23
|
-
"lint:fix": "yarn lint:eslint --fix && yarn lint:dpdm",
|
|
24
|
-
"prepublish": "yarn build",
|
|
25
|
-
"test": "vitest run",
|
|
26
|
-
"test:watch": "vitest watch",
|
|
27
|
-
"test:int": "vitest run --mode int",
|
|
28
|
-
"format": "prettier --config .prettierrc --write \"src\"",
|
|
29
|
-
"format:check": "prettier --config .prettierrc --check \"src\""
|
|
30
|
-
},
|
|
31
16
|
"author": "LangChain",
|
|
32
17
|
"license": "MIT",
|
|
33
18
|
"dependencies": {
|
|
@@ -38,7 +23,6 @@
|
|
|
38
23
|
"@langchain/langgraph-checkpoint": "^1.0.0"
|
|
39
24
|
},
|
|
40
25
|
"devDependencies": {
|
|
41
|
-
"@langchain/langgraph-checkpoint": "workspace:*",
|
|
42
26
|
"@langchain/scripts": ">=0.1.3 <0.2.0",
|
|
43
27
|
"@tsconfig/recommended": "^1.0.3",
|
|
44
28
|
"@types/better-sqlite3": "^7.6.12",
|
|
@@ -57,7 +41,8 @@
|
|
|
57
41
|
"rollup": "^4.37.0",
|
|
58
42
|
"tsx": "^4.19.3",
|
|
59
43
|
"typescript": "^4.9.5 || ^5.4.5",
|
|
60
|
-
"vitest": "^3.2.4"
|
|
44
|
+
"vitest": "^3.2.4",
|
|
45
|
+
"@langchain/langgraph-checkpoint": "1.0.0"
|
|
61
46
|
},
|
|
62
47
|
"publishConfig": {
|
|
63
48
|
"access": "public",
|
|
@@ -80,5 +65,20 @@
|
|
|
80
65
|
},
|
|
81
66
|
"files": [
|
|
82
67
|
"dist/"
|
|
83
|
-
]
|
|
84
|
-
|
|
68
|
+
],
|
|
69
|
+
"scripts": {
|
|
70
|
+
"build": "pnpm turbo build:internal --filter=@langchain/langgraph-checkpoint-mongodb",
|
|
71
|
+
"build:internal": "pnpm --filter @langchain/build compile @langchain/langgraph-checkpoint-mongodb",
|
|
72
|
+
"clean": "rm -rf dist/ dist-cjs/ .turbo/",
|
|
73
|
+
"lint:eslint": "NODE_OPTIONS=--max-old-space-size=4096 eslint --cache --ext .ts,.js src/",
|
|
74
|
+
"lint:dpdm": "dpdm --exit-code circular:1 --no-warning --no-tree src/*.ts src/**/*.ts",
|
|
75
|
+
"lint": "pnpm lint:eslint && pnpm lint:dpdm",
|
|
76
|
+
"lint:fix": "pnpm lint:eslint --fix && pnpm lint:dpdm",
|
|
77
|
+
"prepublish": "pnpm build",
|
|
78
|
+
"test": "vitest run",
|
|
79
|
+
"test:watch": "vitest watch",
|
|
80
|
+
"test:int": "vitest run --mode int",
|
|
81
|
+
"format": "prettier --config .prettierrc --write \"src\"",
|
|
82
|
+
"format:check": "prettier --config .prettierrc --check \"src\""
|
|
83
|
+
}
|
|
84
|
+
}
|