{"id":18487001,"url":"https://github.com/valeriansaliou/node-sonic-channel","last_synced_at":"2025-05-16T11:04:22.501Z","repository":{"id":38326210,"uuid":"172715011","full_name":"valeriansaliou/node-sonic-channel","owner":"valeriansaliou","description":"🦉 Sonic Channel integration for Node. Used in pair with Sonic, the fast, lightweight and schema-less search backend.","archived":false,"fork":false,"pushed_at":"2025-01-06T21:18:55.000Z","size":117,"stargazers_count":148,"open_issues_count":2,"forks_count":9,"subscribers_count":6,"default_branch":"master","last_synced_at":"2025-05-10T10:17:31.104Z","etag":null,"topics":["graph","index","nodejs","npm","npm-package","search","sonic"],"latest_commit_sha":null,"homepage":"https://www.npmjs.com/package/sonic-channel","language":"JavaScript","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/valeriansaliou.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","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":"2019-02-26T13:17:35.000Z","updated_at":"2025-01-06T21:18:59.000Z","dependencies_parsed_at":"2023-11-06T09:45:59.951Z","dependency_job_id":"9125848c-6ad1-4d0b-b2fe-22e215319017","html_url":"https://github.com/valeriansaliou/node-sonic-channel","commit_stats":{"total_commits":86,"total_committers":3,"mean_commits":"28.666666666666668","dds":"0.023255813953488413","last_synced_commit":"1136427ef62106e9d5327f9fffe6dd45b4ee91b8"},"previous_names":[],"tags_count":36,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/valeriansaliou%2Fnode-sonic-channel","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/valeriansaliou%2Fnode-sonic-channel/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/valeriansaliou%2Fnode-sonic-channel/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/valeriansaliou%2Fnode-sonic-channel/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/valeriansaliou","download_url":"https://codeload.github.com/valeriansaliou/node-sonic-channel/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254518384,"owners_count":22084374,"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":["graph","index","nodejs","npm","npm-package","search","sonic"],"created_at":"2024-11-06T12:50:03.028Z","updated_at":"2025-05-16T11:04:22.479Z","avatar_url":"https://github.com/valeriansaliou.png","language":"JavaScript","funding_links":["https://www.buymeacoffee.com/valeriansaliou"],"categories":["JavaScript"],"sub_categories":[],"readme":"# node-sonic-channel\n\n[![Test and Build](https://github.com/valeriansaliou/node-sonic-channel/workflows/Test%20and%20Build/badge.svg?branch=master)](https://github.com/valeriansaliou/node-sonic-channel/actions?query=workflow%3A%22Test+and+Build%22) [![Build and Release](https://github.com/valeriansaliou/node-sonic-channel/workflows/Build%20and%20Release/badge.svg)](https://github.com/valeriansaliou/node-sonic-channel/actions?query=workflow%3A%22Build+and+Release%22) [![NPM](https://img.shields.io/npm/v/sonic-channel.svg)](https://www.npmjs.com/package/sonic-channel) [![Downloads](https://img.shields.io/npm/dt/sonic-channel.svg)](https://www.npmjs.com/package/sonic-channel) [![Buy Me A Coffee](https://img.shields.io/badge/buy%20me%20a%20coffee-donate-yellow.svg)](https://www.buymeacoffee.com/valeriansaliou)\n\n**Sonic Channel integration for Node. Used in pair with Sonic, the fast, lightweight and schema-less search backend.**\n\nSonic Channel lets you manage your Sonic search index, from your NodeJS code. Query your index and get search results, push entries to your index and pop them programmatically.\n\n**🇫🇷 Crafted in Nantes, France.**\n\n## Who uses it?\n\n\u003ctable\u003e\n\u003ctr\u003e\n\u003ctd align=\"center\"\u003e\u003ca href=\"https://crisp.chat/\"\u003e\u003cimg src=\"https://valeriansaliou.github.io/node-sonic-channel/images/crisp.png\" width=\"64\" /\u003e\u003c/a\u003e\u003c/td\u003e\n\u003c/tr\u003e\n\u003ctr\u003e\n\u003ctd align=\"center\"\u003eCrisp\u003c/td\u003e\n\u003c/tr\u003e\n\u003c/table\u003e\n\n_👋 You use sonic-channel and you want to be listed there? [Contact me](https://valeriansaliou.name/)._\n\n## How to install?\n\nInclude `sonic-channel` in your `package.json` dependencies.\n\nAlternatively, you can run `npm install sonic-channel --save`.\n\n## How to use?\n\n### 1️⃣ Search channel\n\n#### 1. Create the connection\n\n`node-sonic-channel` can be instanciated in search mode as such:\n\n```javascript\nvar SonicChannelSearch = require(\"sonic-channel\").Search;\n\nvar sonicChannelSearch = new SonicChannelSearch({\n  host : \"::1\",            // Or '127.0.0.1' if you are still using IPv4\n  port : 1491,             // Default port is '1491'\n  auth : \"SecretPassword\"  // Authentication password (if any)\n}).connect({\n  connected : function() {\n    // Connected handler\n    console.info(\"Sonic Channel succeeded to connect to host (search).\");\n  },\n\n  disconnected : function() {\n    // Disconnected handler\n    console.error(\"Sonic Channel is now disconnected (search).\");\n  },\n\n  timeout : function() {\n    // Timeout handler\n    console.error(\"Sonic Channel connection timed out (search).\");\n  },\n\n  retrying : function() {\n    // Retry handler\n    console.error(\"Trying to reconnect to Sonic Channel (search)...\");\n  },\n\n  error : function(error) {\n    // Failure handler\n    console.error(\"Sonic Channel failed to connect to host (search).\", error);\n  }\n});\n```\n\n#### 2. Query the search index\n\nUse the same `sonicChannelSearch` instance to query the search index:\n\n```javascript\nsonicChannelSearch.query(\"messages\", \"default\", \"valerian saliou\")\n  .then(function(results) {\n    // Query results come there\n  })\n  .catch(function(error) {\n    // Query errors come there\n  });\n```\n\n#### 3. Teardown connection\n\nIf you need to teardown an ongoing connection to Sonic, use:\n\n```javascript\nsonicChannelSearch.close()\n  .then(function() {\n    // Close success handler\n  })\n  .catch(function(error) {\n    // Close errors come there\n  });\n```\n\n---\n\n### 2️⃣ Ingest channel\n\n#### 1. Create the connection\n\n`node-sonic-channel` can be instanciated in ingest mode as such:\n\n```javascript\nvar SonicChannelIngest = require(\"sonic-channel\").Ingest;\n\nvar sonicChannelIngest = new SonicChannelIngest({\n  host : \"::1\",            // Or '127.0.0.1' if you are still using IPv4\n  port : 1491,             // Default port is '1491'\n  auth : \"SecretPassword\"  // Authentication password (if any)\n}).connect({\n  connected : function() {\n    // Connected handler\n    console.info(\"Sonic Channel succeeded to connect to host (ingest).\");\n  },\n\n  disconnected : function() {\n    // Disconnected handler\n    console.error(\"Sonic Channel is now disconnected (ingest).\");\n  },\n\n  timeout : function() {\n    // Timeout handler\n    console.error(\"Sonic Channel connection timed out (ingest).\");\n  },\n\n  retrying : function() {\n    // Retry handler\n    console.error(\"Trying to reconnect to Sonic Channel (ingest)...\");\n  },\n\n  error : function(error) {\n    // Failure handler\n    console.error(\"Sonic Channel failed to connect to host (ingest).\", error);\n  }\n});\n```\n\n#### 2. Manage the search index\n\nUse the same `sonicChannelIngest` instance to push text to the search index:\n\n```javascript\nsonicChannelIngest.push(\"messages\", \"default\", \"conversation:1\", \"I met Valerian Saliou yesterday. Great fun!\")\n  .then(function() {\n    // Push success handler\n  })\n  .catch(function(error) {\n    // Push errors come there\n  });\n```\n\n#### 3. Teardown connection\n\nIf you need to teardown an ongoing connection to Sonic, use:\n\n```javascript\nsonicChannelIngest.close()\n  .then(function() {\n    // Close success handler\n  })\n  .catch(function(error) {\n    // Close errors come there\n  });\n```\n\n---\n\n### 3️⃣ Control channel\n\n#### 1. Create the connection\n\n`node-sonic-channel` can be instanciated in control mode as such:\n\n```javascript\nvar SonicChannelControl = require(\"sonic-channel\").Control;\n\nvar sonicChannelControl = new SonicChannelControl({\n  host : \"::1\",            // Or '127.0.0.1' if you are still using IPv4\n  port : 1491,             // Default port is '1491'\n  auth : \"SecretPassword\"  // Authentication password (if any)\n}).connect({\n  connected : function() {\n    // Connected handler\n    console.info(\"Sonic Channel succeeded to connect to host (control).\");\n  },\n\n  disconnected : function() {\n    // Disconnected handler\n    console.error(\"Sonic Channel is now disconnected (control).\");\n  },\n\n  timeout : function() {\n    // Timeout handler\n    console.error(\"Sonic Channel connection timed out (control).\");\n  },\n\n  retrying : function() {\n    // Retry handler\n    console.error(\"Trying to reconnect to Sonic Channel (control)...\");\n  },\n\n  error : function(error) {\n    // Failure handler\n    console.error(\"Sonic Channel failed to connect to host (control).\", error);\n  }\n});\n```\n\n#### 2. Administrate your Sonic server\n\n_You may use the same `sonicChannelControl` instance to administrate your Sonic server._\n\n#### 3. Teardown connection\n\nIf you need to teardown an ongoing connection to Sonic, use:\n\n```javascript\nsonicChannelControl.close()\n  .then(function() {\n    // Close success handler\n  })\n  .catch(function(error) {\n    // Close errors come there\n  });\n```\n\n## List of channel methods\n\n_For details on argument values, see the [Sonic Channel Protocol specification](https://github.com/valeriansaliou/sonic/blob/master/PROTOCOL.md)._\n\n### Search channel\n\n* `sonicChannelSearch.query(collection_id\u003cstring\u003e, bucket_id\u003cstring\u003e, terms_text\u003cstring\u003e, [options{limit\u003cnumber\u003e, offset\u003cnumber\u003e, lang\u003cstring\u003e}\u003cobject\u003e]?)` ➡️ `Promise(results\u003cobject\u003e, error\u003cobject\u003e)`\n* `sonicChannelSearch.suggest(collection_id\u003cstring\u003e, bucket_id\u003cstring\u003e, word_text\u003cstring\u003e, [options{limit\u003cnumber\u003e}\u003cobject\u003e]?)` ➡️ `Promise(results\u003cobject\u003e, error\u003cobject\u003e)`\n* `sonicChannelSearch.list(collection_id\u003cstring\u003e, bucket_id\u003cstring\u003e, [options{limit\u003cnumber\u003e, offset\u003cnumber\u003e}\u003cobject\u003e]?)` ➡️ `Promise(results\u003cobject\u003e, error\u003cobject\u003e)`\n\n### Ingest channel\n\n* `sonicChannelIngest.push(collection_id\u003cstring\u003e, bucket_id\u003cstring\u003e, object_id\u003cstring\u003e, text\u003cstring\u003e, [options{lang\u003cstring\u003e}\u003cobject\u003e]?)` ➡️ `Promise(_, error\u003cobject\u003e)`\n* `sonicChannelIngest.pop(collection_id\u003cstring\u003e, bucket_id\u003cstring\u003e, object_id\u003cstring\u003e, text\u003cstring\u003e)` ➡️ `Promise(count\u003cnumber\u003e, error\u003cobject\u003e)`\n* `sonicChannelIngest.count\u003cnumber\u003e(collection_id\u003cstring\u003e, [bucket_id\u003cstring\u003e]?, [object_id\u003cstring\u003e]?)` ➡️ `Promise(count\u003cnumber\u003e, error\u003cobject\u003e)`\n* `sonicChannelIngest.flushc(collection_id\u003cstring\u003e)` ➡️ `Promise(count\u003cnumber\u003e, error\u003cobject\u003e)`\n* `sonicChannelIngest.flushb(collection_id\u003cstring\u003e, bucket_id\u003cstring\u003e)` ➡️ `Promise(count\u003cnumber\u003e, error\u003cobject\u003e)`\n* `sonicChannelIngest.flusho(collection_id\u003cstring\u003e, bucket_id\u003cstring\u003e, object_id\u003cstring\u003e)` ➡️ `Promise(count\u003cnumber\u003e, error\u003cobject\u003e)`\n\n### Control channel\n\n* `sonicChannelControl.trigger(action\u003cstring\u003e, [data\u003cstring\u003e]?)` ➡️ `Promise(_, error\u003cobject\u003e)`\n* `sonicChannelControl.info()` ➡️ `Promise(results\u003cobject\u003e, error\u003cobject\u003e)`\n\n## What is Sonic?\n\nℹ️ **Wondering what Sonic is?** Check out **[valeriansaliou/sonic](https://github.com/valeriansaliou/sonic)**.\n\n## How is it linked to Sonic?\n\n`node-sonic-channel` maintains persistent TCP connections to the Sonic network interfaces that are listening on your running Sonic instance. In case `node-sonic-channel` gets disconnected from Sonic, it will retry to connect once the connection is established again.\n\nYou can configure the connection details of your Sonic instance when initializing `node-sonic-channel` from your code; via the Sonic host and port.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvaleriansaliou%2Fnode-sonic-channel","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fvaleriansaliou%2Fnode-sonic-channel","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvaleriansaliou%2Fnode-sonic-channel/lists"}