@saltify/milky-node-sdk 0.1.0-beta.9 → 0.1.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/index.js +12 -6
- package/package.json +4 -4
package/dist/index.js
CHANGED
|
@@ -141,9 +141,9 @@ var require_dist = __commonJS({
|
|
|
141
141
|
}
|
|
142
142
|
});
|
|
143
143
|
|
|
144
|
-
// ../../node_modules/.pnpm/eventsource-client@1.
|
|
144
|
+
// ../../node_modules/.pnpm/eventsource-client@1.2.0/node_modules/eventsource-client/dist/node.js
|
|
145
145
|
var require_node = __commonJS({
|
|
146
|
-
"../../node_modules/.pnpm/eventsource-client@1.
|
|
146
|
+
"../../node_modules/.pnpm/eventsource-client@1.2.0/node_modules/eventsource-client/dist/node.js"(exports) {
|
|
147
147
|
"use strict";
|
|
148
148
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
149
149
|
var node_stream = __require("stream");
|
|
@@ -154,7 +154,13 @@ var require_node = __commonJS({
|
|
|
154
154
|
var noop = () => {
|
|
155
155
|
};
|
|
156
156
|
function createEventSource$1(optionsOrUrl, { getStream: getStream2 }) {
|
|
157
|
-
const options = typeof optionsOrUrl == "string" || optionsOrUrl instanceof URL ? { url: optionsOrUrl } : optionsOrUrl, {
|
|
157
|
+
const options = typeof optionsOrUrl == "string" || optionsOrUrl instanceof URL ? { url: optionsOrUrl } : optionsOrUrl, {
|
|
158
|
+
onMessage,
|
|
159
|
+
onComment = noop,
|
|
160
|
+
onConnect = noop,
|
|
161
|
+
onDisconnect = noop,
|
|
162
|
+
onScheduleReconnect = noop
|
|
163
|
+
} = options, { fetch: fetch2, url, initialLastEventId } = validate(options), requestHeaders = { ...options.headers }, onCloseSubscribers = [], subscribers = onMessage ? [onMessage] : [], emit = (event) => subscribers.forEach((fn) => fn(event)), parser = eventsourceParser.createParser({ onEvent, onRetry, onComment });
|
|
158
164
|
let request, currentUrl = url.toString(), controller = new AbortController(), lastEventId = initialLastEventId, reconnectMs = 2e3, reconnectTimer, readyState = CLOSED2;
|
|
159
165
|
return connect(), {
|
|
160
166
|
close,
|
|
@@ -221,7 +227,7 @@ var require_node = __commonJS({
|
|
|
221
227
|
};
|
|
222
228
|
}
|
|
223
229
|
function scheduleReconnect() {
|
|
224
|
-
onScheduleReconnect({ delay: reconnectMs }), readyState = CONNECTING2, reconnectTimer = setTimeout(connect, reconnectMs);
|
|
230
|
+
onScheduleReconnect({ delay: reconnectMs }), !controller.signal.aborted && (readyState = CONNECTING2, reconnectTimer = setTimeout(connect, reconnectMs));
|
|
225
231
|
}
|
|
226
232
|
async function onFetchResponse(response) {
|
|
227
233
|
onConnect(), parser.reset();
|
|
@@ -304,7 +310,7 @@ var require_node = __commonJS({
|
|
|
304
310
|
// src/index.ts
|
|
305
311
|
import EventEmitter from "events";
|
|
306
312
|
|
|
307
|
-
// ../../node_modules/.pnpm/eventsource-client@1.
|
|
313
|
+
// ../../node_modules/.pnpm/eventsource-client@1.2.0/node_modules/eventsource-client/dist/node.cjs.mjs
|
|
308
314
|
var import_node = __toESM(require_node(), 1);
|
|
309
315
|
var CLOSED = import_node.default.CLOSED;
|
|
310
316
|
var CONNECTING = import_node.default.CONNECTING;
|
|
@@ -338,7 +344,7 @@ var MilkyClient = class {
|
|
|
338
344
|
if (accessToken) this.fetchHeader["Authorization"] = `Bearer ${accessToken}`;
|
|
339
345
|
this.eventEmitter = new EventEmitter();
|
|
340
346
|
this.httpApiUrl = combineUrl(httpUrlBase, "api");
|
|
341
|
-
this.eventUrl = combineUrl(httpUrlBase, "
|
|
347
|
+
this.eventUrl = combineUrl(httpUrlBase, "event");
|
|
342
348
|
if (!useSSE) {
|
|
343
349
|
this.createWebsocket();
|
|
344
350
|
} else {
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@saltify/milky-node-sdk",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.1.0
|
|
4
|
+
"version": "0.1.0",
|
|
5
5
|
"description": "Node.js SDK for Milky protocol",
|
|
6
6
|
"main": "dist/index.js",
|
|
7
7
|
"typings": "dist/index.d.ts",
|
|
@@ -17,11 +17,11 @@
|
|
|
17
17
|
"license": "CC0-1.0",
|
|
18
18
|
"devDependencies": {
|
|
19
19
|
"@types/node": "^22.17.2",
|
|
20
|
-
"eventsource-client": "^1.
|
|
20
|
+
"eventsource-client": "^1.2.0"
|
|
21
21
|
},
|
|
22
22
|
"dependencies": {
|
|
23
|
-
"@saltify/milky-types": "^1.0.0
|
|
24
|
-
"zod": "^4.1.
|
|
23
|
+
"@saltify/milky-types": "^1.0.0",
|
|
24
|
+
"zod": "^4.1.11"
|
|
25
25
|
},
|
|
26
26
|
"scripts": {
|
|
27
27
|
"build": "npm run gen:apis && tsup",
|