@ai-grator/api 0.0.7 → 0.0.9

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 (96) hide show
  1. package/admin/endpoints/admin.ts +3 -0
  2. package/billing/endpoints/index.ts +1 -0
  3. package/billing/endpoints/queries/get-admin-stats.query.ts +29 -0
  4. package/billing/endpoints/queries/index.ts +1 -0
  5. package/billing/enums/index.ts +1 -0
  6. package/billing/enums/model-type.enum.ts +5 -0
  7. package/billing/index.ts +3 -0
  8. package/billing/models/admin-stats-response.schema.ts +29 -0
  9. package/billing/models/index.ts +1 -0
  10. package/build/admin/endpoints/admin.d.ts +1 -0
  11. package/build/admin/endpoints/admin.d.ts.map +1 -1
  12. package/build/admin/endpoints/admin.js +2 -0
  13. package/build/billing/endpoints/index.d.ts +2 -0
  14. package/build/billing/endpoints/index.d.ts.map +1 -0
  15. package/build/billing/endpoints/index.js +17 -0
  16. package/build/billing/endpoints/queries/get-admin-stats.query.d.ts +61 -0
  17. package/build/billing/endpoints/queries/get-admin-stats.query.d.ts.map +1 -0
  18. package/build/billing/endpoints/queries/get-admin-stats.query.js +26 -0
  19. package/build/billing/endpoints/queries/index.d.ts +2 -0
  20. package/build/billing/endpoints/queries/index.d.ts.map +1 -0
  21. package/build/billing/endpoints/queries/index.js +17 -0
  22. package/build/billing/enums/index.d.ts +2 -0
  23. package/build/billing/enums/index.d.ts.map +1 -0
  24. package/build/billing/enums/index.js +17 -0
  25. package/build/billing/enums/model-type.enum.d.ts +6 -0
  26. package/build/billing/enums/model-type.enum.d.ts.map +1 -0
  27. package/build/billing/enums/model-type.enum.js +9 -0
  28. package/build/billing/index.d.ts +4 -0
  29. package/build/billing/index.d.ts.map +1 -0
  30. package/build/billing/index.js +19 -0
  31. package/build/billing/models/admin-stats-response.schema.d.ts +37 -0
  32. package/build/billing/models/admin-stats-response.schema.d.ts.map +1 -0
  33. package/build/billing/models/admin-stats-response.schema.js +25 -0
  34. package/build/billing/models/index.d.ts +2 -0
  35. package/build/billing/models/index.d.ts.map +1 -0
  36. package/build/billing/models/index.js +17 -0
  37. package/build/errors/errors.d.ts +10 -0
  38. package/build/errors/errors.d.ts.map +1 -1
  39. package/build/errors/errors.js +10 -0
  40. package/build/generation-job/endpoints/commands/create-generation-job.command.d.ts +8 -0
  41. package/build/generation-job/endpoints/commands/create-generation-job.command.d.ts.map +1 -1
  42. package/build/generation-job/endpoints/commands/update-generation-job.command.d.ts +13 -20
  43. package/build/generation-job/endpoints/commands/update-generation-job.command.d.ts.map +1 -1
  44. package/build/generation-job/endpoints/commands/update-generation-job.command.js +3 -11
  45. package/build/generation-job/endpoints/queries/get-generation-job-by-uuid.query.d.ts +8 -0
  46. package/build/generation-job/endpoints/queries/get-generation-job-by-uuid.query.d.ts.map +1 -1
  47. package/build/generation-job/endpoints/queries/get-generation-job-history.query.d.ts +12 -0
  48. package/build/generation-job/endpoints/queries/get-generation-job-history.query.d.ts.map +1 -1
  49. package/build/generation-job/endpoints/queries/get-generation-jobs.query.d.ts +8 -0
  50. package/build/generation-job/endpoints/queries/get-generation-jobs.query.d.ts.map +1 -1
  51. package/build/generation-job/models/generation-job-response.schema.d.ts +8 -0
  52. package/build/generation-job/models/generation-job-response.schema.d.ts.map +1 -1
  53. package/build/generation-job/models/generation-job-response.schema.js +4 -0
  54. package/build/generation-job/models/index.d.ts +1 -0
  55. package/build/generation-job/models/index.d.ts.map +1 -1
  56. package/build/generation-job/models/index.js +1 -0
  57. package/build/generation-job/models/suno-params.schema.d.ts +55 -0
  58. package/build/generation-job/models/suno-params.schema.d.ts.map +1 -0
  59. package/build/generation-job/models/suno-params.schema.js +66 -0
  60. package/build/generation-model/endpoints/generation-model.d.ts +1 -0
  61. package/build/generation-model/endpoints/generation-model.d.ts.map +1 -1
  62. package/build/generation-model/endpoints/generation-model.js +1 -0
  63. package/build/generation-model/endpoints/queries/get-music-styles.query.d.ts +59 -0
  64. package/build/generation-model/endpoints/queries/get-music-styles.query.d.ts.map +1 -0
  65. package/build/generation-model/endpoints/queries/get-music-styles.query.js +19 -0
  66. package/build/generation-model/endpoints/queries/index.d.ts +1 -0
  67. package/build/generation-model/endpoints/queries/index.d.ts.map +1 -1
  68. package/build/generation-model/endpoints/queries/index.js +1 -0
  69. package/build/generation-model/enums/generation-type.enum.d.ts +2 -1
  70. package/build/generation-model/enums/generation-type.enum.d.ts.map +1 -1
  71. package/build/generation-model/enums/generation-type.enum.js +1 -0
  72. package/build/generation-model/enums/index.d.ts +1 -0
  73. package/build/generation-model/enums/index.d.ts.map +1 -1
  74. package/build/generation-model/enums/index.js +1 -0
  75. package/build/generation-model/enums/music-style.enum.d.ts +26 -0
  76. package/build/generation-model/enums/music-style.enum.d.ts.map +1 -0
  77. package/build/generation-model/enums/music-style.enum.js +27 -0
  78. package/build/scripts/generate-openapi.js +7 -0
  79. package/build/tsconfig.tsbuildinfo +1 -1
  80. package/build/wallet/enums/wallet-transaction-source-type.enum.d.ts +1 -0
  81. package/build/wallet/enums/wallet-transaction-source-type.enum.d.ts.map +1 -1
  82. package/build/wallet/enums/wallet-transaction-source-type.enum.js +1 -0
  83. package/errors/errors.ts +10 -0
  84. package/generation-job/endpoints/commands/update-generation-job.command.ts +5 -13
  85. package/generation-job/models/generation-job-response.schema.ts +4 -0
  86. package/generation-job/models/index.ts +1 -0
  87. package/generation-job/models/suno-params.schema.ts +73 -0
  88. package/generation-model/endpoints/generation-model.ts +1 -0
  89. package/generation-model/endpoints/queries/get-music-styles.query.ts +18 -0
  90. package/generation-model/endpoints/queries/index.ts +1 -0
  91. package/generation-model/enums/generation-type.enum.ts +1 -0
  92. package/generation-model/enums/index.ts +1 -0
  93. package/generation-model/enums/music-style.enum.ts +27 -0
  94. package/package.json +1 -1
  95. package/scripts/generate-openapi.ts +14 -0
  96. 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: {
@@ -561,6 +566,11 @@ export const ERRORS = {
561
566
  code: 'ADMIN.CANNOT_BAN_ADMIN',
562
567
  message: 'Невозможно заблокировать администратора',
563
568
  },
569
+ STATS_ERROR: {
570
+ httpCode: 500,
571
+ code: 'ADMIN.STATS_ERROR',
572
+ message: 'Не удалось получить статистику',
573
+ },
564
574
  },
