@hello.nrfcloud.com/nrfcloud-api-helpers 1.3.1 → 1.3.3

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.
@@ -13,7 +13,7 @@ export declare const groundFix: ({ apiKey, endpoint, }: {
13
13
  apiKey: string;
14
14
  endpoint: URL;
15
15
  }, fetchImplementation?: typeof fetch) => (cell: {
16
- mcc: string;
16
+ mcc: number;
17
17
  mnc: string;
18
18
  eci: number;
19
19
  tac: number;
@@ -1,10 +1,15 @@
1
+ import { ValidationError } from './validatedFetch.js';
1
2
  /**
2
3
  * @link https://api.nrfcloud.com/v1/#tag/Account/operation/GetServiceToken
3
4
  */
4
5
  export declare const ServiceToken: import("@sinclair/typebox").TObject<{
5
6
  token: import("@sinclair/typebox").TString;
6
7
  }>;
7
- export declare const serviceToken: (fetchImplementation?: typeof fetch, onError?: (error: Error) => void) => ((args: {
8
- apiEndpoint: URL;
8
+ export declare const serviceToken: ({ apiKey, endpoint, }: {
9
9
  apiKey: string;
10
- }) => Promise<string>);
10
+ endpoint: URL;
11
+ }, fetchImplementation?: typeof fetch) => (() => Promise<{
12
+ error: Error | ValidationError;
13
+ } | {
14
+ token: string;
15
+ }>);
@@ -1,17 +1,16 @@
1
1
  import { Type } from '@sinclair/typebox';
2
- import { validatedFetch } from './validatedFetch.js';
2
+ import { ValidationError, validatedFetch } from './validatedFetch.js';
3
3
  /**
4
4
  * @link https://api.nrfcloud.com/v1/#tag/Account/operation/GetServiceToken
5
5
  */
6
6
  export const ServiceToken = Type.Object({
7
7
  token: Type.String(),
8
8
  });
9
- export const serviceToken = (fetchImplementation, onError) => async ({ apiEndpoint, apiKey }) => {
10
- const vf = validatedFetch({ endpoint: apiEndpoint, apiKey }, fetchImplementation);
9
+ export const serviceToken = ({ apiKey, endpoint, }, fetchImplementation) => async () => {
10
+ const vf = validatedFetch({ endpoint, apiKey }, fetchImplementation);
11
11
  const maybeResult = await vf({ resource: 'account/service-token' }, ServiceToken);
12
12
  if ('error' in maybeResult) {
13
- onError?.(maybeResult.error);
14
- throw maybeResult.error;
13
+ return maybeResult;
15
14
  }
16
- return maybeResult.result.token;
15
+ return maybeResult.result;
17
16
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hello.nrfcloud.com/nrfcloud-api-helpers",
3
- "version": "1.3.1",
3
+ "version": "1.3.3",
4
4
  "description": "Helper functions for integrating nRF Cloud APIs in AWS lambdas written in TypeScript.",
5
5
  "exports": {
6
6
  "./*": {