@apiquest/plugin-sse 1.0.2 → 1.0.5

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/README.md CHANGED
@@ -1,160 +1,164 @@
1
- # @apiquest/plugin-sse
2
-
3
- Server-Sent Events (SSE) protocol plugin for ApiQuest. Provides support for testing SSE endpoints with event streaming and message validation.
4
-
5
- ## Installation
6
-
7
- ```bash
8
- npm install -g @apiquest/plugin-sse
9
- ```
10
-
11
- ## Features
12
-
13
- - SSE connection management
14
- - Event streaming with named events
15
- - Message data validation
16
- - Event counting and assertions
17
- - Custom headers support
18
- - Authentication integration (via `@apiquest/plugin-auth`)
19
- - Timeout configuration
20
-
21
- ## Usage
22
-
23
- Set the collection protocol to `sse`:
24
-
25
- ```json
26
- {
27
- "$schema": "https://apiquest.net/schemas/collection-v1.0.json",
28
- "protocol": "sse",
29
- "items": [
30
- {
31
- "type": "request",
32
- "id": "stream-events",
33
- "name": "Stream Server Events",
34
- "data": {
35
- "url": "https://api.example.com/events",
36
- "timeout": 30000,
37
- "scripts": [
38
- {
39
- "event": "onMessage",
40
- "script": "quest.test('Message received', () => {\n const msg = quest.message;\n expect(msg.data).to.be.a('string');\n});"
41
- },
42
- {
43
- "event": "onComplete",
44
- "script": "quest.test('Stream completed', () => {\n expect(quest.messages.length).to.be.greaterThan(0);\n});"
45
- }
46
- ]
47
- }
48
- }
49
- ]
50
- }
51
- ```
52
-
53
- ### With Custom Headers
54
-
55
- ```json
56
- {
57
- "data": {
58
- "url": "https://api.example.com/stream",
59
- "headers": {
60
- "Accept": "text/event-stream",
61
- "x-stream-id": "{{streamId}}"
62
- },
63
- "timeout": 60000
64
- }
65
- }
66
- ```
67
-
68
- ### Event Scripts
69
-
70
- SSE requests support event-based scripts:
71
-
72
- - **onMessage** - Runs for each received message
73
- - **onError** - Runs when an error occurs
74
- - **onComplete** - Runs when the stream completes
75
-
76
- ```json
77
- {
78
- "data": {
79
- "scripts": [
80
- {
81
- "event": "onMessage",
82
- "script": "const data = JSON.parse(quest.message.data);\nquest.variables.set('lastEventId', data.id);\n\nquest.test('Valid event data', () => {\n expect(data).to.have.property('timestamp');\n});"
83
- },
84
- {
85
- "event": "onError",
86
- "script": "console.error('Stream error:', quest.error);"
87
- },
88
- {
89
- "event": "onComplete",
90
- "script": "quest.test('Received messages', () => {\n expect(quest.messages.length).to.equal(10);\n});"
91
- }
92
- ]
93
- }
94
- }
95
- ```
96
-
97
- ### Message Counting
98
-
99
- Use `quest.expectMessages()` in the preRequestScript to enable deterministic test counting:
100
-
101
- ```json
102
- {
103
- "type": "request",
104
- "id": "stream-events",
105
- "name": "Stream Server Events",
106
- "preRequestScript": "quest.expectMessages(5, 10000);",
107
- "data": {
108
- "url": "https://api.example.com/events",
109
- "scripts": [
110
- {
111
- "event": "onMessage",
112
- "script": "quest.test('Message received', () => {\n expect(quest.message.data).to.exist;\n});"
113
- }
114
- ]
115
- }
116
- }
117
- ```
118
-
119
- This informs the runner to expect 5 messages, enabling accurate test count reporting (5 messages × tests per message).
120
-
121
- ## Response Handling
122
-
123
- Access SSE data in scripts:
124
-
125
- ```javascript
126
- // In onMessage script
127
- quest.test('Event has data', () => {
128
- expect(quest.message.data).to.be.a('string');
129
- });
130
-
131
- quest.test('Event type is update', () => {
132
- expect(quest.message.event).to.equal('update');
133
- });
134
-
135
- // In onComplete script
136
- quest.test('Received all messages', () => {
137
- expect(quest.messages.length).to.equal(5);
138
- });
139
-
140
- quest.test('All messages valid', () => {
141
- quest.messages.forEach(msg => {
142
- const data = JSON.parse(msg.data);
143
- expect(data).to.have.property('id');
144
- });
145
- });
146
- ```
147
-
148
- ## Compatibility
149
-
150
- - **Authentication:** Works with `@apiquest/plugin-auth` for Bearer, Basic, API Key
151
- - **Node.js:** Requires Node.js 20+
152
-
153
- ## Documentation
154
-
155
- - [Fracture Documentation](https://apiquest.net/docs/fracture)
156
- - [Schema Reference](https://apiquest.net/schemas/collection-v1.0.json)
157
-
158
- ## License
159
-
160
- Dual-licensed under AGPL-3.0-or-later and commercial license. See LICENSE.txt for details.
1
+ # @apiquest/plugin-sse
2
+
3
+ Server-Sent Events (SSE) protocol plugin for ApiQuest. Provides support for testing SSE endpoints with event streaming and message validation.
4
+
5
+ ## Installation
6
+
7
+ ```bash
8
+ # Using npm
9
+ npm install -g @apiquest/plugin-sse
10
+
11
+ # Or using fracture CLI
12
+ fracture plugin install sse
13
+ ```
14
+
15
+ ## Features
16
+
17
+ - SSE connection management
18
+ - Event streaming with named events
19
+ - Message data validation
20
+ - Event counting and assertions
21
+ - Custom headers support
22
+ - Authentication integration (via `@apiquest/plugin-auth`)
23
+ - Timeout configuration
24
+
25
+ ## Usage
26
+
27
+ Set the collection protocol to `sse`:
28
+
29
+ ```json
30
+ {
31
+ "$schema": "https://apiquest.net/schemas/collection-v1.0.json",
32
+ "protocol": "sse",
33
+ "items": [
34
+ {
35
+ "type": "request",
36
+ "id": "stream-events",
37
+ "name": "Stream Server Events",
38
+ "data": {
39
+ "url": "https://api.example.com/events",
40
+ "timeout": 30000,
41
+ "scripts": [
42
+ {
43
+ "event": "onMessage",
44
+ "script": "quest.test('Message received', () => {\n const msg = quest.message;\n expect(msg.data).to.be.a('string');\n});"
45
+ },
46
+ {
47
+ "event": "onComplete",
48
+ "script": "quest.test('Stream completed', () => {\n expect(quest.messages.length).to.be.greaterThan(0);\n});"
49
+ }
50
+ ]
51
+ }
52
+ }
53
+ ]
54
+ }
55
+ ```
56
+
57
+ ### With Custom Headers
58
+
59
+ ```json
60
+ {
61
+ "data": {
62
+ "url": "https://api.example.com/stream",
63
+ "headers": {
64
+ "Accept": "text/event-stream",
65
+ "x-stream-id": "{{streamId}}"
66
+ },
67
+ "timeout": 60000
68
+ }
69
+ }
70
+ ```
71
+
72
+ ### Event Scripts
73
+
74
+ SSE requests support event-based scripts:
75
+
76
+ - **onMessage** - Runs for each received message
77
+ - **onError** - Runs when an error occurs
78
+ - **onComplete** - Runs when the stream completes
79
+
80
+ ```json
81
+ {
82
+ "data": {
83
+ "scripts": [
84
+ {
85
+ "event": "onMessage",
86
+ "script": "const data = JSON.parse(quest.message.data);\nquest.variables.set('lastEventId', data.id);\n\nquest.test('Valid event data', () => {\n expect(data).to.have.property('timestamp');\n});"
87
+ },
88
+ {
89
+ "event": "onError",
90
+ "script": "console.error('Stream error:', quest.error);"
91
+ },
92
+ {
93
+ "event": "onComplete",
94
+ "script": "quest.test('Received messages', () => {\n expect(quest.messages.length).to.equal(10);\n});"
95
+ }
96
+ ]
97
+ }
98
+ }
99
+ ```
100
+
101
+ ### Message Counting
102
+
103
+ Use `quest.expectMessages()` in the preRequestScript to enable deterministic test counting:
104
+
105
+ ```json
106
+ {
107
+ "type": "request",
108
+ "id": "stream-events",
109
+ "name": "Stream Server Events",
110
+ "preRequestScript": "quest.expectMessages(5, 10000);",
111
+ "data": {
112
+ "url": "https://api.example.com/events",
113
+ "scripts": [
114
+ {
115
+ "event": "onMessage",
116
+ "script": "quest.test('Message received', () => {\n expect(quest.message.data).to.exist;\n});"
117
+ }
118
+ ]
119
+ }
120
+ }
121
+ ```
122
+
123
+ This informs the runner to expect 5 messages, enabling accurate test count reporting (5 messages × tests per message).
124
+
125
+ ## Response Handling
126
+
127
+ Access SSE data in scripts:
128
+
129
+ ```javascript
130
+ // In onMessage script
131
+ quest.test('Event has data', () => {
132
+ expect(quest.message.data).to.be.a('string');
133
+ });
134
+
135
+ quest.test('Event type is update', () => {
136
+ expect(quest.message.event).to.equal('update');
137
+ });
138
+
139
+ // In onComplete script
140
+ quest.test('Received all messages', () => {
141
+ expect(quest.messages.length).to.equal(5);
142
+ });
143
+
144
+ quest.test('All messages valid', () => {
145
+ quest.messages.forEach(msg => {
146
+ const data = JSON.parse(msg.data);
147
+ expect(data).to.have.property('id');
148
+ });
149
+ });
150
+ ```
151
+
152
+ ## Compatibility
153
+
154
+ - **Authentication:** Works with `@apiquest/plugin-auth` for Bearer, Basic, API Key
155
+ - **Node.js:** Requires Node.js 20+
156
+
157
+ ## Documentation
158
+
159
+ - [Fracture Documentation](https://apiquest.net/docs/fracture)
160
+ - [Schema Reference](https://apiquest.net/schemas/collection-v1.0.json)
161
+
162
+ ## License
163
+
164
+ Dual-licensed under AGPL-3.0-or-later and commercial license. See LICENSE.txt for details.
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAA2G,MAAM,iBAAiB,CAAC;AAkBhK,eAAO,MAAM,SAAS,EAAE,eA8WvB,CAAC;AAEF,eAAe,SAAS,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAA2G,MAAM,iBAAiB,CAAC;AAkBhK,eAAO,MAAM,SAAS,EAAE,eAuYvB,CAAC;AAEF,eAAe,SAAS,CAAC"}
package/dist/index.js CHANGED
@@ -95,9 +95,9 @@ const ssePlugin = {
95
95
  }, timeout);
96
96
  try {
97
97
  // Use fetch with streaming which is more universally supported in Node.js
98
- const signal = context.abortSignal || controller.signal;
98
+ const signal = context.abortSignal ?? controller.signal;
99
99
  // Handle abort signal
100
- if (context.abortSignal) {
100
+ if (context.abortSignal !== undefined && context.abortSignal !== null) {
101
101
  context.abortSignal.addEventListener('abort', () => {
102
102
  controller.abort();
103
103
  clearTimeout(timeoutId);
@@ -138,7 +138,7 @@ const ssePlugin = {
138
138
  });
139
139
  return;
140
140
  }
141
- if (!response.body) {
141
+ if (response.body === null || response.body === undefined) {
142
142
  clearTimeout(timeoutId);
143
143
  logger?.error('SSE response has no body');
144
144
  resolve({
@@ -155,15 +155,24 @@ const ssePlugin = {
155
155
  const reader = response.body.getReader();
156
156
  const decoder = new TextDecoder();
157
157
  let buffer = '';
158
- const processLine = async (line) => {
159
- if (line.startsWith('data:')) {
160
- const data = line.slice(5).trim();
161
- const message = { data };
158
+ // Temporary message fields that get compiled when we hit an empty line
159
+ let currentEventType;
160
+ let currentEventId;
161
+ let currentRetry;
162
+ const currentDataLines = [];
163
+ const dispatchCurrentMessage = async () => {
164
+ if (currentDataLines.length > 0) {
165
+ const message = {
166
+ data: currentDataLines.join('\n'),
167
+ event: currentEventType,
168
+ id: currentEventId,
169
+ retry: currentRetry
170
+ };
162
171
  messages.push(message);
163
172
  messageCount++;
164
- logger?.trace('SSE message received', { messageCount, data: data.slice(0, 100) });
173
+ logger?.trace('SSE message received', { messageCount, data: message.data.slice(0, 100) });
165
174
  // Emit onMessage event
166
- if (emitEvent) {
175
+ if (emitEvent !== undefined && emitEvent !== null) {
167
176
  try {
168
177
  await emitEvent('onMessage', {
169
178
  index: messageCount,
@@ -174,43 +183,56 @@ const ssePlugin = {
174
183
  logger?.error('SSE onMessage event error', { error: err instanceof Error ? err.message : String(err) });
175
184
  }
176
185
  }
186
+ // Reset temporary fields
187
+ currentEventType = undefined;
188
+ currentEventId = undefined;
189
+ currentRetry = undefined;
190
+ currentDataLines.length = 0;
191
+ }
192
+ };
193
+ const processLine = async (line) => {
194
+ // Empty line signals the end of an event
195
+ if (line === '') {
196
+ await dispatchCurrentMessage();
197
+ }
198
+ else if (line.startsWith('data:')) {
199
+ // Can have multiple data lines
200
+ const data = line.slice(5);
201
+ // Trim only the leading space if present (per spec)
202
+ currentDataLines.push(data.startsWith(' ') ? data.slice(1) : data);
177
203
  }
178
204
  else if (line.startsWith('event:')) {
179
- const lastMessage = messages[messages.length - 1];
180
- if (lastMessage) {
181
- lastMessage.event = line.slice(6).trim();
182
- }
205
+ currentEventType = line.slice(6).trim();
183
206
  }
184
207
  else if (line.startsWith('id:')) {
185
- const lastMessage = messages[messages.length - 1];
186
- if (lastMessage) {
187
- lastMessage.id = line.slice(3).trim();
188
- }
208
+ currentEventId = line.slice(3).trim();
189
209
  }
190
210
  else if (line.startsWith('retry:')) {
191
- const lastMessage = messages[messages.length - 1];
192
- if (lastMessage) {
193
- lastMessage.retry = parseInt(line.slice(6).trim(), 10);
211
+ const retryValue = parseInt(line.slice(6).trim(), 10);
212
+ if (!isNaN(retryValue)) {
213
+ currentRetry = retryValue;
194
214
  }
195
215
  }
216
+ // Lines starting with ':' are comments and should be ignored
217
+ // Other lines are ignored as well per spec
196
218
  };
197
219
  try {
198
220
  while (true) {
199
- const { done, value } = await reader.read();
221
+ const result = await reader.read();
222
+ const done = result.done;
223
+ const value = result.value;
200
224
  if (done) {
201
225
  // Process remaining buffer
202
- if (buffer.trim()) {
203
- const lines = buffer.split('\n');
204
- for (const line of lines) {
205
- if (line.trim()) {
206
- await processLine(line);
207
- }
208
- }
226
+ const lines = buffer.split('\n');
227
+ for (const line of lines) {
228
+ await processLine(line);
209
229
  }
230
+ // Flush any pending message
231
+ await dispatchCurrentMessage();
210
232
  clearTimeout(timeoutId);
211
233
  logger?.debug('SSE stream complete', { messageCount, duration: Date.now() - startTime });
212
234
  // Emit onComplete event
213
- if (emitEvent) {
235
+ if (emitEvent !== undefined && emitEvent !== null) {
214
236
  try {
215
237
  await emitEvent('onComplete', { messageCount, messages });
216
238
  }
@@ -230,14 +252,14 @@ const ssePlugin = {
230
252
  break;
231
253
  }
232
254
  // Decode chunk and add to buffer
233
- buffer += decoder.decode(value, { stream: true });
255
+ if (value !== undefined) {
256
+ buffer += decoder.decode(value, { stream: true });
257
+ }
234
258
  // Process complete lines
235
259
  const lines = buffer.split('\n');
236
- buffer = lines.pop() || ''; // Keep incomplete line in buffer
260
+ buffer = lines.pop() ?? ''; // Keep incomplete line in buffer
237
261
  for (const line of lines) {
238
- if (line.trim()) {
239
- await processLine(line);
240
- }
262
+ await processLine(line);
241
263
  }
242
264
  }
243
265
  }
@@ -260,7 +282,7 @@ const ssePlugin = {
260
282
  else {
261
283
  logger?.error('SSE stream error', { error: err instanceof Error ? err.message : String(err) });
262
284
  // Emit onError event
263
- if (emitEvent) {
285
+ if (emitEvent !== undefined && emitEvent !== null) {
264
286
  try {
265
287
  await emitEvent('onError', { error: err instanceof Error ? err.message : String(err) });
266
288
  }
@@ -284,7 +306,7 @@ const ssePlugin = {
284
306
  clearTimeout(timeoutId);
285
307
  logger?.error('SSE fetch error', { error: err instanceof Error ? err.message : String(err) });
286
308
  // Emit onError event
287
- if (emitEvent) {
309
+ if (emitEvent !== undefined && emitEvent !== null) {
288
310
  emitEvent('onError', { error: err instanceof Error ? err.message : String(err) }).catch((emitErr) => {
289
311
  logger?.error('SSE onError event error', { error: emitErr instanceof Error ? emitErr.message : String(emitErr) });
290
312
  });
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":["../src/index.ts"],"sourcesContent":[null],"names":[],"mappings":"AAEA;AAKA,SAAS,kBAAkB,CAAC,KAAgC,EAAA;AAC1D,IAAA,OAAO,KAAK,KAAK,IAAI,IAAI,KAAK,KAAK,SAAS,IAAI,KAAK,CAAC,IAAI,EAAE,KAAK,EAAE;AACrE;AASO,MAAM,SAAS,GAAoB;AACxC,IAAA,IAAI,EAAE,YAAY;AAClB,IAAA,OAAO,EAAE,OAAO;AAChB,IAAA,WAAW,EAAE,2CAA2C;;IAGxD,SAAS,EAAE,CAAC,KAAK,CAAC;;IAGlB,kBAAkB,EAAE,CAAC,QAAQ,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,CAAC;;AAGzD,IAAA,cAAc,EAAE,KAAK;;AAGrB,IAAA,UAAU,EAAE;AACV,QAAA,IAAI,EAAE,QAAQ;QACd,QAAQ,EAAE,CAAC,KAAK,CAAC;AACjB,QAAA,UAAU,EAAE;AACV,YAAA,GAAG,EAAE;AACH,gBAAA,IAAI,EAAE,QAAQ;AACd,gBAAA,WAAW,EAAE;AACd,aAAA;AACD,YAAA,OAAO,EAAE;AACP,gBAAA,IAAI,EAAE,QAAQ;AACd,gBAAA,WAAW,EAAE,oCAAoC;AACjD,gBAAA,OAAO,EAAE;AACV,aAAA;AACD,YAAA,OAAO,EAAE;AACP,gBAAA,IAAI,EAAE,QAAQ;AACd,gBAAA,WAAW,E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AA,MAAM,EAAE,CAAC;AACT,oBAAA,UAAU,EAAE,OAAO;AACnB,oBAAA,IAAI,EAAE,EAAE;AACR,oBAAA,OAAO,EAAE,EAAE;AACX,oBAAA,QAAQ,EAAE,IAAI,CAAC,GAAG,EAAE,GAAG,SAAS;AAChC,oBAAA,KAAK,EAAE,GAAG,YAAY,KAAK,GAAG,GAAG,CAAC,OAAO,GAAG,MAAM,CAAC,GAAG,CAAC;AACvD,oBAAA,YAAY,EAAE,CAAC;AACf,oBAAA,QAAQ,EAAE;AAC4D,iBAAA,CAAC;YAC3E;AACF,QAAA,CAAC,CAAC;IACJ,CAAC;IAED,QAAQ,CAAC,OAAgB,EAAE,OAAuB,EAAA;QAChD,MAAM,MAAM,GAAsB,EAAE;;AAGpC,QAAA,IAAI,OAAO,OAAO,CAAC,IAAI,CAAC,GAAG,KAAK,QAAQ,IAAI,kBAAkB,CAAC,OAAO,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE;YAChF,MAAM,CAAC,IAAI,CAAC;AACV,gBAAA,OAAO,EAAE,iBAAiB;AAC1B,gBAAA,QAAQ,EAAE,EAAE;AACZ,gBAAA,MAAM,EAAE;AACT,aAAA,CAAC;QACJ;AAEA,QAAA,IAAI,MAAM,CAAC,MAAM,GAAG,CAAC,EAAE;YACrB,OAAO;AACL,gBAAA,KAAK,EAAE,KAAK;gBACZ;aACD;QACH;AAEA,QAAA,OAAO,EAAE,KAAK,EAAE,IAAI,EAAE;IACxB;;;;;"}
package/esbuild.config.js CHANGED
@@ -1,34 +1,34 @@
1
- import esbuild from 'esbuild';
2
-
3
- await esbuild.build({
4
- entryPoints: ['src/index.ts'],
5
- bundle: true,
6
- outfile: 'dist/index.js',
7
- format: 'esm',
8
- platform: 'node',
9
- target: 'node18',
10
- // Externalize peerDependencies and Node.js built-ins
11
- external: [
12
- '@apiquest/fracture',
13
- // Node.js built-in modules (got depends on these)
14
- 'http',
15
- 'https',
16
- 'http2',
17
- 'net',
18
- 'tls',
19
- 'stream',
20
- 'util',
21
- 'url',
22
- 'zlib',
23
- 'events',
24
- 'buffer',
25
- 'querystring',
26
- 'dns',
27
- 'fs',
28
- 'path',
29
- ],
30
- minify: false,
31
- sourcemap: true,
32
- });
33
-
34
- console.log('✓ Built plugin-sse');
1
+ import esbuild from 'esbuild';
2
+
3
+ await esbuild.build({
4
+ entryPoints: ['src/index.ts'],
5
+ bundle: true,
6
+ outfile: 'dist/index.js',
7
+ format: 'esm',
8
+ platform: 'node',
9
+ target: 'node18',
10
+ // Externalize peerDependencies and Node.js built-ins
11
+ external: [
12
+ '@apiquest/fracture',
13
+ // Node.js built-in modules (got depends on these)
14
+ 'http',
15
+ 'https',
16
+ 'http2',
17
+ 'net',
18
+ 'tls',
19
+ 'stream',
20
+ 'util',
21
+ 'url',
22
+ 'zlib',
23
+ 'events',
24
+ 'buffer',
25
+ 'querystring',
26
+ 'dns',
27
+ 'fs',
28
+ 'path',
29
+ ],
30
+ minify: false,
31
+ sourcemap: true,
32
+ });
33
+
34
+ console.log('✓ Built plugin-sse');
package/package.json CHANGED
@@ -1,62 +1,66 @@
1
- {
2
- "name": "@apiquest/plugin-sse",
3
- "version": "1.0.2",
4
- "description": "SSE protocol plugin for Quest",
5
- "main": "dist/index.js",
6
- "types": "dist/index.d.ts",
7
- "type": "module",
8
- "scripts": {
9
- "build": "rollup -c && tsc --emitDeclarationOnly",
10
- "dev": "rollup -c --watch",
11
- "test": "vitest"
12
- },
13
- "keywords": [
14
- "api",
15
- "http",
16
- "quest",
17
- "plugin"
18
- ],
19
- "author": "ApiQuest",
20
- "license": "AGPL-3.0-or-later",
21
- "dependencies": {
22
- "got": "^14.6.6",
23
- "hpagent": "^1.2.0"
24
- },
25
- "devDependencies": {
26
- "@apiquest/types": "workspace:*",
27
- "@rollup/plugin-commonjs": "^25.0.0",
28
- "@rollup/plugin-node-resolve": "^15.0.0",
29
- "@rollup/plugin-typescript": "^11.0.0",
30
- "@types/node": "^20.10.6",
31
- "rollup": "^4.0.0",
32
- "typescript": "^5.3.3",
33
- "vitest": "^4.0.18"
34
- },
35
- "peerDependencies": {
36
- "@apiquest/types": "^1.0.0"
37
- },
38
- "apiquest": {
39
- "type": "protocol",
40
- "runtime": [
41
- "fracture"
42
- ],
43
- "capabilities": {
44
- "provides": {
45
- "protocols": [
46
- "sse"
47
- ]
48
- },
49
- "supports": {
50
- "authTypes": [
51
- "bearer",
52
- "basic",
53
- "oauth2",
54
- "apikey",
55
- "digest",
56
- "ntlm"
57
- ],
58
- "strictAuthList": false
59
- }
60
- }
61
- }
62
- }
1
+ {
2
+ "name": "@apiquest/plugin-sse",
3
+ "version": "1.0.5",
4
+ "description": "SSE protocol plugin for ApiQuest",
5
+ "main": "dist/index.js",
6
+ "types": "dist/index.d.ts",
7
+ "type": "module",
8
+ "repository": {
9
+ "type": "git",
10
+ "url": "https://github.com/hh-apiquest/fracture.git",
11
+ "directory": "packages/plugin-sse"
12
+ },
13
+ "scripts": {
14
+ "build": "rollup -c && tsc --emitDeclarationOnly",
15
+ "dev": "rollup -c --watch",
16
+ "test": "vitest"
17
+ },
18
+ "keywords": [
19
+ "api",
20
+ "http",
21
+ "quest",
22
+ "plugin"
23
+ ],
24
+ "author": "ApiQuest",
25
+ "license": "AGPL-3.0-or-later",
26
+ "dependencies": {
27
+ "got": "^14.6.6",
28
+ "hpagent": "^1.2.0"
29
+ },
30
+ "devDependencies": {
31
+ "@apiquest/types": "workspace:*",
32
+ "@rollup/plugin-commonjs": "^29.0.0",
33
+ "@rollup/plugin-node-resolve": "^16.0.3",
34
+ "@rollup/plugin-typescript": "^12.3.0",
35
+ "@types/node": "^25.2.3",
36
+ "rollup": "^4.57.1",
37
+ "typescript": "^5.3.3",
38
+ "vitest": "^4.0.18"
39
+ },
40
+ "peerDependencies": {
41
+ "@apiquest/types": "^1.0.0"
42
+ },
43
+ "apiquest": {
44
+ "type": "protocol",
45
+ "runtime": [
46
+ "fracture"
47
+ ],
48
+ "capabilities": {
49
+ "provides": {
50
+ "protocols": [
51
+ "sse"
52
+ ]
53
+ },
54
+ "supports": {
55
+ "authTypes": [
56
+ "bearer",
57
+ "basic",
58
+ "oauth2",
59
+ "apikey",
60
+ "digest",
61
+ "ntlm"
62
+ ]
63
+ }
64
+ }
65
+ }
66
+ }
package/rollup.config.js CHANGED
@@ -1,31 +1,31 @@
1
- import typescript from '@rollup/plugin-typescript';
2
- import resolve from '@rollup/plugin-node-resolve';
3
- import commonjs from '@rollup/plugin-commonjs';
4
-
5
- export default {
6
- input: 'src/index.ts',
7
- output: {
8
- file: 'dist/index.js',
9
- format: 'esm',
10
- sourcemap: true,
11
- },
12
- external: [
13
- // Externalize peer dependencies
14
- '@apiquest/fracture',
15
- ],
16
- plugins: [
17
- // Resolve node modules
18
- resolve({
19
- preferBuiltins: true, // Prefer Node.js built-in modules
20
- exportConditions: ['node', 'import', 'default'],
21
- }),
22
- // Convert CommonJS to ESM (for any CJS dependencies)
23
- commonjs(),
24
- // Compile TypeScript
25
- typescript({
26
- tsconfig: './tsconfig.json',
27
- sourceMap: true,
28
- declaration: false, // We'll use tsc for declarations
29
- }),
30
- ],
31
- };
1
+ import typescript from '@rollup/plugin-typescript';
2
+ import resolve from '@rollup/plugin-node-resolve';
3
+ import commonjs from '@rollup/plugin-commonjs';
4
+
5
+ export default {
6
+ input: 'src/index.ts',
7
+ output: {
8
+ file: 'dist/index.js',
9
+ format: 'esm',
10
+ sourcemap: true,
11
+ },
12
+ external: [
13
+ // Externalize peer dependencies
14
+ '@apiquest/fracture',
15
+ ],
16
+ plugins: [
17
+ // Resolve node modules
18
+ resolve({
19
+ preferBuiltins: true, // Prefer Node.js built-in modules
20
+ exportConditions: ['node', 'import', 'default'],
21
+ }),
22
+ // Convert CommonJS to ESM (for any CJS dependencies)
23
+ commonjs(),
24
+ // Compile TypeScript
25
+ typescript({
26
+ tsconfig: './tsconfig.json',
27
+ sourceMap: true,
28
+ declaration: false, // We'll use tsc for declarations
29
+ }),
30
+ ],
31
+ };
package/tsconfig.json CHANGED
@@ -1,20 +1,20 @@
1
- {
2
- "compilerOptions": {
3
- "target": "ES2022",
4
- "module": "ES2022",
5
- "lib": ["ES2022"],
6
- "moduleResolution": "bundler",
7
- "outDir": "./dist",
8
- "declaration": true,
9
- "declarationMap": true,
10
- "sourceMap": true,
11
- "strict": true,
12
- "esModuleInterop": true,
13
- "skipLibCheck": true,
14
- "forceConsistentCasingInFileNames": true,
15
- "resolveJsonModule": true,
16
- "allowSyntheticDefaultImports": true
17
- },
18
- "include": ["src/**/*"],
19
- "exclude": ["node_modules", "dist", "tests"]
20
- }
1
+ {
2
+ "compilerOptions": {
3
+ "target": "ES2022",
4
+ "module": "ES2022",
5
+ "lib": ["ES2022"],
6
+ "moduleResolution": "bundler",
7
+ "outDir": "./dist",
8
+ "declaration": true,
9
+ "declarationMap": true,
10
+ "sourceMap": true,
11
+ "strict": true,
12
+ "esModuleInterop": true,
13
+ "skipLibCheck": true,
14
+ "forceConsistentCasingInFileNames": true,
15
+ "resolveJsonModule": true,
16
+ "allowSyntheticDefaultImports": true
17
+ },
18
+ "include": ["src/**/*"],
19
+ "exclude": ["node_modules", "dist", "tests"]
20
+ }
@@ -1,5 +1,5 @@
1
- {
2
- "extends": "./tsconfig.json",
3
- "include": ["tests/**/*"],
4
- "exclude": []
5
- }
1
+ {
2
+ "extends": "./tsconfig.json",
3
+ "include": ["tests/**/*"],
4
+ "exclude": []
5
+ }
package/vitest.config.ts CHANGED
@@ -1,12 +1,12 @@
1
- import { defineConfig } from 'vitest/config';
2
-
3
- export default defineConfig({
4
- test: {
5
- globals: true,
6
- environment: 'node',
7
- coverage: {
8
- provider: 'v8',
9
- reporter: ['text', 'json', 'html'],
10
- },
11
- },
12
- });
1
+ import { defineConfig } from 'vitest/config';
2
+
3
+ export default defineConfig({
4
+ test: {
5
+ globals: true,
6
+ environment: 'node',
7
+ coverage: {
8
+ provider: 'v8',
9
+ reporter: ['text', 'json', 'html'],
10
+ },
11
+ },
12
+ });
@@ -1,4 +0,0 @@
1
- import type { IProtocolPlugin } from '@apiquest/types';
2
- export declare const httpPlugin: IProtocolPlugin;
3
- export default httpPlugin;
4
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,eAAe,EAA2G,MAAM,iBAAiB,CAAC;AAmBhK,eAAO,MAAM,UAAU,EAAE,eAmRxB,CAAC;AAEF,eAAe,UAAU,CAAC"}
package/src/index.ts DELETED
@@ -1,412 +0,0 @@
1
- import type { IProtocolPlugin, Request, ExecutionContext, ProtocolResponse, ValidationResult, ValidationError, RuntimeOptions, ILogger } from '@apiquest/types';
2
-
3
- // Helper functions for string validation
4
- function isNullOrEmpty(value: string | null | undefined): boolean {
5
- return value === null || value === undefined || value === '';
6
- }
7
-
8
- function isNullOrWhitespace(value: string | null | undefined): boolean {
9
- return value === null || value === undefined || value.trim() === '';
10
- }
11
-
12
- interface SSEMessage {
13
- data: string;
14
- event?: string;
15
- id?: string;
16
- retry?: number;
17
- }
18
-
19
- export const ssePlugin: IProtocolPlugin = {
20
- name: 'SSE Client',
21
- version: '1.0.0',
22
- description: 'Server-Sent Events (SSE) protocol support',
23
-
24
- // What protocols this plugin provides
25
- protocols: ['sse'],
26
-
27
- // Supported authentication types
28
- supportedAuthTypes: ['bearer', 'basic', 'apikey', 'none'],
29
-
30
- // Accept additional auth plugins beyond the listed types
31
- strictAuthList: false,
32
-
33
- // Data schema for SSE requests
34
- dataSchema: {
35
- type: 'object',
36
- required: ['url'],
37
- properties: {
38
- url: {
39
- type: 'string',
40
- description: 'SSE endpoint URL'
41
- },
42
- timeout: {
43
- type: 'number',
44
- description: 'Connection timeout in milliseconds',
45
- default: 30000
46
- },
47
- headers: {
48
- type: 'object',
49
- description: 'HTTP headers',
50
- additionalProperties: { type: 'string' }
51
- }
52
- }
53
- },
54
-
55
- // Options schema for runtime configuration
56
- optionsSchema: {
57
- timeout: {
58
- type: 'number',
59
- default: 30000,
60
- description: 'Request timeout in milliseconds'
61
- }
62
- },
63
-
64
- // Plugin events
65
- events: [
66
- {
67
- name: 'onMessage',
68
- description: 'Fired when an SSE message is received',
69
- canHaveTests: true,
70
- required: false
71
- },
72
- {
73
- name: 'onError',
74
- description: 'Fired when an error occurs during streaming',
75
- canHaveTests: false,
76
- required: false
77
- },
78
- {
79
- name: 'onComplete',
80
- description: 'Fired when the SSE stream completes',
81
- canHaveTests: true,
82
- required: false
83
- }
84
- ],
85
-
86
- async execute(request: Request, context: ExecutionContext, options: RuntimeOptions, emitEvent?: (eventName: string, eventData: unknown) => Promise<void>, logger?: ILogger): Promise<ProtocolResponse> {
87
- const startTime = Date.now();
88
- const url = String(request.data.url ?? '');
89
-
90
- if (isNullOrWhitespace(url)) {
91
- logger?.error('SSE request missing URL');
92
- throw new Error('URL is required for SSE requests');
93
- }
94
-
95
- const headers: Record<string, string> = typeof request.data.headers === 'object' && request.data.headers !== null
96
- ? Object.fromEntries(
97
- Object.entries(request.data.headers as Record<string, unknown>).map(([k, v]) => [k, String(v)])
98
- )
99
- : {};
100
-
101
- const sseOptions: Record<string, unknown> = (options.plugins?.sse as Record<string, unknown> | null | undefined) ?? {};
102
- const sseTimeout = typeof sseOptions.timeout === 'number' ? sseOptions.timeout : null;
103
- const timeout = (typeof request.data.timeout === 'number' ? request.data.timeout : null) ?? options.timeout?.request ?? sseTimeout ?? 30000;
104
-
105
- logger?.debug('SSE request starting', { url, timeout });
106
-
107
- const messages: SSEMessage[] = [];
108
- let messageCount = 0;
109
-
110
- return new Promise<ProtocolResponse>((resolve, reject) => {
111
- const controller = new AbortController();
112
-
113
- const timeoutId = setTimeout(() => {
114
- controller.abort();
115
- logger?.debug('SSE connection timeout', { url, messageCount, duration: Date.now() - startTime });
116
-
117
- resolve({
118
- status: 200,
119
- statusText: 'Stream Complete (Timeout)',
120
- body: JSON.stringify({ messages, count: messageCount }),
121
- headers: {},
122
- duration: Date.now() - startTime,
123
- messageCount,
124
- messages
125
- } as ProtocolResponse & { messageCount: number; messages: SSEMessage[] });
126
- }, timeout);
127
-
128
- try {
129
- // Use fetch with streaming which is more universally supported in Node.js
130
- const signal = context.abortSignal ?? controller.signal;
131
-
132
- // Handle abort signal
133
- if (context.abortSignal !== undefined && context.abortSignal !== null) {
134
- context.abortSignal.addEventListener('abort', () => {
135
- controller.abort();
136
- clearTimeout(timeoutId);
137
- logger?.debug('SSE request aborted', { url, messageCount, duration: Date.now() - startTime });
138
- resolve({
139
- status: 0,
140
- statusText: 'Aborted',
141
- body: JSON.stringify({ messages, count: messageCount }),
142
- headers: {},
143
- duration: Date.now() - startTime,
144
- error: 'Request aborted',
145
- messageCount,
146
- messages
147
- } as ProtocolResponse & { messageCount: number; messages: SSEMessage[] });
148
- });
149
- }
150
-
151
- // Use fetch with streaming
152
- fetch(url, {
153
- method: 'GET',
154
- headers: {
155
- ...headers,
156
- 'Accept': 'text/event-stream',
157
- 'Cache-Control': 'no-cache'
158
- },
159
- signal
160
- }).then(async (response) => {
161
- if (!response.ok) {
162
- clearTimeout(timeoutId);
163
- logger?.warn('SSE connection failed', { status: response.status, statusText: response.statusText });
164
- resolve({
165
- status: response.status,
166
- statusText: response.statusText,
167
- body: await response.text(),
168
- headers: Object.fromEntries(response.headers.entries()),
169
- duration: Date.now() - startTime,
170
- messageCount: 0,
171
- messages: []
172
- } as ProtocolResponse & { messageCount: number; messages: SSEMessage[] });
173
- return;
174
- }
175
-
176
- if (response.body === null || response.body === undefined) {
177
- clearTimeout(timeoutId);
178
- logger?.error('SSE response has no body');
179
- resolve({
180
- status: response.status,
181
- statusText: 'No Body',
182
- body: '',
183
- headers: Object.fromEntries(response.headers.entries()),
184
- duration: Date.now() - startTime,
185
- messageCount: 0,
186
- messages: []
187
- } as ProtocolResponse & { messageCount: number; messages: SSEMessage[] });
188
- return;
189
- }
190
-
191
- const reader = response.body.getReader();
192
- const decoder = new TextDecoder();
193
- let buffer = '';
194
-
195
- // Temporary message fields that get compiled when we hit an empty line
196
- let currentEventType: string | undefined;
197
- let currentEventId: string | undefined;
198
- let currentRetry: number | undefined;
199
- const currentDataLines: string[] = [];
200
-
201
- const dispatchCurrentMessage = async (): Promise<void> => {
202
- if (currentDataLines.length > 0) {
203
- const message: SSEMessage = {
204
- data: currentDataLines.join('\n'),
205
- event: currentEventType,
206
- id: currentEventId,
207
- retry: currentRetry
208
- };
209
-
210
- messages.push(message);
211
- messageCount++;
212
-
213
- logger?.trace('SSE message received', { messageCount, data: message.data.slice(0, 100) });
214
-
215
- // Emit onMessage event
216
- if (emitEvent !== undefined && emitEvent !== null) {
217
- try {
218
- await emitEvent('onMessage', {
219
- index: messageCount,
220
- data: message
221
- });
222
- } catch (err) {
223
- logger?.error('SSE onMessage event error', { error: err instanceof Error ? err.message : String(err) });
224
- }
225
- }
226
-
227
- // Reset temporary fields
228
- currentEventType = undefined;
229
- currentEventId = undefined;
230
- currentRetry = undefined;
231
- currentDataLines.length = 0;
232
- }
233
- };
234
-
235
- const processLine = async (line: string): Promise<void> => {
236
- // Empty line signals the end of an event
237
- if (line === '') {
238
- await dispatchCurrentMessage();
239
- } else if (line.startsWith('data:')) {
240
- // Can have multiple data lines
241
- const data = line.slice(5);
242
- // Trim only the leading space if present (per spec)
243
- currentDataLines.push(data.startsWith(' ') ? data.slice(1) : data);
244
- } else if (line.startsWith('event:')) {
245
- currentEventType = line.slice(6).trim();
246
- } else if (line.startsWith('id:')) {
247
- currentEventId = line.slice(3).trim();
248
- } else if (line.startsWith('retry:')) {
249
- const retryValue = parseInt(line.slice(6).trim(), 10);
250
- if (!isNaN(retryValue)) {
251
- currentRetry = retryValue;
252
- }
253
- }
254
- // Lines starting with ':' are comments and should be ignored
255
- // Other lines are ignored as well per spec
256
- };
257
-
258
- try {
259
- while (true) {
260
- const result = await reader.read();
261
- const done = result.done;
262
- const value: Uint8Array | undefined = result.value as Uint8Array | undefined;
263
-
264
- if (done) {
265
- // Process remaining buffer
266
- const lines = buffer.split('\n');
267
- for (const line of lines) {
268
- await processLine(line);
269
- }
270
- // Flush any pending message
271
- await dispatchCurrentMessage();
272
-
273
- clearTimeout(timeoutId);
274
- logger?.debug('SSE stream complete', { messageCount, duration: Date.now() - startTime });
275
-
276
- // Emit onComplete event
277
- if (emitEvent !== undefined && emitEvent !== null) {
278
- try {
279
- await emitEvent('onComplete', { messageCount, messages });
280
- } catch (err) {
281
- logger?.error('SSE onComplete event error', { error: err instanceof Error ? err.message : String(err) });
282
- }
283
- }
284
-
285
- resolve({
286
- status: response.status,
287
- statusText: 'Stream Complete',
288
- body: JSON.stringify({ messages, count: messageCount }),
289
- headers: Object.fromEntries(response.headers.entries()),
290
- duration: Date.now() - startTime,
291
- messageCount,
292
- messages
293
- } as ProtocolResponse & { messageCount: number; messages: SSEMessage[] });
294
- break;
295
- }
296
-
297
- // Decode chunk and add to buffer
298
- if (value !== undefined) {
299
- buffer += decoder.decode(value, { stream: true });
300
- }
301
-
302
- // Process complete lines
303
- const lines = buffer.split('\n');
304
- buffer = lines.pop() ?? ''; // Keep incomplete line in buffer
305
-
306
- for (const line of lines) {
307
- await processLine(line);
308
- }
309
- }
310
- } catch (err) {
311
- clearTimeout(timeoutId);
312
-
313
- // Check if it was aborted
314
- if (signal.aborted) {
315
- logger?.debug('SSE stream aborted', { messageCount, duration: Date.now() - startTime });
316
- resolve({
317
- status: 0,
318
- statusText: 'Aborted',
319
- body: JSON.stringify({ messages, count: messageCount }),
320
- headers: {},
321
- duration: Date.now() - startTime,
322
- error: 'Request aborted',
323
- messageCount,
324
- messages
325
- } as ProtocolResponse & { messageCount: number; messages: SSEMessage[] });
326
- } else {
327
- logger?.error('SSE stream error', { error: err instanceof Error ? err.message : String(err) });
328
-
329
- // Emit onError event
330
- if (emitEvent !== undefined && emitEvent !== null) {
331
- try {
332
- await emitEvent('onError', { error: err instanceof Error ? err.message : String(err) });
333
- } catch (emitErr) {
334
- logger?.error('SSE onError event error', { error: emitErr instanceof Error ? emitErr.message : String(emitErr) });
335
- }
336
- }
337
-
338
- resolve({
339
- status: 0,
340
- statusText: 'Stream Error',
341
- body: JSON.stringify({ messages, count: messageCount }),
342
- headers: {},
343
- duration: Date.now() - startTime,
344
- error: err instanceof Error ? err.message : String(err),
345
- messageCount,
346
- messages
347
- } as ProtocolResponse & { messageCount: number; messages: SSEMessage[] });
348
- }
349
- }
350
- }).catch((err) => {
351
- clearTimeout(timeoutId);
352
- logger?.error('SSE fetch error', { error: err instanceof Error ? err.message : String(err) });
353
-
354
- // Emit onError event
355
- if (emitEvent !== undefined && emitEvent !== null) {
356
- emitEvent('onError', { error: err instanceof Error ? err.message : String(err) }).catch((emitErr) => {
357
- logger?.error('SSE onError event error', { error: emitErr instanceof Error ? emitErr.message : String(emitErr) });
358
- });
359
- }
360
-
361
- resolve({
362
- status: 0,
363
- statusText: 'Connection Error',
364
- body: '',
365
- headers: {},
366
- duration: Date.now() - startTime,
367
- error: err instanceof Error ? err.message : String(err),
368
- messageCount: 0,
369
- messages: []
370
- } as ProtocolResponse & { messageCount: number; messages: SSEMessage[] });
371
- });
372
- } catch (err) {
373
- clearTimeout(timeoutId);
374
- logger?.error('SSE unexpected error', { error: err instanceof Error ? err.message : String(err) });
375
- resolve({
376
- status: 0,
377
- statusText: 'Error',
378
- body: '',
379
- headers: {},
380
- duration: Date.now() - startTime,
381
- error: err instanceof Error ? err.message : String(err),
382
- messageCount: 0,
383
- messages: []
384
- } as ProtocolResponse & { messageCount: number; messages: SSEMessage[] });
385
- }
386
- });
387
- },
388
-
389
- validate(request: Request, options: RuntimeOptions): ValidationResult {
390
- const errors: ValidationError[] = [];
391
-
392
- // Check URL
393
- if (typeof request.data.url !== 'string' || isNullOrWhitespace(request.data.url)) {
394
- errors.push({
395
- message: 'URL is required',
396
- location: '',
397
- source: 'protocol'
398
- });
399
- }
400
-
401
- if (errors.length > 0) {
402
- return {
403
- valid: false,
404
- errors
405
- };
406
- }
407
-
408
- return { valid: true };
409
- }
410
- };
411
-
412
- export default ssePlugin;