@ai-grator/api 0.0.8 → 0.0.10

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 (64) hide show
  1. package/admin/endpoints/queries/get-admin-user-transactions.query.ts +3 -0
  2. package/build/admin/endpoints/queries/get-admin-user-transactions.query.d.ts +9 -0
  3. package/build/admin/endpoints/queries/get-admin-user-transactions.query.d.ts.map +1 -1
  4. package/build/admin/endpoints/queries/get-admin-user-transactions.query.js +3 -0
  5. package/build/errors/errors.d.ts +5 -0
  6. package/build/errors/errors.d.ts.map +1 -1
  7. package/build/errors/errors.js +5 -0
  8. package/build/generation-job/endpoints/commands/create-generation-job.command.d.ts +8 -0
  9. package/build/generation-job/endpoints/commands/create-generation-job.command.d.ts.map +1 -1
  10. package/build/generation-job/endpoints/commands/update-generation-job.command.d.ts +13 -20
  11. package/build/generation-job/endpoints/commands/update-generation-job.command.d.ts.map +1 -1
  12. package/build/generation-job/endpoints/commands/update-generation-job.command.js +3 -11
  13. package/build/generation-job/endpoints/queries/get-generation-job-by-uuid.query.d.ts +8 -0
  14. package/build/generation-job/endpoints/queries/get-generation-job-by-uuid.query.d.ts.map +1 -1
  15. package/build/generation-job/endpoints/queries/get-generation-job-history.query.d.ts +12 -0
  16. package/build/generation-job/endpoints/queries/get-generation-job-history.query.d.ts.map +1 -1
  17. package/build/generation-job/endpoints/queries/get-generation-jobs.query.d.ts +8 -0
  18. package/build/generation-job/endpoints/queries/get-generation-jobs.query.d.ts.map +1 -1
  19. package/build/generation-job/models/generation-job-response.schema.d.ts +8 -0
  20. package/build/generation-job/models/generation-job-response.schema.d.ts.map +1 -1
  21. package/build/generation-job/models/generation-job-response.schema.js +4 -0
  22. package/build/generation-job/models/index.d.ts +1 -0
  23. package/build/generation-job/models/index.d.ts.map +1 -1
  24. package/build/generation-job/models/index.js +1 -0
  25. package/build/generation-job/models/suno-params.schema.d.ts +55 -0
  26. package/build/generation-job/models/suno-params.schema.d.ts.map +1 -0
  27. package/build/generation-job/models/suno-params.schema.js +66 -0
  28. package/build/generation-model/endpoints/generation-model.d.ts +1 -0
  29. package/build/generation-model/endpoints/generation-model.d.ts.map +1 -1
  30. package/build/generation-model/endpoints/generation-model.js +1 -0
  31. package/build/generation-model/endpoints/queries/get-music-styles.query.d.ts +59 -0
  32. package/build/generation-model/endpoints/queries/get-music-styles.query.d.ts.map +1 -0
  33. package/build/generation-model/endpoints/queries/get-music-styles.query.js +19 -0
  34. package/build/generation-model/endpoints/queries/index.d.ts +1 -0
  35. package/build/generation-model/endpoints/queries/index.d.ts.map +1 -1
  36. package/build/generation-model/endpoints/queries/index.js +1 -0
  37. package/build/generation-model/enums/generation-type.enum.d.ts +2 -1
  38. package/build/generation-model/enums/generation-type.enum.d.ts.map +1 -1
  39. package/build/generation-model/enums/generation-type.enum.js +1 -0
  40. package/build/generation-model/enums/index.d.ts +1 -0
  41. package/build/generation-model/enums/index.d.ts.map +1 -1
  42. package/build/generation-model/enums/index.js +1 -0
  43. package/build/generation-model/enums/music-style.enum.d.ts +26 -0
  44. package/build/generation-model/enums/music-style.enum.d.ts.map +1 -0
  45. package/build/generation-model/enums/music-style.enum.js +27 -0
  46. package/build/scripts/generate-openapi.js +3 -0
  47. package/build/tsconfig.tsbuildinfo +1 -1
  48. package/build/wallet/enums/wallet-transaction-source-type.enum.d.ts +1 -0
  49. package/build/wallet/enums/wallet-transaction-source-type.enum.d.ts.map +1 -1
  50. package/build/wallet/enums/wallet-transaction-source-type.enum.js +1 -0
  51. package/errors/errors.ts +5 -0
  52. package/generation-job/endpoints/commands/update-generation-job.command.ts +5 -13
  53. package/generation-job/models/generation-job-response.schema.ts +4 -0
  54. package/generation-job/models/index.ts +1 -0
  55. package/generation-job/models/suno-params.schema.ts +73 -0
  56. package/generation-model/endpoints/generation-model.ts +1 -0
  57. package/generation-model/endpoints/queries/get-music-styles.query.ts +18 -0
  58. package/generation-model/endpoints/queries/index.ts +1 -0
  59. package/generation-model/enums/generation-type.enum.ts +1 -0
  60. package/generation-model/enums/index.ts +1 -0
  61. package/generation-model/enums/music-style.enum.ts +27 -0
  62. package/package.json +1 -1
  63. package/scripts/generate-openapi.ts +6 -0
  64. package/wallet/enums/wallet-transaction-source-type.enum.ts +1 -0
