schemaVersion -> schema

This commit is contained in:
Dallin Romney 2025-02-17 14:33:43 -08:00
parent efbed5448c
commit 22dd2d1633
20 changed files with 69 additions and 107 deletions

View file

@ -102,7 +102,7 @@ export class AutocompleteLoggingService {
...outcome,
eventName: "autocomplete",
createdAt: "",
schemaVersion: "",
schema: "",
userAgent: "",
selectedProfileId: "",
userId: "",

View file

@ -29,19 +29,19 @@ export class DataLogger {
return DataLogger.instance;
}
addBaseValues(body: object, schemaVersion: string): object {
addBaseValues(body: object, schema: string): object {
if ("createdAt" in body) {
body.createdAt = new Date().toISOString();
}
if ("schemaVersion" in body) {
body.schemaVersion = schemaVersion;
if ("schema" in body) {
body.schema = schema;
}
if ("userAgent" in body) {
body.userAgent = navigator.userAgent; // TODO sufficient user agent info?
}
if ("selectedProfileId" in body) {
body.selectedProfileId =
this.core?.configHandler.currentProfile.profileDescription.id ?? "";
this.core?.configHandler.currentProfile?.profileDescription.id ?? "";
}
if ("userId" in body) {
body.userId = "not-implemented";
@ -80,7 +80,7 @@ export class DataLogger {
config.data.map(async (dataConfig) => {
try {
// First extract the data schema based on the version and level
const { schemaVersion } = dataConfig;
const { schema } = dataConfig;
const level = dataConfig.level ?? DEFAULT_DEV_DATA_LEVEL;
@ -90,28 +90,28 @@ export class DataLogger {
return;
}
const versionSchemas = devDataVersionedSchemas[schemaVersion];
const versionSchemas = devDataVersionedSchemas[schema];
if (!versionSchemas) {
throw new Error(
`Attempting to log dev data to non-existent version ${schemaVersion}`,
`Attempting to log dev data to non-existent version ${schema}`,
);
}
const levelSchemas = versionSchemas[level];
if (!levelSchemas) {
throw new Error(
`Attempting to log dev data at level ${level} for version ${schemaVersion} which does not exist`,
`Attempting to log dev data at level ${level} for version ${schema} which does not exist`,
);
}
const schema = levelSchemas[event.name];
if (!schema) {
const zodSchema = levelSchemas[event.name];
if (!zodSchema) {
throw new Error(
`Attempting to log dev data for event ${event.name} at level ${level} for version ${schemaVersion}: no schema found`,
`Attempting to log dev data for event ${event.name} at level ${level} for version ${schema}: no schema found`,
);
}
const parsed = schema.safeParse(event.data);
const parsed = zodSchema.safeParse(event.data);
if (!parsed.success) {
throw new Error(
`Failed to parse event data ${parsed.error.toString()}`,
@ -119,7 +119,7 @@ export class DataLogger {
}
// Add base values like createdAt etc. if keys present in body
const payload = this.addBaseValues(parsed.data, schemaVersion);
const payload = this.addBaseValues(parsed.data, schema);
const uriComponents = URI.parse(dataConfig.destination);
@ -143,7 +143,8 @@ export class DataLogger {
headers["Authorization"] = `Bearer ${accessToken}`;
}
const profileId =
this.core?.configHandler.currentProfile.profileDescription.id;
this.core?.configHandler.currentProfile?.profileDescription
.id ?? "";
const response = await fetchwithRequestOptions(
dataConfig.destination,
{
@ -152,7 +153,7 @@ export class DataLogger {
body: JSON.stringify({
name: event.name,
data: payload,
schemaVersion,
schema,
level,
profileId,
}),
@ -166,10 +167,7 @@ export class DataLogger {
}
} else if (uriComponents.scheme === "file") {
// Write to jsonc file for local file URIs
const dirUri = joinPathsToUri(
dataConfig.destination,
schemaVersion,
);
const dirUri = joinPathsToUri(dataConfig.destination, schema);
const dirPath = fileURLToPath(dirUri);
if (!fs.existsSync(dirPath)) {

View file

@ -353,7 +353,7 @@ export abstract class BaseLLM implements ILLM {
eventName: "tokensGenerated",
createdAt: "",
schemaVersion: "",
schema: "",
userAgent: "",
selectedProfileId: "",
userId: "",

13
core/package-lock.json generated
View file

@ -13,7 +13,7 @@
"@aws-sdk/client-sagemaker-runtime": "^3.621.0",
"@aws-sdk/credential-providers": "^3.620.1",
"@continuedev/config-types": "^1.0.13",
"@continuedev/config-yaml": "^1.0.31",
"@continuedev/config-yaml": "file:///users/dallin/documents/code/continuedev/continue/packages/config-yaml/dist",
"@continuedev/fetch": "^1.0.4",
"@continuedev/llm-info": "^1.0.2",
"@continuedev/openai-adapters": "^1.0.10",
@ -106,6 +106,7 @@
"node": ">=20.11.0"
}
},
"../../../../../../../users/dallin/documents/code/continuedev/continue/packages/config-yaml/dist": {},
"../../../../../documents/code/continuedev/continue/packages/config-yaml/dist": {
"extraneous": true
},
@ -3065,14 +3066,8 @@
}
},
"node_modules/@continuedev/config-yaml": {
"version": "1.0.31",
"resolved": "https://registry.npmjs.org/@continuedev/config-yaml/-/config-yaml-1.0.31.tgz",
"integrity": "sha512-HNj+z7UTTARgsJTI0A1buM09fS4HoWVnn6Hbl6kJ2tZmOOm1OgogbcKP68AzHb4fy5H18MWnKS7XuseZpHFzHQ==",
"dependencies": {
"@continuedev/config-types": "^1.0.14",
"yaml": "^2.6.1",
"zod": "^3.23.8"
}
"resolved": "../../../../../../../users/dallin/documents/code/continuedev/continue/packages/config-yaml/dist",
"link": true
},
"node_modules/@continuedev/fetch": {
"version": "1.0.4",

View file

@ -46,7 +46,7 @@
"@aws-sdk/client-sagemaker-runtime": "^3.621.0",
"@aws-sdk/credential-providers": "^3.620.1",
"@continuedev/config-types": "^1.0.13",
"@continuedev/config-yaml": "^1.0.31",
"@continuedev/config-yaml": "file:///users/dallin/documents/code/continuedev/continue/packages/config-yaml/dist",
"@continuedev/fetch": "^1.0.4",
"@continuedev/llm-info": "^1.0.2",
"@continuedev/openai-adapters": "^1.0.10",

View file

@ -217,9 +217,9 @@ export function getDevDataSqlitePath(): string {
export function getDevDataFilePath(
eventName: DevEventName,
schemaVersion: string,
schema: string,
): string {
const versionPath = path.join(getDevDataPath(), schemaVersion);
const versionPath = path.join(getDevDataPath(), schema);
if (!fs.existsSync(versionPath)) {
fs.mkdirSync(versionPath);
}

View file

@ -1,12 +1,12 @@
{
"name": "continue",
"version": "0.9.266",
"version": "0.9.268",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "continue",
"version": "0.9.266",
"version": "0.9.268",
"license": "Apache-2.0",
"dependencies": {
"@continuedev/fetch": "^1.0.3",
@ -106,7 +106,7 @@
"@aws-sdk/client-sagemaker-runtime": "^3.621.0",
"@aws-sdk/credential-providers": "^3.620.1",
"@continuedev/config-types": "^1.0.13",
"@continuedev/config-yaml": "^1.0.31",
"@continuedev/config-yaml": "file:///users/dallin/documents/code/continuedev/continue/packages/config-yaml/dist",
"@continuedev/fetch": "^1.0.4",
"@continuedev/llm-info": "^1.0.2",
"@continuedev/openai-adapters": "^1.0.10",

42
gui/package-lock.json generated
View file

@ -7,7 +7,7 @@
"name": "gui",
"license": "Apache-2.0",
"dependencies": {
"@continuedev/config-yaml": "^1.0.31",
"@continuedev/config-yaml": "file:///users/dallin/documents/code/continuedev/continue/packages/config-yaml/dist",
"@headlessui/react": "^1.7.17",
"@heroicons/react": "^2.0.18",
"@reduxjs/toolkit": "^2.3.0",
@ -98,6 +98,7 @@
"node": ">=20.11.0"
}
},
"../../../../../../../users/dallin/documents/code/continuedev/continue/packages/config-yaml/dist": {},
"../core": {
"name": "@continuedev/core",
"version": "1.0.13",
@ -107,11 +108,7 @@
"@aws-sdk/client-sagemaker-runtime": "^3.621.0",
"@aws-sdk/credential-providers": "^3.620.1",
"@continuedev/config-types": "^1.0.13",
<<<<<<< HEAD
"@continuedev/config-yaml": "^1.0.30",
=======
"@continuedev/config-yaml": "^1.0.31",
>>>>>>> e6c4f8bc84a8efae6f91978988c87145e24ec0bd
"@continuedev/config-yaml": "file:///users/dallin/documents/code/continuedev/continue/packages/config-yaml/dist",
"@continuedev/fetch": "^1.0.4",
"@continuedev/llm-info": "^1.0.2",
"@continuedev/openai-adapters": "^1.0.10",
@ -550,29 +547,9 @@
"integrity": "sha512-0hYQ8SB4Db5zvZB4axdMHGwEaQjkZzFjQiN9LVYvIFB2nSUHW9tYpxWriPrWDASIxiaXax83REcLxuSdnGPZtw==",
"dev": true
},
"node_modules/@continuedev/config-types": {
"version": "1.0.14",
"resolved": "https://registry.npmjs.org/@continuedev/config-types/-/config-types-1.0.14.tgz",
"integrity": "sha512-PVHyHPyRXd2QsaNgnCpiKYU3uHFTlyuQSkqE8OwrBmQqO6/TXUVIr/2EGtyIZGrml4Y+rGMSH40WU4/0t4SGpQ==",
"dependencies": {
"zod": "^3.23.8"
}
},
"node_modules/@continuedev/config-yaml": {
<<<<<<< HEAD
"version": "1.0.30",
"resolved": "https://registry.npmjs.org/@continuedev/config-yaml/-/config-yaml-1.0.30.tgz",
"integrity": "sha512-EIKowUNi/Jc5nPYmbLlRAuQRbpingvAgXpd7XUfdM0LGKEAv3VycoXvZkh66gQCWwWMDhUumvToIzUPuzhugAg==",
=======
"version": "1.0.31",
"resolved": "https://registry.npmjs.org/@continuedev/config-yaml/-/config-yaml-1.0.31.tgz",
"integrity": "sha512-HNj+z7UTTARgsJTI0A1buM09fS4HoWVnn6Hbl6kJ2tZmOOm1OgogbcKP68AzHb4fy5H18MWnKS7XuseZpHFzHQ==",
>>>>>>> e6c4f8bc84a8efae6f91978988c87145e24ec0bd
"dependencies": {
"@continuedev/config-types": "^1.0.14",
"yaml": "^2.6.1",
"zod": "^3.23.8"
}
"resolved": "../../../../../../../users/dallin/documents/code/continuedev/continue/packages/config-yaml/dist",
"link": true
},
"node_modules/@emotion/is-prop-valid": {
"version": "1.3.1",
@ -13723,6 +13700,7 @@
"version": "2.6.1",
"resolved": "https://registry.npmjs.org/yaml/-/yaml-2.6.1.tgz",
"integrity": "sha512-7r0XPzioN/Q9kXBro/XPnA6kznR73DHq+GXh5ON7ZozRO6aMjbmiBuKste2wslTFkC5d1dw0GooOCepZXJ2SAg==",
"dev": true,
"bin": {
"yaml": "bin.mjs"
},
@ -13742,14 +13720,6 @@
"url": "https://github.com/sponsors/sindresorhus"
}
},
"node_modules/zod": {
"version": "3.24.2",
"resolved": "https://registry.npmjs.org/zod/-/zod-3.24.2.tgz",
"integrity": "sha512-lY7CDW43ECgW9u1TcT3IoXHflywfVqDYze4waEz812jR/bZ8FHDsl7pFQoSZTz5N+2NqRXs8GBwnAwo3ZNxqhQ==",
"funding": {
"url": "https://github.com/sponsors/colinhacks"
}
},
"node_modules/zwitch": {
"version": "2.0.4",
"resolved": "https://registry.npmjs.org/zwitch/-/zwitch-2.0.4.tgz",

View file

@ -15,7 +15,7 @@
"test:watch": "vitest"
},
"dependencies": {
"@continuedev/config-yaml": "^1.0.31",
"@continuedev/config-yaml": "file:///users/dallin/documents/code/continuedev/continue/packages/config-yaml/dist",
"@headlessui/react": "^1.7.17",
"@heroicons/react": "^2.0.18",
"@reduxjs/toolkit": "^2.3.0",

View file

@ -30,7 +30,7 @@ export default function FeedbackButtons({ item }: FeedbackButtonsProps) {
eventName: "chatFeedback",
createdAt: "",
schemaVersion: "",
schema: "",
userAgent: "",
selectedProfileId: "",
userId: "",

View file

@ -34,7 +34,7 @@ export const autocompleteEventSchema_0_1_0 = autocompleteEventAllSchema.pick({
timestamp: true,
});
export const autocompleteEventSchema_0_1_0_noPII =
export const autocompleteEventSchema_0_1_0_noCode =
autocompleteEventSchema_0_1_0.omit({
prefix: true,
suffix: true,

View file

@ -7,7 +7,7 @@ export const autocompleteEventSchema_0_2_0 = autocompleteEventAllSchema.pick({
userAgent: true,
selectedProfileId: true,
eventName: true,
schemaVersion: true,
schema: true,
// autocomplete-specific
disable: true,
@ -43,7 +43,7 @@ export const autocompleteEventSchema_0_2_0 = autocompleteEventAllSchema.pick({
timestamp: true,
});
export const autocompleteEventSchema_0_2_0_noPII =
export const autocompleteEventSchema_0_2_0_noCode =
autocompleteEventSchema_0_2_0.omit({
prefix: true,
suffix: true,

View file

@ -2,7 +2,7 @@ import { z } from "zod";
export const baseDevDataAllSchema = z.object({
eventName: z.string(),
schemaVersion: z.string(),
schema: z.string(),
createdAt: z.string(),
userId: z.string(),
userAgent: z.string(),

View file

@ -9,7 +9,7 @@ export const chatFeedbackEventSchema_0_1_0 = chatFeedbackEventAllSchema.pick({
sessionId: true,
});
export const chatFeedbackEventSchema_0_1_0_noPII =
export const chatFeedbackEventSchema_0_1_0_noCode =
chatFeedbackEventSchema_0_1_0.omit({
prompt: true,
completion: true,

View file

@ -7,7 +7,7 @@ export const chatFeedbackEventSchema_0_2_0 = chatFeedbackEventAllSchema.pick({
userAgent: true,
selectedProfileId: true,
eventName: true,
schemaVersion: true,
schema: true,
// other
prompt: true,
@ -17,7 +17,7 @@ export const chatFeedbackEventSchema_0_2_0 = chatFeedbackEventAllSchema.pick({
sessionId: true,
});
export const chatFeedbackEventSchema_0_2_0_noPII =
export const chatFeedbackEventSchema_0_2_0_noCode =
chatFeedbackEventSchema_0_2_0.omit({
prompt: true,
completion: true,

View file

@ -3,45 +3,45 @@ import { autocompleteEventAllSchema } from "./autocomplete/index.js";
import { requestOptionsSchema } from "../models.js";
import {
autocompleteEventSchema_0_1_0,
autocompleteEventSchema_0_1_0_noPII,
autocompleteEventSchema_0_1_0_noCode,
} from "./autocomplete/v0.1.0.js";
import {
quickEditEventSchema_0_1_0,
quickEditEventSchema_0_1_0_noPII,
quickEditEventSchema_0_1_0_noCode,
} from "./quickEdit/v0.1.0.js";
import {
autocompleteEventSchema_0_2_0,
autocompleteEventSchema_0_2_0_noPII,
autocompleteEventSchema_0_2_0_noCode,
} from "./autocomplete/v0.2.0.js";
import { quickEditEventAllSchema } from "./quickEdit/index.js";
import { chatFeedbackEventAllSchema } from "./chatFeedback/index.js";
import { tokensGeneratedEventAllSchema } from "./tokensGenerated/index.js";
import {
chatFeedbackEventSchema_0_1_0,
chatFeedbackEventSchema_0_1_0_noPII,
chatFeedbackEventSchema_0_1_0_noCode,
} from "./chatFeedback/v0.1.0.js";
import {
tokensGeneratedEventSchema_0_1_0,
tokensGeneratedEventSchema_0_1_0_noPII,
tokensGeneratedEventSchema_0_1_0_noCode,
} from "./tokensGenerated/v0.1.0.js";
import {
chatFeedbackEventSchema_0_2_0,
chatFeedbackEventSchema_0_2_0_noPII,
chatFeedbackEventSchema_0_2_0_noCode,
} from "./chatFeedback/v0.2.0.js";
import {
tokensGeneratedEventSchema_0_2_0,
tokensGeneratedEventSchema_0_2_0_noPII,
tokensGeneratedEventSchema_0_2_0_noCode,
} from "./tokensGenerated/v0.2.0.js";
const semverRegex =
/^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-((?:0|[1-9A-Za-z-][0-9A-Za-z-]*)(?:\.(?:0|[1-9A-Za-z-][0-9A-Za-z-]*))*))?(?:\+([0-9A-Za-z-]+(?:\.[0-9A-Za-z-]+)*))?$/;
const dataLevel = z.union([z.literal("all"), z.literal("noPII")]);
const dataLevel = z.union([z.literal("all"), z.literal("noCode")]);
export const dataSchema = z.object({
name: z.string(),
destination: z.string().url(),
schemaVersion: z.string().regex(semverRegex, {
schema: z.string().regex(semverRegex, {
message: "Version must follow semver format, e.g. 0.2.0",
}),
level: dataLevel.optional(),
@ -71,11 +71,11 @@ export const devDataVersionedSchemas = {
chatFeedback: chatFeedbackEventSchema_0_1_0,
tokensGenerated: tokensGeneratedEventSchema_0_1_0,
},
noPII: {
autocomplete: autocompleteEventSchema_0_1_0_noPII,
quickEdit: quickEditEventSchema_0_1_0_noPII,
chatFeedback: chatFeedbackEventSchema_0_1_0_noPII,
tokensGenerated: tokensGeneratedEventSchema_0_1_0_noPII,
noCode: {
autocomplete: autocompleteEventSchema_0_1_0_noCode,
quickEdit: quickEditEventSchema_0_1_0_noCode,
chatFeedback: chatFeedbackEventSchema_0_1_0_noCode,
tokensGenerated: tokensGeneratedEventSchema_0_1_0_noCode,
},
},
["0.2.0" as string]: {
@ -84,10 +84,10 @@ export const devDataVersionedSchemas = {
chatFeedback: chatFeedbackEventSchema_0_2_0,
tokensGenerated: tokensGeneratedEventSchema_0_2_0,
},
noPII: {
autocomplete: autocompleteEventSchema_0_2_0_noPII,
chatFeedback: chatFeedbackEventSchema_0_2_0_noPII,
tokensGenerated: tokensGeneratedEventSchema_0_2_0_noPII,
noCode: {
autocomplete: autocompleteEventSchema_0_2_0_noCode,
chatFeedback: chatFeedbackEventSchema_0_2_0_noCode,
tokensGenerated: tokensGeneratedEventSchema_0_2_0_noCode,
},
},
};

View file

@ -8,10 +8,9 @@ export const quickEditEventSchema_0_1_0 = quickEditEventAllSchema.pick({
model: true,
});
export const quickEditEventSchema_0_1_0_noPII = quickEditEventSchema_0_1_0.omit(
{
export const quickEditEventSchema_0_1_0_noCode =
quickEditEventSchema_0_1_0.omit({
prompt: true,
path: true,
diffs: true,
},
);
});

View file

@ -8,5 +8,5 @@ export const tokensGeneratedEventSchema_0_1_0 =
generatedTokens: true,
});
export const tokensGeneratedEventSchema_0_1_0_noPII =
export const tokensGeneratedEventSchema_0_1_0_noCode =
tokensGeneratedEventSchema_0_1_0;

View file

@ -8,7 +8,7 @@ export const tokensGeneratedEventSchema_0_2_0 =
userAgent: true,
selectedProfileId: true,
eventName: true,
schemaVersion: true,
schema: true,
// tokens generated specific
model: true,
@ -17,5 +17,5 @@ export const tokensGeneratedEventSchema_0_2_0 =
generatedTokens: true,
});
export const tokensGeneratedEventSchema_0_2_0_noPII =
export const tokensGeneratedEventSchema_0_2_0_noCode =
tokensGeneratedEventSchema_0_2_0;

View file

@ -14,7 +14,7 @@
"dependencies": {
"@azure/openai": "^1.0.0-beta.12",
"@continuedev/config-types": "^1.0.5",
"@continuedev/config-yaml": "^1.0.31",
"@continuedev/config-yaml": "file:///users/dallin/documents/code/continuedev/continue/packages/config-yaml/dist",
"@continuedev/fetch": "^1.0.3",
"json-schema": "^0.4.0",
"node-fetch": "^3.3.2",