@m5kdev/backend 0.4.0 → 0.5.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.
@@ -0,0 +1,5 @@
1
+ import { Prompt } from "./ai.prompt";
2
+ export declare const repairJsonPrompt: Prompt<{
3
+ text: string;
4
+ error: string;
5
+ }>;
@@ -0,0 +1,16 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.repairJsonPrompt = void 0;
4
+ const ai_prompt_1 = require("./ai.prompt");
5
+ exports.repairJsonPrompt = new ai_prompt_1.Prompt(`
6
+ You are a JSON repair expert. You are given a JSON string that is invalid, error message and a schema that is used to parse the JSON string. You need to repair the JSON string and return the repaired JSON adher to the schema.
7
+
8
+ ## Text
9
+
10
+ {{text}}
11
+
12
+ ## Error
13
+
14
+ {{error}}
15
+
16
+ `);
@@ -3,10 +3,10 @@ import type { Mastra } from "@mastra/core";
3
3
  import type { FullOutput, MastraModelOutput } from "@mastra/core/stream";
4
4
  import { MDocument } from "@mastra/rag";
5
5
  import type { OpenRouterProvider } from "@openrouter/ai-sdk-provider";
6
- import { generateObject, generateText } from "ai";
6
+ import { generateText, type ModelMessage } from "ai";
7
7
  import type Replicate from "replicate";
8
8
  import type { ZodType, z } from "zod";
9
- import type { User } from "../auth/auth.lib";
9
+ import type { Context, User } from "../auth/auth.lib";
10
10
  import type { ServerResultAsync } from "../base/base.dto";
11
11
  import { BaseService } from "../base/base.service";
12
12
  import type { AiUsageRepository, AiUsageRow } from "./ai.repository";
@@ -18,6 +18,26 @@ type MessageListInput = {
18
18
  role: "user" | "assistant" | "system";
19
19
  content: string;
20
20
  }[];
21
+ type GenerateTextParams = Parameters<typeof generateText>[0];
22
+ type GenerateTextInput = {
23
+ prompt: string | ModelMessage[];
24
+ messages?: never;
25
+ } | {
26
+ messages: ModelMessage[];
27
+ prompt?: never;
28
+ };
29
+ type AIServiceGenerateTextParams = Omit<GenerateTextParams, "model" | "prompt" | "messages"> & GenerateTextInput & {
30
+ model: string;
31
+ removeMDash?: boolean;
32
+ ctx?: Context;
33
+ };
34
+ type AIServiceGenerateObjectParams<T extends ZodType> = Omit<GenerateTextParams, "model" | "prompt" | "messages" | "output"> & GenerateTextInput & {
35
+ model: string;
36
+ schema: T;
37
+ repairAttempts?: number;
38
+ repairModel?: string;
39
+ ctx?: Context;
40
+ };
21
41
  export declare class AIService<MastraInstance extends Mastra> extends BaseService<{
22
42
  aiUsage?: AiUsageRepository;
23
43
  }, {
@@ -39,8 +59,8 @@ export declare class AIService<MastraInstance extends Mastra> extends BaseServic
39
59
  replicate?: Replicate;
40
60
  });
41
61
  getMastra(): MastraInstance;
42
- prepareModel(model: string): any;
43
- prepareEmbeddingModel(model: string): any;
62
+ prepareModel(model: string): ReturnType<OpenRouterProvider["chat"]>;
63
+ prepareEmbeddingModel(model: string): ReturnType<OpenRouterProvider["textEmbeddingModel"]>;
44
64
  agentUse(agent: string, options: MastraAgentGenerateOptions & {
45
65
  prompt?: string;
46
66
  messages?: MessageListInput;
@@ -94,14 +114,8 @@ export declare class AIService<MastraInstance extends Mastra> extends BaseServic
94
114
  }[], model?: string): ServerResultAsync<{
95
115
  embeddings: number[][];
96
116
  }>;