565
575
  REFERRAL: {
566
576
  SELF_REFERRAL: {
@@ -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.7",
3
+ "version": "0.0.9",
4
4
  "main": "build/index.js",
5
5
  "types": "build/index.d.ts",
6
6
  "scripts": {
@@ -81,6 +81,11 @@ import {
81
81
  GetAdminUserTransactionsQueryQuery,
82
82
  GetAdminUserTransactionsQueryResponse,
83
83
  } from '../admin/endpoints/queries/get-admin-user-transactions.query';
84
+ import {
85
+ GetAdminStatsQuery,
86
+ GetAdminStatsQueryQuery,
87
+ GetAdminStatsQueryResponse,
88
+ } from '../billing/endpoints/queries/get-admin-stats.query';
84
89
  import { AUTH_CONTROLLER } from '../auth/endpoints/auth';
85
90
  import { AuthChangePasswordSchema, ChangePasswordCommand } from '../auth/endpoints/commands/change-password.command';
86
91
  import { AuthDeleteAccountSchema, DeleteAccountCommand } from '../auth/endpoints/commands/delete-account.command';
@@ -181,6 +186,10 @@ import {
181
186
  GetGenerationModelsByTypeQueryParams,
182
187
  GetGenerationModelsByTypeQueryResponse,
183
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';
184
193
  import { GENERATION_JOB_CONTROLLER } from '../generation-job/endpoints/generation-job';
185
194
  import {
186
195
  CreateGenerationJobCommand,
@@ -364,6 +373,7 @@ async function main() {
364
373
  registerSchema('GenerationModelGetAllResponse', GetGenerationModelsQueryResponse);
365
374
  registerSchema('GenerationModelGetByTypeParams', GetGenerationModelsByTypeQueryParams);
366
375
  registerSchema('GenerationModelGetByTypeResponse', GetGenerationModelsByTypeQueryResponse);
376
+ registerSchema('GenerationModelGetMusicStylesResponse', GetMusicStylesQueryResponse);
367
377
  registerSchema('GenerationJobCreateRequest', CreateGenerationJobCommandBody);
368
378
  registerSchema('GenerationJobCreateResponse', CreateGenerationJobCommandResponse);
369
379
  registerSchema('GenerationJobGetAllResponse', GetGenerationJobsQueryResponse);
@@ -421,6 +431,8 @@ async function main() {
421
431
  registerSchema('AdminGetUserResponse', GetAdminUserQueryResponse);
422
432
  registerSchema('AdminGetUserTransactionsQuery', GetAdminUserTransactionsQueryQuery);
423
433
  registerSchema('AdminGetUserTransactionsResponse', GetAdminUserTransactionsQueryResponse);
434
+ registerSchema('AdminGetStatsQuery', GetAdminStatsQueryQuery);
435
+ registerSchema('AdminGetStatsResponse', GetAdminStatsQueryResponse);
424
436
 
425
437
  const authContracts: HttpContract[] = [
426
438
  RegisterCommand,
@@ -454,6 +466,7 @@ async function main() {
454
466
  GetGenerationModelsQuery,
455
467
  GetGenerationModelsByTypeQuery,
456
468
  GetGenerationPriceQuery,
469
+ GetMusicStylesQuery,
457
470
  ];
458
471
  const generationJobContracts: HttpContract[] = [
459
472
  CreateGenerationJobCommand,
@@ -485,6 +498,7 @@ async function main() {
485
498
  GetAdminUsersQuery,
486
499
  GetAdminUserQuery,
487
500
  GetAdminUserTransactionsQuery,
501
+ GetAdminStatsQuery,
488
502
  ];
489
503
 
490
504
  for (const contract of authContracts) {
@@ -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',