oip-common 0.2.0 → 0.2.1

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
@@ -584,137 +584,58 @@ declare class FooterComponent {
584
584
  static ɵcmp: i0.ɵɵComponentDeclaration<FooterComponent, "app-footer", never, {}, {}, never, never, true, never>;
585
585
  }
586
586
 
587
- /** Data Transfer Object for creating a new module instance */
588
587
  interface AddModuleInstanceDto {
589
- /**
590
- * The identifier of the module to create an instance of
591
- * @format int32
592
- */
593
588
  moduleId?: number;
594
- /** The display label for the module instance */
595
589
  label?: string | null;
596
- /** The icon identifier for the module instance (optional) */
597
590
  icon?: string | null;
598
- /**
599
- * The parent module instance identifier (optional)
600
- * @format int32
601
- */
602
591
  parentId?: number | null;
603
- /** Array of role identifiers that can view this module instance (optional) */
604
592
  viewRoles?: string[] | null;
605
593
  }
606
- /** Data Transfer Object for editing an existing module instance */
607
594
  interface EditModuleInstanceDto {
608
- /**
609
- * The identifier of the module instance to edit
610
- * @format int32
611
- */
612
595
  moduleInstanceId?: number;
613
- /** The updated display label for the module instance */
614
596
  label?: string | null;
615
- /** The updated icon identifier for the module instance (optional) */
616
597
  icon?: string | null;
617
- /**
618
- * The updated parent module instance identifier (optional)
619
- * @format int32
620
- */
621
598
  parentId?: number | null;
622
- /** Updated array of role identifiers that can view this module instance (optional) */
623
599
  viewRoles?: string[] | null;
624
- /**
625
- * For front compatibility
626
- * @format int32
627
- */
628
600
  moduleId?: number | null;
629
601
  }
630
602
  interface IframeModuleSettings {
631
603
  url?: string | null;
632
604
  }
633
- /** Represents a key-value pair where the key is an integer and the value is a string. */
634
605
  interface IntKeyValueDto {
635
- /** @format int32 */
636
606
  key?: number;
637
607
  value?: string | null;
638
608
  }
639
- /** It module in app */
640
609
  interface ModuleDto {
641
- /**
642
- * Id
643
- * @format int32
644
- */
645
610
  moduleId?: number;
646
- /** Name */
647
611
  name?: string | null;
648
- /** Settings */
649
612
  settings?: string | null;
650
- /** Securities */
651
613
  moduleSecurities?: ModuleSecurityDto[] | null;
652
614
  }
653
- /** Module Instance Dto */
654
615
  interface ModuleInstanceDto {
655
- /**
656
- * Unique identifier for the module instance.
657
- * @format int32
658
- */
659
616
  moduleInstanceId?: number;
660
- /**
661
- * Identifier for the module.
662
- * @format int32
663
- */
664
617
  moduleId?: number;
665
- /** The label for the module instance. */
666
618
  label?: string | null;
667
- /** Icon associated with the module instance. see https://primeng.org/icons */
668
619
  icon?: string | null;
669
- /** Route link. */
670
620
  routerLink?: string[] | null;
671
- /** URL for the module instance. */
672
621
  url?: string | null;
673
- /** The target. */
674
622
  target?: string | null;
675
- /** Configuration settings for the module instance. */
676
623
  settings?: string | null;
677
- /** Child module instances. */
678
624
  items?: ModuleInstanceDto[] | null;
679
- /** Securities */
680
625
  securities?: string[] | null;
681
- /**
682
- * Identifier for the parent module instance.
683
- * @format int32
684
- */
685
626
  parentId?: number | null;
686
- /**
687
- * Sort order position for the module instance.
688
- * @format int32
689
- */
690
627
  order?: number;
691
- /** Indicates whether this module instance should be displayed as a separator. */
692
628
  separator?: boolean;
693
629
  }
694
- /** Module security DTO */
695
630
  interface ModuleSecurityDto {
696
- /** Right */
697
631
  right: string | null;
698
- /** Role */
699
632
  role: string | null;
700
633
  }
701
634
  interface DeleteModuleInstanceParams {
702
- /**
703
- * The unique identifier of the module instance to delete.
704
- * @format int32
705
- */
706
635
  id?: number;
707
636
  }
708
637
  interface ChangeOrderParams {
709
- /**
710
- * The identifier of the first module to swap.
711
- * @format int32
712
- */
713
638
  firstModuleId?: number;
714
- /**
715
- * The identifier of the second module to swap with.
716
- * @format int32
717
- */
718
639
  secondModuleId?: number;
719
640
  }
720
641
 
@@ -853,86 +774,12 @@ declare class HttpClient<SecurityDataType = unknown> {
853
774
  }
854
775
 
