@ai-grator/api 0.1.38 → 0.1.40

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 (113) hide show
  1. package/build/admin/endpoints/commands/create-admin-page.command.d.ts +48 -0
  2. package/build/admin/endpoints/commands/create-admin-page.command.d.ts.map +1 -1
  3. package/build/admin/endpoints/commands/update-admin-page-status.command.d.ts +24 -0
  4. package/build/admin/endpoints/commands/update-admin-page-status.command.d.ts.map +1 -1
  5. package/build/admin/endpoints/commands/update-admin-page.command.d.ts +48 -0
  6. package/build/admin/endpoints/commands/update-admin-page.command.d.ts.map +1 -1
  7. package/build/admin/endpoints/queries/get-admin-page.query.d.ts +24 -0
  8. package/build/admin/endpoints/queries/get-admin-page.query.d.ts.map +1 -1
  9. package/build/admin/models/admin-page-response.schema.d.ts +12 -0
  10. package/build/admin/models/admin-page-response.schema.d.ts.map +1 -1
  11. package/build/errors/errors.d.ts +7 -0
  12. package/build/errors/errors.d.ts.map +1 -1
  13. package/build/errors/errors.js +7 -0
  14. package/build/generation-job/endpoints/commands/create-generation-job.command.d.ts +2 -2
  15. package/build/generation-job/endpoints/commands/update-generation-job.command.d.ts +2 -2
  16. package/build/generation-job/endpoints/queries/get-generation-job-by-uuid.query.d.ts +2 -2
  17. package/build/generation-job/endpoints/queries/get-generation-job-history.query.d.ts +3 -3
  18. package/build/generation-job/endpoints/queries/get-generation-jobs.query.d.ts +2 -2
  19. package/build/generation-job/models/generation-job-attachment-file.schema.d.ts +2 -2
  20. package/build/generation-job/models/generation-job-response.schema.d.ts +1 -1
  21. package/build/index.d.ts +1 -0
  22. package/build/index.d.ts.map +1 -1
  23. package/build/index.js +1 -0
  24. package/build/model-page/endpoints/model-page.d.ts +4 -0
  25. package/build/model-page/endpoints/model-page.d.ts.map +1 -1
  26. package/build/model-page/endpoints/model-page.js +5 -1
  27. package/build/model-page/endpoints/queries/get-public-model-by-slug.query.d.ts +24 -0
  28. package/build/model-page/endpoints/queries/get-public-model-by-slug.query.d.ts.map +1 -1
  29. package/build/model-page/endpoints/queries/get-public-page-by-slug.query.d.ts +387 -0
  30. package/build/model-page/endpoints/queries/get-public-page-by-slug.query.d.ts.map +1 -0
  31. package/build/model-page/endpoints/queries/get-public-page-by-slug.query.js +25 -0
  32. package/build/model-page/endpoints/queries/index.d.ts +1 -0
  33. package/build/model-page/endpoints/queries/index.d.ts.map +1 -1
  34. package/build/model-page/endpoints/queries/index.js +1 -0
  35. package/build/model-page/models/index.d.ts +1 -0
  36. package/build/model-page/models/index.d.ts.map +1 -1
  37. package/build/model-page/models/index.js +1 -0
  38. package/build/model-page/models/page-content.schema.d.ts +37 -0
  39. package/build/model-page/models/page-content.schema.d.ts.map +1 -1
  40. package/build/model-page/models/page-content.schema.js +13 -1
  41. package/build/model-page/models/public-model-detail.schema.d.ts +12 -0
  42. package/build/model-page/models/public-model-detail.schema.d.ts.map +1 -1
  43. package/build/model-page/models/public-page.schema.d.ts +187 -0
  44. package/build/model-page/models/public-page.schema.d.ts.map +1 -0
  45. package/build/model-page/models/public-page.schema.js +16 -0
  46. package/build/pricing-page/endpoints/index.d.ts +3 -0
  47. package/build/pricing-page/endpoints/index.d.ts.map +1 -0
  48. package/build/pricing-page/endpoints/index.js +18 -0
  49. package/build/pricing-page/endpoints/pricing-page.d.ts +5 -0
  50. package/build/pricing-page/endpoints/pricing-page.d.ts.map +1 -0
  51. package/build/pricing-page/endpoints/pricing-page.js +7 -0
  52. package/build/pricing-page/endpoints/queries/get-pricing-page.query.d.ts +132 -0
  53. package/build/pricing-page/endpoints/queries/get-pricing-page.query.d.ts.map +1 -0
  54. package/build/pricing-page/endpoints/queries/get-pricing-page.query.js +16 -0
  55. package/build/pricing-page/endpoints/queries/index.d.ts +2 -0
  56. package/build/pricing-page/endpoints/queries/index.d.ts.map +1 -0
  57. package/build/pricing-page/endpoints/queries/index.js +17 -0
  58. package/build/pricing-page/index.d.ts +3 -0
  59. package/build/pricing-page/index.d.ts.map +1 -0
  60. package/build/pricing-page/index.js +18 -0
  61. package/build/pricing-page/models/index.d.ts +9 -0
  62. package/build/pricing-page/models/index.d.ts.map +1 -0
  63. package/build/pricing-page/models/index.js +24 -0
  64. package/build/pricing-page/models/pricing-breadcrumb-item.schema.d.ts +7 -0
  65. package/build/pricing-page/models/pricing-breadcrumb-item.schema.d.ts.map +1 -0
  66. package/build/pricing-page/models/pricing-breadcrumb-item.schema.js +8 -0
  67. package/build/pricing-page/models/pricing-calculator-task.schema.d.ts +48 -0
  68. package/build/pricing-page/models/pricing-calculator-task.schema.d.ts.map +1 -0
  69. package/build/pricing-page/models/pricing-calculator-task.schema.js +27 -0
  70. package/build/pricing-page/models/pricing-faq-item.schema.d.ts +7 -0
  71. package/build/pricing-page/models/pricing-faq-item.schema.d.ts.map +1 -0
  72. package/build/pricing-page/models/pricing-faq-item.schema.js +8 -0
  73. package/build/pricing-page/models/pricing-image-model.schema.d.ts +10 -0
  74. package/build/pricing-page/models/pricing-image-model.schema.d.ts.map +1 -0
  75. package/build/pricing-page/models/pricing-image-model.schema.js +11 -0
  76. package/build/pricing-page/models/pricing-models.schema.d.ts +45 -0
  77. package/build/pricing-page/models/pricing-models.schema.d.ts.map +1 -0
  78. package/build/pricing-page/models/pricing-models.schema.js +17 -0
  79. package/build/pricing-page/models/pricing-page.schema.d.ts +64 -0
  80. package/build/pricing-page/models/pricing-page.schema.d.ts.map +1 -0
  81. package/build/pricing-page/models/pricing-page.schema.js +15 -0
  82. package/build/pricing-page/models/pricing-text-model.schema.d.ts +10 -0
  83. package/build/pricing-page/models/pricing-text-model.schema.d.ts.map +1 -0
  84. package/build/pricing-page/models/pricing-text-model.schema.js +11 -0
  85. package/build/pricing-page/models/pricing-video-model.schema.d.ts +13 -0
  86. package/build/pricing-page/models/pricing-video-model.schema.d.ts.map +1 -0
  87. package/build/pricing-page/models/pricing-video-model.schema.js +14 -0
  88. package/build/scripts/generate-openapi.js +67 -491
  89. package/build/tsconfig.tsbuildinfo +1 -1
  90. package/errors/errors.ts +7 -0
  91. package/index.ts +1 -0
  92. package/model-page/endpoints/model-page.ts +6 -0
  93. package/model-page/endpoints/queries/get-public-page-by-slug.query.ts +28 -0
  94. package/model-page/endpoints/queries/index.ts +1 -0
  95. package/model-page/models/index.ts +1 -0
  96. package/model-page/models/page-content.schema.ts +15 -0
  97. package/model-page/models/public-page.schema.ts +17 -0
  98. package/package.json +1 -1
  99. package/pricing-page/endpoints/index.ts +2 -0
  100. package/pricing-page/endpoints/pricing-page.ts +5 -0
  101. package/pricing-page/endpoints/queries/get-pricing-page.query.ts +15 -0
  102. package/pricing-page/endpoints/queries/index.ts +1 -0
  103. package/pricing-page/index.ts +2 -0
  104. package/pricing-page/models/index.ts +8 -0
  105. package/pricing-page/models/pricing-breadcrumb-item.schema.ts +8 -0
  106. package/pricing-page/models/pricing-calculator-task.schema.ts +34 -0
  107. package/pricing-page/models/pricing-faq-item.schema.ts +8 -0
  108. package/pricing-page/models/pricing-image-model.schema.ts +11 -0
  109. package/pricing-page/models/pricing-models.schema.ts +19 -0
  110. package/pricing-page/models/pricing-page.schema.ts +15 -0
  111. package/pricing-page/models/pricing-text-model.schema.ts +11 -0
  112. package/pricing-page/models/pricing-video-model.schema.ts +14 -0
  113. package/scripts/generate-openapi.ts +97 -526
