spiceflow 1.1.11 → 1.1.13
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/client/errors.d.ts +1 -1
- package/dist/client/errors.d.ts.map +1 -1
- package/dist/client/errors.js +1 -1
- package/dist/client/errors.js.map +1 -1
- package/dist/client/index.d.ts +0 -1
- package/dist/client/index.d.ts.map +1 -1
- package/dist/client/index.js +5 -24
- package/dist/client/index.js.map +1 -1
- package/dist/client/types.d.ts +8 -17
- package/dist/client/types.d.ts.map +1 -1
- package/dist/openapi.d.ts +1 -1
- package/dist/spiceflow.d.ts +10 -10
- package/dist/spiceflow.d.ts.map +1 -1
- package/dist/spiceflow.js +3 -10
- package/dist/spiceflow.js.map +1 -1
- package/dist/types.d.ts +3 -3
- package/dist/types.d.ts.map +1 -1
- package/dist/utils.js +13 -8
- package/dist/utils.js.map +1 -1
- package/package.json +3 -2
- package/src/client/errors.ts +1 -1
- package/src/client/index.ts +8 -27
- package/src/client/types.ts +73 -90
- package/src/spiceflow.ts +14 -21
- package/src/types.ts +6 -6
- package/src/utils.ts +13 -13
- package/dist/client/ws.d.ts +0 -15
- package/dist/client/ws.d.ts.map +0 -1
- package/dist/client/ws.js +0 -49
- package/dist/client/ws.js.map +0 -1
- package/src/client/ws.ts +0 -97
package/dist/client/ws.d.ts
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import type { InputSchema } from '../types.js';
|
|
2
|
-
import type { SpiceflowClient } from './types.js';
|
|
3
|
-
export declare class EdenWS<in out Schema extends InputSchema<any> = {}> {
|
|
4
|
-
url: string;
|
|
5
|
-
ws: WebSocket;
|
|
6
|
-
constructor(url: string);
|
|
7
|
-
send(data: Schema['body'] | Schema['body'][]): this;
|
|
8
|
-
on<K extends keyof WebSocketEventMap>(type: K, listener: (event: SpiceflowClient.WSEvent<K, Schema['response']>) => void, options?: boolean | AddEventListenerOptions): this;
|
|
9
|
-
off<K extends keyof WebSocketEventMap>(type: K, listener: (this: WebSocket, ev: WebSocketEventMap[K]) => any, options?: boolean | EventListenerOptions): this;
|
|
10
|
-
subscribe(onMessage: (event: SpiceflowClient.WSEvent<'message', Schema['response']>) => void, options?: boolean | AddEventListenerOptions): this;
|
|
11
|
-
addEventListener<K extends keyof WebSocketEventMap>(type: K, listener: (event: SpiceflowClient.WSEvent<K, Schema['response']>) => void, options?: boolean | AddEventListenerOptions): this;
|
|
12
|
-
removeEventListener<K extends keyof WebSocketEventMap>(type: K, listener: (this: WebSocket, ev: WebSocketEventMap[K]) => any, options?: boolean | EventListenerOptions): this;
|
|
13
|
-
close(): this;
|
|
14
|
-
}
|
|
15
|
-
//# sourceMappingURL=ws.d.ts.map
|
package/dist/client/ws.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ws.d.ts","sourceRoot":"","sources":["../../src/client/ws.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAA;AAC9C,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,YAAY,CAAA;AAGjD,qBAAa,MAAM,CAAC,EAAE,CAAC,GAAG,CAAC,MAAM,SAAS,WAAW,CAAC,GAAG,CAAC,GAAG,EAAE;IAG1C,GAAG,EAAE,MAAM;IAF9B,EAAE,EAAE,SAAS,CAAA;gBAEM,GAAG,EAAE,MAAM;IAI9B,IAAI,CAAC,IAAI,EAAE,MAAM,CAAC,MAAM,CAAC,GAAG,MAAM,CAAC,MAAM,CAAC,EAAE;IAc5C,EAAE,CAAC,CAAC,SAAS,MAAM,iBAAiB,EAClC,IAAI,EAAE,CAAC,EACP,QAAQ,EAAE,CAAC,KAAK,EAAE,eAAe,CAAC,OAAO,CAAC,CAAC,EAAE,MAAM,CAAC,UAAU,CAAC,CAAC,KAAK,IAAI,EACzE,OAAO,CAAC,EAAE,OAAO,GAAG,uBAAuB;IAK7C,GAAG,CAAC,CAAC,SAAS,MAAM,iBAAiB,EACnC,IAAI,EAAE,CAAC,EACP,QAAQ,EAAE,CAAC,IAAI,EAAE,SAAS,EAAE,EAAE,EAAE,iBAAiB,CAAC,CAAC,CAAC,KAAK,GAAG,EAC5D,OAAO,CAAC,EAAE,OAAO,GAAG,oBAAoB;IAO1C,SAAS,CACP,SAAS,EAAE,CACT,KAAK,EAAE,eAAe,CAAC,OAAO,CAAC,SAAS,EAAE,MAAM,CAAC,UAAU,CAAC,CAAC,KAC1D,IAAI,EACT,OAAO,CAAC,EAAE,OAAO,GAAG,uBAAuB;IAK7C,gBAAgB,CAAC,CAAC,SAAS,MAAM,iBAAiB,EAChD,IAAI,EAAE,CAAC,EACP,QAAQ,EAAE,CAAC,KAAK,EAAE,eAAe,CAAC,OAAO,CAAC,CAAC,EAAE,MAAM,CAAC,UAAU,CAAC,CAAC,KAAK,IAAI,EACzE,OAAO,CAAC,EAAE,OAAO,GAAG,uBAAuB;IAoB7C,mBAAmB,CAAC,CAAC,SAAS,MAAM,iBAAiB,EACnD,IAAI,EAAE,CAAC,EACP,QAAQ,EAAE,CAAC,IAAI,EAAE,SAAS,EAAE,EAAE,EAAE,iBAAiB,CAAC,CAAC,CAAC,KAAK,GAAG,EAC5D,OAAO,CAAC,EAAE,OAAO,GAAG,oBAAoB;IAO1C,KAAK;CAKN"}
|
package/dist/client/ws.js
DELETED
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
import { parseStringifiedValue } from './utils.js';
|
|
2
|
-
export class EdenWS {
|
|
3
|
-
constructor(url) {
|
|
4
|
-
this.url = url;
|
|
5
|
-
this.ws = new WebSocket(url);
|
|
6
|
-
}
|
|
7
|
-
send(data) {
|
|
8
|
-
if (Array.isArray(data)) {
|
|
9
|
-
data.forEach((datum) => this.send(datum));
|
|
10
|
-
return this;
|
|
11
|
-
}
|
|
12
|
-
this.ws.send(typeof data === 'object' ? JSON.stringify(data) : data.toString());
|
|
13
|
-
return this;
|
|
14
|
-
}
|
|
15
|
-
on(type, listener, options) {
|
|
16
|
-
return this.addEventListener(type, listener, options);
|
|
17
|
-
}
|
|
18
|
-
off(type, listener, options) {
|
|
19
|
-
this.ws.removeEventListener(type, listener, options);
|
|
20
|
-
return this;
|
|
21
|
-
}
|
|
22
|
-
subscribe(onMessage, options) {
|
|
23
|
-
return this.addEventListener('message', onMessage, options);
|
|
24
|
-
}
|
|
25
|
-
addEventListener(type, listener, options) {
|
|
26
|
-
this.ws.addEventListener(type, (ws) => {
|
|
27
|
-
if (type === 'message') {
|
|
28
|
-
const data = parseMessageEvent(ws);
|
|
29
|
-
listener(Object.assign(Object.assign({}, ws), { data }));
|
|
30
|
-
}
|
|
31
|
-
else
|
|
32
|
-
listener(ws);
|
|
33
|
-
}, options);
|
|
34
|
-
return this;
|
|
35
|
-
}
|
|
36
|
-
removeEventListener(type, listener, options) {
|
|
37
|
-
this.off(type, listener, options);
|
|
38
|
-
return this;
|
|
39
|
-
}
|
|
40
|
-
close() {
|
|
41
|
-
this.ws.close();
|
|
42
|
-
return this;
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
const parseMessageEvent = (event) => {
|
|
46
|
-
const messageString = event.data.toString();
|
|
47
|
-
return messageString === 'null' ? null : parseStringifiedValue(messageString);
|
|
48
|
-
};
|
|
49
|
-
//# sourceMappingURL=ws.js.map
|
package/dist/client/ws.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ws.js","sourceRoot":"","sources":["../../src/client/ws.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,qBAAqB,EAAE,MAAM,YAAY,CAAA;AAElD,MAAM,OAAO,MAAM;IAGjB,YAAmB,GAAW;QAAX,QAAG,GAAH,GAAG,CAAQ;QAC5B,IAAI,CAAC,EAAE,GAAG,IAAI,SAAS,CAAC,GAAG,CAAC,CAAA;IAC9B,CAAC;IAED,IAAI,CAAC,IAAuC;QAC1C,IAAI,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE,CAAC;YACxB,IAAI,CAAC,OAAO,C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QAExC,IAAI,CAAC,GAAG,CAAC,IAAI,EAAE,QAAQ,EAAE,OAAO,CAAC,CAAA;QAEjC,OAAO,IAAI,CAAA;IACb,CAAC;IAED,KAAK;QACH,IAAI,CAAC,EAAE,CAAC,KAAK,EAAE,CAAA;QAEf,OAAO,IAAI,CAAA;IACb,CAAC;CACF;AAED,MAAM,iBAAiB,GAAG,CAAC,KAAmB,EAAE,EAAE;IAChD,MAAM,aAAa,GAAG,KAAK,CAAC,IAAI,CAAC,QAAQ,EAAE,CAAA;IAE3C,OAAO,aAAa,KAAK,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,qBAAqB,CAAC,aAAa,CAAC,CAAA;AAC/E,CAAC,CAAA"}
|
package/src/client/ws.ts
DELETED
|
@@ -1,97 +0,0 @@
|
|
|
1
|
-
import type { InputSchema } from '../types.js'
|
|
2
|
-
import type { SpiceflowClient } from './types.js'
|
|
3
|
-
import { parseStringifiedValue } from './utils.js'
|
|
4
|
-
|
|
5
|
-
export class EdenWS<in out Schema extends InputSchema<any> = {}> {
|
|
6
|
-
ws: WebSocket
|
|
7
|
-
|
|
8
|
-
constructor(public url: string) {
|
|
9
|
-
this.ws = new WebSocket(url)
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
send(data: Schema['body'] | Schema['body'][]) {
|
|
13
|
-
if (Array.isArray(data)) {
|
|
14
|
-
data.forEach((datum) => this.send(datum))
|
|
15
|
-
|
|
16
|
-
return this
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
this.ws.send(
|
|
20
|
-
typeof data === 'object' ? JSON.stringify(data) : data.toString(),
|
|
21
|
-
)
|
|
22
|
-
|
|
23
|
-
return this
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
on<K extends keyof WebSocketEventMap>(
|
|
27
|
-
type: K,
|
|
28
|
-
listener: (event: SpiceflowClient.WSEvent<K, Schema['response']>) => void,
|
|
29
|
-
options?: boolean | AddEventListenerOptions,
|
|
30
|
-
) {
|
|
31
|
-
return this.addEventListener(type, listener, options)
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
off<K extends keyof WebSocketEventMap>(
|
|
35
|
-
type: K,
|
|
36
|
-
listener: (this: WebSocket, ev: WebSocketEventMap[K]) => any,
|
|
37
|
-
options?: boolean | EventListenerOptions,
|
|
38
|
-
) {
|
|
39
|
-
this.ws.removeEventListener(type, listener, options)
|
|
40
|
-
|
|
41
|
-
return this
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
subscribe(
|
|
45
|
-
onMessage: (
|
|
46
|
-
event: SpiceflowClient.WSEvent<'message', Schema['response']>,
|
|
47
|
-
) => void,
|
|
48
|
-
options?: boolean | AddEventListenerOptions,
|
|
49
|
-
) {
|
|
50
|
-
return this.addEventListener('message', onMessage, options)
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
addEventListener<K extends keyof WebSocketEventMap>(
|
|
54
|
-
type: K,
|
|
55
|
-
listener: (event: SpiceflowClient.WSEvent<K, Schema['response']>) => void,
|
|
56
|
-
options?: boolean | AddEventListenerOptions,
|
|
57
|
-
) {
|
|
58
|
-
this.ws.addEventListener(
|
|
59
|
-
type,
|
|
60
|
-
(ws) => {
|
|
61
|
-
if (type === 'message') {
|
|
62
|
-
const data = parseMessageEvent(ws as MessageEvent)
|
|
63
|
-
|
|
64
|
-
listener({
|
|
65
|
-
...ws,
|
|
66
|
-
data,
|
|
67
|
-
} as any)
|
|
68
|
-
} else listener(ws as any)
|
|
69
|
-
},
|
|
70
|
-
options,
|
|
71
|
-
)
|
|
72
|
-
|
|
73
|
-
return this
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
removeEventListener<K extends keyof WebSocketEventMap>(
|
|
77
|
-
type: K,
|
|
78
|
-
listener: (this: WebSocket, ev: WebSocketEventMap[K]) => any,
|
|
79
|
-
options?: boolean | EventListenerOptions,
|
|
80
|
-
) {
|
|
81
|
-
this.off(type, listener, options)
|
|
82
|
-
|
|
83
|
-
return this
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
close() {
|
|
87
|
-
this.ws.close()
|
|
88
|
-
|
|
89
|
-
return this
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
const parseMessageEvent = (event: MessageEvent) => {
|
|
94
|
-
const messageString = event.data.toString()
|
|
95
|
-
|
|
96
|
-
return messageString === 'null' ? null : parseStringifiedValue(messageString)
|
|
97
|
-
}
|