855
776
  declare class MenuApi<SecurityDataType = unknown> extends HttpClient<SecurityDataType> {
856
- /**
857
- * @description Retrieves the menu available to the current authenticated user.
858
- *
859
- * @tags Menu
860
- * @name get
861
- * @summary Retrieves the menu available to the current authenticated user.
862
- * @request GET:/api/menu/get
863
- * @secure
864
- * @response `200` `(ModuleInstanceDto)[]` OK
865
- */
866
777
  get: (params?: RequestParams) => Promise<ModuleInstanceDto[]>;
867
- /**
868
- * @description Retrieves the admin-specific menu.
869
- *
870
- * @tags Menu
871
- * @name getAdminMenu
872
- * @summary Retrieves the admin-specific menu.
873
- * @request GET:/api/menu/get-admin-menu
874
- * @secure
875
- * @response `200` `(ModuleInstanceDto)[]` OK
876
- */
877
778
  getAdminMenu: (params?: RequestParams) => Promise<ModuleInstanceDto[]>;
878
- /**
879
- * @description Retrieves all available modules in the system.
880
- *
881
- * @tags Menu
882
- * @name getModules
883
- * @summary Retrieves all available modules in the system.
884
- * @request GET:/api/menu/get-modules
885
- * @secure
886
- * @response `200` `(IntKeyValueDto)[]` OK
887
- */
888
779
  getModules: (params?: RequestParams) => Promise<IntKeyValueDto[]>;
889
- /**
890
- * @description Adds a new module instance to the system.
891
- *
892
- * @tags Menu
893
- * @name addModuleInstance
894
- * @summary Adds a new module instance to the system.
895
- * @request POST:/api/menu/add-module-instance
896
- * @secure
897
- * @response `200` `void` OK
898
- * @response `500` `ApiExceptionResponse` Internal Server Error
899
- */
900
780
  addModuleInstance: (data: AddModuleInstanceDto, params?: RequestParams) => Promise<void>;
901
- /**
902
- * @description Edits an existing module instance.
903
- *
904
- * @tags Menu
905
- * @name editModuleInstance
906
- * @summary Edits an existing module instance.
907
- * @request POST:/api/menu/edit-module-instance
908
- * @secure
909
- * @response `200` `void` OK
910
- * @response `500` `ApiExceptionResponse` Internal Server Error
911
- */
912
781
  editModuleInstance: (data: EditModuleInstanceDto, params?: RequestParams) => Promise<void>;
913
- /**
914
- * @description Deletes a module instance by its identifier.
915
- *
916
- * @tags Menu
917
- * @name deleteModuleInstance
918
- * @summary Deletes a module instance by its identifier.
919
- * @request DELETE:/api/menu/delete-module-instance
920
- * @secure
921
- * @response `200` `void` OK
922
- * @response `500` `ApiExceptionResponse` Internal Server Error
923
- */
924
782
  deleteModuleInstance: (query: DeleteModuleInstanceParams, params?: RequestParams) => Promise<void>;
925
- /**
926
- * @description Swaps the order positions of two modules in the menu structure.
927
- *
928
- * @tags Menu
929
- * @name changeOrder
930
- * @summary Swaps the order positions of two modules in the menu structure.
931
- * @request POST:/api/menu/change-order
932
- * @secure
933
- * @response `200` `void` OK
934
- * @response `500` `ApiExceptionResponse` Internal Server Error
935
- */
936
783
  changeOrder: (query: ChangeOrderParams, params?: RequestParams) => Promise<void>;
937
784
  static ɵfac: i0.ɵɵFactoryDeclaration<MenuApi<any>, never>;
938
785
  static ɵprov: i0.ɵɵInjectableDeclaration<MenuApi<any>>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "oip-common",
3
- "version": "0.2.0",
3
+ "version": "0.2.1",
4
4
  "description": "A template for cross-platform web applications based on sakai-ng and primeNG",
5
5
  "main": "index.js",
6
6
  "keywords": [
@@ -12,22 +12,23 @@ parser.add_argument("-i", "--input", { help: "Input swagger file path" });
12
12
  parser.add_argument("-t", "--templates", { help: "Templates" });
13
13
  parser.add_argument("-d", "--data-contract-prefix", { help: "Data Contract Prefix" });
14
14
  parser.add_argument("-c", "--use-common-client", { action: "store_true", help: "Use common http client" });
15
+ parser.add_argument("--disable-jsdoc", { action: "store_true", help: "Disable JSDoc generation" });
15
16
 
16
17
  let a = parser.parse_args();
17
18
  a.data_contract_prefix ??= "";
18
19
 
19
- console.log(a);
20
20
  /* NOTE: all fields are optional expect one of `input`, `url`, `spec` */
21
21
 
22
22
  let config = {
23
23
  input: path.resolve(process.cwd(), a.input),
24
24
  templates: path.resolve(process.cwd(), a.templates),
25
- httpClientType: "fetch", // or "fetch"
25
+ httpClientType: "fetch",
26
26
  defaultResponseAsSuccess: false,
27
27
  generateClient: true,
28
28
  useCommonClient: a.use_common_client,
29
29
  generateRouteTypes: false,
30
30
  generateResponses: true,
31
+ generateJSDoc: !a.disable_jsdoc,
31
32
  toJS: false,
32
33
  extractRequestParams: true,
33
34
  extractRequestBody: true,
@@ -2,6 +2,8 @@
2
2
  const { data, utils } = it;
3
3
  const { formatDescription, escapeJSDocContent, require, _ } = utils;
4
4
 
5
+ if (it.config.generateJSDoc === false) return "";
6
+
5
7
  const stringify = (value) => _.isObject(value) ? JSON.stringify(value) : _.isString(value) ? `"${value}"` : value;
6
8
 
7
9
  const jsDocLines = _.compact([
@@ -2,6 +2,8 @@
2
2
  const { field, utils } = it;
3
3
  const { formatDescription, escapeJSDocContent, require, _ } = utils;
4
4
 
5
+ if (it.config.generateJSDoc === false) return "";
6
+
5
7
  const comments = _.uniq(
6
8
  _.compact([
7
9
  field.title && formatDescription(field.title),
@@ -5,7 +5,8 @@ const { _, getInlineParseContent, getParseContent, parseSchema, getComponentByRe
5
5
  const { parameters, path, method, payload, query, formData, security, requestParams } = route.request;
6
6
  const { type, errorType, contentTypes } = route.response;
7
7
  const { HTTP_CLIENT, RESERVED_REQ_PARAMS_ARG_NAMES } = config.constants;
8
- const routeDocs = includeFile("./route-docs", { config, route, utils });
8
+ const shouldGenerateJSDoc = config.generateJSDoc !== false;
9
+ const routeDocs = shouldGenerateJSDoc ? includeFile("./route-docs", { config, route, utils }) : null;
9
10
  const queryName = (query && query.name) || "query";
10
11
  const pathParams = _.values(parameters);
11
12
  const pathParamsNames = _.map(pathParams, "name");
@@ -82,6 +83,7 @@ const describeReturnType = () => {
82
83
  const isValidIdentifier = (name) => /^[A-Za-z_$][A-Za-z0-9_$]*$/.test(name);
83
84
 
84
85
  %>
86
+ <% if (shouldGenerateJSDoc) { %>
85
87
  /**
86
88
  <%~ routeDocs.description %>
87
89
 
@@ -90,6 +92,7 @@ const isValidIdentifier = (name) => /^[A-Za-z_$][A-Za-z0-9_$]*$/.test(name);
90
92
  <%~ routeDocs.lines %>
91
93
 
92
94
  */
95
+ <% } %>
93
96
  <% if (isValidIdentifier(route.routeName.usage)) { %><%~ route.routeName.usage %><% } else { %>"<%~ route.routeName.usage %>"<% } %> = (<%~ wrapperArgs %>)<%~ config.toJS ? `: ${describeReturnType()}` : "" %> =>
94
97
  <%~ config.singleHttpClient ? 'this.http.request' : 'this.request' %><<%~ type %>, <%~ errorType %>>({
95
98
  path: `<%~ path %>`,
@@ -3,18 +3,21 @@ const { route, utils, config } = it;
3
3
  const { _, pascalCase, require } = utils;
4
4
  const { query, payload, pathParams, headers } = route.request;
5
5
 
6
- const routeDocs = includeFile("./route-docs", { config, route, utils });
6
+ const shouldGenerateJSDoc = config.generateJSDoc !== false;
7
+ const routeDocs = shouldGenerateJSDoc ? includeFile("./route-docs", { config, route, utils }) : null;
7
8
  const isValidIdentifier = (name) => /^[A-Za-z_$][A-Za-z0-9_$]*$/.test(name);
8
9
  const routeNamespace = pascalCase(route.routeName.usage);
9
10
 
10
11
  %>
11
12
 
13
+ <% if (shouldGenerateJSDoc) { %>
12
14
  /**
13
15
  <%~ routeDocs.description %>
14
16
 
15
17
  <%~ routeDocs.lines %>
16
18
 
17
19
  */
20
+ <% } %>
18
21
  export namespace <% if (isValidIdentifier(routeNamespace)) { %><%~ routeNamespace %><% } else { %>"<%~ routeNamespace %>"<% } %> {
19
22
  export type RequestParams = <%~ (pathParams && pathParams.type) || '{}' %>;
20
23
  export type RequestQuery = <%~ (query && query.type) || '{}' %>;