routeflow-api 1.0.0 → 1.0.1

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.
@@ -0,0 +1,60 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+
20
+ // src/sqlite.ts
21
+ var sqlite_exports = {};
22
+ __export(sqlite_exports, {
23
+ SQLiteStore: () => SQLiteStore
24
+ });
25
+ module.exports = __toCommonJS(sqlite_exports);
26
+
27
+ // src/core/adapter/sqlite-store.ts
28
+ var import_node_sqlite = require("node:sqlite");
29
+ var import_node_fs = require("fs");
30
+ var import_node_path = require("path");
31
+ var SQLiteStore = class {
32
+ db;
33
+ path;
34
+ /**
35
+ * @param dbPath - Path to the SQLite file. Parent directories are created automatically.
36
+ * Relative paths are resolved from `process.cwd()`.
37
+ */
38
+ constructor(dbPath) {
39
+ this.path = (0, import_node_path.resolve)(dbPath);
40
+ (0, import_node_fs.mkdirSync)((0, import_node_path.dirname)(this.path), { recursive: true });
41
+ this.db = new import_node_sqlite.DatabaseSync(this.path);
42
+ }
43
+ /** Execute one or more SQL statements (no return value). */
44
+ exec(sql) {
45
+ this.db.exec(sql);
46
+ }
47
+ /** Prepare a statement for repeated use. */
48
+ prepare(sql) {
49
+ return this.db.prepare(sql);
50
+ }
51
+ /** Close the database connection. */
52
+ close() {
53
+ this.db.close();
54
+ }
55
+ };
56
+ // Annotate the CommonJS export names for ESM import in node:
57
+ 0 && (module.exports = {
58
+ SQLiteStore
59
+ });
60
+ //# sourceMappingURL=sqlite.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/sqlite.ts","../src/core/adapter/sqlite-store.ts"],"sourcesContent":["export { SQLiteStore } from './core/adapter/sqlite-store.js'\nexport type { SqliteRow } from './core/adapter/sqlite-store.js'\n","import { DatabaseSync } from 'node:sqlite'\nimport { mkdirSync } from 'node:fs'\nimport { dirname, resolve } from 'node:path'\n\n/**\n * A generic record type for SQLite rows.\n * Keys map to column names; values are SQLite-compatible primitives.\n */\nexport type SqliteRow = Record<string, string | number | null>\n\n/**\n * File-based key-value store backed by Node's built-in `node:sqlite`.\n * Requires Node.js 22.5+.\n *\n * Data survives server restarts because it is written to a file on disk.\n * The path can be set directly in code — no environment variable required.\n *\n * @example\n * ```ts\n * const store = new SQLiteStore('./data/app.db')\n * store.exec(`CREATE TABLE IF NOT EXISTS items (id INTEGER PRIMARY KEY, name TEXT)`)\n * store.prepare('INSERT INTO items (name) VALUES (?)').run('Apple')\n * const rows = store.prepare('SELECT * FROM items').all()\n * ```\n */\nexport class SQLiteStore {\n readonly db: DatabaseSync\n readonly path: string\n\n /**\n * @param dbPath - Path to the SQLite file. Parent directories are created automatically.\n * Relative paths are resolved from `process.cwd()`.\n */\n constructor(dbPath: string) {\n this.path = resolve(dbPath)\n mkdirSync(dirname(this.path), { recursive: true })\n this.db = new DatabaseSync(this.path)\n }\n\n /** Execute one or more SQL statements (no return value). */\n exec(sql: string): void {\n this.db.exec(sql)\n }\n\n /** Prepare a statement for repeated use. */\n prepare(sql: string): ReturnType<DatabaseSync['prepare']> {\n return this.db.prepare(sql)\n }\n\n /** Close the database connection. */\n close(): void {\n this.db.close()\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA,yBAA6B;AAC7B,qBAA0B;AAC1B,uBAAiC;AAuB1B,IAAM,cAAN,MAAkB;AAAA,EACd;AAAA,EACA;AAAA;AAAA;AAAA;AAAA;AAAA,EAMT,YAAY,QAAgB;AAC1B,SAAK,WAAO,0BAAQ,MAAM;AAC1B,sCAAU,0BAAQ,KAAK,IAAI,GAAG,EAAE,WAAW,KAAK,CAAC;AACjD,SAAK,KAAK,IAAI,gCAAa,KAAK,IAAI;AAAA,EACtC;AAAA;AAAA,EAGA,KAAK,KAAmB;AACtB,SAAK,GAAG,KAAK,GAAG;AAAA,EAClB;AAAA;AAAA,EAGA,QAAQ,KAAkD;AACxD,WAAO,KAAK,GAAG,QAAQ,GAAG;AAAA,EAC5B;AAAA;AAAA,EAGA,QAAc;AACZ,SAAK,GAAG,MAAM;AAAA,EAChB;AACF;","names":[]}
@@ -0,0 +1,39 @@
1
+ import { DatabaseSync } from 'node:sqlite';
2
+
3
+ /**
4
+ * A generic record type for SQLite rows.
5
+ * Keys map to column names; values are SQLite-compatible primitives.
6
+ */
7
+ type SqliteRow = Record<string, string | number | null>;
8
+ /**
9
+ * File-based key-value store backed by Node's built-in `node:sqlite`.
10
+ * Requires Node.js 22.5+.
11
+ *
12
+ * Data survives server restarts because it is written to a file on disk.
13
+ * The path can be set directly in code — no environment variable required.
14
+ *
15
+ * @example
16
+ * ```ts
17
+ * const store = new SQLiteStore('./data/app.db')
18
+ * store.exec(`CREATE TABLE IF NOT EXISTS items (id INTEGER PRIMARY KEY, name TEXT)`)
19
+ * store.prepare('INSERT INTO items (name) VALUES (?)').run('Apple')
20
+ * const rows = store.prepare('SELECT * FROM items').all()
21
+ * ```
22
+ */
23
+ declare class SQLiteStore {
24
+ readonly db: DatabaseSync;
25
+ readonly path: string;
26
+ /**
27
+ * @param dbPath - Path to the SQLite file. Parent directories are created automatically.
28
+ * Relative paths are resolved from `process.cwd()`.
29
+ */
30
+ constructor(dbPath: string);
31
+ /** Execute one or more SQL statements (no return value). */
32
+ exec(sql: string): void;
33
+ /** Prepare a statement for repeated use. */
34
+ prepare(sql: string): ReturnType<DatabaseSync['prepare']>;
35
+ /** Close the database connection. */
36
+ close(): void;
37
+ }
38
+
39
+ export { SQLiteStore, type SqliteRow };
@@ -0,0 +1,39 @@
1
+ import { DatabaseSync } from 'node:sqlite';
2
+
3
+ /**
4
+ * A generic record type for SQLite rows.
5
+ * Keys map to column names; values are SQLite-compatible primitives.
6
+ */
7
+ type SqliteRow = Record<string, string | number | null>;
8
+ /**
9
+ * File-based key-value store backed by Node's built-in `node:sqlite`.
10
+ * Requires Node.js 22.5+.
11
+ *
12
+ * Data survives server restarts because it is written to a file on disk.
13
+ * The path can be set directly in code — no environment variable required.
14
+ *
15
+ * @example
16
+ * ```ts
17
+ * const store = new SQLiteStore('./data/app.db')
18
+ * store.exec(`CREATE TABLE IF NOT EXISTS items (id INTEGER PRIMARY KEY, name TEXT)`)
19
+ * store.prepare('INSERT INTO items (name) VALUES (?)').run('Apple')
20
+ * const rows = store.prepare('SELECT * FROM items').all()
21
+ * ```
22
+ */
23
+ declare class SQLiteStore {
24
+ readonly db: DatabaseSync;
25
+ readonly path: string;
26
+ /**
27
+ * @param dbPath - Path to the SQLite file. Parent directories are created automatically.
28
+ * Relative paths are resolved from `process.cwd()`.
29
+ */
30
+ constructor(dbPath: string);
31
+ /** Execute one or more SQL statements (no return value). */
32
+ exec(sql: string): void;
33
+ /** Prepare a statement for repeated use. */
34
+ prepare(sql: string): ReturnType<DatabaseSync['prepare']>;
35
+ /** Close the database connection. */
36
+ close(): void;
37
+ }
38
+
39
+ export { SQLiteStore, type SqliteRow };
package/dist/sqlite.js ADDED
@@ -0,0 +1,33 @@
1
+ // src/core/adapter/sqlite-store.ts
2
+ import { DatabaseSync } from "node:sqlite";
3
+ import { mkdirSync } from "fs";
4
+ import { dirname, resolve } from "path";
5
+ var SQLiteStore = class {
6
+ db;
7
+ path;
8
+ /**
9
+ * @param dbPath - Path to the SQLite file. Parent directories are created automatically.
10
+ * Relative paths are resolved from `process.cwd()`.
11
+ */
12
+ constructor(dbPath) {
13
+ this.path = resolve(dbPath);
14
+ mkdirSync(dirname(this.path), { recursive: true });
15
+ this.db = new DatabaseSync(this.path);
16
+ }
17
+ /** Execute one or more SQL statements (no return value). */
18
+ exec(sql) {
19
+ this.db.exec(sql);
20
+ }
21
+ /** Prepare a statement for repeated use. */
22
+ prepare(sql) {
23
+ return this.db.prepare(sql);
24
+ }
25
+ /** Close the database connection. */
26
+ close() {
27
+ this.db.close();
28
+ }
29
+ };
30
+ export {
31
+ SQLiteStore
32
+ };
33
+ //# sourceMappingURL=sqlite.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/core/adapter/sqlite-store.ts"],"sourcesContent":["import { DatabaseSync } from 'node:sqlite'\nimport { mkdirSync } from 'node:fs'\nimport { dirname, resolve } from 'node:path'\n\n/**\n * A generic record type for SQLite rows.\n * Keys map to column names; values are SQLite-compatible primitives.\n */\nexport type SqliteRow = Record<string, string | number | null>\n\n/**\n * File-based key-value store backed by Node's built-in `node:sqlite`.\n * Requires Node.js 22.5+.\n *\n * Data survives server restarts because it is written to a file on disk.\n * The path can be set directly in code — no environment variable required.\n *\n * @example\n * ```ts\n * const store = new SQLiteStore('./data/app.db')\n * store.exec(`CREATE TABLE IF NOT EXISTS items (id INTEGER PRIMARY KEY, name TEXT)`)\n * store.prepare('INSERT INTO items (name) VALUES (?)').run('Apple')\n * const rows = store.prepare('SELECT * FROM items').all()\n * ```\n */\nexport class SQLiteStore {\n readonly db: DatabaseSync\n readonly path: string\n\n /**\n * @param dbPath - Path to the SQLite file. Parent directories are created automatically.\n * Relative paths are resolved from `process.cwd()`.\n */\n constructor(dbPath: string) {\n this.path = resolve(dbPath)\n mkdirSync(dirname(this.path), { recursive: true })\n this.db = new DatabaseSync(this.path)\n }\n\n /** Execute one or more SQL statements (no return value). */\n exec(sql: string): void {\n this.db.exec(sql)\n }\n\n /** Prepare a statement for repeated use. */\n prepare(sql: string): ReturnType<DatabaseSync['prepare']> {\n return this.db.prepare(sql)\n }\n\n /** Close the database connection. */\n close(): void {\n this.db.close()\n }\n}\n"],"mappings":";AAAA,SAAS,oBAAoB;AAC7B,SAAS,iBAAiB;AAC1B,SAAS,SAAS,eAAe;AAuB1B,IAAM,cAAN,MAAkB;AAAA,EACd;AAAA,EACA;AAAA;AAAA;AAAA;AAAA;AAAA,EAMT,YAAY,QAAgB;AAC1B,SAAK,OAAO,QAAQ,MAAM;AAC1B,cAAU,QAAQ,KAAK,IAAI,GAAG,EAAE,WAAW,KAAK,CAAC;AACjD,SAAK,KAAK,IAAI,aAAa,KAAK,IAAI;AAAA,EACtC;AAAA;AAAA,EAGA,KAAK,KAAmB;AACtB,SAAK,GAAG,KAAK,GAAG;AAAA,EAClB;AAAA;AAAA,EAGA,QAAQ,KAAkD;AACxD,WAAO,KAAK,GAAG,QAAQ,GAAG;AAAA,EAC5B;AAAA;AAAA,EAGA,QAAc;AACZ,SAAK,GAAG,MAAM;AAAA,EAChB;AACF;","names":[]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "routeflow-api",
3
- "version": "1.0.0",
3
+ "version": "1.0.1",
4
4
  "description": "RouteFlow — REST API with real-time database push subscriptions",
