@nordsym/apiclaw 1.7.10 → 1.7.11
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/convex/providers.ts +10 -14
- package/package.json +1 -1
package/convex/providers.ts
CHANGED
|
@@ -164,32 +164,28 @@ export const trackDiscovery = mutation({
|
|
|
164
164
|
export const trackDiscoveryByProvider = mutation({
|
|
165
165
|
args: { provider: v.string(), query: v.string() },
|
|
166
166
|
handler: async (ctx, args) => {
|
|
167
|
-
// Find
|
|
167
|
+
// Find provider by email mapping
|
|
168
168
|
const providerEmailMap: Record<string, string> = {
|
|
169
169
|
apilayer: "gustav_hemmingsson@hotmail.com",
|
|
170
170
|
};
|
|
171
171
|
const email = providerEmailMap[args.provider];
|
|
172
|
-
if (!email) return;
|
|
172
|
+
if (!email) return { updated: 0, error: "no email mapping" };
|
|
173
173
|
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
.
|
|
174
|
+
// Find provider record by email
|
|
175
|
+
const provider = await ctx.db
|
|
176
|
+
.query("providers")
|
|
177
|
+
.withIndex("by_email", (q) => q.eq("email", email))
|
|
177
178
|
.first();
|
|
178
|
-
if (!
|
|
179
|
-
|
|
180
|
-
// Find provider record
|
|
181
|
-
const providers = await ctx.db.query("providers").collect();
|
|
182
|
-
const provider = providers.find((p: any) => p.workspaceId === workspace._id);
|
|
183
|
-
if (!provider) return;
|
|
179
|
+
if (!provider) return { updated: 0, error: "provider not found" };
|
|
184
180
|
|
|
185
181
|
// Get all APIs for this provider
|
|
186
182
|
const apis = await ctx.db.query("providerAPIs").collect();
|
|
187
|
-
const providerApis = apis.filter((a
|
|
183
|
+
const providerApis = apis.filter((a) => a.providerId === provider._id);
|
|
188
184
|
|
|
189
|
-
// Increment discoveryCount on ALL provider APIs
|
|
185
|
+
// Increment discoveryCount on ALL provider APIs
|
|
190
186
|
for (const api of providerApis) {
|
|
191
187
|
await ctx.db.patch(api._id, {
|
|
192
|
-
discoveryCount: (api.discoveryCount || 0) + 1,
|
|
188
|
+
discoveryCount: ((api as any).discoveryCount || 0) + 1,
|
|
193
189
|
lastDiscoveredAt: Date.now(),
|
|
194
190
|
});
|
|
195
191
|
}
|