@@ -11,7 +11,12 @@ import * as validator from './validators';
11
11
import getPromiseBasedAdapter from './storage-adapter' ;
12
12
import * as versionHandler from './version-handler' ;
13
13
import errorToString from '../../utils/error-to-string' ;
14
- import { Component , Config } from '../../types' ;
14
+ import {
15
+ Component ,
16
+ ComponentsDetails ,
17
+ Config ,
18
+ TemplateInfo
19
+ } from '../../types' ;
15
20
import { StorageAdapter } from 'oc-storage-adapters-utils' ;
16
21
17
22
const packageInfo = fs . readJsonSync (
@@ -110,7 +115,10 @@ export default function repository(conf: Config) {
110
115
} ;
111
116
112
117
const repository = {
113
- getCompiledView ( componentName : string , componentVersion : string ) {
118
+ getCompiledView (
119
+ componentName : string ,
120
+ componentVersion : string
121
+ ) : Promise < string > {
114
122
if ( conf . local ) {
115
123
return Promise . resolve ( local . getCompiledView ( componentName ) ) ;
116
124
}
@@ -119,7 +127,10 @@ export default function repository(conf: Config) {
119
127
getFilePath ( componentName , componentVersion , 'template.js' )
120
128
) ;
121
129
} ,
122
- async getComponent ( componentName : string , componentVersion ?: string ) {
130
+ async getComponent (
131
+ componentName : string ,
132
+ componentVersion ?: string
133
+ ) : Promise < Component > {
123
134
const allVersions = await repository . getComponentVersions ( componentName ) ;
124
135
125
136
if ( allVersions . length === 0 ) {
@@ -150,7 +161,10 @@ export default function repository(conf: Config) {
150
161
151
162
return Object . assign ( component , { allVersions } ) ;
152
163
} ,
153
- getComponentInfo ( componentName : string , componentVersion : string ) {
164
+ getComponentInfo (
165
+ componentName : string ,
166
+ componentVersion : string
167
+ ) : Promise < Component > {
154
168
if ( conf . local ) {
155
169
let componentInfo : Component ;
156
170
@@ -180,29 +194,29 @@ export default function repository(conf: Config) {
180
194
false
181
195
) ;
182
196
} ,
183
- getComponentPath ( componentName : string , componentVersion : string ) {
197
+ getComponentPath ( componentName : string , componentVersion : string ) : string {
184
198
const prefix = conf . local
185
199
? conf . baseUrl
186
200
: `${ options ! [ 'path' ] } ${ options ! . componentsDir } /` ;
187
201
return `${ prefix } ${ componentName } /${ componentVersion } /` ;
188
202
} ,
189
- async getComponents ( ) {
203
+ async getComponents ( ) : Promise < string [ ] > {
190
204
if ( conf . local ) {
191
205
return local . getComponents ( ) ;
192
206
}
193
207
194
208
const { components } = await componentsCache . get ( ) ;
195
209
return Object . keys ( components ) ;
196
210
} ,
197
- getComponentsDetails ( ) {
211
+ getComponentsDetails ( ) : Promise < ComponentsDetails > {
198
212
if ( conf . local ) {
199
213
// when in local this won't get called
200
214
return Promise . resolve ( null ) as any ;
201
215
}
202
216
203
217
return componentsDetails . get ( ) ;
204
218
} ,
205
- async getComponentVersions ( componentName : string ) {
219
+ async getComponentVersions ( componentName : string ) : Promise < string [ ] > {
206
220
if ( conf . local ) {
207
221
return local . getComponentVersions ( componentName ) ;
208
222
}
@@ -211,7 +225,13 @@ export default function repository(conf: Config) {
211
225
212
226
return res . components [ componentName ] ? res . components [ componentName ] : [ ] ;
213
227
} ,
214
- async getDataProvider ( componentName : string , componentVersion : string ) {
228
+ async getDataProvider (
229
+ componentName : string ,
230
+ componentVersion : string
231
+ ) : Promise < {
232
+ content : string ;
233
+ filePath : string ;
234
+ } > {
215
235
if ( conf . local ) {
216
236
return local . getDataProvider ( componentName ) ;
217
237
}
@@ -226,14 +246,14 @@ export default function repository(conf: Config) {
226
246
227
247
return { content, filePath } ;
228
248
} ,
229
- getStaticClientPath : ( ) =>
249
+ getStaticClientPath : ( ) : string =>
230
250
`${ options ! [ 'path' ] } ${ getFilePath (
231
251
'oc-client' ,
232
252
packageInfo . version ,
233
253
'src/oc-client.min.js'
234
254
) } `,
235
255
236
- getStaticClientMapPath : ( ) =>
256
+ getStaticClientMapPath : ( ) : string =>
237
257
`${ options ! [ 'path' ] } ${ getFilePath (
238
258
'oc-client' ,
239
259
packageInfo . version ,
@@ -244,14 +264,14 @@ export default function repository(conf: Config) {
244
264
componentName : string ,
245
265
componentVersion : string ,
246
266
filePath : string
247
- ) =>
267
+ ) : string =>
248
268
`${ repository . getComponentPath ( componentName , componentVersion ) } ${
249
269
conf . local ? settings . registry . localStaticRedirectorPath : ''
250
270
} ${ filePath } `,
251
271
252
- getTemplatesInfo : ( ) => templatesInfo ,
272
+ getTemplatesInfo : ( ) : TemplateInfo [ ] => templatesInfo ,
253
273
getTemplate : ( type : string ) => templatesHash [ type ] ,
254
- async init ( ) {
274
+ async init ( ) : Promise < ComponentsDetails > {
255
275
if ( conf . local ) {
256
276
// when in local this won't get called
257
277
return 'ok' as any ;
@@ -265,7 +285,7 @@ export default function repository(conf: Config) {
265
285
pkgDetails : any ,
266
286
componentName : string ,
267
287
componentVersion : string
268
- ) {
288
+ ) : Promise < ComponentsDetails > {
269
289
if ( conf . local ) {
270
290
throw {
271
291
code : strings . errors . registry . LOCAL_PUBLISH_NOT_ALLOWED_CODE ,
0 commit comments