5
5
  "license": "Apache-2.0",
6
6
  "repository": {
@@ -42,6 +42,11 @@
42
42
  "import": "./dist/index.js",
43
43
  "require": "./dist/index.cjs"
44
44
  },
45
+ "./sqlite": {
46
+ "types": "./dist/sqlite.d.ts",
47
+ "import": "./dist/sqlite.js",
48
+ "require": "./dist/sqlite.cjs"
49
+ },
45
50
  "./client": {
46
51
  "types": "./dist/client/index.d.ts",
47
52
  "import": "./dist/client/index.js",
@@ -94,7 +99,7 @@
94
99
  }
95
100
  },
96
101
  "scripts": {
97
- "build": "tsup",
102
+ "build": "tsup && sed -i '' 's/from \"sqlite\"/from \"node:sqlite\"/g; s/require(\"sqlite\")/require(\"node:sqlite\")/g' dist/sqlite.js dist/sqlite.cjs",
98
103
  "test": "vitest run",
99
104
  "dev": "tsup --watch"
100
105
  },
@@ -147,7 +152,7 @@
147
152
  }
148
153
  },
149
154
  "devDependencies": {
150
- "@types/node": "^20.0.0",
155
+ "@types/node": "^22.0.0",
151
156
  "@types/pg": "^8.11.10",
152
157
  "@types/ws": "^8.5.13",
153
158
  "tsup": "^8.0.0",