@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.
package/dist/api/groundFix.d.ts
CHANGED
|
@@ -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: (
|
|
8
|
-
apiEndpoint: URL;
|
|
8
|
+
export declare const serviceToken: ({ apiKey, endpoint, }: {
|
|
9
9
|
apiKey: string;
|
|
10
|
-
|
|
10
|
+
endpoint: URL;
|
|
11
|
+
}, fetchImplementation?: typeof fetch) => (() => Promise<{
|
|
12
|
+
error: Error | ValidationError;
|
|
13
|
+
} | {
|
|
14
|
+
token: string;
|
|
15
|
+
}>);
|
package/dist/api/serviceToken.js
CHANGED
|
@@ -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 = (
|
|
10
|
-
const vf = validatedFetch({ endpoint
|
|
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
|
-
|
|
14
|
-
throw maybeResult.error;
|
|
13
|
+
return maybeResult;
|
|
15
14
|
}
|
|
16
|
-
return maybeResult.result
|
|
15
|
+
return maybeResult.result;
|
|
17
16
|
};
|