@smartbit4all/ng-client 3.3.244 → 3.4.0

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 (118) hide show
  1. package/esm2020/lib/session/api/configuration.mjs +1 -1
  2. package/esm2020/lib/session/api/model/sessionInfoData.mjs +1 -1
  3. package/esm2020/lib/smart-component-layout/api/api/api.mjs +1 -1
  4. package/esm2020/lib/smart-component-layout/api/api/default.service.mjs +1 -1
  5. package/esm2020/lib/smart-component-layout/api/api.module.mjs +1 -1
  6. package/esm2020/lib/smart-component-layout/api/configuration.mjs +1 -1
  7. package/esm2020/lib/smart-component-layout/api/encoder.mjs +1 -1
  8. package/esm2020/lib/smart-component-layout/api/index.mjs +1 -1
  9. package/esm2020/lib/smart-component-layout/api/model/componentType.mjs +1 -1
  10. package/esm2020/lib/smart-component-layout/api/model/componentWidgetType.mjs +1 -1
  11. package/esm2020/lib/smart-component-layout/api/model/layoutDirection.mjs +1 -1
  12. package/esm2020/lib/smart-component-layout/api/model/models.mjs +1 -1
  13. package/esm2020/lib/smart-component-layout/api/model/smartComponentLayoutDefinition.mjs +1 -1
  14. package/esm2020/lib/smart-component-layout/api/model/smartComponentWidgetDefinition.mjs +1 -1
  15. package/esm2020/lib/smart-component-layout/api/param.mjs +1 -1
  16. package/esm2020/lib/smart-component-layout/api/variables.mjs +1 -1
  17. package/esm2020/lib/smart-filter/api/filter/model/filterExpressionBoolOperator.mjs +1 -1
  18. package/esm2020/lib/smart-filter/api/filter/model/filterExpressionBuilderField.mjs +1 -1
  19. package/esm2020/lib/smart-filter/api/filter/model/filterExpressionBuilderGroup.mjs +1 -1
  20. package/esm2020/lib/smart-filter/api/filter/model/filterExpressionBuilderModel.mjs +1 -1
  21. package/esm2020/lib/smart-filter/api/filter/model/filterExpressionData.mjs +1 -1
  22. package/esm2020/lib/smart-filter/api/filter/model/filterExpressionDataType.mjs +1 -1
  23. package/esm2020/lib/smart-filter/api/filter/model/filterExpressionField.mjs +1 -1
  24. package/esm2020/lib/smart-filter/api/filter/model/filterExpressionFieldList.mjs +1 -1
  25. package/esm2020/lib/smart-filter/api/filter/model/filterExpressionFieldWidgetType.mjs +1 -1
  26. package/esm2020/lib/smart-filter/api/filter/model/filterExpressionList.mjs +1 -1
  27. package/esm2020/lib/smart-filter/api/filter/model/filterExpressionOperandData.mjs +1 -1
  28. package/esm2020/lib/smart-filter/api/filter/model/filterExpressionOperation.mjs +1 -1
  29. package/esm2020/lib/smart-filter/api/filter/model/filterExpressionOrderBy.mjs +1 -1
  30. package/esm2020/lib/smart-filter-editor/api/api/filter.service.mjs +1 -1
  31. package/esm2020/lib/smart-filter-editor/api/configuration.mjs +1 -1
  32. package/esm2020/lib/smart-filter-editor/api/encoder.mjs +1 -1
  33. package/esm2020/lib/smart-filter-editor/api/model/filterExpressionBoolOperator.mjs +1 -1
  34. package/esm2020/lib/smart-filter-editor/api/model/filterExpressionBuilderApiConfig.mjs +1 -1
  35. package/esm2020/lib/smart-filter-editor/api/model/filterExpressionBuilderField.mjs +1 -1
  36. package/esm2020/lib/smart-filter-editor/api/model/filterExpressionBuilderGroup.mjs +1 -1
  37. package/esm2020/lib/smart-filter-editor/api/model/filterExpressionBuilderModel.mjs +1 -1
  38. package/esm2020/lib/smart-filter-editor/api/model/filterExpressionBuilderUiModel.mjs +1 -1
  39. package/esm2020/lib/smart-filter-editor/api/model/filterExpressionData.mjs +1 -1
  40. package/esm2020/lib/smart-filter-editor/api/model/filterExpressionDataType.mjs +1 -1
  41. package/esm2020/lib/smart-filter-editor/api/model/filterExpressionField.mjs +1 -1
  42. package/esm2020/lib/smart-filter-editor/api/model/filterExpressionFieldEditor.mjs +1 -1
  43. package/esm2020/lib/smart-filter-editor/api/model/filterExpressionFieldList.mjs +1 -1
  44. package/esm2020/lib/smart-filter-editor/api/model/filterExpressionFieldWidgetType.mjs +1 -1
  45. package/esm2020/lib/smart-filter-editor/api/model/filterExpressionList.mjs +1 -1
  46. package/esm2020/lib/smart-filter-editor/api/model/filterExpressionOperandData.mjs +1 -1
  47. package/esm2020/lib/smart-filter-editor/api/model/filterExpressionOperation.mjs +1 -1
  48. package/esm2020/lib/smart-filter-editor/api/model/smartFilterType.mjs +1 -1
  49. package/esm2020/lib/smart-filter-editor/api/param.mjs +1 -1
  50. package/esm2020/lib/smart-filter-editor/api/variables.mjs +1 -1
  51. package/esm2020/lib/smart-form/api/model/models.mjs +1 -1
  52. package/esm2020/lib/smart-form/api/model/smartFormInputMode.mjs +1 -1
  53. package/esm2020/lib/smart-form/api/model/smartFormWidgetType.mjs +1 -1
  54. package/esm2020/lib/smart-form/api/model/smartWidgetDefinition.mjs +1 -1
  55. package/esm2020/lib/smart-form/services/smartform.service.mjs +14 -6
  56. package/esm2020/lib/smart-form/smartform.form-model.mjs +1 -1
  57. package/esm2020/lib/smart-form/smartform.model.mjs +1 -1
  58. package/esm2020/lib/smart-form/validators/validator-provider.mjs +44 -0
  59. package/esm2020/lib/smart-form/widgets/smartformwidget/smartformwidget.component.mjs +3 -1
  60. package/esm2020/lib/smart-tree/tree-api/api/tree.service.mjs +1 -1
  61. package/esm2020/lib/smart-tree/tree-api/configuration.mjs +1 -1
  62. package/esm2020/lib/smart-tree/tree-api/encoder.mjs +1 -1
  63. package/esm2020/lib/smart-tree/tree-api/param.mjs +1 -1
  64. package/esm2020/lib/smart-tree/tree-api/variables.mjs +1 -1
  65. package/esm2020/lib/smart-validation/named-validator.service.mjs +122 -0
  66. package/esm2020/lib/smart-validation/projects.mjs +4 -0
  67. package/esm2020/lib/smart-validation/smart-validation.module.mjs +24 -0
  68. package/esm2020/lib/smart-validation/smart-validation.types.mjs +4 -0
  69. package/esm2020/lib/view-context/api/model/clipboardData.mjs +1 -1
  70. package/esm2020/lib/view-context/api/model/componentConstraint.mjs +1 -1
  71. package/esm2020/lib/view-context/api/model/deviceInfo.mjs +1 -1
  72. package/esm2020/lib/view-context/api/model/models.mjs +2 -1
  73. package/esm2020/lib/view-context/api/model/namedValidator.mjs +19 -0
  74. package/esm2020/lib/view-context/api/model/uiActionButtonDescriptor.mjs +1 -1
  75. package/esm2020/lib/view-context/api/model/view.mjs +1 -1
  76. package/esm2020/lib/view-context/api/model/viewContext.mjs +1 -1
  77. package/esm2020/lib/view-context/api/model/viewContextData.mjs +1 -1
  78. package/esm2020/lib/view-context/api/model/viewContextUpdate.mjs +1 -1
  79. package/esm2020/lib/view-context/api/model/viewPlaceholder.mjs +1 -1
  80. package/esm2020/lib/view-context/smart-view-context.module.mjs +1 -1
  81. package/esm2020/lib/view-context/value-api/api/api.mjs +1 -1
  82. package/esm2020/lib/view-context/value-api/api/value.service.mjs +1 -1
  83. package/esm2020/lib/view-context/value-api/api.module.mjs +1 -1
  84. package/esm2020/lib/view-context/value-api/configuration.mjs +1 -1
  85. package/esm2020/lib/view-context/value-api/encoder.mjs +1 -1
  86. package/esm2020/lib/view-context/value-api/index.mjs +1 -1
  87. package/esm2020/lib/view-context/value-api/model/genericValue.mjs +1 -1
  88. package/esm2020/lib/view-context/value-api/model/models.mjs +1 -1
  89. package/esm2020/lib/view-context/value-api/model/value.mjs +1 -1
  90. package/esm2020/lib/view-context/value-api/model/valueSetDefinition.mjs +1 -1
  91. package/esm2020/lib/view-context/value-api/model/valueSetDefinitionIdentifier.mjs +1 -1
  92. package/esm2020/lib/view-context/value-api/model/valueSetOperand.mjs +1 -1
  93. package/esm2020/lib/view-context/value-api/param.mjs +1 -1
  94. package/esm2020/lib/view-context/value-api/variables.mjs +1 -1
  95. package/esm2020/projects.mjs +2 -1
  96. package/fesm2015/smartbit4all-ng-client.mjs +180 -7
  97. package/fesm2015/smartbit4all-ng-client.mjs.map +1 -1
  98. package/fesm2020/smartbit4all-ng-client.mjs +175 -6
  99. package/fesm2020/smartbit4all-ng-client.mjs.map +1 -1
  100. package/lib/smart-form/services/smartform.service.d.ts +4 -1
  101. package/lib/smart-form/smartform.form-model.d.ts +2 -2
  102. package/lib/smart-form/smartform.model.d.ts +6 -0
  103. package/lib/smart-form/validators/validator-provider.d.ts +16 -0
  104. package/lib/smart-validation/named-validator.service.d.ts +17 -0
  105. package/lib/smart-validation/projects.d.ts +3 -0
  106. package/lib/smart-validation/smart-validation.module.d.ts +8 -0
  107. package/lib/smart-validation/smart-validation.types.d.ts +12 -0
  108. package/lib/view-context/api/model/componentConstraint.d.ts +6 -0
  109. package/lib/view-context/api/model/models.d.ts +1 -0
  110. package/lib/view-context/api/model/namedValidator.d.ts +26 -0
  111. package/package.json +1 -1
  112. package/projects.d.ts +1 -0
  113. package/smartbit4all-ng-client-3.4.0.tgz +0 -0
  114. package/src/lib/smart-component-layout/api/README.md +226 -226
  115. package/src/lib/smart-filter-editor/api/README.md +226 -226
  116. package/src/lib/smart-tree/tree-api/README.md +226 -226
  117. package/src/lib/view-context/value-api/README.md +226 -226
  118. package/smartbit4all-ng-client-3.3.244.tgz +0 -0
@@ -1,12 +1,15 @@
1
1
  import { FormGroup } from '@angular/forms';
2
2
  import { SmartFormWidget, SmartItem, SmartItems } from '../smartform.form-model';
3
3
  import { SmartForm, SmartValidator } from '../smartform.model';
4
+ import { NamedValidatorService } from '../../smart-validation/named-validator.service';
4
5
  import * as i0 from "@angular/core";
5
6
  export declare class SmartFormService {
7
+ private validatorProvider?;
6
8
  private readonly emptyKey;
7
9
  group: any;
8
10
  formGroup?: FormGroup;
9
11
  smartForm?: SmartForm;
12
+ constructor(validatorProvider?: NamedValidatorService | undefined);
10
13
  getSmartFormWidgetByKey(key: string): SmartFormWidget<any> | undefined;
11
14
  private collectKeysFromSmartForm;
12
15
  private findSmartFormWidgetByKey;
@@ -41,6 +44,6 @@ export declare class SmartFormService {
41
44
  private getTranslationOfKey;
42
45
  translateWidgets(widgets: SmartFormWidget<any>[]): Promise<void>;
43
46
  translateWidgetItems(widgets: SmartItems<any>[]): Promise<void>;
44
- static ɵfac: i0.ɵɵFactoryDeclaration<SmartFormService, never>;
47
+ static ɵfac: i0.ɵɵFactoryDeclaration<SmartFormService, [{ optional: true; }]>;
45
48
  static ɵprov: i0.ɵɵInjectableDeclaration<SmartFormService>;
46
49
  }
@@ -91,7 +91,7 @@ export interface SmartTextFieldChips<T> {
91
91
  value?: T;
92
92
  placeholder?: string;
93
93
  originalPlaceholder?: string;
94
- minWidth?: SmartFormWidgetWidth | number | number;
94
+ minWidth?: SmartFormWidgetWidth | number;
95
95
  isDisabled?: boolean;
96
96
  isReadonly?: boolean;
97
97
  validators?: SmartValidator[];
@@ -121,7 +121,7 @@ export interface SmartTextFieldLookup<T> {
121
121
  value?: T;
122
122
  placeholder?: string;
123
123
  originalPlaceholder?: string;
124
- minWidth?: SmartFormWidgetWidth | number | number;
124
+ minWidth?: SmartFormWidgetWidth | number;
125
125
  isDisabled?: boolean;
126
126
  isReadonly?: boolean;
127
127
  validators?: SmartValidator[];
@@ -2,6 +2,7 @@ import { ValidatorFn } from '@angular/forms';
2
2
  import { SmartFormWidget } from './smartform.form-model';
3
3
  import { SmartFormWidgetDirection } from './api';
4
4
  import { SmartTranslateService } from '../view-context/smart-view-context.model';
5
+ import { NamedValidator } from '../view-context/api';
5
6
  export interface SophisticatedValueChange {
6
7
  key: string;
7
8
  value: any;
@@ -15,6 +16,11 @@ export interface SmartFormComponentConstraint {
15
16
  visible?: boolean;
16
17
  mandatory?: boolean;
17
18
  enabled?: boolean;
19
+ max?: number;
20
+ maxLength?: number;
21
+ min?: number;
22
+ minLength?: number;
23
+ namedValidators?: Array<NamedValidator>;
18
24
  }
19
25
  export declare enum SmartFormWidgetWidth {
20
26
  SMALL = 150,
@@ -0,0 +1,16 @@
1
+ import { InjectionToken } from '@angular/core';
2
+ import { SmartValidator } from '../smartform.model';
3
+ import { SmartFormWidget } from '../smartform.form-model';
4
+ import { ComponentConstraint } from '../../view-context/projects';
5
+ import * as i0 from "@angular/core";
6
+ export declare const SMART_VALIDATOR: InjectionToken<SmartValidator>;
7
+ export declare class ValidatorProvider {
8
+ private readonly validatorsByName;
9
+ constructor(vs: Array<SmartValidator> | undefined);
10
+ provide(name: string): SmartValidator | undefined;
11
+ clearProvidedValidators(widget: SmartFormWidget<any>): void;
12
+ apply2(widget: SmartFormWidget<any>, constraints: ComponentConstraint[]): void;
13
+ apply(widget: SmartFormWidget<any>, validatorName: string): void;
14
+ static ɵfac: i0.ɵɵFactoryDeclaration<ValidatorProvider, [{ optional: true; }]>;
15
+ static ɵprov: i0.ɵɵInjectableDeclaration<ValidatorProvider>;
16
+ }
@@ -0,0 +1,17 @@
1
+ import { SmartFormWidget } from '../smart-form/smartform.form-model';
2
+ import { SmartFormComponentConstraint, SmartValidator } from '../smart-form/smartform.model';
3
+ import { ValidatorFactory } from './smart-validation.types';
4
+ import * as i0 from "@angular/core";
5
+ export declare type ValidatedWidget<T> = SmartFormWidget<T> & {
6
+ validators: Array<SmartValidator>;
7
+ };
8
+ export declare class NamedValidatorService {
9
+ private readonly factories;
10
+ constructor(factories: Array<ValidatorFactory>);
11
+ applyConstraint(w: ValidatedWidget<any>, c: SmartFormComponentConstraint): void;
12
+ private applyBuiltInValidators;
13
+ private applyNamedValidators;
14
+ private applyNamedValidator;
15
+ static ɵfac: i0.ɵɵFactoryDeclaration<NamedValidatorService, [{ optional: true; }]>;
16
+ static ɵprov: i0.ɵɵInjectableDeclaration<NamedValidatorService>;
17
+ }
@@ -0,0 +1,3 @@
1
+ export * from './smart-validation.types';
2
+ export * from './smart-validation.module';
3
+ export * from './named-validator.service';
@@ -0,0 +1,8 @@
1
+ import { ModuleWithProviders, Provider } from '@angular/core';
2
+ import * as i0 from "@angular/core";
3
+ export declare class SmartValidationModule {
4
+ static forRoot(providers: Array<Provider>): ModuleWithProviders<SmartValidationModule>;
5
+ static ɵfac: i0.ɵɵFactoryDeclaration<SmartValidationModule, never>;
6
+ static ɵmod: i0.ɵɵNgModuleDeclaration<SmartValidationModule, never, never, never>;
7
+ static ɵinj: i0.ɵɵInjectorDeclaration<SmartValidationModule>;
8
+ }
@@ -0,0 +1,12 @@
1
+ import { ValidatorFn } from '@angular/forms';
2
+ import { InjectionToken } from '@angular/core';
3
+ export interface ValidatorParameters {
4
+ [k: string]: any;
5
+ }
6
+ export declare const EMPTY_PARAMS: ValidatorParameters;
7
+ export interface ValidatorFactory {
8
+ name: string;
9
+ params: Array<String>;
10
+ create(validatorParameters?: ValidatorParameters): ValidatorFn;
11
+ }
12
+ export declare const NAMED_VALIDATOR: InjectionToken<ValidatorFactory>;
@@ -9,6 +9,7 @@
9
9
  * https://openapi-generator.tech
10
10
  * Do not edit the class manually.
11
11
  */
12
+ import { NamedValidator } from './namedValidator';
12
13
  import { ValueSetData } from '../../value-api';
13
14
  /**
14
15
  * The component constraint is responsible for the constraints belong to a given component (textfield, combobox etc.) on the view. The UI must identify the component by the dataName that is a path of the data name separated by dot like dataSheet.field.
@@ -22,4 +23,9 @@ export interface ComponentConstraint {
22
23
  mandatory?: boolean;
23
24
  enabled?: boolean;
24
25
  valueSet?: ValueSetData;
26
+ min?: number;
27
+ max?: number;
28
+ minLength?: number;
29
+ maxLength?: number;
30
+ namedValidators: Array<NamedValidator>;
25
31
  }
@@ -17,6 +17,7 @@ export * from './messageOptionType';
17
17
  export * from './messageResult';
18
18
  export * from './messageTextType';
19
19
  export * from './messageType';
20
+ export * from './namedValidator';
20
21
  export * from './openPendingData';
21
22
  export * from './serverRequestExecutionStat';
22
23
  export * from './serverRequestTrack';
@@ -0,0 +1,26 @@
1
+ /**
2
+ * View API
3
+ * View API
4
+ *
5
+ * The version of the OpenAPI document: 1.0.0
6
+ * Contact: info@it4all.hu
7
+ *
8
+ * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
9
+ * https://openapi-generator.tech
10
+ * Do not edit the class manually.
11
+ */
12
+ export interface NamedValidator {
13
+ name: string;
14
+ params: {
15
+ [key: string]: object;
16
+ };
17
+ /**
18
+ * ADD: REMOVE: ALTER: Do not explicitly add, but alter preexisting matching validator\'s parameters
19
+ */
20
+ operation: NamedValidatorOperationEnum;
21
+ }
22
+ export declare enum NamedValidatorOperationEnum {
23
+ ADD = "ADD",
24
+ REMOVE = "REMOVE",
25
+ ALTER = "ALTER"
26
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@smartbit4all/ng-client",
3
- "version": "3.3.244",
3
+ "version": "3.4.0",
4
4
  "peerDependencies": {
5
5
  "@angular/animations": "^13.3.9",
6
6
  "@angular/common": "^13.2.0",
package/projects.d.ts CHANGED
@@ -17,6 +17,7 @@ export * from './lib/smart-subject/projects';
17
17
  export * from './lib/smart-tab-group/projects';
18
18
  export * from './lib/smart-table/projects';
19
19
  export * from './lib/smart-tree/projects';
20
+ export * from './lib/smart-validation/projects';
20
21
  export * from './lib/view-context/projects';
21
22
  export * from './lib/smart-filter-editor/project';
22
23
  export * from './lib/shared/projects';
Binary file
@@ -1,226 +1,226 @@
1
- ## @
2
-
3
- ### Building
4
-
5
- To install the required dependencies and to build the typescript sources run:
6
- ```
7
- npm install
8
- npm run build
9
- ```
10
-
11
- ### publishing
12
-
13
- First build the package then run ```npm publish dist``` (don't forget to specify the `dist` folder!)
14
-
15
- ### consuming
16
-
17
- Navigate to the folder of your consuming project and run one of next commands.
18
-
19
- _published:_
20
-
21
- ```
22
- npm install @ --save
23
- ```
24
-
25
- _without publishing (not recommended):_
26
-
27
- ```
28
- npm install PATH_TO_GENERATED_PACKAGE/dist.tgz --save
29
- ```
30
-
31
- _It's important to take the tgz file, otherwise you'll get trouble with links on windows_
32
-
33
- _using `npm link`:_
34
-
35
- In PATH_TO_GENERATED_PACKAGE/dist:
36
- ```
37
- npm link
38
- ```
39
-
40
- In your project:
41
- ```
42
- npm link
43
- ```
44
-
45
- __Note for Windows users:__ The Angular CLI has troubles to use linked npm packages.
46
- Please refer to this issue https://github.com/angular/angular-cli/issues/8284 for a solution / workaround.
47
- Published packages are not effected by this issue.
48
-
49
-
50
- #### General usage
51
-
52
- In your Angular project:
53
-
54
-
55
- ```
56
- // without configuring providers
57
- import { ApiModule } from '';
58
- import { HttpClientModule } from '@angular/common/http';
59
-
60
- @NgModule({
61
- imports: [
62
- ApiModule,
63
- // make sure to import the HttpClientModule in the AppModule only,
64
- // see https://github.com/angular/angular/issues/20575
65
- HttpClientModule
66
- ],
67
- declarations: [ AppComponent ],
68
- providers: [],
69
- bootstrap: [ AppComponent ]
70
- })
71
- export class AppModule {}
72
- ```
73
-
74
- ```
75
- // configuring providers
76
- import { ApiModule, Configuration, ConfigurationParameters } from '';
77
-
78
- export function apiConfigFactory (): Configuration {
79
- const params: ConfigurationParameters = {
80
- // set configuration parameters here.
81
- }
82
- return new Configuration(params);
83
- }
84
-
85
- @NgModule({
86
- imports: [ ApiModule.forRoot(apiConfigFactory) ],
87
- declarations: [ AppComponent ],
88
- providers: [],
89
- bootstrap: [ AppComponent ]
90
- })
91
- export class AppModule {}
92
- ```
93
-
94
- ```
95
- // configuring providers with an authentication service that manages your access tokens
96
- import { ApiModule, Configuration } from '';
97
-
98
- @NgModule({
99
- imports: [ ApiModule ],
100
- declarations: [ AppComponent ],
101
- providers: [
102
- {
103
- provide: Configuration,
104
- useFactory: (authService: AuthService) => new Configuration(
105
- {
106
- basePath: environment.apiUrl,
107
- accessToken: authService.getAccessToken.bind(authService)
108
- }
109
- ),
110
- deps: [AuthService],
111
- multi: false
112
- }
113
- ],
114
- bootstrap: [ AppComponent ]
115
- })
116
- export class AppModule {}
117
- ```
118
-
119
- ```
120
- import { DefaultApi } from '';
121
-
122
- export class AppComponent {
123
- constructor(private apiGateway: DefaultApi) { }
124
- }
125
- ```
126
-
127
- Note: The ApiModule is restricted to being instantiated once app wide.
128
- This is to ensure that all services are treated as singletons.
129
-
130
- #### Using multiple OpenAPI files / APIs / ApiModules
131
- In order to use multiple `ApiModules` generated from different OpenAPI files,
132
- you can create an alias name when importing the modules
133
- in order to avoid naming conflicts:
134
- ```
135
- import { ApiModule } from 'my-api-path';
136
- import { ApiModule as OtherApiModule } from 'my-other-api-path';
137
- import { HttpClientModule } from '@angular/common/http';
138
-
139
- @NgModule({
140
- imports: [
141
- ApiModule,
142
- OtherApiModule,
143
- // make sure to import the HttpClientModule in the AppModule only,
144
- // see https://github.com/angular/angular/issues/20575
145
- HttpClientModule
146
- ]
147
- })
148
- export class AppModule {
149
-
150
- }
151
- ```
152
-
153
-
154
- ### Set service base path
155
- If different than the generated base path, during app bootstrap, you can provide the base path to your service.
156
-
157
- ```
158
- import { BASE_PATH } from '';
159
-
160
- bootstrap(AppComponent, [
161
- { provide: BASE_PATH, useValue: 'https://your-web-service.com' },
162
- ]);
163
- ```
164
- or
165
-
166
- ```
167
- import { BASE_PATH } from '';
168
-
169
- @NgModule({
170
- imports: [],
171
- declarations: [ AppComponent ],
172
- providers: [ provide: BASE_PATH, useValue: 'https://your-web-service.com' ],
173
- bootstrap: [ AppComponent ]
174
- })
175
- export class AppModule {}
176
- ```
177
-
178
-
179
- #### Using @angular/cli
180
- First extend your `src/environments/*.ts` files by adding the corresponding base path:
181
-
182
- ```
183
- export const environment = {
184
- production: false,
185
- API_BASE_PATH: 'http://127.0.0.1:8080'
186
- };
187
- ```
188
-
189
- In the src/app/app.module.ts:
190
- ```
191
- import { BASE_PATH } from '';
192
- import { environment } from '../environments/environment';
193
-
194
- @NgModule({
195
- declarations: [
196
- AppComponent
197
- ],
198
- imports: [ ],
199
- providers: [{ provide: BASE_PATH, useValue: environment.API_BASE_PATH }],
200
- bootstrap: [ AppComponent ]
201
- })
202
- export class AppModule { }
203
- ```
204
-
205
- ### Customizing path parameter encoding
206
-
207
- Without further customization, only [path-parameters][parameter-locations-url] of [style][style-values-url] 'simple'
208
- and Dates for format 'date-time' are encoded correctly.
209
-
210
- Other styles (e.g. "matrix") are not that easy to encode
211
- and thus are best delegated to other libraries (e.g.: [@honoluluhenk/http-param-expander]).
212
-
213
- To implement your own parameter encoding (or call another library),
214
- pass an arrow-function or method-reference to the `encodeParam` property of the Configuration-object
215
- (see [General Usage](#general-usage) above).
216
-
217
- Example value for use in your Configuration-Provider:
218
- ```typescript
219
- new Configuration({
220
- encodeParam: (param: Param) => myFancyParamEncoder(param),
221
- })
222
- ```
223
-
224
- [parameter-locations-url]: https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.1.0.md#parameter-locations
225
- [style-values-url]: https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.1.0.md#style-values
226
- [@honoluluhenk/http-param-expander]: https://www.npmjs.com/package/@honoluluhenk/http-param-expander
1
+ ## @
2
+
3
+ ### Building
4
+
5
+ To install the required dependencies and to build the typescript sources run:
6
+ ```
7
+ npm install
8
+ npm run build
9
+ ```
10
+
11
+ ### publishing
12
+
13
+ First build the package then run ```npm publish dist``` (don't forget to specify the `dist` folder!)
14
+
15
+ ### consuming
16
+
17
+ Navigate to the folder of your consuming project and run one of next commands.
18
+
19
+ _published:_
20
+
21
+ ```
22
+ npm install @ --save
23
+ ```
24
+
25
+ _without publishing (not recommended):_
26
+
27
+ ```
28
+ npm install PATH_TO_GENERATED_PACKAGE/dist.tgz --save
29
+ ```
30
+
31
+ _It's important to take the tgz file, otherwise you'll get trouble with links on windows_
32
+
33
+ _using `npm link`:_
34
+
35
+ In PATH_TO_GENERATED_PACKAGE/dist:
36
+ ```
37
+ npm link
38
+ ```
39
+
40
+ In your project:
41
+ ```
42
+ npm link
43
+ ```
44
+
45
+ __Note for Windows users:__ The Angular CLI has troubles to use linked npm packages.
46
+ Please refer to this issue https://github.com/angular/angular-cli/issues/8284 for a solution / workaround.
47
+ Published packages are not effected by this issue.
48
+
49
+
50
+ #### General usage
51
+
52
+ In your Angular project:
53
+
54
+
55
+ ```
56
+ // without configuring providers
57
+ import { ApiModule } from '';
58
+ import { HttpClientModule } from '@angular/common/http';
59
+
60
+ @NgModule({
61
+ imports: [
62
+ ApiModule,
63
+ // make sure to import the HttpClientModule in the AppModule only,
64
+ // see https://github.com/angular/angular/issues/20575
65
+ HttpClientModule
66
+ ],
67
+ declarations: [ AppComponent ],
68
+ providers: [],
69
+ bootstrap: [ AppComponent ]
70
+ })
71
+ export class AppModule {}
72
+ ```
73
+
74
+ ```
75
+ // configuring providers
76
+ import { ApiModule, Configuration, ConfigurationParameters } from '';
77
+
78
+ export function apiConfigFactory (): Configuration {
79
+ const params: ConfigurationParameters = {
80
+ // set configuration parameters here.
81
+ }
82
+ return new Configuration(params);
83
+ }
84
+
85
+ @NgModule({
86
+ imports: [ ApiModule.forRoot(apiConfigFactory) ],
87
+ declarations: [ AppComponent ],
88
+ providers: [],
89
+ bootstrap: [ AppComponent ]
90
+ })
91
+ export class AppModule {}
92
+ ```
93
+
94
+ ```
95
+ // configuring providers with an authentication service that manages your access tokens
96
+ import { ApiModule, Configuration } from '';
97
+
98
+ @NgModule({
99
+ imports: [ ApiModule ],
100
+ declarations: [ AppComponent ],
101
+ providers: [
102
+ {
103
+ provide: Configuration,
104
+ useFactory: (authService: AuthService) => new Configuration(
105
+ {
106
+ basePath: environment.apiUrl,
107
+ accessToken: authService.getAccessToken.bind(authService)
108
+ }
109
+ ),
110
+ deps: [AuthService],
111
+ multi: false
112
+ }
113
+ ],
114
+ bootstrap: [ AppComponent ]
115
+ })
116
+ export class AppModule {}
117
+ ```
118
+
119
+ ```
120
+ import { DefaultApi } from '';
121
+
122
+ export class AppComponent {
123
+ constructor(private apiGateway: DefaultApi) { }
124
+ }
125
+ ```
126
+
127
+ Note: The ApiModule is restricted to being instantiated once app wide.
128
+ This is to ensure that all services are treated as singletons.
129
+
130
+ #### Using multiple OpenAPI files / APIs / ApiModules
131
+ In order to use multiple `ApiModules` generated from different OpenAPI files,
132
+ you can create an alias name when importing the modules
133
+ in order to avoid naming conflicts:
134
+ ```
135
+ import { ApiModule } from 'my-api-path';
136
+ import { ApiModule as OtherApiModule } from 'my-other-api-path';
137
+ import { HttpClientModule } from '@angular/common/http';
138
+
139
+ @NgModule({
140
+ imports: [
141
+ ApiModule,
142
+ OtherApiModule,
143
+ // make sure to import the HttpClientModule in the AppModule only,
144
+ // see https://github.com/angular/angular/issues/20575
145
+ HttpClientModule
146
+ ]
147
+ })
148
+ export class AppModule {
149
+
150
+ }
151
+ ```
152
+
153
+
154
+ ### Set service base path
155
+ If different than the generated base path, during app bootstrap, you can provide the base path to your service.
156
+
157
+ ```
158
+ import { BASE_PATH } from '';
159
+
160
+ bootstrap(AppComponent, [
161
+ { provide: BASE_PATH, useValue: 'https://your-web-service.com' },
162
+ ]);
163
+ ```
164
+ or
165
+
166
+ ```
167
+ import { BASE_PATH } from '';
168
+
169
+ @NgModule({
170
+ imports: [],
171
+ declarations: [ AppComponent ],
172
+ providers: [ provide: BASE_PATH, useValue: 'https://your-web-service.com' ],
173
+ bootstrap: [ AppComponent ]
174
+ })
175
+ export class AppModule {}
176
+ ```
177
+
178
+
179
+ #### Using @angular/cli
180
+ First extend your `src/environments/*.ts` files by adding the corresponding base path:
181
+
182
+ ```
183
+ export const environment = {
184
+ production: false,
185
+ API_BASE_PATH: 'http://127.0.0.1:8080'
186
+ };
187
+ ```
188
+
189
+ In the src/app/app.module.ts:
190
+ ```
191
+ import { BASE_PATH } from '';
192
+ import { environment } from '../environments/environment';
193
+
194
+ @NgModule({
195
+ declarations: [
196
+ AppComponent
197
+ ],
198
+ imports: [ ],
199
+ providers: [{ provide: BASE_PATH, useValue: environment.API_BASE_PATH }],
200
+ bootstrap: [ AppComponent ]
201
+ })
202
+ export class AppModule { }
203
+ ```
204
+
205
+ ### Customizing path parameter encoding
206
+
207
+ Without further customization, only [path-parameters][parameter-locations-url] of [style][style-values-url] 'simple'
208
+ and Dates for format 'date-time' are encoded correctly.
209
+
210
+ Other styles (e.g. "matrix") are not that easy to encode
211
+ and thus are best delegated to other libraries (e.g.: [@honoluluhenk/http-param-expander]).
212
+
213
+ To implement your own parameter encoding (or call another library),
214
+ pass an arrow-function or method-reference to the `encodeParam` property of the Configuration-object
215
+ (see [General Usage](#general-usage) above).
216
+
217
+ Example value for use in your Configuration-Provider:
218
+ ```typescript
219
+ new Configuration({
220
+ encodeParam: (param: Param) => myFancyParamEncoder(param),
221
+ })
222
+ ```
223
+
224
+ [parameter-locations-url]: https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.1.0.md#parameter-locations
225
+ [style-values-url]: https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.1.0.md#style-values
226
+ [@honoluluhenk/http-param-expander]: https://www.npmjs.com/package/@honoluluhenk/http-param-expander