@m5kdev/backend 0.4.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/ai/ai.prompts.d.ts +5 -0
- package/dist/src/modules/ai/ai.prompts.js +16 -0
- package/dist/src/modules/ai/ai.service.d.ts +26 -12
- package/dist/src/modules/ai/ai.service.js +105 -15
- package/dist/src/modules/auth/auth.dto.d.ts +2 -2
- package/dist/src/modules/auth/auth.lib.d.ts +3 -3
- package/dist/src/modules/auth/auth.repository.d.ts +2 -2
- package/dist/src/modules/auth/auth.repository.js +1 -1
- package/dist/src/modules/auth/auth.service.d.ts +3 -3
- package/dist/src/modules/auth/auth.service.js +1 -1
- package/dist/src/modules/auth/auth.trpc.d.ts +6 -6
- package/dist/src/modules/auth/auth.trpc.js +1 -1
- 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 +4 -4
- 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 +3 -3
- package/dist/src/modules/recurrence/recurrence.trpc.js +1 -1
- package/dist/src/modules/tag/tag.db.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 +3 -3
- package/dist/src/types.d.ts +5 -5
- package/dist/src/utils/trpc.d.ts +6 -6
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +6 -5
|
@@ -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
|
}
|
|
@@ -11,11 +11,11 @@ export declare function createTagTRPC({ router, privateProcedure: procedure }: T
|
|
|
11
11
|
page?: number | undefined;
|
|
12
12
|
limit?: number | undefined;
|
|
13
13
|
sort?: string | undefined;
|
|
14
|
-
order?: "
|
|
14
|
+
order?: "asc" | "desc" | undefined;
|
|
15
15
|
filters?: {
|
|
16
16
|
columnId: string;
|
|
17
17
|
type: "string" | "number" | "boolean" | "date" | "enum";
|
|
18
|
-
method: "
|
|
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: "
|
|
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
|
@@ -147,8 +147,8 @@ export declare const createAuthTRPCRouter: <MastraInstance extends Mastra>(trpcM
|
|
|
147
147
|
listAdminWaitlist: import("@trpc/server").TRPCQueryProcedure<{
|
|
148
148
|
input: void;
|
|
149
149
|
output: {
|
|
150
|
-
name: string | null;
|
|
151
150
|
id: string;
|
|
151
|
+
name: string | null;
|
|
152
152
|
email: string | null;
|
|
153
153
|
createdAt: Date;
|
|
154
154
|
updatedAt: Date | null;
|
|
@@ -161,8 +161,8 @@ export declare const createAuthTRPCRouter: <MastraInstance extends Mastra>(trpcM
|
|
|
161
161
|
email: string;
|
|
162
162
|
};
|
|
163
163
|
output: {
|
|
164
|
-
name: string | null;
|
|
165
164
|
id: string;
|
|
165
|
+
name: string | null;
|
|
166
166
|
email: string | null;
|
|
167
167
|
createdAt: Date;
|
|
168
168
|
updatedAt: Date | null;
|
|
@@ -192,8 +192,8 @@ export declare const createAuthTRPCRouter: <MastraInstance extends Mastra>(trpcM
|
|
|
192
192
|
id: string;
|
|
193
193
|
};
|
|
194
194
|
output: {
|
|
195
|
-
name: string | null;
|
|
196
195
|
id: string;
|
|
196
|
+
name: string | null;
|
|
197
197
|
email: string | null;
|
|
198
198
|
createdAt: Date;
|
|
199
199
|
updatedAt: Date | null;
|
|
@@ -206,8 +206,8 @@ export declare const createAuthTRPCRouter: <MastraInstance extends Mastra>(trpcM
|
|
|
206
206
|
id: string;
|
|
207
207
|
};
|
|
208
208
|
output: {
|
|
209
|
-
name: string | null;
|
|
210
209
|
id: string;
|
|
210
|
+
name: string | null;
|
|
211
211
|
email: string | null;
|
|
212
212
|
createdAt: Date;
|
|
213
213
|
updatedAt: Date | null;
|
|
@@ -220,8 +220,8 @@ export declare const createAuthTRPCRouter: <MastraInstance extends Mastra>(trpcM
|
|
|
220
220
|
email: string;
|
|
221
221
|
};
|
|
222
222
|
output: {
|
|
223
|
-
name: string | null;
|
|
224
223
|
id: string;
|
|
224
|
+
name: string | null;
|
|
225
225
|
email: string | null;
|
|
226
226
|
createdAt: Date;
|
|
227
227
|
updatedAt: Date | null;
|
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
21
|
expiresAt: Date;
|
|
23
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;
|
|
@@ -30,15 +30,14 @@ export declare function createAuthContext(auth: BetterAuth): ({ req }: CreateExp
|
|
|
30
30
|
activeTeamRole: string | null;
|
|
31
31
|
};
|
|
32
32
|
user: {
|
|
33
|
-
|
|
33
|
+
id: string;
|
|
34
34
|
name: string;
|
|
35
|
-
|
|
35
|
+
email: string;
|
|
36
|
+
emailVerified: boolean;
|
|
36
37
|
image: string | null;
|
|
37
|
-
metadata: Record<string, unknown>;
|
|
38
|
-
id: string;
|
|
39
38
|
createdAt: Date;
|
|
40
39
|
updatedAt: Date;
|
|
41
|
-
|
|
40
|
+
role: string | null;
|
|
42
41
|
banned: boolean | null;
|
|
43
42
|
banReason: string | null;
|
|
44
43
|
banExpires: Date | null;
|
|
@@ -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
|
};
|