oip-common 0.0.31 → 0.0.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.
package/index.d.ts CHANGED
@@ -465,38 +465,59 @@ declare class FooterComponent {
465
465
 
466
466
  /** Data Transfer Object for creating a new module instance */
467
467
  interface AddModuleInstanceDto {
468
- /** The identifier of the module to create an instance of */
468
+ /**
469
+ * The identifier of the module to create an instance of
470
+ * @format int32
471
+ */
469
472
  moduleId?: number;
470
473
  /** The display label for the module instance */
471
474
  label?: string | null;
472
475
  /** The icon identifier for the module instance (optional) */
473
476
  icon?: string | null;
474
- /** The parent module instance identifier (optional) */
477
+ /**
478
+ * The parent module instance identifier (optional)
479
+ * @format int32
480
+ */
475
481
  parentId?: number | null;
476
482
  /** Array of role identifiers that can view this module instance (optional) */
477
483
  viewRoles?: string[] | null;
478
484
  }
479
485
  /** Data Transfer Object for editing an existing module instance */
480
- interface EditModuleInstanceDto$1 {
481
- /** The identifier of the module instance to edit */
486
+ interface EditModuleInstanceDto {
487
+ /**
488
+ * The identifier of the module instance to edit
489
+ * @format int32
490
+ */
482
491
  moduleInstanceId?: number;
483
492
  /** The updated display label for the module instance */
484
493
  label?: string | null;
485
494
  /** The updated icon identifier for the module instance (optional) */
486
495
  icon?: string | null;
487
- /** The updated parent module instance identifier (optional) */
496
+ /**
497
+ * The updated parent module instance identifier (optional)
498
+ * @format int32
499
+ */
488
500
  parentId?: number | null;
489
501
  /** Updated array of role identifiers that can view this module instance (optional) */
490
502
  viewRoles?: string[] | null;
503
+ /**
504
+ * For front compatibility
505
+ * @format int32
506
+ */
507
+ moduleId?: number | null;
491
508
  }
492
509
  /** Represents a key-value pair where the key is an integer and the value is a string. */
493
510
  interface IntKeyValueDto {
511
+ /** @format int32 */
494
512
  key?: number;
495
513
  value?: string | null;
496
514
  }
497
515
  /** It module in app */
498
516
  interface ModuleDto {
499
- /** Id */
517
+ /**
518
+ * Id
519
+ * @format int32
520
+ */
500
521
  moduleId?: number;
501
522
  /** Name */
502
523
  name?: string | null;
@@ -507,9 +528,15 @@ interface ModuleDto {
507
528
  }
508
529
  /** Module Instance Dto */
509
530
  interface ModuleInstanceDto {
510
- /** Unique identifier for the module instance. */
531
+ /**
532
+ * Unique identifier for the module instance.
533
+ * @format int32
534
+ */
511
535
  moduleInstanceId?: number;
512
- /** Identifier for the module. */
536
+ /**
537
+ * Identifier for the module.
538
+ * @format int32
539
+ */
513
540
  moduleId?: number;
514
541
  /** The label for the module instance. */
515
542
  label?: string | null;
@@ -527,10 +554,18 @@ interface ModuleInstanceDto {
527
554
  items?: ModuleInstanceDto[] | null;
528
555
  /** Securities */
529
556
  securities?: string[] | null;
530
- /** Identifier for the parent module instance. */
557
+ /**
558
+ * Identifier for the parent module instance.
559
+ * @format int32
560
+ */
531
561
  parentId?: number | null;
532
- /** Sort order position for the module instance. */
562
+ /**
563
+ * Sort order position for the module instance.
564
+ * @format int32
565
+ */
533
566
  order?: number;
567
+ /** Indicates whether this module instance should be displayed as a separator. */
568
+ separator?: boolean;
534
569
  }
535
570
  /** Module security DTO */
536
571
  interface ModuleSecurityDto {
@@ -539,14 +574,23 @@ interface ModuleSecurityDto {
539
574
  /** Role */
540
575
  role: string | null;
541
576
  }
542
- interface MenuDeleteModuleInstanceParams {
543
- /** The unique identifier of the module instance to delete. */
577
+ interface DeleteModuleInstanceParams {
578
+ /**
579
+ * The unique identifier of the module instance to delete.
580
+ * @format int32
581
+ */
544
582
  id?: number;
545
583
  }
546
- interface MenuChangeOrderParams {
547
- /** The identifier of the first module to swap. */
584
+ interface ChangeOrderParams {
585
+ /**
586
+ * The identifier of the first module to swap.
587
+ * @format int32
588
+ */
548
589
  firstModuleId?: number;
549
- /** The identifier of the second module to swap with. */
590
+ /**
591
+ * The identifier of the second module to swap with.
592
+ * @format int32
593
+ */
550
594
  secondModuleId?: number;
551
595
  }
552
596
 
@@ -602,15 +646,6 @@ interface MenuChangeEvent {
602
646
  item: ContextMenuItemDto;
603
647
  }
604
648
 
605
- interface EditModuleInstanceDto {
606
- moduleInstanceId: number;
607
- moduleId: number;
608
- parentId: number;
609
- label: string;
610
- icon: string;
611
- viewRoles: string[];
612
- }
613
-
614
649
  declare class MenuService extends BaseDataService {
615
650
  private readonly menuSource;
616
651
  private readonly resetSource;
@@ -633,8 +668,8 @@ declare class MenuService extends BaseDataService {
633
668
  getAdminMenu(): Promise<ModuleInstanceDto[]>;
634
669
  getModules(): Promise<IntKeyValueDto[]>;
635
670
  addModuleInstance(addModuleInstance: AddModuleInstanceDto): Promise<void>;
636
- deleteItem(moduleInstanceId: number): Promise<unknown>;
637
- editModuleInstance(item: EditModuleInstanceDto): Promise<unknown>;
671
+ deleteItem(moduleInstanceId: number): Promise<void>;
672
+ editModuleInstance(item: EditModuleInstanceDto): Promise<void>;
638
673
  static ɵfac: i0.ɵɵFactoryDeclaration<MenuService, never>;
639
674
  static ɵprov: i0.ɵɵInjectableDeclaration<MenuService>;
640
675
  }
@@ -663,6 +698,7 @@ type RequestParams = Omit<FullRequestParams, "body" | "method" | "query" | "path
663
698
  type CancelToken = Symbol | string | number;
664
699
  declare enum ContentType {
665
700
  Json = "application/json",
701
+ JsonApi = "application/vnd.api+json",
666
702
  FormData = "multipart/form-data",
667
703
  UrlEncoded = "application/x-www-form-urlencoded",
668
704
  Text = "text/plain"
@@ -692,77 +728,95 @@ declare class HttpClient<SecurityDataType = unknown> {
692
728
  static ɵprov: i0.ɵɵInjectableDeclaration<HttpClient<any>>;
693
729
  }
694
730
 
695
- declare class Menu<SecurityDataType = unknown> extends HttpClient<SecurityDataType> {
731
+ declare class MenuApi<SecurityDataType = unknown> extends HttpClient<SecurityDataType> {
696
732
  /**
697
733
  * @description Retrieves the menu available to the current authenticated user.
698
734
  *
699
735
  * @tags Menu
700
- * @name menuGet
736
+ * @name get
737
+ * @summary Retrieves the menu available to the current authenticated user.
701
738
  * @request GET:/api/menu/get
702
739
  * @secure
740
+ * @response `200` `(ModuleInstanceDto)[]` OK
703
741
  */
704
- menuGet: (params?: RequestParams) => Promise<ModuleInstanceDto[]>;
742
+ get: (params?: RequestParams) => Promise<ModuleInstanceDto[]>;
705
743
  /**
706
744
  * @description Retrieves the admin-specific menu.
707
745
  *
708
746
  * @tags Menu
709
- * @name menuGetAdminMenu
747
+ * @name getAdminMenu
748
+ * @summary Retrieves the admin-specific menu.
710
749
  * @request GET:/api/menu/get-admin-menu
711
750
  * @secure
751
+ * @response `200` `(ModuleInstanceDto)[]` OK
712
752
  */
713
- menuGetAdminMenu: (params?: RequestParams) => Promise<ModuleInstanceDto[]>;
753
+ getAdminMenu: (params?: RequestParams) => Promise<ModuleInstanceDto[]>;
714
754
  /**
715
755
  * @description Retrieves all available modules in the system.
716
756
  *
717
757
  * @tags Menu
718
- * @name menuGetModules
758
+ * @name getModules
759
+ * @summary Retrieves all available modules in the system.
719
760
  * @request GET:/api/menu/get-modules
720
761
  * @secure
762
+ * @response `200` `(IntKeyValueDto)[]` OK
721
763
  */
722
- menuGetModules: (params?: RequestParams) => Promise<IntKeyValueDto[]>;
764
+ getModules: (params?: RequestParams) => Promise<IntKeyValueDto[]>;
723
765
  /**
724
766
  * @description Adds a new module instance to the system.
725
767
  *
726
768
  * @tags Menu
727
- * @name menuAddModuleInstance
769
+ * @name addModuleInstance
770
+ * @summary Adds a new module instance to the system.
728
771
  * @request POST:/api/menu/add-module-instance
729
772
  * @secure
773
+ * @response `200` `void` OK
774
+ * @response `500` `ApiExceptionResponse` Internal Server Error
730
775
  */
731
- menuAddModuleInstance: (data: AddModuleInstanceDto, params?: RequestParams) => Promise<void>;
776
+ addModuleInstance: (data: AddModuleInstanceDto, params?: RequestParams) => Promise<void>;
732
777
  /**
733
778
  * @description Edits an existing module instance.
734
779
  *
735
780
  * @tags Menu
736
- * @name menuEditModuleInstance
781
+ * @name editModuleInstance
782
+ * @summary Edits an existing module instance.
737
783
  * @request POST:/api/menu/edit-module-instance
738
784
  * @secure
785
+ * @response `200` `void` OK
786
+ * @response `500` `ApiExceptionResponse` Internal Server Error
739
787
  */
740
- menuEditModuleInstance: (data: EditModuleInstanceDto$1, params?: RequestParams) => Promise<void>;
788
+ editModuleInstance: (data: EditModuleInstanceDto, params?: RequestParams) => Promise<void>;
741
789
  /**
742
790
  * @description Deletes a module instance by its identifier.
743
791
  *
744
792
  * @tags Menu
745
- * @name menuDeleteModuleInstance
793
+ * @name deleteModuleInstance
794
+ * @summary Deletes a module instance by its identifier.
746
795
  * @request DELETE:/api/menu/delete-module-instance
747
796
  * @secure
797
+ * @response `200` `void` OK
798
+ * @response `500` `ApiExceptionResponse` Internal Server Error
748
799
  */
749
- menuDeleteModuleInstance: (query: MenuDeleteModuleInstanceParams, params?: RequestParams) => Promise<void>;
800
+ deleteModuleInstance: (query: DeleteModuleInstanceParams, params?: RequestParams) => Promise<void>;
750
801
  /**
751
802
  * @description Swaps the order positions of two modules in the menu structure.
752
803
  *
753
804
  * @tags Menu
754
- * @name menuChangeOrder
805
+ * @name changeOrder
806
+ * @summary Swaps the order positions of two modules in the menu structure.
755
807
  * @request POST:/api/menu/change-order
756
808
  * @secure
809
+ * @response `200` `void` OK
810
+ * @response `500` `ApiExceptionResponse` Internal Server Error
757
811
  */
758
- menuChangeOrder: (query: MenuChangeOrderParams, params?: RequestParams) => Promise<void>;
759
- static ɵfac: i0.ɵɵFactoryDeclaration<Menu<any>, never>;
760
- static ɵprov: i0.ɵɵInjectableDeclaration<Menu<any>>;
812
+ changeOrder: (query: ChangeOrderParams, params?: RequestParams) => Promise<void>;
813
+ static ɵfac: i0.ɵɵFactoryDeclaration<MenuApi<any>, never>;
814
+ static ɵprov: i0.ɵɵInjectableDeclaration<MenuApi<any>>;
761
815
  }
762
816
 
763
817
  declare class MenuItemCreateDialogComponent implements OnInit {
764
- menuService: MenuService;
765
- protected readonly menu: Menu<any>;
818
+ protected readonly menuService: MenuService;
819
+ protected readonly menu: MenuApi<any>;
766
820
  visible: boolean;
767
821
  visibleChange: EventEmitter<boolean>;
768
822
  modules: IntKeyValueDto[];
@@ -861,7 +915,6 @@ declare class L10nService {
861
915
  private readonly primeNg;
862
916
  private readonly layoutService;
863
917
  availableLanguages: LanguageDto[];
864
- private appRef;
865
918
  /**
866
919
  * Loads translations for a specific component
867
920
  * @param component - Name of the component to load translations for
@@ -1224,5 +1277,5 @@ declare class SecurePipe implements PipeTransform {
1224
1277
  */
1225
1278
  declare const httpLoaderAuthFactory: (httpClient: HttpClient$1) => StsConfigHttpLoader;
1226
1279
 
1227
- export { AppConfiguratorComponent, AppFloatingConfiguratorComponent, AppLayoutComponent, AppModulesComponent, AppTopbar, AuthGuardService, BaseDataService, BaseModuleComponent, ConfigComponent, DbMigrationComponent, ErrorComponent, FooterComponent, KeycloakSecurityService, L10nService, LOGO_COMPONENT_TOKEN, LayoutService, LogoComponent, LogoService, MenuComponent, MenuService, MsgService, NotfoundComponent, NotificationService, ProfileComponent, SecurePipe, SecurityComponent, SecurityDataService, SecurityService, SecurityStorageService, SidebarComponent, TableFilterService, TopBarService, UnauthorizedComponent, UserService, httpLoaderAuthFactory, langIntercept, provideLogoComponent };
1228
- export type { AppConfig, LanguageDto, MenuChangeEvent, NoSettingsDto, PutSecurityDto, SecurityDto, TopBarDto };
1280
+ export { AppConfiguratorComponent, AppFloatingConfiguratorComponent, AppLayoutComponent, AppModulesComponent, AppTopbar, AuthGuardService, BaseDataService, BaseModuleComponent, ConfigComponent, ContentType, DbMigrationComponent, ErrorComponent, FooterComponent, HttpClient, KeycloakSecurityService, L10nService, LOGO_COMPONENT_TOKEN, LayoutService, LogoComponent, LogoService, MenuComponent, MenuService, MsgService, NotfoundComponent, NotificationService, ProfileComponent, SecurePipe, SecurityComponent, SecurityDataService, SecurityService, SecurityStorageService, SidebarComponent, TableFilterService, TopBarService, UnauthorizedComponent, UserService, httpLoaderAuthFactory, langIntercept, provideLogoComponent };
1281
+ export type { AppConfig, LanguageDto, MenuChangeEvent, NoSettingsDto, PutSecurityDto, RequestParams, SecurityDto, TopBarDto };
package/package.json CHANGED
@@ -1,12 +1,15 @@
1
1
  {
2
2
  "name": "oip-common",
3
- "version": "0.0.31",
3
+ "version": "0.0.32",
4
4
  "description": "A template for cross-platform web applications based on sakai-ng and primeNG",
5
5
  "main": "index.js",
6
6
  "keywords": [
7
7
  "oip",
8
8
  "template"
9
9
  ],
10
+ "bin": {
11
+ "oip-generate-api": "./dist/cli.js"
12
+ },
10
13
  "author": "Igor Tyulyakov aka g101k",
11
14
  "license": "MIT",
12
15
  "repository": {
@@ -0,0 +1,163 @@
1
+ #!/usr/bin/env node
2
+
3
+ import fs from "node:fs";
4
+ import path from "node:path";
5
+ import {generateApi, generateTemplates} from "swagger-typescript-api";
6
+ import {ArgumentParser} from 'argparse';
7
+
8
+ const parser = new ArgumentParser({
9
+ description: 'Argparse example'
10
+ });
11
+
12
+ parser.add_argument('-o', '--output', {help: 'Output path'});
13
+ parser.add_argument('-i', '--input', {help: 'Input swagger file path'});
14
+ parser.add_argument('-t', '--templates', {help: 'Templates'});
15
+ parser.add_argument('-d', '--data-contract-prefix', {help: 'Data Contract Prefix'});
16
+ parser.add_argument('-c', '--use-common-client', {action: 'store_true', help: 'Use common http client'});
17
+
18
+ let a = parser.parse_args();
19
+ a.data_contract_prefix ??= "";
20
+
21
+ console.log(a);
22
+ /* NOTE: all fields are optional expect one of `input`, `url`, `spec` */
23
+
24
+ let config = {
25
+ input: path.resolve(process.cwd(), a.input),
26
+ templates: path.resolve(process.cwd(), a.templates),
27
+ httpClientType: "fetch", // or "fetch"
28
+ defaultResponseAsSuccess: false,
29
+ generateClient: true,
30
+ useCommonClient: a.use_common_client,
31
+ generateRouteTypes: false,
32
+ generateResponses: true,
33
+ toJS: false,
34
+ extractRequestParams: true,
35
+ extractRequestBody: true,
36
+ extractEnums: true,
37
+ unwrapResponseData: true,
38
+ modular: true,
39
+ prettier: {
40
+ printWidth: 120,
41
+ tabWidth: 2,
42
+ trailingComma: "all",
43
+ parser: "typescript",
44
+ },
45
+ defaultResponseType: "void",
46
+ singleHttpClient: false,
47
+ cleanOutput: false,
48
+ enumNamesAsValues: false,
49
+ moduleNameFirstTag: true,
50
+ generateUnionEnums: false,
51
+ dataContractPrefix: a.data_contract_prefix,
52
+ typePrefix: "",
53
+ typeSuffix: "",
54
+ enumKeyPrefix: "",
55
+ enumKeySuffix: "",
56
+ addReadonly: false,
57
+ sortTypes: false,
58
+ sortRouters: false,
59
+ extractingOptions: {
60
+ requestBodySuffix: ["Payload", "Body", "Input"],
61
+ requestParamsSuffix: ["Params"],
62
+ responseBodySuffix: ["Data", "Result", "Output"],
63
+ responseErrorSuffix: [
64
+ "Error",
65
+ "Fail",
66
+ "Fails",
67
+ "ErrorData",
68
+ "HttpError",
69
+ "BadResponse",
70
+ ],
71
+ },
72
+ /** allow to generate extra files based with this extra templates, see more below */
73
+ extraTemplates: [],
74
+ anotherArrayType: false,
75
+ fixInvalidTypeNamePrefix: "Type",
76
+ fixInvalidEnumKeyPrefix: "Value",
77
+ codeGenConstructs: (constructs) => ({
78
+ ...constructs,
79
+ RecordType: (key, value) => `MyRecord<key, value>`,
80
+ }),
81
+ primitiveTypeConstructs: (constructs) => ({
82
+ ...constructs,
83
+ string: {
84
+ "date-time": "Date",
85
+ },
86
+ }),
87
+ hooks: {
88
+ onCreateComponent: (component) => {
89
+ },
90
+ onCreateRequestParams: (rawType) => {
91
+ },
92
+ onCreateRoute: (routeData) => {
93
+ },
94
+ onCreateRouteName: (routeNameInfo, rawRouteInfo) => {
95
+ if (routeNameInfo.usage.startsWith(rawRouteInfo.moduleName)) {
96
+ const str = routeNameInfo.usage.substring(rawRouteInfo.moduleName.length);
97
+ routeNameInfo.usage = str[0].toLowerCase() + str.slice(1);
98
+ routeNameInfo.original = routeNameInfo.usage;
99
+ }
100
+ return routeNameInfo;
101
+ },
102
+ onFormatRouteName: (routeInfo, templateRouteName) => {
103
+ },
104
+ onFormatTypeName: (typeName, rawTypeName, schemaType) => {
105
+ },
106
+ onInit: (configuration) => {
107
+ },
108
+ onPreParseSchema: (originalSchema, typeName, schemaType) => {
109
+ },
110
+ onParseSchema: (originalSchema, parsedSchema) => {
111
+ },
112
+ onPrepareConfig: (currentConfiguration) => {
113
+ },
114
+ },
115
+ }
116
+ const toKebabCase = (str) =>
117
+ str &&
118
+ str
119
+ .match(/[A-Z]{2,}(?=[A-Z][a-z]+[0-9]*|\b)|[A-Z]?[a-z]+[0-9]*|[A-Z]|[0-9]+/g)
120
+ .map(x => x.toLowerCase())
121
+ .join('-');
122
+
123
+ generateApi(config)
124
+ .then(async ({files, configuration}) => {
125
+ for (const f of files) {
126
+ if (f.fileContent) {
127
+ if (f.fileName === 'http-client')
128
+ continue;
129
+ let dir = path.join(process.cwd(), a.output);
130
+ if (!fs.existsSync(dir))
131
+ fs.mkdirSync(dir);
132
+
133
+ if (f.fileName === 'data-contracts') {
134
+ f.fileName = config.dataContractPrefix + f.fileName;
135
+ } else if (f.fileName.endsWith('http-client')) {
136
+ // do nothing
137
+ } else {
138
+ f.fileName = `${toKebabCase(f.fileName)}.api`;
139
+ }
140
+
141
+ const absolutePath = path.join(dir, `${f.fileName}${f.fileExtension}`);
142
+ fs.writeFile(absolutePath, f.fileContent, (err) => {
143
+ if (err) {
144
+ console.log(err);
145
+ } else {
146
+ console.log(`File create: ${f.fileName}${f.fileExtension}`);
147
+ }
148
+ });
149
+ }
150
+ }
151
+ })
152
+ .catch((e) => console.error(e));
153
+
154
+ /*
155
+ generateTemplates({
156
+ cleanOutput: false,
157
+ output: './output/',
158
+ httpClientType: "fetch",
159
+ modular: true,
160
+ silent: false,
161
+ rewrite: false,
162
+ });
163
+ */
package/templates/api.ejs CHANGED
@@ -8,14 +8,14 @@ const dataContracts = _.map(modelTypes, "name");
8
8
 
9
9
  <% if (config.httpClientType === config.constants.HTTP_CLIENT.AXIOS) { %> import type { AxiosRequestConfig, AxiosResponse } from "axios"; <% } %>
10
10
 
11
- import { HttpClient, RequestParams, ContentType, HttpResponse } from "./<%~ config.fileNames.httpClient %>";
11
+ import { HttpClient, RequestParams, ContentType, HttpResponse } from "<%~ (config.useCommonClient) ? 'oip-common' : './' + config.fileNames.httpClient %>";
12
12
  <% if (dataContracts.length) { %>
13
- import { <%~ dataContracts.join(", ") %> } from "./<%~ config.fileNames.dataContracts %>"
13
+ import { <%~ dataContracts.join(", ") %> } from "./<%~ config.dataContractPrefix + config.fileNames.dataContracts %>"
14
14
  <% } %>
15
15
  import { Injectable } from "@angular/core";
16
16
 
17
17
  @Injectable()
18
- export class <%= apiClassName %><SecurityDataType = unknown><% if (!config.singleHttpClient) { %> extends HttpClient<SecurityDataType> <% } %> {
18
+ export class <%= apiClassName %>Api<SecurityDataType = unknown><% if (!config.singleHttpClient) { %> extends HttpClient<SecurityDataType> <% } %> {
19
19
  <% if(config.singleHttpClient) { %>
20
20
  http: HttpClient<SecurityDataType>;
21
21
 
@@ -1,27 +1,27 @@
1
1
  <%
2
2
  const { data, utils } = it;
3
- const { formatDescription, require, _ } = utils;
3
+ const { formatDescription, escapeJSDocContent, require, _ } = utils;
4
4
 
5
- const stringify = (value) => _.isObject(value) ? JSON.stringify(value) : _.isString(value) ? `"${value}"` : value
5
+ const stringify = (value) => _.isObject(value) ? JSON.stringify(value) : _.isString(value) ? `"${value}"` : value;
6
6
 
7
7
  const jsDocLines = _.compact([
8
- data.title,
8
+ data.title && formatDescription(data.title),
9
9
  data.description && formatDescription(data.description),
10
10
  !_.isUndefined(data.deprecated) && data.deprecated && '@deprecated',
11
- !_.isUndefined(data.format) && `@format ${data.format}`,
12
- !_.isUndefined(data.minimum) && `@min ${data.minimum}`,
13
- !_.isUndefined(data.multipleOf) && `@multipleOf ${data.multipleOf}`,
14
- !_.isUndefined(data.exclusiveMinimum) && `@exclusiveMin ${data.exclusiveMinimum}`,
15
- !_.isUndefined(data.maximum) && `@max ${data.maximum}`,
16
- !_.isUndefined(data.minLength) && `@minLength ${data.minLength}`,
17
- !_.isUndefined(data.maxLength) && `@maxLength ${data.maxLength}`,
18
- !_.isUndefined(data.exclusiveMaximum) && `@exclusiveMax ${data.exclusiveMaximum}`,
19
- !_.isUndefined(data.maxItems) && `@maxItems ${data.maxItems}`,
20
- !_.isUndefined(data.minItems) && `@minItems ${data.minItems}`,
21
- !_.isUndefined(data.uniqueItems) && `@uniqueItems ${data.uniqueItems}`,
22
- !_.isUndefined(data.default) && `@default ${stringify(data.default)}`,
23
- !_.isUndefined(data.pattern) && `@pattern ${data.pattern}`,
24
- !_.isUndefined(data.example) && `@example ${stringify(data.example)}`
11
+ !_.isUndefined(data.format) && `@format ${escapeJSDocContent(data.format)}`,
12
+ !_.isUndefined(data.minimum) && `@min ${escapeJSDocContent(data.minimum)}`,
13
+ !_.isUndefined(data.multipleOf) && `@multipleOf ${escapeJSDocContent(data.multipleOf)}`,
14
+ !_.isUndefined(data.exclusiveMinimum) && `@exclusiveMin ${escapeJSDocContent(data.exclusiveMinimum)}`,
15
+ !_.isUndefined(data.maximum) && `@max ${escapeJSDocContent(data.maximum)}`,
16
+ !_.isUndefined(data.minLength) && `@minLength ${escapeJSDocContent(data.minLength)}`,
17
+ !_.isUndefined(data.maxLength) && `@maxLength ${escapeJSDocContent(data.maxLength)}`,
18
+ !_.isUndefined(data.exclusiveMaximum) && `@exclusiveMax ${escapeJSDocContent(data.exclusiveMaximum)}`,
19
+ !_.isUndefined(data.maxItems) && `@maxItems ${escapeJSDocContent(data.maxItems)}`,
20
+ !_.isUndefined(data.minItems) && `@minItems ${escapeJSDocContent(data.minItems)}`,
21
+ !_.isUndefined(data.uniqueItems) && `@uniqueItems ${escapeJSDocContent(data.uniqueItems)}`,
22
+ !_.isUndefined(data.default) && `@default ${escapeJSDocContent(stringify(data.default))}`,
23
+ !_.isUndefined(data.pattern) && `@pattern ${escapeJSDocContent(data.pattern)}`,
24
+ !_.isUndefined(data.example) && `@example ${escapeJSDocContent(stringify(data.example))}`
25
25
  ]).join('\n').split('\n');
26
26
  %>
27
27
  <% if (jsDocLines.every(_.isEmpty)) { %>
@@ -20,7 +20,7 @@ const dataContractTemplates = {
20
20
  return `enum ${contract.name} {\r\n${contract.content} \r\n }`;
21
21
  },
22
22
  interface: (contract) => {
23
- return `interface ${contract.name}${buildGenerics(contract)} {\r\n${contract.content}}\r\n\r\n`;
23
+ return `interface ${contract.name}${buildGenerics(contract)} {\r\n${contract.content}}`;
24
24
  },
25
25
  type: (contract) => {
26
26
  return `type ${contract.name}${buildGenerics(contract)} = ${contract.content}`;
@@ -32,21 +32,9 @@ const dataContractTemplates = {
32
32
  type <%~ config.Ts.CodeGenKeyword.UtilRequiredKeys %><T, K extends keyof T> = Omit<T, K> & Required<Pick<T, K>>
33
33
  <% } %>
34
34
 
35
- <% for (const contract of modelTypes) {
36
- if (contract.typeIdentifier === 'interface' && contract.rawContent && Array.isArray(contract.rawContent)) {
37
- contract.rawContent.forEach((prop) => {
38
- if (prop.format ==='date-time') {
39
- prop.field = prop.field.replace(': string', ': Date');
40
- }
41
- })
42
- let customContent = '';
43
- contract.rawContent.forEach((prop) => {
44
- if (prop.description) customContent += `/** ${prop.description} */ \r\n`;
45
- customContent += `${prop.field};\r\n`;
46
- })
47
- contract.content = customContent;
48
- }
49
- %>
35
+ <% for (const contract of modelTypes) { %>
50
36
  <%~ includeFile('./data-contract-jsdoc.ejs', { ...it, data: { ...contract, ...contract.typeData } }) %>
51
37
  <%~ contract.internal ? '' : 'export'%> <%~ (dataContractTemplates[contract.typeIdentifier] || dataContractTemplates.type)(contract) %>
38
+
39
+
52
40
  <% } %>
@@ -7,6 +7,12 @@ const { name, $content } = contract;
7
7
  export type <%~ name %> = <%~ _.map($content, ({ value }) => value).join(" | ") %>
8
8
  <% } else { %>
9
9
  export enum <%~ name %> {
10
- <%~ _.map($content, ({ key, value }) => `${key} = ${value}`).join(",\n") %>
10
+ <%~ _.map($content, ({ key, value, description }) => {
11
+ let formattedDescription = description && formatDescription(description, true);
12
+ return [
13
+ formattedDescription && `/** ${formattedDescription} */`,
14
+ `${key} = ${value}`
15
+ ].filter(Boolean).join("\n");
16
+ }).join(",\n") %>
11
17
  }
12
18
  <% } %>