{"_id":"@allmightypush/push-storage-sqlite","name":"@allmightypush/push-storage-sqlite","dist-tags":{"latest":"1.0.0"},"versions":{"1.0.0":{"name":"@allmightypush/push-storage-sqlite","version":"1.0.0","description":"SQLite storage adapter for push notification library","main":"dist/cjs/index.js","module":"dist/esm/index.js","types":"dist/types/index.d.ts","exports":{".":{"require":"./dist/cjs/index.js","import":"./dist/esm/index.js","types":"./dist/types/index.d.ts"}},"scripts":{"build":"npm run build:cjs && npm run build:esm && npm run build:types","build:cjs":"tsc -p tsconfig.cjs.json","build:esm":"tsc -p tsconfig.esm.json","build:types":"tsc -p tsconfig.types.json","test":"jest --passWithNoTests","test:watch":"jest --watch","test:coverage":"jest --coverage --passWithNoTests","clean":"rm -rf dist"},"keywords":["push","notification","storage","sqlite"],"author":{"name":"Samtes64"},"license":"MIT","repository":{"type":"git","url":"git+https://github.com/Samtes64/all-mighty-push.git","directory":"packages/push-storage-sqlite"},"bugs":{"url":"https://github.com/Samtes64/all-mighty-push/issues"},"homepage":"https://github.com/Samtes64/all-mighty-push/tree/main/packages/push-storage-sqlite#readme","dependencies":{"@allmightypush/push-core":"^1.0.0","better-sqlite3":"^9.2.2"},"devDependencies":{"@types/better-sqlite3":"^7.6.8"},"engines":{"node":">=16.0.0"},"_id":"@allmightypush/push-storage-sqlite@1.0.0","gitHead":"8d7b012f519f95515344d9b5c96d4ba42039046b","_nodeVersion":"22.19.0","_npmVersion":"10.9.3","dist":{"integrity":"sha512-3OylSuFj6FkHRfCS/ZX9344nLxH4pILku2Kj4f4pj6U/rEpbJ98vHq3ibIwslOAeBoD2JMMTOCoVwEr7l3pOtQ==","shasum":"21835050a395854ab6983d1140d2868e4f99c080","tarball":"https://registry.npmjs.org/@allmightypush/push-storage-sqlite/-/push-storage-sqlite-1.0.0.tgz","fileCount":8,"unpackedSize":57899,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEYCIQCLZT1kOTXfrpkcQOQ05T3PQEJGlKoZg0qRxUoHgS6mpgIhAPpn7TBsJu4BkMOorPxR3JIKpl3P3T7hEDN9Wh/DvXfr"}]},"_npmUser":{"name":"samtes64","email":"samtes64@gmail.com"},"directories":{},"maintainers":[{"name":"samtes64","email":"samtes64@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/push-storage-sqlite_1.0.0_1768561528299_0.059423752453868106"},"_hasShrinkwrap":false}},"time":{"created":"2026-01-16T11:05:28.228Z","1.0.0":"2026-01-16T11:05:28.430Z","modified":"2026-01-16T11:05:28.607Z"},"maintainers":[{"name":"samtes64","email":"samtes64@gmail.com"}],"description":"SQLite storage adapter for push notification library","homepage":"https://github.com/Samtes64/all-mighty-push/tree/main/packages/push-storage-sqlite#readme","keywords":["push","notification","storage","sqlite"],"repository":{"type":"git","url":"git+https://github.com/Samtes64/all-mighty-push.git","directory":"packages/push-storage-sqlite"},"author":{"name":"Samtes64"},"bugs":{"url":"https://github.com/Samtes64/all-mighty-push/issues"},"license":"MIT","readme":"# @allmightypush/push-storage-sqlite\n\nSQLite storage adapter for the push notification library.\n\n## Installation\n\n```bash\nnpm install @allmightypush/push-storage-sqlite\n```\n\n## Usage\n\n```typescript\nimport { SQLiteStorageAdapter } from '@allmightypush/push-storage-sqlite';\n\n// Create adapter with file-based database\nconst adapter = new SQLiteStorageAdapter({\n  filename: './push-notifications.db',\n  enableWAL: true,      // Enable WAL mode for better concurrency (default: true)\n  autoMigrate: true,    // Run migrations automatically (default: true)\n});\n\n// Or use in-memory database for testing\nconst testAdapter = new SQLiteStorageAdapter({\n  filename: ':memory:',\n});\n\n// Use with push core\nimport { PushCore } from '@allmightypush/push-core';\n\nconst push = new PushCore();\npush.configure({\n  storageAdapter: adapter,\n  // ... other configuration\n});\n```\n\n## Configuration Options\n\n### `SQLiteStorageOptions`\n\n- **`filename`** (required): Path to the SQLite database file, or `':memory:'` for an in-memory database\n- **`enableWAL`** (optional, default: `true`): Enable Write-Ahead Logging mode for better concurrency\n- **`autoMigrate`** (optional, default: `true`): Automatically run database migrations on initialization\n\n## Database Schema\n\n### Subscriptions Table\n\nStores push notification subscriptions with the following columns:\n\n- `id` (TEXT, PRIMARY KEY): UUID identifier\n- `endpoint` (TEXT, NOT NULL): Push service endpoint URL\n- `keys` (TEXT, NOT NULL): JSON-encoded encryption keys (p256dh and auth)\n- `user_id` (TEXT): Optional user identifier\n- `created_at` (INTEGER, NOT NULL): Creation timestamp (Unix milliseconds)\n- `updated_at` (INTEGER, NOT NULL): Last update timestamp (Unix milliseconds)\n- `last_used_at` (INTEGER): Last successful send timestamp (Unix milliseconds)\n- `failed_count` (INTEGER, NOT NULL, DEFAULT 0): Consecutive failure count\n- `status` (TEXT, NOT NULL): Subscription status ('active', 'blocked', or 'expired')\n- `expires_at` (INTEGER): Optional expiration timestamp (Unix milliseconds)\n- `metadata` (TEXT): JSON-encoded arbitrary metadata\n\n**Indexes:**\n- `idx_subscriptions_user_id` on `user_id`\n- `idx_subscriptions_status` on `status`\n\n### Retry Queue Table\n\nStores failed notifications awaiting retry:\n\n- `id` (TEXT, PRIMARY KEY): UUID identifier\n- `subscription_id` (TEXT, NOT NULL): Foreign key to subscriptions table\n- `payload` (TEXT, NOT NULL): JSON-encoded notification payload\n- `attempt` (INTEGER, NOT NULL): Current attempt number (0-indexed)\n- `next_retry_at` (INTEGER, NOT NULL): Next retry timestamp (Unix milliseconds)\n- `last_error` (TEXT): Last error message\n- `created_at` (INTEGER, NOT NULL): Creation timestamp (Unix milliseconds)\n\n**Indexes:**\n- `idx_retry_queue_next_retry` on `next_retry_at`\n\n**Foreign Keys:**\n- `subscription_id` references `subscriptions(id)` with CASCADE DELETE\n\n## Migrations\n\nThe adapter automatically creates the required tables and indexes on initialization (when `autoMigrate` is `true`). You can also run migrations manually:\n\n```typescript\nawait adapter.migrate();\n```\n\nMigrations are idempotent and can be safely called multiple times.\n\n## Features\n\n- ✅ Full StorageAdapter interface implementation\n- ✅ Automatic schema creation and migrations\n- ✅ WAL mode for better concurrency\n- ✅ Efficient indexes for common queries\n- ✅ Foreign key constraints with cascade delete\n- ✅ In-memory database support for testing\n- ✅ TypeScript type definitions included\n\n## License\n\nMIT\n","readmeFilename":"README.md","_rev":"1-adb8fa3b27d893ebaee520ab8d49d45f"}