@morscherlab/mint-sdk 1.0.52 → 1.0.53

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@morscherlab/mint-sdk",
3
- "version": "1.0.52",
3
+ "version": "1.0.53",
4
4
  "description": "MINT Platform SDK — Vue 3 components, composables, and types for plugin development. MINT = Mass-spec INtegrated Toolkit.",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -578,6 +578,54 @@ describe('usePluginClient', () => {
578
578
  expect(onMessage.mock.calls[0]![0].data).toEqual({ job_id: 'fit' })
579
579
  })
580
580
 
581
+ it('should deliver terminal enrichment on the original generated stream', async () => {
582
+ type JobStreamData = {
583
+ jobs?: Array<Record<string, unknown>>
584
+ job_id?: string
585
+ can_delete?: boolean
586
+ output_path?: string | null
587
+ }
588
+ const onMessage = vi.fn()
589
+ const streamBody = new ReadableStream({
590
+ start(controller) {
591
+ controller.enqueue(new TextEncoder().encode(
592
+ 'event: snapshot\ndata: {"jobs":[{"job_id":"fit","can_delete":false,"output_path":null}]}\n\n'
593
+ + 'event: terminal\ndata: {"job_id":"fit","can_delete":true,"output_path":"/results/final.csv"}\n\n',
594
+ ))
595
+ controller.close()
596
+ },
597
+ })
598
+ const fetchMock = vi.fn(async () => new Response(streamBody, { status: 200 }))
599
+ vi.stubGlobal('fetch', fetchMock)
600
+
601
+ const stream = usePluginEventStream<JobStreamData>(
602
+ contract,
603
+ {
604
+ method: 'get',
605
+ path: '/jobs/events',
606
+ eventStream: true,
607
+ responseType: 'JobStatePayload | JobSnapshotPayload',
608
+ },
609
+ { reconnect: false, onMessage },
610
+ )
611
+
612
+ await vi.waitFor(() => {
613
+ expect({
614
+ fetches: fetchMock.mock.calls.length,
615
+ events: onMessage.mock.calls.map(([message]) => message.event),
616
+ last: stream.lastMessage.value?.data,
617
+ }).toEqual({
618
+ fetches: 1,
619
+ events: ['snapshot', 'terminal'],
620
+ last: {
621
+ job_id: 'fit',
622
+ can_delete: true,
623
+ output_path: '/results/final.csv',
624
+ },
625
+ })
626
+ })
627
+ })
628
+
581
629
  it('keeps generated string event streams as text by default', async () => {
582
630
  const onMessage = vi.fn()
583
631
  const streamBody = new ReadableStream({