kuzzleio / sdk-javascript

Kuzzle Javascript SDK. High level library including multi-protocol support, offline resiliency, realtime data and more
http://docs.kuzzle.io/sdk/js/7
Apache License 2.0
39 stars 15 forks source link

Add query typing #707

Closed Aschen closed 2 years ago

Aschen commented 2 years ago

What does this PR do ?

Implements https://github.com/kuzzleio/sdk-javascript/issues/706

A new BaseRequest interface can be extended to define the request type.

export interface NotificationSmsRequest extends BaseRequest {
  controller: 'notification',
  action: 'sms',
  engineId: string;
  body: {
    smsContent: string;
  }
};

interface NotificationSmsResult {
    smsCount: number;
}

const { result } = await sdk.query<NotificationSmsRequest, NotificationSmsResult>({
  controller: 'notification',
  action: 'sms',
  engineId: 'tenant-worksite-kuzzle',
  body: {
    smsContent: 'Hello, world',
  }
});

result.smsCount; // number
codecov[bot] commented 2 years ago

Codecov Report

Merging #707 (9be8c7e) into 7-dev (d73f171) will increase coverage by 0.08%. The diff coverage is 100.00%.

@@            Coverage Diff             @@
##            7-dev     #707      +/-   ##
==========================================
+ Coverage   83.47%   83.56%   +0.08%     
==========================================
  Files          45       45              
  Lines        2100     2099       -1     
  Branches      370      370              
==========================================
+ Hits         1753     1754       +1     
+ Misses        269      268       -1     
+ Partials       78       77       -1     
Impacted Files Coverage Δ
src/core/searchResult/SearchResultBase.ts 78.94% <ø> (+1.36%) :arrow_up:
src/Kuzzle.ts 86.20% <100.00%> (ø)
src/controllers/Base.ts 100.00% <100.00%> (+12.50%) :arrow_up:

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.