{"_id":"@anteqkois/zongji","_rev":"3-a9b637cc78ad2aad5e7f4a44043498f0","name":"@anteqkois/zongji","dist-tags":{"latest":"0.5.2"},"versions":{"0.4.14":{"name":"@anteqkois/zongji","private":false,"version":"0.4.14","description":"A mysql binlog listener running on Node.js (fork of @rodrigogs/zongji)","main":"index.js","directories":{"test":"test"},"scripts":{"test":"nodeunit --reporter=minimal test","lint":"eslint ."},"repository":{"type":"git","url":"git+https://github.com/anteqkois/zongji.git"},"keywords":["mysql","binlog"],"author":{"name":"Nevill","email":"nevill.dutt@gmail.com"},"contributors":[{"name":"anteqkois","email":"anteqkois.dev@gmail.com (https://github.com/anteqkois)","url":"https://github.com/anteqkois"},{"name":"numtel","email":"ben@latenightsketches.com","url":"https://github.com/numtel"},{"name":"rfanth","email":"rfa@rfanth.com","url":"https://github.com/rfanth"},{"name":"rodrigogs","email":"rodrigo.smscom@gmail.com (https://github.com/rodrigogs)","url":"https://github.com/rodrigogs"}],"license":"MIT","bugs":{"url":"https://github.com/anteqkois/zongji/issues"},"homepage":"https://github.com/anteqkois/zongji","devDependencies":{"eslint":"5.12.0","nodeunit":"~0.11.3"},"dependencies":{"iconv-lite":"^0.4.24","mysql":"^2.16.0"},"engines":{"node":">=6"},"gitHead":"e4a3d74f94afbe4ae8b3d8d5a9f8fa26d088bb48","_id":"@anteqkois/zongji@0.4.14","_nodeVersion":"18.12.0","_npmVersion":"9.2.0","dist":{"integrity":"sha512-jhLMEtgyOVivmVCFAkPgFG3cCPmkJaR9AAA/zkZ+LAEtCAxOC7g259vX6YFhA1txQCol5IEn9fRF45vhgUaSJQ==","shasum":"0d99f9adb12f42f61ab4c2a03ac0f5337cf7f7b0","tarball":"https://registry.npmjs.org/@anteqkois/zongji/-/zongji-0.4.14.tgz","fileCount":21,"unpackedSize":85535,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQCKIfC1lwCdTO8Ey3w0v460lb6frFHsUjTHBnezPrFFpAIgD5bXpNnH4cDXw+eWaVUSeJ+4opT4kx5Z1Jq6GoI1RLY="}]},"_npmUser":{"name":"anteqkois","email":"anteqkois.dev@gmail.com"},"maintainers":[{"name":"anteqkois","email":"anteqkois.dev@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/zongji_0.4.14_1698255833271_0.738402595168616"},"_hasShrinkwrap":false},"0.4.15":{"name":"@anteqkois/zongji","private":false,"version":"0.4.15","description":"A mysql binlog listener running on Node.js (fork of @rodrigogs/zongji)","main":"index.js","directories":{"test":"test"},"types":"index.d.ts","scripts":{"test":"nodeunit --reporter=minimal test","lint":"eslint .","publish:public":"npm publish --access=public"},"repository":{"type":"git","url":"git+https://github.com/anteqkois/zongji.git"},"keywords":["mysql","binlog"],"author":{"name":"Nevill","email":"nevill.dutt@gmail.com"},"contributors":[{"name":"anteqkois","email":"anteqkois.dev@gmail.com (https://github.com/anteqkois)","url":"https://github.com/anteqkois"},{"name":"numtel","email":"ben@latenightsketches.com","url":"https://github.com/numtel"},{"name":"rfanth","email":"rfa@rfanth.com","url":"https://github.com/rfanth"},{"name":"rodrigogs","email":"rodrigo.smscom@gmail.com (https://github.com/rodrigogs)","url":"https://github.com/rodrigogs"}],"license":"MIT","bugs":{"url":"https://github.com/anteqkois/zongji/issues"},"homepage":"https://github.com/anteqkois/zongji","devDependencies":{"eslint":"5.12.0","nodeunit":"~0.11.3"},"dependencies":{"iconv-lite":"^0.4.24","mysql":"^2.16.0","@types/zongji":"^0.5.2"},"engines":{"node":">=6"},"gitHead":"c0c6b64a75a1c925a9d918d796000a619c579a39","_id":"@anteqkois/zongji@0.4.15","_nodeVersion":"18.12.0","_npmVersion":"9.2.0","dist":{"integrity":"sha512-130DEZK3vtmhHOvUE5C3XFBxlOlup1lstEqOgAAK74n5Ikbi4VLfcRoOMN/Mgnwp2tMxkHgkXJSy/nPWD4jI2A==","shasum":"da825862f8a9385278adb95825e749dcf7094121","tarball":"https://registry.npmjs.org/@anteqkois/zongji/-/zongji-0.4.15.tgz","fileCount":22,"unpackedSize":85731,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQDznWeY2hJ6fPOHNHBB5SdtDca/ay783/JoWVTjVL8Q9QIhAOUoyTU3UxtqVo2wfmFjEq/iE1dUwplFvZZWTWL53r60"}]},"_npmUser":{"name":"anteqkois","email":"anteqkois.dev@gmail.com"},"maintainers":[{"name":"anteqkois","email":"anteqkois.dev@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/zongji_0.4.15_1698257878067_0.32079340638378273"},"_hasShrinkwrap":false},"0.5.1":{"name":"@anteqkois/zongji","version":"0.5.1","description":"A mysql binlog listener running on Node.js","main":"index.js","types":"index.d.ts","directories":{"test":"test"},"scripts":{"test":"tap --bail --no-coverage --jobs=1 test/*.js","lint":"eslint .","pub":"npm publish --access=public"},"repository":{"type":"git","url":"git+https://github.com/anteqkois/zongji.git"},"keywords":["mysql","binlog"],"author":{"name":"Nevill","email":"nevill.dutt@gmail.com"},"contributors":[{"name":"anteqkois","email":"anteqkois.dev@gmail.com (https://github.com/anteqkois)","url":"https://github.com/anteqkois"},{"name":"numtel","email":"ben@latenightsketches.com","url":"https://github.com/numtel"},{"name":"rfanth","email":"rfa@rfanth.com","url":"https://github.com/rfanth"}],"license":"MIT","bugs":{"url":"https://github.com/anteqkois/zongji/issues"},"homepage":"https://github.com/anteqkois/zongji/","engines":{"node":">= 8.0"},"devDependencies":{"eslint":"6.8.0","tap":"14.10.7"},"dependencies":{"@types/zongji":"^0.5.2","big-integer":"1.6.48","iconv-lite":"0.5.1","mysql":"2.18.1"},"gitHead":"e63c7139c7eb0e896d4ea13983d5a24f789cf27a","_id":"@anteqkois/zongji@0.5.1","_nodeVersion":"18.12.0","_npmVersion":"9.2.0","dist":{"integrity":"sha512-ukYoLPltPdYgg+51Fh3JFJ1/3/32G2aklmr+8kQhcqmIBVIvq1eOqmwuu32BrwgsSvV6ZHzPfaW6AE2/VwUdLg==","shasum":"85979ec7516731ce42cfc5cb26b1f97d23bfa14a","tarball":"https://registry.npmjs.org/@anteqkois/zongji/-/zongji-0.5.1.tgz","fileCount":21,"unpackedSize":86683,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIBDMklCX1SieKRzAKDiwro7LBa4h/7hcvtAJTi8Zq8INAiAWs0qlE8IHW6/MxaftLff2AxA62yuGbw22MjJ0UuUP8g=="}]},"_npmUser":{"name":"anteqkois","email":"anteqkois.dev@gmail.com"},"maintainers":[{"name":"anteqkois","email":"anteqkois.dev@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/zongji_0.5.1_1698259604048_0.7799368141067387"},"_hasShrinkwrap":false},"0.5.2":{"name":"@anteqkois/zongji","version":"0.5.2","description":"A mysql binlog listener running on Node.js","main":"index.js","types":"index.d.ts","directories":{"test":"test"},"scripts":{"test":"tap --bail --no-coverage --jobs=1 test/*.js","lint":"eslint .","pub":"npm publish --access=public"},"repository":{"type":"git","url":"git+https://github.com/anteqkois/zongji.git"},"keywords":["mysql","binlog"],"author":{"name":"Nevill","email":"nevill.dutt@gmail.com"},"contributors":[{"name":"anteqkois","email":"anteqkois.dev@gmail.com (https://github.com/anteqkois)","url":"https://github.com/anteqkois"},{"name":"numtel","email":"ben@latenightsketches.com","url":"https://github.com/numtel"},{"name":"rfanth","email":"rfa@rfanth.com","url":"https://github.com/rfanth"}],"license":"MIT","bugs":{"url":"https://github.com/anteqkois/zongji/issues"},"homepage":"https://github.com/anteqkois/zongji/","engines":{"node":">= 8.0"},"devDependencies":{"@types/mysql":"^2.15.23","@types/node":"^20.8.9","eslint":"6.8.0","tap":"14.10.7"},"dependencies":{"big-integer":"1.6.48","iconv-lite":"0.5.1","mysql":"2.18.1"},"gitHead":"dc5ff5782c6b837a97c6b35660e0f221175c5cd3","_id":"@anteqkois/zongji@0.5.2","_nodeVersion":"18.12.0","_npmVersion":"9.2.0","dist":{"integrity":"sha512-BRRfhU+RPoBZdz0ZZ3DGvXu9mYCdM8fqAm0CIAFXYazji8K3mdw7GQDOngDSInr/fjRYQOZgMNB+ts/7RC/aUg==","shasum":"8621efaa6626b066bf492ae60507beb92923f937","tarball":"https://registry.npmjs.org/@anteqkois/zongji/-/zongji-0.5.2.tgz","fileCount":21,"unpackedSize":89811,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIH1gvLly9AeXVScb3ERKxCG6KTG4eWLuGenZZXGRTMfvAiEA5BQNH8IWAmxep/mV2/lKz+PBcfrcBbgbQJAlRejAcF4="}]},"_npmUser":{"name":"anteqkois","email":"anteqkois.dev@gmail.com"},"maintainers":[{"name":"anteqkois","email":"anteqkois.dev@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/zongji_0.5.2_1698262090600_0.6742183454234159"},"_hasShrinkwrap":false}},"time":{"created":"2023-10-25T17:43:53.151Z","0.4.14":"2023-10-25T17:43:53.647Z","modified":"2023-10-25T19:28:11.032Z","0.4.15":"2023-10-25T18:17:58.369Z","0.5.1":"2023-10-25T18:46:44.347Z","0.5.2":"2023-10-25T19:28:10.884Z"},"maintainers":[{"name":"anteqkois","email":"anteqkois.dev@gmail.com"}],"description":"A mysql binlog listener running on Node.js","homepage":"https://github.com/anteqkois/zongji/","keywords":["mysql","binlog"],"repository":{"type":"git","url":"git+https://github.com/anteqkois/zongji.git"},"contributors":[{"name":"anteqkois","email":"anteqkois.dev@gmail.com (https://github.com/anteqkois)","url":"https://github.com/anteqkois"},{"name":"numtel","email":"ben@latenightsketches.com","url":"https://github.com/numtel"},{"name":"rfanth","email":"rfa@rfanth.com","url":"https://github.com/rfanth"}],"author":{"name":"Nevill","email":"nevill.dutt@gmail.com"},"bugs":{"url":"https://github.com/anteqkois/zongji/issues"},"license":"MIT","readme":"# ZongJi [![Build Status](https://travis-ci.org/rodrigogs/zongji.svg?branch=master)](https://travis-ci.org/rodrigogs/zongji)\nA MySQL binlog listener running on Node.js.\n\nZongJi (踪迹) is pronounced as `zōng jì` in Chinese.\n\nThis package is a pure JS implementation based on [`mysql`](https://github.com/mysqljs/mysql). It has been tested to work in MySQL 5.5, 5.6, and 5.7.\n\n# Latest Release\n\nThe latest release is v0.5.0, only supports Node.js from v8.\n\nv0.4.7 is the last release which supports Node.js v4.x.\n\n## Quick Start\n\n```javascript\nlet zongji = new ZongJi({ /* ... MySQL Connection Settings ... */ });\n\n// Each change to the replication log results in an event\nzongji.on('binlog', function(evt) {\n  evt.dump();\n});\n\n// Binlog must be started, optionally pass in filters\nzongji.start({\n  includeEvents: ['tablemap', 'writerows', 'updaterows', 'deleterows']\n});\n```\n\nFor a complete implementation see [`example.js`](example.js)...\n\n## Installation\n\n* Requires Node.js v8+\n\n  ```bash\n  $ npm install zongji\n  ```\n\n* Enable MySQL binlog in `my.cnf`, restart MySQL server after making the changes.\n  > From [MySQL 5.6](https://dev.mysql.com/doc/refman/5.6/en/replication-options-binary-log.html), binlog checksum is enabled by default. Zongji can work with it, but it doesn't really verify it.\n\n  ```\n  # Must be unique integer from 1-2^32\n  server-id        = 1\n  # Row format required for ZongJi\n  binlog_format    = row\n  # Directory must exist. This path works for Linux. Other OS may require\n  #   different path.\n  log_bin          = /var/log/mysql/mysql-bin.log\n\n  binlog_do_db     = employees   # Optional, limit which databases to log\n  expire_logs_days = 10          # Optional, purge old logs\n  max_binlog_size  = 100M        # Optional, limit log size\n  ```\n* Create an account with replication privileges, e.g. given privileges to account `zongji` (or any account that you use to read binary logs)\n\n  ```sql\n  GRANT REPLICATION SLAVE, REPLICATION CLIENT, SELECT ON *.* TO 'zongji'@'localhost'\n  ```\n\n## ZongJi Class\n\nThe `ZongJi` constructor accepts one argument of either:\n\n* An object containing MySQL connection details in the same format as used by [package mysql](https://npm.im/mysql)\n* Or, a [mysql](https://npm.im/mysql) `Connection` or `Pool` object that will be used for querying column information.\n\nIf a `Connection` or `Pool` object is passed to the constructor, it will not be destroyed/ended by Zongji's `stop()` method.\n\nIf there is a `dateStrings` `mysql` configuration option in the connection details or connection, `ZongJi` will follow it.\n\nEach instance includes the following methods:\n\nMethod Name | Arguments | Description\n------------|-----------|------------------------\n`start`     | `options` | Start receiving replication events, see options listed below\n`stop`      | *None*    | Disconnect from MySQL server, stop receiving events\n`on`        | `eventName`, `handler` | Add a listener to the `binlog` or `error` event. Each handler function accepts one argument.\n\nSome events can be emitted in different phases:\n\nEvent Name | Description\n-----------|------------------------\n`ready`    | This event is occurred right after ZongJi successfully established a connection, setup slave status, and set binlog position.\n`binlog`   | Once a binlog is received and passes the filter, it will bubble up with this event.\n`error`    | Every error will be caught by this event.\n`stopped`  | Emitted when ZongJi connection is stopped (ZongJi#stop is called).\n\n**Options available:**\n\nOption Name | Type | Description\n------------|------|-------------------------------\n`serverId`  | `integer` | [Unique number (1 - 2<sup>32</sup>)](http://dev.mysql.com/doc/refman/5.0/en/replication-options.html#option_mysqld_server-id) to identify this replication slave instance. Must be specified if running more than one instance of ZongJi. Must be used in `start()` method for effect.<br>**Default:** `1`\n`startAtEnd` | `boolean` | Pass `true` to only emit binlog events that occur after ZongJi's instantiation. Must be used in `start()` method for effect.<br>**Default:** `false`\n`filename` | `string` | Begin reading events from this binlog file. If specified together with `position`, will take precedence over `startAtEnd`.\n`position` | `integer` | Begin reading events from this position. Must be included with `filename`.\n`includeEvents` | `[string]` | Array of event names to include<br>**Example:** `['writerows', 'updaterows', 'deleterows']`\n`excludeEvents` | `[string]` | Array of event names to exclude<br>**Example:** `['rotate', 'tablemap']`\n`includeSchema` | `object` | Object describing which databases and tables to include (Only for row events). Use database names as the key and pass an array of table names or `true` (for the entire database).<br>**Example:** ```{ 'my_database': ['allow_table', 'another_table'], 'another_db': true }```\n`excludeSchema` | `object` | Object describing which databases and tables to exclude (Same format as `includeSchema`)<br>**Example:** ```{ 'other_db': ['disallowed_table'], 'ex_db': true }```\n\n* By default, all events and schema are emitted.\n* `excludeSchema` and `excludeEvents` take precedence over `includeSchema` and `includeEvents`, respectively.\n\n**Supported Binlog Events:**\n\nEvent name  | Description\n------------|---------------\n`unknown`   | Catch any other events\n`query`     | [Insert/Update/Delete Query](http://dev.mysql.com/doc/internals/en/query-event.html)\n`intvar`    | [Autoincrement and LAST_INSERT_ID](https://dev.mysql.com/doc/internals/en/intvar-event.html)\n`rotate`    | [New Binlog file](http://dev.mysql.com/doc/internals/en/rotate-event.html) Not required to be included to rotate to new files, but it is required to be included in order to keep the `filename` and `position` properties updated with current values for [graceful restarting on errors](https://gist.github.com/numtel/5b37b2a7f47b380c1a099596c6f3db2f).\n`format`    | [Format Description](http://dev.mysql.com/doc/internals/en/format-description-event.html)\n`xid`       | [Transaction ID](http://dev.mysql.com/doc/internals/en/xid-event.html)\n`tablemap`  | Before any row event (must be included for any other row events)\n`writerows` | Rows inserted, row data array available as `rows` property on event object\n`updaterows` | Rows changed, row data array available as `rows` property on event object\n`deleterows` | Rows deleted, row data array available as `rows` property on event object\n\n**Event Methods**\n\nNeither method requires any arguments.\n\nName   | Description\n-------|---------------------------\n`dump` | Log a description of the event to the console\n`getEventName` | Return the name of the event\n\n## Important Notes\n\n* :star2: [All types allowed by `mysql`](https://github.com/mysqljs/mysql#type-casting) are supported by this package.\n* :speak_no_evil: 64-bit integer is supported via package big-integer(see #108). If an integer is within the safe range of JS number (-2^53, 2^53), a Number object will returned, otherwise, will return as String.\n* :point_right: `TRUNCATE` statement does not cause corresponding `DeleteRows` event. Use unqualified `DELETE FROM` for same effect.\n* When using fractional seconds with `DATETIME` and `TIMESTAMP` data types in MySQL > 5.6.4, only millisecond precision is available due to the limit of Javascript's `Date` object.\n\n## Run Tests\n\n* install [Docker](https://www.docker.com/community-edition#download)\n* run `docker-compose up` and then `./docker-test.sh`\n\n## Reference\n\nI learnt many things from following resources while making ZongJi.\n\n* https://github.com/mysqljs/mysql\n* https://github.com/felixge/faster-than-c/\n* http://intuitive-search.blogspot.co.uk/2011/07/binary-log-api-and-replication-listener.html\n* https://github.com/Sannis/node-mysql-libmysqlclient\n* https://kkaefer.com/node-cpp-modules/\n* http://dev.mysql.com/doc/internals/en/replication-protocol.html\n* http://www.cs.wichita.edu/~chang/lecture/cs742/program/how-mysql-c-api.html\n* https://github.com/jeremycole/mysql_binlog (Ruby implemenation of MySQL binlog parser)\n* http://dev.mysql.com/doc/internals/en/date-and-time-data-type-representation.html\n\n## License\nMIT\n","readmeFilename":"README.md"}