mirror of
https://github.com/rowboatlabs/rowboat.git
synced 2026-05-10 15:52:38 +02:00
use strong typing in mongo repos
This commit is contained in:
parent
53219974d3
commit
0131c2a111
7 changed files with 15 additions and 15 deletions
|
|
@ -1,5 +1,5 @@
|
|||
import { z } from "zod";
|
||||
import { ObjectId } from "mongodb";
|
||||
import { Filter, ObjectId } from "mongodb";
|
||||
import { db } from "@/app/lib/mongodb";
|
||||
import { CreateDeploymentSchema, IComposioTriggerDeploymentsRepository } from "@/src/application/repositories/composio-trigger-deployments.repository.interface";
|
||||
import { ComposioTriggerDeployment } from "@/src/entities/models/composio-trigger-deployment";
|
||||
|
|
@ -135,7 +135,7 @@ export class MongodbComposioTriggerDeploymentsRepository implements IComposioTri
|
|||
* Retrieves all trigger deployments for a specific project with pagination.
|
||||
*/
|
||||
async listByProjectId(projectId: string, cursor?: string, limit: number = 50): Promise<z.infer<ReturnType<typeof PaginatedList<typeof ComposioTriggerDeployment>>>> {
|
||||
const query: any = { projectId };
|
||||
const query: Filter<z.infer<typeof DocSchema>> = { projectId };
|
||||
|
||||
if (cursor) {
|
||||
query._id = { $gt: new ObjectId(cursor) };
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
import { z } from "zod";
|
||||
import { db } from "@/app/lib/mongodb";
|
||||
import { ObjectId } from "mongodb";
|
||||
import { Filter, ObjectId } from "mongodb";
|
||||
import { AddTurnData, CreateConversationData, IConversationsRepository, ListedConversationItem } from "@/src/application/repositories/conversations.repository.interface";
|
||||
import { Conversation } from "@/src/entities/models/conversation";
|
||||
import { nanoid } from "nanoid";
|
||||
|
|
@ -76,7 +76,7 @@ export class MongoDBConversationsRepository implements IConversationsRepository
|
|||
}
|
||||
|
||||
async list(projectId: string, cursor?: string, limit: number = 50): Promise<z.infer<ReturnType<typeof PaginatedList<typeof ListedConversationItem>>>> {
|
||||
const query: any = { projectId };
|
||||
const query: Filter<z.infer<typeof DocSchema>> = { projectId };
|
||||
|
||||
if (cursor) {
|
||||
query._id = { $lt: new ObjectId(cursor) };
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
import { z } from "zod";
|
||||
import { ObjectId } from "mongodb";
|
||||
import { Filter, ObjectId } from "mongodb";
|
||||
import { db } from "@/app/lib/mongodb";
|
||||
import { DataSource } from "@/src/entities/models/data-source";
|
||||
import {
|
||||
|
|
@ -68,7 +68,7 @@ export class MongoDBDataSourcesRepository implements IDataSourcesRepository {
|
|||
cursor?: string,
|
||||
limit: number = 50
|
||||
): Promise<z.infer<ReturnType<typeof PaginatedList<typeof DataSource>>>> {
|
||||
const query: any = { projectId, status: { $ne: "deleted" } };
|
||||
const query: Filter<z.infer<typeof DocSchema>> = { projectId, status: { $ne: "deleted" } };
|
||||
|
||||
// Default behavior: exclude deleted unless explicitly asked for
|
||||
if (filters?.deleted === true) {
|
||||
|
|
@ -92,7 +92,7 @@ export class MongoDBDataSourcesRepository implements IDataSourcesRepository {
|
|||
.toArray();
|
||||
|
||||
const hasNextPage = results.length > _limit;
|
||||
const items = results.slice(0, _limit).map((doc: any) => {
|
||||
const items = results.slice(0, _limit).map((doc) => {
|
||||
const { _id, ...rest } = doc;
|
||||
return {
|
||||
...rest,
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
import { z } from "zod";
|
||||
import { ObjectId } from "mongodb";
|
||||
import { Filter, ObjectId } from "mongodb";
|
||||
import { db } from "@/app/lib/mongodb";
|
||||
import { CreateJobSchema, IJobsRepository, JobFiltersSchema, ListedJobItem, UpdateJobSchema } from "@/src/application/repositories/jobs.repository.interface";
|
||||
import { Job } from "@/src/entities/models/job";
|
||||
|
|
@ -206,7 +206,7 @@ export class MongoDBJobsRepository implements IJobsRepository {
|
|||
cursor?: string,
|
||||
limit: number = 50
|
||||
): Promise<z.infer<ReturnType<typeof PaginatedList<typeof ListedJobItem>>>> {
|
||||
const query: any = { projectId };
|
||||
const query: Filter<z.infer<typeof DocSchema>> = { projectId };
|
||||
|
||||
const _limit = Math.min(limit, 50);
|
||||
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@ import { CreateProjectMemberSchema, IProjectMembersRepository } from "@/src/appl
|
|||
import { ProjectMember } from "@/src/entities/models/project-member";
|
||||
import { db } from "@/app/lib/mongodb";
|
||||
import { z } from "zod";
|
||||
import { ObjectId } from "mongodb";
|
||||
import { Filter, ObjectId } from "mongodb";
|
||||
import { PaginatedList } from "@/src/entities/common/paginated-list";
|
||||
|
||||
const docSchema = ProjectMember.omit({
|
||||
|
|
@ -45,7 +45,7 @@ export class MongoDBProjectMembersRepository implements IProjectMembersRepositor
|
|||
}
|
||||
|
||||
async findByUserId(userId: string, cursor?: string, limit: number = 50): Promise<z.infer<ReturnType<typeof PaginatedList<typeof ProjectMember>>>> {
|
||||
const query: any = { userId };
|
||||
const query: Filter<z.infer<typeof docSchema>> = { userId };
|
||||
|
||||
if (cursor) {
|
||||
query._id = { $lt: new ObjectId(cursor) };
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
import { z } from "zod";
|
||||
import { ObjectId } from "mongodb";
|
||||
import { Filter, ObjectId } from "mongodb";
|
||||
import { db } from "@/app/lib/mongodb";
|
||||
import { CreateRecurringRuleSchema, IRecurringJobRulesRepository, ListedRecurringRuleItem } from "@/src/application/repositories/recurring-job-rules.repository.interface";
|
||||
import { RecurringJobRule } from "@/src/entities/models/recurring-job-rule";
|
||||
|
|
@ -170,7 +170,7 @@ export class MongoDBRecurringJobRulesRepository implements IRecurringJobRulesRep
|
|||
* Lists recurring job rules for a specific project with pagination.
|
||||
*/
|
||||
async list(projectId: string, cursor?: string, limit: number = 50): Promise<z.infer<ReturnType<typeof PaginatedList<typeof ListedRecurringRuleItem>>>> {
|
||||
const query: any = { projectId };
|
||||
const query: Filter<z.infer<typeof DocSchema>> = { projectId };
|
||||
|
||||
if (cursor) {
|
||||
query._id = { $lt: new ObjectId(cursor) };
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
import { z } from "zod";
|
||||
import { ObjectId } from "mongodb";
|
||||
import { Filter, ObjectId } from "mongodb";
|
||||
import { db } from "@/app/lib/mongodb";
|
||||
import { CreateRuleSchema, IScheduledJobRulesRepository, ListedRuleItem, UpdateJobSchema } from "@/src/application/repositories/scheduled-job-rules.repository.interface";
|
||||
import { ScheduledJobRule } from "@/src/entities/models/scheduled-job-rule";
|
||||
|
|
@ -187,7 +187,7 @@ export class MongoDBScheduledJobRulesRepository implements IScheduledJobRulesRep
|
|||
* Lists scheduled job rules for a specific project with pagination.
|
||||
*/
|
||||
async list(projectId: string, cursor?: string, limit: number = 50): Promise<z.infer<ReturnType<typeof PaginatedList<typeof ListedRuleItem>>>> {
|
||||
const query: any = { projectId };
|
||||
const query: Filter<z.infer<typeof DocSchema>> = { projectId };
|
||||
|
||||
if (cursor) {
|
||||
query._id = { $lt: new ObjectId(cursor) };
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue