@ai-grator/api 0.1.25 → 0.1.27

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 (52) hide show
  1. package/build/errors/errors.d.ts +7 -0
  2. package/build/errors/errors.d.ts.map +1 -1
  3. package/build/errors/errors.js +7 -0
  4. package/build/index.d.ts +1 -0
  5. package/build/index.d.ts.map +1 -1
  6. package/build/index.js +1 -0
  7. package/build/model-catalog/endpoints/index.d.ts +3 -0
  8. package/build/model-catalog/endpoints/index.d.ts.map +1 -0
  9. package/build/model-catalog/endpoints/index.js +18 -0
  10. package/build/model-catalog/endpoints/model-catalog.d.ts +5 -0
  11. package/build/model-catalog/endpoints/model-catalog.d.ts.map +1 -0
  12. package/build/model-catalog/endpoints/model-catalog.js +7 -0
  13. package/build/model-catalog/endpoints/queries/get-model-catalog.query.d.ts +39 -0
  14. package/build/model-catalog/endpoints/queries/get-model-catalog.query.d.ts.map +1 -0
  15. package/build/model-catalog/endpoints/queries/get-model-catalog.query.js +19 -0
  16. package/build/model-catalog/endpoints/queries/index.d.ts +2 -0
  17. package/build/model-catalog/endpoints/queries/index.d.ts.map +1 -0
  18. package/build/model-catalog/endpoints/queries/index.js +17 -0
  19. package/build/model-catalog/enums/index.d.ts +3 -0
  20. package/build/model-catalog/enums/index.d.ts.map +1 -0
  21. package/build/model-catalog/enums/index.js +18 -0
  22. package/build/model-catalog/enums/model-category.enum.d.ts +7 -0
  23. package/build/model-catalog/enums/model-category.enum.d.ts.map +1 -0
  24. package/build/model-catalog/enums/model-category.enum.js +10 -0
  25. package/build/model-catalog/enums/price-unit.enum.d.ts +5 -0
  26. package/build/model-catalog/enums/price-unit.enum.d.ts.map +1 -0
  27. package/build/model-catalog/enums/price-unit.enum.js +8 -0
  28. package/build/model-catalog/index.d.ts +4 -0
  29. package/build/model-catalog/index.d.ts.map +1 -0
  30. package/build/model-catalog/index.js +19 -0
  31. package/build/model-catalog/models/index.d.ts +2 -0
  32. package/build/model-catalog/models/index.d.ts.map +1 -0
  33. package/build/model-catalog/models/index.js +17 -0
  34. package/build/model-catalog/models/model-catalog-item-response.schema.d.ts +16 -0
  35. package/build/model-catalog/models/model-catalog-item-response.schema.d.ts.map +1 -0
  36. package/build/model-catalog/models/model-catalog-item-response.schema.js +15 -0
  37. package/build/scripts/generate-openapi.js +33 -0
  38. package/build/tsconfig.tsbuildinfo +1 -1
  39. package/errors/errors.ts +7 -0
  40. package/index.ts +1 -0
  41. package/model-catalog/endpoints/index.ts +2 -0
  42. package/model-catalog/endpoints/model-catalog.ts +5 -0
  43. package/model-catalog/endpoints/queries/get-model-catalog.query.ts +18 -0
  44. package/model-catalog/endpoints/queries/index.ts +1 -0
  45. package/model-catalog/enums/index.ts +2 -0
  46. package/model-catalog/enums/model-category.enum.ts +6 -0
  47. package/model-catalog/enums/price-unit.enum.ts +4 -0
  48. package/model-catalog/index.ts +3 -0
  49. package/model-catalog/models/index.ts +1 -0
  50. package/model-catalog/models/model-catalog-item-response.schema.ts +15 -0
  51. package/package.json +1 -1
  52. package/scripts/generate-openapi.ts +38 -0
package/errors/errors.ts CHANGED
@@ -823,4 +823,11 @@ export const ERRORS = {
823
823
  message: 'Не удалось отметить сообщения поддержки как прочитанные',
824
824
  },
825
825
  },
826
+ MODEL_CATALOG: {
827
+ FIND_ERROR: {
828
+ httpCode: 500,
829
+ code: 'MODEL_CATALOG.FIND_ERROR',
830
+ message: 'Не удалось получить каталог моделей',
831
+ },
832
+ },
826
833
  } as const;
package/index.ts CHANGED
@@ -1,6 +1,7 @@
1
1
  export * from './_common';
2
2
  export * from './ai-model';
3
3
  export * from './generation-model';
4
+ export * from './model-catalog';
4
5
  export * from './generation-job';
5
6
  export * from './article';
6
7
  export * from './auth';
