@m5kdev/commons 0.1.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.
Files changed (77) hide show
  1. package/.cursor/rules/commons.mdc +27 -0
  2. package/.turbo/turbo-build.log +5 -0
  3. package/.turbo/turbo-check-types.log +5 -0
  4. package/.turbo/turbo-lint$colon$fix.log +6 -0
  5. package/.turbo/turbo-lint.log +61 -0
  6. package/LICENSE +621 -0
  7. package/dist/src/modules/ai/ai.constants.d.ts +55 -0
  8. package/dist/src/modules/ai/ai.constants.d.ts.map +1 -0
  9. package/dist/src/modules/ai/ai.constants.js +287 -0
  10. package/dist/src/modules/ai/ai.utils.d.ts +2 -0
  11. package/dist/src/modules/ai/ai.utils.d.ts.map +1 -0
  12. package/dist/src/modules/ai/ai.utils.js +10 -0
  13. package/dist/src/modules/auth/auth.schema.d.ts +21 -0
  14. package/dist/src/modules/auth/auth.schema.d.ts.map +1 -0
  15. package/dist/src/modules/auth/auth.schema.js +22 -0
  16. package/dist/src/modules/base/base.schema.d.ts +26 -0
  17. package/dist/src/modules/base/base.schema.d.ts.map +1 -0
  18. package/dist/src/modules/base/base.schema.js +18 -0
  19. package/dist/src/modules/billing/billing.schema.d.ts +23 -0
  20. package/dist/src/modules/billing/billing.schema.d.ts.map +1 -0
  21. package/dist/src/modules/billing/billing.schema.js +24 -0
  22. package/dist/src/modules/billing/billing.types.d.ts +18 -0
  23. package/dist/src/modules/billing/billing.types.d.ts.map +1 -0
  24. package/dist/src/modules/billing/billing.types.js +2 -0
  25. package/dist/src/modules/billing/billing.utils.d.ts +6 -0
  26. package/dist/src/modules/billing/billing.utils.d.ts.map +1 -0
  27. package/dist/src/modules/billing/billing.utils.js +12 -0
  28. package/dist/src/modules/file/file.constants.d.ts +5 -0
  29. package/dist/src/modules/file/file.constants.d.ts.map +1 -0
  30. package/dist/src/modules/file/file.constants.js +17 -0
  31. package/dist/src/modules/recurrence/recurrence.schema.d.ts +99 -0
  32. package/dist/src/modules/recurrence/recurrence.schema.d.ts.map +1 -0
  33. package/dist/src/modules/recurrence/recurrence.schema.js +65 -0
  34. package/dist/src/modules/schemas/query.schema.d.ts +111 -0
  35. package/dist/src/modules/schemas/query.schema.d.ts.map +1 -0
  36. package/dist/src/modules/schemas/query.schema.js +38 -0
  37. package/dist/src/modules/table/filter.types.d.ts +13 -0
  38. package/dist/src/modules/table/filter.types.d.ts.map +1 -0
  39. package/dist/src/modules/table/filter.types.js +2 -0
  40. package/dist/src/modules/tag/tag.schema.d.ts +112 -0
  41. package/dist/src/modules/tag/tag.schema.d.ts.map +1 -0
  42. package/dist/src/modules/tag/tag.schema.js +54 -0
  43. package/dist/src/modules/workflow/workflow.constants.d.ts +3 -0
  44. package/dist/src/modules/workflow/workflow.constants.d.ts.map +1 -0
  45. package/dist/src/modules/workflow/workflow.constants.js +4 -0
  46. package/dist/src/modules/workflow/workflow.schema.d.ts +93 -0
  47. package/dist/src/modules/workflow/workflow.schema.d.ts.map +1 -0
  48. package/dist/src/modules/workflow/workflow.schema.js +37 -0
  49. package/dist/src/utils/json.d.ts +3 -0
  50. package/dist/src/utils/json.d.ts.map +1 -0
  51. package/dist/src/utils/json.js +11 -0
  52. package/dist/src/utils/timezones.d.ts +15 -0
  53. package/dist/src/utils/timezones.d.ts.map +1 -0
  54. package/dist/src/utils/timezones.js +4362 -0
  55. package/dist/src/utils/trpc.d.ts +5 -0
  56. package/dist/src/utils/trpc.d.ts.map +1 -0
  57. package/dist/src/utils/trpc.js +8 -0
  58. package/dist/tsconfig.tsbuildinfo +1 -0
  59. package/package.json +75 -0
  60. package/src/modules/ai/ai.constants.ts +305 -0
  61. package/src/modules/ai/ai.utils.ts +14 -0
  62. package/src/modules/auth/auth.schema.ts +22 -0
  63. package/src/modules/base/base.schema.ts +27 -0
  64. package/src/modules/billing/billing.schema.ts +24 -0
  65. package/src/modules/billing/billing.types.ts +18 -0
  66. package/src/modules/billing/billing.utils.ts +13 -0
  67. package/src/modules/file/file.constants.ts +14 -0
  68. package/src/modules/recurrence/recurrence.schema.ts +78 -0
  69. package/src/modules/schemas/query.schema.ts +44 -0
  70. package/src/modules/table/filter.types.ts +39 -0
  71. package/src/modules/tag/tag.schema.ts +68 -0
  72. package/src/modules/workflow/workflow.constants.ts +2 -0
  73. package/src/modules/workflow/workflow.schema.ts +48 -0
  74. package/src/utils/json.ts +9 -0
  75. package/src/utils/timezones.ts +4380 -0
  76. package/src/utils/trpc.ts +6 -0
  77. package/tsconfig.json +10 -0
