{"id":13541208,"url":"https://github.com/cablehead/nu_plugin_from_sse","last_synced_at":"2025-08-07T01:31:07.185Z","repository":{"id":224861845,"uuid":"764430598","full_name":"cablehead/nu_plugin_from_sse","owner":"cablehead","description":"Nushell plugin to parse a stream of HTTP server sent events","archived":false,"fork":false,"pushed_at":"2024-11-11T05:08:18.000Z","size":241,"stargazers_count":8,"open_issues_count":2,"forks_count":1,"subscribers_count":2,"default_branch":"main","last_synced_at":"2024-12-08T20:43:22.024Z","etag":null,"topics":["http","nushell","nushell-plugin","pipeline","server-sent-events","shell","streaming"],"latest_commit_sha":null,"homepage":"","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/cablehead.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-02-28T03:58:15.000Z","updated_at":"2024-11-11T05:08:21.000Z","dependencies_parsed_at":"2024-05-29T16:44:13.716Z","dependency_job_id":"9463ec42-4382-4a4c-8bf4-e3456b56203c","html_url":"https://github.com/cablehead/nu_plugin_from_sse","commit_stats":null,"previous_names":["cablehead/nu_plugin_from_sse"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cablehead%2Fnu_plugin_from_sse","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cablehead%2Fnu_plugin_from_sse/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cablehead%2Fnu_plugin_from_sse/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cablehead%2Fnu_plugin_from_sse/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/cablehead","download_url":"https://codeload.github.com/cablehead/nu_plugin_from_sse/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":228976854,"owners_count":18000695,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["http","nushell","nushell-plugin","pipeline","server-sent-events","shell","streaming"],"created_at":"2024-08-01T10:00:41.437Z","updated_at":"2025-08-07T01:31:07.176Z","avatar_url":"https://github.com/cablehead.png","language":"Rust","funding_links":[],"categories":["Plugins"],"sub_categories":[],"readme":"As of Nushell [0.102.0](https://www.nushell.sh/blog/2025-02-04-nushell_0_102_0.html#generate-with-input-toc) `nu`'s [`generate`](https://www.nushell.sh/commands/docs/generate.html) command now supports stateful aggregation and downstream of streaming input. This means a plugin for things like `from sse` is no longer required. You can achieve the same result with a custom command similar to:\n\n```nushell\nexport def \"from sse\" [] {\n  lines | generate {|line pending = {data: []}|\n\n    match ($line | split row -n 2 \":\" | each { str trim }) {\n      [$prefix $content] if $prefix == \"id\" =\u003e {\n        return {next: ($pending | upsert id $content)}\n      }\n\n      [$prefix $content] if $prefix == \"event\" =\u003e {\n        return {next: ($pending | upsert event $content)}\n      }\n\n      [$prefix $content] if $prefix == \"data\" =\u003e {\n        return {next: ($pending | update data { append $content })}\n      }\n\n      [$empty] if $empty == \"\" =\u003e {\n        if ($pending == {data: []}) {\n          return {next: $pending}\n        }\n        return {next: {data: []} out: ($pending | update data { str join \"\\n\" })}\n      }\n\n      _ =\u003e { error make {msg: $\"unexpected: ($line)\"} }\n    }\n  }\n}\n```\n\n\n# [`nu`](https://www.nushell.sh) [streaming plugin](https://www.nushell.sh/blog/2024-03-05-nushell_0_91_0.html#plugin-protocol-overhaul-toc): `nu_plugin_from_sse`\n\nThis plugin was forked from the\n[nu_plugin_example](https://github.com/nushell/nushell/blob/main/crates/nu_plugin_example/src/commands/sum.rs).\n\n## Install with Cargo\n\nFrom within nushell:\n\n    cargo install --locked nu_plugin_from_sse\n    plugin add ~/.cargo/bin/nu_plugin_from_sse\n    # and then restart nu or use plugin add to activate\n\n## Usage\n\n`nu_plugin_from_sse` provides one command:\n\n\n### `from sse`\n\nThis command transforms HTTP SSE (Server-Sent Events) into structured records with the shape:\n\n```plaintext\n{\n  id: string,    // Unique identifier for the SSE event\n  event: string, // Type of event\n  data: string   // Data payload of the event\n}\n```\n\n#### known issue: nu table buffering [#12129](https://github.com/nushell/nushell/issues/12129)\n\nIf your SSE endpoint dispatches initial events upon connection, then\npauses—awaiting rare updates—you won't see any output until the first new\nupdate after connecting. This behavior is due to nu's [table buffering\nmechanism](https://github.com/nushell/nushell/blob/65e5abaa3e48126ff730c9a59e5f6f55777a85bd/crates/nu-command/src/viewers/table.rs#L846-L875),\nwhere a duration timeout is factored in only during active input processing.\n\nAn easy workaround for this issue is to pipe to\n[`each`](https://www.nushell.sh/commands/docs/each.html).\n\n#### example\n\nCopy this text to your clipboard:\n\n```\nevent: creatureAlert\nid: 1\ndata: {\"id\":\"uni123\",\"type\":\"Unicorn\",\"lat\":45.4235,\"lon\":-75.6979,\"urgency\":\"high\",\"desc\":\"Injured near Crystal River.\"}\n\n\n```\n\nUse [`bp`](https://github.com/printfn/bp) to pipe it:\n\n```nushell\nbp | from sse | update data { from json }\n````\n\n![output](./docs/out.png)\n\n#### live example\n\n```nushell\nhttp get https://ndyg.cross.stream/projects/enchanted-animal-rescue/rescue-feed |\n    from sse |\n    update data { from json }\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcablehead%2Fnu_plugin_from_sse","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcablehead%2Fnu_plugin_from_sse","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcablehead%2Fnu_plugin_from_sse/lists"}