@vue-skuilder/mcp 0.1.24 → 0.1.26
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +126 -61
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +126 -61
- package/dist/index.mjs.map +1 -1
- package/package.json +5 -5
- package/src/resources/cards.ts +182 -78
package/dist/index.js
CHANGED
|
@@ -131,6 +131,51 @@ function logToolError(toolName, message, error) {
|
|
|
131
131
|
}
|
|
132
132
|
|
|
133
133
|
// src/resources/cards.ts
|
|
134
|
+
async function transformCardsToResourceData(courseDB, cardIds, eloMap) {
|
|
135
|
+
if (cardIds.length === 0) return [];
|
|
136
|
+
const cardDocs = await courseDB.getCourseDocs(cardIds);
|
|
137
|
+
const dataDocIds = [];
|
|
138
|
+
const cardToDataMap = /* @__PURE__ */ new Map();
|
|
139
|
+
for (const row of cardDocs.rows) {
|
|
140
|
+
if (isSuccessRow(row)) {
|
|
141
|
+
const cardDoc = row.doc;
|
|
142
|
+
const cardId = cardDoc._id;
|
|
143
|
+
const dataIds = cardDoc.id_displayable_data;
|
|
144
|
+
if (dataIds && dataIds.length > 0) {
|
|
145
|
+
const dataDocId = dataIds[0];
|
|
146
|
+
dataDocIds.push(dataDocId);
|
|
147
|
+
cardToDataMap.set(cardId, dataDocId);
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
const dataDocs = dataDocIds.length > 0 ? await courseDB.getCourseDocs(dataDocIds) : { rows: [] };
|
|
152
|
+
const dataDocMap = /* @__PURE__ */ new Map();
|
|
153
|
+
for (const row of dataDocs.rows) {
|
|
154
|
+
if (isSuccessRow(row)) {
|
|
155
|
+
dataDocMap.set(row.doc._id, row.doc);
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
const cards = [];
|
|
159
|
+
for (const row of cardDocs.rows) {
|
|
160
|
+
if (isSuccessRow(row)) {
|
|
161
|
+
const cardDoc = row.doc;
|
|
162
|
+
const cardId = cardDoc._id;
|
|
163
|
+
const dataDocId = cardToDataMap.get(cardId);
|
|
164
|
+
const dataDoc = dataDocId ? dataDocMap.get(dataDocId) : null;
|
|
165
|
+
cards.push({
|
|
166
|
+
cardId,
|
|
167
|
+
datashape: dataDoc?.id_datashape || "unknown",
|
|
168
|
+
data: dataDoc?.data || {},
|
|
169
|
+
tags: [],
|
|
170
|
+
// Tags are stored separately in TAG documents
|
|
171
|
+
elo: eloMap.get(cardId) || cardDoc.elo?.global?.score || 1500,
|
|
172
|
+
created: cardDoc.created,
|
|
173
|
+
modified: cardDoc.modified
|
|
174
|
+
});
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
return cards;
|
|
178
|
+
}
|
|
134
179
|
var EloRangeSchema = import_zod3.z.object({
|
|
135
180
|
min: import_zod3.z.number().min(0).max(5e3),
|
|
136
181
|
max: import_zod3.z.number().min(0).max(5e3)
|
|
@@ -139,40 +184,68 @@ var EloRangeSchema = import_zod3.z.object({
|
|
|
139
184
|
});
|
|
140
185
|
async function handleCardsAllResource(courseDB, limit = 50, offset = 0) {
|
|
141
186
|
try {
|
|
142
|
-
const
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
187
|
+
const countResult = await courseDB.db.allDocs({
|
|
188
|
+
startkey: "c-",
|
|
189
|
+
endkey: "c-\uFFF0",
|
|
190
|
+
include_docs: false
|
|
191
|
+
// No limit - get all IDs to count them
|
|
192
|
+
});
|
|
193
|
+
const totalCards = countResult.rows.length;
|
|
194
|
+
const allCardsResult = await courseDB.db.allDocs({
|
|
195
|
+
startkey: "c-",
|
|
196
|
+
endkey: "c-\uFFF0",
|
|
197
|
+
include_docs: true,
|
|
198
|
+
// Include docs so we can debug
|
|
199
|
+
skip: offset,
|
|
200
|
+
limit
|
|
201
|
+
});
|
|
202
|
+
const cardIds = allCardsResult.rows.map((row) => row.id);
|
|
203
|
+
if (cardIds.length === 0) {
|
|
146
204
|
return {
|
|
147
205
|
cards: [],
|
|
148
|
-
total:
|
|
206
|
+
total: totalCards,
|
|
149
207
|
page: Math.floor(offset / limit) + 1,
|
|
150
208
|
limit,
|
|
151
209
|
filter: "all"
|
|
152
210
|
};
|
|
153
211
|
}
|
|
154
|
-
const
|
|
155
|
-
const
|
|
156
|
-
const
|
|
157
|
-
|
|
158
|
-
|
|
212
|
+
const dataDocIds = [];
|
|
213
|
+
const cardToDataMap = /* @__PURE__ */ new Map();
|
|
214
|
+
for (const row of allCardsResult.rows) {
|
|
215
|
+
const cardDoc = row.doc;
|
|
216
|
+
const dataIds = cardDoc.id_displayable_data;
|
|
217
|
+
if (dataIds && dataIds.length > 0) {
|
|
218
|
+
const dataDocId = dataIds[0];
|
|
219
|
+
dataDocIds.push(dataDocId);
|
|
220
|
+
cardToDataMap.set(cardDoc._id, dataDocId);
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
const dataDocs = dataDocIds.length > 0 ? await courseDB.getCourseDocs(dataDocIds, { include_docs: true }) : { rows: [] };
|
|
224
|
+
const dataDocMap = /* @__PURE__ */ new Map();
|
|
225
|
+
for (const row of dataDocs.rows) {
|
|
159
226
|
if (isSuccessRow(row)) {
|
|
160
|
-
|
|
161
|
-
cards.push({
|
|
162
|
-
cardId: doc._id,
|
|
163
|
-
datashape: doc.shape?.name || "unknown",
|
|
164
|
-
data: doc.data || {},
|
|
165
|
-
tags: [],
|
|
166
|
-
// Will be populated separately if needed
|
|
167
|
-
elo: eloMap.get(doc._id),
|
|
168
|
-
created: doc.created,
|
|
169
|
-
modified: doc.modified
|
|
170
|
-
});
|
|
227
|
+
dataDocMap.set(row.doc._id, row.doc);
|
|
171
228
|
}
|
|
172
229
|
}
|
|
230
|
+
const cards = [];
|
|
231
|
+
for (const row of allCardsResult.rows) {
|
|
232
|
+
const cardDoc = row.doc;
|
|
233
|
+
const cardId = cardDoc._id;
|
|
234
|
+
const dataDocId = cardToDataMap.get(cardId);
|
|
235
|
+
const dataDoc = dataDocId ? dataDocMap.get(dataDocId) : null;
|
|
236
|
+
cards.push({
|
|
237
|
+
cardId,
|
|
238
|
+
datashape: dataDoc?.id_datashape || "unknown",
|
|
239
|
+
data: dataDoc?.data || {},
|
|
240
|
+
tags: [],
|
|
241
|
+
elo: cardDoc.elo?.global?.score || 1500,
|
|
242
|
+
created: cardDoc.created,
|
|
243
|
+
modified: cardDoc.modified
|
|
244
|
+
});
|
|
245
|
+
}
|
|
173
246
|
return {
|
|
174
247
|
cards,
|
|
175
|
-
total:
|
|
248
|
+
total: totalCards,
|
|
176
249
|
page: Math.floor(offset / limit) + 1,
|
|
177
250
|
limit,
|
|
178
251
|
filter: "all"
|
|
@@ -217,34 +290,40 @@ async function handleCardsShapeResource(courseDB, shapeName, limit = 50, offset
|
|
|
217
290
|
filter: `shape:${shapeName}`
|
|
218
291
|
};
|
|
219
292
|
}
|
|
220
|
-
const
|
|
221
|
-
const
|
|
222
|
-
const
|
|
293
|
+
const cardIds = allCardIds.map((c) => c.cardID);
|
|
294
|
+
const cardDocs = await courseDB.getCourseDocs(cardIds);
|
|
295
|
+
const dataDocIds = [];
|
|
296
|
+
const cardToDataMap = /* @__PURE__ */ new Map();
|
|
223
297
|
for (const row of cardDocs.rows) {
|
|
224
|
-
if (isSuccessRow(row)
|
|
225
|
-
|
|
226
|
-
|
|
298
|
+
if (isSuccessRow(row)) {
|
|
299
|
+
const cardDoc = row.doc;
|
|
300
|
+
const dataIds = cardDoc.id_displayable_data;
|
|
301
|
+
if (dataIds && dataIds.length > 0) {
|
|
302
|
+
const dataDocId = dataIds[0];
|
|
303
|
+
dataDocIds.push(dataDocId);
|
|
304
|
+
cardToDataMap.set(cardDoc._id, dataDocId);
|
|
305
|
+
}
|
|
227
306
|
}
|
|
228
307
|
}
|
|
229
|
-
const
|
|
230
|
-
const
|
|
231
|
-
const
|
|
232
|
-
const eloMap = new Map(eloData.map((elo, index) => [paginatedCardIds[index], elo.global?.score || 1500]));
|
|
233
|
-
const cards = [];
|
|
234
|
-
for (const row of paginatedRows) {
|
|
308
|
+
const dataDocs = dataDocIds.length > 0 ? await courseDB.getCourseDocs(dataDocIds) : { rows: [] };
|
|
309
|
+
const dataDocShapeMap = /* @__PURE__ */ new Map();
|
|
310
|
+
for (const row of dataDocs.rows) {
|
|
235
311
|
if (isSuccessRow(row)) {
|
|
236
|
-
const
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
});
|
|
312
|
+
const dataDoc = row.doc;
|
|
313
|
+
dataDocShapeMap.set(dataDoc._id, dataDoc.id_datashape);
|
|
314
|
+
}
|
|
315
|
+
}
|
|
316
|
+
const filteredCardIds = [];
|
|
317
|
+
for (const [cardId, dataDocId] of cardToDataMap.entries()) {
|
|
318
|
+
const dataShape = dataDocShapeMap.get(dataDocId);
|
|
319
|
+
if (dataShape === shapeName) {
|
|
320
|
+
filteredCardIds.push(cardId);
|
|
246
321
|
}
|
|
247
322
|
}
|
|
323
|
+
const paginatedCardIds = filteredCardIds.slice(offset, offset + limit);
|
|
324
|
+
const eloData = await courseDB.getCardEloData(paginatedCardIds);
|
|
325
|
+
const eloMap = new Map(eloData.map((elo, index) => [paginatedCardIds[index], elo.global?.score || 1500]));
|
|
326
|
+
const cards = await transformCardsToResourceData(courseDB, paginatedCardIds, eloMap);
|
|
248
327
|
const totalFiltered = filteredCardIds.length;
|
|
249
328
|
return {
|
|
250
329
|
cards,
|
|
@@ -295,23 +374,9 @@ async function handleCardsEloResource(courseDB, eloRange, limit = 50, offset = 0
|
|
|
295
374
|
filter: `elo:${eloRange}`
|
|
296
375
|
};
|
|
297
376
|
}
|
|
298
|
-
const
|
|
299
|
-
const eloMap = new Map(paginatedEloData.map(({ elo, cardId }) => [cardId, elo.global?.score || 1500]));
|
|
300
|
-
const cardsData =
|
|
301
|
-
for (const row of cardDocs.rows) {
|
|
302
|
-
if (isSuccessRow(row)) {
|
|
303
|
-
const doc = row.doc;
|
|
304
|
-
cardsData.push({
|
|
305
|
-
cardId: doc._id,
|
|
306
|
-
datashape: doc.shape?.name || "unknown",
|
|
307
|
-
data: doc.data || {},
|
|
308
|
-
tags: [],
|
|
309
|
-
elo: eloMap.get(doc._id),
|
|
310
|
-
created: doc.created,
|
|
311
|
-
modified: doc.modified
|
|
312
|
-
});
|
|
313
|
-
}
|
|
314
|
-
}
|
|
377
|
+
const paginatedCardIds = paginatedCards.map((c) => c.cardID);
|
|
378
|
+
const eloMap = new Map(paginatedEloData.map(({ elo, cardId }) => [cardId.cardID, elo.global?.score || 1500]));
|
|
379
|
+
const cardsData = await transformCardsToResourceData(courseDB, paginatedCardIds, eloMap);
|
|
315
380
|
return {
|
|
316
381
|
cards: cardsData,
|
|
317
382
|
total: filteredEloData.length,
|