MCPcopy
hub / github.com/codedogQBY/ReadAny / upsertSkill

Function upsertSkill

packages/core/src/db/skill-queries.ts:62–96  ·  view source on GitHub ↗
(skill: Skill)

Source from the content-addressed store, hash-verified

60}
61
62export async function upsertSkill(skill: Skill): Promise<void> {
63 const database = await getDB();
64 const deviceId = await getDeviceId();
65 const syncVersion = await nextSyncVersion(database, "skills");
66 const updatedAt = Math.max(skill.updatedAt, await nextUpdatedAt(database, "skills", skill.id));
67 await database.execute(
68 `INSERT INTO skills (id, name, description, icon, enabled, parameters, prompt, built_in, created_at, updated_at, sync_version, last_modified_by)
69 VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
70 ON CONFLICT(id) DO UPDATE SET
71 name = excluded.name,
72 description = excluded.description,
73 icon = excluded.icon,
74 enabled = excluded.enabled,
75 parameters = excluded.parameters,
76 prompt = excluded.prompt,
77 built_in = excluded.built_in,
78 updated_at = excluded.updated_at,
79 sync_version = excluded.sync_version,
80 last_modified_by = excluded.last_modified_by`,
81 [
82 skill.id,
83 skill.name,
84 skill.description,
85 skill.icon || null,
86 skill.enabled ? 1 : 0,
87 JSON.stringify(skill.parameters),
88 skill.prompt,
89 skill.builtIn ? 1 : 0,
90 skill.createdAt,
91 updatedAt,
92 syncVersion,
93 deviceId,
94 ],
95 );
96}
97
98export async function updateSkill(id: string, updates: Partial<Skill>): Promise<void> {
99 const database = await getDB();

Callers 5

SkillsScreenFunction · 0.90
toggleSkillFunction · 0.85
toggleSkillFunction · 0.85
handleSaveSkillFunction · 0.85

Calls 5

getDBFunction · 0.90
getDeviceIdFunction · 0.90
nextSyncVersionFunction · 0.90
nextUpdatedAtFunction · 0.90
executeMethod · 0.65

Tested by

no test coverage detected