@ai-grator/api 0.1.31 → 0.1.32

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 (44) hide show
  1. package/build/index.d.ts +1 -0
  2. package/build/index.d.ts.map +1 -1
  3. package/build/index.js +1 -0
  4. package/build/model-page/endpoints/index.d.ts +3 -0
  5. package/build/model-page/endpoints/index.d.ts.map +1 -0
  6. package/build/model-page/endpoints/index.js +18 -0
  7. package/build/model-page/endpoints/model-page.d.ts +6 -0
  8. package/build/model-page/endpoints/model-page.d.ts.map +1 -0
  9. package/build/model-page/endpoints/model-page.js +8 -0
  10. package/build/model-page/endpoints/queries/get-public-model-by-slug.query.d.ts +90 -0
  11. package/build/model-page/endpoints/queries/get-public-model-by-slug.query.d.ts.map +1 -0
  12. package/build/model-page/endpoints/queries/get-public-model-by-slug.query.js +24 -0
  13. package/build/model-page/endpoints/queries/index.d.ts +3 -0
  14. package/build/model-page/endpoints/queries/index.d.ts.map +1 -0
  15. package/build/model-page/endpoints/queries/index.js +18 -0
  16. package/build/model-page/endpoints/queries/list-public-models.query.d.ts +39 -0
  17. package/build/model-page/endpoints/queries/list-public-models.query.d.ts.map +1 -0
  18. package/build/model-page/endpoints/queries/list-public-models.query.js +19 -0
  19. package/build/model-page/index.d.ts +3 -0
  20. package/build/model-page/index.d.ts.map +1 -0
  21. package/build/model-page/index.js +18 -0
  22. package/build/model-page/models/index.d.ts +3 -0
  23. package/build/model-page/models/index.d.ts.map +1 -0
  24. package/build/model-page/models/index.js +18 -0
  25. package/build/model-page/models/public-model-card.schema.d.ts +16 -0
  26. package/build/model-page/models/public-model-card.schema.d.ts.map +1 -0
  27. package/build/model-page/models/public-model-card.schema.js +15 -0
  28. package/build/model-page/models/public-model-detail.schema.d.ts +74 -0
  29. package/build/model-page/models/public-model-detail.schema.d.ts.map +1 -0
  30. package/build/model-page/models/public-model-detail.schema.js +36 -0
  31. package/build/scripts/generate-openapi.js +36 -0
  32. package/build/tsconfig.tsbuildinfo +1 -1
  33. package/index.ts +1 -0
  34. package/model-page/endpoints/index.ts +2 -0
  35. package/model-page/endpoints/model-page.ts +6 -0
  36. package/model-page/endpoints/queries/get-public-model-by-slug.query.ts +24 -0
  37. package/model-page/endpoints/queries/index.ts +2 -0
  38. package/model-page/endpoints/queries/list-public-models.query.ts +18 -0
  39. package/model-page/index.ts +2 -0
  40. package/model-page/models/index.ts +2 -0
  41. package/model-page/models/public-model-card.schema.ts +15 -0
  42. package/model-page/models/public-model-detail.schema.ts +45 -0
  43. package/package.json +1 -1
  44. package/scripts/generate-openapi.ts +45 -0
package/index.ts CHANGED
@@ -2,6 +2,7 @@ export * from './_common';
2
2
  export * from './ai-model';
3
3
  export * from './generation-model';
4
4
  export * from './model-catalog';
5
+ export * from './model-page';
5
6
  export * from './generation-job';
6
7
  export * from './article';
7
8
  export * from './auth';
