@ai-grator/api 0.1.38 → 0.1.39

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 (42) 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/model-page/endpoints/model-page.d.ts +4 -0
  12. package/build/model-page/endpoints/model-page.d.ts.map +1 -1
  13. package/build/model-page/endpoints/model-page.js +5 -1
  14. package/build/model-page/endpoints/queries/get-public-model-by-slug.query.d.ts +24 -0
  15. package/build/model-page/endpoints/queries/get-public-model-by-slug.query.d.ts.map +1 -1
  16. package/build/model-page/endpoints/queries/get-public-page-by-slug.query.d.ts +387 -0
  17. package/build/model-page/endpoints/queries/get-public-page-by-slug.query.d.ts.map +1 -0
  18. package/build/model-page/endpoints/queries/get-public-page-by-slug.query.js +25 -0
  19. package/build/model-page/endpoints/queries/index.d.ts +1 -0
  20. package/build/model-page/endpoints/queries/index.d.ts.map +1 -1
  21. package/build/model-page/endpoints/queries/index.js +1 -0
  22. package/build/model-page/models/index.d.ts +1 -0
  23. package/build/model-page/models/index.d.ts.map +1 -1
  24. package/build/model-page/models/index.js +1 -0
  25. package/build/model-page/models/page-content.schema.d.ts +37 -0
  26. package/build/model-page/models/page-content.schema.d.ts.map +1 -1
  27. package/build/model-page/models/page-content.schema.js +13 -1
  28. package/build/model-page/models/public-model-detail.schema.d.ts +12 -0
  29. package/build/model-page/models/public-model-detail.schema.d.ts.map +1 -1
  30. package/build/model-page/models/public-page.schema.d.ts +187 -0
  31. package/build/model-page/models/public-page.schema.d.ts.map +1 -0
  32. package/build/model-page/models/public-page.schema.js +16 -0
  33. package/build/scripts/generate-openapi.js +62 -491
  34. package/build/tsconfig.tsbuildinfo +1 -1
  35. package/model-page/endpoints/model-page.ts +6 -0
  36. package/model-page/endpoints/queries/get-public-page-by-slug.query.ts +28 -0
  37. package/model-page/endpoints/queries/index.ts +1 -0
  38. package/model-page/models/index.ts +1 -0
  39. package/model-page/models/page-content.schema.ts +15 -0
  40. package/model-page/models/public-page.schema.ts +17 -0
  41. package/package.json +1 -1
  42. package/scripts/generate-openapi.ts +89 -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,