@@ -0,0 +1,305 @@
1
+ // Models > $1/M tokens
2
+ export const GPT_5_CHAT = "openai/gpt-5-chat";
3
+ export const GPT_5_1 = "openai/gpt-5.1";
4
+ export const GPT_5_2 = "openai/gpt-5.2";
5
+ export const GEMINI_3_1_PRO = "google/gemini-3.1-pro-preview";
6
+ export const GEMINI_2_5_PRO = "google/gemini-2.5-pro";
7
+ export const GEMINI_3_PRO = "google/gemini-3-pro-preview";
8
+ export const GEMINI_3_FLASH = "google/gemini-3-flash-preview";
9
+ export const GROK_4 = "x-ai/grok-4";
10
+ export const CLAUDE_SONNET_4 = "anthropic/claude-sonnet-4";
11
+ export const CLAUDE_SONNET_4_5 = "anthropic/claude-sonnet-4.5";
12
+ export const CLAUDE_OPUS_4_5 = "anthropic/claude-opus-4.5";
13
+ export const CLAUDE_SONNET_4_6 = "anthropic/claude-sonnet-4.6";
14
+ export const CLAUDE_OPUS_4_6 = "anthropic/claude-opus-4.6";
15
+ export const MINIMAX_M2 = "minimax/minimax-m2";
16
+ export const QWEN3_MAX = "qwen/qwen3-max";
17
+ export const O3 = "openai/o3";
18
+
19
+ // Models < $1/M tokens
20
+ export const GPT_5_MINI = "openai/gpt-5-mini";
21
+ export const GEMINI_2_5_FLASH = "google/gemini-2.5-flash";
22
+ export const GROK_3_MINI = "x-ai/grok-3-mini";
23
+ export const GROK_4_FAST = "x-ai/grok-4-fast";
24
+ export const KIMI_K2_THINKING = "moonshotai/kimi-k2-thinking";
25
+ export const KIMI_K2 = "moonshotai/kimi-k2-0905";
26
+ export const KIMI_K2_5 = "moonshotai/kimi-k2.5";
27
+ export const CLAUDE_SONNET_3_HAIKU = "anthropic/claude-3-haiku";
28
+ export const GLM_4_5V = "z-ai/glm-4.5v";
29
+ export const GLM_4_6 = "z-ai/glm-4.6";
30
+ export const DEEPSEEK_V3_1 = "deepseek/deepseek-chat-v3.1";
31
+ export const DEEPSEEK_R1 = "deepseek/deepseek-r1-0528";
32
+ export const LLAMA_3_3_70B_INSTRUCT = "meta-llama/llama-3.3-70b-instruct";
33
+ export const MISTRAL_3_1_MEDIUM = "mistralai/mistral-medium-3.1";
34
+
35
+ // Models < $0.1/M tokens
36
+ export const QWEN3_30B_A3B = "qwen/qwen3-30b-a3b";
37
+ export const GPT_5_NANO = "openai/gpt-5-nano";
38
+ export const GEMINI_2_5_FLASH_LITE = "google/gemini-2.5-flash-lite";
39
+
40
+ // Embedding Models
41
+ export const OPENAI_TEXT_EMBEDDING_3_SMALL = "openai/text-embedding-3-small";
42
+
43
+ export const AI_EMBEDDING_MODELS = [OPENAI_TEXT_EMBEDDING_3_SMALL] as const;
44
+
45
+ export type AiEmbeddingModel = (typeof AI_EMBEDDING_MODELS)[number];
46
+
47
+ // Models by utility
48
+ export const SCORER_BEST = GEMINI_3_FLASH;
49
+ export const SCORER_FAST = KIMI_K2_5;
50
+ export const RESONING_BEST = GEMINI_3_1_PRO;
51
+ export const RESONING_FAST = KIMI_K2_5;
52
+ export const STRUCTURED_OUTPUT_BEST = CLAUDE_SONNET_4_5;
53
+ export const STRUCTURED_OUTPUT_FAST = GPT_5_MINI;
54
+ export const TOOL_CALL_BEST = CLAUDE_SONNET_4_5;
55
+ export const TOOL_CALL_FAST = GPT_5_MINI;
56
+
57
+ export const AI_MODELS = [
58
+ LLAMA_3_3_70B_INSTRUCT,
59
+ QWEN3_30B_A3B,
60
+ GEMINI_2_5_PRO,
61
+ GEMINI_3_PRO,
62
+ GEMINI_3_FLASH,
63
+ DEEPSEEK_R1,
64
+ O3,
65
+ GPT_5_1,
66
+ GPT_5_2,
67
+ GPT_5_CHAT,
68
+ GROK_4,
69
+ CLAUDE_SONNET_4,
70
+ CLAUDE_SONNET_4_5,
71
+ CLAUDE_OPUS_4_5,
72
+ GPT_5_MINI,
73
+ GLM_4_5V,
74
+ MISTRAL_3_1_MEDIUM,
75
+ GEMINI_2_5_FLASH,
76
+ GROK_3_MINI,
77
+ CLAUDE_SONNET_3_HAIKU,
78
+ GPT_5_NANO,
79
+ GEMINI_2_5_FLASH_LITE,
80
+ GROK_4_FAST,
81
+ MINIMAX_M2,
82
+ KIMI_K2,
83
+ KIMI_K2_THINKING,
84
+ DEEPSEEK_V3_1,
85
+ GLM_4_6,
86
+ QWEN3_MAX,
87
+ ] as const;
88
+
89
+ export const AI_MODELS_REGISTRY: AiModelRegistry = {
90
+ [O3]: {
91
+ name: "O3",
92
+ provider: "openai",
93
+ icon: "ti-brand-openai",
94
+ tier: "pro",
95
+ order: 1,
96
+ },
97
+ [MISTRAL_3_1_MEDIUM]: {
98
+ name: "Mistral 3.1 Medium",
99
+ provider: "mistralai",
100
+ icon: "ti-ai",
101
+ tier: "pro",
102
+ order: 1,
103
+ },
104
+ [DEEPSEEK_R1]: {
105
+ name: "DeepSeek R1",
106
+ provider: "deepseek",
107
+ icon: "ti-ai",
108
+ tier: "pro",
109
+ order: 1,
110
+ },
111
+ [QWEN3_30B_A3B]: {
112
+ name: "Qwen3 30B A3B",
113
+ provider: "qwen",
114
+ icon: "ti-ai",
115
+ tier: "pro",
116
+ order: 1,
117
+ },
118
+ [LLAMA_3_3_70B_INSTRUCT]: {
119
+ name: "LLama 3.3 70B",
120
+ provider: "meta-llama",
121
+ icon: "ti-brand-meta",
122
+ tier: "pro",
123
+ order: 1,
124
+ },
125
+ [GLM_4_5V]: {
126
+ name: "GLM 4.5V",
127
+ provider: "z-ai",
128
+ icon: "ti-ai",
129
+ tier: "pro",
130
+ order: 1,
131
+ },
132
+ [GLM_4_6]: {
133
+ name: "GLM 4.6",
134
+ provider: "z-ai",
135
+ icon: "ti-ai",
136
+ tier: "pro",
137
+ order: 1,
138
+ },
139
+ [QWEN3_MAX]: {
140
+ name: "Qwen3 Max",
141
+ provider: "qwen",
142
+ icon: "ti-ai",
143
+ tier: "pro",
144
+ order: 1,
145
+ },
146
+ [DEEPSEEK_V3_1]: {
147
+ name: "DeepSeek V3.1",
148
+ provider: "deepseek",
149
+ icon: "ti-ai",
150
+ tier: "pro",
151
+ order: 1,
152
+ },
153
+ [KIMI_K2]: {
154
+ name: "Kimi K2",
155
+ provider: "moonshotai",
156
+ icon: "ti-ai",
157
+ tier: "pro",
158
+ order: 1,
159
+ },
160
+ [KIMI_K2_THINKING]: {
161
+ name: "Kimi K2 Thinking",
162
+ provider: "moonshotai",
163
+ icon: "ti-ai",
164
+ tier: "pro",
165
+ order: 1,
166
+ },
167
+ [CLAUDE_SONNET_4_5]: {
168
+ name: "Claude Sonnet 4.5",
169
+ provider: "anthropic",
170
+ icon: "ti-ai",
171
+ tier: "pro",
172
+ order: 1,
173
+ },
174
+ [GPT_5_1]: {
175
+ name: "GPT-5.1",
176
+ provider: "openai",
177
+ icon: "ti-brand-openai",
178
+ tier: "pro",
179
+ order: 1,
180
+ },
181
+ [GPT_5_2]: {
182
+ name: "GPT-5.2",
183
+ provider: "openai",
184
+ icon: "ti-brand-openai",
185
+ tier: "pro",
186
+ order: 1,
187
+ },
188
+ [MINIMAX_M2]: {
189
+ name: "MiniMax M2",
190
+ provider: "minimax",
191
+ icon: "ti-ai",
192
+ tier: "pro",
193
+ order: 1,
194
+ },
195
+ [GEMINI_2_5_PRO]: {
196
+ name: "Gemini 2.5 Pro",
197
+ provider: "google",
198
+ icon: "ti-brand-google",
199
+ tier: "pro",
200
+ order: 1,
201
+ },
202
+ [GEMINI_3_PRO]: {
203
+ name: "Gemini 3 Pro",
204
+ provider: "google",
205
+ icon: "ti-brand-google",
206
+ tier: "pro",
207
+ order: 1,
208
+ },
209
+ [GEMINI_3_FLASH]: {
210
+ name: "Gemini 3 Flash",
211
+ provider: "google",
212
+ icon: "ti-brand-google",
213
+ tier: "pro",
214
+ order: 1,
215
+ },
216
+ [GPT_5_CHAT]: {
217
+ name: "GPT-5",
218
+ provider: "openai",
219
+ icon: "ti-brand-openai",
220
+ tier: "pro",
221
+ order: 2,
222
+ },
223
+ [GROK_4]: {
224
+ name: "Grok 4",
225
+ provider: "x-ai",
226
+ icon: "ti-brand-x",
227
+ tier: "pro",
228
+ order: 3,
229
+ },
230
+ [GROK_4_FAST]: {
231
+ name: "Grok 4 Fast",
232
+ provider: "x-ai",
233
+ icon: "ti-brand-x",
234
+ tier: "pro",
235
+ order: 4,
236
+ },
237
+ [CLAUDE_SONNET_4]: {
238
+ name: "Claude Sonnet 4",
239
+ provider: "anthropic",
240
+ icon: "ti-ai",
241
+ tier: "pro",
242
+ order: 4,
243
+ },
244
+ [CLAUDE_OPUS_4_5]: {
245
+ name: "Claude Opus 4.5",
246
+ provider: "anthropic",
247
+ icon: "ti-ai",
248
+ tier: "pro",
249
+ order: 1,
250
+ },
251
+ [GPT_5_MINI]: {
252
+ name: "GPT-5 Mini",
253
+ provider: "openai",
254
+ icon: "ti-brand-openai",
255
+ tier: "standard",
256
+ order: 5,
257
+ },
258
+ [GEMINI_2_5_FLASH]: {
259
+ name: "Gemini 2.5 Flash",
260
+ provider: "google",
261
+ icon: "ti-brand-google",
262
+ tier: "standard",
263
+ order: 6,
264
+ },
265
+ [GROK_3_MINI]: {
266
+ name: "Grok 3 Mini",
267
+ provider: "x-ai",
268
+ icon: "ti-brand-x",
269
+ tier: "standard",
270
+ order: 7,
271
+ },
272
+ [CLAUDE_SONNET_3_HAIKU]: {
273
+ name: "Claude Sonnet 3 Haiku",
274
+ provider: "anthropic",
275
+ icon: "ti-brand-anthropic",
276
+ tier: "standard",
277
+ order: 8,
278
+ },
279
+ [GPT_5_NANO]: {
280
+ name: "GPT-5 Nano",
281
+ provider: "openai",
282
+ icon: "ti-brand-openai",
283
+ tier: "fast",
284
+ order: 9,
285
+ },
286
+ [GEMINI_2_5_FLASH_LITE]: {
287
+ name: "Gemini 2.5 Flash Lite",
288
+ provider: "google",
289
+ icon: "ti-brand-google",
290
+ tier: "fast",
291
+ order: 10,
292
+ },
293
+ };
294
+
295
+ export type AiModel = (typeof AI_MODELS)[number];
296
+ export type AiModelRegistry = Record<
297
+ AiModel,
298
+ {
299
+ name: string;
300
+ provider: string;
301
+ icon: string;
302
+ tier: string;
303
+ order: number;
304
+ }
305
+ >;
@@ -0,0 +1,14 @@
1
+ export function arrayToPseudoXML<T extends Record<string, unknown>>(
2
+ array: readonly T[],
3
+ keys: readonly (keyof T)[],
4
+ name = "item"
5
+ ): string {
6
+ return array
7
+ .map(
8
+ (item) =>
9
+ `<${name}>${keys
10
+ .map((key) => `<${String(key)}>${String(item[key])}</${String(key)}>`)
11
+ .join("\n")}</${name}>`
12
+ )
13
+ .join("\n");
14
+ }
@@ -0,0 +1,22 @@
1
+ import { z } from "zod";
2
+
3
+ export const userSchema = z.object({
4
+ id: z.string(),
5
+ name: z.string(),
6
+ email: z.string(),
7
+ emailVerified: z.boolean(),
8
+ image: z.string().nullable(),
9
+ createdAt: z.date(),
10
+ updatedAt: z.date(),
11
+ role: z.string().nullable(),
12
+ banned: z.boolean().nullable(),
13
+ banReason: z.string().nullable(),
14
+ banExpires: z.date().nullable(),
15
+ paymentCustomerId: z.string().nullable(),
16
+ paymentPlanTier: z.string().nullable(),
17
+ paymentPlanExpiresAt: z.date().nullable(),
18
+ preferences: z.string().nullable(),
19
+ onboarding: z.boolean().nullable(),
20
+ });
21
+
22
+ export type UserSchema = z.infer<typeof userSchema>;
@@ -0,0 +1,27 @@
1
+ import { z } from "zod";
2
+
3
+ export const uuidSchema = z.object({
4
+ id: z.uuid(),
5
+ });
6
+
7
+ export const uuidManySchema = z.object({
8
+ ids: z.array(z.uuid()),
9
+ });
10
+
11
+ export const scheduleOutputSchema = z.object({
12
+ jobId: z.string(),
13
+ });
14
+
15
+ export const scheduleManyOutputSchema = z.object({
16
+ jobIds: z.array(z.string()),
17
+ });
18
+
19
+ export const deleteOutputSchema = uuidSchema;
20
+ export const deleteManyOutputSchema = uuidManySchema;
21
+
22
+ export type UuidSchema = z.infer<typeof uuidSchema>;
23
+ export type UuidManySchema = z.infer<typeof uuidManySchema>;
24
+ export type ScheduleOutputSchema = z.infer<typeof scheduleOutputSchema>;
25
+ export type ScheduleManyOutputSchema = z.infer<typeof scheduleManyOutputSchema>;
26
+ export type DeleteOutputSchema = z.infer<typeof deleteOutputSchema>;
27
+ export type DeleteManyInputSchema = z.infer<typeof deleteManyOutputSchema>;
@@ -0,0 +1,24 @@
1
+ import { z } from "zod";
2
+
3
+ export const billingSchema = z.object({
4
+ id: z.string(),
5
+ plan: z.string(),
6
+ referenceId: z.string(),
7
+ stripeCustomerId: z.string().nullish(),
8
+ stripeSubscriptionId: z.string().nullish(),
9
+ status: z.string(),
10
+ periodStart: z.date().nullish(),
11
+ periodEnd: z.date().nullish(),
12
+ cancelAtPeriodEnd: z.boolean().nullish(),
13
+ cancelAt: z.date().nullish(),
14
+ canceledAt: z.date().nullish(),
15
+ seats: z.number().nullish(),
16
+ trialStart: z.date().nullish(),
17
+ trialEnd: z.date().nullish(),
18
+ priceId: z.string().nullish(),
19
+ interval: z.string().nullish(),
20
+ unitAmount: z.number().nullish(),
21
+ discounts: z.array(z.string()).nullish(),
22
+ });
23
+
24
+ export type BillingSchema = z.infer<typeof billingSchema>;
@@ -0,0 +1,18 @@
1
+ export type StripePlan = {
2
+ name: string;
3
+ priceId: string;
4
+ priceUnitAmount?: number;
5
+ annualDiscountPriceId?: string;
6
+ annualPriceUnitAmount?: number;
7
+ freeTrial?: {
8
+ days: number;
9
+ };
10
+ limits?: Record<string, number>;
11
+ group?: string;
12
+ };
13
+
14
+ export type StripePlansConfig = {
15
+ production: StripePlan[];
16
+ sandbox: StripePlan[];
17
+ trialPlanName?: string;
18
+ };
@@ -0,0 +1,13 @@
1
+ import type { StripePlan, StripePlansConfig } from "./billing.types";
2
+
3
+ export const getEnvironmentPlans = (
4
+ plansConfig: StripePlansConfig,
5
+ environment = "sandbox"
6
+ ): { plans: StripePlan[]; trial: StripePlan | undefined } => {
7
+ const isProduction = environment === "production";
8
+ const plans = isProduction ? plansConfig.production : plansConfig.sandbox;
9
+ const trial = plansConfig.trialPlanName
10
+ ? plans.find((plan) => plan.name === plansConfig.trialPlanName)
11
+ : undefined;
12
+ return { plans, trial };
13
+ };
@@ -0,0 +1,14 @@
1
+ export const fileTypes: Record<string, { mimetypes: string[]; extensions: string[] }> = {
2
+ image: {
3
+ mimetypes: ["image/jpeg", "image/png", "image/jpg", "image/webp"],
4
+ extensions: ["jpg", "jpeg", "png", "webp"],
5
+ },
6
+ video: {
7
+ mimetypes: ["video/mp4", "video/mov", "video/avi", "video/mkv", "video/webm"],
8
+ extensions: ["mp4", "mov", "avi", "mkv"],
9
+ },
10
+ audio: {
11
+ mimetypes: ["audio/mp3", "audio/wav", "audio/m4a", "audio/webm"],
12
+ extensions: ["mp3", "wav", "m4a", "webm"],
13
+ },
14
+ } as const;
@@ -0,0 +1,78 @@
1
+ import { z } from "zod";
2
+
3
+ // Reusable schemas for JSON-by-* fields (number or number[])
4
+ const numberOrNumberArraySchema = z.union([z.number(), z.array(z.number())]).nullish();
5
+
6
+ export const recurrenceMetadataSchema = z.record(z.string(), z.unknown()).nullish();
7
+
8
+ export const recurrenceSchema = z.object({
9
+ id: z.string(),
10
+ userId: z.string().nullish(),
11
+ organizationId: z.string().nullish(),
12
+ teamId: z.string().nullish(),
13
+ name: z.string().nullish(),
14
+ kind: z.string().nullish(),
15
+ enabled: z.boolean(),
16
+ metadata: recurrenceMetadataSchema,
17
+ createdAt: z.date(),
18
+ updatedAt: z.date(),
19
+ });
20
+
21
+ export const recurrenceRulesSchema = z.object({
22
+ id: z.string(),
23
+ createdAt: z.date(),
24
+ updatedAt: z.date(),
25
+ recurrenceId: z.string().nullish(),
26
+ freq: z.number(),
27
+ dtstart: z.date().nullish(),
28
+ interval: z.number(),
29
+ wkst: z.number().nullish(),
30
+ count: z.number().nullish(),
31
+ until: z.date().nullish(),
32
+ tzid: z.string().nullish(),
33
+ bysetpos: numberOrNumberArraySchema,
34
+ bymonth: numberOrNumberArraySchema,
35
+ bymonthday: numberOrNumberArraySchema,
36
+ byyearday: numberOrNumberArraySchema,
37
+ byweekno: numberOrNumberArraySchema,
38
+ byweekday: numberOrNumberArraySchema,
39
+ byhour: numberOrNumberArraySchema,
40
+ byminute: numberOrNumberArraySchema,
41
+ bysecond: numberOrNumberArraySchema,
42
+ });
43
+ export const updateRecurrenceRulesSchema = recurrenceRulesSchema.omit({
44
+ createdAt: true,
45
+ updatedAt: true,
46
+ recurrenceId: true,
47
+ });
48
+
49
+ export const createRecurrenceSchema = z.object({
50
+ name: z.string(),
51
+ kind: z.string(),
52
+ enabled: z.boolean(),
53
+ metadata: recurrenceMetadataSchema,
54
+ recurrenceRules: z.array(updateRecurrenceRulesSchema.omit({ id: true })),
55
+ });
56
+
57
+ export const updateRecurrenceSchema = z.object({
58
+ name: z.string().optional(),
59
+ kind: z.string().optional(),
60
+ enabled: z.boolean().optional(),
61
+ metadata: recurrenceMetadataSchema,
62
+ });
63
+
64
+ export const deleteRecurrenceSchema = z.object({
65
+ id: z.string(),
66
+ });
67
+
68
+ export const deleteRecurrenceRulesSchema = z.object({
69
+ id: z.string(),
70
+ });
71
+
72
+ export type RecurrenceSchema = z.infer<typeof recurrenceSchema>;
73
+ export type RecurrenceRulesSchema = z.infer<typeof recurrenceRulesSchema>;
74
+ export type CreateRecurrenceSchema = z.infer<typeof createRecurrenceSchema>;
75
+ export type UpdateRecurrenceSchema = z.infer<typeof updateRecurrenceSchema>;
76
+ export type UpdateRecurrenceRulesSchema = z.infer<typeof updateRecurrenceRulesSchema>;
77
+ export type DeleteRecurrenceSchema = z.infer<typeof deleteRecurrenceSchema>;
78
+ export type DeleteRecurrenceRulesSchema = z.infer<typeof deleteRecurrenceRulesSchema>;
@@ -0,0 +1,44 @@
1
+ import { z } from "zod";
2
+
3
+ export const filterSchema = z.object({
4
+ columnId: z.string(),
5
+ type: z.enum(["string", "number", "date", "boolean", "enum"]),
6
+ method: z.enum([
7
+ "contains",
8
+ "equals",
9
+ "starts_with",
10
+ "ends_with",
11
+ "greater_than",
12
+ "less_than",
13
+ "on",
14
+ "between",
15
+ "before",
16
+ "after",
17
+ "oneOf",
18
+ "intersect",
19
+ "isEmpty",
20
+ "isNotEmpty",
21
+ "is_null",
22
+ "is_not_null",
23
+ ]),
24
+ value: z.union([z.string(), z.number(), z.boolean(), z.array(z.string())]),
25
+ valueTo: z.string().optional(),
26
+ endColumnId: z.string().optional(),
27
+ });
28
+
29
+ export const filtersSchema = z.array(filterSchema);
30
+
31
+ export const querySchema = z.object({
32
+ // TODO: Remove default values
33
+ page: z.number().optional(),
34
+ limit: z.number().optional(),
35
+ sort: z.string().optional(),
36
+ order: z.enum(["asc", "desc"]).optional(),
37
+ filters: filtersSchema.optional(),
38
+ });
39
+
40
+ export type QueryListOutput<T> = { rows: T[]; total: number };
41
+
42
+ export type QueryInput = z.infer<typeof querySchema>;
43
+ export type QueryFilter = z.infer<typeof filterSchema>;
44
+ export type QueryFilters = z.infer<typeof filtersSchema>;
@@ -0,0 +1,39 @@
1
+ import type { QueryFilter } from "../schemas/query.schema";
2
+
3
+ export type ColumnDataType = NonNullable<QueryFilter["type"]>;
4
+
5
+ export type ComponentForFilterMethod =
6
+ | "text"
7
+ | "number"
8
+ | "date"
9
+ | "range"
10
+ | "radio"
11
+ | "select"
12
+ | "multiSelect";
13
+
14
+ export type FilterMethodName =
15
+ | "contains"
16
+ | "equals"
17
+ | "starts_with"
18
+ | "ends_with"
19
+ | "greater_than"
20
+ | "less_than"
21
+ | "on"
22
+ | "between"
23
+ | "before"
24
+ | "after"
25
+ | "intersect"
26
+ | "oneOf"
27
+ | "isEmpty"
28
+ | "isNotEmpty";
29
+
30
+ export type FilterMethod = {
31
+ value: FilterMethodName;
32
+ label: string;
33
+ component?: ComponentForFilterMethod | null;
34
+ };
35
+
36
+ export type FilterMethods = {
37
+ [key in ColumnDataType]: FilterMethod[];
38
+ };
39
+
@@ -0,0 +1,68 @@
1
+ import { z } from "zod";
2
+ import { querySchema } from "../schemas/query.schema";
3
+
4
+ export const tagSchema = z.object({
5
+ id: z.string(),
6
+ organizationId: z.string().nullish(),
7
+ teamId: z.string().nullish(),
8
+ createdAt: z.date(),
9
+ updatedAt: z.date().nullish(),
10
+ deletedAt: z.date().nullish(),
11
+ userId: z.string(),
12
+ name: z.string(),
13
+ color: z.string().nullish(),
14
+ type: z.string().nullish(),
15
+ isEnabled: z.boolean(),
16
+ parentId: z.string().nullish(),
17
+ assignableTo: z.string().array().nullish().default([]),
18
+ });
19
+
20
+ export const taggingSchema = z.object({
21
+ id: z.string(),
22
+ createdAt: z.date(),
23
+ tagId: z.string(),
24
+ resourceType: z.string(),
25
+ resourceId: z.string(),
26
+ });
27
+
28
+ export const tagListInputSchema = querySchema;
29
+
30
+ export const tagListOutputSchema = z.object({
31
+ rows: z.array(tagSchema),
32
+ total: z.number(),
33
+ });
34
+
35
+ export const tagListSchema = z.object({
36
+ assignableTo: z.string().optional(),
37
+ });
38
+
39
+ export const tagCreateSchema = z.object({
40
+ organizationId: z.string().optional(),
41
+ teamId: z.string().optional(),
42
+ name: z.string(),
43
+ color: z.string(),
44
+ assignableTo: z.string().array().optional().default([]),
45
+ resourceType: z.string().optional(),
46
+ resourceId: z.string().optional(),
47
+ });
48
+
49
+ export const tagUpdateSchema = z.object({
50
+ id: z.string(),
51
+ name: z.string().optional(),
52
+ color: z.string().optional(),
53
+ });
54
+
55
+ export const tagLinkSchema = z.object({
56
+ tagId: z.string(),
57
+ resourceType: z.string(),
58
+ resourceId: z.string(),
59
+ });
60
+
61
+ export type TagSchema = z.infer<typeof tagSchema>;
62
+ export type TaggingSchema = z.infer<typeof taggingSchema>;
63
+ export type TagListSchema = z.infer<typeof tagListSchema>;
64
+ export type TagCreateSchema = z.infer<typeof tagCreateSchema>;
65
+ export type TagUpdateSchema = z.infer<typeof tagUpdateSchema>;
66
+ export type TagLinkSchema = z.infer<typeof tagLinkSchema>;
67
+ export type TagListOutputSchema = z.infer<typeof tagListOutputSchema>;
68
+ export type TagListInputSchema = z.infer<typeof tagListInputSchema>;
@@ -0,0 +1,2 @@
1
+ export const WORFLOW_STATUSES = ["queued", "running", "completed", "failed"] as const;
2
+ export type WorkflowStatus = (typeof WORFLOW_STATUSES)[number];