@@ -5,6 +5,13 @@ import { OpenAPIRegistry, OpenApiGeneratorV3 } from '@asteasolutions/zod-to-open
5
5
  import { z } from 'zod';
6
6
 
7
7
  import type { HttpContract } from '../_common/http-contract.helper';
8
+
9
+ type ContractGroup = {
10
+ controller: string;
11
+ tag: string;
12
+ contracts: HttpContract[];
13
+ bodyContentType?: string;
14
+ };
8
15
  import { HttpErrorResponseSchema } from '../_common/error.contract';
9
16
  import { HttpSuccessResponseSchema } from '../_common/success.contract';
10
17
  import { ADMIN_CONTROLLER } from '../admin/endpoints/admin';
@@ -281,7 +288,12 @@ import {
281
288
  GetAdminOrganizationQueryResponse,
282
289
  } from '../admin/endpoints/queries/get-admin-organization.query';
283
290
  import { AI_MODELS_CONTROLLER } from '../ai-model/endpoints/ai-model';
284
- import { PUBLIC_MODEL_CONTROLLER } from '../model-page/endpoints/model-page';
291
+ import {
292
+ GetPublicPageBySlugQuery,
293
+ GetPublicPageBySlugQueryParams,
294
+ GetPublicPageBySlugQueryResponse,
295
+ } from '../model-page/endpoints/queries/get-public-page-by-slug.query';
296
+ import { PUBLIC_MODEL_CONTROLLER, PUBLIC_PAGE_CONTROLLER } from '../model-page/endpoints/model-page';
285
297
  import {
286
298
  GetAiModelByUuidQuery,
287
299
  GetAiModelByUuidQueryParams,
@@ -302,6 +314,11 @@ import {
302
314
  GetModelCatalogQuery,
303
315
  GetModelCatalogQueryResponse,
304
316
  } from '../model-catalog/endpoints/queries/get-model-catalog.query';
317
+ import { PRICING_PAGE_CONTROLLER } from '../pricing-page/endpoints/pricing-page';
318
+ import {
319
+ GetPricingPageQuery,
320
+ GetPricingPageQueryResponse,
321
+ } from '../pricing-page/endpoints/queries/get-pricing-page.query';
305
322
  import { GENERATION_MODEL_CONTROLLER } from '../generation-model/endpoints/generation-model';
306
323
  import {
307
324
  GetGenerationModelsQuery,
@@ -429,6 +446,11 @@ import {
429
446
 
430
447
  const supportedHttpMethods = new Set(['get', 'post', 'put', 'patch', 'delete']);
431
448
 
449
+ type OpenApiResponse = {
450
+ description: string;
451
+ content: Record<string, { schema: z.ZodTypeAny }>;
452
+ };
453
+
432
454
  function toOpenApiPath(controller: string, routePath: string): string {
433
455
  const normalizedController = controller.replace(/^\/+|\/+$/g, '');
434
456
  const normalizedRoute = routePath.replace(/^\/+|\/+$/g, '');
@@ -440,8 +462,8 @@ function toOpenApiPath(controller: string, routePath: string): string {
440
462
  function buildResponses(
441
463
  contractsResponses: HttpContract['responses'],
442
464
  schemaResolver: (schema: z.ZodTypeAny) => z.ZodTypeAny,
443
- ) {
444
- const entries = Object.entries(contractsResponses).map(([status, schema]) => {
465
+ ): Record<string, OpenApiResponse> {
466
+ const entries = Object.entries(contractsResponses).map(([status, schema]): [string, OpenApiResponse] => {
445
467
  return [
446
468
  status,
447
469
  {
@@ -462,8 +484,8 @@ function buildSseSuccessResponses(
462
484
  contractsResponses: HttpContract['responses'],
463
485
  successStatus: number,
464
486
  schemaResolver: (schema: z.ZodTypeAny) => z.ZodTypeAny,
465
- ) {
466
- const entries = Object.entries(contractsResponses).map(([status, schema]) => {
487
+ ): Record<string, OpenApiResponse> {
488
+ const entries = Object.entries(contractsResponses).map(([status, schema]): [string, OpenApiResponse] => {
467
489
  const statusCode = Number(status);
468
490
  const contentType = statusCode === successStatus ? 'text/event-stream' : 'application/json';
469
491
 
@@ -546,6 +568,7 @@ async function main() {
546
568
  registerSchema('PublicModelsGetBySlugParams', GetPublicModelBySlugQueryParams);
547
569
  registerSchema('PublicModelsGetBySlugResponse', GetPublicModelBySlugQueryResponse);
548
570
  registerSchema('ModelCatalogGetAllResponse', GetModelCatalogQueryResponse);
571
+ registerSchema('PricingPageGetResponse', GetPricingPageQueryResponse);
549
572
  registerSchema('GenerationModelGetAllResponse', GetGenerationModelsQueryResponse);
550
573
  registerSchema('GenerationModelGetByTypeParams', GetGenerationModelsByTypeQueryParams);
551
574
  registerSchema('GenerationModelGetByTypeResponse', GetGenerationModelsByTypeQueryResponse);
@@ -664,6 +687,8 @@ async function main() {
664
687
  registerSchema('AdminUpdateOrganizationRequest', UpdateAdminOrganizationCommandBody);
665
688
  registerSchema('AdminUpdateOrganizationResponse', UpdateAdminOrganizationCommandResponse);
666
689
  registerSchema('OrganizationGetResponse', GetOrganizationQueryResponse);
690
+ registerSchema('PublicPageGetBySlugParams', GetPublicPageBySlugQueryParams);
691
+ registerSchema('PublicPageGetBySlugResponse', GetPublicPageBySlugQueryResponse);
667
692
  registerSchema('UserContextGetResponse', GetUserContextQueryResponse);
668
693
  registerSchema('UserContextUpsertRequest', UpsertUserContextCommandBody);
669
694
  registerSchema('UserContextUpsertResponse', UpsertUserContextCommandResponse);
@@ -718,7 +743,9 @@ async function main() {
718
743
  ];
719
744
  const aiModelContracts: HttpContract[] = [GetAllAiModelsQuery, GetAiModelByUuidQuery];
720
745
  const publicModelContracts: HttpContract[] = [ListPublicModelsQuery, GetPublicModelBySlugQuery];
746
+ const publicPageContracts: HttpContract[] = [GetPublicPageBySlugQuery];
721
747
  const modelCatalogContracts: HttpContract[] = [GetModelCatalogQuery];
748
+ const pricingPageContracts: HttpContract[] = [GetPricingPageQuery];
722
749
  const generationModelContracts: HttpContract[] = [
723
750
  GetGenerationModelsQuery,
724
751
  GetGenerationModelsByTypeQuery,
@@ -776,534 +803,78 @@ async function main() {
776
803
  ];
777
804
  const organizationContracts: HttpContract[] = [GetOrganizationQuery];
778
805
 
779
- for (const contract of authContracts) {
780
- const method = contract.method.toLowerCase();
781
- if (!supportedHttpMethods.has(method)) {
782
- throw new Error(`Unsupported HTTP method: ${contract.method}`);
783
- }
784
-
785
- registry.registerPath({
786
- method: method as 'get' | 'post' | 'put' | 'patch' | 'delete',
787
- path: toOpenApiPath(AUTH_CONTROLLER, contract.path),
788
- summary: contract.summary,
789
- tags: ['Auth'],
790
- request: {
791
- ...(contract.request?.body
792
- ? {
793
- body: {
794
- required: true,
795
- content: {
796
- 'application/json': {
797
- schema: resolveSchema(contract.request.body),
798
- },
799
- },
800
- },
801
- }
802
- : {}),
803
- ...(contract.request?.query ? { query: resolveSchema(contract.request.query) } : {}),
804
- ...(contract.request?.params ? { params: resolveSchema(contract.request.params) } : {}),
805
- },
806
- responses: buildResponses(contract.responses, resolveSchema),
807
- });
808
- }
809
-
810
- for (const contract of chatContracts) {
811
- const method = contract.method.toLowerCase();
812
- if (!supportedHttpMethods.has(method)) {
813
- throw new Error(`Unsupported HTTP method: ${contract.method}`);
814
- }
815
-
816
- registry.registerPath({
817
- method: method as 'get' | 'post' | 'put' | 'patch' | 'delete',
818
- path: toOpenApiPath(CHAT_CONTROLLER, contract.path),
819
- summary: contract.summary,
820
- tags: ['Chat'],
821
- request: {
822
- ...(contract.request?.body
823
- ? {
824
- body: {
825
- required: true,
826
- content: {
827
- 'application/json': {
828
- schema: resolveSchema(contract.request.body),
829
- },
830
- },
831
- },
832
- }
833
- : {}),
834
- ...(contract.request?.query ? { query: resolveSchema(contract.request.query) } : {}),
835
- ...(contract.request?.params ? { params: resolveSchema(contract.request.params) } : {}),
836
- },
837
- responses: buildResponses(contract.responses, resolveSchema),
838
- });
839
- }
840
-
841
- for (const contract of messageContracts) {
842
- const method = contract.method.toLowerCase();
843
- if (!supportedHttpMethods.has(method)) {
844
- throw new Error(`Unsupported HTTP method: ${contract.method}`);
845
- }
846
-
847
- registry.registerPath({
848
- method: method as 'get' | 'post' | 'put' | 'patch' | 'delete',
849
- path: toOpenApiPath(MESSAGE_CONTROLLER, contract.path),
850
- summary: contract.summary,
851
- tags: ['Message'],
852
- request: {
853
- ...(contract.request?.body
854
- ? {
855
- body: {
856
- required: true,
857
- content: {
858
- 'application/json': {
859
- schema: resolveSchema(contract.request.body),
806
+ const DEFAULT_BODY_CONTENT_TYPE = 'application/json';
807
+ const SSE_CREATED_CONTRACTS = new Set<HttpContract>([CreateMessageCommand]);
808
+
809
+ const registerContractGroup = ({
810
+ controller,
811
+ tag,
812
+ contracts,
813
+ bodyContentType = DEFAULT_BODY_CONTENT_TYPE,
814
+ }: ContractGroup): void => {
815
+ for (const contract of contracts) {
816
+ const method = contract.method.toLowerCase();
817
+
818
+ if (!supportedHttpMethods.has(method)) {
819
+ throw new Error(`Unsupported HTTP method: ${contract.method}`);
820
+ }
821
+
822
+ registry.registerPath({
823
+ method: method as 'get' | 'post' | 'put' | 'patch' | 'delete',
824
+ path: toOpenApiPath(controller, contract.path),
825
+ summary: contract.summary,
826
+ tags: [tag],
827
+ request: {
828
+ ...(contract.request?.body
829
+ ? {
830
+ body: {
831
+ required: true,
832
+ content: {
833
+ [bodyContentType]: {
834
+ schema: resolveSchema(contract.request.body),
835
+ },
860
836
  },
861
837
  },
862
- },
863
- }
864
- : {}),
865
- ...(contract.request?.query ? { query: resolveSchema(contract.request.query) } : {}),
866
- ...(contract.request?.params ? { params: resolveSchema(contract.request.params) } : {}),
867
- },
868
- responses:
869
- contract === CreateMessageCommand
838
+ }
839
+ : {}),
840
+ ...(contract.request?.query ? { query: resolveSchema(contract.request.query) } : {}),
841
+ ...(contract.request?.params ? { params: resolveSchema(contract.request.params) } : {}),
842
+ },
843
+ responses: SSE_CREATED_CONTRACTS.has(contract)
870
844
  ? buildSseSuccessResponses(contract.responses, 201, resolveSchema)
871
845
  : buildResponses(contract.responses, resolveSchema),
872
- });
873
- }
874
-
875
- for (const contract of fileContracts) {
876
- const method = contract.method.toLowerCase();
877
- if (!supportedHttpMethods.has(method)) {
878
- throw new Error(`Unsupported HTTP method: ${contract.method}`);
879
- }
880
-
881
- registry.registerPath({
882
- method: method as 'get' | 'post' | 'put' | 'patch' | 'delete',
883
- path: toOpenApiPath(FILE_CONTROLLER, contract.path),
884
- summary: contract.summary,
885
- tags: ['File'],
886
- request: {
887
- ...(contract.request?.body
888
- ? {
889
- body: {
890
- required: true,
891
- content: {
892
- 'multipart/form-data': {
893
- schema: resolveSchema(contract.request.body),
894
- },
895
- },
896
- },
897
- }
898
- : {}),
899
- ...(contract.request?.query ? { query: resolveSchema(contract.request.query) } : {}),
900
- ...(contract.request?.params ? { params: resolveSchema(contract.request.params) } : {}),
901
- },
902
- responses: buildResponses(contract.responses, resolveSchema),
903
- });
904
- }
905
-
906
- for (const contract of supportContracts) {
907
- const method = contract.method.toLowerCase();
908
- if (!supportedHttpMethods.has(method)) {
909
- throw new Error(`Unsupported HTTP method: ${contract.method}`);
910
- }
911
-
912
- registry.registerPath({
913
- method: method as 'get' | 'post' | 'put' | 'patch' | 'delete',
914
- path: toOpenApiPath(SUPPORT_CONTROLLER, contract.path),
915
- summary: contract.summary,
916
- tags: ['Support'],
917
- request: {
918
- ...(contract.request?.body
919
- ? {
920
- body: {
921
- required: true,
922
- content: {
923
- 'application/json': {
924
- schema: resolveSchema(contract.request.body),
925
- },
926
- },
927
- },
928
- }
929
- : {}),
930
- ...(contract.request?.query ? { query: resolveSchema(contract.request.query) } : {}),
931
- ...(contract.request?.params ? { params: resolveSchema(contract.request.params) } : {}),
932
- },
933
- responses: buildResponses(contract.responses, resolveSchema),
934
- });
935
- }
936
-
937
- for (const contract of walletContracts) {
938
- const method = contract.method.toLowerCase();
939
- if (!supportedHttpMethods.has(method)) {
940
- throw new Error(`Unsupported HTTP method: ${contract.method}`);
941
- }
942
-
943
- registry.registerPath({
944
- method: method as 'get' | 'post' | 'put' | 'patch' | 'delete',
945
- path: toOpenApiPath(WALLET_CONTROLLER, contract.path),
946
- summary: contract.summary,
947
- tags: ['Wallet'],
948
- request: {
949
- ...(contract.request?.body
950
- ? {
951
- body: {
952
- required: true,
953
- content: {
954
- 'application/json': {
955
- schema: resolveSchema(contract.request.body),
956
- },
957
- },
958
- },
959
- }
960
- : {}),
961
- ...(contract.request?.query ? { query: resolveSchema(contract.request.query) } : {}),
962
- ...(contract.request?.params ? { params: resolveSchema(contract.request.params) } : {}),
963
- },
964
- responses: buildResponses(contract.responses, resolveSchema),
965
- });
966
- }
967
-
968
- for (const contract of paymentContracts) {
969
- const method = contract.method.toLowerCase();
970
- if (!supportedHttpMethods.has(method)) {
971
- throw new Error(`Unsupported HTTP method: ${contract.method}`);
972
- }
973
-
974
- registry.registerPath({
975
- method: method as 'get' | 'post' | 'put' | 'patch' | 'delete',
976
- path: toOpenApiPath(PAYMENT_CONTROLLER, contract.path),
977
- summary: contract.summary,
978
- tags: ['Payment'],
979
- request: {
980
- ...(contract.request?.body
981
- ? {
982
- body: {
983
- required: true,
984
- content: {
985
- 'application/json': {
986
- schema: resolveSchema(contract.request.body),
987
- },
988
- },
989
- },
990
- }
991
- : {}),
992
- ...(contract.request?.query ? { query: resolveSchema(contract.request.query) } : {}),
993
- ...(contract.request?.params ? { params: resolveSchema(contract.request.params) } : {}),
994
- },
995
- responses: buildResponses(contract.responses, resolveSchema),
996
- });
997
- }
998
-
999
- for (const contract of aiModelContracts) {
1000
- const method = contract.method.toLowerCase();
1001
- if (!supportedHttpMethods.has(method)) {
1002
- throw new Error(`Unsupported HTTP method: ${contract.method}`);
1003
- }
1004
-
1005
- registry.registerPath({
1006
- method: method as 'get' | 'post' | 'put' | 'patch' | 'delete',
1007
- path: toOpenApiPath(AI_MODELS_CONTROLLER, contract.path),
1008
- summary: contract.summary,
1009
- tags: ['AI Models'],
1010
- request: {
1011
- ...(contract.request?.body
1012
- ? {
1013
- body: {
1014
- required: true,
1015
- content: {
1016
- 'application/json': {
1017
- schema: resolveSchema(contract.request.body),
1018
- },
1019
- },
1020
- },
1021
- }
1022
- : {}),
1023
- ...(contract.request?.query ? { query: resolveSchema(contract.request.query) } : {}),
1024
- ...(contract.request?.params ? { params: resolveSchema(contract.request.params) } : {}),
1025
- },
1026
- responses: buildResponses(contract.responses, resolveSchema),
1027
- });
1028
- }
1029
-
1030
- for (const contract of publicModelContracts) {
1031
- const method = contract.method.toLowerCase();
1032
- if (!supportedHttpMethods.has(method)) {
1033
- throw new Error(`Unsupported HTTP method: ${contract.method}`);
1034
- }
1035
-
1036
- registry.registerPath({
1037
- method: method as 'get' | 'post' | 'put' | 'patch' | 'delete',
1038
- path: toOpenApiPath(PUBLIC_MODEL_CONTROLLER, contract.path),
1039
- summary: contract.summary,
1040
- tags: ['Models (public)'],
1041
- request: {
1042
- ...(contract.request?.body
1043
- ? {
1044
- body: {
1045
- required: true,
1046
- content: {
1047
- 'application/json': {
1048
- schema: resolveSchema(contract.request.body),
1049
- },
1050
- },
1051
- },
1052
- }
1053
- : {}),
1054
- ...(contract.request?.query ? { query: resolveSchema(contract.request.query) } : {}),
1055
- ...(contract.request?.params ? { params: resolveSchema(contract.request.params) } : {}),
1056
- },
1057
- responses: buildResponses(contract.responses, resolveSchema),
1058
- });
1059
- }
1060
-
1061
- for (const contract of modelCatalogContracts) {
1062
- const method = contract.method.toLowerCase();
1063
- if (!supportedHttpMethods.has(method)) {
1064
- throw new Error(`Unsupported HTTP method: ${contract.method}`);
1065
- }
1066
-
1067
- registry.registerPath({
1068
- method: method as 'get' | 'post' | 'put' | 'patch' | 'delete',
1069
- path: toOpenApiPath(MODEL_CATALOG_CONTROLLER, contract.path),
1070
- summary: contract.summary,
1071
- tags: ['Model Catalog'],
1072
- request: {
1073
- ...(contract.request?.body
1074
- ? {
1075
- body: {
1076
- required: true,
1077
- content: {
1078
- 'application/json': {
1079
- schema: resolveSchema(contract.request.body),
1080
- },
1081
- },
1082
- },
1083
- }
1084
- : {}),
1085
- ...(contract.request?.query ? { query: resolveSchema(contract.request.query) } : {}),
1086
- ...(contract.request?.params ? { params: resolveSchema(contract.request.params) } : {}),
1087
- },
1088
- responses: buildResponses(contract.responses, resolveSchema),
1089
- });
1090
- }
1091
-
1092
- for (const contract of generationModelContracts) {
1093
- const method = contract.method.toLowerCase();
1094
- if (!supportedHttpMethods.has(method)) {
1095
- throw new Error(`Unsupported HTTP method: ${contract.method}`);
1096
- }
1097
-
1098
- registry.registerPath({
1099
- method: method as 'get' | 'post' | 'put' | 'patch' | 'delete',
1100
- path: toOpenApiPath(GENERATION_MODEL_CONTROLLER, contract.path),
1101
- summary: contract.summary,
1102
- tags: ['Generation Models'],
1103
- request: {
1104
- ...(contract.request?.body
1105
- ? {
1106
- body: {
1107
- required: true,
1108
- content: {
1109
- 'application/json': {
1110
- schema: resolveSchema(contract.request.body),
1111
- },
1112
- },
1113
- },
1114
- }
1115
- : {}),
1116
- ...(contract.request?.query ? { query: resolveSchema(contract.request.query) } : {}),
1117
- ...(contract.request?.params ? { params: resolveSchema(contract.request.params) } : {}),
1118
- },
1119
- responses: buildResponses(contract.responses, resolveSchema),
1120
- });
1121
- }
1122
-
1123
- for (const contract of generationJobContracts) {
1124
- const method = contract.method.toLowerCase();
1125
- if (!supportedHttpMethods.has(method)) {
1126
- throw new Error(`Unsupported HTTP method: ${contract.method}`);
1127
- }
1128
-
1129
- registry.registerPath({
1130
- method: method as 'get' | 'post' | 'put' | 'patch' | 'delete',
1131
- path: toOpenApiPath(GENERATION_JOB_CONTROLLER, contract.path),
1132
- summary: contract.summary,
1133
- tags: ['Generation Jobs'],
1134
- request: {
1135
- ...(contract.request?.body
1136
- ? {
1137
- body: {
1138
- required: true,
1139
- content: {
1140
- 'application/json': {
1141
- schema: resolveSchema(contract.request.body),
1142
- },
1143
- },
1144
- },
1145
- }
1146
- : {}),
1147
- ...(contract.request?.query ? { query: resolveSchema(contract.request.query) } : {}),
1148
- ...(contract.request?.params ? { params: resolveSchema(contract.request.params) } : {}),
1149
- },
1150
- responses: buildResponses(contract.responses, resolveSchema),
1151
- });
1152
- }
1153
-
1154
- for (const contract of generationJobChatContracts) {
1155
- const method = contract.method.toLowerCase();
1156
- if (!supportedHttpMethods.has(method)) {
1157
- throw new Error(`Unsupported HTTP method: ${contract.method}`);
1158
- }
1159
-
1160
- registry.registerPath({
1161
- method: method as 'get' | 'post' | 'put' | 'patch' | 'delete',
1162
- path: toOpenApiPath(GENERATION_JOB_CHAT_CONTROLLER, contract.path),
1163
- summary: contract.summary,
1164
- tags: ['Generation Job Chats'],
1165
- request: {
1166
- ...(contract.request?.body
1167
- ? {
1168
- body: {
1169
- required: true,
1170
- content: {
1171
- 'application/json': {
1172
- schema: resolveSchema(contract.request.body),
1173
- },
1174
- },
1175
- },
1176
- }
1177
- : {}),
1178
- ...(contract.request?.query ? { query: resolveSchema(contract.request.query) } : {}),
1179
- ...(contract.request?.params ? { params: resolveSchema(contract.request.params) } : {}),
1180
- },
1181
- responses: buildResponses(contract.responses, resolveSchema),
1182
- });
1183
- }
1184
-
1185
- for (const contract of adminContracts) {
1186
- const method = contract.method.toLowerCase();
1187
- if (!supportedHttpMethods.has(method)) {
1188
- throw new Error(`Unsupported HTTP method: ${contract.method}`);
1189
- }
1190
-
1191
- registry.registerPath({
1192
- method: method as 'get' | 'post' | 'put' | 'patch' | 'delete',
1193
- path: toOpenApiPath(ADMIN_CONTROLLER, contract.path),
1194
- summary: contract.summary,
1195
- tags: ['Admin'],
1196
- request: {
1197
- ...(contract.request?.body
1198
- ? {
1199
- body: {
1200
- required: true,
1201
- content: {
1202
- 'application/json': {
1203
- schema: resolveSchema(contract.request.body),
1204
- },
1205
- },
1206
- },
1207
- }
1208
- : {}),
1209
- ...(contract.request?.query ? { query: resolveSchema(contract.request.query) } : {}),
1210
- ...(contract.request?.params ? { params: resolveSchema(contract.request.params) } : {}),
1211
- },
1212
- responses: buildResponses(contract.responses, resolveSchema),
1213
- });
1214
- }
1215
-
1216
- for (const contract of marketplaceCardContracts) {
1217
- const method = contract.method.toLowerCase();
1218
- if (!supportedHttpMethods.has(method)) {
1219
- throw new Error(`Unsupported HTTP method: ${contract.method}`);
1220
- }
1221
-
1222
- registry.registerPath({
1223
- method: method as 'get' | 'post' | 'put' | 'patch' | 'delete',
1224
- path: toOpenApiPath(MARKETPLACE_CARD_CONTROLLER, contract.path),
1225
- summary: contract.summary,
1226
- tags: ['Marketplace Cards'],
1227
- request: {
1228
- ...(contract.request?.body
1229
- ? {
1230
- body: {
1231
- required: true,
1232
- content: {
1233
- 'application/json': {
1234
- schema: resolveSchema(contract.request.body),
1235
- },
1236
- },
1237
- },
1238
- }
1239
- : {}),
1240
- ...(contract.request?.query ? { query: resolveSchema(contract.request.query) } : {}),
1241
- ...(contract.request?.params ? { params: resolveSchema(contract.request.params) } : {}),
1242
- },
1243
- responses: buildResponses(contract.responses, resolveSchema),
1244
- });
1245
- }
1246
-
1247
- for (const contract of organizationContracts) {
1248
- const method = contract.method.toLowerCase();
1249
- if (!supportedHttpMethods.has(method)) {
1250
- throw new Error(`Unsupported HTTP method: ${contract.method}`);
846
+ });
1251
847
  }
848
+ };
1252
849
 
1253
- registry.registerPath({
1254
- method: method as 'get' | 'post' | 'put' | 'patch' | 'delete',
1255
- path: toOpenApiPath(ORGANIZATION_CONTROLLER, contract.path),
1256
- summary: contract.summary,
1257
- tags: ['Organization'],
1258
- request: {
1259
- ...(contract.request?.body
1260
- ? {
1261
- body: {
1262
- required: true,
1263
- content: {
1264
- 'application/json': {
1265
- schema: resolveSchema(contract.request.body),
1266
- },
1267
- },
1268
- },
1269
- }
1270
- : {}),
1271
- ...(contract.request?.query ? { query: resolveSchema(contract.request.query) } : {}),
1272
- ...(contract.request?.params ? { params: resolveSchema(contract.request.params) } : {}),
1273
- },
1274
- responses: buildResponses(contract.responses, resolveSchema),
1275
- });
1276
- }
1277
-
1278
- for (const contract of userContextContracts) {
1279
- const method = contract.method.toLowerCase();
1280
- if (!supportedHttpMethods.has(method)) {
1281
- throw new Error(`Unsupported HTTP method: ${contract.method}`);
1282
- }
850
+ const contractGroups: ContractGroup[] = [
851
+ { controller: AUTH_CONTROLLER, tag: 'Auth', contracts: authContracts },
852
+ { controller: CHAT_CONTROLLER, tag: 'Chat', contracts: chatContracts },
853
+ { controller: MESSAGE_CONTROLLER, tag: 'Message', contracts: messageContracts },
854
+ { controller: FILE_CONTROLLER, tag: 'File', contracts: fileContracts, bodyContentType: 'multipart/form-data' },
855
+ { controller: SUPPORT_CONTROLLER, tag: 'Support', contracts: supportContracts },
856
+ { controller: WALLET_CONTROLLER, tag: 'Wallet', contracts: walletContracts },
857
+ { controller: PAYMENT_CONTROLLER, tag: 'Payment', contracts: paymentContracts },
858
+ { controller: AI_MODELS_CONTROLLER, tag: 'AI Models', contracts: aiModelContracts },
859
+ { controller: PUBLIC_MODEL_CONTROLLER, tag: 'Models (public)', contracts: publicModelContracts },
860
+ { controller: PUBLIC_PAGE_CONTROLLER, tag: 'Pages (public)', contracts: publicPageContracts },
861
+ { controller: MODEL_CATALOG_CONTROLLER, tag: 'Model Catalog', contracts: modelCatalogContracts },
862
+ { controller: PRICING_PAGE_CONTROLLER, tag: 'Pricing Page (public)', contracts: pricingPageContracts },
863
+ { controller: GENERATION_MODEL_CONTROLLER, tag: 'Generation Models', contracts: generationModelContracts },
864
+ { controller: GENERATION_JOB_CONTROLLER, tag: 'Generation Jobs', contracts: generationJobContracts },
865
+ {
866
+ controller: GENERATION_JOB_CHAT_CONTROLLER,
867
+ tag: 'Generation Job Chats',
868
+ contracts: generationJobChatContracts,
869
+ },
870
+ { controller: ADMIN_CONTROLLER, tag: 'Admin', contracts: adminContracts },
871
+ { controller: MARKETPLACE_CARD_CONTROLLER, tag: 'Marketplace Cards', contracts: marketplaceCardContracts },
872
+ { controller: ORGANIZATION_CONTROLLER, tag: 'Organization', contracts: organizationContracts },
873
+ { controller: USER_CONTEXT_CONTROLLER, tag: 'User Context', contracts: userContextContracts },
874
+ ];
1283
875
 
1284
- registry.registerPath({
1285
- method: method as 'get' | 'post' | 'put' | 'patch' | 'delete',
1286
- path: toOpenApiPath(USER_CONTEXT_CONTROLLER, contract.path),
1287
- summary: contract.summary,
1288
- tags: ['User Context'],
1289
- request: {
1290
- ...(contract.request?.body
1291
- ? {
1292
- body: {
1293
- required: true,
1294
- content: {
1295
- 'application/json': {
1296
- schema: resolveSchema(contract.request.body),
1297
- },
1298
- },
1299
- },
1300
- }
1301
- : {}),
1302
- ...(contract.request?.query ? { query: resolveSchema(contract.request.query) } : {}),
1303
- ...(contract.request?.params ? { params: resolveSchema(contract.request.params) } : {}),
1304
- },
1305
- responses: buildResponses(contract.responses, resolveSchema),
1306
- });
876
+ for (const group of contractGroups) {
877
+ registerContractGroup(group);
1307
878
  }
1308
879
 
1309
880
  const generator = new OpenApiGeneratorV3(registry.definitions);