@@ -11,7 +11,12 @@ import * as validator from './validators';
1111import getPromiseBasedAdapter from './storage-adapter' ;
1212import * as versionHandler from './version-handler' ;
1313import 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' ;
1520import { StorageAdapter } from 'oc-storage-adapters-utils' ;
1621
1722const packageInfo = fs . readJsonSync (
@@ -110,7 +115,10 @@ export default function repository(conf: Config) {
110115 } ;
111116
112117 const repository = {
113- getCompiledView ( componentName : string , componentVersion : string ) {
118+ getCompiledView (
119+ componentName : string ,
120+ componentVersion : string
121+ ) : Promise < string > {
114122 if ( conf . local ) {
115123 return Promise . resolve ( local . getCompiledView ( componentName ) ) ;
116124 }
@@ -119,7 +127,10 @@ export default function repository(conf: Config) {
119127 getFilePath ( componentName , componentVersion , 'template.js' )
120128 ) ;
121129 } ,
122- async getComponent ( componentName : string , componentVersion ?: string ) {
130+ async getComponent (
131+ componentName : string ,
132+ componentVersion ?: string
133+ ) : Promise < Component > {
123134 const allVersions = await repository . getComponentVersions ( componentName ) ;
124135
125136 if ( allVersions . length === 0 ) {
@@ -150,7 +161,10 @@ export default function repository(conf: Config) {
150161
151162 return Object . assign ( component , { allVersions } ) ;
152163 } ,
153- getComponentInfo ( componentName : string , componentVersion : string ) {
164+ getComponentInfo (
165+ componentName : string ,
166+ componentVersion : string
167+ ) : Promise < Component > {
154168 if ( conf . local ) {
155169 let componentInfo : Component ;
156170
@@ -180,29 +194,29 @@ export default function repository(conf: Config) {
180194 false
181195 ) ;
182196 } ,
183- getComponentPath ( componentName : string , componentVersion : string ) {
197+ getComponentPath ( componentName : string , componentVersion : string ) : string {
184198 const prefix = conf . local
185199 ? conf . baseUrl
186200 : `${ options ! [ 'path' ] } ${ options ! . componentsDir } /` ;
187201 return `${ prefix } ${ componentName } /${ componentVersion } /` ;
188202 } ,
189- async getComponents ( ) {
203+ async getComponents ( ) : Promise < string [ ] > {
190204 if ( conf . local ) {
191205 return local . getComponents ( ) ;
192206 }
193207
194208 const { components } = await componentsCache . get ( ) ;
195209 return Object . keys ( components ) ;
196210 } ,
197- getComponentsDetails ( ) {
211+ getComponentsDetails ( ) : Promise < ComponentsDetails > {
198212 if ( conf . local ) {
199213 // when in local this won't get called
200214 return Promise . resolve ( null ) as any ;
201215 }
202216
203217 return componentsDetails . get ( ) ;
204218 } ,
205- async getComponentVersions ( componentName : string ) {
219+ async getComponentVersions ( componentName : string ) : Promise < string [ ] > {
206220 if ( conf . local ) {
207221 return local . getComponentVersions ( componentName ) ;
208222 }
@@ -211,7 +225,13 @@ export default function repository(conf: Config) {
211225
212226 return res . components [ componentName ] ? res . components [ componentName ] : [ ] ;
213227 } ,
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+ } > {
215235 if ( conf . local ) {
216236 return local . getDataProvider ( componentName ) ;
217237 }
@@ -226,14 +246,14 @@ export default function repository(conf: Config) {
226246
227247 return { content, filePath } ;
228248 } ,
229- getStaticClientPath : ( ) =>
249+ getStaticClientPath : ( ) : string =>
230250 `${ options ! [ 'path' ] } ${ getFilePath (
231251 'oc-client' ,
232252 packageInfo . version ,
233253 'src/oc-client.min.js'
234254 ) } `,
235255
236- getStaticClientMapPath : ( ) =>
256+ getStaticClientMapPath : ( ) : string =>
237257 `${ options ! [ 'path' ] } ${ getFilePath (
238258 'oc-client' ,
239259 packageInfo . version ,
@@ -244,14 +264,14 @@ export default function repository(conf: Config) {
244264 componentName : string ,
245265 componentVersion : string ,
246266 filePath : string
247- ) =>
267+ ) : string =>
248268 `${ repository . getComponentPath ( componentName , componentVersion ) } ${
249269 conf . local ? settings . registry . localStaticRedirectorPath : ''
250270 } ${ filePath } `,
251271
252- getTemplatesInfo : ( ) => templatesInfo ,
272+ getTemplatesInfo : ( ) : TemplateInfo [ ] => templatesInfo ,
253273 getTemplate : ( type : string ) => templatesHash [ type ] ,
254- async init ( ) {
274+ async init ( ) : Promise < ComponentsDetails > {
255275 if ( conf . local ) {
256276 // when in local this won't get called
257277 return 'ok' as any ;
@@ -265,7 +285,7 @@ export default function repository(conf: Config) {
265285 pkgDetails : any ,
266286 componentName : string ,
267287 componentVersion : string
268- ) {
288+ ) : Promise < ComponentsDetails > {
269289 if ( conf . local ) {
270290 throw {
271291 code : strings . errors . registry . LOCAL_PUBLISH_NOT_ALLOWED_CODE ,
0 commit comments