@m5kdev/backend 0.1.0 → 0.1.2
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/.cursor/rules/backend.mdc +70 -0
- package/.turbo/turbo-build.log +5 -0
- package/.turbo/turbo-check-types.log +5 -0
- package/.turbo/turbo-lint$colon$fix.log +255 -0
- package/CHANGELOG.md +19 -0
- package/dist/src/lib/posthog.d.ts +3 -0
- package/dist/src/lib/posthog.d.ts.map +1 -0
- package/dist/src/lib/posthog.js +7 -0
- package/dist/src/lib/sentry.d.ts +2 -0
- package/dist/src/lib/sentry.d.ts.map +1 -0
- package/dist/src/lib/sentry.js +9 -0
- package/dist/src/modules/access/access.repository.d.ts +2348 -0
- package/dist/src/modules/access/access.repository.d.ts.map +1 -0
- package/dist/src/modules/access/access.repository.js +32 -0
- package/dist/src/modules/access/access.service.d.ts +22 -0
- package/dist/src/modules/access/access.service.d.ts.map +1 -0
- package/dist/src/modules/access/access.service.js +51 -0
- package/dist/src/modules/access/access.test.d.ts +2 -0
- package/dist/src/modules/access/access.test.d.ts.map +1 -0
- package/dist/src/modules/access/access.test.js +182 -0
- package/dist/src/modules/access/access.utils.d.ts +17 -0
- package/dist/src/modules/access/access.utils.d.ts.map +1 -0
- package/dist/src/modules/access/access.utils.js +20 -0
- package/dist/src/modules/ai/ai.db.d.ts +396 -0
- package/dist/src/modules/ai/ai.db.d.ts.map +1 -0
- package/dist/src/modules/ai/ai.db.js +39 -0
- package/dist/src/modules/ai/ai.prompt.d.ts +28 -0
- package/dist/src/modules/ai/ai.prompt.d.ts.map +1 -0
- package/dist/src/modules/ai/ai.prompt.js +30 -0
- package/dist/src/modules/ai/ai.repository.d.ts +424 -0
- package/dist/src/modules/ai/ai.repository.d.ts.map +1 -0
- package/dist/src/modules/ai/ai.repository.js +26 -0
- package/dist/src/modules/ai/ai.router.d.ts +2 -0
- package/dist/src/modules/ai/ai.router.d.ts.map +1 -0
- package/dist/src/modules/ai/ai.router.js +132 -0
- package/dist/src/modules/ai/ai.service.d.ts +115 -0
- package/dist/src/modules/ai/ai.service.d.ts.map +1 -0
- package/dist/src/modules/ai/ai.service.js +207 -0
- package/dist/src/modules/ai/ai.trpc.d.ts +59 -0
- package/dist/src/modules/ai/ai.trpc.d.ts.map +1 -0
- package/dist/src/modules/ai/ai.trpc.js +20 -0
- package/dist/src/modules/ai/ideogram/ideogram.constants.d.ts +8 -0
- package/dist/src/modules/ai/ideogram/ideogram.constants.d.ts.map +1 -0
- package/dist/src/modules/ai/ideogram/ideogram.constants.js +167 -0
- package/dist/src/modules/ai/ideogram/ideogram.dto.d.ts +230 -0
- package/dist/src/modules/ai/ideogram/ideogram.dto.d.ts.map +1 -0
- package/dist/src/modules/ai/ideogram/ideogram.dto.js +49 -0
- package/dist/src/modules/ai/ideogram/ideogram.prompt.d.ts +3 -0
- package/dist/src/modules/ai/ideogram/ideogram.prompt.d.ts.map +1 -0
- package/dist/src/modules/ai/ideogram/ideogram.prompt.js +860 -0
- package/dist/src/modules/ai/ideogram/ideogram.repository.d.ts +7 -0
- package/dist/src/modules/ai/ideogram/ideogram.repository.d.ts.map +1 -0
- package/dist/src/modules/ai/ideogram/ideogram.repository.js +46 -0
- package/dist/src/modules/ai/ideogram/ideogram.service.d.ts +10 -0
- package/dist/src/modules/ai/ideogram/ideogram.service.d.ts.map +1 -0
- package/dist/src/modules/ai/ideogram/ideogram.service.js +11 -0
- package/dist/src/modules/auth/auth.db.d.ts +2336 -0
- package/dist/src/modules/auth/auth.db.d.ts.map +1 -0
- package/dist/src/modules/auth/auth.db.js +215 -0
- package/dist/src/modules/auth/auth.dto.d.ts +66 -0
- package/dist/src/modules/auth/auth.dto.d.ts.map +1 -0
- package/dist/src/modules/auth/auth.dto.js +38 -0
- package/dist/src/modules/auth/auth.lib.d.ts +4874 -0
- package/dist/src/modules/auth/auth.lib.d.ts.map +1 -0
- package/dist/src/modules/auth/auth.lib.js +284 -0
- package/dist/src/modules/auth/auth.middleware.d.ts +615 -0
- package/dist/src/modules/auth/auth.middleware.d.ts.map +1 -0
- package/dist/src/modules/auth/auth.middleware.js +52 -0
- package/dist/src/modules/auth/auth.repository.d.ts +2417 -0
- package/dist/src/modules/auth/auth.repository.d.ts.map +1 -0
- package/dist/src/modules/auth/auth.repository.js +541 -0
- package/dist/src/modules/auth/auth.service.d.ts +104 -0
- package/dist/src/modules/auth/auth.service.d.ts.map +1 -0
- package/dist/src/modules/auth/auth.service.js +201 -0
- package/dist/src/modules/auth/auth.trpc.d.ts +309 -0
- package/dist/src/modules/auth/auth.trpc.d.ts.map +1 -0
- package/dist/src/modules/auth/auth.trpc.js +157 -0
- package/dist/src/modules/auth/auth.utils.d.ts +2352 -0
- package/dist/src/modules/auth/auth.utils.d.ts.map +1 -0
- package/dist/src/modules/auth/auth.utils.js +97 -0
- package/dist/src/modules/base/base.abstract.d.ts +19 -0
- package/dist/src/modules/base/base.abstract.d.ts.map +1 -0
- package/dist/src/modules/base/base.abstract.js +53 -0
- package/dist/src/modules/base/base.dto.d.ts +70 -0
- package/dist/src/modules/base/base.dto.d.ts.map +1 -0
- package/dist/src/modules/base/base.dto.js +112 -0
- package/dist/src/modules/base/base.grants.d.ts +29 -0
- package/dist/src/modules/base/base.grants.d.ts.map +1 -0
- package/dist/src/modules/base/base.grants.js +123 -0
- package/dist/src/modules/base/base.grants.test.d.ts +2 -0
- package/dist/src/modules/base/base.grants.test.d.ts.map +1 -0
- package/dist/src/modules/base/base.grants.test.js +668 -0
- package/dist/src/modules/base/base.repository.d.ts +97 -0
- package/dist/src/modules/base/base.repository.d.ts.map +1 -0
- package/dist/src/modules/base/base.repository.js +307 -0
- package/dist/src/modules/base/base.service.d.ts +42 -0
- package/dist/src/modules/base/base.service.d.ts.map +1 -0
- package/dist/src/modules/base/base.service.js +109 -0
- package/dist/src/modules/base/base.types.d.ts +2 -0
- package/dist/src/modules/base/base.types.d.ts.map +1 -0
- package/dist/src/modules/base/base.types.js +2 -0
- package/dist/src/modules/billing/billing.db.d.ts +366 -0
- package/dist/src/modules/billing/billing.db.d.ts.map +1 -0
- package/dist/src/modules/billing/billing.db.js +29 -0
- package/dist/src/modules/billing/billing.repository.d.ts +2764 -0
- package/dist/src/modules/billing/billing.repository.d.ts.map +1 -0
- package/dist/src/modules/billing/billing.repository.js +235 -0
- package/dist/src/modules/billing/billing.router.d.ts +5 -0
- package/dist/src/modules/billing/billing.router.d.ts.map +1 -0
- package/dist/src/modules/billing/billing.router.js +56 -0
- package/dist/src/modules/billing/billing.service.d.ts +60 -0
- package/dist/src/modules/billing/billing.service.d.ts.map +1 -0
- package/dist/src/modules/billing/billing.service.js +147 -0
- package/dist/src/modules/billing/billing.trpc.d.ts +75 -0
- package/dist/src/modules/billing/billing.trpc.d.ts.map +1 -0
- package/dist/src/modules/billing/billing.trpc.js +17 -0
- package/dist/src/modules/clay/clay.repository.d.ts +6 -0
- package/dist/src/modules/clay/clay.repository.d.ts.map +1 -0
- package/dist/src/modules/clay/clay.repository.js +26 -0
- package/dist/src/modules/clay/clay.service.d.ts +29 -0
- package/dist/src/modules/clay/clay.service.d.ts.map +1 -0
- package/dist/src/modules/clay/clay.service.js +24 -0
- package/dist/src/modules/connect/connect.db.d.ts +357 -0
- package/dist/src/modules/connect/connect.db.d.ts.map +1 -0
- package/dist/src/modules/connect/connect.db.js +30 -0
- package/dist/src/modules/connect/connect.dto.d.ts +75 -0
- package/dist/src/modules/connect/connect.dto.d.ts.map +1 -0
- package/dist/src/modules/connect/connect.dto.js +36 -0
- package/dist/src/modules/connect/connect.linkedin.d.ts +3 -0
- package/dist/src/modules/connect/connect.linkedin.d.ts.map +1 -0
- package/dist/src/modules/connect/connect.linkedin.js +53 -0
- package/dist/src/modules/connect/connect.oauth.d.ts +28 -0
- package/dist/src/modules/connect/connect.oauth.d.ts.map +1 -0
- package/dist/src/modules/connect/connect.oauth.js +198 -0
- package/dist/src/modules/connect/connect.repository.d.ts +414 -0
- package/dist/src/modules/connect/connect.repository.d.ts.map +1 -0
- package/dist/src/modules/connect/connect.repository.js +54 -0
- package/dist/src/modules/connect/connect.router.d.ts +5 -0
- package/dist/src/modules/connect/connect.router.d.ts.map +1 -0
- package/dist/src/modules/connect/connect.router.js +54 -0
- package/dist/src/modules/connect/connect.service.d.ts +89 -0
- package/dist/src/modules/connect/connect.service.d.ts.map +1 -0
- package/dist/src/modules/connect/connect.service.js +114 -0
- package/dist/src/modules/connect/connect.trpc.d.ts +81 -0
- package/dist/src/modules/connect/connect.trpc.d.ts.map +1 -0
- package/dist/src/modules/connect/connect.trpc.js +21 -0
- package/dist/src/modules/connect/connect.types.d.ts +26 -0
- package/dist/src/modules/connect/connect.types.d.ts.map +1 -0
- package/dist/src/modules/connect/connect.types.js +2 -0
- package/dist/src/modules/crypto/crypto.db.d.ts +152 -0
- package/dist/src/modules/crypto/crypto.db.d.ts.map +1 -0
- package/dist/src/modules/crypto/crypto.db.js +17 -0
- package/dist/src/modules/crypto/crypto.repository.d.ts +160 -0
- package/dist/src/modules/crypto/crypto.repository.d.ts.map +1 -0
- package/dist/src/modules/crypto/crypto.repository.js +10 -0
- package/dist/src/modules/crypto/crypto.service.d.ts +11 -0
- package/dist/src/modules/crypto/crypto.service.d.ts.map +1 -0
- package/dist/src/modules/crypto/crypto.service.js +52 -0
- package/dist/src/modules/email/email.service.d.ts +57 -0
- package/dist/src/modules/email/email.service.d.ts.map +1 -0
- package/dist/src/modules/email/email.service.js +107 -0
- package/dist/src/modules/file/file.repository.d.ts +13 -0
- package/dist/src/modules/file/file.repository.d.ts.map +1 -0
- package/dist/src/modules/file/file.repository.js +79 -0
- package/dist/src/modules/file/file.router.d.ts +4 -0
- package/dist/src/modules/file/file.router.d.ts.map +1 -0
- package/dist/src/modules/file/file.router.js +99 -0
- package/dist/src/modules/file/file.service.d.ts +25 -0
- package/dist/src/modules/file/file.service.d.ts.map +1 -0
- package/dist/src/modules/file/file.service.js +150 -0
- package/dist/src/modules/recurrence/recurrence.db.d.ts +563 -0
- package/dist/src/modules/recurrence/recurrence.db.d.ts.map +1 -0
- package/dist/src/modules/recurrence/recurrence.db.js +66 -0
- package/dist/src/modules/recurrence/recurrence.repository.d.ts +585 -0
- package/dist/src/modules/recurrence/recurrence.repository.d.ts.map +1 -0
- package/dist/src/modules/recurrence/recurrence.repository.js +39 -0
- package/dist/src/modules/recurrence/recurrence.service.d.ts +30 -0
- package/dist/src/modules/recurrence/recurrence.service.d.ts.map +1 -0
- package/dist/src/modules/recurrence/recurrence.service.js +70 -0
- package/dist/src/modules/recurrence/recurrence.trpc.d.ts +243 -0
- package/dist/src/modules/recurrence/recurrence.trpc.d.ts.map +1 -0
- package/dist/src/modules/recurrence/recurrence.trpc.js +65 -0
- package/dist/src/modules/social/social.dto.d.ts +35 -0
- package/dist/src/modules/social/social.dto.d.ts.map +1 -0
- package/dist/src/modules/social/social.dto.js +18 -0
- package/dist/src/modules/social/social.linkedin.d.ts +11 -0
- package/dist/src/modules/social/social.linkedin.d.ts.map +1 -0
- package/dist/src/modules/social/social.linkedin.js +427 -0
- package/dist/src/modules/social/social.linkedin.test.d.ts +2 -0
- package/dist/src/modules/social/social.linkedin.test.d.ts.map +1 -0
- package/dist/src/modules/social/social.linkedin.test.js +235 -0
- package/dist/src/modules/social/social.service.d.ts +29 -0
- package/dist/src/modules/social/social.service.d.ts.map +1 -0
- package/dist/src/modules/social/social.service.js +76 -0
- package/dist/src/modules/social/social.types.d.ts +36 -0
- package/dist/src/modules/social/social.types.d.ts.map +1 -0
- package/dist/src/modules/social/social.types.js +2 -0
- package/dist/src/modules/tag/tag.db.d.ts +347 -0
- package/dist/src/modules/tag/tag.db.d.ts.map +1 -0
- package/dist/src/modules/tag/tag.db.js +42 -0
- package/dist/src/modules/tag/tag.dto.d.ts +1019 -0
- package/dist/src/modules/tag/tag.dto.d.ts.map +1 -0
- package/dist/src/modules/tag/tag.dto.js +9 -0
- package/dist/src/modules/tag/tag.repository.d.ts +384 -0
- package/dist/src/modules/tag/tag.repository.d.ts.map +1 -0
- package/dist/src/modules/tag/tag.repository.js +154 -0
- package/dist/src/modules/tag/tag.service.d.ts +36 -0
- package/dist/src/modules/tag/tag.service.d.ts.map +1 -0
- package/dist/src/modules/tag/tag.service.js +31 -0
- package/dist/src/modules/tag/tag.trpc.d.ts +191 -0
- package/dist/src/modules/tag/tag.trpc.d.ts.map +1 -0
- package/dist/src/modules/tag/tag.trpc.js +47 -0
- package/dist/src/modules/utils/applyPagination.d.ts +7 -0
- package/dist/src/modules/utils/applyPagination.d.ts.map +1 -0
- package/dist/src/modules/utils/applyPagination.js +16 -0
- package/dist/src/modules/utils/applySorting.d.ts +9 -0
- package/dist/src/modules/utils/applySorting.d.ts.map +1 -0
- package/dist/src/modules/utils/applySorting.js +18 -0
- package/dist/src/modules/utils/getConditionsFromFilters.d.ts +5 -0
- package/dist/src/modules/utils/getConditionsFromFilters.d.ts.map +1 -0
- package/dist/src/modules/utils/getConditionsFromFilters.js +200 -0
- package/dist/src/modules/video/video.service.d.ts +8 -0
- package/dist/src/modules/video/video.service.d.ts.map +1 -0
- package/dist/src/modules/video/video.service.js +84 -0
- package/dist/src/modules/webhook/webhook.constants.d.ts +9 -0
- package/dist/src/modules/webhook/webhook.constants.d.ts.map +1 -0
- package/dist/src/modules/webhook/webhook.constants.js +10 -0
- package/dist/src/modules/webhook/webhook.db.d.ts +137 -0
- package/dist/src/modules/webhook/webhook.db.d.ts.map +1 -0
- package/dist/src/modules/webhook/webhook.db.js +17 -0
- package/dist/src/modules/webhook/webhook.dto.d.ts +395 -0
- package/dist/src/modules/webhook/webhook.dto.d.ts.map +1 -0
- package/dist/src/modules/webhook/webhook.dto.js +7 -0
- package/dist/src/modules/webhook/webhook.repository.d.ts +149 -0
- package/dist/src/modules/webhook/webhook.repository.d.ts.map +1 -0
- package/dist/src/modules/webhook/webhook.repository.js +56 -0
- package/dist/src/modules/webhook/webhook.router.d.ts +4 -0
- package/dist/src/modules/webhook/webhook.router.d.ts.map +1 -0
- package/dist/src/modules/webhook/webhook.router.js +30 -0
- package/dist/src/modules/webhook/webhook.service.d.ts +10 -0
- package/dist/src/modules/webhook/webhook.service.d.ts.map +1 -0
- package/dist/src/modules/webhook/webhook.service.js +68 -0
- package/dist/src/modules/workflow/workflow.db.d.ts +297 -0
- package/dist/src/modules/workflow/workflow.db.d.ts.map +1 -0
- package/dist/src/modules/workflow/workflow.db.js +30 -0
- package/dist/src/modules/workflow/workflow.repository.d.ts +344 -0
- package/dist/src/modules/workflow/workflow.repository.d.ts.map +1 -0
- package/dist/src/modules/workflow/workflow.repository.js +105 -0
- package/dist/src/modules/workflow/workflow.service.d.ts +22 -0
- package/dist/src/modules/workflow/workflow.service.d.ts.map +1 -0
- package/dist/src/modules/workflow/workflow.service.js +37 -0
- package/dist/src/modules/workflow/workflow.trpc.d.ts +93 -0
- package/dist/src/modules/workflow/workflow.trpc.d.ts.map +1 -0
- package/dist/src/modules/workflow/workflow.trpc.js +21 -0
- package/dist/src/modules/workflow/workflow.types.d.ts +21 -0
- package/dist/src/modules/workflow/workflow.types.d.ts.map +1 -0
- package/dist/src/modules/workflow/workflow.types.js +2 -0
- package/dist/src/modules/workflow/workflow.utils.d.ts +22 -0
- package/dist/src/modules/workflow/workflow.utils.d.ts.map +1 -0
- package/dist/src/modules/workflow/workflow.utils.js +173 -0
- package/dist/src/test/stubs/utils.d.ts +3 -0
- package/dist/src/test/stubs/utils.d.ts.map +1 -0
- package/dist/src/test/stubs/utils.js +5 -0
- package/dist/src/trpc/context.d.ts +42 -0
- package/dist/src/trpc/context.d.ts.map +1 -0
- package/dist/src/trpc/context.js +17 -0
- package/dist/src/trpc/index.d.ts +4 -0
- package/dist/src/trpc/index.d.ts.map +1 -0
- package/dist/src/trpc/index.js +6 -0
- package/dist/src/trpc/procedures.d.ts +234 -0
- package/dist/src/trpc/procedures.d.ts.map +1 -0
- package/dist/src/trpc/procedures.js +32 -0
- package/dist/src/trpc/utils.d.ts +5 -0
- package/dist/src/trpc/utils.d.ts.map +1 -0
- package/dist/src/trpc/utils.js +20 -0
- package/dist/src/types.d.ts +486 -0
- package/dist/src/types.d.ts.map +1 -0
- package/dist/src/types.js +13 -0
- package/dist/src/utils/errors.d.ts +50 -0
- package/dist/src/utils/errors.d.ts.map +1 -0
- package/dist/src/utils/errors.js +104 -0
- package/dist/src/utils/logger.d.ts +2 -0
- package/dist/src/utils/logger.d.ts.map +1 -0
- package/dist/src/utils/logger.js +11 -0
- package/dist/src/utils/posthog.d.ts +14 -0
- package/dist/src/utils/posthog.d.ts.map +1 -0
- package/dist/src/utils/posthog.js +31 -0
- package/dist/src/utils/types.d.ts +5 -0
- package/dist/src/utils/types.d.ts.map +1 -0
- package/dist/src/utils/types.js +2 -0
- package/dist/tsconfig.tsbuildinfo +1 -0
- package/jest.config.ts +19 -0
- package/package.json +3 -6
- package/tsconfig.json +21 -0
|
@@ -0,0 +1,191 @@
|
|
|
1
|
+
import type { TagService } from "#modules/tag/tag.service";
|
|
2
|
+
export declare function createTagTRPC(tagService: TagService): import("@trpc/server").TRPCBuiltRouter<{
|
|
3
|
+
ctx: {
|
|
4
|
+
session: {
|
|
5
|
+
id: string;
|
|
6
|
+
userId: string;
|
|
7
|
+
updatedAt: Date;
|
|
8
|
+
createdAt: Date;
|
|
9
|
+
expiresAt: Date;
|
|
10
|
+
token: string;
|
|
11
|
+
ipAddress: string | null;
|
|
12
|
+
userAgent: string | null;
|
|
13
|
+
impersonatedBy: string | null;
|
|
14
|
+
activeOrganizationId: string | null;
|
|
15
|
+
activeOrganizationRole: string | null;
|
|
16
|
+
activeTeamId: string | null;
|
|
17
|
+
activeTeamRole: string | null;
|
|
18
|
+
};
|
|
19
|
+
user: {
|
|
20
|
+
name: string;
|
|
21
|
+
id: string;
|
|
22
|
+
updatedAt: Date;
|
|
23
|
+
email: string;
|
|
24
|
+
emailVerified: boolean;
|
|
25
|
+
image: string | null;
|
|
26
|
+
createdAt: Date;
|
|
27
|
+
role: string | null;
|
|
28
|
+
banned: boolean | null;
|
|
29
|
+
banReason: string | null;
|
|
30
|
+
banExpires: Date | null;
|
|
31
|
+
stripeCustomerId: string | null;
|
|
32
|
+
paymentCustomerId: string | null;
|
|
33
|
+
paymentPlanTier: string | null;
|
|
34
|
+
paymentPlanExpiresAt: Date | null;
|
|
35
|
+
preferences: string | null;
|
|
36
|
+
metadata: Record<string, unknown>;
|
|
37
|
+
onboarding: number | null;
|
|
38
|
+
flags: string | null;
|
|
39
|
+
};
|
|
40
|
+
};
|
|
41
|
+
meta: import("trpc-to-openapi").OpenApiMeta;
|
|
42
|
+
errorShape: import("@trpc/server").TRPCDefaultErrorShape;
|
|
43
|
+
transformer: true;
|
|
44
|
+
}, import("@trpc/server").TRPCDecorateCreateRouterOptions<{
|
|
45
|
+
list: import("@trpc/server").TRPCQueryProcedure<{
|
|
46
|
+
input: {
|
|
47
|
+
page?: number | undefined;
|
|
48
|
+
limit?: number | undefined;
|
|
49
|
+
sort?: string | undefined;
|
|
50
|
+
order?: "asc" | "desc" | undefined;
|
|
51
|
+
filters?: {
|
|
52
|
+
columnId: string;
|
|
53
|
+
type: "string" | "number" | "boolean" | "date" | "enum";
|
|
54
|
+
method: "contains" | "equals" | "starts_with" | "ends_with" | "greater_than" | "less_than" | "on" | "between" | "before" | "after" | "oneOf" | "intersect" | "isEmpty" | "isNotEmpty" | "is_null" | "is_not_null";
|
|
55
|
+
value: string | number | boolean | string[];
|
|
56
|
+
valueTo?: string | undefined;
|
|
57
|
+
endColumnId?: string | undefined;
|
|
58
|
+
}[] | undefined;
|
|
59
|
+
assignableTo?: string | undefined;
|
|
60
|
+
};
|
|
61
|
+
output: {
|
|
62
|
+
rows: {
|
|
63
|
+
id: string;
|
|
64
|
+
createdAt: Date;
|
|
65
|
+
userId: string;
|
|
66
|
+
name: string;
|
|
67
|
+
isEnabled: boolean;
|
|
68
|
+
assignableTo: string[] | null;
|
|
69
|
+
organizationId?: string | null | undefined;
|
|
70
|
+
teamId?: string | null | undefined;
|
|
71
|
+
updatedAt?: Date | null | undefined;
|
|
72
|
+
deletedAt?: Date | null | undefined;
|
|
73
|
+
color?: string | null | undefined;
|
|
74
|
+
type?: string | null | undefined;
|
|
75
|
+
parentId?: string | null | undefined;
|
|
76
|
+
}[];
|
|
77
|
+
total: number;
|
|
78
|
+
};
|
|
79
|
+
meta: import("trpc-to-openapi").OpenApiMeta;
|
|
80
|
+
}>;
|
|
81
|
+
listTaggings: import("@trpc/server").TRPCQueryProcedure<{
|
|
82
|
+
input: {
|
|
83
|
+
resourceType: string;
|
|
84
|
+
resourceIds?: {
|
|
85
|
+
columnId: string;
|
|
86
|
+
type: "string" | "number" | "boolean" | "date" | "enum";
|
|
87
|
+
method: "contains" | "equals" | "starts_with" | "ends_with" | "greater_than" | "less_than" | "on" | "between" | "before" | "after" | "oneOf" | "intersect" | "isEmpty" | "isNotEmpty" | "is_null" | "is_not_null";
|
|
88
|
+
value: string | number | boolean | string[];
|
|
89
|
+
valueTo?: string | undefined;
|
|
90
|
+
endColumnId?: string | undefined;
|
|
91
|
+
}[] | undefined;
|
|
92
|
+
};
|
|
93
|
+
output: {
|
|
94
|
+
id: string;
|
|
95
|
+
createdAt: Date;
|
|
96
|
+
tagId: string;
|
|
97
|
+
resourceType: string;
|
|
98
|
+
resourceId: string;
|
|
99
|
+
}[];
|
|
100
|
+
meta: import("trpc-to-openapi").OpenApiMeta;
|
|
101
|
+
}>;
|
|
102
|
+
create: import("@trpc/server").TRPCMutationProcedure<{
|
|
103
|
+
input: {
|
|
104
|
+
name: string;
|
|
105
|
+
color: string;
|
|
106
|
+
organizationId?: string | undefined;
|
|
107
|
+
teamId?: string | undefined;
|
|
108
|
+
assignableTo?: string[] | undefined;
|
|
109
|
+
resourceType?: string | undefined;
|
|
110
|
+
resourceId?: string | undefined;
|
|
111
|
+
};
|
|
112
|
+
output: {
|
|
113
|
+
id: string;
|
|
114
|
+
createdAt: Date;
|
|
115
|
+
updatedAt: Date | null;
|
|
116
|
+
deletedAt: Date | null;
|
|
117
|
+
userId: string;
|
|
118
|
+
organizationId: string | null;
|
|
119
|
+
teamId: string | null;
|
|
120
|
+
name: string;
|
|
121
|
+
color: string | null;
|
|
122
|
+
type: string | null;
|
|
123
|
+
isEnabled: boolean;
|
|
124
|
+
parentId: string | null;
|
|
125
|
+
assignableTo: string[];
|
|
126
|
+
};
|
|
127
|
+
meta: import("trpc-to-openapi").OpenApiMeta;
|
|
128
|
+
}>;
|
|
129
|
+
update: import("@trpc/server").TRPCMutationProcedure<{
|
|
130
|
+
input: {
|
|
131
|
+
id: string;
|
|
132
|
+
name?: string | undefined;
|
|
133
|
+
color?: string | undefined;
|
|
134
|
+
};
|
|
135
|
+
output: {
|
|
136
|
+
id: string;
|
|
137
|
+
createdAt: Date;
|
|
138
|
+
updatedAt: Date | null;
|
|
139
|
+
deletedAt: Date | null;
|
|
140
|
+
userId: string;
|
|
141
|
+
organizationId: string | null;
|
|
142
|
+
teamId: string | null;
|
|
143
|
+
name: string;
|
|
144
|
+
color: string | null;
|
|
145
|
+
type: string | null;
|
|
146
|
+
isEnabled: boolean;
|
|
147
|
+
parentId: string | null;
|
|
148
|
+
assignableTo: string[];
|
|
149
|
+
};
|
|
150
|
+
meta: import("trpc-to-openapi").OpenApiMeta;
|
|
151
|
+
}>;
|
|
152
|
+
link: import("@trpc/server").TRPCMutationProcedure<{
|
|
153
|
+
input: {
|
|
154
|
+
tagId: string;
|
|
155
|
+
resourceType: string;
|
|
156
|
+
resourceId: string;
|
|
157
|
+
};
|
|
158
|
+
output: {
|
|
159
|
+
id: string;
|
|
160
|
+
createdAt: Date;
|
|
161
|
+
tagId: string;
|
|
162
|
+
resourceType: string;
|
|
163
|
+
resourceId: string;
|
|
164
|
+
};
|
|
165
|
+
meta: import("trpc-to-openapi").OpenApiMeta;
|
|
166
|
+
}>;
|
|
167
|
+
unlink: import("@trpc/server").TRPCMutationProcedure<{
|
|
168
|
+
input: {
|
|
169
|
+
tagId: string;
|
|
170
|
+
resourceType: string;
|
|
171
|
+
resourceId: string;
|
|
172
|
+
};
|
|
173
|
+
output: {
|
|
174
|
+
id: string;
|
|
175
|
+
createdAt: Date;
|
|
176
|
+
updatedAt: Date | null;
|
|
177
|
+
deletedAt: Date | null;
|
|
178
|
+
userId: string;
|
|
179
|
+
organizationId: string | null;
|
|
180
|
+
teamId: string | null;
|
|
181
|
+
name: string;
|
|
182
|
+
color: string | null;
|
|
183
|
+
type: string | null;
|
|
184
|
+
isEnabled: boolean;
|
|
185
|
+
parentId: string | null;
|
|
186
|
+
assignableTo: string[];
|
|
187
|
+
};
|
|
188
|
+
meta: import("trpc-to-openapi").OpenApiMeta;
|
|
189
|
+
}>;
|
|
190
|
+
}>>;
|
|
191
|
+
//# sourceMappingURL=tag.trpc.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tag.trpc.d.ts","sourceRoot":"","sources":["../../../../src/modules/tag/tag.trpc.ts"],"names":[],"mappings":"AAUA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAC;AAG3D,wBAAgB,aAAa,CAAC,UAAU,EAAE,UAAU;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IAgDnD"}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.createTagTRPC = createTagTRPC;
|
|
4
|
+
const tag_schema_1 = require("@m5kdev/commons/modules/tag/tag.schema");
|
|
5
|
+
const tag_dto_1 = require("#modules/tag/tag.dto");
|
|
6
|
+
const _trpc_1 = require("#trpc");
|
|
7
|
+
function createTagTRPC(tagService) {
|
|
8
|
+
const tagListInput = tag_schema_1.tagListInputSchema.extend({
|
|
9
|
+
assignableTo: tag_schema_1.tagListSchema.shape.assignableTo,
|
|
10
|
+
});
|
|
11
|
+
return (0, _trpc_1.router)({
|
|
12
|
+
list: _trpc_1.procedure
|
|
13
|
+
.input(tagListInput)
|
|
14
|
+
.output(tag_schema_1.tagListOutputSchema)
|
|
15
|
+
.query(async ({ input }) => (0, _trpc_1.handleTRPCResult)(await tagService.list(input))),
|
|
16
|
+
listTaggings: _trpc_1.procedure
|
|
17
|
+
.input(tag_schema_1.taggingSchema
|
|
18
|
+
.pick({ resourceType: true })
|
|
19
|
+
.extend({ resourceIds: tag_schema_1.tagListInputSchema.shape.filters.optional() }))
|
|
20
|
+
.output(tag_dto_1.taggingsSelectOutput.array())
|
|
21
|
+
.query(async ({ input }) => (0, _trpc_1.handleTRPCResult)(await tagService.listTaggings(input))),
|
|
22
|
+
create: _trpc_1.procedure
|
|
23
|
+
.input(tag_schema_1.tagCreateSchema)
|
|
24
|
+
.output(tag_dto_1.tagsSelectOutput)
|
|
25
|
+
.mutation(async ({ ctx, input }) => {
|
|
26
|
+
return (0, _trpc_1.handleTRPCResult)(await tagService.create(input, ctx));
|
|
27
|
+
}),
|
|
28
|
+
update: _trpc_1.procedure
|
|
29
|
+
.input(tag_schema_1.tagUpdateSchema)
|
|
30
|
+
.output(tag_dto_1.tagsSelectOutput)
|
|
31
|
+
.mutation(async ({ ctx, input }) => {
|
|
32
|
+
return (0, _trpc_1.handleTRPCResult)(await tagService.update(input, ctx));
|
|
33
|
+
}),
|
|
34
|
+
link: _trpc_1.procedure
|
|
35
|
+
.input(tag_schema_1.tagLinkSchema)
|
|
36
|
+
.output(tag_dto_1.taggingsSelectOutput)
|
|
37
|
+
.mutation(async ({ ctx, input }) => {
|
|
38
|
+
return (0, _trpc_1.handleTRPCResult)(await tagService.link(input, ctx));
|
|
39
|
+
}),
|
|
40
|
+
unlink: _trpc_1.procedure
|
|
41
|
+
.input(tag_schema_1.tagLinkSchema)
|
|
42
|
+
.output(tag_dto_1.tagsSelectOutput)
|
|
43
|
+
.mutation(async ({ ctx, input }) => {
|
|
44
|
+
return (0, _trpc_1.handleTRPCResult)(await tagService.unlink(input, ctx));
|
|
45
|
+
}),
|
|
46
|
+
});
|
|
47
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Applies pagination (limit and offset) to a drizzle query builder.
|
|
3
|
+
* Returns the query builder with pagination applied, or the original query if no limit is specified.
|
|
4
|
+
* Page is 1-based and only applied if limit is also provided.
|
|
5
|
+
*/
|
|
6
|
+
export declare const applyPagination: <TQuery>(query: TQuery, limit?: number, page?: number) => TQuery;
|
|
7
|
+
//# sourceMappingURL=applyPagination.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"applyPagination.d.ts","sourceRoot":"","sources":["../../../../src/modules/utils/applyPagination.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,eAAO,MAAM,eAAe,GAAI,MAAM,EAAE,OAAO,MAAM,EAAE,QAAQ,MAAM,EAAE,OAAO,MAAM,KAAG,MAMtF,CAAC"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Applies pagination (limit and offset) to a drizzle query builder.
|
|
4
|
+
* Returns the query builder with pagination applied, or the original query if no limit is specified.
|
|
5
|
+
* Page is 1-based and only applied if limit is also provided.
|
|
6
|
+
*/
|
|
7
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
8
|
+
exports.applyPagination = void 0;
|
|
9
|
+
const applyPagination = (query, limit, page) => {
|
|
10
|
+
if (limit)
|
|
11
|
+
query.limit(limit);
|
|
12
|
+
if (page && page > 1 && limit)
|
|
13
|
+
query.offset((page - 1) * limit);
|
|
14
|
+
return query;
|
|
15
|
+
};
|
|
16
|
+
exports.applyPagination = applyPagination;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { SQLiteTableWithColumns } from "drizzle-orm/sqlite-core";
|
|
2
|
+
/**
|
|
3
|
+
* Applies sorting to a drizzle query builder.
|
|
4
|
+
* Returns the query builder with sorting applied.
|
|
5
|
+
* If no sort or order is specified, defaults to createdAt descending.
|
|
6
|
+
* If createdAt column doesn't exist, returns the query unchanged.
|
|
7
|
+
*/
|
|
8
|
+
export declare const applySorting: <TQuery, TTable extends SQLiteTableWithColumns<any>>(query: TQuery, table: TTable, sort?: string, order?: "asc" | "desc") => TQuery;
|
|
9
|
+
//# sourceMappingURL=applySorting.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"applySorting.d.ts","sourceRoot":"","sources":["../../../../src/modules/utils/applySorting.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,yBAAyB,CAAC;AAEtE;;;;;GAKG;AAEH,eAAO,MAAM,YAAY,GAAI,MAAM,EAAE,MAAM,SAAS,sBAAsB,CAAC,GAAG,CAAC,EAC7E,OAAO,MAAM,EACb,OAAO,MAAM,EACb,OAAO,MAAM,EACb,QAAQ,KAAK,GAAG,MAAM,KACrB,MAKF,CAAC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.applySorting = void 0;
|
|
4
|
+
const drizzle_orm_1 = require("drizzle-orm");
|
|
5
|
+
/**
|
|
6
|
+
* Applies sorting to a drizzle query builder.
|
|
7
|
+
* Returns the query builder with sorting applied.
|
|
8
|
+
* If no sort or order is specified, defaults to createdAt descending.
|
|
9
|
+
* If createdAt column doesn't exist, returns the query unchanged.
|
|
10
|
+
*/
|
|
11
|
+
const applySorting = (query, table, sort, order) => {
|
|
12
|
+
const column = sort ? table[sort] : table.createdAt || table.id;
|
|
13
|
+
if (!column)
|
|
14
|
+
throw new Error(`Column ${sort} not found in table ${table.name}`);
|
|
15
|
+
query.orderBy(order === "asc" ? (0, drizzle_orm_1.asc)(column) : (0, drizzle_orm_1.desc)(column));
|
|
16
|
+
return query;
|
|
17
|
+
};
|
|
18
|
+
exports.applySorting = applySorting;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { QueryFilters } from "@m5kdev/commons/modules/schemas/query.schema";
|
|
2
|
+
import type { SQLiteTableWithColumns } from "drizzle-orm/sqlite-core";
|
|
3
|
+
import type { ConditionBuilder } from "#modules/base/base.repository";
|
|
4
|
+
export declare const getConditionsFromFilters: <T extends SQLiteTableWithColumns<any>>(conditions: ConditionBuilder, filters: QueryFilters | undefined, table: T) => ConditionBuilder;
|
|
5
|
+
//# sourceMappingURL=getConditionsFromFilters.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getConditionsFromFilters.d.ts","sourceRoot":"","sources":["../../../../src/modules/utils/getConditionsFromFilters.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,8CAA8C,CAAC;AAEjF,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,yBAAyB,CAAC;AAEtE,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,+BAA+B,CAAC;AAatE,eAAO,MAAM,wBAAwB,GAAI,CAAC,SAAS,sBAAsB,CAAC,GAAG,CAAC,EAC5E,YAAY,gBAAgB,EAC5B,SAAS,YAAY,GAAG,SAAS,EACjC,OAAO,CAAC,KACP,gBAkMF,CAAC"}
|
|
@@ -0,0 +1,200 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getConditionsFromFilters = void 0;
|
|
4
|
+
const drizzle_orm_1 = require("drizzle-orm");
|
|
5
|
+
const luxon_1 = require("luxon");
|
|
6
|
+
// Helper: Create UTC date boundaries from ISO string
|
|
7
|
+
const getUTCDateBoundaries = (isoString) => {
|
|
8
|
+
const dateTime = luxon_1.DateTime.fromISO(isoString, { zone: "utc" });
|
|
9
|
+
return {
|
|
10
|
+
start: dateTime.startOf("day").toJSDate(),
|
|
11
|
+
end: dateTime.endOf("day").toJSDate(),
|
|
12
|
+
};
|
|
13
|
+
};
|
|
14
|
+
const getConditionsFromFilters = (conditions, filters, table) => {
|
|
15
|
+
if (!filters || filters.length === 0) {
|
|
16
|
+
return conditions;
|
|
17
|
+
}
|
|
18
|
+
// Process each filter (maximum one filter per column)
|
|
19
|
+
for (const filter of filters) {
|
|
20
|
+
const { columnId, type, method, value, valueTo } = filter;
|
|
21
|
+
// Get the column from the table using columnId
|
|
22
|
+
const column = table[columnId];
|
|
23
|
+
if (!column) {
|
|
24
|
+
continue; // Skip if column doesn't exist
|
|
25
|
+
}
|
|
26
|
+
// Handle isEmpty/isNotEmpty methods (work across types, ignore value)
|
|
27
|
+
if (method === "isEmpty" || method === "isNotEmpty") {
|
|
28
|
+
switch (type) {
|
|
29
|
+
case "string":
|
|
30
|
+
case "enum":
|
|
31
|
+
// isEmpty: IS NULL OR = ''
|
|
32
|
+
// isNotEmpty: IS NOT NULL AND != ''
|
|
33
|
+
if (method === "isEmpty") {
|
|
34
|
+
conditions.push((0, drizzle_orm_1.or)((0, drizzle_orm_1.isNull)(column), (0, drizzle_orm_1.eq)(column, "")));
|
|
35
|
+
}
|
|
36
|
+
else {
|
|
37
|
+
conditions.push((0, drizzle_orm_1.and)((0, drizzle_orm_1.isNotNull)(column), (0, drizzle_orm_1.ne)(column, "")));
|
|
38
|
+
}
|
|
39
|
+
continue;
|
|
40
|
+
case "number":
|
|
41
|
+
// isEmpty: IS NULL OR = 0
|
|
42
|
+
// isNotEmpty: IS NOT NULL AND != 0
|
|
43
|
+
if (method === "isEmpty") {
|
|
44
|
+
conditions.push((0, drizzle_orm_1.or)((0, drizzle_orm_1.isNull)(column), (0, drizzle_orm_1.eq)(column, 0)));
|
|
45
|
+
}
|
|
46
|
+
else {
|
|
47
|
+
conditions.push((0, drizzle_orm_1.and)((0, drizzle_orm_1.isNotNull)(column), (0, drizzle_orm_1.ne)(column, 0)));
|
|
48
|
+
}
|
|
49
|
+
continue;
|
|
50
|
+
case "boolean":
|
|
51
|
+
// Should not happen per plan, but handle gracefully
|
|
52
|
+
continue;
|
|
53
|
+
default:
|
|
54
|
+
continue;
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
// Apply filter based on type and method
|
|
58
|
+
switch (type) {
|
|
59
|
+
case "string":
|
|
60
|
+
switch (method) {
|
|
61
|
+
case "contains":
|
|
62
|
+
if (typeof value === "string") {
|
|
63
|
+
conditions.push((0, drizzle_orm_1.like)(column, `%${value}%`));
|
|
64
|
+
}
|
|
65
|
+
break;
|
|
66
|
+
case "equals":
|
|
67
|
+
if (typeof value === "string") {
|
|
68
|
+
conditions.push((0, drizzle_orm_1.eq)(column, value));
|
|
69
|
+
}
|
|
70
|
+
break;
|
|
71
|
+
case "starts_with":
|
|
72
|
+
if (typeof value === "string") {
|
|
73
|
+
conditions.push((0, drizzle_orm_1.like)(column, `${value}%`));
|
|
74
|
+
}
|
|
75
|
+
break;
|
|
76
|
+
case "ends_with":
|
|
77
|
+
if (typeof value === "string") {
|
|
78
|
+
conditions.push((0, drizzle_orm_1.like)(column, `%${value}`));
|
|
79
|
+
}
|
|
80
|
+
break;
|
|
81
|
+
case "is_null":
|
|
82
|
+
conditions.push((0, drizzle_orm_1.isNull)(column));
|
|
83
|
+
break;
|
|
84
|
+
case "is_not_null":
|
|
85
|
+
conditions.push((0, drizzle_orm_1.isNotNull)(column));
|
|
86
|
+
break;
|
|
87
|
+
}
|
|
88
|
+
break;
|
|
89
|
+
case "number":
|
|
90
|
+
switch (method) {
|
|
91
|
+
case "equals":
|
|
92
|
+
if (typeof value === "number") {
|
|
93
|
+
conditions.push((0, drizzle_orm_1.eq)(column, value));
|
|
94
|
+
}
|
|
95
|
+
break;
|
|
96
|
+
case "greater_than":
|
|
97
|
+
if (typeof value === "number") {
|
|
98
|
+
conditions.push((0, drizzle_orm_1.gte)(column, value));
|
|
99
|
+
}
|
|
100
|
+
break;
|
|
101
|
+
case "less_than":
|
|
102
|
+
if (typeof value === "number") {
|
|
103
|
+
conditions.push((0, drizzle_orm_1.lte)(column, value));
|
|
104
|
+
}
|
|
105
|
+
break;
|
|
106
|
+
case "is_null":
|
|
107
|
+
conditions.push((0, drizzle_orm_1.isNull)(column));
|
|
108
|
+
break;
|
|
109
|
+
case "is_not_null":
|
|
110
|
+
conditions.push((0, drizzle_orm_1.isNotNull)(column));
|
|
111
|
+
break;
|
|
112
|
+
}
|
|
113
|
+
break;
|
|
114
|
+
case "date":
|
|
115
|
+
if (typeof value !== "string")
|
|
116
|
+
break;
|
|
117
|
+
switch (method) {
|
|
118
|
+
case "on": {
|
|
119
|
+
const { start, end } = getUTCDateBoundaries(value);
|
|
120
|
+
conditions.push((0, drizzle_orm_1.and)((0, drizzle_orm_1.gte)(column, start), (0, drizzle_orm_1.lte)(column, end)));
|
|
121
|
+
break;
|
|
122
|
+
}
|
|
123
|
+
case "between":
|
|
124
|
+
if (valueTo) {
|
|
125
|
+
const { start } = getUTCDateBoundaries(value);
|
|
126
|
+
const { end } = getUTCDateBoundaries(valueTo);
|
|
127
|
+
conditions.push((0, drizzle_orm_1.between)(column, start, end));
|
|
128
|
+
}
|
|
129
|
+
break;
|
|
130
|
+
case "before": {
|
|
131
|
+
const { end } = getUTCDateBoundaries(value);
|
|
132
|
+
conditions.push((0, drizzle_orm_1.lte)(column, end));
|
|
133
|
+
break;
|
|
134
|
+
}
|
|
135
|
+
case "after": {
|
|
136
|
+
const { start } = getUTCDateBoundaries(value);
|
|
137
|
+
conditions.push((0, drizzle_orm_1.gte)(column, start));
|
|
138
|
+
break;
|
|
139
|
+
}
|
|
140
|
+
case "intersect": {
|
|
141
|
+
// Interval overlap: [columnId, endColumnId] intersects with [value, valueTo]
|
|
142
|
+
// Logic: columnId <= valueTo AND (endColumnId IS NULL OR endColumnId >= value)
|
|
143
|
+
if (!valueTo || !filter.endColumnId)
|
|
144
|
+
break;
|
|
145
|
+
const endColumn = table[filter.endColumnId];
|
|
146
|
+
if (!endColumn)
|
|
147
|
+
break;
|
|
148
|
+
const { start } = getUTCDateBoundaries(value);
|
|
149
|
+
const { end } = getUTCDateBoundaries(valueTo);
|
|
150
|
+
conditions.push((0, drizzle_orm_1.and)((0, drizzle_orm_1.lte)(column, end), (0, drizzle_orm_1.or)((0, drizzle_orm_1.isNull)(endColumn), (0, drizzle_orm_1.gte)(endColumn, start))));
|
|
151
|
+
break;
|
|
152
|
+
}
|
|
153
|
+
case "is_null":
|
|
154
|
+
conditions.push((0, drizzle_orm_1.isNull)(column));
|
|
155
|
+
break;
|
|
156
|
+
case "is_not_null":
|
|
157
|
+
conditions.push((0, drizzle_orm_1.isNotNull)(column));
|
|
158
|
+
break;
|
|
159
|
+
}
|
|
160
|
+
break;
|
|
161
|
+
case "boolean":
|
|
162
|
+
switch (method) {
|
|
163
|
+
case "equals":
|
|
164
|
+
if (typeof value === "boolean") {
|
|
165
|
+
conditions.push((0, drizzle_orm_1.eq)(column, value));
|
|
166
|
+
}
|
|
167
|
+
break;
|
|
168
|
+
case "is_null":
|
|
169
|
+
conditions.push((0, drizzle_orm_1.isNull)(column));
|
|
170
|
+
break;
|
|
171
|
+
case "is_not_null":
|
|
172
|
+
conditions.push((0, drizzle_orm_1.isNotNull)(column));
|
|
173
|
+
break;
|
|
174
|
+
}
|
|
175
|
+
break;
|
|
176
|
+
case "enum":
|
|
177
|
+
switch (method) {
|
|
178
|
+
case "oneOf":
|
|
179
|
+
if (Array.isArray(value) && value.length > 0) {
|
|
180
|
+
conditions.push((0, drizzle_orm_1.inArray)(column, value));
|
|
181
|
+
}
|
|
182
|
+
break;
|
|
183
|
+
case "equals":
|
|
184
|
+
if (typeof value === "string") {
|
|
185
|
+
conditions.push((0, drizzle_orm_1.eq)(column, value));
|
|
186
|
+
}
|
|
187
|
+
break;
|
|
188
|
+
case "is_null":
|
|
189
|
+
conditions.push((0, drizzle_orm_1.isNull)(column));
|
|
190
|
+
break;
|
|
191
|
+
case "is_not_null":
|
|
192
|
+
conditions.push((0, drizzle_orm_1.isNotNull)(column));
|
|
193
|
+
break;
|
|
194
|
+
}
|
|
195
|
+
break;
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
return conditions;
|
|
199
|
+
};
|
|
200
|
+
exports.getConditionsFromFilters = getConditionsFromFilters;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { ServerResultAsync } from "#modules/base/base.dto";
|
|
2
|
+
import { BaseService } from "#modules/base/base.service";
|
|
3
|
+
export declare class VideoService extends BaseService<never, never> {
|
|
4
|
+
cut(file: string, start: number, end: number): ServerResultAsync<string>;
|
|
5
|
+
webmToWav(input: string, hz?: number): ServerResultAsync<string>;
|
|
6
|
+
extractAudioMp3(input: string, kbps?: number, streamIndex?: number): ServerResultAsync<string>;
|
|
7
|
+
}
|
|
8
|
+
//# sourceMappingURL=video.service.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"video.service.d.ts","sourceRoot":"","sources":["../../../../src/modules/video/video.service.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAChE,OAAO,EAAE,WAAW,EAAE,MAAM,4BAA4B,CAAC;AAczD,qBAAa,YAAa,SAAQ,WAAW,CAAC,KAAK,EAAE,KAAK,CAAC;IACnD,GAAG,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,iBAAiB,CAAC,MAAM,CAAC;IAwBxE,SAAS,CAAC,KAAK,EAAE,MAAM,EAAE,EAAE,SAAQ,GAAG,iBAAiB,CAAC,MAAM,CAAC;IAsB/D,eAAe,CAAC,KAAK,EAAE,MAAM,EAAE,IAAI,SAAM,EAAE,WAAW,SAAI,GAAG,iBAAiB,CAAC,MAAM,CAAC;CAmB7F"}
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.VideoService = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const node_fs_1 = require("node:fs");
|
|
6
|
+
const node_path_1 = tslib_1.__importDefault(require("node:path"));
|
|
7
|
+
//
|
|
8
|
+
const ffmpeg_ffprobe_static_1 = tslib_1.__importDefault(require("ffmpeg-ffprobe-static"));
|
|
9
|
+
const fluent_ffmpeg_1 = tslib_1.__importDefault(require("fluent-ffmpeg"));
|
|
10
|
+
const neverthrow_1 = require("neverthrow");
|
|
11
|
+
const uuid_1 = require("uuid");
|
|
12
|
+
const base_service_1 = require("#modules/base/base.service");
|
|
13
|
+
if (!ffmpeg_ffprobe_static_1.default.ffmpegPath || !ffmpeg_ffprobe_static_1.default.ffprobePath) {
|
|
14
|
+
throw new Error("FFmpeg or FFprobe not found");
|
|
15
|
+
}
|
|
16
|
+
fluent_ffmpeg_1.default.setFfmpegPath(ffmpeg_ffprobe_static_1.default.ffmpegPath);
|
|
17
|
+
fluent_ffmpeg_1.default.setFfprobePath(ffmpeg_ffprobe_static_1.default.ffprobePath);
|
|
18
|
+
const uploadsDir = node_path_1.default.join(__dirname, "..", "uploads");
|
|
19
|
+
if (!(0, node_fs_1.existsSync)(uploadsDir)) {
|
|
20
|
+
(0, node_fs_1.mkdirSync)(uploadsDir, { recursive: true });
|
|
21
|
+
}
|
|
22
|
+
class VideoService extends base_service_1.BaseService {
|
|
23
|
+
async cut(file, start, end) {
|
|
24
|
+
return this.throwableAsync(async () => {
|
|
25
|
+
const duration = end - start;
|
|
26
|
+
const output = node_path_1.default.join(uploadsDir, `${(0, uuid_1.v4)()}.mp4`);
|
|
27
|
+
if (!(0, node_fs_1.existsSync)(output)) {
|
|
28
|
+
(0, node_fs_1.closeSync)((0, node_fs_1.openSync)(output, "w"));
|
|
29
|
+
}
|
|
30
|
+
await new Promise((resolve, reject) => {
|
|
31
|
+
(0, fluent_ffmpeg_1.default)(file)
|
|
32
|
+
.seekOutput(start)
|
|
33
|
+
.videoCodec("libx264")
|
|
34
|
+
.audioCodec("copy")
|
|
35
|
+
.outputOptions(["-y", "-movflags +faststart"])
|
|
36
|
+
.duration(duration)
|
|
37
|
+
.on("end", () => resolve())
|
|
38
|
+
.on("error", (e, _stdout, _stderr) => reject(e))
|
|
39
|
+
.save(output);
|
|
40
|
+
}).catch((error) => (0, neverthrow_1.err)(this.handleUnknownError(error)));
|
|
41
|
+
return (0, neverthrow_1.ok)(output);
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
async webmToWav(input, hz = 48000) {
|
|
45
|
+
return this.throwableAsync(async () => {
|
|
46
|
+
const output = node_path_1.default.join(uploadsDir, `${(0, uuid_1.v4)()}.wav`);
|
|
47
|
+
if (!(0, node_fs_1.existsSync)(output)) {
|
|
48
|
+
(0, node_fs_1.closeSync)((0, node_fs_1.openSync)(output, "w"));
|
|
49
|
+
}
|
|
50
|
+
await new Promise((resolve, reject) => {
|
|
51
|
+
(0, fluent_ffmpeg_1.default)(input)
|
|
52
|
+
.noVideo()
|
|
53
|
+
.audioCodec("pcm_s16le") // WAV PCM 16-bit
|
|
54
|
+
.audioFrequency(hz) // 48000 or 44100
|
|
55
|
+
.audioChannels(2) // down/up-mix as needed
|
|
56
|
+
.format("wav")
|
|
57
|
+
.outputOptions(["-y"])
|
|
58
|
+
.on("end", () => resolve())
|
|
59
|
+
.on("error", reject)
|
|
60
|
+
.save(output);
|
|
61
|
+
}).catch((error) => (0, neverthrow_1.err)(this.handleUnknownError(error)));
|
|
62
|
+
return (0, neverthrow_1.ok)(output);
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
async extractAudioMp3(input, kbps = 192, streamIndex = 0) {
|
|
66
|
+
return this.throwableAsync(async () => {
|
|
67
|
+
const output = node_path_1.default.join(uploadsDir, `${(0, uuid_1.v4)()}.mp3`);
|
|
68
|
+
if (!(0, node_fs_1.existsSync)(output)) {
|
|
69
|
+
(0, node_fs_1.closeSync)((0, node_fs_1.openSync)(output, "w"));
|
|
70
|
+
}
|
|
71
|
+
await new Promise((resolve, reject) => {
|
|
72
|
+
(0, fluent_ffmpeg_1.default)(input)
|
|
73
|
+
.outputOptions(["-y", `-map 0:a:${streamIndex}`])
|
|
74
|
+
.audioCodec("libmp3lame")
|
|
75
|
+
.audioBitrate(kbps)
|
|
76
|
+
.on("end", () => resolve())
|
|
77
|
+
.on("error", reject)
|
|
78
|
+
.save(output);
|
|
79
|
+
}).catch((error) => (0, neverthrow_1.err)(this.handleUnknownError(error)));
|
|
80
|
+
return (0, neverthrow_1.ok)(output);
|
|
81
|
+
});
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
exports.VideoService = VideoService;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export declare const WEBHOOK_STATUS_ENUM: {
|
|
2
|
+
readonly WAITING: "WAITING";
|
|
3
|
+
readonly COMPLETED: "COMPLETED";
|
|
4
|
+
readonly TIMEOUT: "TIMEOUT";
|
|
5
|
+
readonly ERROR_CALLBACK: "ERROR_CALLBACK";
|
|
6
|
+
readonly ERROR_DATA: "ERROR_DATA";
|
|
7
|
+
};
|
|
8
|
+
export type WebhookStatus = (typeof WEBHOOK_STATUS_ENUM)[keyof typeof WEBHOOK_STATUS_ENUM];
|
|
9
|
+
//# sourceMappingURL=webhook.constants.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"webhook.constants.d.ts","sourceRoot":"","sources":["../../../../src/modules/webhook/webhook.constants.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,mBAAmB;;;;;;CAMtB,CAAC;AAEX,MAAM,MAAM,aAAa,GAAG,CAAC,OAAO,mBAAmB,CAAC,CAAC,MAAM,OAAO,mBAAmB,CAAC,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.WEBHOOK_STATUS_ENUM = void 0;
|
|
4
|
+
exports.WEBHOOK_STATUS_ENUM = {
|
|
5
|
+
WAITING: "WAITING",
|
|
6
|
+
COMPLETED: "COMPLETED",
|
|
7
|
+
TIMEOUT: "TIMEOUT",
|
|
8
|
+
ERROR_CALLBACK: "ERROR_CALLBACK",
|
|
9
|
+
ERROR_DATA: "ERROR_DATA",
|
|
10
|
+
};
|