mirror of
https://github.com/supermemoryai/supermemory.git
synced 2026-10-10 03:28:14 +00:00
Merge 84d6f5bd3d into 66ce7f8c78
This commit is contained in:
commit
39f90ea7e9
3 changed files with 42 additions and 3 deletions
|
|
@ -26,13 +26,14 @@ import {
|
||||||
SearchResponseSchema,
|
SearchResponseSchema,
|
||||||
type SearchResult,
|
type SearchResult,
|
||||||
SettingsRequestSchema,
|
SettingsRequestSchema,
|
||||||
|
SettingsResponseSchema,
|
||||||
UpdateContainerTagSettingsRequestSchema,
|
UpdateContainerTagSettingsRequestSchema,
|
||||||
} from "../validation/api"
|
} from "../validation/api"
|
||||||
|
|
||||||
const UpdateSettingsResponseSchema = z.object({
|
const UpdateSettingsResponseSchema = z.object({
|
||||||
orgId: z.string(),
|
orgId: z.string(),
|
||||||
orgSlug: z.string(),
|
orgSlug: z.string(),
|
||||||
updated: SettingsRequestSchema,
|
updated: SettingsResponseSchema,
|
||||||
})
|
})
|
||||||
|
|
||||||
// Analytics request schema - custom to console
|
// Analytics request schema - custom to console
|
||||||
|
|
@ -190,7 +191,7 @@ export const apiSchema = createSchema({
|
||||||
|
|
||||||
// Settings operations
|
// Settings operations
|
||||||
"@get/settings": {
|
"@get/settings": {
|
||||||
output: SettingsRequestSchema,
|
output: SettingsResponseSchema,
|
||||||
},
|
},
|
||||||
"@patch/settings": {
|
"@patch/settings": {
|
||||||
input: SettingsRequestSchema,
|
input: SettingsRequestSchema,
|
||||||
|
|
|
||||||
|
|
@ -6,8 +6,42 @@ import {
|
||||||
ListMemoriesQuerySchema,
|
ListMemoriesQuerySchema,
|
||||||
SearchRequestSchema,
|
SearchRequestSchema,
|
||||||
Searchv4RequestSchema,
|
Searchv4RequestSchema,
|
||||||
|
SettingsRequestSchema,
|
||||||
|
SettingsResponseSchema,
|
||||||
} from "./api"
|
} from "./api"
|
||||||
|
|
||||||
|
describe("organization settings schemas", () => {
|
||||||
|
it.each([
|
||||||
|
"x",
|
||||||
|
"x".repeat(750),
|
||||||
|
])("accepts a filter prompt at a documented boundary", (filterPrompt) => {
|
||||||
|
expect(SettingsRequestSchema.parse({ filterPrompt }).filterPrompt).toBe(
|
||||||
|
filterPrompt,
|
||||||
|
)
|
||||||
|
})
|
||||||
|
|
||||||
|
it.each([
|
||||||
|
"",
|
||||||
|
"x".repeat(751),
|
||||||
|
])("rejects a filter prompt outside the documented boundaries", (filterPrompt) => {
|
||||||
|
expect(SettingsRequestSchema.safeParse({ filterPrompt }).success).toBe(
|
||||||
|
false,
|
||||||
|
)
|
||||||
|
})
|
||||||
|
|
||||||
|
it("accepts null to clear the filter prompt", () => {
|
||||||
|
expect(
|
||||||
|
SettingsRequestSchema.parse({ filterPrompt: null }).filterPrompt,
|
||||||
|
).toBe(null)
|
||||||
|
})
|
||||||
|
|
||||||
|
it("continues to parse legacy empty prompts in settings responses", () => {
|
||||||
|
expect(
|
||||||
|
SettingsResponseSchema.parse({ filterPrompt: "" }).filterPrompt,
|
||||||
|
).toBe("")
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
describe("search threshold schemas", () => {
|
describe("search threshold schemas", () => {
|
||||||
it("do not contain redundant number transforms or unreachable range guards", () => {
|
it("do not contain redundant number transforms or unreachable range guards", () => {
|
||||||
const source = readFileSync(new URL("./api.ts", import.meta.url), "utf8")
|
const source = readFileSync(new URL("./api.ts", import.meta.url), "utf8")
|
||||||
|
|
|
||||||
|
|
@ -803,12 +803,16 @@ export const ErrorResponseSchema = z.object({
|
||||||
|
|
||||||
export type SearchResult = z.infer<typeof SearchResultSchema>
|
export type SearchResult = z.infer<typeof SearchResultSchema>
|
||||||
|
|
||||||
export const SettingsRequestSchema = OrganizationSettingsSchema.omit({
|
export const SettingsResponseSchema = OrganizationSettingsSchema.omit({
|
||||||
id: true,
|
id: true,
|
||||||
orgId: true,
|
orgId: true,
|
||||||
updatedAt: true,
|
updatedAt: true,
|
||||||
}).partial()
|
}).partial()
|
||||||
|
|
||||||
|
export const SettingsRequestSchema = SettingsResponseSchema.extend({
|
||||||
|
filterPrompt: z.string().min(1).max(750).nullable().optional(),
|
||||||
|
})
|
||||||
|
|
||||||
export const ConnectionResponseSchema = z.object({
|
export const ConnectionResponseSchema = z.object({
|
||||||
createdAt: z.string().datetime(),
|
createdAt: z.string().datetime(),
|
||||||
documentLimit: z.number().optional(),
|
documentLimit: z.number().optional(),
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue