@smartbit4all/ng-client 3.1.27 → 3.1.29
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/esm2020/lib/smart-form/api/api/api.mjs +1 -1
- package/esm2020/lib/smart-form/api/api/default.service.mjs +1 -1
- package/esm2020/lib/smart-form/api/api.module.mjs +1 -1
- package/esm2020/lib/smart-form/api/configuration.mjs +1 -1
- package/esm2020/lib/smart-form/api/encoder.mjs +1 -1
- package/esm2020/lib/smart-form/api/index.mjs +1 -1
- package/esm2020/lib/smart-form/api/model/models.mjs +1 -1
- package/esm2020/lib/smart-form/api/model/propertyMapping.mjs +1 -1
- package/esm2020/lib/smart-form/api/model/selectionDefinition.mjs +1 -1
- package/esm2020/lib/smart-form/api/model/smartLayoutDefinition.mjs +1 -1
- package/esm2020/lib/smart-form/api/model/smartMatrixModel.mjs +1 -1
- package/esm2020/lib/smart-form/api/model/smartWidgetDefinition.mjs +1 -1
- package/esm2020/lib/smart-form/api/param.mjs +1 -1
- package/esm2020/lib/smart-form/api/variables.mjs +1 -1
- package/esm2020/lib/smart-grid/api/grid-api/api/api.mjs +1 -1
- package/esm2020/lib/smart-grid/api/grid-api/api/grid.service.mjs +1 -1
- package/esm2020/lib/smart-grid/api/grid-api/api.module.mjs +1 -1
- package/esm2020/lib/smart-grid/api/grid-api/configuration.mjs +1 -1
- package/esm2020/lib/smart-grid/api/grid-api/encoder.mjs +1 -1
- package/esm2020/lib/smart-grid/api/grid-api/index.mjs +1 -1
- package/esm2020/lib/smart-grid/api/grid-api/model/gridColumnContentType.mjs +1 -1
- package/esm2020/lib/smart-grid/api/grid-api/model/gridColumnMeta.mjs +1 -1
- package/esm2020/lib/smart-grid/api/grid-api/model/gridDataAccessConfig.mjs +1 -1
- package/esm2020/lib/smart-grid/api/grid-api/model/gridModel.mjs +1 -1
- package/esm2020/lib/smart-grid/api/grid-api/model/gridPage.mjs +1 -1
- package/esm2020/lib/smart-grid/api/grid-api/model/gridRow.mjs +1 -1
- package/esm2020/lib/smart-grid/api/grid-api/model/gridSelectionMode.mjs +1 -1
- package/esm2020/lib/smart-grid/api/grid-api/model/gridSelectionType.mjs +1 -1
- package/esm2020/lib/smart-grid/api/grid-api/model/gridServerModel.mjs +1 -1
- package/esm2020/lib/smart-grid/api/grid-api/model/gridUpdateData.mjs +1 -1
- package/esm2020/lib/smart-grid/api/grid-api/model/gridView.mjs +1 -1
- package/esm2020/lib/smart-grid/api/grid-api/model/gridViewDescriptor.mjs +1 -1
- package/esm2020/lib/smart-grid/api/grid-api/model/models.mjs +1 -1
- package/esm2020/lib/smart-grid/api/grid-api/param.mjs +1 -1
- package/esm2020/lib/smart-grid/api/grid-api/variables.mjs +1 -1
- package/esm2020/lib/smart-grid/smart-grid.component.mjs +17 -3
- package/esm2020/lib/smart-table/smarttable.model.mjs +19 -20
- package/esm2020/lib/smart-table/smarttable.module.mjs +6 -2
- package/esm2020/lib/smart-table/tables/material-table/material-table.component.mjs +6 -5
- package/esm2020/lib/smart-table/tables/table.mjs +20 -8
- package/esm2020/lib/view-context/api/model/uiActionButtonType.mjs +3 -2
- package/esm2020/lib/view-context/api/model/uploadedFile.mjs +1 -1
- package/esm2020/lib/view-context/api/model/viewEventHandler.mjs +1 -1
- package/esm2020/lib/view-context/value-api/api/api.mjs +1 -1
- package/esm2020/lib/view-context/value-api/api/value.service.mjs +1 -1
- package/esm2020/lib/view-context/value-api/api.module.mjs +1 -1
- package/esm2020/lib/view-context/value-api/configuration.mjs +1 -1
- package/esm2020/lib/view-context/value-api/encoder.mjs +1 -1
- package/esm2020/lib/view-context/value-api/index.mjs +1 -1
- package/esm2020/lib/view-context/value-api/model/genericValue.mjs +1 -1
- package/esm2020/lib/view-context/value-api/model/models.mjs +1 -1
- package/esm2020/lib/view-context/value-api/model/value.mjs +1 -1
- package/esm2020/lib/view-context/value-api/model/valueSetData.mjs +1 -1
- package/esm2020/lib/view-context/value-api/model/valueSetDefinition.mjs +1 -1
- package/esm2020/lib/view-context/value-api/model/valueSetDefinitionData.mjs +1 -1
- package/esm2020/lib/view-context/value-api/model/valueSetDefinitionIdentifier.mjs +1 -1
- package/esm2020/lib/view-context/value-api/model/valueSetDefinitionKind.mjs +1 -1
- package/esm2020/lib/view-context/value-api/model/valueSetExpression.mjs +1 -1
- package/esm2020/lib/view-context/value-api/model/valueSetOperand.mjs +1 -1
- package/esm2020/lib/view-context/value-api/model/valueSetOperation.mjs +1 -1
- package/esm2020/lib/view-context/value-api/param.mjs +1 -1
- package/esm2020/lib/view-context/value-api/variables.mjs +1 -1
- package/fesm2015/smartbit4all-ng-client.mjs +67 -37
- package/fesm2015/smartbit4all-ng-client.mjs.map +1 -1
- package/fesm2020/smartbit4all-ng-client.mjs +63 -32
- package/fesm2020/smartbit4all-ng-client.mjs.map +1 -1
- package/lib/smart-table/smarttable.model.d.ts +7 -3
- package/lib/smart-table/smarttable.module.d.ts +2 -1
- package/lib/smart-table/tables/table.d.ts +4 -1
- package/lib/view-context/api/model/uiActionButtonType.d.ts +2 -1
- package/package.json +1 -1
- package/smartbit4all-ng-client-3.1.29.tgz +0 -0
- package/src/lib/smart-form/api/README.md +226 -226
- package/src/lib/smart-grid/api/grid-api/README.md +226 -226
- package/src/lib/view-context/value-api/README.md +226 -226
- package/smartbit4all-ng-client-3.1.27.tgz +0 -0
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { SelectionModel } from
|
|
2
|
-
import { ThemePalette } from
|
|
1
|
+
import { SelectionModel } from '@angular/cdk/collections';
|
|
2
|
+
import { ThemePalette } from '@angular/material/core';
|
|
3
3
|
export declare enum SmartTableType {
|
|
4
4
|
INHERITED = "Inherited",
|
|
5
5
|
CHECK_BOX = "CheckBox",
|
|
@@ -69,7 +69,8 @@ export declare enum SmartTableButtonType {
|
|
|
69
69
|
MENU = "MENU",
|
|
70
70
|
ICON = "ICON",
|
|
71
71
|
NORMAL = "NORMAL",
|
|
72
|
-
RAISED = "RAISED"
|
|
72
|
+
RAISED = "RAISED",
|
|
73
|
+
SEPARATOR = "SEPARATOR"
|
|
73
74
|
}
|
|
74
75
|
export declare enum SmartTableOptionButtonDirection {
|
|
75
76
|
HORIZONTAL = 0,
|
|
@@ -92,6 +93,7 @@ export interface SmartTableInterface<T> {
|
|
|
92
93
|
tableOptionButtonDirection?: SmartTableOptionButtonDirection;
|
|
93
94
|
onRowClick?: (row: T) => void;
|
|
94
95
|
onRowDoubleClick?: (row: T) => void;
|
|
96
|
+
defaultActions?: SmartTableButton[];
|
|
95
97
|
highlightOnRowClick?: boolean;
|
|
96
98
|
highlightClass?: string;
|
|
97
99
|
hover?: boolean;
|
|
@@ -121,6 +123,7 @@ export interface SmartTableGridInterface<T> {
|
|
|
121
123
|
tableOptionButtonDirection?: SmartTableOptionButtonDirection;
|
|
122
124
|
onRowClick?: (row: T) => void;
|
|
123
125
|
onRowDoubleClick?: (row: T) => void;
|
|
126
|
+
defaultActions?: SmartTableButton[];
|
|
124
127
|
highlightOnRowClick?: boolean;
|
|
125
128
|
highlightClass?: string;
|
|
126
129
|
hover?: boolean;
|
|
@@ -158,6 +161,7 @@ export declare class SmartTable<T> implements SmartTableInterface<T> {
|
|
|
158
161
|
tableOptionButtonDirection?: SmartTableOptionButtonDirection;
|
|
159
162
|
onRowClick?: (row: T) => void;
|
|
160
163
|
onRowDoubleClick?: (row: T) => void;
|
|
164
|
+
defaultActions?: SmartTableButton[];
|
|
161
165
|
highlightOnRowClick?: boolean;
|
|
162
166
|
highlightClass?: string;
|
|
163
167
|
hover?: boolean;
|
|
@@ -16,8 +16,9 @@ import * as i14 from "@angular/material/menu";
|
|
|
16
16
|
import * as i15 from "@angular/material/progress-spinner";
|
|
17
17
|
import * as i16 from "../component-factory-service/component-factory-service.module";
|
|
18
18
|
import * as i17 from "../smart-icon/smart-icon.module";
|
|
19
|
+
import * as i18 from "@angular/material/divider";
|
|
19
20
|
export declare class SmarttableModule {
|
|
20
21
|
static ɵfac: i0.ɵɵFactoryDeclaration<SmarttableModule, never>;
|
|
21
|
-
static ɵmod: i0.ɵɵNgModuleDeclaration<SmarttableModule, [typeof i1.SmarttableComponent, typeof i2.SmartDatePipe, typeof i2.SmartDateTimePipe, typeof i2.SmartTimePipe, typeof i3.LoadingComponent, typeof i4.MaterialTableComponent, typeof i5.MobileTableComponent], [typeof i6.BrowserModule, typeof i7.MatCommonModule, typeof i8.FormsModule, typeof i8.ReactiveFormsModule, typeof i9.MatFormFieldModule, typeof i10.MatCheckboxModule, typeof i11.MatButtonModule, typeof i12.MatTableModule, typeof i13.MatIconModule, typeof i14.MatMenuModule, typeof i15.MatProgressSpinnerModule, typeof i16.ComponentFactoryServiceModule, typeof i17.SmartIconModule], [typeof i1.SmarttableComponent]>;
|
|
22
|
+
static ɵmod: i0.ɵɵNgModuleDeclaration<SmarttableModule, [typeof i1.SmarttableComponent, typeof i2.SmartDatePipe, typeof i2.SmartDateTimePipe, typeof i2.SmartTimePipe, typeof i3.LoadingComponent, typeof i4.MaterialTableComponent, typeof i5.MobileTableComponent], [typeof i6.BrowserModule, typeof i7.MatCommonModule, typeof i8.FormsModule, typeof i8.ReactiveFormsModule, typeof i9.MatFormFieldModule, typeof i10.MatCheckboxModule, typeof i11.MatButtonModule, typeof i12.MatTableModule, typeof i13.MatIconModule, typeof i14.MatMenuModule, typeof i15.MatProgressSpinnerModule, typeof i16.ComponentFactoryServiceModule, typeof i17.SmartIconModule, typeof i18.MatDividerModule], [typeof i1.SmarttableComponent]>;
|
|
22
23
|
static ɵinj: i0.ɵɵInjectorDeclaration<SmarttableModule>;
|
|
23
24
|
}
|
|
@@ -9,7 +9,8 @@ import * as i0 from "@angular/core";
|
|
|
9
9
|
export declare class Table implements OnInit, OnDestroy {
|
|
10
10
|
protected cfService: ComponentFactoryService;
|
|
11
11
|
_destroy$: Subject<void>;
|
|
12
|
-
|
|
12
|
+
triggers: QueryList<MatMenuTrigger>;
|
|
13
|
+
trigger: MatMenuTrigger;
|
|
13
14
|
vcRef?: ViewContainerRef[];
|
|
14
15
|
componentRef?: ComponentRef<any>;
|
|
15
16
|
myTableChild: MatTable<any>;
|
|
@@ -23,6 +24,7 @@ export declare class Table implements OnInit, OnDestroy {
|
|
|
23
24
|
onSelectionChanged: Subject<void>;
|
|
24
25
|
constructor(cfService: ComponentFactoryService);
|
|
25
26
|
asyncTranslationResult: (translator: any, param: string) => any;
|
|
27
|
+
readonly ACTION_SEPERATOR = SmartTableButtonType.SEPARATOR;
|
|
26
28
|
ngOnInit(): void;
|
|
27
29
|
ngOnDestroy(): void;
|
|
28
30
|
handleOnRowClick(element: any): void;
|
|
@@ -58,6 +60,7 @@ export declare class Table implements OnInit, OnDestroy {
|
|
|
58
60
|
isImageResource(element: any, header: string): boolean;
|
|
59
61
|
getImageResourceIcon(element: any, header: string): any;
|
|
60
62
|
getImageResourceColor(element: any, header: string): any;
|
|
63
|
+
openDefaultActionsMenu(): void;
|
|
61
64
|
static ɵfac: i0.ɵɵFactoryDeclaration<Table, never>;
|
|
62
65
|
static ɵcmp: i0.ɵɵComponentDeclaration<Table, "ng-component", never, { "smartTable": "smartTable"; }, {}, never, never>;
|
|
63
66
|
}
|
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
/**
|
|
13
13
|
* Defines the type of the button.
|
|
14
14
|
*/
|
|
15
|
-
export declare type UiActionButtonType = 'NORMAL' | 'FLAT' | 'STROKED' | 'RAISED' | 'ICON' | 'MINI_FAB' | 'FAB';
|
|
15
|
+
export declare type UiActionButtonType = 'NORMAL' | 'FLAT' | 'STROKED' | 'RAISED' | 'ICON' | 'MINI_FAB' | 'FAB' | 'SEPARATOR';
|
|
16
16
|
export declare const UiActionButtonType: {
|
|
17
17
|
Normal: UiActionButtonType;
|
|
18
18
|
Flat: UiActionButtonType;
|
|
@@ -21,4 +21,5 @@ export declare const UiActionButtonType: {
|
|
|
21
21
|
Icon: UiActionButtonType;
|
|
22
22
|
MiniFab: UiActionButtonType;
|
|
23
23
|
Fab: UiActionButtonType;
|
|
24
|
+
Separator: UiActionButtonType;
|
|
24
25
|
};
|
package/package.json
CHANGED
|
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
|