@hocuspocus/extension-sqlite 1.0.0-alpha.3 → 1.0.0-alpha.4

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.
@@ -4,12 +4,12 @@ Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
5
  var extensionDatabase = require('@hocuspocus/extension-database');
6
6
  var sqlite3 = require('sqlite3');
7
- var chalk = require('chalk');
7
+ var kleur = require('kleur');
8
8
 
9
9
  function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
10
10
 
11
11
  var sqlite3__default = /*#__PURE__*/_interopDefaultLegacy(sqlite3);
12
- var chalk__default = /*#__PURE__*/_interopDefaultLegacy(chalk);
12
+ var kleur__default = /*#__PURE__*/_interopDefaultLegacy(kleur);
13
13
 
14
14
  class SQLite extends extensionDatabase.Database {
15
15
  /**
@@ -50,7 +50,7 @@ class SQLite extends extensionDatabase.Database {
50
50
  };
51
51
  }
52
52
  async onListen() {
53
- console.warn(` ${chalk__default["default"].yellow('The SQLite extension is intended to be used in a local development environment, not in a production environment.')}`);
53
+ console.warn(` ${kleur__default["default"].yellow('The SQLite extension is intended to be used in a local development environment, not in a production environment.')}`);
54
54
  console.log();
55
55
  }
56
56
  async onConfigure() {
@@ -1 +1 @@
1
- {"version":3,"file":"hocuspocus-sqlite.cjs","sources":["../src/SQLite.ts"],"sourcesContent":["import { Database, DatabaseConfiguration } from '@hocuspocus/extension-database'\nimport sqlite3 from 'sqlite3'\nimport chalk from 'chalk'\n\nexport interface SQLiteConfiguration extends DatabaseConfiguration {\n /**\n * Valid values are filenames, \":memory:\" for an anonymous in-memory database and an empty\n * string for an anonymous disk-based database. Anonymous databases are not persisted and\n * when closing the database handle, their contents are lost.\n *\n * https://github.com/mapbox/node-sqlite3/wiki/API#new-sqlite3databasefilename-mode-callback\n */\n database: string,\n /**\n * The database schema to create.\n */\n schema: string,\n}\n\nexport class SQLite extends Database {\n db?: sqlite3.Database\n\n configuration: SQLiteConfiguration = {\n database: ':memory:',\n schema: `CREATE TABLE IF NOT EXISTS \"documents\" (\n \"name\" varchar(255) NOT NULL,\n \"data\" blob NOT NULL\n );`,\n fetchUpdates: async ({ documentName }) => {\n return new Promise((resolve, reject) => {\n this.db?.all('SELECT data FROM \"documents\" WHERE name = $name ORDER BY rowid', {\n $name: documentName,\n }, (error, rows) => {\n if (error) {\n reject(error)\n }\n\n resolve(rows.map(row => row.data))\n })\n })\n },\n storeUpdate: async ({ documentName, update }) => {\n this.db?.run('INSERT INTO \"documents\" (\"name\", \"data\") VALUES ($name, $data)', {\n $name: documentName,\n $data: update,\n })\n },\n }\n\n /**\n * Constructor\n */\n constructor(configuration?: Partial<SQLiteConfiguration>) {\n super({})\n\n this.configuration = {\n ...this.configuration,\n ...configuration,\n }\n }\n\n async onListen() {\n console.warn(` ${chalk.yellow('The SQLite extension is intended to be used in a local development environment, not in a production environment.')}`)\n console.log()\n }\n\n async onConfigure() {\n this.db = new sqlite3.Database(this.configuration.database)\n\n this.db.run(this.configuration.schema)\n }\n}\n"],"names":["Database","chalk","sqlite3"],"mappings":";;;;;;;;;;;;;MAmBa,MAAO,SAAQA,0BAAQ;;;;IAiClC,YAAY,aAA4C;QACtD,KAAK,CAAC,EAAE,CAAC,CAAA;QA/BX,kBAAa,GAAwB;YACnC,QAAQ,EAAE,UAAU;YACpB,MAAM,EAAE;;;OAGL;YACH,YAAY,EAAE,OAAO,EAAE,YAAY,EAAE;gBACnC,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,MAAM;;oBACjC,MAAA,IAAI,CAAC,EAAE,0CAAE,GAAG,CAAC,gEAAgE,EAAE;wBAC7E,KAAK,EAAE,YAAY;qBACpB,EAAE,CAAC,KAAK,EAAE,IAAI;wBACb,IAAI,KAAK,EAAE;4BACT,MAAM,CAAC,KAAK,CAAC,CAAA;yBACd;wBAED,OAAO,CAAC,IAAI,CAAC,GAAG,CAAC,GAAG,IAAI,GAAG,CAAC,IAAI,CAAC,CAAC,CAAA;qBACnC,CAAC,CAAA;iBACH,CAAC,CAAA;aACH;YACD,WAAW,EAAE,OAAO,EAAE,YAAY,EAAE,MAAM,EAAE;;gBAC1C,MAAA,IAAI,CAAC,EAAE,0CAAE,GAAG,CAAC,gEAAgE,EAAE;oBAC7E,KAAK,EAAE,YAAY;oBACnB,KAAK,EAAE,MAAM;iBACd,CAAC,CAAA;aACH;SACF,CAAA;QAQC,IAAI,CAAC,aAAa,GAAG;YACnB,GAAG,IAAI,CAAC,aAAa;YACrB,GAAG,aAAa;SACjB,CAAA;KACF;IAED,MAAM,QAAQ;QACZ,OAAO,CAAC,IAAI,CAAC,KAAKC,yBAAK,CAAC,MAAM,CAAC,kHAAkH,CAAC,EAAE,CAAC,CAAA;QACrJ,OAAO,CAAC,GAAG,EAAE,CAAA;KACd;IAED,MAAM,WAAW;QACf,IAAI,CAAC,EAAE,GAAG,IAAIC,2BAAO,CAAC,QAAQ,CAAC,IAAI,CAAC,aAAa,CAAC,QAAQ,CAAC,CAAA;QAE3D,IAAI,CAAC,EAAE,CAAC,GAAG,CAAC,IAAI,CAAC,aAAa,CAAC,MAAM,CAAC,CAAA;KACvC;;;;;"}
1
+ {"version":3,"file":"hocuspocus-sqlite.cjs","sources":["../src/SQLite.ts"],"sourcesContent":["import { Database, DatabaseConfiguration } from '@hocuspocus/extension-database'\nimport sqlite3 from 'sqlite3'\nimport kleur from 'kleur'\n\nexport interface SQLiteConfiguration extends DatabaseConfiguration {\n /**\n * Valid values are filenames, \":memory:\" for an anonymous in-memory database and an empty\n * string for an anonymous disk-based database. Anonymous databases are not persisted and\n * when closing the database handle, their contents are lost.\n *\n * https://github.com/mapbox/node-sqlite3/wiki/API#new-sqlite3databasefilename-mode-callback\n */\n database: string,\n /**\n * The database schema to create.\n */\n schema: string,\n}\n\nexport class SQLite extends Database {\n db?: sqlite3.Database\n\n configuration: SQLiteConfiguration = {\n database: ':memory:',\n schema: `CREATE TABLE IF NOT EXISTS \"documents\" (\n \"name\" varchar(255) NOT NULL,\n \"data\" blob NOT NULL\n );`,\n fetchUpdates: async ({ documentName }) => {\n return new Promise((resolve, reject) => {\n this.db?.all('SELECT data FROM \"documents\" WHERE name = $name ORDER BY rowid', {\n $name: documentName,\n }, (error, rows) => {\n if (error) {\n reject(error)\n }\n\n resolve(rows.map(row => row.data))\n })\n })\n },\n storeUpdate: async ({ documentName, update }) => {\n this.db?.run('INSERT INTO \"documents\" (\"name\", \"data\") VALUES ($name, $data)', {\n $name: documentName,\n $data: update,\n })\n },\n }\n\n /**\n * Constructor\n */\n constructor(configuration?: Partial<SQLiteConfiguration>) {\n super({})\n\n this.configuration = {\n ...this.configuration,\n ...configuration,\n }\n }\n\n async onListen() {\n console.warn(` ${kleur.yellow('The SQLite extension is intended to be used in a local development environment, not in a production environment.')}`)\n console.log()\n }\n\n async onConfigure() {\n this.db = new sqlite3.Database(this.configuration.database)\n\n this.db.run(this.configuration.schema)\n }\n}\n"],"names":["Database","kleur","sqlite3"],"mappings":";;;;;;;;;;;;;MAmBa,MAAO,SAAQA,0BAAQ;;;;IAiClC,YAAY,aAA4C;QACtD,KAAK,CAAC,EAAE,CAAC,CAAA;QA/BX,kBAAa,GAAwB;YACnC,QAAQ,EAAE,UAAU;YACpB,MAAM,EAAE;;;OAGL;YACH,YAAY,EAAE,OAAO,EAAE,YAAY,EAAE;gBACnC,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,MAAM;;oBACjC,MAAA,IAAI,CAAC,EAAE,0CAAE,GAAG,CAAC,gEAAgE,EAAE;wBAC7E,KAAK,EAAE,YAAY;qBACpB,EAAE,CAAC,KAAK,EAAE,IAAI;wBACb,IAAI,KAAK,EAAE;4BACT,MAAM,CAAC,KAAK,CAAC,CAAA;yBACd;wBAED,OAAO,CAAC,IAAI,CAAC,GAAG,CAAC,GAAG,IAAI,GAAG,CAAC,IAAI,CAAC,CAAC,CAAA;qBACnC,CAAC,CAAA;iBACH,CAAC,CAAA;aACH;YACD,WAAW,EAAE,OAAO,EAAE,YAAY,EAAE,MAAM,EAAE;;gBAC1C,MAAA,IAAI,CAAC,EAAE,0CAAE,GAAG,CAAC,gEAAgE,EAAE;oBAC7E,KAAK,EAAE,YAAY;oBACnB,KAAK,EAAE,MAAM;iBACd,CAAC,CAAA;aACH;SACF,CAAA;QAQC,IAAI,CAAC,aAAa,GAAG;YACnB,GAAG,IAAI,CAAC,aAAa;YACrB,GAAG,aAAa;SACjB,CAAA;KACF;IAED,MAAM,QAAQ;QACZ,OAAO,CAAC,IAAI,CAAC,KAAKC,yBAAK,CAAC,MAAM,CAAC,kHAAkH,CAAC,EAAE,CAAC,CAAA;QACrJ,OAAO,CAAC,GAAG,EAAE,CAAA;KACd;IAED,MAAM,WAAW;QACf,IAAI,CAAC,EAAE,GAAG,IAAIC,2BAAO,CAAC,QAAQ,CAAC,IAAI,CAAC,aAAa,CAAC,QAAQ,CAAC,CAAA;QAE3D,IAAI,CAAC,EAAE,CAAC,GAAG,CAAC,IAAI,CAAC,aAAa,CAAC,MAAM,CAAC,CAAA;KACvC;;;;;"}
@@ -1,6 +1,6 @@
1
1
  import { Database } from '@hocuspocus/extension-database';
