odsl-javascript-sdk 1.0.0 → 1.0.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.
package/README.md CHANGED
@@ -1,2 +1,75 @@
1
1
  # odsl-javascript-sdk
2
- Javascript SDK for OpenDataDSL
2
+ The Javascript SDK for the [OpenDataDSL](https://opendatadsl.com) data management platform
3
+
4
+ ## Installation
5
+ You can install the ODSL Javascript SDK from [npm](https://www.npmjs.com/package/odsl-javascript-sdk):
6
+
7
+ npm i odsl-javascipt-sdk
8
+
9
+ ## About
10
+ This javascript SDK for OpenDataDSL has the following features:
11
+
12
+ * Find any data in OpenDataDSL using the ```list``` command
13
+ * Retrieve any data using the ```get``` command
14
+ * Update any data (if you have permission) using the ```update``` command
15
+
16
+ Check out our [demo repository](https://github.com/OpenDataDSL/odsl-javascript-sdk-demo) for examples of real-world usage.
17
+
18
+ ## Usage
19
+
20
+ ### Logging in and getting started
21
+
22
+ #### Logging in using a client credentials flow (client secret)
23
+ ```js
24
+ import ODSL from '../src/sdk.js'
25
+ import "dotenv/config";
26
+
27
+ var config = {
28
+ auth: {
29
+ clientId: process.env.clientId,
30
+ authority: process.env.authority,
31
+ clientSecret: process.env.clientSecret
32
+ }
33
+ };
34
+
35
+ ODSL.loginWithSecret(config).then(function(odsl) {
36
+ # Do Something
37
+ });
38
+ ```
39
+
40
+ ### Finding master data
41
+
42
+ ```js
43
+ objects = ODSL.list('object', 'public', 'source=ECB')
44
+ # objects is a JSON object wrapper containing status, statusText and body
45
+ print(objects.body[0])
46
+ ```
47
+
48
+ ### Getting master data
49
+
50
+ ```js
51
+ obj = ODSL.get('object', 'public', '#ECB')
52
+ print(obj.body['description'])
53
+ ```
54
+
55
+ ### Getting a timeseries
56
+ ```js
57
+ ts = ODSL.get('data', 'public', '#ABN_FX.EURUSD:SPOT')
58
+ print(ts.body)
59
+ ```
60
+
61
+ ### Updating some private master data
62
+ ```js
63
+ var = {
64
+ '_id': 'AAA.PYTHON',
65
+ 'name': 'Python Example'
66
+ }
67
+ ODSL.update('object', 'private', var)
68
+ ```
69
+
70
+ ### Reading and updating some private master data
71
+ ```js
72
+ po = ODSL.get('object', 'private', 'AAA.TEST')
73
+ po.body['description'] = 'Updated from Javascript'
74
+ ODSL.update('object', 'private', po.body)
75
+ ```
package/package.json CHANGED
@@ -1,11 +1,12 @@
1
1
  {
2
2
  "name": "odsl-javascript-sdk",
3
3
  "type": "module",
4
- "version": "1.0.0",
4
+ "version": "1.0.1",
5
5
  "description": "Javascript SDK for OpenDataDSL",
6
6
  "main": "src/sdk.js",
7
7
  "scripts": {
8
- "test": "mocha test/test.js"
8
+ "test": "mocha test/test.js",
9
+ "npm:publish": "npm publish"
9
10
  },
10
11
  "repository": {
11
12
  "type": "git",
@@ -1,15 +0,0 @@
1
- {
2
- // Use IntelliSense to learn about possible attributes.
3
- // Hover to view descriptions of existing attributes.
4
- // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
5
- "version": "0.2.0",
6
- "configurations": [
7
- {
8
- "type": "chrome",
9
- "request": "launch",
10
- "name": "Launch Chrome against localhost",
11
- "url": "http://localhost:8080",
12
- "webRoot": "${workspaceFolder}/test/web"
13
- }
14
- ]
15
- }
package/test/test.js DELETED
@@ -1,33 +0,0 @@
1
- 'use strict';
2
-
3
- import ODSL from '../src/sdk.js'
4
- import "dotenv/config";
5
-
6
- var config = {
7
- auth: {
8
- clientId: process.env.clientId,
9
- authority: process.env.authority,
10
- clientSecret: process.env.clientSecret
11
- }
12
- };
13
-
14
- console.log("Asynchronous GET");
15
- ODSL.loginWithSecret(config).then(function(odsl) {
16
- odsl.getAsync('object', 'private', 'AAA', function(r) {
17
- if (r.status == 200) {
18
- console.log(r.body);
19
- } else {
20
- console.log(r.status + ": " + r.statusText);
21
- }
22
- });
23
- });
24
-
25
- console.log("Synchronous GET");
26
- ODSL.loginWithSecret(config).then(function(odsl) {
27
- var r = odsl.get('object', 'private', 'AAA');
28
- if (r.status == 200) {
29
- console.log(r.body);
30
- } else {
31
- console.log(r.status + ": " + r.statusText);
32
- }
33
- });