@m5kdev/backend 0.5.0 → 0.6.0
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/src/modules/auth/auth.lib.d.ts +7 -7
- package/dist/src/modules/auth/auth.trpc.d.ts +15 -15
- package/dist/src/modules/base/base.abstract.d.ts +3 -2
- package/dist/src/modules/base/base.abstract.js +10 -1
- package/dist/src/modules/base/base.procedure.d.ts +112 -0
- package/dist/src/modules/base/base.procedure.js +289 -0
- package/dist/src/modules/base/base.repository.d.ts +1 -0
- package/dist/src/modules/base/base.repository.js +12 -2
- package/dist/src/modules/base/base.service.d.ts +17 -5
- package/dist/src/modules/base/base.service.js +7 -0
- package/dist/src/modules/base/base.service.test.d.ts +1 -0
- package/dist/src/modules/base/base.service.test.js +415 -0
- package/dist/src/modules/connect/connect.repository.d.ts +3 -3
- package/dist/src/modules/connect/connect.service.d.ts +6 -6
- package/dist/src/modules/connect/connect.trpc.d.ts +2 -2
- package/dist/src/modules/recurrence/recurrence.service.d.ts +29 -8
- package/dist/src/modules/recurrence/recurrence.service.js +3 -4
- package/dist/src/modules/recurrence/recurrence.trpc.d.ts +2 -2
- package/dist/src/modules/recurrence/recurrence.trpc.js +1 -1
- package/dist/src/modules/tag/tag.repository.js +27 -26
- package/dist/src/modules/tag/tag.service.d.ts +86 -15
- package/dist/src/modules/tag/tag.service.js +20 -12
- package/dist/src/modules/tag/tag.trpc.d.ts +2 -2
- package/dist/src/types.d.ts +15 -15
- package/dist/src/utils/trpc.d.ts +4 -4
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +3 -3
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { RecurrenceService } from "./recurrence.service";
|
|
2
1
|
import { type TRPCMethods } from "../../utils/trpc";
|
|
2
|
+
import type { RecurrenceService } from "./recurrence.service";
|
|
3
3
|
export declare function createRecurrenceTRPC({ router, privateProcedure: procedure }: TRPCMethods, recurrenceService: RecurrenceService): import("@trpc/server").TRPCBuiltRouter<{
|
|
4
4
|
ctx: import("../auth/auth.lib").Context;
|
|
5
5
|
meta: any;
|
|
@@ -15,7 +15,7 @@ export declare function createRecurrenceTRPC({ router, privateProcedure: procedu
|
|
|
15
15
|
filters?: {
|
|
16
16
|
columnId: string;
|
|
17
17
|
type: "string" | "number" | "boolean" | "date" | "enum";
|
|
18
|
-
method: "contains" | "equals" | "starts_with" | "ends_with" | "greater_than" | "less_than" | "
|
|
18
|
+
method: "on" | "contains" | "equals" | "starts_with" | "ends_with" | "greater_than" | "less_than" | "between" | "before" | "after" | "oneOf" | "intersect" | "isEmpty" | "isNotEmpty" | "is_null" | "is_not_null";
|
|
19
19
|
value: string | number | boolean | string[];
|
|
20
20
|
valueTo?: string | undefined;
|
|
21
21
|
endColumnId?: string | undefined;
|
|
@@ -20,7 +20,7 @@ const deleteRecurrenceOutputSchema = zod_1.z.object({ id: zod_1.z.string() });
|
|
|
20
20
|
function createRecurrenceTRPC({ router, privateProcedure: procedure }, recurrenceService) {
|
|
21
21
|
return router({
|
|
22
22
|
list: procedure
|
|
23
|
-
.input(query_schema_1.querySchema.
|
|
23
|
+
.input(query_schema_1.querySchema.default({}))
|
|
24
24
|
.output(listRecurrenceOutputSchema)
|
|
25
25
|
.query(async ({ ctx, input }) => {
|
|
26
26
|
return (0, trpc_1.handleTRPCResult)(await recurrenceService.list(input, ctx));
|
|
@@ -122,34 +122,35 @@ class TagRepository extends base_repository_1.BaseTableRepository {
|
|
|
122
122
|
});
|
|
123
123
|
}
|
|
124
124
|
async listTaggings(input, tx) {
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
return (0, neverthrow_1.
|
|
136
|
-
|
|
125
|
+
const db = tx ?? this.orm;
|
|
126
|
+
const filters = [(0, drizzle_orm_1.eq)(this.schema.taggings.resourceType, input.resourceType)];
|
|
127
|
+
if (input.resourceIds?.length) {
|
|
128
|
+
filters.push((0, drizzle_orm_1.inArray)(this.schema.taggings.resourceId, input.resourceIds));
|
|
129
|
+
}
|
|
130
|
+
const rows = await this.throwableQuery(() => db
|
|
131
|
+
.select()
|
|
132
|
+
.from(this.schema.taggings)
|
|
133
|
+
.where((0, drizzle_orm_1.and)(...filters)));
|
|
134
|
+
if (rows.isErr())
|
|
135
|
+
return (0, neverthrow_1.err)(rows.error);
|
|
136
|
+
return (0, neverthrow_1.ok)(rows.value);
|
|
137
137
|
}
|
|
138
138
|
async list(input, tx) {
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
return (0, neverthrow_1.
|
|
152
|
-
|
|
139
|
+
const db = tx ?? this.orm;
|
|
140
|
+
const conditions = this.getConditionBuilder(this.table);
|
|
141
|
+
conditions.push((0, drizzle_orm_1.isNull)(this.table.deletedAt));
|
|
142
|
+
conditions.applyFilters(input);
|
|
143
|
+
if (input?.assignableTo) {
|
|
144
|
+
conditions.push(this.helpers.arrayContains(this.table.assignableTo, [input.assignableTo]));
|
|
145
|
+
}
|
|
146
|
+
const whereClause = conditions.join();
|
|
147
|
+
const rowsQuery = this.withSortingAndPagination(db.select().from(this.table).where(whereClause), input || {});
|
|
148
|
+
const countQuery = db.select({ count: (0, drizzle_orm_1.count)() }).from(this.table).where(whereClause);
|
|
149
|
+
const countResult = await this.throwableQuery(() => Promise.all([rowsQuery, countQuery]));
|
|
150
|
+
if (countResult.isErr())
|
|
151
|
+
return (0, neverthrow_1.err)(countResult.error);
|
|
152
|
+
const [rows, [totalResult]] = countResult.value;
|
|
153
|
+
return (0, neverthrow_1.ok)({ rows, total: totalResult?.count ?? 0 });
|
|
153
154
|
}
|
|
154
155
|
}
|
|
155
156
|
exports.TagRepository = TagRepository;
|
|
@@ -1,8 +1,6 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import type { User } from "../auth/auth.lib";
|
|
1
|
+
import type { TagDeleteSchema, TagLinkSchema, TagListInputSchema, TagListOutputSchema, TagListSchema, TagSchema } from "@m5kdev/commons/modules/tag/tag.schema";
|
|
3
2
|
import type { ServerResultAsync } from "../base/base.dto";
|
|
4
3
|
import { BaseService } from "../base/base.service";
|
|
5
|
-
import type { TaggingSelectOutputResult, TagSelectOutputResult } from "./tag.dto";
|
|
6
4
|
import type { TagRepository } from "./tag.repository";
|
|
7
5
|
export declare class TagService extends BaseService<{
|
|
8
6
|
tag: TagRepository;
|
|
@@ -18,20 +16,93 @@ export declare class TagService extends BaseService<{
|
|
|
18
16
|
resourceType: string;
|
|
19
17
|
resourceId: string;
|
|
20
18
|
}[]>>;
|
|
21
|
-
create
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
}
|
|
19
|
+
readonly create: import("../base/base.procedure").ServiceProcedure<{
|
|
20
|
+
name: string;
|
|
21
|
+
color: string;
|
|
22
|
+
assignableTo: string[];
|
|
23
|
+
organizationId?: string | undefined;
|
|
24
|
+
teamId?: string | undefined;
|
|
25
|
+
resourceType?: string | undefined;
|
|
26
|
+
resourceId?: string | undefined;
|
|
27
|
+
}, {
|
|
28
|
+
user?: import("../auth/auth.lib").User | null;
|
|
29
|
+
session?: import("../auth/auth.lib").Session | null;
|
|
30
|
+
} & Record<string, unknown> & import("../auth/auth.lib").Context, {
|
|
31
|
+
id: string;
|
|
32
|
+
createdAt: Date;
|
|
33
|
+
updatedAt: Date | null;
|
|
34
|
+
deletedAt: Date | null;
|
|
35
|
+
userId: string;
|
|
36
|
+
organizationId: string | null;
|
|
37
|
+
teamId: string | null;
|
|
38
|
+
name: string;
|
|
39
|
+
color: string | null;
|
|
40
|
+
type: string | null;
|
|
41
|
+
isEnabled: boolean;
|
|
42
|
+
parentId: string | null;
|
|
43
|
+
assignableTo: string[];
|
|
44
|
+
}>;
|
|
45
|
+
readonly update: import("../base/base.procedure").ServiceProcedure<{
|
|
46
|
+
id: string;
|
|
47
|
+
name?: string | undefined;
|
|
48
|
+
color?: string | undefined;
|
|
49
|
+
assignableTo?: string[] | undefined;
|
|
50
|
+
}, {
|
|
51
|
+
user?: import("../auth/auth.lib").User | null;
|
|
52
|
+
session?: import("../auth/auth.lib").Session | null;
|
|
53
|
+
} & Record<string, unknown> & import("../auth/auth.lib").Context, {
|
|
54
|
+
id: string;
|
|
55
|
+
createdAt: Date;
|
|
56
|
+
updatedAt: Date | null;
|
|
57
|
+
deletedAt: Date | null;
|
|
58
|
+
userId: string;
|
|
59
|
+
organizationId: string | null;
|
|
60
|
+
teamId: string | null;
|
|
61
|
+
name: string;
|
|
62
|
+
color: string | null;
|
|
63
|
+
type: string | null;
|
|
64
|
+
isEnabled: boolean;
|
|
65
|
+
parentId: string | null;
|
|
66
|
+
assignableTo: string[];
|
|
67
|
+
}>;
|
|
68
|
+
readonly link: import("../base/base.procedure").ServiceProcedure<{
|
|
69
|
+
tagId: string;
|
|
70
|
+
resourceType: string;
|
|
71
|
+
resourceId: string;
|
|
72
|
+
}, {
|
|
73
|
+
user?: import("../auth/auth.lib").User | null;
|
|
74
|
+
session?: import("../auth/auth.lib").Session | null;
|
|
75
|
+
} & Record<string, unknown> & import("../auth/auth.lib").Context, {
|
|
76
|
+
id: string;
|
|
77
|
+
createdAt: Date;
|
|
78
|
+
tagId: string;
|
|
79
|
+
resourceType: string;
|
|
80
|
+
resourceId: string;
|
|
81
|
+
}>;
|
|
30
82
|
linkBulk(data: TagLinkSchema[]): ServerResultAsync<TagSchema[]>;
|
|
31
83
|
set(data: TagLinkSchema[]): ServerResultAsync<TagSchema[]>;
|
|
32
|
-
unlink
|
|
33
|
-
|
|
34
|
-
|
|
84
|
+
readonly unlink: import("../base/base.procedure").ServiceProcedure<{
|
|
85
|
+
tagId: string;
|
|
86
|
+
resourceType: string;
|
|
87
|
+
resourceId: string;
|
|
88
|
+
}, {
|
|
89
|
+
user?: import("../auth/auth.lib").User | null;
|
|
90
|
+
session?: import("../auth/auth.lib").Session | null;
|
|
91
|
+
} & Record<string, unknown> & import("../auth/auth.lib").Context, {
|
|
92
|
+
id: string;
|
|
93
|
+
createdAt: Date;
|
|
94
|
+
updatedAt: Date | null;
|
|
95
|
+
deletedAt: Date | null;
|
|
96
|
+
userId: string;
|
|
97
|
+
organizationId: string | null;
|
|
98
|
+
teamId: string | null;
|
|
99
|
+
name: string;
|
|
100
|
+
color: string | null;
|
|
101
|
+
type: string | null;
|
|
102
|
+
isEnabled: boolean;
|
|
103
|
+
parentId: string | null;
|
|
104
|
+
assignableTo: string[];
|
|
105
|
+
}>;
|
|
35
106
|
delete(data: TagDeleteSchema): ServerResultAsync<{
|
|
36
107
|
id: string;
|
|
37
108
|
}>;
|
|
@@ -9,24 +9,32 @@ class TagService extends base_service_1.BaseService {
|
|
|
9
9
|
async listTaggings(input) {
|
|
10
10
|
return this.repository.tag.listTaggings(input);
|
|
11
11
|
}
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
12
|
+
create = this.procedure("create")
|
|
13
|
+
.requireAuth()
|
|
14
|
+
.handle(({ input, ctx }) => {
|
|
15
|
+
return this.repository.tag.create({ ...input, userId: ctx.user.id });
|
|
16
|
+
});
|
|
17
|
+
update = this.procedure("update")
|
|
18
|
+
.requireAuth()
|
|
19
|
+
.handle(({ input, ctx }) => {
|
|
20
|
+
return this.repository.tag.update({ ...input, userId: ctx.user.id });
|
|
21
|
+
});
|
|
22
|
+
link = this.procedure("link")
|
|
23
|
+
.requireAuth()
|
|
24
|
+
.handle(({ input, ctx }) => {
|
|
25
|
+
return this.repository.tag.link({ ...input, userId: ctx.user.id });
|
|
26
|
+
});
|
|
21
27
|
async linkBulk(data) {
|
|
22
28
|
return this.repository.tag.linkBulk(data);
|
|
23
29
|
}
|
|
24
30
|
async set(data) {
|
|
25
31
|
return this.repository.tag.set(data);
|
|
26
32
|
}
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
33
|
+
unlink = this.procedure("unlink")
|
|
34
|
+
.requireAuth()
|
|
35
|
+
.handle(({ input, ctx }) => {
|
|
36
|
+
return this.repository.tag.unlink({ ...input, userId: ctx.user.id });
|
|
37
|
+
});
|
|
30
38
|
async delete(data) {
|
|
31
39
|
return this.repository.tag.softDeleteById(data.id);
|
|
32
40
|
}
|
|
@@ -15,7 +15,7 @@ export declare function createTagTRPC({ router, privateProcedure: procedure }: T
|
|
|
15
15
|
filters?: {
|
|
16
16
|
columnId: string;
|
|
17
17
|
type: "string" | "number" | "boolean" | "date" | "enum";
|
|
18
|
-
method: "contains" | "equals" | "starts_with" | "ends_with" | "greater_than" | "less_than" | "
|
|
18
|
+
method: "on" | "contains" | "equals" | "starts_with" | "ends_with" | "greater_than" | "less_than" | "between" | "before" | "after" | "oneOf" | "intersect" | "isEmpty" | "isNotEmpty" | "is_null" | "is_not_null";
|
|
19
19
|
value: string | number | boolean | string[];
|
|
20
20
|
valueTo?: string | undefined;
|
|
21
21
|
endColumnId?: string | undefined;
|
|
@@ -48,7 +48,7 @@ export declare function createTagTRPC({ router, privateProcedure: procedure }: T
|
|
|
48
48
|
resourceIds?: {
|
|
49
49
|
columnId: string;
|
|
50
50
|
type: "string" | "number" | "boolean" | "date" | "enum";
|
|
51
|
-
method: "contains" | "equals" | "starts_with" | "ends_with" | "greater_than" | "less_than" | "
|
|
51
|
+
method: "on" | "contains" | "equals" | "starts_with" | "ends_with" | "greater_than" | "less_than" | "between" | "before" | "after" | "oneOf" | "intersect" | "isEmpty" | "isNotEmpty" | "is_null" | "is_not_null";
|
|
52
52
|
value: string | number | boolean | string[];
|
|
53
53
|
valueTo?: string | undefined;
|
|
54
54
|
endColumnId?: string | undefined;
|
package/dist/src/types.d.ts
CHANGED
|
@@ -58,10 +58,10 @@ export declare const createAuthTRPCRouter: <MastraInstance extends Mastra>(trpcM
|
|
|
58
58
|
input: void;
|
|
59
59
|
output: {
|
|
60
60
|
id: string;
|
|
61
|
-
status: string;
|
|
62
61
|
createdAt: Date;
|
|
63
62
|
updatedAt: Date | null;
|
|
64
63
|
expiresAt: Date | null;
|
|
64
|
+
status: string;
|
|
65
65
|
claimUserId: string | null;
|
|
66
66
|
claimedAt: Date | null;
|
|
67
67
|
claimedEmail: string | null;
|
|
@@ -76,11 +76,11 @@ export declare const createAuthTRPCRouter: <MastraInstance extends Mastra>(trpcM
|
|
|
76
76
|
output: {
|
|
77
77
|
id: string;
|
|
78
78
|
email: string;
|
|
79
|
-
url: string;
|
|
80
79
|
createdAt: Date;
|
|
81
|
-
userId: string;
|
|
82
80
|
expiresAt: Date | null;
|
|
81
|
+
userId: string;
|
|
83
82
|
claimId: string;
|
|
83
|
+
url: string;
|
|
84
84
|
};
|
|
85
85
|
meta: any;
|
|
86
86
|
}>;
|
|
@@ -91,11 +91,11 @@ export declare const createAuthTRPCRouter: <MastraInstance extends Mastra>(trpcM
|
|
|
91
91
|
output: {
|
|
92
92
|
id: string;
|
|
93
93
|
email: string;
|
|
94
|
-
url: string;
|
|
95
94
|
createdAt: Date;
|
|
96
|
-
userId: string;
|
|
97
95
|
expiresAt: Date | null;
|
|
96
|
+
userId: string;
|
|
98
97
|
claimId: string;
|
|
98
|
+
url: string;
|
|
99
99
|
}[];
|
|
100
100
|
meta: any;
|
|
101
101
|
}>;
|
|
@@ -148,11 +148,11 @@ export declare const createAuthTRPCRouter: <MastraInstance extends Mastra>(trpcM
|
|
|
148
148
|
input: void;
|
|
149
149
|
output: {
|
|
150
150
|
id: string;
|
|
151
|
-
email: string | null;
|
|
152
151
|
name: string | null;
|
|
153
|
-
|
|
152
|
+
email: string | null;
|
|
154
153
|
createdAt: Date;
|
|
155
154
|
updatedAt: Date | null;
|
|
155
|
+
status: string;
|
|
156
156
|
}[];
|
|
157
157
|
meta: any;
|
|
158
158
|
}>;
|
|
@@ -162,11 +162,11 @@ export declare const createAuthTRPCRouter: <MastraInstance extends Mastra>(trpcM
|
|
|
162
162
|
};
|
|
163
163
|
output: {
|
|
164
164
|
id: string;
|
|
165
|
-
email: string | null;
|
|
166
165
|
name: string | null;
|
|
167
|
-
|
|
166
|
+
email: string | null;
|
|
168
167
|
createdAt: Date;
|
|
169
168
|
updatedAt: Date | null;
|
|
169
|
+
status: string;
|
|
170
170
|
};
|
|
171
171
|
meta: any;
|
|
172
172
|
}>;
|
|
@@ -193,11 +193,11 @@ export declare const createAuthTRPCRouter: <MastraInstance extends Mastra>(trpcM
|
|
|
193
193
|
};
|
|
194
194
|
output: {
|
|
195
195
|
id: string;
|
|
196
|
-
email: string | null;
|
|
197
196
|
name: string | null;
|
|
198
|
-
|
|
197
|
+
email: string | null;
|
|
199
198
|
createdAt: Date;
|
|
200
199
|
updatedAt: Date | null;
|
|
200
|
+
status: string;
|
|
201
201
|
};
|
|
202
202
|
meta: any;
|
|
203
203
|
}>;
|
|
@@ -207,11 +207,11 @@ export declare const createAuthTRPCRouter: <MastraInstance extends Mastra>(trpcM
|
|
|
207
207
|
};
|
|
208
208
|
output: {
|
|
209
209
|
id: string;
|
|
210
|
-
email: string | null;
|
|
211
210
|
name: string | null;
|
|
212
|
-
|
|
211
|
+
email: string | null;
|
|
213
212
|
createdAt: Date;
|
|
214
213
|
updatedAt: Date | null;
|
|
214
|
+
status: string;
|
|
215
215
|
};
|
|
216
216
|
meta: any;
|
|
217
217
|
}>;
|
|
@@ -221,11 +221,11 @@ export declare const createAuthTRPCRouter: <MastraInstance extends Mastra>(trpcM
|
|
|
221
221
|
};
|
|
222
222
|
output: {
|
|
223
223
|
id: string;
|
|
224
|
-
email: string | null;
|
|
225
224
|
name: string | null;
|
|
226
|
-
|
|
225
|
+
email: string | null;
|
|
227
226
|
createdAt: Date;
|
|
228
227
|
updatedAt: Date | null;
|
|
228
|
+
status: string;
|
|
229
229
|
};
|
|
230
230
|
meta: any;
|
|
231
231
|
}>;
|
package/dist/src/utils/trpc.d.ts
CHANGED
|
@@ -18,11 +18,11 @@ export declare function createAuthContext(auth: BetterAuth): ({ req }: CreateExp
|
|
|
18
18
|
id: string;
|
|
19
19
|
createdAt: Date;
|
|
20
20
|
updatedAt: Date;
|
|
21
|
-
userId: string;
|
|
22
|
-
token: string;
|
|
23
21
|
expiresAt: Date;
|
|
22
|
+
token: string;
|
|
24
23
|
ipAddress: string | null;
|
|
25
24
|
userAgent: string | null;
|
|
25
|
+
userId: string;
|
|
26
26
|
impersonatedBy: string | null;
|
|
27
27
|
activeOrganizationId: string | null;
|
|
28
28
|
activeOrganizationRole: string | null;
|
|
@@ -31,9 +31,8 @@ export declare function createAuthContext(auth: BetterAuth): ({ req }: CreateExp
|
|
|
31
31
|
};
|
|
32
32
|
user: {
|
|
33
33
|
id: string;
|
|
34
|
-
email: string;
|
|
35
34
|
name: string;
|
|
36
|
-
|
|
35
|
+
email: string;
|
|
37
36
|
emailVerified: boolean;
|
|
38
37
|
image: string | null;
|
|
39
38
|
createdAt: Date;
|
|
@@ -47,6 +46,7 @@ export declare function createAuthContext(auth: BetterAuth): ({ req }: CreateExp
|
|
|
47
46
|
paymentPlanTier: string | null;
|
|
48
47
|
paymentPlanExpiresAt: Date | null;
|
|
49
48
|
preferences: string | null;
|
|
49
|
+
metadata: Record<string, unknown>;
|
|
50
50
|
onboarding: number | null;
|
|
51
51
|
flags: string | null;
|
|
52
52
|
};
|