Skip to content

Commit f6aa706

Browse files
committed
NPM setup
1 parent bce99c9 commit f6aa706

4 files changed

Lines changed: 136 additions & 40 deletions

File tree

GITHUB-GUIDE.md

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
# CDPLogger Client for JavaScript
2+
3+
A simple JavaScript interface for communicating with CDP applications that include a CDPLogger component to retrieve historic data.
4+
- For documentation on the JS logger client see [DOCUMENTATION.md](DOCUMENTATION.md).
5+
- For a quickstart guide on how to set-up the npm project for either Node or Web see [QUICKSTART.md](QUICKSTART.md)
6+
- For more information about CDP Studio see https://cdpstudio.com/.
7+
8+
## Installation
9+
10+
Clone the repository and install dependencies:
11+
12+
```bash
13+
npm install
14+
```
15+
16+
17+
## Running Tests
18+
19+
To run the automatic tests with fake data, execute:
20+
21+
```bash
22+
npm test
23+
```
24+
25+
Note: these jest tests execute on every push and pull of the repo as well.
26+
27+
To test the time sync functionality using simulated response:
28+
29+
```bash
30+
node test/testTimeSync.js
31+
```
32+
33+
34+
## Usage
35+
36+
The value.js file contains a simple logger built for the CDP Studio example case.
37+
38+
1. Set up and run the Logger in CDP Studio.
39+
(Refer to Help → Framework - Data Logging → How to Setup Logging in Automation System)
40+
https://cdpstudio.com/manual/cdp/cdplogger/cdplogger-configuration-example.html
41+
42+
2. Run the value.js file from the command line:
43+
44+
```bash
45+
node examples/value.js
46+
```
47+
48+
For usage related to events run:
49+
50+
```bash
51+
node examples/event.js
52+
```
53+
54+
55+
## Contact
56+
57+
Email: support@cdptech.com

README.md

Lines changed: 36 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,57 +1,57 @@
1-
# CDPLogger Client for JavaScript
1+
# CDP Logger Client
22

3-
A simple JavaScript interface for communicating with CDP applications that include a CDPLogger component to retrieve historic data.
4-
- For documentation on the JS logger client see [DOCUMENTATION.md](DOCUMENTATION.md).
5-
- For a quickstart guide on how to set-up the npm project for either Node or Web see [QUICKSTART.md](QUICKSTART.md)
6-
- For more information about CDP Studio see https://cdpstudio.com/.
3+
A JavaScript client for interacting with CDP Logger or LogServer via WebSocket. This client allows you to:
4+
- Connect to a CDP Logger or LogServer
5+
- Request logged nodes and their metadata
6+
- Retrieve data points for specific nodes
7+
- Query events from the logger
8+
- Get log limits and API version information
79

810
## Installation
911

10-
Clone the repository and install dependencies:
11-
1212
```bash
13-
npm install
13+
npm install cdp-logger-client
1414
```
1515

16+
## Quick Start
1617

17-
## Running Tests
18-
19-
To run the automatic tests with fake data, execute:
18+
For a quick introduction, see the [QUICKSTART.md](QUICKSTART.md) guide.
2019

21-
```bash
22-
npm test
23-
```
24-
25-
Note: these jest tests execute on every push and pull of the repo as well.
26-
27-
To test the time sync functionality using simulated response:
28-
29-
```bash
30-
node test/testTimeSync.js
31-
```
20+
## Documentation
3221

22+
For detailed documentation, see [DOCUMENTATION.md](DOCUMENTATION.md).
3323

3424
## Usage
3525

36-
The value.js file contains a simple logger built for the CDP Studio example case.
26+
### Node.js
3727

38-
1. Set up and run the Logger in CDP Studio.
39-
(Refer to Help → Framework - Data Logging → How to Setup Logging in Automation System)
40-
https://cdpstudio.com/manual/cdp/cdplogger/cdplogger-configuration-example.html
28+
```javascript
29+
const cdplogger = require('cdp-logger-client');
30+
global.WebSocket = require('ws');
4131

42-
2. Run the value.js file from the command line:
32+
const client = new cdplogger.Client('127.0.0.1:17000');
4333

44-
```bash
45-
node examples/value.js
34+
// List logged nodes
35+
client.requestLoggedNodes().then(nodes => {
36+
console.log("Available nodes:", nodes);
37+
});
4638
```
4739

48-
For usage related to events run:
49-
50-
```bash
51-
node examples/event.js
40+
### Browser
41+
42+
```html
43+
<script src="protobuf.min.js"></script>
44+
<script src="containerPb.js"></script>
45+
<script src="client.js"></script>
46+
<script>
47+
const client = new cdplogger.Client(window.location.hostname + ":17000");
48+
49+
client.requestLoggedNodes().then(nodes => {
50+
console.log("Available nodes:", nodes);
51+
});
52+
</script>
5253
```
5354

55+
## License
5456

55-
## Contact
56-
57-
Email: support@cdptech.com
57+
MIT

client.js

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1117,7 +1117,15 @@ class Client {
11171117
}
11181118
}
11191119

1120+
// Export the module
11201121
const cdplogger = {};
11211122
cdplogger.Client = Client;
11221123

1123-
module.exports = cdplogger;
1124+
// For Node.js
1125+
if (typeof module !== 'undefined' && module.exports) {
1126+
module.exports = cdplogger;
1127+
}
1128+
// For Browser
1129+
else if (typeof window !== 'undefined') {
1130+
window.cdplogger = cdplogger;
1131+
}

package.json

Lines changed: 34 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,43 @@
11
{
2-
"devDependencies": {
3-
"jest": "^29.7.0",
4-
"ws": "^8.18.1"
2+
"name": "cdp-logger-client",
3+
"version": "1.0.0",
4+
"description": "A JavaScript client for interacting with CDP Logger or LogServer via WebSocket",
5+
"main": "client.js",
6+
"files": [
7+
"client.js",
8+
"generated/containerPb.js",
9+
"README.md",
10+
"QUICKSTART.md",
11+
"DOCUMENTATION.md",
12+
"LICENSE"
13+
],
14+
"repository": {
15+
"type": "git",
16+
"url": "https://github.com/CDPTechnologies/JavascriptCDPLoggerClient.git"
517
},
618
"scripts": {
719
"test": "jest"
820
},
21+
"keywords": [
22+
"cdp",
23+
"cdp-studio",
24+
"cdplogger",
25+
"cdp-logger",
26+
"cdp-logger-client",
27+
"cdploggerclient",
28+
"cdpjsclientlogger",
29+
"cdp-js-client-logger",
30+
"cdp-studio-logger",
31+
"logger",
32+
"logger-client"
33+
],
34+
"author": "",
35+
"license": "MIT",
936
"dependencies": {
1037
"protobufjs": "^7.4.0"
38+
},
39+
"devDependencies": {
40+
"ws": "^8.13.0",
41+
"jest": "^29.5.0"
1142
}
1243
}

0 commit comments

Comments
 (0)