@inflector/aura 0.1.15 → 0.1.17
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/dist/database.d.ts.map +1 -1
- package/dist/database.js +21 -9
- package/package.json +2 -1
package/dist/database.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"database.d.ts","sourceRoot":"","sources":["../src/database.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAS,KAAK,EAAE,MAAM,mBAAmB,CAAA;
|
|
1
|
+
{"version":3,"file":"database.d.ts","sourceRoot":"","sources":["../src/database.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAS,KAAK,EAAE,MAAM,mBAAmB,CAAA;AAMjE,cAAM,WAAW,CAAC,IAAI,SAAS,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC;IAC9C,OAAO,CAAC,GAAG,CAAQ;IACnB,OAAO,CAAC,IAAI,CAAQ;IACpB,OAAO,CAAC,SAAS,CAAQ;IAEzB,OAAO,CAAC,cAAc;gBAKV,GAAG,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM;IAMxD,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;wvBAYF;IACD,MAAM;;ovBAYL;IACD,MAAM;;wvBAYL;IACD,GAAG,GAAI,QAAQ,QAAQ,CAAC,IAAI,CAAC,gvBAe5B;IACD,OAAO,GAAI,QAAQ,QAAQ,CAAC,IAAI,CAAC,EAAE,gvBAelC;IACD,MAAM,GAAI,QAAQ,OAAO,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;;wvBAarC;IACD,KAAK;;4BAYJ;IACD,KAAK;;6BAYJ;IACD,SAAS,GAAI,UAAU,CAAC,CAAC,CAAC,EAAE;QAAE,MAAM,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,GAAG,GAAG,GAAG,EAAE,CAAA;KAAE,KAAK,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE;QAAE,MAAM,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,GAAG,CAAA;KAAE,KAAK,OAAO,CAAC,GAAG,CAAC,CAAC,EAAE,QAAQ,GAAG,EAAE,OAAO,OAAO,gBA+B7J;CACJ;AAED,eAAO,MAAM,YAAY,GAAI,CAAC,SAAS;IAAE,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAA;CAAE,EACzE,KAAK,MAAM,EACX,WAAW,MAAM,EACjB,QAAQ,CAAC,QAEe,CAAC,kCAY5B,CAAA"}
|
package/dist/database.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { createFluentBuilder } from "./fluent";
|
|
2
2
|
import axios from "axios";
|
|
3
3
|
import { getToken } from "./auth";
|
|
4
|
+
import { SSE } from "sse.js";
|
|
4
5
|
class RemoteTable {
|
|
5
6
|
URL;
|
|
6
7
|
Name;
|
|
@@ -107,17 +108,28 @@ class RemoteTable {
|
|
|
107
108
|
params.push("where=" + JSON.stringify(where));
|
|
108
109
|
if (init)
|
|
109
110
|
params.push("init=true");
|
|
110
|
-
// Add token to query params for EventSource (doesn't support headers)
|
|
111
|
-
const token = getToken(this.WorkSpace);
|
|
112
|
-
if (token)
|
|
113
|
-
params.push("token=" + encodeURIComponent(token));
|
|
114
111
|
const query = params.length ? "?" + params.join("&") : "";
|
|
115
|
-
const
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
112
|
+
const tableName = this.Name;
|
|
113
|
+
const url = `${this.URL}/api/db/${this.WorkSpace}/${this.Name}${query}`;
|
|
114
|
+
const source = new SSE(url, {
|
|
115
|
+
headers: this.getAuthHeaders(),
|
|
116
|
+
});
|
|
117
|
+
source.addEventListener(tableName, (event) => {
|
|
118
|
+
try {
|
|
119
|
+
const { op, data } = JSON.parse(event.data);
|
|
120
|
+
callback({ action: op, data });
|
|
121
|
+
}
|
|
122
|
+
catch (e) {
|
|
123
|
+
// Ignore parse errors
|
|
124
|
+
}
|
|
125
|
+
});
|
|
126
|
+
source.addEventListener('error', (error) => {
|
|
127
|
+
console.error('SSE stream error:', error);
|
|
119
128
|
});
|
|
120
|
-
|
|
129
|
+
source.stream();
|
|
130
|
+
return () => {
|
|
131
|
+
source.close();
|
|
132
|
+
};
|
|
121
133
|
};
|
|
122
134
|
}
|
|
123
135
|
export const AuraDatabase = (url, workspace, tables) => {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@inflector/aura",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.17",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"types": "./dist/index.d.ts",
|
|
@@ -42,6 +42,7 @@
|
|
|
42
42
|
"chalk": "^5.6.2",
|
|
43
43
|
"chokidar": "^5.0.0",
|
|
44
44
|
"eventsource": "^4.1.0",
|
|
45
|
+
"sse.js": "^2.7.2",
|
|
45
46
|
"tsx": "^4.20.4",
|
|
46
47
|
"zod": "^3.25.67"
|
|
47
48
|
}
|