@hello.nrfcloud.com/nrfcloud-api-helpers 1.1.0 → 1.1.1

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.
@@ -15,9 +15,9 @@ declare const DeviceShadows: import("@sinclair/typebox").TArray<import("@sinclai
15
15
  export declare const getDeviceShadow: ({ endpoint, apiKey, }: {
16
16
  endpoint: URL;
17
17
  apiKey: string;
18
- }, fetchImplementation?: typeof fetch) => (devices: string[]) => Promise<{
18
+ }, fetchImplementation?: typeof fetch) => ((devices: string[]) => Promise<{
19
19
  shadows: Static<typeof DeviceShadows>;
20
20
  } | {
21
21
  error: Error | ValidationError;
22
- }>;
22
+ }>);
23
23
  export {};
@@ -4,4 +4,9 @@ export declare const updateDeviceShadow: ({ endpoint, apiKey, }: {
4
4
  }, fetchImplementation?: typeof fetch) => (deviceId: string, state: {
5
5
  desired?: Record<string, any>;
6
6
  reported?: Record<string, any>;
7
- }) => Promise<void>;
7
+ }) => Promise<MaybeOK>;
8
+ export type MaybeOK = {
9
+ error: Error;
10
+ } | {
11
+ ok: true;
12
+ };
@@ -1,6 +1,6 @@
1
1
  import { slashless } from './slashless.js';
2
2
  export const updateDeviceShadow = ({ endpoint, apiKey, }, fetchImplementation) => async (deviceId, state) => {
3
- await (fetchImplementation ?? fetch)(new URL(`${slashless(endpoint)}/v1/devices/${encodeURIComponent(deviceId)}/state`), {
3
+ const res = await (fetchImplementation ?? fetch)(new URL(`${slashless(endpoint)}/v1/devices/${encodeURIComponent(deviceId)}/state`), {
4
4
  method: 'PATCH',
5
5
  headers: {
6
6
  'Content-Type': 'application/json',
@@ -8,4 +8,9 @@ export const updateDeviceShadow = ({ endpoint, apiKey, }, fetchImplementation) =
8
8
  },
9
9
  body: JSON.stringify(state),
10
10
  });
11
+ if (res.ok)
12
+ return { ok: true };
13
+ return {
14
+ error: new Error(`Update device status for ${deviceId} failed: ${res.status} (${await res.text()})`),
15
+ };
11
16
  };
@@ -26,7 +26,7 @@ export declare const putSettings: ({ ssm, stackName, account, }: {
26
26
  ssm: SSMClient;
27
27
  stackName: string;
28
28
  account: string;
29
- }) => (settings: Partial<Settings>) => Promise<void>;
29
+ }) => ((settings: Partial<Settings>) => Promise<void>);
30
30
  export declare const putSetting: ({ ssm, stackName, account, }: {
31
31
  ssm: SSMClient;
32
32
  stackName: string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hello.nrfcloud.com/nrfcloud-api-helpers",
3
- "version": "1.1.0",
3
+ "version": "1.1.1",
4
4
  "description": "Helper functions for integrating nRF Cloud APIs in AWS lambdas written in TypeScript.",
5
5
  "exports": {
6
6
  "./*": {
@@ -32,11 +32,11 @@
32
32
  "author": "Nordic Semiconductor ASA | nordicsemi.no",
33
33
  "license": "BSD-3-Clause",
34
34
  "devDependencies": {
35
- "@bifravst/eslint-config-typescript": "6.0.17",
35
+ "@bifravst/eslint-config-typescript": "6.0.21",
36
36
  "@bifravst/prettier-config": "1.0.0",
37
37
  "@commitlint/config-conventional": "19.1.0",
38
38
  "@types/aws-lambda": "8.10.137",
39
- "@types/node": "20.12.3",
39
+ "@types/node": "20.12.7",
40
40
  "husky": "9.0.11",
41
41
  "tsmatchers": "5.0.2",
42
42
  "tsx": "4.7.2"