@@ -0,0 +1,2 @@
1
+ export * from './model-page';
2
+ export * from './queries';
@@ -0,0 +1,6 @@
1
+ export const PUBLIC_MODEL_CONTROLLER = 'ai' as const;
2
+
3
+ export const PUBLIC_MODEL_ROUTES = {
4
+ LIST: '',
5
+ GET_BY_SLUG: (slug: string) => `${slug}`,
6
+ } as const;
@@ -0,0 +1,24 @@
1
+ import { z } from 'zod';
2
+ import { defineContract, HTTP_METHODS, HttpErrorResponseSchema } from '../../../_common';
3
+ import { PublicModelDetailSchema } from '../../models';
4
+ import { PUBLIC_MODEL_ROUTES } from '../model-page';
5
+
6
+ export const GetPublicModelBySlugQueryParams = z.object({
7
+ slug: z.string().min(1),
8
+ });
9
+
10
+ export const GetPublicModelBySlugQueryResponse = PublicModelDetailSchema;
11
+
12
+ export const GetPublicModelBySlugQuery = defineContract({
13
+ method: HTTP_METHODS.GET,
14
+ path: PUBLIC_MODEL_ROUTES.GET_BY_SLUG(':slug'),
15
+ summary: 'Get published model by slug',
16
+ request: {
17
+ params: GetPublicModelBySlugQueryParams,
18
+ },
19
+ responses: {
20
+ 200: GetPublicModelBySlugQueryResponse,
21
+ 404: HttpErrorResponseSchema,
22
+ 500: HttpErrorResponseSchema,
23
+ },
24
+ });
@@ -0,0 +1,2 @@
1
+ export * from './get-public-model-by-slug.query';
2
+ export * from './list-public-models.query';
@@ -0,0 +1,18 @@
1
+ import { z } from 'zod';
2
+ import { defineContract, HTTP_METHODS, HttpErrorResponseSchema } from '../../../_common';
3
+ import { PublicModelCardSchema } from '../../models';
4
+ import { PUBLIC_MODEL_ROUTES } from '../model-page';
5
+
6
+ export const ListPublicModelsQueryResponse = z.object({
7
+ models: z.array(PublicModelCardSchema),
8
+ });
9
+
10
+ export const ListPublicModelsQuery = defineContract({
11
+ method: HTTP_METHODS.GET,
12
+ path: PUBLIC_MODEL_ROUTES.LIST,
13
+ summary: 'List published models (chat, image, video)',
14
+ responses: {
15
+ 200: ListPublicModelsQueryResponse,
16
+ 500: HttpErrorResponseSchema,
17
+ },
18
+ });
@@ -0,0 +1,2 @@
1
+ export * from './models';
2
+ export * from './endpoints';
@@ -0,0 +1,2 @@
1
+ export * from './public-model-card.schema';
2
+ export * from './public-model-detail.schema';
@@ -0,0 +1,15 @@
1
+ import { z } from 'zod';
2
+ import { IconSchema } from '../../_common';
3
+ import { MODEL_CATEGORY } from '../../model-catalog';
4
+
5
+ export const PublicModelCardSchema = z.object({
6
+ slug: z.string().min(1),
7
+ title: z.string().min(1),
8
+ description: z.string().nullable(),
9
+ vendorName: z.string().min(1),
10
+ icons: IconSchema,
11
+ category: z.enum(MODEL_CATEGORY),
12
+ order: z.number().int(),
13
+ });
14
+
15
+ export type PublicModelCardSchemaType = z.infer<typeof PublicModelCardSchema>;
@@ -0,0 +1,45 @@
1
+ import { z } from 'zod';
2
+ import { FILE_TYPE } from '../../file';
3
+ import { PublicModelCardSchema } from './public-model-card.schema';
4
+
5
+ export const PublicChatModelCapabilitiesSchema = z.object({
6
+ reasoning: z.boolean(),
7
+ webSearch: z.boolean(),
8
+ supportedFileTypes: z.array(z.enum(FILE_TYPE)),
9
+ });
10
+
11
+ export const PublicChatModelDetailsSchema = z.object({
12
+ type: z.array(z.string()),
13
+ features: z.array(z.string()),
14
+ maxMessageLength: z.number().int().positive(),
15
+ maxContextWindow: z.number().int().positive(),
16
+ capabilities: PublicChatModelCapabilitiesSchema,
17
+ });
18
+
19
+ export const PublicGenerationModelDetailsSchema = z.object({
20
+ supportedInputFileTypes: z.array(z.enum(FILE_TYPE)),
21
+ });
22
+
23
+ export const PublicModelContentSectionSchema = z.object({
24
+ id: z.string().min(1),
25
+ heading: z.string().min(1),
26
+ body: z.string().min(1),
27
+ });
28
+
29
+ export const PublicModelContentSchema = z.object({
30
+ sections: z.array(PublicModelContentSectionSchema),
31
+ });
32
+
33
+ export const PublicModelDetailSchema = PublicModelCardSchema.extend({
34
+ seoTitle: z.string().min(1),
35
+ seoDescription: z.string().nullable(),
36
+ content: PublicModelContentSchema.nullable(),
37
+ chat: PublicChatModelDetailsSchema.nullable(),
38
+ generation: PublicGenerationModelDetailsSchema.nullable(),
39
+ });
40
+
41
+ export type PublicModelContentSchemaType = z.infer<typeof PublicModelContentSchema>;
42
+ export type PublicChatModelCapabilitiesSchemaType = z.infer<typeof PublicChatModelCapabilitiesSchema>;
43
+ export type PublicChatModelDetailsSchemaType = z.infer<typeof PublicChatModelDetailsSchema>;
44
+ export type PublicGenerationModelDetailsSchemaType = z.infer<typeof PublicGenerationModelDetailsSchema>;
45
+ export type PublicModelDetailSchemaType = z.infer<typeof PublicModelDetailSchema>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ai-grator/api",
3
- "version": "0.1.31",
3
+ "version": "0.1.32",
4
4
  "main": "build/index.js",
