@inflector/aura 0.3.7 → 0.4.0
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/hooks/react.js +2 -2
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -0
- package/dist/realtime.d.ts +5 -0
- package/dist/realtime.d.ts.map +1 -0
- package/dist/realtime.js +19 -0
- package/package.json +1 -1
package/dist/hooks/react.js
CHANGED
|
@@ -28,7 +28,7 @@ export function useTable(table, Options) {
|
|
|
28
28
|
useEffect(() => {
|
|
29
29
|
const unsubscribe = table.Subscribe((event) => {
|
|
30
30
|
// Normalize op to uppercase to handle both old and new formats
|
|
31
|
-
const op = event.
|
|
31
|
+
const op = event.action;
|
|
32
32
|
setData((prev) => {
|
|
33
33
|
// Helper to prevent duplicates (Upsert logic)
|
|
34
34
|
const merge = (existing, incoming) => {
|
|
@@ -81,7 +81,7 @@ export function useRecord(table, Options) {
|
|
|
81
81
|
useEffect(() => {
|
|
82
82
|
const unsubscribe = table.Subscribe((event) => {
|
|
83
83
|
// Normalize op to uppercase to handle both old and new formats
|
|
84
|
-
const op = event.
|
|
84
|
+
const op = event.action;
|
|
85
85
|
setData((prev) => {
|
|
86
86
|
switch (op) {
|
|
87
87
|
case 'Get': {
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { AuraAuth } from "./auth";
|
|
2
2
|
import { AuraDatabase } from "./database";
|
|
3
|
+
import { Realtime } from "./realtime";
|
|
3
4
|
import { AuraStorage } from "./storage";
|
|
4
5
|
export * from "@inflector/optima-pg/types";
|
|
5
6
|
export * from "./lib";
|
|
@@ -17,6 +18,7 @@ type AuraInstance<F, T extends Record<string, any>> = {
|
|
|
17
18
|
Function: F;
|
|
18
19
|
Storage: ReturnType<typeof AuraStorage>;
|
|
19
20
|
Auth: ReturnType<typeof AuraAuth>;
|
|
21
|
+
Realtime: typeof Realtime;
|
|
20
22
|
};
|
|
21
23
|
export declare const CreateAura: <F, T extends Record<string, any>>(Config: CreateAuraConfig<T>) => AuraInstance<F, T>;
|
|
22
24
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,QAAQ,CAAC;AAClC,OAAO,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAE1C,OAAO,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AAExC,cAAc,4BAA4B,CAAC;AAC3C,cAAc,OAAO,CAAC;AACtB,cAAc,eAAe,CAAC;AAE9B,KAAK,gBAAgB,CAAC,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,IAAI;IACnD,MAAM,EAAE;QACJ,GAAG,EAAE,MAAM,CAAC;QACZ,SAAS,EAAE,MAAM,CAAC;QAClB,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAC;KACtB,CAAC;IACF,MAAM,EAAE,CAAC,CAAC;CACb,CAAC;AAEF,KAAK,YAAY,CAAC,CAAC,EAAE,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,IAAI;IAClD,QAAQ,EAAE,UAAU,CAAC,OAAO,YAAY,CAAC,CAAC,CAAC,CAAC,CAAC;IAC7C,QAAQ,EAAE,CAAC,CAAC;IACZ,OAAO,EAAE,UAAU,CAAC,OAAO,WAAW,CAAC,CAAC;IACxC,IAAI,EAAE,UAAU,CAAC,OAAO,QAAQ,CAAC,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,QAAQ,CAAC;AAClC,OAAO,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAE1C,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AACtC,OAAO,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AAExC,cAAc,4BAA4B,CAAC;AAC3C,cAAc,OAAO,CAAC;AACtB,cAAc,eAAe,CAAC;AAE9B,KAAK,gBAAgB,CAAC,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,IAAI;IACnD,MAAM,EAAE;QACJ,GAAG,EAAE,MAAM,CAAC;QACZ,SAAS,EAAE,MAAM,CAAC;QAClB,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAC;KACtB,CAAC;IACF,MAAM,EAAE,CAAC,CAAC;CACb,CAAC;AAEF,KAAK,YAAY,CAAC,CAAC,EAAE,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,IAAI;IAClD,QAAQ,EAAE,UAAU,CAAC,OAAO,YAAY,CAAC,CAAC,CAAC,CAAC,CAAC;IAC7C,QAAQ,EAAE,CAAC,CAAC;IACZ,OAAO,EAAE,UAAU,CAAC,OAAO,WAAW,CAAC,CAAC;IACxC,IAAI,EAAE,UAAU,CAAC,OAAO,QAAQ,CAAC,CAAC;IAClC,QAAQ,EAAC,OAAO,QAAQ,CAAA;CAC3B,CAAC;AAEF,eAAO,MAAM,UAAU,GACnB,CAAC,EACD,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EAE7B,QAAQ,gBAAgB,CAAC,CAAC,CAAC,KAC5B,YAAY,CAAC,CAAC,EAAE,CAAC,CAkBnB,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { AuraAuth } from "./auth";
|
|
2
2
|
import { AuraDatabase } from "./database";
|
|
3
3
|
import { createFunctionHandler } from "./function";
|
|
4
|
+
import { Realtime } from "./realtime";
|
|
4
5
|
import { AuraStorage } from "./storage";
|
|
5
6
|
export * from "@inflector/optima-pg/types";
|
|
6
7
|
export * from "./lib";
|
|
@@ -20,5 +21,6 @@ export const CreateAura = (Config) => {
|
|
|
20
21
|
Function: createFunctionHandler(Config.config.WorkSpace),
|
|
21
22
|
Auth: auth,
|
|
22
23
|
Storage: AuraStorage(Config.config.WorkSpace, auth.Signal),
|
|
24
|
+
Realtime: Realtime
|
|
23
25
|
};
|
|
24
26
|
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"realtime.d.ts","sourceRoot":"","sources":["../src/realtime.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,QAAQ,GAAI,WAAW,MAAM;sBAEd,MAAM,WAAW,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC;sBAQnD,MAAM,YAAY,CAAC,OAAO,EAAE,MAAM,KAAK,IAAI;CAWhE,CAAA"}
|
package/dist/realtime.js
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
export const Realtime = (workspace) => {
|
|
2
|
+
return {
|
|
3
|
+
Notify: async (channel, payload) => {
|
|
4
|
+
await fetch(`/api/db/${workspace}/notify`, {
|
|
5
|
+
method: 'POST',
|
|
6
|
+
headers: { 'Content-Type': 'application/json' },
|
|
7
|
+
body: JSON.stringify({ channel, payload }),
|
|
8
|
+
});
|
|
9
|
+
},
|
|
10
|
+
Listen: (channel, callback) => {
|
|
11
|
+
const eventSource = new EventSource(`/api/db/${workspace}/listen/${channel}`);
|
|
12
|
+
eventSource.onmessage = (event) => {
|
|
13
|
+
callback(event.data);
|
|
14
|
+
};
|
|
15
|
+
// Return unsubscribe function
|
|
16
|
+
return () => eventSource.close();
|
|
17
|
+
},
|
|
18
|
+
};
|
|
19
|
+
};
|