@@ -1,6 +1,7 @@
1
1
  export declare enum WALLET_TRANSACTION_SOURCE_TYPE {
2
2
  GENERATION_JOB_IMAGE = "generation_job_image",
3
3
  GENERATION_JOB_VIDEO = "generation_job_video",
4
+ GENERATION_JOB_MUSIC = "generation_job_music",
4
5
  MESSAGE = "message",
5
6
  PAYMENT = "payment",
6
7
  EMAIL_VERIFICATION = "email_verification",
@@ -1 +1 @@
1
- {"version":3,"file":"wallet-transaction-source-type.enum.d.ts","sourceRoot":"","sources":["../../../wallet/enums/wallet-transaction-source-type.enum.ts"],"names":[],"mappings":"AAAA,oBAAY,8BAA8B;IACtC,oBAAoB,yBAAyB;IAC7C,oBAAoB,yBAAyB;IAC7C,OAAO,YAAY;IACnB,OAAO,YAAY;IACnB,kBAAkB,uBAAuB;IACzC,QAAQ,aAAa;IACrB,qBAAqB,0BAA0B;CAClD"}
1
+ {"version":3,"file":"wallet-transaction-source-type.enum.d.ts","sourceRoot":"","sources":["../../../wallet/enums/wallet-transaction-source-type.enum.ts"],"names":[],"mappings":"AAAA,oBAAY,8BAA8B;IACtC,oBAAoB,yBAAyB;IAC7C,oBAAoB,yBAAyB;IAC7C,oBAAoB,yBAAyB;IAC7C,OAAO,YAAY;IACnB,OAAO,YAAY;IACnB,kBAAkB,uBAAuB;IACzC,QAAQ,aAAa;IACrB,qBAAqB,0BAA0B;CAClD"}
@@ -5,6 +5,7 @@ var WALLET_TRANSACTION_SOURCE_TYPE;
5
5
  (function (WALLET_TRANSACTION_SOURCE_TYPE) {
6
6
  WALLET_TRANSACTION_SOURCE_TYPE["GENERATION_JOB_IMAGE"] = "generation_job_image";
7
7
  WALLET_TRANSACTION_SOURCE_TYPE["GENERATION_JOB_VIDEO"] = "generation_job_video";
8
+ WALLET_TRANSACTION_SOURCE_TYPE["GENERATION_JOB_MUSIC"] = "generation_job_music";
8
9
  WALLET_TRANSACTION_SOURCE_TYPE["MESSAGE"] = "message";
9
10
  WALLET_TRANSACTION_SOURCE_TYPE["PAYMENT"] = "payment";
10
11
  WALLET_TRANSACTION_SOURCE_TYPE["EMAIL_VERIFICATION"] = "email_verification";
package/errors/errors.ts CHANGED
@@ -316,6 +316,11 @@ export const ERRORS = {
316
316
  code: 'GENERATION_JOB.CHAT_MODEL_MISMATCH',
317
317
  message: 'Этот чат заблокирован для другой модели генерации',
318
318
  },
319
+ ALREADY_TERMINAL: {
320
+ httpCode: 400,
321
+ code: 'GENERATION_JOB.ALREADY_TERMINAL',
322
+ message: 'Задача генерации уже завершена и не может быть отменена',
323
+ },
319
324
  },
320
325
  BILLING: {
321
326
  QUOTE_ERROR: {
@@ -1,24 +1,16 @@
1
1
  import { z } from 'zod';
2
2
  import { defineContract, HTTP_METHODS, HttpErrorResponseSchema } from '../../../_common';
3
- import { GenerationJobOutputSchema, GenerationJobResponseSchema, GenerationJobStatusSchema } from '../../models';
3
+ import { GENERATION_JOB_STATUS } from '../../enums';
4
+ import { GenerationJobResponseSchema } from '../../models';
4
5
  import { GENERATION_JOB_ROUTES } from '../generation-job';
5
6
 
6
7
  export const UpdateGenerationJobCommandParams = z.object({
7
8
  uuid: z.uuid(),
8
9
  });
9
10
 
10
- export const UpdateGenerationJobCommandBody = z
11
- .object({
12
- status: GenerationJobStatusSchema.optional(),
13
- providerJobId: z.string().min(1).nullable().optional(),
14
- errorMessage: z.string().min(1).nullable().optional(),
15
- startedAt: z.iso.datetime().nullable().optional(),
16
- finishedAt: z.iso.datetime().nullable().optional(),
17
- outputs: z.array(GenerationJobOutputSchema).optional(),
18
- })
19
- .refine((value) => Object.keys(value).length > 0, {
20
- message: 'At least one field is required',
21
- });
11
+ export const UpdateGenerationJobCommandBody = z.object({
12
+ status: z.literal(GENERATION_JOB_STATUS.CANCELED),
13
+ });
22
14
 
23
15
  export const UpdateGenerationJobCommandResponse = GenerationJobResponseSchema;
24
16
 
@@ -9,6 +9,10 @@ export const GenerationJobStatusSchema = z.enum(GENERATION_JOB_STATUS);
9
9
  export const GenerationJobOutputSchema = z.object({
10
10
  uuid: z.uuid(),
11
11
  url: z.url(),
12
+ title: z.string().optional(),
13
+ tags: z.string().optional(),
14
+ duration: z.number().optional(),
15
+ imageUrl: z.string().optional(),
12
16
  });
13
17
 
14
18
  export const GenerationJobResponseSchema = z.object({
@@ -1 +1,2 @@
1
1
  export * from './generation-job-response.schema';
2
+ export * from './suno-params.schema';
@@ -0,0 +1,73 @@
1
+ import { z } from 'zod';
2
+ import { MusicStyleSchema } from '../../generation-model';
3
+
4
+ export const SunoVocalGenderSchema = z.enum(['m', 'f']);
5
+ export type SunoVocalGender = z.infer<typeof SunoVocalGenderSchema>;
6
+
7
+ export const SunoPersonaModelSchema = z.enum(['style_persona', 'voice_persona']);
8
+ export type SunoPersonaModel = z.infer<typeof SunoPersonaModelSchema>;
9
+
10
+ // KIE/Suno docs don't state an explicit max for V5_5; capped conservatively above the
11
+ // documented V4.5 ceiling (8 min) pending real limits/duration-aware pricing from product.
12
+ const MAX_DURATION_SECONDS = 600;
13
+
14
+ export const SunoParamsSchema = z
15
+ .object({
16
+ customMode: z.boolean().default(false),
17
+ prompt: z.string().max(5000).optional(),
18
+ instrumental: z.boolean().default(false),
19
+ audioWeight: z.number().min(0).max(1).multipleOf(0.05).default(0.65),
20
+ title: z.string().max(80).optional(),
21
+ style: MusicStyleSchema.optional(),
22
+ duration: z.number().positive().max(MAX_DURATION_SECONDS).default(120),
23
+ vocalGender: SunoVocalGenderSchema.optional(),
24
+ negativeTags: z.string().max(500).optional(),
25
+ styleWeight: z.number().min(0).max(1).optional(),
26
+ weirdnessConstraint: z.number().min(0).max(1).optional(),
27
+ personaId: z.string().nullable().optional(),
28
+ personaModel: SunoPersonaModelSchema.nullable().optional(),
29
+ })
30
+ .superRefine((params, ctx) => {
31
+ if (!params.customMode) {
32
+ if (!params.prompt || params.prompt.length === 0) {
33
+ ctx.addIssue({
34
+ code: 'custom',
35
+ path: ['prompt'],
36
+ message: 'Song Description (prompt) is required when Custom Mode is disabled',
37
+ });
38
+ } else if (params.prompt.length > 500) {
39
+ ctx.addIssue({
40
+ code: 'custom',
41
+ path: ['prompt'],
42
+ message: 'Song Description (prompt) must be at most 500 characters in Simple Mode',
43
+ });
44
+ }
45
+ return;
46
+ }
47
+
48
+ if (!params.title) {
49
+ ctx.addIssue({
50
+ code: 'custom',
51
+ path: ['title'],
52
+ message: 'Title is required when Custom Mode is enabled',
53
+ });
54
+ }
55
+
56
+ if (!params.style) {
57
+ ctx.addIssue({
58
+ code: 'custom',
59
+ path: ['style'],
60
+ message: 'Style of Music is required when Custom Mode is enabled',
61
+ });
62
+ }
63
+
64
+ if (!params.instrumental && (!params.prompt || params.prompt.length === 0)) {
65
+ ctx.addIssue({
66
+ code: 'custom',
67
+ path: ['prompt'],
68
+ message: 'Lyrics (prompt) is required when Instrumental is disabled in Custom Mode',
69
+ });
70
+ }
71
+ });
72
+
73
+ export type SunoParams = z.infer<typeof SunoParamsSchema>;
@@ -4,4 +4,5 @@ export const GENERATION_MODEL_ROUTES = {
4
4
  GET_ALL: '',
5
5
  GET_BY_TYPE: (generationType: string) => `${generationType}`,
6
6
  GET_PRICE: (modelId: string) => `${modelId}/price`,
7
+ GET_MUSIC_STYLES: 'music-styles',
7
8
  } as const;
@@ -0,0 +1,18 @@
1
+ import { z } from 'zod';
2
+ import { defineContract, HTTP_METHODS, HttpErrorResponseSchema } from '../../../_common';
3
+ import { MusicStyleSchema } from '../../enums';
4
+ import { GENERATION_MODEL_ROUTES } from '../generation-model';
5
+
6
+ export const GetMusicStylesQueryResponse = z.object({
7
+ styles: z.array(MusicStyleSchema),
8
+ });
9
+
10
+ export const GetMusicStylesQuery = defineContract({
11
+ method: HTTP_METHODS.GET,
12
+ path: GENERATION_MODEL_ROUTES.GET_MUSIC_STYLES,
13
+ summary: 'Get fixed list of music styles for Suno music generation',
14
+ responses: {
15
+ 200: GetMusicStylesQueryResponse,
16
+ 500: HttpErrorResponseSchema,
17
+ },
18
+ });
@@ -1,3 +1,4 @@
1
1
  export * from './get-generation-models.query';
2
2
  export * from './get-generation-models-by-type.query';
3
3
  export * from './get-generation-price.query';
4
+ export * from './get-music-styles.query';
@@ -1,4 +1,5 @@
1
1
  export enum GENERATION_TYPE {
2
2
  IMAGE = 'image',
3
3
  VIDEO = 'video',
4
+ MUSIC = 'music',
4
5
  }
@@ -1 +1,2 @@
1
1
  export * from './generation-type.enum';
2
+ export * from './music-style.enum';
@@ -0,0 +1,27 @@
1
+ import { z } from 'zod';
2
+
3
+ export const MUSIC_STYLE = [
4
+ 'Pop',
5
+ 'Rock',
6
+ 'Hip-hop',
7
+ 'Electronic',
8
+ 'Jazz',
9
+ 'Classical',
10
+ 'R&B',
11
+ 'Country',
12
+ 'Metal',
13
+ 'Folk',
14
+ 'Reggae',
15
+ 'Blues',
16
+ 'Funk',
17
+ 'Punk',
18
+ 'Ambient',
19
+ 'Latin',
20
+ 'K-pop',
21
+ 'Indie',
22
+ 'Soul',
23
+ 'Gospel',
24
+ ] as const;
25
+
26
+ export const MusicStyleSchema = z.enum(MUSIC_STYLE);
27
+ export type MusicStyle = z.infer<typeof MusicStyleSchema>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ai-grator/api",
3
- "version": "0.0.8",
3
+ "version": "0.0.10",
4
4
  "main": "build/index.js",
5
5
  "types": "build/index.d.ts",
6
6
  "scripts": {
@@ -186,6 +186,10 @@ import {
186
186
  GetGenerationModelsByTypeQueryParams,
187
187
  GetGenerationModelsByTypeQueryResponse,
188
188
  } from '../generation-model/endpoints/queries/get-generation-models-by-type.query';
189
+ import {
190
+ GetMusicStylesQuery,
191
+ GetMusicStylesQueryResponse,
192
+ } from '../generation-model/endpoints/queries/get-music-styles.query';
189
193
  import { GENERATION_JOB_CONTROLLER } from '../generation-job/endpoints/generation-job';
190
194
  import {
191
195
  CreateGenerationJobCommand,
@@ -369,6 +373,7 @@ async function main() {
369
373
  registerSchema('GenerationModelGetAllResponse', GetGenerationModelsQueryResponse);
370
374
  registerSchema('GenerationModelGetByTypeParams', GetGenerationModelsByTypeQueryParams);
371
375
  registerSchema('GenerationModelGetByTypeResponse', GetGenerationModelsByTypeQueryResponse);
376
+ registerSchema('GenerationModelGetMusicStylesResponse', GetMusicStylesQueryResponse);
372
377
  registerSchema('GenerationJobCreateRequest', CreateGenerationJobCommandBody);
373
378
  registerSchema('GenerationJobCreateResponse', CreateGenerationJobCommandResponse);
374
379
  registerSchema('GenerationJobGetAllResponse', GetGenerationJobsQueryResponse);
@@ -461,6 +466,7 @@ async function main() {
461
466
  GetGenerationModelsQuery,
462
467
  GetGenerationModelsByTypeQuery,
463
468
  GetGenerationPriceQuery,
469
+ GetMusicStylesQuery,
464
470
  ];
465
471
  const generationJobContracts: HttpContract[] = [
466
472
  CreateGenerationJobCommand,
@@ -1,6 +1,7 @@
1
1
  export enum WALLET_TRANSACTION_SOURCE_TYPE {
2
2
  GENERATION_JOB_IMAGE = 'generation_job_image',
3
3
  GENERATION_JOB_VIDEO = 'generation_job_video',
4
+ GENERATION_JOB_MUSIC = 'generation_job_music',
4
5
  MESSAGE = 'message',
5
6
  PAYMENT = 'payment',
6
7
  EMAIL_VERIFICATION = 'email_verification',