@m5kdev/backend 0.1.5 → 0.3.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/access/access.repository.d.ts +2 -2
- package/dist/src/modules/access/access.repository.js +2 -2
- package/dist/src/modules/access/access.service.d.ts +4 -4
- package/dist/src/modules/access/access.service.js +1 -1
- package/dist/src/modules/access/access.test.js +4 -4
- package/dist/src/modules/ai/ai.db.js +1 -1
- package/dist/src/modules/ai/ai.prompt.js +1 -1
- package/dist/src/modules/ai/ai.repository.d.ts +2 -2
- package/dist/src/modules/ai/ai.repository.js +2 -2
- package/dist/src/modules/ai/ai.service.d.ts +6 -6
- package/dist/src/modules/ai/ai.service.js +1 -1
- package/dist/src/modules/ai/ai.trpc.d.ts +6 -42
- package/dist/src/modules/ai/ai.trpc.js +5 -5
- package/dist/src/modules/ai/ideogram/ideogram.dto.js +1 -1
- package/dist/src/modules/ai/ideogram/ideogram.prompt.d.ts +1 -1
- package/dist/src/modules/ai/ideogram/ideogram.prompt.js +1 -1
- package/dist/src/modules/ai/ideogram/ideogram.repository.d.ts +3 -3
- package/dist/src/modules/ai/ideogram/ideogram.repository.js +1 -1
- package/dist/src/modules/ai/ideogram/ideogram.service.d.ts +4 -4
- package/dist/src/modules/ai/ideogram/ideogram.service.js +1 -1
- package/dist/src/modules/auth/auth.dto.d.ts +5 -5
- package/dist/src/modules/auth/auth.lib.d.ts +10 -10
- package/dist/src/modules/auth/auth.lib.js +4 -4
- package/dist/src/modules/auth/auth.middleware.d.ts +1 -1
- package/dist/src/modules/auth/auth.middleware.js +2 -2
- package/dist/src/modules/auth/auth.repository.d.ts +4 -4
- package/dist/src/modules/auth/auth.repository.js +2 -2
- package/dist/src/modules/auth/auth.service.d.ts +7 -7
- package/dist/src/modules/auth/auth.service.js +2 -2
- package/dist/src/modules/auth/auth.trpc.d.ts +45 -81
- package/dist/src/modules/auth/auth.trpc.js +57 -55
- package/dist/src/modules/auth/auth.utils.js +1 -1
- package/dist/src/modules/base/base.abstract.d.ts +4 -4
- package/dist/src/modules/base/base.abstract.js +2 -2
- package/dist/src/modules/base/base.dto.d.ts +3 -3
- package/dist/src/modules/base/base.grants.d.ts +2 -2
- package/dist/src/modules/base/base.grants.test.js +2 -2
- package/dist/src/modules/base/base.repository.d.ts +2 -2
- package/dist/src/modules/base/base.repository.js +5 -5
- package/dist/src/modules/base/base.service.d.ts +6 -7
- package/dist/src/modules/base/base.service.js +2 -2
- package/dist/src/modules/billing/billing.repository.d.ts +2 -2
- package/dist/src/modules/billing/billing.repository.js +4 -4
- package/dist/src/modules/billing/billing.router.d.ts +2 -2
- package/dist/src/modules/billing/billing.service.d.ts +4 -4
- package/dist/src/modules/billing/billing.service.js +2 -2
- package/dist/src/modules/billing/billing.trpc.d.ts +7 -43
- package/dist/src/modules/billing/billing.trpc.js +7 -7
- package/dist/src/modules/clay/clay.repository.d.ts +2 -2
- package/dist/src/modules/clay/clay.repository.js +1 -1
- package/dist/src/modules/clay/clay.service.d.ts +3 -3
- package/dist/src/modules/clay/clay.service.js +1 -1
- package/dist/src/modules/connect/connect.dto.d.ts +4 -4
- package/dist/src/modules/connect/connect.oauth.js +1 -1
- package/dist/src/modules/connect/connect.repository.d.ts +4 -4
- package/dist/src/modules/connect/connect.repository.js +2 -2
- package/dist/src/modules/connect/connect.router.d.ts +1 -1
- package/dist/src/modules/connect/connect.service.d.ts +12 -12
- package/dist/src/modules/connect/connect.service.js +1 -1
- package/dist/src/modules/connect/connect.trpc.d.ts +7 -43
- package/dist/src/modules/connect/connect.trpc.js +7 -7
- package/dist/src/modules/crypto/crypto.repository.d.ts +1 -1
- package/dist/src/modules/crypto/crypto.repository.js +2 -2
- package/dist/src/modules/crypto/crypto.service.d.ts +3 -3
- package/dist/src/modules/crypto/crypto.service.js +1 -1
- package/dist/src/modules/email/email.service.d.ts +1 -1
- package/dist/src/modules/email/email.service.js +1 -1
- package/dist/src/modules/file/file.repository.d.ts +2 -2
- package/dist/src/modules/file/file.repository.js +1 -1
- package/dist/src/modules/file/file.router.js +2 -2
- package/dist/src/modules/file/file.service.d.ts +3 -3
- package/dist/src/modules/file/file.service.js +1 -1
- package/dist/src/modules/recurrence/recurrence.db.js +1 -1
- package/dist/src/modules/recurrence/recurrence.repository.d.ts +2 -2
- package/dist/src/modules/recurrence/recurrence.repository.js +2 -2
- package/dist/src/modules/recurrence/recurrence.service.d.ts +4 -4
- package/dist/src/modules/recurrence/recurrence.service.js +1 -1
- package/dist/src/modules/recurrence/recurrence.trpc.d.ts +12 -48
- package/dist/src/modules/recurrence/recurrence.trpc.js +17 -17
- package/dist/src/modules/social/social.service.d.ts +5 -5
- package/dist/src/modules/social/social.service.js +1 -1
- package/dist/src/modules/social/social.types.d.ts +2 -2
- package/dist/src/modules/tag/tag.db.js +1 -1
- package/dist/src/modules/tag/tag.dto.d.ts +1 -1
- package/dist/src/modules/tag/tag.dto.js +2 -2
- package/dist/src/modules/tag/tag.repository.d.ts +3 -3
- package/dist/src/modules/tag/tag.repository.js +2 -2
- package/dist/src/modules/tag/tag.service.d.ts +6 -6
- package/dist/src/modules/tag/tag.service.js +1 -1
- package/dist/src/modules/tag/tag.trpc.d.ts +11 -47
- package/dist/src/modules/tag/tag.trpc.js +16 -16
- package/dist/src/modules/utils/getConditionsFromFilters.d.ts +1 -1
- package/dist/src/modules/video/video.service.d.ts +2 -2
- package/dist/src/modules/video/video.service.js +1 -1
- package/dist/src/modules/webhook/webhook.dto.js +1 -1
- package/dist/src/modules/webhook/webhook.repository.d.ts +2 -2
- package/dist/src/modules/webhook/webhook.repository.js +1 -1
- package/dist/src/modules/webhook/webhook.service.d.ts +2 -2
- package/dist/src/modules/webhook/webhook.service.js +1 -1
- package/dist/src/modules/workflow/workflow.db.js +1 -1
- package/dist/src/modules/workflow/workflow.repository.d.ts +2 -2
- package/dist/src/modules/workflow/workflow.repository.js +2 -2
- package/dist/src/modules/workflow/workflow.service.d.ts +4 -4
- package/dist/src/modules/workflow/workflow.service.js +1 -1
- package/dist/src/modules/workflow/workflow.trpc.d.ts +7 -43
- package/dist/src/modules/workflow/workflow.trpc.js +7 -7
- package/dist/src/modules/workflow/workflow.types.d.ts +2 -2
- package/dist/src/modules/workflow/workflow.utils.js +3 -3
- package/dist/src/types.d.ts +56 -203
- package/dist/src/types.js +7 -8
- package/dist/src/utils/errors.d.ts +1 -1
- package/dist/src/utils/trpc.d.ts +58 -0
- package/dist/src/utils/trpc.js +63 -0
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +3 -30
|
@@ -1,16 +1,15 @@
|
|
|
1
1
|
import type { QueryFilter, QueryInput } from "@m5kdev/commons/modules/schemas/query.schema";
|
|
2
|
-
import type { Session, User } from "
|
|
3
|
-
import { Base } from "
|
|
4
|
-
import type { ServerResult, ServerResultAsync } from "
|
|
5
|
-
import { type Entity, type ResourceActionGrant, type ResourceGrant } from "
|
|
6
|
-
import type { BaseExternaRepository, BaseRepository } from "
|
|
7
|
-
import type { Context } from "#trpc";
|
|
2
|
+
import type { Context, Session, User } from "../auth/auth.lib";
|
|
3
|
+
import { Base } from "./base.abstract";
|
|
4
|
+
import type { ServerResult, ServerResultAsync } from "./base.dto";
|
|
5
|
+
import { type Entity, type ResourceActionGrant, type ResourceGrant } from "./base.grants";
|
|
6
|
+
import type { BaseExternaRepository, BaseRepository } from "./base.repository";
|
|
8
7
|
export declare class BaseService<Repositories extends Record<string, BaseRepository<any, any, any> | BaseExternaRepository>, Services extends Record<string, BaseService<any, any>>> extends Base {
|
|
9
8
|
repository: Repositories;
|
|
10
9
|
service: Services;
|
|
11
10
|
constructor(repository?: Repositories, service?: Services);
|
|
12
11
|
addUserFilter(value: string, query?: QueryInput, columnId?: string, method?: QueryFilter["method"]): QueryInput;
|
|
13
|
-
addContextFilter(ctx:
|
|
12
|
+
addContextFilter(ctx: Context, include?: {
|
|
14
13
|
user?: boolean;
|
|
15
14
|
organization?: boolean;
|
|
16
15
|
team?: boolean;
|
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.BasePermissionService = exports.BaseService = void 0;
|
|
4
4
|
const neverthrow_1 = require("neverthrow");
|
|
5
|
-
const base_abstract_1 = require("
|
|
6
|
-
const base_grants_1 = require("
|
|
5
|
+
const base_abstract_1 = require("./base.abstract");
|
|
6
|
+
const base_grants_1 = require("./base.grants");
|
|
7
7
|
class BaseService extends base_abstract_1.Base {
|
|
8
8
|
repository;
|
|
9
9
|
service;
|
|
@@ -3,8 +3,8 @@ import type { StripePlan } from "@m5kdev/commons/modules/billing/billing.types";
|
|
|
3
3
|
import { type InferSelectModel } from "drizzle-orm";
|
|
4
4
|
import type { LibSQLDatabase } from "drizzle-orm/libsql";
|
|
5
5
|
import type { Stripe } from "stripe";
|
|
6
|
-
import type { ServerResult, ServerResultAsync } from "
|
|
7
|
-
import { BaseTableRepository } from "
|
|
6
|
+
import type { ServerResult, ServerResultAsync } from "../base/base.dto";
|
|
7
|
+
import { BaseTableRepository } from "../base/base.repository";
|
|
8
8
|
declare const schema: {
|
|
9
9
|
subscriptions: import("drizzle-orm/sqlite-core").SQLiteTableWithColumns<{
|
|
10
10
|
name: "subscriptions";
|
|
@@ -4,10 +4,10 @@ exports.BillingRepository = void 0;
|
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
5
|
const drizzle_orm_1 = require("drizzle-orm");
|
|
6
6
|
const neverthrow_1 = require("neverthrow");
|
|
7
|
-
const auth = tslib_1.__importStar(require("
|
|
8
|
-
const base_repository_1 = require("
|
|
9
|
-
const billing = tslib_1.__importStar(require("
|
|
10
|
-
const posthog_1 = require("
|
|
7
|
+
const auth = tslib_1.__importStar(require("../auth/auth.db"));
|
|
8
|
+
const base_repository_1 = require("../base/base.repository");
|
|
9
|
+
const billing = tslib_1.__importStar(require("./billing.db"));
|
|
10
|
+
const posthog_1 = require("../../utils/posthog");
|
|
11
11
|
const schema = { ...auth, ...billing };
|
|
12
12
|
class BillingRepository extends base_repository_1.BaseTableRepository {
|
|
13
13
|
stripe;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { Router } from "express";
|
|
2
|
-
import type { AuthMiddleware } from "
|
|
3
|
-
import type { BillingService } from "
|
|
2
|
+
import type { AuthMiddleware } from "../auth/auth.middleware";
|
|
3
|
+
import type { BillingService } from "./billing.service";
|
|
4
4
|
export declare function createBillingRouter(authMiddleware: AuthMiddleware, service: BillingService): Router;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import type Stripe from "stripe";
|
|
2
|
-
import type { User } from "
|
|
3
|
-
import type { ServerResult, ServerResultAsync } from "
|
|
4
|
-
import { BaseService } from "
|
|
5
|
-
import type { BillingRepository } from "
|
|
2
|
+
import type { User } from "../auth/auth.lib";
|
|
3
|
+
import type { ServerResult, ServerResultAsync } from "../base/base.dto";
|
|
4
|
+
import { BaseService } from "../base/base.service";
|
|
5
|
+
import type { BillingRepository } from "./billing.repository";
|
|
6
6
|
export declare class BillingService extends BaseService<{
|
|
7
7
|
billing: BillingRepository;
|
|
8
8
|
}, never> {
|
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.BillingService = void 0;
|
|
4
4
|
const neverthrow_1 = require("neverthrow");
|
|
5
|
-
const base_service_1 = require("
|
|
6
|
-
const posthog_1 = require("
|
|
5
|
+
const base_service_1 = require("../base/base.service");
|
|
6
|
+
const posthog_1 = require("../../utils/posthog");
|
|
7
7
|
const allowedEvents = [
|
|
8
8
|
"checkout.session.completed",
|
|
9
9
|
"customer.subscription.created",
|
|
@@ -1,44 +1,8 @@
|
|
|
1
|
-
import type { BillingService } from "
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
createdAt: Date;
|
|
7
|
-
updatedAt: Date;
|
|
8
|
-
expiresAt: Date;
|
|
9
|
-
token: string;
|
|
10
|
-
ipAddress: string | null;
|
|
11
|
-
userAgent: string | null;
|
|
12
|
-
userId: string;
|
|
13
|
-
impersonatedBy: string | null;
|
|
14
|
-
activeOrganizationId: string | null;
|
|
15
|
-
activeOrganizationRole: string | null;
|
|
16
|
-
activeTeamId: string | null;
|
|
17
|
-
activeTeamRole: string | null;
|
|
18
|
-
};
|
|
19
|
-
user: {
|
|
20
|
-
id: string;
|
|
21
|
-
name: string;
|
|
22
|
-
email: string;
|
|
23
|
-
emailVerified: boolean;
|
|
24
|
-
image: string | null;
|
|
25
|
-
createdAt: Date;
|
|
26
|
-
updatedAt: 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;
|
|
1
|
+
import type { BillingService } from "./billing.service";
|
|
2
|
+
import { type TRPCMethods } from "../../utils/trpc";
|
|
3
|
+
export declare function createBillingTRPC({ router, privateProcedure: procedure }: TRPCMethods, billingService: BillingService): import("@trpc/server").TRPCBuiltRouter<{
|
|
4
|
+
ctx: import("../auth/auth.lib").Context;
|
|
5
|
+
meta: any;
|
|
42
6
|
errorShape: import("@trpc/server").TRPCDefaultErrorShape;
|
|
43
7
|
transformer: true;
|
|
44
8
|
}, import("@trpc/server").TRPCDecorateCreateRouterOptions<{
|
|
@@ -64,11 +28,11 @@ export declare function createBillingTRPC(billingService: BillingService): impor
|
|
|
64
28
|
unitAmount?: number | null | undefined;
|
|
65
29
|
discounts?: string[] | null | undefined;
|
|
66
30
|
} | null;
|
|
67
|
-
meta:
|
|
31
|
+
meta: any;
|
|
68
32
|
}>;
|
|
69
33
|
listInvoices: import("@trpc/server").TRPCQueryProcedure<{
|
|
70
34
|
input: void;
|
|
71
35
|
output: import("stripe").Stripe.Invoice[];
|
|
72
|
-
meta:
|
|
36
|
+
meta: any;
|
|
73
37
|
}>;
|
|
74
38
|
}>>;
|
|
@@ -2,16 +2,16 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.createBillingTRPC = createBillingTRPC;
|
|
4
4
|
const billing_schema_1 = require("@m5kdev/commons/modules/billing/billing.schema");
|
|
5
|
-
const
|
|
6
|
-
function createBillingTRPC(billingService) {
|
|
7
|
-
return
|
|
8
|
-
getActiveSubscription:
|
|
5
|
+
const trpc_1 = require("../../utils/trpc");
|
|
6
|
+
function createBillingTRPC({ router, privateProcedure: procedure }, billingService) {
|
|
7
|
+
return router({
|
|
8
|
+
getActiveSubscription: procedure
|
|
9
9
|
.output(billing_schema_1.billingSchema.nullable())
|
|
10
10
|
.query(async ({ ctx: { user } }) => {
|
|
11
|
-
return (0,
|
|
11
|
+
return (0, trpc_1.handleTRPCResult)(await billingService.getActiveSubscription({ user }));
|
|
12
12
|
}),
|
|
13
|
-
listInvoices:
|
|
14
|
-
return (0,
|
|
13
|
+
listInvoices: procedure.query(async ({ ctx: { user } }) => {
|
|
14
|
+
return (0, trpc_1.handleTRPCResult)(await billingService.listInvoices({ user }));
|
|
15
15
|
}),
|
|
16
16
|
});
|
|
17
17
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { ServerResultAsync } from "
|
|
2
|
-
import { BaseExternaRepository } from "
|
|
1
|
+
import type { ServerResultAsync } from "../base/base.dto";
|
|
2
|
+
import { BaseExternaRepository } from "../base/base.repository";
|
|
3
3
|
export declare class ClayRepository extends BaseExternaRepository {
|
|
4
4
|
sendToWebhook(webhookUrl: string, row: Record<string, unknown>, callbackUrl: string): ServerResultAsync<void>;
|
|
5
5
|
}
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.ClayRepository = void 0;
|
|
4
4
|
const neverthrow_1 = require("neverthrow");
|
|
5
|
-
const base_repository_1 = require("
|
|
5
|
+
const base_repository_1 = require("../base/base.repository");
|
|
6
6
|
const { CLAY_WEBHOOK_AUTH_TOKEN } = process.env;
|
|
7
7
|
class ClayRepository extends base_repository_1.BaseExternaRepository {
|
|
8
8
|
async sendToWebhook(webhookUrl, row, callbackUrl) {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { z } from "zod";
|
|
2
|
-
import type { ServerResultAsync } from "
|
|
3
|
-
import { BaseService } from "
|
|
4
|
-
import type { WebhookService } from "
|
|
2
|
+
import type { ServerResultAsync } from "../base/base.dto";
|
|
3
|
+
import { BaseService } from "../base/base.service";
|
|
4
|
+
import type { WebhookService } from "../webhook/webhook.service";
|
|
5
5
|
import type { ClayRepository } from "./clay.repository";
|
|
6
6
|
type ClayTable = {
|
|
7
7
|
name?: string;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.ClayService = void 0;
|
|
4
|
-
const base_service_1 = require("
|
|
4
|
+
const base_service_1 = require("../base/base.service");
|
|
5
5
|
class ClayService extends base_service_1.BaseService {
|
|
6
6
|
tables;
|
|
7
7
|
constructor(repositories, services, tables) {
|
|
@@ -22,13 +22,13 @@ export declare const connectSelectSchema: z.ZodObject<{
|
|
|
22
22
|
}, z.core.$strip>;
|
|
23
23
|
export type ConnectSelectSchema = z.infer<typeof connectSelectSchema>;
|
|
24
24
|
export declare const connectSelectOutputSchema: z.ZodObject<{
|
|
25
|
+
provider: z.ZodString;
|
|
25
26
|
id: z.ZodString;
|
|
26
27
|
createdAt: z.ZodDate;
|
|
27
28
|
updatedAt: z.ZodOptional<z.ZodNullable<z.ZodDate>>;
|
|
28
|
-
expiresAt: z.ZodOptional<z.ZodNullable<z.ZodDate>>;
|
|
29
29
|
userId: z.ZodString;
|
|
30
|
+
expiresAt: z.ZodOptional<z.ZodNullable<z.ZodDate>>;
|
|
30
31
|
scope: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
31
|
-
provider: z.ZodString;
|
|
32
32
|
accountType: z.ZodString;
|
|
33
33
|
providerAccountId: z.ZodString;
|
|
34
34
|
handle: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
@@ -46,13 +46,13 @@ export declare const connectListInputSchema: z.ZodObject<{
|
|
|
46
46
|
}, z.core.$strip>;
|
|
47
47
|
export type ConnectListInputSchema = z.infer<typeof connectListInputSchema>;
|
|
48
48
|
export declare const connectListOutputSchema: z.ZodArray<z.ZodObject<{
|
|
49
|
+
provider: z.ZodString;
|
|
49
50
|
id: z.ZodString;
|
|
50
51
|
createdAt: z.ZodDate;
|
|
51
52
|
updatedAt: z.ZodOptional<z.ZodNullable<z.ZodDate>>;
|
|
52
|
-
expiresAt: z.ZodOptional<z.ZodNullable<z.ZodDate>>;
|
|
53
53
|
userId: z.ZodString;
|
|
54
|
+
expiresAt: z.ZodOptional<z.ZodNullable<z.ZodDate>>;
|
|
54
55
|
scope: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
55
|
-
provider: z.ZodString;
|
|
56
56
|
accountType: z.ZodString;
|
|
57
57
|
providerAccountId: z.ZodString;
|
|
58
58
|
handle: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
@@ -8,7 +8,7 @@ exports.exchangeCodeForTokens = exchangeCodeForTokens;
|
|
|
8
8
|
exports.refreshAccessToken = refreshAccessToken;
|
|
9
9
|
const tslib_1 = require("tslib");
|
|
10
10
|
const client = tslib_1.__importStar(require("openid-client"));
|
|
11
|
-
const logger_1 = require("
|
|
11
|
+
const logger_1 = require("../../utils/logger");
|
|
12
12
|
// In-memory store for OAuth state (keyed by sessionId + provider)
|
|
13
13
|
// In production, consider using Redis with TTL
|
|
14
14
|
const oauthStateStore = new Map();
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { InferInsertModel, InferSelectModel } from "drizzle-orm";
|
|
2
2
|
import type { LibSQLDatabase } from "drizzle-orm/libsql";
|
|
3
|
-
import { BaseTableRepository } from "
|
|
4
|
-
import type { ConnectListInputSchema } from "
|
|
3
|
+
import { BaseTableRepository } from "../base/base.repository";
|
|
4
|
+
import type { ConnectListInputSchema } from "./connect.dto";
|
|
5
5
|
declare const schema: {
|
|
6
6
|
connect: import("drizzle-orm/sqlite-core").SQLiteTableWithColumns<{
|
|
7
7
|
name: "connect";
|
|
@@ -389,15 +389,15 @@ export declare class ConnectRepository extends BaseTableRepository<Orm, Schema,
|
|
|
389
389
|
updatedAt: Date | null;
|
|
390
390
|
}[]>>;
|
|
391
391
|
upsert(data: ConnectInsert, tx?: Orm): Promise<import("../base/base.dto").ServerResult<{
|
|
392
|
+
provider: string;
|
|
392
393
|
id: string;
|
|
393
394
|
createdAt: Date;
|
|
394
395
|
updatedAt: Date | null;
|
|
395
|
-
expiresAt: Date | null;
|
|
396
396
|
userId: string;
|
|
397
|
+
expiresAt: Date | null;
|
|
397
398
|
accessToken: string;
|
|
398
399
|
refreshToken: string | null;
|
|
399
400
|
scope: string | null;
|
|
400
|
-
provider: string;
|
|
401
401
|
accountType: string;
|
|
402
402
|
providerAccountId: string;
|
|
403
403
|
handle: string | null;
|
|
@@ -4,8 +4,8 @@ exports.ConnectRepository = void 0;
|
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
5
|
const drizzle_orm_1 = require("drizzle-orm");
|
|
6
6
|
const neverthrow_1 = require("neverthrow");
|
|
7
|
-
const base_repository_1 = require("
|
|
8
|
-
const connect = tslib_1.__importStar(require("
|
|
7
|
+
const base_repository_1 = require("../base/base.repository");
|
|
8
|
+
const connect = tslib_1.__importStar(require("./connect.db"));
|
|
9
9
|
const schema = { ...connect };
|
|
10
10
|
class ConnectRepository extends base_repository_1.BaseTableRepository {
|
|
11
11
|
async list(data, tx) {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { Router } from "express";
|
|
2
|
-
import type { AuthMiddleware } from "
|
|
2
|
+
import type { AuthMiddleware } from "../auth/auth.middleware";
|
|
3
3
|
import type { ConnectService } from "./connect.service";
|
|
4
4
|
export declare function createConnectRouter(authMiddleware: AuthMiddleware, connectService: ConnectService): Router;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import type { User } from "
|
|
2
|
-
import type { ServerResultAsync } from "
|
|
3
|
-
import { BaseService } from "
|
|
4
|
-
import type { ConnectDeleteInputSchema, ConnectListInputSchema } from "
|
|
1
|
+
import type { User } from "../auth/auth.lib";
|
|
2
|
+
import type { ServerResultAsync } from "../base/base.dto";
|
|
3
|
+
import { BaseService } from "../base/base.service";
|
|
4
|
+
import type { ConnectDeleteInputSchema, ConnectListInputSchema } from "./connect.dto";
|
|
5
5
|
import type { ConnectRepository } from "./connect.repository";
|
|
6
6
|
import type { ConnectProvider } from "./connect.types";
|
|
7
7
|
export declare class ConnectService extends BaseService<{
|
|
@@ -15,16 +15,16 @@ export declare class ConnectService extends BaseService<{
|
|
|
15
15
|
startAuth(_user: User, sessionId: string, providerId: string): ServerResultAsync<{
|
|
16
16
|
url: string;
|
|
17
17
|
}>;
|
|
18
|
-
handleCallback(user: User, sessionId: string, providerId: string, code: string, state: string): Promise<import("
|
|
18
|
+
handleCallback(user: User, sessionId: string, providerId: string, code: string, state: string): Promise<import("../base/base.dto").ServerResult<{
|
|
19
|
+
provider: string;
|
|
19
20
|
id: string;
|
|
20
21
|
createdAt: Date;
|
|
21
22
|
updatedAt: Date | null;
|
|
22
|
-
expiresAt: Date | null;
|
|
23
23
|
userId: string;
|
|
24
|
+
expiresAt: Date | null;
|
|
24
25
|
accessToken: string;
|
|
25
26
|
refreshToken: string | null;
|
|
26
27
|
scope: string | null;
|
|
27
|
-
provider: string;
|
|
28
28
|
accountType: string;
|
|
29
29
|
providerAccountId: string;
|
|
30
30
|
handle: string | null;
|
|
@@ -36,16 +36,16 @@ export declare class ConnectService extends BaseService<{
|
|
|
36
36
|
revokedAt: Date | null;
|
|
37
37
|
lastRefreshedAt: Date | null;
|
|
38
38
|
}>>;
|
|
39
|
-
refreshToken(connectionId: string): Promise<import("
|
|
39
|
+
refreshToken(connectionId: string): Promise<import("../base/base.dto").ServerResult<{
|
|
40
|
+
provider: string;
|
|
40
41
|
id: string;
|
|
41
42
|
createdAt: Date;
|
|
42
43
|
updatedAt: Date | null;
|
|
43
|
-
expiresAt: Date | null;
|
|
44
44
|
userId: string;
|
|
45
|
+
expiresAt: Date | null;
|
|
45
46
|
accessToken: string;
|
|
46
47
|
refreshToken: string | null;
|
|
47
48
|
scope: string | null;
|
|
48
|
-
provider: string;
|
|
49
49
|
accountType: string;
|
|
50
50
|
providerAccountId: string;
|
|
51
51
|
handle: string | null;
|
|
@@ -59,7 +59,7 @@ export declare class ConnectService extends BaseService<{
|
|
|
59
59
|
}>>;
|
|
60
60
|
list(input: ConnectListInputSchema, { user }: {
|
|
61
61
|
user: User;
|
|
62
|
-
}): Promise<import("
|
|
62
|
+
}): Promise<import("../base/base.dto").ServerResult<{
|
|
63
63
|
id: string;
|
|
64
64
|
userId: string;
|
|
65
65
|
provider: string;
|
|
@@ -82,7 +82,7 @@ export declare class ConnectService extends BaseService<{
|
|
|
82
82
|
}[]>>;
|
|
83
83
|
delete({ id }: ConnectDeleteInputSchema, { user }: {
|
|
84
84
|
user: User;
|
|
85
|
-
}): Promise<import("
|
|
85
|
+
}): Promise<import("../base/base.dto").ServerResult<{
|
|
86
86
|
id: string;
|
|
87
87
|
}>>;
|
|
88
88
|
}
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.ConnectService = void 0;
|
|
4
4
|
const neverthrow_1 = require("neverthrow");
|
|
5
|
-
const base_service_1 = require("
|
|
5
|
+
const base_service_1 = require("../base/base.service");
|
|
6
6
|
const connect_oauth_1 = require("./connect.oauth");
|
|
7
7
|
class ConnectService extends base_service_1.BaseService {
|
|
8
8
|
providers = new Map();
|
|
@@ -1,44 +1,8 @@
|
|
|
1
|
+
import { type TRPCMethods } from "../../utils/trpc";
|
|
1
2
|
import type { ConnectService } from "./connect.service";
|
|
2
|
-
export declare function createConnectTRPC(connectService: ConnectService): import("@trpc/server").TRPCBuiltRouter<{
|
|
3
|
-
ctx:
|
|
4
|
-
|
|
5
|
-
id: string;
|
|
6
|
-
createdAt: Date;
|
|
7
|
-
updatedAt: Date;
|
|
8
|
-
expiresAt: Date;
|
|
9
|
-
token: string;
|
|
10
|
-
ipAddress: string | null;
|
|
11
|
-
userAgent: string | null;
|
|
12
|
-
userId: string;
|
|
13
|
-
impersonatedBy: string | null;
|
|
14
|
-
activeOrganizationId: string | null;
|
|
15
|
-
activeOrganizationRole: string | null;
|
|
16
|
-
activeTeamId: string | null;
|
|
17
|
-
activeTeamRole: string | null;
|
|
18
|
-
};
|
|
19
|
-
user: {
|
|
20
|
-
id: string;
|
|
21
|
-
name: string;
|
|
22
|
-
email: string;
|
|
23
|
-
emailVerified: boolean;
|
|
24
|
-
image: string | null;
|
|
25
|
-
createdAt: Date;
|
|
26
|
-
updatedAt: 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;
|
|
3
|
+
export declare function createConnectTRPC({ router, privateProcedure: procedure }: TRPCMethods, connectService: ConnectService): import("@trpc/server").TRPCBuiltRouter<{
|
|
4
|
+
ctx: import("../auth/auth.lib").Context;
|
|
5
|
+
meta: any;
|
|
42
6
|
errorShape: import("@trpc/server").TRPCDefaultErrorShape;
|
|
43
7
|
transformer: true;
|
|
44
8
|
}, import("@trpc/server").TRPCDecorateCreateRouterOptions<{
|
|
@@ -48,10 +12,10 @@ export declare function createConnectTRPC(connectService: ConnectService): impor
|
|
|
48
12
|
inactive?: boolean | undefined;
|
|
49
13
|
};
|
|
50
14
|
output: {
|
|
15
|
+
provider: string;
|
|
51
16
|
id: string;
|
|
52
17
|
createdAt: Date;
|
|
53
18
|
userId: string;
|
|
54
|
-
provider: string;
|
|
55
19
|
accountType: string;
|
|
56
20
|
providerAccountId: string;
|
|
57
21
|
updatedAt?: Date | null | undefined;
|
|
@@ -66,7 +30,7 @@ export declare function createConnectTRPC(connectService: ConnectService): impor
|
|
|
66
30
|
revokedAt?: Date | null | undefined;
|
|
67
31
|
lastRefreshedAt?: Date | null | undefined;
|
|
68
32
|
}[];
|
|
69
|
-
meta:
|
|
33
|
+
meta: any;
|
|
70
34
|
}>;
|
|
71
35
|
delete: import("@trpc/server").TRPCMutationProcedure<{
|
|
72
36
|
input: {
|
|
@@ -75,6 +39,6 @@ export declare function createConnectTRPC(connectService: ConnectService): impor
|
|
|
75
39
|
output: {
|
|
76
40
|
id: string;
|
|
77
41
|
};
|
|
78
|
-
meta:
|
|
42
|
+
meta: any;
|
|
79
43
|
}>;
|
|
80
44
|
}>>;
|
|
@@ -1,21 +1,21 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.createConnectTRPC = createConnectTRPC;
|
|
4
|
-
const
|
|
4
|
+
const trpc_1 = require("../../utils/trpc");
|
|
5
5
|
const connect_dto_1 = require("./connect.dto");
|
|
6
|
-
function createConnectTRPC(connectService) {
|
|
7
|
-
return
|
|
8
|
-
list:
|
|
6
|
+
function createConnectTRPC({ router, privateProcedure: procedure }, connectService) {
|
|
7
|
+
return router({
|
|
8
|
+
list: procedure
|
|
9
9
|
.input(connect_dto_1.connectListInputSchema)
|
|
10
10
|
.output(connect_dto_1.connectListOutputSchema)
|
|
11
11
|
.query(async ({ ctx, input }) => {
|
|
12
|
-
return (0,
|
|
12
|
+
return (0, trpc_1.handleTRPCResult)(await connectService.list(input, ctx));
|
|
13
13
|
}),
|
|
14
|
-
delete:
|
|
14
|
+
delete: procedure
|
|
15
15
|
.input(connect_dto_1.connectDeleteInputSchema)
|
|
16
16
|
.output(connect_dto_1.connectDeleteOutputSchema)
|
|
17
17
|
.mutation(async ({ ctx, input }) => {
|
|
18
|
-
return (0,
|
|
18
|
+
return (0, trpc_1.handleTRPCResult)(await connectService.delete(input, ctx));
|
|
19
19
|
}),
|
|
20
20
|
});
|
|
21
21
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { LibSQLDatabase } from "drizzle-orm/libsql";
|
|
2
|
-
import { BaseTableRepository } from "
|
|
2
|
+
import { BaseTableRepository } from "../base/base.repository";
|
|
3
3
|
declare const schema: {
|
|
4
4
|
cryptoPayments: import("drizzle-orm/sqlite-core").SQLiteTableWithColumns<{
|
|
5
5
|
name: "crypto_payments";
|
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.CryptoRepository = void 0;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
|
-
const base_repository_1 = require("
|
|
6
|
-
const crypto = tslib_1.__importStar(require("
|
|
5
|
+
const base_repository_1 = require("../base/base.repository");
|
|
6
|
+
const crypto = tslib_1.__importStar(require("./crypto.db"));
|
|
7
7
|
const schema = { ...crypto };
|
|
8
8
|
class CryptoRepository extends base_repository_1.BaseTableRepository {
|
|
9
9
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { BaseService } from "
|
|
2
|
-
import type { ServerResult } from "
|
|
3
|
-
import type { CryptoRepository } from "
|
|
1
|
+
import { BaseService } from "../base/base.service";
|
|
2
|
+
import type { ServerResult } from "../base/base.dto";
|
|
3
|
+
import type { CryptoRepository } from "./crypto.repository";
|
|
4
4
|
export declare class CryptoService extends BaseService<{
|
|
5
5
|
crypto: CryptoRepository;
|
|
6
6
|
}, Record<string, never>> {
|
|
@@ -7,7 +7,7 @@ const bip39 = tslib_1.__importStar(require("bip39"));
|
|
|
7
7
|
const bitcoin = tslib_1.__importStar(require("bitcoinjs-lib"));
|
|
8
8
|
const ecc = tslib_1.__importStar(require("tiny-secp256k1"));
|
|
9
9
|
const neverthrow_1 = require("neverthrow");
|
|
10
|
-
const base_service_1 = require("
|
|
10
|
+
const base_service_1 = require("../base/base.service");
|
|
11
11
|
const BITCOIN_NATIVE_SEGWIT_PATH = "m/84'/0'/0'/0";
|
|
12
12
|
const bip32 = (0, bip32_1.default)(ecc);
|
|
13
13
|
class CryptoService extends base_service_1.BaseService {
|
|
@@ -4,7 +4,7 @@ exports.EmailService = void 0;
|
|
|
4
4
|
const neverthrow_1 = require("neverthrow");
|
|
5
5
|
const react_1 = require("react");
|
|
6
6
|
const resend_1 = require("resend");
|
|
7
|
-
const base_service_1 = require("
|
|
7
|
+
const base_service_1 = require("../base/base.service");
|
|
8
8
|
class EmailService extends base_service_1.BaseService {
|
|
9
9
|
client;
|
|
10
10
|
brand;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { type GetObjectCommandOutput } from "@aws-sdk/client-s3";
|
|
2
|
-
import type { ServerResultAsync } from "
|
|
3
|
-
import { BaseExternaRepository } from "
|
|
2
|
+
import type { ServerResultAsync } from "../base/base.dto";
|
|
3
|
+
import { BaseExternaRepository } from "../base/base.repository";
|
|
4
4
|
export declare class FileRepository extends BaseExternaRepository {
|
|
5
5
|
private readonly s3;
|
|
6
6
|
constructor();
|
|
@@ -4,7 +4,7 @@ exports.FileRepository = void 0;
|
|
|
4
4
|
const client_s3_1 = require("@aws-sdk/client-s3");
|
|
5
5
|
const s3_request_presigner_1 = require("@aws-sdk/s3-request-presigner");
|
|
6
6
|
const neverthrow_1 = require("neverthrow");
|
|
7
|
-
const base_repository_1 = require("
|
|
7
|
+
const base_repository_1 = require("../base/base.repository");
|
|
8
8
|
class FileRepository extends base_repository_1.BaseExternaRepository {
|
|
9
9
|
s3;
|
|
10
10
|
constructor() {
|
|
@@ -8,8 +8,8 @@ const body_parser_1 = tslib_1.__importDefault(require("body-parser"));
|
|
|
8
8
|
const express_1 = tslib_1.__importDefault(require("express"));
|
|
9
9
|
const multer_1 = tslib_1.__importDefault(require("multer"));
|
|
10
10
|
const uuid_1 = require("uuid");
|
|
11
|
-
const file_repository_1 = require("
|
|
12
|
-
const file_service_1 = require("
|
|
11
|
+
const file_repository_1 = require("./file.repository");
|
|
12
|
+
const file_service_1 = require("./file.service");
|
|
13
13
|
const fileRepository = new file_repository_1.FileRepository();
|
|
14
14
|
const fileService = new file_service_1.FileService({ file: fileRepository });
|
|
15
15
|
function validateMimeType(type, file) {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { fileTypes } from "@m5kdev/commons/modules/file/file.constants";
|
|
2
|
-
import type { ServerResult, ServerResultAsync } from "
|
|
3
|
-
import { BaseService } from "
|
|
4
|
-
import type { FileRepository } from "
|
|
2
|
+
import type { ServerResult, ServerResultAsync } from "../base/base.dto";
|
|
3
|
+
import { BaseService } from "../base/base.service";
|
|
4
|
+
import type { FileRepository } from "./file.repository";
|
|
5
5
|
export declare class FileService extends BaseService<{
|
|
6
6
|
file: FileRepository;
|
|
7
7
|
}, never> {
|
|
@@ -11,7 +11,7 @@ const promises_2 = require("node:stream/promises");
|
|
|
11
11
|
const file_constants_1 = require("@m5kdev/commons/modules/file/file.constants");
|
|
12
12
|
const neverthrow_1 = require("neverthrow");
|
|
13
13
|
const uuid_1 = require("uuid");
|
|
14
|
-
const base_service_1 = require("
|
|
14
|
+
const base_service_1 = require("../base/base.service");
|
|
15
15
|
class FileService extends base_service_1.BaseService {
|
|
16
16
|
isS3Path(path) {
|
|
17
17
|
return path.startsWith("s3::");
|