roboto-js 1.1.9 → 1.1.11

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,13 +1,18 @@
1
1
  {
2
2
  "name": "roboto-js",
3
- "version": "1.1.9",
3
+ "version": "1.1.11",
4
4
  "type": "module",
5
5
  "description": "",
6
6
  "main": "dist/cjs/index.cjs",
7
+ "exports": {
8
+ "import": "./dist/esm/index.js",
9
+ "require": "./dist/cjs/index.cjs"
10
+ },
7
11
  "scripts": {
8
12
  "build": "npm run build:cjs && npm run build:esm",
9
13
  "build:cjs": "babel src --out-dir dist/cjs --presets=@babel/preset-env --extensions \".js,.jsx\" --out-file-extension .cjs && npm run postbuild:cjs",
10
- "build:esm": "babel src --out-dir dist/esm --presets=@babel/preset-env --no-babelrc --config-file ./babel.esm.config.json",
14
+ "build:esm": "babel src --out-dir dist/esm",
15
+ "xbuild:esm": "babel src --out-dir dist/esm --presets=@babel/preset-env --no-babelrc --config-file ./babel.esm.config.json",
11
16
  "postbuild:cjs": "node postbuild-cjs.js",
12
17
  "test": "echo \"Error: no test specified\" && exit 1",
13
18
  "prepublishOnly": "npm run build"
@@ -21,8 +26,8 @@
21
26
  "lodash": "^4.17.21"
22
27
  },
23
28
  "devDependencies": {
24
- "@babel/cli": "^7.23.0",
25
- "@babel/core": "^7.23.2",
26
- "@babel/preset-env": "^7.23.2"
29
+ "@babel/cli": "^7.23.9",
30
+ "@babel/core": "^7.23.9",
31
+ "@babel/preset-env": "^7.23.9"
27
32
  }
28
- }
33
+ }
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
@@ -470,6 +470,7 @@ export default class RbtApi {
470
470
  * @returns {Promise<Object>} - The response data from the API.
471
471
  */
472
472
  async get(endpoint, params = {}) {
473
+ debugger;
473
474
  try {
474
475
 
475
476
  // Add the authToken to the headers
package/babel.config.json DELETED
@@ -1,3 +0,0 @@
1
- {
2
- "presets": ["@babel/preset-env"]
3
- }