oip-common 0.2.0 → 0.2.2
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/assets/i18n/app-modules.en.json +23 -23
- package/assets/i18n/app-modules.ru.json +23 -23
- package/fesm2022/oip-common.mjs +412 -201
- package/fesm2022/oip-common.mjs.map +1 -1
- package/index.d.ts +51 -181
- package/package.json +1 -1
- package/scripts/generate-api.mjs +3 -2
- package/templates/data-contract-jsdoc.ejs +2 -0
- package/templates/object-field-jsdoc.ejs +2 -0
- package/templates/procedure-call.ejs +4 -1
- package/templates/route-type.ejs +4 -1
package/index.d.ts
CHANGED
|
@@ -190,6 +190,7 @@ interface LanguageDto {
|
|
|
190
190
|
*/
|
|
191
191
|
declare class L10nService {
|
|
192
192
|
private loadedTranslations;
|
|
193
|
+
private loadingTranslations;
|
|
193
194
|
private httpClient;
|
|
194
195
|
private translateService;
|
|
195
196
|
private readonly primeNg;
|
|
@@ -199,12 +200,12 @@ declare class L10nService {
|
|
|
199
200
|
* Loads translations for a specific component
|
|
200
201
|
* @param component - Name of the component to load translations for
|
|
201
202
|
*/
|
|
202
|
-
loadComponentTranslations(component: string):
|
|
203
|
+
loadComponentTranslations(component: string): Observable<unknown>;
|
|
203
204
|
/**
|
|
204
205
|
* Gets the translated value of a key (or an array of keys)
|
|
205
206
|
* @returns the translated key, or an object of translated keys
|
|
206
207
|
*/
|
|
207
|
-
get(key: string):
|
|
208
|
+
get(key: string): Observable<any>;
|
|
208
209
|
/**
|
|
209
210
|
* Internal method to load translations from JSON files
|
|
210
211
|
* @param component - Component or translation namespace
|
|
@@ -241,6 +242,9 @@ declare class SecurityDataService extends BaseDataService {
|
|
|
241
242
|
static ɵprov: i0.ɵɵInjectableDeclaration<SecurityDataService>;
|
|
242
243
|
}
|
|
243
244
|
|
|
245
|
+
type RefreshCustomParams = {
|
|
246
|
+
[key: string]: string | number | boolean;
|
|
247
|
+
};
|
|
244
248
|
declare abstract class SecurityService {
|
|
245
249
|
abstract auth(): void;
|
|
246
250
|
abstract logout(): void;
|
|
@@ -249,7 +253,7 @@ declare abstract class SecurityService {
|
|
|
249
253
|
abstract isTokenExpired(): Observable<boolean>;
|
|
250
254
|
abstract getCurrentUser(): any;
|
|
251
255
|
abstract getCurrentUser$(): Observable<any>;
|
|
252
|
-
abstract forceRefreshSession(): Observable<LoginResponse>;
|
|
256
|
+
abstract forceRefreshSession(customParams?: RefreshCustomParams, configId?: string): Observable<LoginResponse>;
|
|
253
257
|
abstract isAdmin(): boolean;
|
|
254
258
|
abstract authorize(configId?: string, authOptions?: AuthOptions): void;
|
|
255
259
|
abstract payload: BehaviorSubject<any>;
|
|
@@ -262,6 +266,12 @@ declare abstract class SecurityService {
|
|
|
262
266
|
* determining user roles, and performing logout and refresh operations.
|
|
263
267
|
*/
|
|
264
268
|
declare class KeycloakSecurityService extends OidcSecurityService implements OnDestroy, SecurityService {
|
|
269
|
+
private readonly refreshLockKeyPrefix;
|
|
270
|
+
private readonly refreshResultKeyPrefix;
|
|
271
|
+
private readonly refreshLockTtlMs;
|
|
272
|
+
private readonly refreshWaitTimeoutMs;
|
|
273
|
+
private readonly refreshTabId;
|
|
274
|
+
private refreshSession$?;
|
|
265
275
|
/**
|
|
266
276
|
* Handles angular OIDC events.
|
|
267
277
|
*/
|
|
@@ -295,6 +305,7 @@ declare class KeycloakSecurityService extends OidcSecurityService implements OnD
|
|
|
295
305
|
* @returns A string with the id token.
|
|
296
306
|
*/
|
|
297
307
|
getAccessToken(configId?: string): Observable<string>;
|
|
308
|
+
forceRefreshSession(customParams?: RefreshCustomParams, configId?: string): Observable<LoginResponse>;
|
|
298
309
|
/**
|
|
299
310
|
* Indicates whether the current user has the 'admin' role.
|
|
300
311
|
*
|
|
@@ -323,6 +334,23 @@ declare class KeycloakSecurityService extends OidcSecurityService implements OnD
|
|
|
323
334
|
* @returns {Observable<boolean>} Observable that emits true if the token is expired.
|
|
324
335
|
*/
|
|
325
336
|
isTokenExpired(): Observable<boolean>;
|
|
337
|
+
private runSynchronizedRefresh;
|
|
338
|
+
private runSynchronizedRefreshWithStorageLock;
|
|
339
|
+
private refreshAsLockOwner;
|
|
340
|
+
private syncAuthState;
|
|
341
|
+
private applyLoginResponse;
|
|
342
|
+
private isCurrentAccessTokenExpired;
|
|
343
|
+
private tryAcquireRefreshLock;
|
|
344
|
+
private releaseRefreshLock;
|
|
345
|
+
private waitForRefreshResult;
|
|
346
|
+
private tryResolveRefreshResult;
|
|
347
|
+
private publishRefreshResult;
|
|
348
|
+
private readRefreshLock;
|
|
349
|
+
private readRefreshResult;
|
|
350
|
+
private getRefreshLockKey;
|
|
351
|
+
private getRefreshResultKey;
|
|
352
|
+
private getWebLocks;
|
|
353
|
+
private createRefreshTabId;
|
|
326
354
|
static ɵfac: i0.ɵɵFactoryDeclaration<KeycloakSecurityService, never>;
|
|
327
355
|
static ɵprov: i0.ɵɵInjectableDeclaration<KeycloakSecurityService>;
|
|
328
356
|
}
|
|
@@ -584,137 +612,58 @@ declare class FooterComponent {
|
|
|
584
612
|
static ɵcmp: i0.ɵɵComponentDeclaration<FooterComponent, "app-footer", never, {}, {}, never, never, true, never>;
|
|
585
613
|
}
|
|
586
614
|
|
|
587
|
-
/** Data Transfer Object for creating a new module instance */
|
|
588
615
|
interface AddModuleInstanceDto {
|
|
589
|
-
/**
|
|
590
|
-
* The identifier of the module to create an instance of
|
|
591
|
-
* @format int32
|
|
592
|
-
*/
|
|
593
616
|
moduleId?: number;
|
|
594
|
-
/** The display label for the module instance */
|
|
595
617
|
label?: string | null;
|
|
596
|
-
/** The icon identifier for the module instance (optional) */
|
|
597
618
|
icon?: string | null;
|
|
598
|
-
/**
|
|
599
|
-
* The parent module instance identifier (optional)
|
|
600
|
-
* @format int32
|
|
601
|
-
*/
|
|
602
619
|
parentId?: number | null;
|
|
603
|
-
/** Array of role identifiers that can view this module instance (optional) */
|
|
604
620
|
viewRoles?: string[] | null;
|
|
605
621
|
}
|
|
606
|
-
/** Data Transfer Object for editing an existing module instance */
|
|
607
622
|
interface EditModuleInstanceDto {
|
|
608
|
-
/**
|
|
609
|
-
* The identifier of the module instance to edit
|
|
610
|
-
* @format int32
|
|
611
|
-
*/
|
|
612
623
|
moduleInstanceId?: number;
|
|
613
|
-
/** The updated display label for the module instance */
|
|
614
624
|
label?: string | null;
|
|
615
|
-
/** The updated icon identifier for the module instance (optional) */
|
|
616
625
|
icon?: string | null;
|
|
617
|
-
/**
|
|
618
|
-
* The updated parent module instance identifier (optional)
|
|
619
|
-
* @format int32
|
|
620
|
-
*/
|
|
621
626
|
parentId?: number | null;
|
|
622
|
-
/** Updated array of role identifiers that can view this module instance (optional) */
|
|
623
627
|
viewRoles?: string[] | null;
|
|
624
|
-
/**
|
|
625
|
-
* For front compatibility
|
|
626
|
-
* @format int32
|
|
627
|
-
*/
|
|
628
628
|
moduleId?: number | null;
|
|
629
629
|
}
|
|
630
630
|
interface IframeModuleSettings {
|
|
631
631
|
url?: string | null;
|
|
632
632
|
}
|
|
633
|
-
/** Represents a key-value pair where the key is an integer and the value is a string. */
|
|
634
633
|
interface IntKeyValueDto {
|
|
635
|
-
/** @format int32 */
|
|
636
634
|
key?: number;
|
|
637
635
|
value?: string | null;
|
|
638
636
|
}
|
|
639
|
-
/** It module in app */
|
|
640
637
|
interface ModuleDto {
|
|
641
|
-
/**
|
|
642
|
-
* Id
|
|
643
|
-
* @format int32
|
|
644
|
-
*/
|
|
645
638
|
moduleId?: number;
|
|
646
|
-
/** Name */
|
|
647
639
|
name?: string | null;
|
|
648
|
-
/** Settings */
|
|
649
640
|
settings?: string | null;
|
|
650
|
-
/** Securities */
|
|
651
641
|
moduleSecurities?: ModuleSecurityDto[] | null;
|
|
652
642
|
}
|
|
653
|
-
/** Module Instance Dto */
|
|
654
643
|
interface ModuleInstanceDto {
|
|
655
|
-
/**
|
|
656
|
-
* Unique identifier for the module instance.
|
|
657
|
-
* @format int32
|
|
658
|
-
*/
|
|
659
644
|
moduleInstanceId?: number;
|
|
660
|
-
/**
|
|
661
|
-
* Identifier for the module.
|
|
662
|
-
* @format int32
|
|
663
|
-
*/
|
|
664
645
|
moduleId?: number;
|
|
665
|
-
/** The label for the module instance. */
|
|
666
646
|
label?: string | null;
|
|
667
|
-
/** Icon associated with the module instance. see https://primeng.org/icons */
|
|
668
647
|
icon?: string | null;
|
|
669
|
-
/** Route link. */
|
|
670
648
|
routerLink?: string[] | null;
|
|
671
|
-
/** URL for the module instance. */
|
|
672
649
|
url?: string | null;
|
|
673
|
-
/** The target. */
|
|
674
650
|
target?: string | null;
|
|
675
|
-
/** Configuration settings for the module instance. */
|
|
676
651
|
settings?: string | null;
|
|
677
|
-
/** Child module instances. */
|
|
678
652
|
items?: ModuleInstanceDto[] | null;
|
|
679
|
-
/** Securities */
|
|
680
653
|
securities?: string[] | null;
|
|
681
|
-
/**
|
|
682
|
-
* Identifier for the parent module instance.
|
|
683
|
-
* @format int32
|
|
684
|
-
*/
|
|
685
654
|
parentId?: number | null;
|
|
686
|
-
/**
|
|
687
|
-
* Sort order position for the module instance.
|
|
688
|
-
* @format int32
|
|
689
|
-
*/
|
|
690
655
|
order?: number;
|
|
691
|
-
/** Indicates whether this module instance should be displayed as a separator. */
|
|
692
656
|
separator?: boolean;
|
|
693
657
|
}
|
|
694
|
-
/** Module security DTO */
|
|
695
658
|
interface ModuleSecurityDto {
|
|
696
|
-
/** Right */
|
|
697
659
|
right: string | null;
|
|
698
|
-
/** Role */
|
|
699
660
|
role: string | null;
|
|
700
661
|
}
|
|
701
662
|
interface DeleteModuleInstanceParams {
|
|
702
|
-
/**
|
|
703
|
-
* The unique identifier of the module instance to delete.
|
|
704
|
-
* @format int32
|
|
705
|
-
*/
|
|
706
663
|
id?: number;
|
|
707
664
|
}
|
|
708
665
|
interface ChangeOrderParams {
|
|
709
|
-
/**
|
|
710
|
-
* The identifier of the first module to swap.
|
|
711
|
-
* @format int32
|
|
712
|
-
*/
|
|
713
666
|
firstModuleId?: number;
|
|
714
|
-
/**
|
|
715
|
-
* The identifier of the second module to swap with.
|
|
716
|
-
* @format int32
|
|
717
|
-
*/
|
|
718
667
|
secondModuleId?: number;
|
|
719
668
|
}
|
|
720
669
|
|
|
@@ -853,100 +802,33 @@ declare class HttpClient<SecurityDataType = unknown> {
|
|
|
853
802
|
}
|
|
854
803
|
|
|
855
804
|
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
805
|
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
806
|
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
807
|
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
808
|
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
809
|
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
810
|
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
811
|
changeOrder: (query: ChangeOrderParams, params?: RequestParams) => Promise<void>;
|
|
937
812
|
static ɵfac: i0.ɵɵFactoryDeclaration<MenuApi<any>, never>;
|
|
938
813
|
static ɵprov: i0.ɵɵInjectableDeclaration<MenuApi<any>>;
|
|
939
814
|
}
|
|
940
815
|
|
|
816
|
+
type PrimeIconOption$1 = {
|
|
817
|
+
label: string;
|
|
818
|
+
value: string;
|
|
819
|
+
};
|
|
941
820
|
declare class MenuItemCreateDialogComponent implements OnInit {
|
|
942
821
|
protected readonly menuService: MenuService;
|
|
943
822
|
protected readonly menu: MenuApi<any>;
|
|
823
|
+
private readonly msgService;
|
|
944
824
|
visible: boolean;
|
|
945
825
|
visibleChange: EventEmitter<boolean>;
|
|
946
826
|
modules: IntKeyValueDto[];
|
|
827
|
+
iconOptions: PrimeIconOption$1[];
|
|
947
828
|
selectModule: any;
|
|
948
829
|
label: string;
|
|
949
830
|
selectIcon: string;
|
|
831
|
+
saving: boolean;
|
|
950
832
|
ngOnInit(): Promise<void>;
|
|
951
833
|
changeVisible(): void;
|
|
952
834
|
save(): Promise<void>;
|
|
@@ -956,14 +838,21 @@ declare class MenuItemCreateDialogComponent implements OnInit {
|
|
|
956
838
|
static ɵcmp: i0.ɵɵComponentDeclaration<MenuItemCreateDialogComponent, "menu-item-create-dialog", never, { "visible": { "alias": "visible"; "required": false; }; }, { "visibleChange": "visibleChange"; }, never, never, true, never>;
|
|
957
839
|
}
|
|
958
840
|
|
|
841
|
+
type PrimeIconOption = {
|
|
842
|
+
label: string;
|
|
843
|
+
value: string;
|
|
844
|
+
};
|
|
959
845
|
declare class MenuItemEditDialogComponent {
|
|
960
846
|
private readonly menuService;
|
|
961
847
|
private readonly securityDataService;
|
|
848
|
+
private readonly msgService;
|
|
962
849
|
visible: boolean;
|
|
963
850
|
visibleChange: EventEmitter<boolean>;
|
|
964
851
|
modules: any[];
|
|
965
852
|
roles: string[];
|
|
853
|
+
iconOptions: PrimeIconOption[];
|
|
966
854
|
item: EditModuleInstanceDto;
|
|
855
|
+
saving: boolean;
|
|
967
856
|
changeVisible(): void;
|
|
968
857
|
save(): Promise<void>;
|
|
969
858
|
hide(): void;
|
|
@@ -1050,7 +939,7 @@ declare class ProfileComponent {
|
|
|
1050
939
|
static ɵcmp: i0.ɵɵComponentDeclaration<ProfileComponent, "user-profile", never, {}, {}, never, never, true, never>;
|
|
1051
940
|
}
|
|
1052
941
|
|
|
1053
|
-
interface L10n
|
|
942
|
+
interface L10n {
|
|
1054
943
|
menu: string;
|
|
1055
944
|
all: string;
|
|
1056
945
|
profile: string;
|
|
@@ -1067,7 +956,7 @@ declare class ConfigComponent {
|
|
|
1067
956
|
protected readonly userService: UserService;
|
|
1068
957
|
protected readonly securityService: SecurityService;
|
|
1069
958
|
protected readonly menuService: MenuService;
|
|
1070
|
-
protected l10n: L10n
|
|
959
|
+
protected l10n: L10n;
|
|
1071
960
|
protected readonly dateFormats: string[];
|
|
1072
961
|
protected readonly timeFormats: string[];
|
|
1073
962
|
protected readonly allTimeZones: any[];
|
|
@@ -1108,39 +997,20 @@ declare class DbMigrationComponent extends BaseModuleComponent<NoSettingsDto, No
|
|
|
1108
997
|
static ɵcmp: i0.ɵɵComponentDeclaration<DbMigrationComponent, "db-migration", never, {}, {}, never, never, true, never>;
|
|
1109
998
|
}
|
|
1110
999
|
|
|
1111
|
-
interface L10n {
|
|
1112
|
-
confirm: {
|
|
1113
|
-
header: string;
|
|
1114
|
-
message: string;
|
|
1115
|
-
cancel: string;
|
|
1116
|
-
delete: string;
|
|
1117
|
-
};
|
|
1118
|
-
title: string;
|
|
1119
|
-
messages: {
|
|
1120
|
-
deleteSuccess: string;
|
|
1121
|
-
};
|
|
1122
|
-
table: {
|
|
1123
|
-
deleteTooltip: string;
|
|
1124
|
-
currentlyLoaded: string;
|
|
1125
|
-
yes: string;
|
|
1126
|
-
no: string;
|
|
1127
|
-
name: string;
|
|
1128
|
-
moduleId: string;
|
|
1129
|
-
};
|
|
1130
|
-
refreshTooltip: string;
|
|
1131
|
-
}
|
|
1132
1000
|
declare class AppModulesComponent implements OnInit {
|
|
1133
1001
|
protected dataService: BaseDataService;
|
|
1134
1002
|
protected modules: ModuleDto[];
|
|
1135
1003
|
protected msgService: MsgService;
|
|
1136
1004
|
protected confirmationService: ConfirmationService;
|
|
1137
1005
|
protected l10nService: L10nService;
|
|
1138
|
-
protected l10n: L10n;
|
|
1139
1006
|
protected titleService: AppTitleService;
|
|
1140
1007
|
private moduleService;
|
|
1008
|
+
private translationsReady;
|
|
1009
|
+
constructor();
|
|
1141
1010
|
ngOnInit(): Promise<void>;
|
|
1142
1011
|
refreshAction(): Promise<void>;
|
|
1143
|
-
deleteModule(module: ModuleDto): void
|
|
1012
|
+
deleteModule(module: ModuleDto): Promise<void>;
|
|
1013
|
+
t(key: string): any;
|
|
1144
1014
|
static ɵfac: i0.ɵɵFactoryDeclaration<AppModulesComponent, never>;
|
|
1145
1015
|
static ɵcmp: i0.ɵɵComponentDeclaration<AppModulesComponent, "app-modules", never, {}, {}, never, never, true, never>;
|
|
1146
1016
|
}
|
package/package.json
CHANGED
package/scripts/generate-api.mjs
CHANGED
|
@@ -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",
|
|
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([
|
|
@@ -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
|
|
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 %>`,
|
package/templates/route-type.ejs
CHANGED
|
@@ -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
|
|
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) || '{}' %>;
|