base schema refactor

This commit is contained in:
Dallin Romney 2025-02-03 09:33:47 -08:00
parent cb7944e01f
commit ba772ff55b
8 changed files with 81 additions and 59 deletions

View file

@ -1,7 +1,8 @@
import { z } from "zod";
import { completionOptionsSchema } from "../../models.js";
import { baseDevDataAllSchema } from "../base.js";
export const autocompleteEventAllSchema = z.object({
export const autocompleteEventAllSchema = baseDevDataAllSchema.extend({
// Tab autocomplete options - TODO - old json version?
disable: z.boolean(),
useFileSuffix: z.boolean(),

View file

@ -1,41 +1,49 @@
import { baseDevDataSchema_0_2_0 } from "../base/0.2.0.js";
import { autocompleteEventAllSchema } from "./index.js";
export const autocompleteEventSchema_0_2_0 = baseDevDataSchema_0_2_0.merge(
autocompleteEventAllSchema.pick({
disable: true,
useFileSuffix: true,
maxPromptTokens: true,
debounceDelay: true,
maxSuffixPercentage: true,
prefixPercentage: true,
transform: true,
template: true,
multilineCompletions: true,
slidingWindowPrefixPercentage: true,
slidingWindowSize: true,
useCache: true,
onlyMyCode: true,
useRecentlyEdited: true,
disableInFiles: true,
useImports: true,
accepted: true,
time: true,
prefix: true,
suffix: true,
prompt: true,
completion: true,
modelProvider: true,
modelName: true,
completionOptions: true,
cacheHit: true,
filepath: true,
gitRepo: true,
completionId: true,
uniqueId: true,
timestamp: true,
}),
);
export const autocompleteEventSchema_0_2_0 = autocompleteEventAllSchema.pick({
// base
createdAt: true,
userId: true,
userAgent: true,
platform: true,
selectedProfileId: true,
eventName: true,
schemaVersion: true,
sessionId: true,
// autocomplete-specific
disable: true,
useFileSuffix: true,
maxPromptTokens: true,
debounceDelay: true,
maxSuffixPercentage: true,
prefixPercentage: true,
transform: true,
template: true,
multilineCompletions: true,
slidingWindowPrefixPercentage: true,
slidingWindowSize: true,
useCache: true,
onlyMyCode: true,
useRecentlyEdited: true,
disableInFiles: true,
useImports: true,
accepted: true,
time: true,
prefix: true,
suffix: true,
prompt: true,
completion: true,
modelProvider: true,
modelName: true,
completionOptions: true,
cacheHit: true,
filepath: true,
gitRepo: true,
completionId: true,
uniqueId: true,
timestamp: true,
});
export const autocompleteEventSchema_0_2_0_noPII =
autocompleteEventSchema_0_2_0.omit({

View file

@ -1,6 +1,6 @@
import { z } from "zod";
export const baseDevDataSchema_0_2_0 = z.object({
export const baseDevDataAllSchema = z.object({
eventName: z.string(),
schemaVersion: z.string(),
sessionId: z.string(),

View file

@ -1,5 +0,0 @@
import { baseDevDataSchema_0_2_0 } from "./0.2.0.js";
export const baseSchemasPerVersion = {
["0.2.0" as string]: baseDevDataSchema_0_2_0,
};

View file

@ -1,6 +1,7 @@
import { z } from "zod";
import { baseDevDataAllSchema } from "../base.js";
export const chatFeedbackEventAllSchema = z.object({
export const chatFeedbackEventAllSchema = baseDevDataAllSchema.extend({
modelTitle: z.string(),
completionOptions: z.object({}),
prompt: z.string(),

View file

@ -1,15 +1,22 @@
import { baseDevDataSchema_0_2_0 } from "../base/0.2.0.js";
import { chatFeedbackEventAllSchema } from "./index.js";
export const chatFeedbackEventSchema_0_2_0 = baseDevDataSchema_0_2_0.merge(
chatFeedbackEventAllSchema.pick({
prompt: true,
completion: true,
modelTitle: true,
feedback: true,
sessionId: true,
}),
);
export const chatFeedbackEventSchema_0_2_0 = chatFeedbackEventAllSchema.pick({
// base
createdAt: true,
userId: true,
userAgent: true,
platform: true,
selectedProfileId: true,
eventName: true,
schemaVersion: true,
sessionId: true,
// other
prompt: true,
completion: true,
modelTitle: true,
feedback: true,
});
export const chatFeedbackEventSchema_0_2_0_noPII =
chatFeedbackEventSchema_0_2_0.omit({

View file

@ -1,6 +1,7 @@
import { z } from "zod";
import { baseDevDataAllSchema } from "../base.js";
export const tokensGeneratedEventAllSchema = z.object({
export const tokensGeneratedEventAllSchema = baseDevDataAllSchema.extend({
model: z.string(),
provider: z.string(),
promptTokens: z.number(),

View file

@ -1,14 +1,23 @@
import { baseDevDataSchema_0_2_0 } from "../base/0.2.0.js";
import { tokensGeneratedEventAllSchema } from "./index.js";
export const tokensGeneratedEventSchema_0_2_0 = baseDevDataSchema_0_2_0.merge(
export const tokensGeneratedEventSchema_0_2_0 =
tokensGeneratedEventAllSchema.pick({
// base
createdAt: true,
userId: true,
userAgent: true,
platform: true,
selectedProfileId: true,
eventName: true,
schemaVersion: true,
sessionId: true,
// tokens generated specific
model: true,
provider: true,
promptTokens: true,
generatedTokens: true,
}),
);
});
export const tokensGeneratedEventSchema_0_2_0_noPII =
tokensGeneratedEventSchema_0_2_0;