@@ -0,0 +1,2 @@
1
+ export * from './model-catalog';
2
+ export * from './queries';
@@ -0,0 +1,5 @@
1
+ export const MODEL_CATALOG_CONTROLLER = 'models' as const;
2
+
3
+ export const MODEL_CATALOG_ROUTES = {
4
+ GET_ALL: '',
5
+ } as const;
@@ -0,0 +1,18 @@
1
+ import { z } from 'zod';
2
+ import { defineContract, HTTP_METHODS, HttpErrorResponseSchema } from '../../../_common';
3
+ import { ModelCatalogItemResponseSchema } from '../../models';
4
+ import { MODEL_CATALOG_ROUTES } from '../model-catalog';
5
+
6
+ export const GetModelCatalogQueryResponse = z.object({
7
+ models: z.array(ModelCatalogItemResponseSchema),
8
+ });
9
+
10
+ export const GetModelCatalogQuery = defineContract({
11
+ method: HTTP_METHODS.GET,
12
+ path: MODEL_CATALOG_ROUTES.GET_ALL,
13
+ summary: 'Get public model catalog',
14
+ responses: {
15
+ 200: GetModelCatalogQueryResponse,
16
+ 500: HttpErrorResponseSchema,
17
+ },
18
+ });
@@ -0,0 +1 @@
1
+ export * from './get-model-catalog.query';
@@ -0,0 +1,2 @@
1
+ export * from './model-category.enum';
2
+ export * from './price-unit.enum';
@@ -0,0 +1,6 @@
1
+ export enum MODEL_CATEGORY {
2
+ TEXT = 'text',
3
+ IMAGE = 'image',
4
+ VIDEO = 'video',
5
+ MUSIC = 'music',
6
+ }
@@ -0,0 +1,4 @@
1
+ export enum PRICE_UNIT {
2
+ PER_MILLION_TOKENS = 'per_million_tokens',
3
+ PER_GENERATION = 'per_generation',
4
+ }
@@ -0,0 +1,3 @@
1
+ export * from './enums';
2
+ export * from './models';
3
+ export * from './endpoints';
@@ -0,0 +1 @@
1
+ export * from './model-catalog-item-response.schema';
@@ -0,0 +1,15 @@
1
+ import { z } from 'zod';
2
+ import { IconSchema } from '../../_common';
3
+ import { MODEL_CATEGORY, PRICE_UNIT } from '../enums';
4
+
5
+ export const ModelCatalogItemResponseSchema = z.object({
6
+ uuid: z.uuid(),
7
+ name: z.string(),
8
+ description: z.string().nullable(),
9
+ category: z.enum(MODEL_CATEGORY),
10
+ icons: IconSchema,
11
+ priceFrom: z.number().nonnegative(),
12
+ priceUnit: z.enum(PRICE_UNIT),
13
+ });
14
+
15
+ export type ModelCatalogItemResponseSchemaType = z.infer<typeof ModelCatalogItemResponseSchema>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ai-grator/api",
3
- "version": "0.1.25",
3
+ "version": "0.1.27",
4
4
  "main": "build/index.js",
5
5
  "types": "build/index.d.ts",
6
6
  "scripts": {
@@ -221,6 +221,11 @@ import {
221
221
  GetAiModelByUuidQueryResponse,
222
222
  } from '../ai-model/endpoints/queries/get-ai-model-by-uuid.query';
223
223
  import { GetAllAiModelsQuery, GetAllAiModelsQueryResponse } from '../ai-model/endpoints/queries/get-ai-models.query';
224
+ import { MODEL_CATALOG_CONTROLLER } from '../model-catalog/endpoints/model-catalog';
225
+ import {
226
+ GetModelCatalogQuery,
227
+ GetModelCatalogQueryResponse,
228
+ } from '../model-catalog/endpoints/queries/get-model-catalog.query';
224
229
  import { GENERATION_MODEL_CONTROLLER } from '../generation-model/endpoints/generation-model';
225
230
  import {
226
231
  GetGenerationModelsQuery,
@@ -446,6 +451,7 @@ async function main() {
446
451
  registerSchema('AiModelsGetAllResponse', GetAllAiModelsQueryResponse);
447
452
  registerSchema('AiModelsGetByUuidParams', GetAiModelByUuidQueryParams);
448
453
  registerSchema('AiModelsGetByUuidResponse', GetAiModelByUuidQueryResponse);
454
+ registerSchema('ModelCatalogGetAllResponse', GetModelCatalogQueryResponse);
449
455
  registerSchema('GenerationModelGetAllResponse', GetGenerationModelsQueryResponse);
450
456
  registerSchema('GenerationModelGetByTypeParams', GetGenerationModelsByTypeQueryParams);
451
457
  registerSchema('GenerationModelGetByTypeResponse', GetGenerationModelsByTypeQueryResponse);
@@ -581,6 +587,7 @@ async function main() {
581
587
  DeleteMarketplaceCardCommand,
582
588
  ];
583
589
  const aiModelContracts: HttpContract[] = [GetAllAiModelsQuery, GetAiModelByUuidQuery];
590
+ const modelCatalogContracts: HttpContract[] = [GetModelCatalogQuery];
584
591
  const generationModelContracts: HttpContract[] = [
585
592
  GetGenerationModelsQuery,
586
593
  GetGenerationModelsByTypeQuery,
@@ -876,6 +883,37 @@ async function main() {
876
883
  });
877
884
  }
878
885
 
886
+ for (const contract of modelCatalogContracts) {
887
+ const method = contract.method.toLowerCase();
888
+ if (!supportedHttpMethods.has(method)) {
889
+ throw new Error(`Unsupported HTTP method: ${contract.method}`);
890
+ }
891
+
892
+ registry.registerPath({
893
+ method: method as 'get' | 'post' | 'put' | 'patch' | 'delete',
894
+ path: toOpenApiPath(MODEL_CATALOG_CONTROLLER, contract.path),
895
+ summary: contract.summary,
896
+ tags: ['Model Catalog'],
897
+ request: {
898
+ ...(contract.request?.body
899
+ ? {
900
+ body: {
901
+ required: true,
902
+ content: {
903
+ 'application/json': {
904
+ schema: resolveSchema(contract.request.body),
905
+ },
906
+ },
907
+ },
908
+ }
909
+ : {}),
910
+ ...(contract.request?.query ? { query: resolveSchema(contract.request.query) } : {}),
911
+ ...(contract.request?.params ? { params: resolveSchema(contract.request.params) } : {}),
912
+ },
913
+ responses: buildResponses(contract.responses, resolveSchema),
914
+ });
915
+ }
916
+
879
917
  for (const contract of generationModelContracts) {
880
918
  const method = contract.method.toLowerCase();
881
919
  if (!supportedHttpMethods.has(method)) {