2
2
  import sqlite3 from 'sqlite3';
3
- import chalk from 'chalk';
3
+ import kleur from 'kleur';
4
4
 
5
5
  class SQLite extends Database {
6
6
  /**
@@ -41,7 +41,7 @@ class SQLite extends Database {
41
41
  };
42
42
  }
43
43
  async onListen() {
44
- console.warn(` ${chalk.yellow('The SQLite extension is intended to be used in a local development environment, not in a production environment.')}`);
44
+ console.warn(` ${kleur.yellow('The SQLite extension is intended to be used in a local development environment, not in a production environment.')}`);
45
45
  console.log();
46
46
  }
47
47
  async onConfigure() {
@@ -1 +1 @@
1
- {"version":3,"file":"hocuspocus-sqlite.esm.js","sources":["../src/SQLite.ts"],"sourcesContent":["import { Database, DatabaseConfiguration } from '@hocuspocus/extension-database'\nimport sqlite3 from 'sqlite3'\nimport chalk from 'chalk'\n\nexport interface SQLiteConfiguration extends DatabaseConfiguration {\n /**\n * Valid values are filenames, \":memory:\" for an anonymous in-memory database and an empty\n * string for an anonymous disk-based database. Anonymous databases are not persisted and\n * when closing the database handle, their contents are lost.\n *\n * https://github.com/mapbox/node-sqlite3/wiki/API#new-sqlite3databasefilename-mode-callback\n */\n database: string,\n /**\n * The database schema to create.\n */\n schema: string,\n}\n\nexport class SQLite extends Database {\n db?: sqlite3.Database\n\n configuration: SQLiteConfiguration = {\n database: ':memory:',\n schema: `CREATE TABLE IF NOT EXISTS \"documents\" (\n \"name\" varchar(255) NOT NULL,\n \"data\" blob NOT NULL\n );`,\n fetchUpdates: async ({ documentName }) => {\n return new Promise((resolve, reject) => {\n this.db?.all('SELECT data FROM \"documents\" WHERE name = $name ORDER BY rowid', {\n $name: documentName,\n }, (error, rows) => {\n if (error) {\n reject(error)\n }\n\n resolve(rows.map(row => row.data))\n })\n })\n },\n storeUpdate: async ({ documentName, update }) => {\n this.db?.run('INSERT INTO \"documents\" (\"name\", \"data\") VALUES ($name, $data)', {\n $name: documentName,\n $data: update,\n })\n },\n }\n\n /**\n * Constructor\n */\n constructor(configuration?: Partial<SQLiteConfiguration>) {\n super({})\n\n this.configuration = {\n ...this.configuration,\n ...configuration,\n }\n }\n\n async onListen() {\n console.warn(` ${chalk.yellow('The SQLite extension is intended to be used in a local development environment, not in a production environment.')}`)\n console.log()\n }\n\n async onConfigure() {\n this.db = new sqlite3.Database(this.configuration.database)\n\n this.db.run(this.configuration.schema)\n }\n}\n"],"names":[],"mappings":";;;;MAmBa,MAAO,SAAQ,QAAQ;;;;IAiClC,YAAY,aAA4C;QACtD,KAAK,CAAC,EAAE,CAAC,CAAA;QA/BX,kBAAa,GAAwB;YACnC,QAAQ,EAAE,UAAU;YACpB,MAAM,EAAE;;;OAGL;YACH,YAAY,EAAE,OAAO,EAAE,YAAY,EAAE;gBACnC,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,MAAM;;oBACjC,MAAA,IAAI,CAAC,EAAE,0CAAE,GAAG,CAAC,gEAAgE,EAAE;wBAC7E,KAAK,EAAE,YAAY;qBACpB,EAAE,CAAC,KAAK,EAAE,IAAI;wBACb,IAAI,KAAK,EAAE;4BACT,MAAM,CAAC,KAAK,CAAC,CAAA;yBACd;wBAED,OAAO,CAAC,IAAI,CAAC,GAAG,CAAC,GAAG,IAAI,GAAG,CAAC,IAAI,CAAC,CAAC,CAAA;qBACnC,CAAC,CAAA;iBACH,CAAC,CAAA;aACH;YACD,WAAW,EAAE,OAAO,EAAE,YAAY,EAAE,MAAM,EAAE;;gBAC1C,MAAA,IAAI,CAAC,EAAE,0CAAE,GAAG,CAAC,gEAAgE,EAAE;oBAC7E,KAAK,EAAE,YAAY;oBACnB,KAAK,EAAE,MAAM;iBACd,CAAC,CAAA;aACH;SACF,CAAA;QAQC,IAAI,CAAC,aAAa,GAAG;YACnB,GAAG,IAAI,CAAC,aAAa;YACrB,GAAG,aAAa;SACjB,CAAA;KACF;IAED,MAAM,QAAQ;QACZ,OAAO,CAAC,IAAI,CAAC,KAAK,KAAK,CAAC,MAAM,CAAC,kHAAkH,CAAC,EAAE,CAAC,CAAA;QACrJ,OAAO,CAAC,GAAG,EAAE,CAAA;KACd;IAED,MAAM,WAAW;QACf,IAAI,CAAC,EAAE,GAAG,IAAI,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAC,aAAa,CAAC,QAAQ,CAAC,CAAA;QAE3D,IAAI,CAAC,EAAE,CAAC,GAAG,CAAC,IAAI,CAAC,aAAa,CAAC,MAAM,CAAC,CAAA;KACvC;;;;;"}
1
+ {"version":3,"file":"hocuspocus-sqlite.esm.js","sources":["../src/SQLite.ts"],"sourcesContent":["import { Database, DatabaseConfiguration } from '@hocuspocus/extension-database'\nimport sqlite3 from 'sqlite3'\nimport kleur from 'kleur'\n\nexport interface SQLiteConfiguration extends DatabaseConfiguration {\n /**\n * Valid values are filenames, \":memory:\" for an anonymous in-memory database and an empty\n * string for an anonymous disk-based database. Anonymous databases are not persisted and\n * when closing the database handle, their contents are lost.\n *\n * https://github.com/mapbox/node-sqlite3/wiki/API#new-sqlite3databasefilename-mode-callback\n */\n database: string,\n /**\n * The database schema to create.\n */\n schema: string,\n}\n\nexport class SQLite extends Database {\n db?: sqlite3.Database\n\n configuration: SQLiteConfiguration = {\n database: ':memory:',\n schema: `CREATE TABLE IF NOT EXISTS \"documents\" (\n \"name\" varchar(255) NOT NULL,\n \"data\" blob NOT NULL\n );`,\n fetchUpdates: async ({ documentName }) => {\n return new Promise((resolve, reject) => {\n this.db?.all('SELECT data FROM \"documents\" WHERE name = $name ORDER BY rowid', {\n $name: documentName,\n }, (error, rows) => {\n if (error) {\n reject(error)\n }\n\n resolve(rows.map(row => row.data))\n })\n })\n },\n storeUpdate: async ({ documentName, update }) => {\n this.db?.run('INSERT INTO \"documents\" (\"name\", \"data\") VALUES ($name, $data)', {\n $name: documentName,\n $data: update,\n })\n },\n }\n\n /**\n * Constructor\n */\n constructor(configuration?: Partial<SQLiteConfiguration>) {\n super({})\n\n this.configuration = {\n ...this.configuration,\n ...configuration,\n }\n }\n\n async onListen() {\n console.warn(` ${kleur.yellow('The SQLite extension is intended to be used in a local development environment, not in a production environment.')}`)\n console.log()\n }\n\n async onConfigure() {\n this.db = new sqlite3.Database(this.configuration.database)\n\n this.db.run(this.configuration.schema)\n }\n}\n"],"names":[],"mappings":";;;;MAmBa,MAAO,SAAQ,QAAQ;;;;IAiClC,YAAY,aAA4C;QACtD,KAAK,CAAC,EAAE,CAAC,CAAA;QA/BX,kBAAa,GAAwB;YACnC,QAAQ,EAAE,UAAU;YACpB,MAAM,EAAE;;;OAGL;YACH,YAAY,EAAE,OAAO,EAAE,YAAY,EAAE;gBACnC,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,MAAM;;oBACjC,MAAA,IAAI,CAAC,EAAE,0CAAE,GAAG,CAAC,gEAAgE,EAAE;wBAC7E,KAAK,EAAE,YAAY;qBACpB,EAAE,CAAC,KAAK,EAAE,IAAI;wBACb,IAAI,KAAK,EAAE;4BACT,MAAM,CAAC,KAAK,CAAC,CAAA;yBACd;wBAED,OAAO,CAAC,IAAI,CAAC,GAAG,CAAC,GAAG,IAAI,GAAG,CAAC,IAAI,CAAC,CAAC,CAAA;qBACnC,CAAC,CAAA;iBACH,CAAC,CAAA;aACH;YACD,WAAW,EAAE,OAAO,EAAE,YAAY,EAAE,MAAM,EAAE;;gBAC1C,MAAA,IAAI,CAAC,EAAE,0CAAE,GAAG,CAAC,gEAAgE,EAAE;oBAC7E,KAAK,EAAE,YAAY;oBACnB,KAAK,EAAE,MAAM;iBACd,CAAC,CAAA;aACH;SACF,CAAA;QAQC,IAAI,CAAC,aAAa,GAAG;YACnB,GAAG,IAAI,CAAC,aAAa;YACrB,GAAG,aAAa;SACjB,CAAA;KACF;IAED,MAAM,QAAQ;QACZ,OAAO,CAAC,IAAI,CAAC,KAAK,KAAK,CAAC,MAAM,CAAC,kHAAkH,CAAC,EAAE,CAAC,CAAA;QACrJ,OAAO,CAAC,GAAG,EAAE,CAAA;KACd;IAED,MAAM,WAAW;QACf,IAAI,CAAC,EAAE,GAAG,IAAI,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAC,aAAa,CAAC,QAAQ,CAAC,CAAA;QAE3D,IAAI,CAAC,EAAE,CAAC,GAAG,CAAC,IAAI,CAAC,aAAa,CAAC,MAAM,CAAC,CAAA;KACvC;;;;;"}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@hocuspocus/extension-sqlite",
3
3
  "description": "a generic Hocuspocus persistence driver for the sqlite",
