roboto-js 1.1.10 → 1.1.12

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/index.ems.js ADDED
@@ -0,0 +1,123 @@
1
+ import RbtApi from './rbt_api.js';
2
+ import RbtObject from './rbt_object.js';
3
+ import RbtFile from './rbt_file.js';
4
+ export { RbtApi, RbtObject, RbtFile
5
+ //User,
6
+ //Site
7
+ };
8
+ export default class Roboto {
9
+ constructor(proxyReq = null) {
10
+ debugger;
11
+ if (Roboto.instance && !proxyReq) {
12
+ // if on client, there can only be one instance
13
+ // on server, with proxyReq, each request has its own instance
14
+ return Roboto.instance;
15
+ }
16
+ const isBrowser = typeof window !== "undefined";
17
+ this.config = {
18
+ apiKey: isBrowser ? process.env.NEXT_PUBLIC_ROBOTO_API_KEY : process.env.ROBOTO_API_KEY,
19
+ baseUrl: 'https://' + (isBrowser ? process.env.NEXT_PUBLIC_ROBOTO_HOST : process.env.ROBOTO_HOST)
20
+ };
21
+
22
+ // DEVELOPMENT
23
+ if (this.config.baseUrl.indexOf('rbt.dorfio') !== -1) {
24
+ this.config.baseUrl = 'http://rbt.dorfio.com';
25
+ }
26
+
27
+ // Check if a request object is provided
28
+ if (proxyReq && proxyReq.headers) {
29
+ const authtoken = proxyReq.headers.authtoken;
30
+ const accesskey = proxyReq.headers.accesskey;
31
+ // Optionally add more headers as needed
32
+ if (authtoken) {
33
+ this.config.authtoken = authtoken; // Set the authtoken in the config
34
+ }
35
+ if (accesskey) {
36
+ this.config.accesskey = accesskey; // Set the accesskey in the config
37
+ }
38
+ }
39
+ http:
40
+ //localhost:3002
41
+
42
+ this.api = new RbtApi(this.config);
43
+ if (isBrowser) {
44
+ this.api.initLocalDb();
45
+ }
46
+ Roboto.instance = this;
47
+ }
48
+ setAppServiceHost(host) {
49
+ this.api.setAppServiceHost(host);
50
+ }
51
+ setErrorHandler(customErrorHandler) {
52
+ if (this.api) {
53
+ this.api.setErrorHandler(customErrorHandler);
54
+ }
55
+ }
56
+
57
+ //
58
+ // User register, login, and refresh token
59
+ //
60
+ async login(params) {
61
+ return this.api.login(params);
62
+ }
63
+ async logout() {
64
+ return this.api.logout();
65
+ }
66
+ async refreshAuthToken() {
67
+ return this.api.refreshAuthToken(this.config.authtoken);
68
+ }
69
+ async registerUser(params) {
70
+ // TODO - need to
71
+
72
+ return this.api.registerUser(params);
73
+ }
74
+ async loadUser(params) {
75
+ return this.api.loadUser(params);
76
+ }
77
+ async loadCurrentUser() {
78
+ return this.api.loadCurrentUser();
79
+ }
80
+ async confirmUserEmail(params) {
81
+ return this.api.confirmUserEmail(params);
82
+ }
83
+
84
+ //
85
+ // create and upload files
86
+ //
87
+ async createFile(data = {}) {
88
+ return this.api.createFile(data);
89
+ }
90
+
91
+ //
92
+ //
93
+ //
94
+ async create(params, data = {}) {
95
+ return this.api.create(params, data);
96
+ }
97
+ async load(type, ids, options) {
98
+ return this.api.load(type, ids, options);
99
+ }
100
+ async query(type, params) {
101
+ return this.api.query(type, params);
102
+ }
103
+
104
+ //
105
+ //
106
+ //
107
+ async runTask(params, callbacks) {
108
+ return this.api.runTask(params, callbacks);
109
+ }
110
+ async pollTaskProgress(params) {
111
+ return this.api.pollTaskProgress(params);
112
+ }
113
+
114
+ //
115
+ // Get/Post to endpoint with Roboto authtoken
116
+ //
117
+ async get(endpoint, params) {
118
+ return this.api.get(endpoint, params);
119
+ }
120
+ async post(endpoint, data) {
121
+ return this.api.post(endpoint, data);
122
+ }
123
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "roboto-js",
3
- "version": "1.1.10",
3
+ "version": "1.1.12",
4
4
  "type": "module",
5
5
  "description": "",
6
6
  "main": "dist/cjs/index.cjs",
@@ -9,9 +9,11 @@
9
9
  "require": "./dist/cjs/index.cjs"
10
10
  },