97
- generateText(params: Omit<Parameters<typeof generateText>[0], "model"> & {
98
- model: string;
99
- removeMDash?: boolean;
100
- }): ServerResultAsync<string>;
101
- generateObject<T extends ZodType>(params: Omit<Parameters<typeof generateObject<T>>[0], "model" | "schema"> & {
102
- model: string;
103
- schema: T;
104
- }): ServerResultAsync<z.infer<T>>;
117
+ generateText(params: AIServiceGenerateTextParams): ServerResultAsync<string>;
118
+ generateObject<T extends ZodType>(params: AIServiceGenerateObjectParams<T>): ServerResultAsync<z.infer<T>>;
105
119
  generateReplicate(model: Parameters<Replicate["run"]>[0], options: Parameters<Replicate["run"]>[1]): ServerResultAsync<object>;
106
120
  generateTranscript(file_url: string): ServerResultAsync<{
107
121
  text: string;
@@ -6,8 +6,10 @@ const ai_utils_1 = require("@m5kdev/commons/modules/ai/ai.utils");
6
6
  const request_context_1 = require("@mastra/core/request-context");
7
7
  const rag_1 = require("@mastra/rag");
8
8
  const ai_1 = require("ai");
9
+ const jsonrepair_1 = require("jsonrepair");
9
10
  const neverthrow_1 = require("neverthrow");
10
11
  const base_service_1 = require("../base/base.service");
12
+ const ai_prompts_1 = require("./ai.prompts");
11
13
  class AIService extends base_service_1.BaseService {
12
14
  helpers = {
13
15
  arrayToPseudoXML: ai_utils_1.arrayToPseudoXML,
@@ -31,15 +33,19 @@ class AIService extends base_service_1.BaseService {
31
33
  if (!this.openrouter) {
32
34
  throw new Error("OpenRouter is not configured");
33
35
  }
34
- const openrouterModel = this.openrouter.chat(model);
35
- return openrouterModel;
36
+ return this.openrouter.chat(model, {
37
+ usage: {
38
+ include: true,
39
+ },
40
+ });
36
41
  }
37
42
  prepareEmbeddingModel(model) {
38
43
  if (!this.openrouter) {
39
44
  throw new Error("OpenRouter is not configured");
40
45
  }
41
- const openrouterModel = this.openrouter.textEmbeddingModel(model);
42
- return openrouterModel;
46
+ const openrouter = this.openrouter;
47
+ return (openrouter.embeddingModel?.(model) ??
48
+ openrouter.textEmbeddingModel(model));
43
49
  }
44
50
  async agentUse(agent, options, ctx) {
45
51
  return this.throwableAsync(async () => {
@@ -146,21 +152,105 @@ class AIService extends base_service_1.BaseService {
146
152
  }
147
153
  async generateText(params) {
148
154
  return this.throwableAsync(async () => {
149
- const { removeMDash = true, model, ...rest } = params;
150
- const result = await (0, ai_1.generateText)({ ...rest, model: this.prepareModel(model) });
155
+ const { removeMDash = true, model, prompt, messages, ctx, ...rest } = params;
156
+ const request = messages
157
+ ? { ...rest, model: this.prepareModel(model), messages }
158
+ : { ...rest, model: this.prepareModel(model), prompt };
159
+ const result = await (0, ai_1.generateText)(request);
160
+ if (this.repository.aiUsage) {
161
+ const createUsageResult = await this.repository.aiUsage.create({
162
+ userId: ctx?.user?.id,
163
+ model,
164
+ provider: "openrouter",
165
+ feature: "generateText",
166
+ traceId: result.providerMetadata?.openrouter?.traceId?.toString(),
167
+ inputTokens: result.usage.inputTokens,
168
+ outputTokens: result.usage.outputTokens,
169
+ totalTokens: result.usage.totalTokens,
170
+ cost: result?.providerMetadata?.openrouter?.usage?.cost ?? 0,
171
+ });
172
+ if (createUsageResult.isErr())
173
+ return (0, neverthrow_1.err)(createUsageResult.error);
174
+ }
151
175
  return (0, neverthrow_1.ok)(removeMDash ? result.text.replace(/\u2013|\u2014/g, "-") : result.text);
152
176
  });
153
177
  }
154
178
  async generateObject(params) {
155
- return this.throwableAsync(async () => {
156
- const model = this.prepareModel(params.model);
157
- const result = await (0, ai_1.generateObject)({
158
- ...params,
159
- model,
160
- schema: params.schema,
161
- });
162
- return (0, neverthrow_1.ok)(result.object);
163
- });
179
+ const { model, schema, prompt, messages, repairAttempts = 0, repairModel, ctx, ...rest } = params;
180
+ const request = messages
181
+ ? {
182
+ ...rest,
183
+ model: this.prepareModel(model),
184
+ messages,
185
+ output: ai_1.Output.object({ schema }),
186
+ }
187
+ : {
188
+ ...rest,
189
+ model: this.prepareModel(model),
190
+ prompt,
191
+ output: ai_1.Output.object({ schema }),
192
+ };
193
+ try {
194
+ const result = await (0, ai_1.generateText)(request);
195
+ if (this.repository.aiUsage) {
196
+ const createUsageResult = await this.repository.aiUsage.create({
197
+ userId: ctx?.user?.id,
198
+ model,
199
+ provider: "openrouter",
200
+ feature: "generateObject",
201
+ traceId: result.providerMetadata?.openrouter?.traceId?.toString(),
202
+ inputTokens: result.usage.inputTokens,
203
+ outputTokens: result.usage.outputTokens,
204
+ totalTokens: result.usage.totalTokens,
205
+ cost: result?.providerMetadata?.openrouter?.usage?.cost ?? 0,
206
+ });
207
+ if (createUsageResult.isErr())
208
+ return (0, neverthrow_1.err)(createUsageResult.error);
209
+ }
210
+ return (0, neverthrow_1.ok)(result.output);
211
+ }
212
+ catch (error) {
213
+ if (ai_1.NoObjectGeneratedError.isInstance(error)) {
214
+ if (this.repository.aiUsage) {
215
+ const createUsageResult = await this.repository.aiUsage.create({
216
+ userId: ctx?.user?.id,
217
+ model,
218
+ provider: "openrouter",
219
+ feature: "generateObject",
220
+ traceId: null,
221
+ inputTokens: error?.usage?.inputTokens,
222
+ outputTokens: error?.usage?.outputTokens,
223
+ totalTokens: error?.usage?.totalTokens,
224
+ cost: 0,
225
+ });
226
+ if (createUsageResult.isErr())
227
+ return (0, neverthrow_1.err)(createUsageResult.error);
228
+ }
229
+ if (error.text) {
230
+ const repairedText = (0, jsonrepair_1.jsonrepair)(error.text);
231
+ const parsed = schema.safeParse(repairedText);
232
+ if (parsed.success)
233
+ return (0, neverthrow_1.ok)(parsed.data);
234
+ if (repairAttempts === 0)
235
+ return this.error("PARSE_ERROR", "AI: Agent object failed", { cause: error });
236
+ return this.generateObject({
237
+ ...rest,
238
+ prompt: ai_prompts_1.repairJsonPrompt.compile({
239
+ text: error.text,
240
+ error: JSON.stringify(error.cause ?? "Unknown error"),
241
+ }),
242
+ repairAttempts: repairAttempts - 1,
243
+ model: repairModel ?? model,
244
+ schema,
245
+ ctx,
246
+ });
247
+ }
248
+ return this.error("PARSE_ERROR", "AI: Agent object failed without text", {
249
+ cause: error,
250
+ });
251
+ }
252
+ return this.error("BAD_REQUEST", "AI: Provided failed to generate object", { cause: error });
253
+ }
164
254
  }
165
255
  async generateReplicate(model, options) {
166
256
  return this.throwableAsync(async () => {
@@ -10,9 +10,9 @@ export declare const waitlistSchema: z.ZodObject<{
10
10
  expiresAt: z.ZodNullable<z.ZodDate>;
11
11
  }, z.core.$strip>;
12
12
  export declare const waitlistOutputSchema: z.ZodObject<{
13
- name: z.ZodNullable<z.ZodString>;
14
13
  id: z.ZodString;
15
14
  email: z.ZodNullable<z.ZodString>;
15
+ name: z.ZodNullable<z.ZodString>;
16
16
  status: z.ZodString;
17
17
  createdAt: z.ZodDate;
18
18
  updatedAt: z.ZodNullable<z.ZodDate>;
@@ -53,9 +53,9 @@ export declare const accountClaimMagicLinkSchema: z.ZodObject<{
53
53
  createdAt: z.ZodDate;
54
54
  }, z.core.$strip>;
55
55
  export declare const accountClaimMagicLinkOutputSchema: z.ZodObject<{
56
- url: z.ZodString;
57
56
  id: z.ZodString;
58
57
  email: z.ZodString;
58
+ url: z.ZodString;
59
59
  createdAt: z.ZodDate;
60
60
  userId: z.ZodString;
61
61
  expiresAt: z.ZodNullable<z.ZodDate>;
@@ -3260,13 +3260,13 @@ export declare function createBetterAuth<O extends Orm, S extends Schema, E exte
3260
3260
  $Infer: {
3261
3261
  body: ({
3262
3262
  permission: {
3263
- readonly user?: ("get" | "delete" | "list" | "create" | "update" | "set-role" | "ban" | "impersonate" | "set-password")[] | undefined;
3263
+ readonly user?: ("get" | "update" | "set-role" | "create" | "delete" | "list" | "ban" | "impersonate" | "set-password")[] | undefined;
3264
3264
  readonly session?: ("delete" | "list" | "revoke")[] | undefined;
3265
3265
  };
3266
3266
  permissions?: never | undefined;
3267
3267
  } | {
3268
3268
  permissions: {
3269
- readonly user?: ("get" | "delete" | "list" | "create" | "update" | "set-role" | "ban" | "impersonate" | "set-password")[] | undefined;
3269
+ readonly user?: ("get" | "update" | "set-role" | "create" | "delete" | "list" | "ban" | "impersonate" | "set-password")[] | undefined;
3270
3270
  readonly session?: ("delete" | "list" | "revoke")[] | undefined;
3271
3271
  };
3272
3272
  permission?: never | undefined;
@@ -3528,7 +3528,7 @@ export declare function createBetterAuth<O extends Orm, S extends Schema, E exte
3528
3528
  id: string;
3529
3529
  organizationId: string;
3530
3530
  email: string;
3531
- role: "admin" | "member" | "owner";
3531
+ role: "member" | "owner" | "admin";
3532
3532
  status: import("better-auth/plugins", { with: { "resolution-mode": "import" } }).InvitationStatus;
3533
3533
  inviterId: string;
3534
3534
  expiresAt: Date;
@@ -3538,7 +3538,7 @@ export declare function createBetterAuth<O extends Orm, S extends Schema, E exte
3538
3538
  Member: {
3539
3539
  id: string;
3540
3540
  organizationId: string;
3541
- role: "admin" | "member" | "owner";
3541
+ role: "member" | "owner" | "admin";
3542
3542
  createdAt: Date;
3543
3543
  userId: string;
3544
3544
  teamId?: string | undefined | undefined;
@@ -3566,7 +3566,7 @@ export declare function createBetterAuth<O extends Orm, S extends Schema, E exte
3566
3566
  members: {
3567
3567
  id: string;
3568
3568
  organizationId: string;
3569
- role: "admin" | "member" | "owner";
3569
+ role: "member" | "owner" | "admin";
3570
3570
  createdAt: Date;
3571
3571
  userId: string;
3572
3572
  teamId?: string | undefined | undefined;
@@ -3581,7 +3581,7 @@ export declare function createBetterAuth<O extends Orm, S extends Schema, E exte
3581
3581
  id: string;
3582
3582
  organizationId: string;
3583
3583
  email: string;
3584
- role: "admin" | "member" | "owner";
3584
+ role: "member" | "owner" | "admin";
3585
3585
  status: import("better-auth/plugins", { with: { "resolution-mode": "import" } }).InvitationStatus;
3586
3586
  inviterId: string;
3587
3587
  expiresAt: Date;
@@ -1,8 +1,8 @@
1
1
  import type { LibSQLDatabase } from "drizzle-orm/libsql";
2
- import * as auth from "./auth.db";
3
- import type { AccountClaim, AccountClaimMagicLink, AccountClaimMagicLinkOutput, AccountClaimOutput, Waitlist, WaitlistOutput } from "./auth.dto";
4
2
  import type { ServerResultAsync } from "../base/base.dto";
5
3
  import { BaseRepository } from "../base/base.repository";
4
+ import * as auth from "./auth.db";
5
+ import type { AccountClaim, AccountClaimMagicLink, AccountClaimMagicLinkOutput, AccountClaimOutput, Waitlist, WaitlistOutput } from "./auth.dto";
6
6
  declare const schema: {
7
7
  users: import("drizzle-orm/sqlite-core").SQLiteTableWithColumns<{
8
8
  name: "users";
@@ -5,8 +5,8 @@ const tslib_1 = require("tslib");
5
5
  const drizzle_orm_1 = require("drizzle-orm");
6
6
  const neverthrow_1 = require("neverthrow");
7
7
  const uuid_1 = require("uuid");
8
- const auth = tslib_1.__importStar(require("./auth.db"));
9
8
  const base_repository_1 = require("../base/base.repository");
9
+ const auth = tslib_1.__importStar(require("./auth.db"));
10
10
  const schema = { ...auth };
11
11
  function parseOrganizationMetadata(metadata) {
12
12
  if (!metadata)
@@ -1,10 +1,10 @@
1
- import type { AccountClaim, AccountClaimMagicLinkOutput, AccountClaimOutput, Waitlist, WaitlistOutput } from "./auth.dto";
2
- import type { Context, User } from "./auth.lib";
3
- import type { AuthRepository } from "./auth.repository";
4
1
  import type { ServerResultAsync } from "../base/base.dto";
5
2
  import { BaseService } from "../base/base.service";
6
3
  import type { BillingService } from "../billing/billing.service";
7
4
  import type { EmailService } from "../email/email.service";
5
+ import type { AccountClaim, AccountClaimMagicLinkOutput, AccountClaimOutput, Waitlist, WaitlistOutput } from "./auth.dto";
6
+ import type { Context, User } from "./auth.lib";
7
+ import type { AuthRepository } from "./auth.repository";
8
8
  type AuthServiceDependencies = {
9
9
  email: EmailService;
10
10
  } | {
@@ -2,8 +2,8 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.AuthService = void 0;
4
4
  const neverthrow_1 = require("neverthrow");
5
- const base_service_1 = require("../base/base.service");
6
5
  const posthog_1 = require("../../utils/posthog");
6
+ const base_service_1 = require("../base/base.service");
7
7
  class AuthService extends base_service_1.BaseService {
8
8
  getBillingService() {
9
9
  if (!("billing" in this.service))
@@ -1,5 +1,5 @@
1
- import type { AuthService } from "./auth.service";
2
1
  import { type TRPCMethods } from "../../utils/trpc";
2
+ import type { AuthService } from "./auth.service";
3
3
  export declare function createAuthTRPC({ router, publicProcedure, privateProcedure: procedure, adminProcedure }: TRPCMethods, authService: AuthService): import("@trpc/server").TRPCBuiltRouter<{
4
4
  ctx: import("./auth.lib").Context;
5
5
  meta: any;
@@ -49,10 +49,10 @@ export declare function createAuthTRPC({ router, publicProcedure, privateProcedu
49
49
  input: void;
50
50
  output: {
51
51
  id: string;
52
+ status: string;
52
53
  createdAt: Date;
53
54
  updatedAt: Date | null;
54
55
  expiresAt: Date | null;
55
- status: string;
56
56
  claimUserId: string | null;
57
57
  claimedAt: Date | null;
58
58
  claimedEmail: string | null;
@@ -67,11 +67,11 @@ export declare function createAuthTRPC({ router, publicProcedure, privateProcedu
67
67
  output: {
68
68
  id: string;
69
69
  email: string;
70
+ url: string;
70
71
  createdAt: Date;
71
- expiresAt: Date | null;
72
72
  userId: string;
73
+ expiresAt: Date | null;
73
74
  claimId: string;
74
- url: string;
75
75
  };
76
76
  meta: any;
77
77
  }>;
@@ -82,11 +82,11 @@ export declare function createAuthTRPC({ router, publicProcedure, privateProcedu
82
82
  output: {
83
83
  id: string;
84
84
  email: string;
85
+ url: string;
85
86
  createdAt: Date;
86
- expiresAt: Date | null;
87
87
  userId: string;
88
+ expiresAt: Date | null;
88
89
  claimId: string;
89
- url: string;
90
90
  }[];
91
91
  meta: any;
92
92
  }>;
@@ -138,12 +138,12 @@ export declare function createAuthTRPC({ router, publicProcedure, privateProcedu
138
138
  listAdminWaitlist: import("@trpc/server").TRPCQueryProcedure<{
139
139
  input: void;
140
140
  output: {
141
- name: string | null;
142
141
  id: string;
143
142
  email: string | null;
143
+ name: string | null;
144
+ status: string;
144
145
  createdAt: Date;
145
146
  updatedAt: Date | null;
146
- status: string;
147
147
  }[];
148
148
  meta: any;
149
149
  }>;
@@ -152,12 +152,12 @@ export declare function createAuthTRPC({ router, publicProcedure, privateProcedu
152
152
  email: string;
153
153
  };
154
154
  output: {
155
- name: string | null;
156
155
  id: string;
157
156
  email: string | null;
157
+ name: string | null;
158
+ status: string;
158
159
  createdAt: Date;
159
160
  updatedAt: Date | null;
160
- status: string;
161
161
  };
162
162
  meta: any;
163
163
  }>;
@@ -183,12 +183,12 @@ export declare function createAuthTRPC({ router, publicProcedure, privateProcedu
183
183
  id: string;
184
184
  };
185
185
  output: {
186
- name: string | null;
187
186
  id: string;
188
187
  email: string | null;
188
+ name: string | null;
189
+ status: string;
189
190
  createdAt: Date;
190
191
  updatedAt: Date | null;
191
- status: string;
192
192
  };
193
193
  meta: any;
194
194
  }>;
@@ -197,12 +197,12 @@ export declare function createAuthTRPC({ router, publicProcedure, privateProcedu
197
197
  id: string;
198
198
  };
199
199
  output: {
200
- name: string | null;
201
200
  id: string;
202
201
  email: string | null;
202
+ name: string | null;
203
+ status: string;
203
204
  createdAt: Date;
204
205
  updatedAt: Date | null;
205
- status: string;
206
206
  };
207
207
  meta: any;
208
208
  }>;
@@ -211,12 +211,12 @@ export declare function createAuthTRPC({ router, publicProcedure, privateProcedu
211
211
  email: string;
212
212
  };
213
213
  output: {
214
- name: string | null;
215
214
  id: string;
216
215
  email: string | null;
216
+ name: string | null;
217
+ status: string;
217
218
  createdAt: Date;
218
219
  updatedAt: Date | null;
219
- status: string;
220
220
  };
221
221
  meta: any;
222
222
  }>;
@@ -2,8 +2,8 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.createAuthTRPC = createAuthTRPC;
4
4
  const zod_1 = require("zod");
5
- const auth_dto_1 = require("./auth.dto");
6
5
  const trpc_1 = require("../../utils/trpc");
6
+ const auth_dto_1 = require("./auth.dto");
7
7
  function createAuthTRPC({ router, publicProcedure, privateProcedure: procedure, adminProcedure }, authService) {
8
8
  return router({
9
9
  getUserWaitlistCount: procedure.output(zod_1.z.number()).query(async ({ ctx }) => {
@@ -16,43 +16,43 @@ export declare class ConnectService extends BaseService<{
16
16
  url: string;
17
17
  }>;
18
18
  handleCallback(user: User, sessionId: string, providerId: string, code: string, state: string): Promise<import("../base/base.dto").ServerResult<{
19
- handle: string | null;
19
+ provider: string;
20
20
  id: string;
21
21
  createdAt: Date;
22
22
  updatedAt: Date | null;
23
23
  userId: string;
24
- parentId: string | null;
25
24
  expiresAt: Date | null;
26
25
  accessToken: string;
27
26
  refreshToken: string | null;
28
27
  scope: string | null;
29
- provider: string;
30
28
  accountType: string;
31
29
  providerAccountId: string;
30
+ handle: string | null;
32
31
  displayName: string | null;
33
32
  avatarUrl: string | null;
34
33
  tokenType: string | null;
34
+ parentId: string | null;
35
35
  metadataJson: unknown;
36
36
  revokedAt: Date | null;
37
37
  lastRefreshedAt: Date | null;
38
38
  }>>;
39
39
  refreshToken(connectionId: string): Promise<import("../base/base.dto").ServerResult<{
40
- handle: string | null;
40
+ provider: string;
41
41
  id: string;
42
42
  createdAt: Date;
43
43
  updatedAt: Date | null;
44
44
  userId: string;
45
- parentId: string | null;
46
45
  expiresAt: Date | null;
47
46
  accessToken: string;
48
47
  refreshToken: string | null;
49
48
  scope: string | null;
50
- provider: string;
51
49
  accountType: string;
52
50
  providerAccountId: string;
51
+ handle: string | null;
53
52
  displayName: string | null;
54
53
  avatarUrl: string | null;
55
54
  tokenType: string | null;
55
+ parentId: string | null;
56
56
  metadataJson: unknown;
57
57
  revokedAt: Date | null;
58
58
  lastRefreshedAt: Date | null;
@@ -12,20 +12,20 @@ export declare function createConnectTRPC({ router, privateProcedure: procedure
12
12
  inactive?: boolean | undefined;
13
13
  };
14
14
  output: {
15
+ provider: string;
15
16
  id: string;
16
17
  createdAt: Date;
17
18
  userId: string;
18
- provider: string;
19
19
  accountType: string;
20
20
  providerAccountId: string;
21
- handle?: string | null | undefined;
22
21
  updatedAt?: Date | null | undefined;
23
- parentId?: string | null | undefined;
24
22
  expiresAt?: Date | null | undefined;
25
23
  scope?: string | null | undefined;
24
+ handle?: string | null | undefined;
26
25
  displayName?: string | null | undefined;
27
26
  avatarUrl?: string | null | undefined;
28
27
  tokenType?: string | null | undefined;
28
+ parentId?: string | null | undefined;
29
29
  metadataJson?: unknown;
30
30
  revokedAt?: Date | null | undefined;
31
31
  lastRefreshedAt?: Date | null | undefined;
@@ -11,11 +11,11 @@ export declare function createRecurrenceTRPC({ router, privateProcedure: procedu
11
11
  page?: number | undefined;
12
12
  limit?: number | undefined;
13
13
  sort?: string | undefined;
14
- order?: "desc" | "asc" | undefined;
14
+ order?: "asc" | "desc" | undefined;
15
15
  filters?: {
16
16
  columnId: string;
17
17
  type: "string" | "number" | "boolean" | "date" | "enum";
18
- method: "intersect" | "contains" | "equals" | "starts_with" | "ends_with" | "greater_than" | "less_than" | "on" | "between" | "before" | "after" | "oneOf" | "isEmpty" | "isNotEmpty" | "is_null" | "is_not_null";
18
+ method: "contains" | "equals" | "starts_with" | "ends_with" | "greater_than" | "less_than" | "on" | "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;
@@ -36,7 +36,7 @@ exports.taggings = (0, sqlite_core_1.sqliteTable)("taggings", {
36
36
  .$default(() => new Date()),
37
37
  tagId: (0, sqlite_core_1.text)("tag_id")
38
38
  .notNull()
39
- .references(() => exports.tags.id),
39
+ .references(() => exports.tags.id, { onDelete: "cascade" }),
40
40
  resourceType: (0, sqlite_core_1.text)("resource_type").notNull(), // e.g., "post", "image"
41
41
  resourceId: (0, sqlite_core_1.text)("resource_id").notNull(), // id in the resource table
42
42
  });
@@ -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?: "desc" | "asc" | undefined;
14
+ order?: "asc" | "desc" | undefined;
15
15
  filters?: {
16
16
  columnId: string;
17
17
  type: "string" | "number" | "boolean" | "date" | "enum";
18
- method: "intersect" | "contains" | "equals" | "starts_with" | "ends_with" | "greater_than" | "less_than" | "on" | "between" | "before" | "after" | "oneOf" | "isEmpty" | "isNotEmpty" | "is_null" | "is_not_null";
18
+ method: "contains" | "equals" | "starts_with" | "ends_with" | "greater_than" | "less_than" | "on" | "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: "intersect" | "contains" | "equals" | "starts_with" | "ends_with" | "greater_than" | "less_than" | "on" | "between" | "before" | "after" | "oneOf" | "isEmpty" | "isNotEmpty" | "is_null" | "is_not_null";
51
+ method: "contains" | "equals" | "starts_with" | "ends_with" | "greater_than" | "less_than" | "on" | "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;