4
- "version": "1.0.0-alpha.3",
4
+ "version": "1.0.0-alpha.4",
5
5
  "homepage": "https://hocuspocus.dev",
6
6
  "keywords": [
7
7
  "hocuspocus",
@@ -26,8 +26,8 @@
26
26
  "dist"
27
27
  ],
28
28
  "dependencies": {
29
- "@hocuspocus/extension-database": "^1.0.0-alpha.3",
30
- "chalk": "^5.0.0",
29
+ "@hocuspocus/extension-database": "^1.0.0-alpha.4",
30
+ "kleur": "^4.1.4",
31
31
  "sqlite3": "^5.0.2"
32
32
  },
33
33
  "publishConfig": {
@@ -36,5 +36,5 @@
36
36
  "devDependencies": {
37
37
  "@types/sqlite3": "^3.1.7"
38
38
  },
39
- "gitHead": "87b715d1d28c603702879f4413c17d2c4a38c51a"
39
+ "gitHead": "b3454a4ca289a84ddfb7fa5607a2d4b8d5c37e9d"
40
40
  }
package/src/SQLite.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import { Database, DatabaseConfiguration } from '@hocuspocus/extension-database'
2
2
  import sqlite3 from 'sqlite3'
3
- import chalk from 'chalk'
3
+ import kleur from 'kleur'
4
4
 
5
5
  export interface SQLiteConfiguration extends DatabaseConfiguration {
6
6
  /**
@@ -60,7 +60,7 @@ export class SQLite extends Database {
60
60
  }
61
61
 
62
62
  async onListen() {
63
- console.warn(` ${chalk.yellow('The SQLite extension is intended to be used in a local development environment, not in a production environment.')}`)
63
+ console.warn(` ${kleur.yellow('The SQLite extension is intended to be used in a local development environment, not in a production environment.')}`)
64
64
  console.log()
65
65
  }
66
66