(userId: string)
| 539 | } |
| 540 | |
| 541 | export async function getStarredPlugins(userId: string) { |
| 542 | "use cache"; |
| 543 | cacheLife("hours"); |
| 544 | cacheTag("plugins", `stars-${userId}`); |
| 545 | |
| 546 | const supabase = await createClient(); |
| 547 | const { data, error } = await supabase |
| 548 | .from("plugin_stars") |
| 549 | .select("plugin:plugin_id(*, plugin_components(*))") |
| 550 | .eq("user_id", userId); |
| 551 | |
| 552 | // Without generated DB types, supabase-js can't tell this embedded |
| 553 | // resource is to-one, so the inferred shape needs correcting. |
| 554 | const rows = (data ?? []) as unknown as Array<{ plugin: PluginRow | null }>; |
| 555 | const plugins = rows |
| 556 | .map((row) => row.plugin) |
| 557 | .filter((plugin): plugin is PluginRow => Boolean(plugin)); |
| 558 | |
| 559 | return { data: plugins, error }; |
| 560 | } |
| 561 | |
| 562 | export async function hasUserStarredPlugin(pluginId: string, userId: string) { |
| 563 | const supabase = await createClient(); |
no test coverage detected