5
5
  "types": "build/index.d.ts",
6
6
  "scripts": {
@@ -215,12 +215,22 @@ import {
215
215
  CreatePaymentCommandResponse,
216
216
  } from '../payment/endpoints/commands/create-payment.command';
217
217
  import { AI_MODELS_CONTROLLER } from '../ai-model/endpoints/ai-model';
218
+ import { PUBLIC_MODEL_CONTROLLER } from '../model-page/endpoints/model-page';
218
219
  import {
219
220
  GetAiModelByUuidQuery,
220
221
  GetAiModelByUuidQueryParams,
221
222
  GetAiModelByUuidQueryResponse,
222
223
  } from '../ai-model/endpoints/queries/get-ai-model-by-uuid.query';
223
224
  import { GetAllAiModelsQuery, GetAllAiModelsQueryResponse } from '../ai-model/endpoints/queries/get-ai-models.query';
225
+ import {
226
+ GetPublicModelBySlugQuery,
227
+ GetPublicModelBySlugQueryParams,
228
+ GetPublicModelBySlugQueryResponse,
229
+ } from '../model-page/endpoints/queries/get-public-model-by-slug.query';
230
+ import {
231
+ ListPublicModelsQuery,
232
+ ListPublicModelsQueryResponse,
233
+ } from '../model-page/endpoints/queries/list-public-models.query';
224
234
  import { MODEL_CATALOG_CONTROLLER } from '../model-catalog/endpoints/model-catalog';
225
235
  import {
226
236
  GetModelCatalogQuery,
@@ -466,6 +476,9 @@ async function main() {
466
476
  registerSchema('AiModelsGetAllResponse', GetAllAiModelsQueryResponse);
467
477
  registerSchema('AiModelsGetByUuidParams', GetAiModelByUuidQueryParams);
468
478
  registerSchema('AiModelsGetByUuidResponse', GetAiModelByUuidQueryResponse);
479
+ registerSchema('PublicModelsListResponse', ListPublicModelsQueryResponse);
480
+ registerSchema('PublicModelsGetBySlugParams', GetPublicModelBySlugQueryParams);
481
+ registerSchema('PublicModelsGetBySlugResponse', GetPublicModelBySlugQueryResponse);
469
482
  registerSchema('ModelCatalogGetAllResponse', GetModelCatalogQueryResponse);
470
483
  registerSchema('GenerationModelGetAllResponse', GetGenerationModelsQueryResponse);
471
484
  registerSchema('GenerationModelGetByTypeParams', GetGenerationModelsByTypeQueryParams);
@@ -612,6 +625,7 @@ async function main() {
612
625
  DeleteMarketplaceCardCommand,
613
626
  ];
614
627
  const aiModelContracts: HttpContract[] = [GetAllAiModelsQuery, GetAiModelByUuidQuery];
628
+ const publicModelContracts: HttpContract[] = [ListPublicModelsQuery, GetPublicModelBySlugQuery];
615
629
  const modelCatalogContracts: HttpContract[] = [GetModelCatalogQuery];
616
630
  const generationModelContracts: HttpContract[] = [
617
631
  GetGenerationModelsQuery,
@@ -908,6 +922,37 @@ async function main() {
908
922
  });
909
923
  }
910
924
 
925
+ for (const contract of publicModelContracts) {
926
+ const method = contract.method.toLowerCase();
927
+ if (!supportedHttpMethods.has(method)) {
928
+ throw new Error(`Unsupported HTTP method: ${contract.method}`);
929
+ }
930
+
931
+ registry.registerPath({
932
+ method: method as 'get' | 'post' | 'put' | 'patch' | 'delete',
933
+ path: toOpenApiPath(PUBLIC_MODEL_CONTROLLER, contract.path),
934
+ summary: contract.summary,
935
+ tags: ['Models (public)'],
936
+ request: {
937
+ ...(contract.request?.body
938
+ ? {
939
+ body: {
940
+ required: true,
941
+ content: {
942
+ 'application/json': {
943
+ schema: resolveSchema(contract.request.body),
944
+ },
945
+ },
946
+ },
947
+ }
948
+ : {}),
949
+ ...(contract.request?.query ? { query: resolveSchema(contract.request.query) } : {}),
950
+ ...(contract.request?.params ? { params: resolveSchema(contract.request.params) } : {}),
951
+ },
952
+ responses: buildResponses(contract.responses, resolveSchema),
953
+ });
954
+ }
955
+
911
956
  for (const contract of modelCatalogContracts) {
912
957
  const method = contract.method.toLowerCase();
913
958
  if (!supportedHttpMethods.has(method)) {