Skip to content

Commit

Permalink
fix: import type from @yandex-cloud/nodejs-sdk
Browse files Browse the repository at this point in the history
  • Loading branch information
zeruk committed Mar 7, 2023
1 parent 11273aa commit 331074b
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
3 changes: 2 additions & 1 deletion examples/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
"url-shortener": "node build/url-shortener/index.js"
},
"dependencies": {
"@yandex-cloud/nodejs-sdk": "^2.4.1",
"pino": "^8.11.0",
"winston": "^3.8.2",
"yargs": "^16.1.0",
Expand All @@ -33,4 +34,4 @@
"express": "^4.17.1",
"typescript": "^4.6.4"
}
}
}
5 changes: 2 additions & 3 deletions src/credentials.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import {ISslCredentials, makeDefaultSslCredentials} from './ssl-credentials';
import IamTokenService = yandex.cloud.iam.v1.IamTokenService;
import AuthServiceResult = Ydb.Auth.LoginResult;
import ICreateIamTokenResponse = yandex.cloud.iam.v1.ICreateIamTokenResponse;
import type {MetadataTokenService} from '@yandex-cloud/nodejs-sdk/dist/token-service/metadata-token-service';

function makeCredentialsMetadata(token: string): grpc.Metadata {
const metadata = new grpc.Metadata();
Expand Down Expand Up @@ -239,7 +240,7 @@ export class IamAuthService implements IAuthService {

export class MetadataAuthService implements IAuthService {
private tokenService?: ITokenService;
private MetadataTokenServiceClass?: typeof import('@yandex-cloud/nodejs-sdk/dist/token-service/metadata-token-service').MetadataTokenService;
private MetadataTokenServiceClass?: typeof MetadataTokenService;

/** Do not use this, use MetadataAuthService.create */
constructor(tokenService?: ITokenService) {
Expand All @@ -251,11 +252,9 @@ export class MetadataAuthService implements IAuthService {
*/
private async createMetadata(): Promise<void> {
if (!this.tokenService) {
console.log('importing `@yandex-cloud/nodejs-sdk`');
const {MetadataTokenService} = await import(
'@yandex-cloud/nodejs-sdk/dist/token-service/metadata-token-service'
);
console.log('\timported ...');
this.MetadataTokenServiceClass = MetadataTokenService;
this.tokenService = new MetadataTokenService();
}
Expand Down

0 comments on commit 331074b

Please sign in to comment.