@viewcandidate/client 0.0.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/README.md +185 -0
- package/fesm2022/viewcandidate-client.mjs +1254 -0
- package/fesm2022/viewcandidate-client.mjs.map +1 -0
- package/index.d.ts +1241 -0
- package/package.json +34 -0
package/README.md
ADDED
|
@@ -0,0 +1,185 @@
|
|
|
1
|
+
# @viewcandidate/client@0.0.1
|
|
2
|
+
|
|
3
|
+
The ViewCandidate API
|
|
4
|
+
|
|
5
|
+
The version of the OpenAPI document: 0.0.1
|
|
6
|
+
|
|
7
|
+
## Building
|
|
8
|
+
|
|
9
|
+
To install the required dependencies and to build the typescript sources run:
|
|
10
|
+
|
|
11
|
+
```console
|
|
12
|
+
npm install
|
|
13
|
+
npm run build
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
## Publishing
|
|
17
|
+
|
|
18
|
+
First build the package then run `npm publish dist` (don't forget to specify the `dist` folder!)
|
|
19
|
+
|
|
20
|
+
## Consuming
|
|
21
|
+
|
|
22
|
+
Navigate to the folder of your consuming project and run one of next commands.
|
|
23
|
+
|
|
24
|
+
_published:_
|
|
25
|
+
|
|
26
|
+
```console
|
|
27
|
+
npm install @viewcandidate/client@0.0.1 --save
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
_without publishing (not recommended):_
|
|
31
|
+
|
|
32
|
+
```console
|
|
33
|
+
npm install PATH_TO_GENERATED_PACKAGE/dist.tgz --save
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
_It's important to take the tgz file, otherwise you'll get trouble with links on windows_
|
|
37
|
+
|
|
38
|
+
_using `npm link`:_
|
|
39
|
+
|
|
40
|
+
In PATH_TO_GENERATED_PACKAGE/dist:
|
|
41
|
+
|
|
42
|
+
```console
|
|
43
|
+
npm link
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
In your project:
|
|
47
|
+
|
|
48
|
+
```console
|
|
49
|
+
npm link @viewcandidate/client
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
__Note for Windows users:__ The Angular CLI has troubles to use linked npm packages.
|
|
53
|
+
Please refer to this issue <https://github.com/angular/angular-cli/issues/8284> for a solution / workaround.
|
|
54
|
+
Published packages are not effected by this issue.
|
|
55
|
+
|
|
56
|
+
### General usage
|
|
57
|
+
|
|
58
|
+
In your Angular project:
|
|
59
|
+
|
|
60
|
+
```typescript
|
|
61
|
+
|
|
62
|
+
import { ApplicationConfig } from '@angular/core';
|
|
63
|
+
import { provideHttpClient } from '@angular/common/http';
|
|
64
|
+
import { provideApi } from '@viewcandidate/client';
|
|
65
|
+
|
|
66
|
+
export const appConfig: ApplicationConfig = {
|
|
67
|
+
providers: [
|
|
68
|
+
// ...
|
|
69
|
+
provideHttpClient(),
|
|
70
|
+
provideApi()
|
|
71
|
+
],
|
|
72
|
+
};
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
**NOTE**
|
|
76
|
+
If you're still using `AppModule` and haven't [migrated](https://angular.dev/reference/migrations/standalone) yet, you can still import an Angular module:
|
|
77
|
+
```typescript
|
|
78
|
+
import { ViewCandidateApiModule } from '@viewcandidate/client';
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
If different from the generated base path, during app bootstrap, you can provide the base path to your service.
|
|
82
|
+
|
|
83
|
+
```typescript
|
|
84
|
+
import { ApplicationConfig } from '@angular/core';
|
|
85
|
+
import { provideHttpClient } from '@angular/common/http';
|
|
86
|
+
import { provideApi } from '@viewcandidate/client';
|
|
87
|
+
|
|
88
|
+
export const appConfig: ApplicationConfig = {
|
|
89
|
+
providers: [
|
|
90
|
+
// ...
|
|
91
|
+
provideHttpClient(),
|
|
92
|
+
provideApi('http://localhost:9999')
|
|
93
|
+
],
|
|
94
|
+
};
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
```typescript
|
|
98
|
+
// with a custom configuration
|
|
99
|
+
import { ApplicationConfig } from '@angular/core';
|
|
100
|
+
import { provideHttpClient } from '@angular/common/http';
|
|
101
|
+
import { provideApi } from '@viewcandidate/client';
|
|
102
|
+
|
|
103
|
+
export const appConfig: ApplicationConfig = {
|
|
104
|
+
providers: [
|
|
105
|
+
// ...
|
|
106
|
+
provideHttpClient(),
|
|
107
|
+
provideApi({
|
|
108
|
+
withCredentials: true,
|
|
109
|
+
username: 'user',
|
|
110
|
+
password: 'password'
|
|
111
|
+
})
|
|
112
|
+
],
|
|
113
|
+
};
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
```typescript
|
|
117
|
+
// with factory building a custom configuration
|
|
118
|
+
import { ApplicationConfig } from '@angular/core';
|
|
119
|
+
import { provideHttpClient } from '@angular/common/http';
|
|
120
|
+
import { provideApi, Configuration } from '@viewcandidate/client';
|
|
121
|
+
|
|
122
|
+
export const appConfig: ApplicationConfig = {
|
|
123
|
+
providers: [
|
|
124
|
+
// ...
|
|
125
|
+
provideHttpClient(),
|
|
126
|
+
{
|
|
127
|
+
provide: Configuration,
|
|
128
|
+
useFactory: (authService: AuthService) => new Configuration({
|
|
129
|
+
basePath: 'http://localhost:9999',
|
|
130
|
+
withCredentials: true,
|
|
131
|
+
username: authService.getUsername(),
|
|
132
|
+
password: authService.getPassword(),
|
|
133
|
+
}),
|
|
134
|
+
deps: [AuthService],
|
|
135
|
+
multi: false
|
|
136
|
+
}
|
|
137
|
+
],
|
|
138
|
+
};
|
|
139
|
+
```
|
|
140
|
+
|
|
141
|
+
### Using multiple OpenAPI files / APIs
|
|
142
|
+
|
|
143
|
+
In order to use multiple APIs generated from different OpenAPI files,
|
|
144
|
+
you can create an alias name when importing the modules
|
|
145
|
+
in order to avoid naming conflicts:
|
|
146
|
+
|
|
147
|
+
```typescript
|
|
148
|
+
import { provideApi as provideUserApi } from 'my-user-api-path';
|
|
149
|
+
import { provideApi as provideAdminApi } from 'my-admin-api-path';
|
|
150
|
+
import { HttpClientModule } from '@angular/common/http';
|
|
151
|
+
import { environment } from '../environments/environment';
|
|
152
|
+
|
|
153
|
+
export const appConfig: ApplicationConfig = {
|
|
154
|
+
providers: [
|
|
155
|
+
// ...
|
|
156
|
+
provideHttpClient(),
|
|
157
|
+
provideUserApi(environment.basePath),
|
|
158
|
+
provideAdminApi(environment.basePath),
|
|
159
|
+
],
|
|
160
|
+
};
|
|
161
|
+
```
|
|
162
|
+
|
|
163
|
+
### Customizing path parameter encoding
|
|
164
|
+
|
|
165
|
+
Without further customization, only [path-parameters][parameter-locations-url] of [style][style-values-url] 'simple'
|
|
166
|
+
and Dates for format 'date-time' are encoded correctly.
|
|
167
|
+
|
|
168
|
+
Other styles (e.g. "matrix") are not that easy to encode
|
|
169
|
+
and thus are best delegated to other libraries (e.g.: [@honoluluhenk/http-param-expander]).
|
|
170
|
+
|
|
171
|
+
To implement your own parameter encoding (or call another library),
|
|
172
|
+
pass an arrow-function or method-reference to the `encodeParam` property of the Configuration-object
|
|
173
|
+
(see [General Usage](#general-usage) above).
|
|
174
|
+
|
|
175
|
+
Example value for use in your Configuration-Provider:
|
|
176
|
+
|
|
177
|
+
```typescript
|
|
178
|
+
new Configuration({
|
|
179
|
+
encodeParam: (param: Param) => myFancyParamEncoder(param),
|
|
180
|
+
})
|
|
181
|
+
```
|
|
182
|
+
|
|
183
|
+
[parameter-locations-url]: https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.1.0.md#parameter-locations
|
|
184
|
+
[style-values-url]: https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.1.0.md#style-values
|
|
185
|
+
[@honoluluhenk/http-param-expander]: https://www.npmjs.com/package/@honoluluhenk/http-param-expander
|