@@ -429,6 +441,11 @@ import {
429
441
 
430
442
  const supportedHttpMethods = new Set(['get', 'post', 'put', 'patch', 'delete']);
431
443
 
444
+ type OpenApiResponse = {
445
+ description: string;
446
+ content: Record<string, { schema: z.ZodTypeAny }>;
447
+ };
448
+
432
449
  function toOpenApiPath(controller: string, routePath: string): string {
433
450
  const normalizedController = controller.replace(/^\/+|\/+$/g, '');
434
451
  const normalizedRoute = routePath.replace(/^\/+|\/+$/g, '');
@@ -440,8 +457,8 @@ function toOpenApiPath(controller: string, routePath: string): string {
440
457
  function buildResponses(
441
458
  contractsResponses: HttpContract['responses'],
442
459
  schemaResolver: (schema: z.ZodTypeAny) => z.ZodTypeAny,
443
- ) {
444
- const entries = Object.entries(contractsResponses).map(([status, schema]) => {
460
+ ): Record<string, OpenApiResponse> {
461
+ const entries = Object.entries(contractsResponses).map(([status, schema]): [string, OpenApiResponse] => {
445
462
  return [
446
463
  status,
447
464
  {
@@ -462,8 +479,8 @@ function buildSseSuccessResponses(
462
479
  contractsResponses: HttpContract['responses'],
463
480
  successStatus: number,
464
481
  schemaResolver: (schema: z.ZodTypeAny) => z.ZodTypeAny,
465
- ) {
466
- const entries = Object.entries(contractsResponses).map(([status, schema]) => {
482
+ ): Record<string, OpenApiResponse> {
483
+ const entries = Object.entries(contractsResponses).map(([status, schema]): [string, OpenApiResponse] => {
467
484
  const statusCode = Number(status);
468
485
  const contentType = statusCode === successStatus ? 'text/event-stream' : 'application/json';
469
486
 
@@ -664,6 +681,8 @@ async function main() {
664
681
  registerSchema('AdminUpdateOrganizationRequest', UpdateAdminOrganizationCommandBody);
665
682
  registerSchema('AdminUpdateOrganizationResponse', UpdateAdminOrganizationCommandResponse);
666
683
  registerSchema('OrganizationGetResponse', GetOrganizationQueryResponse);
684
+ registerSchema('PublicPageGetBySlugParams', GetPublicPageBySlugQueryParams);
685
+ registerSchema('PublicPageGetBySlugResponse', GetPublicPageBySlugQueryResponse);
667
686
  registerSchema('UserContextGetResponse', GetUserContextQueryResponse);
668
687
  registerSchema('UserContextUpsertRequest', UpsertUserContextCommandBody);
669
688
  registerSchema('UserContextUpsertResponse', UpsertUserContextCommandResponse);
@@ -718,6 +737,7 @@ async function main() {
718
737
  ];
719
738
  const aiModelContracts: HttpContract[] = [GetAllAiModelsQuery, GetAiModelByUuidQuery];
720
739
  const publicModelContracts: HttpContract[] = [ListPublicModelsQuery, GetPublicModelBySlugQuery];
740
+ const publicPageContracts: HttpContract[] = [GetPublicPageBySlugQuery];
721
741
  const modelCatalogContracts: HttpContract[] = [GetModelCatalogQuery];
722
742
  const generationModelContracts: HttpContract[] = [
723
743
  GetGenerationModelsQuery,
@@ -776,534 +796,77 @@ async function main() {
776
796
  ];
777
797
  const organizationContracts: HttpContract[] = [GetOrganizationQuery];
778
798
 
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),
799
+ const DEFAULT_BODY_CONTENT_TYPE = 'application/json';
800
+ const SSE_CREATED_CONTRACTS = new Set<HttpContract>([CreateMessageCommand]);
801
+
802
+ const registerContractGroup = ({
803
+ controller,
804
+ tag,
805
+ contracts,
806
+ bodyContentType = DEFAULT_BODY_CONTENT_TYPE,
807
+ }: ContractGroup): void => {
808
+ for (const contract of contracts) {
809
+ const method = contract.method.toLowerCase();
810
+
811
+ if (!supportedHttpMethods.has(method)) {
812
+ throw new Error(`Unsupported HTTP method: ${contract.method}`);
813
+ }
814
+
815
+ registry.registerPath({
816
+ method: method as 'get' | 'post' | 'put' | 'patch' | 'delete',
817
+ path: toOpenApiPath(controller, contract.path),
818
+ summary: contract.summary,
819
+ tags: [tag],
820
+ request: {
821
+ ...(contract.request?.body
822
+ ? {
823
+ body: {
824
+ required: true,
825
+ content: {
826
+ [bodyContentType]: {
827
+ schema: resolveSchema(contract.request.body),
828
+ },
860
829
  },
861
830
  },
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
831
+ }
832
+ : {}),
833
+ ...(contract.request?.query ? { query: resolveSchema(contract.request.query) } : {}),
834
+ ...(contract.request?.params ? { params: resolveSchema(contract.request.params) } : {}),
835
+ },
836
+ responses: SSE_CREATED_CONTRACTS.has(contract)
870
837
  ? buildSseSuccessResponses(contract.responses, 201, resolveSchema)
871
838
  : 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}`);
839
+ });
910
840
  }
841
+ };
911
842
 
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}`);
1251
- }
1252
-
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
- }
843
+ const contractGroups: ContractGroup[] = [
844
+ { controller: AUTH_CONTROLLER, tag: 'Auth', contracts: authContracts },
845
+ { controller: CHAT_CONTROLLER, tag: 'Chat', contracts: chatContracts },
846
+ { controller: MESSAGE_CONTROLLER, tag: 'Message', contracts: messageContracts },
847
+ { controller: FILE_CONTROLLER, tag: 'File', contracts: fileContracts, bodyContentType: 'multipart/form-data' },
848
+ { controller: SUPPORT_CONTROLLER, tag: 'Support', contracts: supportContracts },
849
+ { controller: WALLET_CONTROLLER, tag: 'Wallet', contracts: walletContracts },
850
+ { controller: PAYMENT_CONTROLLER, tag: 'Payment', contracts: paymentContracts },
851
+ { controller: AI_MODELS_CONTROLLER, tag: 'AI Models', contracts: aiModelContracts },
852
+ { controller: PUBLIC_MODEL_CONTROLLER, tag: 'Models (public)', contracts: publicModelContracts },
853
+ { controller: PUBLIC_PAGE_CONTROLLER, tag: 'Pages (public)', contracts: publicPageContracts },
854
+ { controller: MODEL_CATALOG_CONTROLLER, tag: 'Model Catalog', contracts: modelCatalogContracts },
855
+ { controller: GENERATION_MODEL_CONTROLLER, tag: 'Generation Models', contracts: generationModelContracts },
856
+ { controller: GENERATION_JOB_CONTROLLER, tag: 'Generation Jobs', contracts: generationJobContracts },
857
+ {
858
+ controller: GENERATION_JOB_CHAT_CONTROLLER,
859
+ tag: 'Generation Job Chats',
860
+ contracts: generationJobChatContracts,
861
+ },
862
+ { controller: ADMIN_CONTROLLER, tag: 'Admin', contracts: adminContracts },
863
+ { controller: MARKETPLACE_CARD_CONTROLLER, tag: 'Marketplace Cards', contracts: marketplaceCardContracts },
864
+ { controller: ORGANIZATION_CONTROLLER, tag: 'Organization', contracts: organizationContracts },
865
+ { controller: USER_CONTEXT_CONTROLLER, tag: 'User Context', contracts: userContextContracts },
866
+ ];
1283
867
 
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
- });
868
+ for (const group of contractGroups) {
869
+ registerContractGroup(group);
1307
870
  }
1308
871
 
1309
872
  const generator = new OpenApiGeneratorV3(registry.definitions);