fostrom 0.0.17 → 0.0.18

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.
Files changed (3) hide show
  1. package/README.md +1 -67
  2. package/dl-agent.sh +1 -1
  3. package/package.json +2 -2
package/README.md CHANGED
@@ -4,70 +4,4 @@
4
4
 
5
5
  The Fostrom Device SDK for JavaScript works in Node.js and Bun, on Linux and macOS, and helps you quickly integrate, start monitoring, and controlling your IoT devices in just a few lines of code.
6
6
 
7
- ## Example
8
-
9
- ```js
10
- import Fostrom from 'fostrom';
11
-
12
- const fostrom = new Fostrom({
13
- fleet_id: "<fleet-id>",
14
- device_id: "<device-id>",
15
- device_secret: "<device-secret>",
16
- })
17
-
18
- // Setup the on_mail handler, to process incoming mail.
19
- fostrom.onMail = async (mail) => {
20
- const {id, name, payload, mailbox_size} = mail
21
- console.debug(`Received Mail (${mailbox_size}): ${name} ${id}`)
22
-
23
- // You need to call `mail.ack()` to acknowledge the mail.
24
- // Other options are: `mail.reject()` and `mail.requeue()`
25
- // Note that if your function throws an error, the SDK will auto-reject the mail.
26
- await mail.ack()
27
- }
28
-
29
- async function main() {
30
- await fostrom.start()
31
-
32
- // Send a message to Fostrom (payload can be null if schema has no payload)
33
- await fostrom.sendMsg("<packet-schema-name>", { /* ...payload */ })
34
-
35
- // Send a datapoint to Fostrom
36
- await fostrom.sendDatapoint("<packet-schema-name>", { /* ...payload */ })
37
- }
38
-
39
- main()
40
- ```
41
-
42
- > Requires Node.js 22.12+ or Bun 1.2+
43
-
44
- You can load the SDK via either syntax:
45
-
46
- ```js
47
- import Fostrom from 'fostrom'
48
- ```
49
-
50
- ```js
51
- const { default: Fostrom } = require('fostrom')
52
- ```
53
-
54
- ## A Note on BigInts
55
-
56
- Fostrom's Packet Schemas support defining `u64` and `i64` integers. However, JavaScript's `Number` type is limited to `2^53 - 1`. To rectify this issue, we use the `bigint` type and handle JSON encoding and decoding automatically.
57
-
58
- Note that there's a caveat here. When Fostrom delivers a message to the SDK containing a `u64` or `i64` number, it will convert to the `Number` type if it is smaller than `2^53 - 1`, and convert to `bigint` if it is larger. This is because the SDK does not know if the field is a `u64` or `i64` type when converting. So for those fields you will need to check whether the type is `bigint` or not.
59
-
60
- ## A Note on the Device Agent
61
-
62
- The Fostrom Device SDK downloads and runs the Fostrom Device Agent in the background. The Agent is downloaded when the package is installed through `npm`. The Device Agent starts when `fostrom.start()` is called and handles communication with the Fostrom platform.
63
-
64
- By default, the agent remains running in the background for fast reconnections. The SDK also installs a process exit handler; `fostrom.shutdown()` is called automatically on process exit, and if `stopAgentOnExit` is set to true in the config, the agent is stopped as well.
65
-
66
- ## Logging
67
-
68
- By default, the SDK logs connection and handler messages to the console. Set
69
- `log: false` in the constructor config to silence SDK logs. Levels used:
70
-
71
- - `console.info` for successful connection events
72
- - `console.warn` for reconnection attempts
73
- - `console.error` for unauthorized/critical errors
7
+ [Visit our JavaScript SDK Docs to get started.](https://fostrom.io/docs/sdk/js)
package/dl-agent.sh CHANGED
@@ -4,7 +4,7 @@
4
4
  #
5
5
  # Usage: ./dl-agent.sh <directory>
6
6
 
7
- VERSION="v0.0.15"
7
+ VERSION="v0.0.16"
8
8
 
9
9
  # CDN URLs in order of preference
10
10
  CDN_PRIMARY="https://cdn.fostrom.dev/fostrom-device-agent/$VERSION"
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "fostrom",
3
- "version": "0.0.17",
3
+ "version": "0.0.18",
4
4
  "description": "Fostrom's Official Device SDK for JS. Fostrom (https://fostrom.io) is an IoT Cloud Platform.",
5
5
  "keywords": [
6
6
  "fostrom",
@@ -17,7 +17,7 @@
17
17
  "hardware",
18
18
  "raspberry"
19
19
  ],
20
- "homepage": "https://docs.fostrom.io/sdk/js",
20
+ "homepage": "https://fostrom.io/docs/sdk/js",
21
21
  "license": "Apache-2.0",
22
22
  "author": "Fostrom <support@fostrom.io> (https://fostrom.io)",
23
23
  "files": [