@m5kdev/backend 0.1.1 → 0.1.3
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/.turbo/turbo-build.log +1 -1
- package/CHANGELOG.md +18 -0
- package/dist/src/lib/posthog.js +7 -0
- package/dist/src/lib/sentry.js +9 -0
- package/dist/src/modules/access/access.repository.js +32 -0
- package/dist/src/modules/access/access.service.js +51 -0
- package/dist/src/modules/access/access.test.js +182 -0
- package/dist/src/modules/access/access.utils.js +20 -0
- package/dist/src/modules/ai/ai.db.js +39 -0
- package/dist/src/modules/ai/ai.prompt.js +30 -0
- package/dist/src/modules/ai/ai.repository.js +26 -0
- package/dist/src/modules/ai/ai.router.js +132 -0
- package/dist/src/modules/ai/ai.service.js +207 -0
- package/dist/src/modules/ai/ai.trpc.d.ts +5 -5
- package/dist/src/modules/ai/ai.trpc.js +20 -0
- package/dist/src/modules/ai/ideogram/ideogram.constants.js +167 -0
- package/dist/src/modules/ai/ideogram/ideogram.dto.js +49 -0
- package/dist/src/modules/ai/ideogram/ideogram.prompt.js +860 -0
- package/dist/src/modules/ai/ideogram/ideogram.repository.js +46 -0
- package/dist/src/modules/ai/ideogram/ideogram.service.js +11 -0
- package/dist/src/modules/auth/auth.db.js +215 -0
- package/dist/src/modules/auth/auth.dto.js +38 -0
- package/dist/src/modules/auth/auth.lib.d.ts +4 -4
- package/dist/src/modules/auth/auth.lib.js +284 -0
- package/dist/src/modules/auth/auth.middleware.js +52 -0
- package/dist/src/modules/auth/auth.repository.js +541 -0
- package/dist/src/modules/auth/auth.service.js +201 -0
- package/dist/src/modules/auth/auth.trpc.d.ts +18 -18
- package/dist/src/modules/auth/auth.trpc.js +157 -0
- package/dist/src/modules/auth/auth.utils.js +97 -0
- package/dist/src/modules/base/base.abstract.js +53 -0
- package/dist/src/modules/base/base.dto.js +112 -0
- package/dist/src/modules/base/base.grants.js +123 -0
- package/dist/src/modules/base/base.grants.test.js +668 -0
- package/dist/src/modules/base/base.repository.js +307 -0
- package/dist/src/modules/base/base.service.js +109 -0
- package/dist/src/modules/base/base.types.js +2 -0
- package/dist/src/modules/billing/billing.db.js +29 -0
- package/dist/src/modules/billing/billing.repository.js +235 -0
- package/dist/src/modules/billing/billing.router.js +56 -0
- package/dist/src/modules/billing/billing.service.js +147 -0
- package/dist/src/modules/billing/billing.trpc.d.ts +5 -5
- package/dist/src/modules/billing/billing.trpc.js +17 -0
- package/dist/src/modules/clay/clay.repository.js +26 -0
- package/dist/src/modules/clay/clay.service.js +24 -0
- package/dist/src/modules/connect/connect.db.js +30 -0
- package/dist/src/modules/connect/connect.dto.js +36 -0
- package/dist/src/modules/connect/connect.linkedin.js +53 -0
- package/dist/src/modules/connect/connect.oauth.js +198 -0
- package/dist/src/modules/connect/connect.repository.d.ts +7 -7
- package/dist/src/modules/connect/connect.repository.js +54 -0
- package/dist/src/modules/connect/connect.router.js +54 -0
- package/dist/src/modules/connect/connect.service.d.ts +14 -14
- package/dist/src/modules/connect/connect.service.js +114 -0
- package/dist/src/modules/connect/connect.trpc.d.ts +10 -10
- package/dist/src/modules/connect/connect.trpc.js +21 -0
- package/dist/src/modules/connect/connect.types.js +2 -0
- package/dist/src/modules/crypto/crypto.db.js +17 -0
- package/dist/src/modules/crypto/crypto.repository.js +10 -0
- package/dist/src/modules/crypto/crypto.service.js +52 -0
- package/dist/src/modules/email/email.service.js +107 -0
- package/dist/src/modules/file/file.repository.js +79 -0
- package/dist/src/modules/file/file.router.js +99 -0
- package/dist/src/modules/file/file.service.js +150 -0
- package/dist/src/modules/recurrence/recurrence.db.js +66 -0
- package/dist/src/modules/recurrence/recurrence.repository.js +39 -0
- package/dist/src/modules/recurrence/recurrence.service.js +70 -0
- package/dist/src/modules/recurrence/recurrence.trpc.d.ts +15 -15
- package/dist/src/modules/recurrence/recurrence.trpc.js +65 -0
- package/dist/src/modules/social/social.dto.js +18 -0
- package/dist/src/modules/social/social.linkedin.js +427 -0
- package/dist/src/modules/social/social.linkedin.test.js +235 -0
- package/dist/src/modules/social/social.service.js +76 -0
- package/dist/src/modules/social/social.types.js +2 -0
- package/dist/src/modules/tag/tag.db.js +42 -0
- package/dist/src/modules/tag/tag.dto.js +9 -0
- package/dist/src/modules/tag/tag.repository.js +154 -0
- package/dist/src/modules/tag/tag.service.js +31 -0
- package/dist/src/modules/tag/tag.trpc.d.ts +5 -5
- package/dist/src/modules/tag/tag.trpc.js +47 -0
- package/dist/src/modules/utils/applyPagination.js +16 -0
- package/dist/src/modules/utils/applySorting.js +18 -0
- package/dist/src/modules/utils/getConditionsFromFilters.js +200 -0
- package/dist/src/modules/video/video.service.js +84 -0
- package/dist/src/modules/webhook/webhook.constants.js +10 -0
- package/dist/src/modules/webhook/webhook.db.js +17 -0
- package/dist/src/modules/webhook/webhook.dto.js +7 -0
- package/dist/src/modules/webhook/webhook.repository.js +56 -0
- package/dist/src/modules/webhook/webhook.router.js +30 -0
- package/dist/src/modules/webhook/webhook.service.js +68 -0
- package/dist/src/modules/workflow/workflow.db.js +30 -0
- package/dist/src/modules/workflow/workflow.repository.js +105 -0
- package/dist/src/modules/workflow/workflow.service.js +37 -0
- package/dist/src/modules/workflow/workflow.trpc.d.ts +5 -5
- package/dist/src/modules/workflow/workflow.trpc.js +21 -0
- package/dist/src/modules/workflow/workflow.types.js +2 -0
- package/dist/src/modules/workflow/workflow.utils.js +173 -0
- package/dist/src/test/stubs/utils.js +5 -0
- package/dist/src/trpc/context.d.ts +5 -5
- package/dist/src/trpc/context.js +17 -0
- package/dist/src/trpc/index.js +6 -0
- package/dist/src/trpc/procedures.d.ts +56 -56
- package/dist/src/trpc/procedures.js +32 -0
- package/dist/src/trpc/utils.js +20 -0
- package/dist/src/types.d.ts +33 -33
- package/dist/src/types.js +13 -0
- package/dist/src/utils/errors.js +104 -0
- package/dist/src/utils/logger.js +11 -0
- package/dist/src/utils/posthog.js +31 -0
- package/dist/src/utils/types.js +2 -0
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +3 -3
- package/tsconfig.json +2 -0
|
@@ -0,0 +1,207 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.AIService = void 0;
|
|
4
|
+
const ai_constants_1 = require("@m5kdev/commons/modules/ai/ai.constants");
|
|
5
|
+
const ai_utils_1 = require("@m5kdev/commons/modules/ai/ai.utils");
|
|
6
|
+
const request_context_1 = require("@mastra/core/request-context");
|
|
7
|
+
const rag_1 = require("@mastra/rag");
|
|
8
|
+
const ai_1 = require("ai");
|
|
9
|
+
const neverthrow_1 = require("neverthrow");
|
|
10
|
+
const base_service_1 = require("#modules/base/base.service");
|
|
11
|
+
class AIService extends base_service_1.BaseService {
|
|
12
|
+
helpers = {
|
|
13
|
+
arrayToPseudoXML: ai_utils_1.arrayToPseudoXML,
|
|
14
|
+
};
|
|
15
|
+
mastra;
|
|
16
|
+
openrouter;
|
|
17
|
+
replicate;
|
|
18
|
+
constructor(repositories, services, libs) {
|
|
19
|
+
super(repositories, services);
|
|
20
|
+
this.mastra = libs.mastra;
|
|
21
|
+
this.openrouter = libs.openrouter;
|
|
22
|
+
this.replicate = libs.replicate;
|
|
23
|
+
}
|
|
24
|
+
getMastra() {
|
|
25
|
+
if (!this.mastra) {
|
|
26
|
+
throw new Error("Mastra is not available");
|
|
27
|
+
}
|
|
28
|
+
return this.mastra;
|
|
29
|
+
}
|
|
30
|
+
prepareModel(model) {
|
|
31
|
+
if (!this.openrouter) {
|
|
32
|
+
throw new Error("OpenRouter is not configured");
|
|
33
|
+
}
|
|
34
|
+
const openrouterModel = this.openrouter.chat(model);
|
|
35
|
+
return openrouterModel;
|
|
36
|
+
}
|
|
37
|
+
prepareEmbeddingModel(model) {
|
|
38
|
+
if (!this.openrouter) {
|
|
39
|
+
throw new Error("OpenRouter is not configured");
|
|
40
|
+
}
|
|
41
|
+
const openrouterModel = this.openrouter.textEmbeddingModel(model);
|
|
42
|
+
return openrouterModel;
|
|
43
|
+
}
|
|
44
|
+
async agentUse(agent, options, ctx) {
|
|
45
|
+
return this.throwableAsync(async () => {
|
|
46
|
+
this.logger.info("AGENT USE");
|
|
47
|
+
const { prompt, messages, ...rest } = options;
|
|
48
|
+
const payload = messages || prompt;
|
|
49
|
+
if (!payload)
|
|
50
|
+
return this.error("BAD_REQUEST", "No prompt or messages provided");
|
|
51
|
+
const requestContext = options.requestContext ?? new request_context_1.RequestContext();
|
|
52
|
+
if (ctx?.user) {
|
|
53
|
+
requestContext.set("userId", ctx.user.id);
|
|
54
|
+
}
|
|
55
|
+
if (ctx?.model) {
|
|
56
|
+
requestContext.set("model", ctx.model);
|
|
57
|
+
}
|
|
58
|
+
const mAgent = this.getMastra().getAgent(agent);
|
|
59
|
+
const result = await mAgent.generate(payload, {
|
|
60
|
+
...rest,
|
|
61
|
+
requestContext: rest.requestContext ?? requestContext,
|
|
62
|
+
});
|
|
63
|
+
this.logger.info("AGENT USE DONE");
|
|
64
|
+
if (this.repository.aiUsage) {
|
|
65
|
+
const createUsageResult = await this.repository.aiUsage.create({
|
|
66
|
+
userId: ctx?.user?.id,
|
|
67
|
+
model: ctx?.model ?? "unknown",
|
|
68
|
+
provider: "openrouter",
|
|
69
|
+
feature: agent,
|
|
70
|
+
traceId: result.traceId,
|
|
71
|
+
inputTokens: result.usage.inputTokens,
|
|
72
|
+
outputTokens: result.usage.outputTokens,
|
|
73
|
+
totalTokens: result.usage.totalTokens,
|
|
74
|
+
cost: result?.providerMetadata?.openrouter?.usage?.cost ?? 0,
|
|
75
|
+
});
|
|
76
|
+
if (createUsageResult.isErr())
|
|
77
|
+
return (0, neverthrow_1.err)(createUsageResult.error);
|
|
78
|
+
}
|
|
79
|
+
this.logger.info("AGENT USE CREATED USAGE");
|
|
80
|
+
return (0, neverthrow_1.ok)(result);
|
|
81
|
+
});
|
|
82
|
+
}
|
|
83
|
+
async agentText(agent, options, ctx) {
|
|
84
|
+
const result = await this.agentUse(agent, options, ctx);
|
|
85
|
+
if (result.isErr())
|
|
86
|
+
return this.error("SERVICE_UNAVAILABLE", "AI: Agent text failed", { cause: result.error });
|
|
87
|
+
return (0, neverthrow_1.ok)(result.value.text);
|
|
88
|
+
}
|
|
89
|
+
async agentTextResult(agent, options, ctx) {
|
|
90
|
+
const result = await this.agentUse(agent, options, ctx);
|
|
91
|
+
if (result.isErr())
|
|
92
|
+
return (0, neverthrow_1.err)(result.error);
|
|
93
|
+
return (0, neverthrow_1.ok)(result.value);
|
|
94
|
+
}
|
|
95
|
+
async agentObject(agent, options, ctx) {
|
|
96
|
+
const { schema, ...rest } = options;
|
|
97
|
+
const result = await this.agentUse(agent, { ...rest, structuredOutput: { schema } }, ctx);
|
|
98
|
+
if (result.isErr())
|
|
99
|
+
return this.error("SERVICE_UNAVAILABLE", "AI: Agent object failed", { cause: result.error });
|
|
100
|
+
return (0, neverthrow_1.ok)(result.value.object);
|
|
101
|
+
}
|
|
102
|
+
async agentObjectResult(agent, options, ctx) {
|
|
103
|
+
this.logger.info("AGENT OBJECT RESULT");
|
|
104
|
+
const { schema, ...rest } = options;
|
|
105
|
+
const result = await this.agentUse(agent, { ...rest, structuredOutput: { schema } }, ctx);
|
|
106
|
+
if (result.isErr())
|
|
107
|
+
return (0, neverthrow_1.err)(result.error);
|
|
108
|
+
this.logger.info("AGENT OBJECT RESULT DONE");
|
|
109
|
+
return (0, neverthrow_1.ok)({ ...result.value, object: result.value.object });
|
|
110
|
+
}
|
|
111
|
+
async embedDocument(value, options, type = "text", model = ai_constants_1.OPENAI_TEXT_EMBEDDING_3_SMALL) {
|
|
112
|
+
return this.throwableAsync(async () => {
|
|
113
|
+
if (type === "text") {
|
|
114
|
+
const doc = rag_1.MDocument.fromText(value);
|
|
115
|
+
const chunks = await doc.chunk(options ?? {
|
|
116
|
+
strategy: "recursive",
|
|
117
|
+
maxSize: 512,
|
|
118
|
+
overlap: 50,
|
|
119
|
+
separators: ["\n"],
|
|
120
|
+
});
|
|
121
|
+
const embeddings = await this.embedMany(chunks, model);
|
|
122
|
+
if (embeddings.isErr())
|
|
123
|
+
return (0, neverthrow_1.err)(embeddings.error);
|
|
124
|
+
return (0, neverthrow_1.ok)({ embeddings: embeddings.value.embeddings, chunks });
|
|
125
|
+
}
|
|
126
|
+
return this.error("BAD_REQUEST", "Unsupported document type");
|
|
127
|
+
});
|
|
128
|
+
}
|
|
129
|
+
async embed(text, model = ai_constants_1.OPENAI_TEXT_EMBEDDING_3_SMALL) {
|
|
130
|
+
return this.throwableAsync(async () => {
|
|
131
|
+
const result = await (0, ai_1.embed)({
|
|
132
|
+
model: this.prepareEmbeddingModel(model),
|
|
133
|
+
value: text,
|
|
134
|
+
});
|
|
135
|
+
return (0, neverthrow_1.ok)(result);
|
|
136
|
+
});
|
|
137
|
+
}
|
|
138
|
+
async embedMany(chunks, model = ai_constants_1.OPENAI_TEXT_EMBEDDING_3_SMALL) {
|
|
139
|
+
return this.throwableAsync(async () => {
|
|
140
|
+
const result = await (0, ai_1.embedMany)({
|
|
141
|
+
model: this.prepareEmbeddingModel(model),
|
|
142
|
+
values: chunks.map((chunk) => chunk.text),
|
|
143
|
+
});
|
|
144
|
+
return (0, neverthrow_1.ok)(result);
|
|
145
|
+
});
|
|
146
|
+
}
|
|
147
|
+
async generateText(params) {
|
|
148
|
+
return this.throwableAsync(async () => {
|
|
149
|
+
const { removeMDash = true, model, ...rest } = params;
|
|
150
|
+
const result = await (0, ai_1.generateText)({ ...rest, model: this.prepareModel(model) });
|
|
151
|
+
return (0, neverthrow_1.ok)(removeMDash ? result.text.replace(/\u2013|\u2014/g, "-") : result.text);
|
|
152
|
+
});
|
|
153
|
+
}
|
|
154
|
+
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
|
+
});
|
|
164
|
+
}
|
|
165
|
+
async generateReplicate(model, options) {
|
|
166
|
+
return this.throwableAsync(async () => {
|
|
167
|
+
if (!this.replicate) {
|
|
168
|
+
return this.error("INTERNAL_SERVER_ERROR", "Replicate is not configured");
|
|
169
|
+
}
|
|
170
|
+
try {
|
|
171
|
+
return (0, neverthrow_1.ok)(await this.replicate.run(model, options));
|
|
172
|
+
}
|
|
173
|
+
catch (error) {
|
|
174
|
+
return this.error("INTERNAL_SERVER_ERROR", undefined, { cause: error });
|
|
175
|
+
}
|
|
176
|
+
});
|
|
177
|
+
}
|
|
178
|
+
async generateTranscript(file_url) {
|
|
179
|
+
const output = await this.generateReplicate("thomasmol/whisper-diarization:1495a9cddc83b2203b0d8d3516e38b80fd1572ebc4bc5700ac1da56a9b3ed886", {
|
|
180
|
+
input: {
|
|
181
|
+
file_url,
|
|
182
|
+
},
|
|
183
|
+
});
|
|
184
|
+
if (output.isErr())
|
|
185
|
+
return (0, neverthrow_1.err)(output.error);
|
|
186
|
+
try {
|
|
187
|
+
const { segments } = output.value;
|
|
188
|
+
return (0, neverthrow_1.ok)({ text: segments.map((segment) => segment.text).join(""), metadata: segments });
|
|
189
|
+
}
|
|
190
|
+
catch (error) {
|
|
191
|
+
return this.error("INTERNAL_SERVER_ERROR", undefined, { cause: error });
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
async generateIdeogram(input) {
|
|
195
|
+
if (!this.service.ideogram) {
|
|
196
|
+
return this.error("INTERNAL_SERVER_ERROR", "Ideogram service is not available");
|
|
197
|
+
}
|
|
198
|
+
return this.service.ideogram.generate(input);
|
|
199
|
+
}
|
|
200
|
+
async getUsage(userId) {
|
|
201
|
+
if (!this.repository.aiUsage) {
|
|
202
|
+
return this.error("INTERNAL_SERVER_ERROR", "AI usage repository is not available");
|
|
203
|
+
}
|
|
204
|
+
return this.repository.aiUsage.getUsage(userId);
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
exports.AIService = AIService;
|
|
@@ -5,9 +5,9 @@ export declare function createAITRPC<MastraInstance extends Mastra>(aiService: A
|
|
|
5
5
|
session: {
|
|
6
6
|
id: string;
|
|
7
7
|
userId: string;
|
|
8
|
-
expiresAt: Date;
|
|
9
|
-
createdAt: Date;
|
|
10
8
|
updatedAt: Date;
|
|
9
|
+
createdAt: Date;
|
|
10
|
+
expiresAt: Date;
|
|
11
11
|
token: string;
|
|
12
12
|
ipAddress: string | null;
|
|
13
13
|
userAgent: string | null;
|
|
@@ -19,13 +19,12 @@ export declare function createAITRPC<MastraInstance extends Mastra>(aiService: A
|
|
|
19
19
|
};
|
|
20
20
|
user: {
|
|
21
21
|
name: string;
|
|
22
|
-
image: string | null;
|
|
23
22
|
id: string;
|
|
24
|
-
createdAt: Date;
|
|
25
23
|
updatedAt: Date;
|
|
26
24
|
email: string;
|
|
27
|
-
metadata: Record<string, unknown>;
|
|
28
25
|
emailVerified: boolean;
|
|
26
|
+
image: string | null;
|
|
27
|
+
createdAt: Date;
|
|
29
28
|
role: string | null;
|
|
30
29
|
banned: boolean | null;
|
|
31
30
|
banReason: string | null;
|
|
@@ -35,6 +34,7 @@ export declare function createAITRPC<MastraInstance extends Mastra>(aiService: A
|
|
|
35
34
|
paymentPlanTier: string | null;
|
|
36
35
|
paymentPlanExpiresAt: Date | null;
|
|
37
36
|
preferences: string | null;
|
|
37
|
+
metadata: Record<string, unknown>;
|
|
38
38
|
onboarding: number | null;
|
|
39
39
|
flags: string | null;
|
|
40
40
|
};
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.createAITRPC = createAITRPC;
|
|
4
|
+
const zod_1 = require("zod");
|
|
5
|
+
const _trpc_1 = require("#trpc");
|
|
6
|
+
function createAITRPC(aiService) {
|
|
7
|
+
return (0, _trpc_1.router)({
|
|
8
|
+
getUserUsage: _trpc_1.adminProcedure
|
|
9
|
+
.input(zod_1.z.object({ userId: zod_1.z.string() }))
|
|
10
|
+
.output(zod_1.z.object({
|
|
11
|
+
inputTokens: zod_1.z.number().nullable(),
|
|
12
|
+
outputTokens: zod_1.z.number().nullable(),
|
|
13
|
+
totalTokens: zod_1.z.number().nullable(),
|
|
14
|
+
cost: zod_1.z.number().nullable(),
|
|
15
|
+
}))
|
|
16
|
+
.query(async ({ input }) => {
|
|
17
|
+
return (0, _trpc_1.handleTRPCResult)(await aiService.getUsage(input.userId));
|
|
18
|
+
}),
|
|
19
|
+
});
|
|
20
|
+
}
|
|
@@ -0,0 +1,167 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ideogramColorPalettePreset = exports.ideogramMagicPrompt = exports.ideogramRenderingSpeed = exports.ideogramAspectRatios = exports.ideogramResolutions = exports.ideogramStylePresets = exports.ideogramStyleTypes = void 0;
|
|
4
|
+
exports.ideogramStyleTypes = ["AUTO", "GENERAL", "REALISTIC", "DESIGN", "FICTION"];
|
|
5
|
+
exports.ideogramStylePresets = [
|
|
6
|
+
"80S_ILLUSTRATION",
|
|
7
|
+
"90S_NOSTALGIA",
|
|
8
|
+
"ABSTRACT_ORGANIC",
|
|
9
|
+
"ANALOG_NOSTALGIA",
|
|
10
|
+
"ART_BRUT",
|
|
11
|
+
"ART_DECO",
|
|
12
|
+
"ART_POSTER",
|
|
13
|
+
"AURA",
|
|
14
|
+
"AVANT_GARDE",
|
|
15
|
+
"BAUHAUS",
|
|
16
|
+
"BLUEPRINT",
|
|
17
|
+
"BLURRY_MOTION",
|
|
18
|
+
"BRIGHT_ART",
|
|
19
|
+
"C4D_CARTOON",
|
|
20
|
+
"CHILDRENS_BOOK",
|
|
21
|
+
"COLLAGE",
|
|
22
|
+
"COLORING_BOOK_I",
|
|
23
|
+
"COLORING_BOOK_II",
|
|
24
|
+
"CUBISM",
|
|
25
|
+
"DARK_AURA",
|
|
26
|
+
"DOODLE",
|
|
27
|
+
"DOUBLE_EXPOSURE",
|
|
28
|
+
"DRAMATIC_CINEMA",
|
|
29
|
+
"EDITORIAL",
|
|
30
|
+
"EMOTIONAL_MINIMAL",
|
|
31
|
+
"ETHEREAL_PARTY",
|
|
32
|
+
"EXPIRED_FILM",
|
|
33
|
+
"FLAT_ART",
|
|
34
|
+
"FLAT_VECTOR",
|
|
35
|
+
"FOREST_REVERIE",
|
|
36
|
+
"GEO_MINIMALIST",
|
|
37
|
+
"GLASS_PRISM",
|
|
38
|
+
"GOLDEN_HOUR",
|
|
39
|
+
"GRAFFITI_I",
|
|
40
|
+
"GRAFFITI_II",
|
|
41
|
+
"HALFTONE_PRINT",
|
|
42
|
+
"HIGH_CONTRAST",
|
|
43
|
+
"HIPPIE_ERA",
|
|
44
|
+
"ICONIC",
|
|
45
|
+
"JAPANDI_FUSION",
|
|
46
|
+
"JAZZY",
|
|
47
|
+
"LONG_EXPOSURE",
|
|
48
|
+
"MAGAZINE_EDITORIAL",
|
|
49
|
+
"MINIMAL_ILLUSTRATION",
|
|
50
|
+
"MIXED_MEDIA",
|
|
51
|
+
"MONOCHROME",
|
|
52
|
+
"NIGHTLIFE",
|
|
53
|
+
"OIL_PAINTING",
|
|
54
|
+
"OLD_CARTOONS",
|
|
55
|
+
"PAINT_GESTURE",
|
|
56
|
+
"POP_ART",
|
|
57
|
+
"RETRO_ETCHING",
|
|
58
|
+
"RIVIERA_POP",
|
|
59
|
+
"SPOTLIGHT_80S",
|
|
60
|
+
"STYLIZED_RED",
|
|
61
|
+
"SURREAL_COLLAGE",
|
|
62
|
+
"TRAVEL_POSTER",
|
|
63
|
+
"VINTAGE_GEO",
|
|
64
|
+
"VINTAGE_POSTER",
|
|
65
|
+
];
|
|
66
|
+
exports.ideogramResolutions = [
|
|
67
|
+
"512x1536",
|
|
68
|
+
"576x1408",
|
|
69
|
+
"576x1472",
|
|
70
|
+
"576x1536",
|
|
71
|
+
"640x1344",
|
|
72
|
+
"640x1408",
|
|
73
|
+
"640x1472",
|
|
74
|
+
"640x1536",
|
|
75
|
+
"704x1152",
|
|
76
|
+
"704x1216",
|
|
77
|
+
"704x1280",
|
|
78
|
+
"704x1344",
|
|
79
|
+
"704x1408",
|
|
80
|
+
"704x1472",
|
|
81
|
+
"736x1312",
|
|
82
|
+
"768x1088",
|
|
83
|
+
"768x1216",
|
|
84
|
+
"768x1280",
|
|
85
|
+
"768x1344",
|
|
86
|
+
"800x1280",
|
|
87
|
+
"832x960",
|
|
88
|
+
"832x1024",
|
|
89
|
+
"832x1088",
|
|
90
|
+
"832x1152",
|
|
91
|
+
"832x1216",
|
|
92
|
+
"832x1248",
|
|
93
|
+
"864x1152",
|
|
94
|
+
"896x960",
|
|
95
|
+
"896x1024",
|
|
96
|
+
"896x1088",
|
|
97
|
+
"896x1120",
|
|
98
|
+
"896x1152",
|
|
99
|
+
"960x832",
|
|
100
|
+
"960x896",
|
|
101
|
+
"960x1024",
|
|
102
|
+
"960x1088",
|
|
103
|
+
"960x1120",
|
|
104
|
+
"960x1152",
|
|
105
|
+
"1024x832",
|
|
106
|
+
"1024x896",
|
|
107
|
+
"1024x960",
|
|
108
|
+
"1024x1024",
|
|
109
|
+
"1088x768",
|
|
110
|
+
"1088x832",
|
|
111
|
+
"1088x896",
|
|
112
|
+
"1088x960",
|
|
113
|
+
"1120x896",
|
|
114
|
+
"1152x704",
|
|
115
|
+
"1152x832",
|
|
116
|
+
"1152x864",
|
|
117
|
+
"1152x896",
|
|
118
|
+
"1216x704",
|
|
119
|
+
"1216x768",
|
|
120
|
+
"1216x832",
|
|
121
|
+
"1248x832",
|
|
122
|
+
"1280x704",
|
|
123
|
+
"1280x768",
|
|
124
|
+
"1280x800",
|
|
125
|
+
"1312x736",
|
|
126
|
+
"1344x640",
|
|
127
|
+
"1344x704",
|
|
128
|
+
"1344x768",
|
|
129
|
+
"1408x576",
|
|
130
|
+
"1408x640",
|
|
131
|
+
"1408x704",
|
|
132
|
+
"1472x576",
|
|
133
|
+
"1472x640",
|
|
134
|
+
"1472x704",
|
|
135
|
+
"1536x512",
|
|
136
|
+
"1536x576",
|
|
137
|
+
"1536x640",
|
|
138
|
+
];
|
|
139
|
+
exports.ideogramAspectRatios = [
|
|
140
|
+
"1x3",
|
|
141
|
+
"3x1",
|
|
142
|
+
"1x2",
|
|
143
|
+
"2x1",
|
|
144
|
+
"9x16",
|
|
145
|
+
"16x9",
|
|
146
|
+
"10x16",
|
|
147
|
+
"16x10",
|
|
148
|
+
"2x3",
|
|
149
|
+
"3x2",
|
|
150
|
+
"3x4",
|
|
151
|
+
"4x3",
|
|
152
|
+
"4x5",
|
|
153
|
+
"5x4",
|
|
154
|
+
"1x1",
|
|
155
|
+
];
|
|
156
|
+
exports.ideogramRenderingSpeed = ["FLASH", "TURBO", "DEFAULT", "QUALITY"];
|
|
157
|
+
exports.ideogramMagicPrompt = ["AUTO", "ON", "OFF"];
|
|
158
|
+
exports.ideogramColorPalettePreset = [
|
|
159
|
+
"EMBER",
|
|
160
|
+
"FRESH",
|
|
161
|
+
"JUNGLE",
|
|
162
|
+
"MAGIC",
|
|
163
|
+
"MELON",
|
|
164
|
+
"MOSAIC",
|
|
165
|
+
"PASTEL",
|
|
166
|
+
"ULTRAMARINE",
|
|
167
|
+
];
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ideogramV3GenerateOutputSchema = exports.ideogramV3GenerateInputSchema = exports.ideogramAISchema = void 0;
|
|
4
|
+
const zod_1 = require("zod");
|
|
5
|
+
const ideogram_constants_1 = require("#modules/ai/ideogram/ideogram.constants");
|
|
6
|
+
exports.ideogramAISchema = zod_1.z.object({
|
|
7
|
+
prompt: zod_1.z.string().describe("Create a prompt for the image generation."),
|
|
8
|
+
style_type: zod_1.z.enum(ideogram_constants_1.ideogramStyleTypes).describe("Choose a style type for the image generation."),
|
|
9
|
+
// style_preset: z
|
|
10
|
+
// .enum(ideogramStylePresets)
|
|
11
|
+
// .describe("Choose a style preset for the image generation."),
|
|
12
|
+
});
|
|
13
|
+
exports.ideogramV3GenerateInputSchema = zod_1.z.object({
|
|
14
|
+
prompt: zod_1.z.string(),
|
|
15
|
+
seed: zod_1.z.number().optional(),
|
|
16
|
+
resolution: zod_1.z.enum(ideogram_constants_1.ideogramResolutions).optional(),
|
|
17
|
+
rendering_speed: zod_1.z.enum(ideogram_constants_1.ideogramRenderingSpeed).optional(),
|
|
18
|
+
magic_prompt: zod_1.z.enum(ideogram_constants_1.ideogramMagicPrompt).optional(),
|
|
19
|
+
negative_prompt: zod_1.z.string().optional(),
|
|
20
|
+
num_images: zod_1.z.number().optional(),
|
|
21
|
+
color_palette: zod_1.z
|
|
22
|
+
.object({
|
|
23
|
+
ColorPaletteWithPresetName: zod_1.z.object({ name: zod_1.z.enum(ideogram_constants_1.ideogramColorPalettePreset) }).optional(),
|
|
24
|
+
ColorPaletteWithMembers: zod_1.z
|
|
25
|
+
.object({
|
|
26
|
+
members: zod_1.z.array(zod_1.z.object({ color_hex: zod_1.z.string(), color_weight: zod_1.z.number().min(0.05).max(1) })),
|
|
27
|
+
})
|
|
28
|
+
.optional(),
|
|
29
|
+
})
|
|
30
|
+
.optional(),
|
|
31
|
+
style_codes: zod_1.z.array(zod_1.z.string()).optional(),
|
|
32
|
+
aspect_ratio: zod_1.z.enum(ideogram_constants_1.ideogramAspectRatios).optional(),
|
|
33
|
+
style_type: zod_1.z.enum(ideogram_constants_1.ideogramStyleTypes).optional(),
|
|
34
|
+
style_preset: zod_1.z.enum(ideogram_constants_1.ideogramStylePresets).optional(),
|
|
35
|
+
style_reference_images: zod_1.z.array(zod_1.z.file()).optional(),
|
|
36
|
+
character_reference_images: zod_1.z.array(zod_1.z.file()).optional(),
|
|
37
|
+
character_reference_images_mask: zod_1.z.file().optional(),
|
|
38
|
+
});
|
|
39
|
+
exports.ideogramV3GenerateOutputSchema = zod_1.z.object({
|
|
40
|
+
created: zod_1.z.string(),
|
|
41
|
+
data: zod_1.z.array(zod_1.z.object({
|
|
42
|
+
prompt: zod_1.z.string(),
|
|
43
|
+
resolution: zod_1.z.string(),
|
|
44
|
+
is_image_safe: zod_1.z.boolean(),
|
|
45
|
+
seed: zod_1.z.number(),
|
|
46
|
+
url: zod_1.z.url(),
|
|
47
|
+
style_type: zod_1.z.enum(ideogram_constants_1.ideogramStyleTypes),
|
|
48
|
+
})),
|
|
49
|
+
});
|