11
11
  "scripts": {
12
+ "clean": "rm -rf node_modules; rm package-lock.json; npm install",
12
13
  "build": "npm run build:cjs && npm run build:esm",
13
14
  "build:cjs": "babel src --out-dir dist/cjs --presets=@babel/preset-env --extensions \".js,.jsx\" --out-file-extension .cjs && npm run postbuild:cjs",
14
- "build:esm": "babel src --out-dir dist/esm --presets=@babel/preset-env --no-babelrc --config-file ./babel.esm.config.json",
15
+ "build:esm": "babel src --out-dir dist/esm",
16
+ "xbuild:esm": "babel src --out-dir dist/esm --presets=@babel/preset-env --no-babelrc --config-file ./babel.esm.config.json",
15
17
  "postbuild:cjs": "node postbuild-cjs.js",
16
18
  "test": "echo \"Error: no test specified\" && exit 1",
17
19
  "prepublishOnly": "npm run build"
@@ -25,8 +27,8 @@
25
27
  "lodash": "^4.17.21"
26
28
  },
27
29
  "devDependencies": {
28
- "@babel/cli": "^7.23.0",
29
- "@babel/core": "^7.23.2",
30
- "@babel/preset-env": "^7.23.2"
30
+ "@babel/cli": "^7.23.9",
31
+ "@babel/core": "^7.23.9",
32
+ "@babel/preset-env": "^7.23.9"
31
33
  }
32
- }
34
+ }
package/src/index.js CHANGED
@@ -15,6 +15,8 @@ export default class Roboto{
15
15
 
16
16
  constructor(proxyReq = null) {
17
17
 
18
+ debugger;
19
+
18
20
  if(Roboto.instance && !proxyReq){
19
21
  // if on client, there can only be one instance
20
22
  // on server, with proxyReq, each request has its own instance
package/src/rbt_api.js CHANGED
@@ -25,7 +25,6 @@ export default class RbtApi {
25
25
  this.authtoken = authTokenToUse;
26
26
  this.appServiceHost = null;
27
27
 
28
-
29
28
  }
30
29
 
31
30
  async initLocalDb(){
@@ -369,7 +368,7 @@ export default class RbtApi {
369
368
  const { onProgress, onError, onFinish } = callbacks;
370
369
 
371
370
  try {
372
- const response = await this.post('http://localhost:3004/runChain', params);
371
+ const response = await this.post('/task_service/runChain', params);
373
372
  // Check if response and response.data are defined
374
373
  if (!response) {
375
374
  throw new Error('Invalid server response');
@@ -417,14 +416,14 @@ export default class RbtApi {
417
416
  * @param {function} onProgress - Callback function that receives progress updates.
418
417
  *
419
418
  * The function periodically sends GET requests to check the task's progress
420
- * and reports back via the provided callback function. The polling stops when
419
+ * and reports back via the provided callback function . The polling stops when
421
420
  * the task is completed or an error occurs.
422
421
  */
423
422
  async pollTaskProgress(jobId, callbacks) {
424
423
  const { onProgress, onError, onFinish } = callbacks;
425
424
  try {
426
425
  const checkProgress = async () => {
427
- const response = await this.get(`http://localhost:3004/pollChainProgress`, { jobId: jobId });
426
+ const response = await this.get(`/task_service/pollChainProgress`, { jobId: jobId });
428
427
 
429
428
  // If the task is still in progress, start polling for updates
430
429
  if (response.status === 'DONE' && onFinish){
@@ -543,6 +542,9 @@ export default class RbtApi {
543
542
  }
544
543
 
545
544
  if (_.isObject(err) && _.get(err, 'response')) {
545
+
546
+ console.log('RbtAPI handleError', err);
547
+
546
548
  const msg = _.get(err, 'response.data.message', 'Error in API response');
547
549
 
548
550
  if(msg.key){
package/babel.config.json DELETED
@@ -1,3 +0,0 @@
1
- {
2
- "presets": ["@babel/preset-env"]
3
- }