@hello.nrfcloud.com/nrfcloud-api-helpers 4.0.2 → 4.1.0
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/createFOTAJob.d.ts +17 -0
- package/dist/api/createFOTAJob.js +29 -0
- package/dist/api/fetchFOTAJob.d.ts +27 -0
- package/dist/api/fetchFOTAJob.js +45 -0
- package/dist/api/index.d.ts +2 -0
- package/dist/api/index.js +2 -0
- package/package.json +3 -3
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { type Static } from '@sinclair/typebox';
|
|
2
|
+
import type { ValidationError } from 'ajv';
|
|
3
|
+
declare const FOTAJobType: import("@sinclair/typebox").TObject<{
|
|
4
|
+
jobId: import("@sinclair/typebox").TString;
|
|
5
|
+
}>;
|
|
6
|
+
export declare const createFOTAJob: ({ apiKey, endpoint, }: {
|
|
7
|
+
apiKey: string;
|
|
8
|
+
endpoint: URL;
|
|
9
|
+
}, fetchImplementation?: typeof fetch) => ({ deviceId, bundleId, }: {
|
|
10
|
+
deviceId: string;
|
|
11
|
+
bundleId: string;
|
|
12
|
+
}) => Promise<{
|
|
13
|
+
error: Error | ValidationError;
|
|
14
|
+
} | {
|
|
15
|
+
result: Static<typeof FOTAJobType>;
|
|
16
|
+
}>;
|
|
17
|
+
export {};
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { Type } from '@sinclair/typebox';
|
|
2
|
+
import { JSONPayload, validatedFetch } from './validatedFetch.js';
|
|
3
|
+
const FOTAJobType = Type.Object({
|
|
4
|
+
jobId: Type.String({
|
|
5
|
+
minLength: 1,
|
|
6
|
+
title: 'ID',
|
|
7
|
+
description: 'Universally unique identifier',
|
|
8
|
+
examples: ['bc631093-7f7c-4c1b-aa63-a68c759bcd5c'],
|
|
9
|
+
}),
|
|
10
|
+
}, {
|
|
11
|
+
title: 'FOTA Job',
|
|
12
|
+
description: 'See https://api.nrfcloud.com/#tag/FOTA-Jobs/operation/CreateFOTAJob',
|
|
13
|
+
});
|
|
14
|
+
export const createFOTAJob = ({ apiKey, endpoint, }, fetchImplementation) => async ({ deviceId, bundleId, }) => {
|
|
15
|
+
const maybeJob = await validatedFetch({
|
|
16
|
+
endpoint,
|
|
17
|
+
apiKey,
|
|
18
|
+
}, fetchImplementation)({
|
|
19
|
+
resource: 'fota-jobs',
|
|
20
|
+
payload: JSONPayload({
|
|
21
|
+
bundleId,
|
|
22
|
+
autoApply: 'true',
|
|
23
|
+
deviceIds: [deviceId],
|
|
24
|
+
}),
|
|
25
|
+
}, FOTAJobType);
|
|
26
|
+
if ('error' in maybeJob)
|
|
27
|
+
return maybeJob;
|
|
28
|
+
return maybeJob;
|
|
29
|
+
};
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { type Static } from '@sinclair/typebox';
|
|
2
|
+
import type { ValidationError } from 'ajv';
|
|
3
|
+
export declare enum FOTAJobStatus {
|
|
4
|
+
CREATED = "CREATED",
|
|
5
|
+
IN_PROGRESS = "IN_PROGRESS",
|
|
6
|
+
CANCELLED = "CANCELLED",
|
|
7
|
+
DELETION_IN_PROGRESS = "DELETION_IN_PROGRESS",
|
|
8
|
+
COMPLETED = "COMPLETED"
|
|
9
|
+
}
|
|
10
|
+
export declare const FOTAJobType: import("@sinclair/typebox").TObject<{
|
|
11
|
+
jobId: import("@sinclair/typebox").TString;
|
|
12
|
+
status: import("@sinclair/typebox").TEnum<typeof FOTAJobStatus>;
|
|
13
|
+
statusDetail: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
|
|
14
|
+
createdAt: import("@sinclair/typebox").TString;
|
|
15
|
+
lastUpdatedAt: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
|
|
16
|
+
completedAt: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
|
|
17
|
+
}>;
|
|
18
|
+
export declare const fetchFOTAJob: ({ apiKey, endpoint, }: {
|
|
19
|
+
apiKey: string;
|
|
20
|
+
endpoint: URL;
|
|
21
|
+
}, fetchImplementation?: typeof fetch) => ({ jobId, }: {
|
|
22
|
+
jobId: string;
|
|
23
|
+
}) => Promise<{
|
|
24
|
+
error: Error | ValidationError;
|
|
25
|
+
} | {
|
|
26
|
+
result: Static<typeof FOTAJobType>;
|
|
27
|
+
}>;
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { Type } from '@sinclair/typebox';
|
|
2
|
+
import { validatedFetch } from './validatedFetch.js';
|
|
3
|
+
export var FOTAJobStatus;
|
|
4
|
+
(function (FOTAJobStatus) {
|
|
5
|
+
FOTAJobStatus["CREATED"] = "CREATED";
|
|
6
|
+
FOTAJobStatus["IN_PROGRESS"] = "IN_PROGRESS";
|
|
7
|
+
FOTAJobStatus["CANCELLED"] = "CANCELLED";
|
|
8
|
+
FOTAJobStatus["DELETION_IN_PROGRESS"] = "DELETION_IN_PROGRESS";
|
|
9
|
+
FOTAJobStatus["COMPLETED"] = "COMPLETED";
|
|
10
|
+
})(FOTAJobStatus || (FOTAJobStatus = {}));
|
|
11
|
+
const ts = Type.String({
|
|
12
|
+
title: 'Timestamp',
|
|
13
|
+
description: 'ISO-8601 date-time string',
|
|
14
|
+
examples: ['2019-08-24T14:15:22Z'],
|
|
15
|
+
});
|
|
16
|
+
export const FOTAJobType = Type.Object({
|
|
17
|
+
jobId: Type.String({
|
|
18
|
+
minLength: 1,
|
|
19
|
+
title: 'ID',
|
|
20
|
+
description: 'Universally unique identifier',
|
|
21
|
+
examples: ['bc631093-7f7c-4c1b-aa63-a68c759bcd5c'],
|
|
22
|
+
}),
|
|
23
|
+
status: Type.Enum(FOTAJobStatus, {
|
|
24
|
+
title: 'Status',
|
|
25
|
+
description: 'Current status of the job',
|
|
26
|
+
}),
|
|
27
|
+
statusDetail: Type.Optional(Type.String({ minLength: 1 })),
|
|
28
|
+
createdAt: ts,
|
|
29
|
+
lastUpdatedAt: Type.Optional(ts),
|
|
30
|
+
completedAt: Type.Optional(ts),
|
|
31
|
+
}, {
|
|
32
|
+
title: 'FOTA Job',
|
|
33
|
+
description: 'See https://api.nrfcloud.com/#tag/FOTA-Jobs/operation/FetchFOTAJob',
|
|
34
|
+
});
|
|
35
|
+
export const fetchFOTAJob = ({ apiKey, endpoint, }, fetchImplementation) => async ({ jobId, }) => {
|
|
36
|
+
const maybeJob = await validatedFetch({
|
|
37
|
+
endpoint,
|
|
38
|
+
apiKey,
|
|
39
|
+
}, fetchImplementation)({
|
|
40
|
+
resource: `fota-jobs/${jobId}`,
|
|
41
|
+
}, FOTAJobType);
|
|
42
|
+
if ('error' in maybeJob)
|
|
43
|
+
return maybeJob;
|
|
44
|
+
return maybeJob;
|
|
45
|
+
};
|
package/dist/api/index.d.ts
CHANGED
package/dist/api/index.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hello.nrfcloud.com/nrfcloud-api-helpers",
|
|
3
|
-
"version": "4.0
|
|
3
|
+
"version": "4.1.0",
|
|
4
4
|
"description": "Helper functions for integrating nRF Cloud APIs in AWS lambdas written in TypeScript.",
|
|
5
5
|
"exports": {
|
|
6
6
|
"./*": {
|
|
@@ -36,7 +36,7 @@
|
|
|
36
36
|
"@bifravst/prettier-config": "1.0.1",
|
|
37
37
|
"@commitlint/config-conventional": "19.2.2",
|
|
38
38
|
"@types/aws-lambda": "8.10.138",
|
|
39
|
-
"@types/node": "20.14.
|
|
39
|
+
"@types/node": "20.14.2",
|
|
40
40
|
"husky": "9.0.11",
|
|
41
41
|
"tsmatchers": "5.0.2",
|
|
42
42
|
"tsx": "4.11.2"
|
|
@@ -86,7 +86,7 @@
|
|
|
86
86
|
"@aws-sdk/client-ssm": "^3.590.0",
|
|
87
87
|
"@aws-sdk/util-dynamodb": "^3.590.0",
|
|
88
88
|
"@bifravst/aws-ssm-settings-helpers": "^1.1.27",
|
|
89
|
-
"@hello.nrfcloud.com/proto": "^13.0.
|
|
89
|
+
"@hello.nrfcloud.com/proto": "^13.0.9",
|
|
90
90
|
"@sinclair/typebox": "^0.32.31"
|
|
91
91
|
}
|
|
92
92
|
}
|