mirror of
https://github.com/supermemoryai/supermemory.git
synced 2026-08-14 19:14:01 +00:00
fix(tools): reject conflicting container config (#1214)
This commit is contained in:
parent
09e3b78fc2
commit
bc6eb73d43
2 changed files with 33 additions and 0 deletions
28
packages/tools/src/tools-shared.test.ts
Normal file
28
packages/tools/src/tools-shared.test.ts
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
import { describe, expect, it } from "vitest"
|
||||
import { getContainerTags } from "./tools-shared"
|
||||
|
||||
describe("getContainerTags", () => {
|
||||
it("uses the default project when no config is provided", () => {
|
||||
expect(getContainerTags()).toEqual(["sm_project_default"])
|
||||
})
|
||||
|
||||
it("converts projectId into a project container tag", () => {
|
||||
expect(getContainerTags({ projectId: "abc" })).toEqual(["sm_project_abc"])
|
||||
})
|
||||
|
||||
it("uses explicit container tags", () => {
|
||||
expect(getContainerTags({ containerTags: ["tag-a", "tag-b"] })).toEqual([
|
||||
"tag-a",
|
||||
"tag-b",
|
||||
])
|
||||
})
|
||||
|
||||
it("rejects config with both projectId and containerTags", () => {
|
||||
expect(() =>
|
||||
getContainerTags({
|
||||
projectId: "abc",
|
||||
containerTags: ["tag-a"],
|
||||
}),
|
||||
).toThrow("either projectId or containerTags")
|
||||
})
|
||||
})
|
||||
|
|
@ -61,6 +61,11 @@ export function getContainerTags(config?: {
|
|||
projectId?: string
|
||||
containerTags?: string[]
|
||||
}): string[] {
|
||||
if (config?.projectId !== undefined && config.containerTags !== undefined) {
|
||||
throw new Error(
|
||||
"Supermemory tools config accepts either projectId or containerTags, not both.",
|
||||
)
|
||||
}
|
||||
if (config?.projectId) {
|
||||
return [`${CONTAINER_TAG_CONSTANTS.projectPrefix}${config.projectId}`]
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue