{"_id":"@biks2013/asset-database","_rev":"3-bfc039a2ecbda77e7c1892889811be40","name":"@biks2013/asset-database","dist-tags":{"latest":"1.0.2"},"versions":{"1.0.0":{"name":"@biks2013/asset-database","version":"1.0.0","license":"MIT","_id":"@biks2013/asset-database@1.0.0","maintainers":[{"name":"giorgos-marinos","email":"giorgos.marinos@gmail.com"}],"dist":{"shasum":"29a2660d7d3ea1730edae24589f8993333c64ad8","tarball":"https://registry.npmjs.org/@biks2013/asset-database/-/asset-database-1.0.0.tgz","fileCount":15,"integrity":"sha512-itRUt00YY0y/LGzH01ikCIMn3Zj+2UMOMs1LWdy76oZkydwpW/6aflcRzcX8KyPZSGw7xTDKVifLmt1e+N5aZQ==","signatures":[{"sig":"MEYCIQC5ak2D2qFKQm1pTi+tCIhxgXqG4ANgvDVPSLwKTRY+RAIhAIozfcyCO6xRW/bGiKXOIePvPFkEil6m8/zLHcljQYlu","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":53115},"main":"dist/index.js","types":"dist/index.d.ts","gitHead":"8c424647d7f1e6bbd6d881bb419c11ba455d1176","scripts":{"lint":"eslint . --ext .ts","test":"jest","build":"tsc -p tsconfig.json","clean":"rm -rf dist coverage","typecheck":"tsc --noEmit"},"_npmUser":{"name":"giorgos-marinos","actor":{"name":"giorgos-marinos","type":"user","email":"giorgos.marinos@gmail.com"},"email":"giorgos.marinos@gmail.com"},"_npmVersion":"10.9.2","description":"PostgreSQL storage for configuration assets with version history","directories":{},"_nodeVersion":"23.5.0","dependencies":{"pg":"^8.11.5","crypto":"^1.0.1"},"publishConfig":{"access":"public"},"_hasShrinkwrap":false,"devDependencies":{"jest":"^29.7.0","ts-jest":"^29.1.2","@types/pg":"^8.11.4","typescript":"^5.4.3","@types/jest":"^29.5.12","@types/node":"^20.11.30"},"peerDependencies":{"@types/node":">=18"},"_npmOperationalInternal":{"tmp":"tmp/asset-database_1.0.0_1750872951325_0.8685598404580277","host":"s3://npm-registry-packages-npm-production"}},"1.0.1":{"name":"@biks2013/asset-database","version":"1.0.1","license":"MIT","_id":"@biks2013/asset-database@1.0.1","maintainers":[{"name":"giorgos-marinos","email":"giorgos.marinos@gmail.com"}],"dist":{"shasum":"db78534d6a5458e7cc5ada238051798bca281d39","tarball":"https://registry.npmjs.org/@biks2013/asset-database/-/asset-database-1.0.1.tgz","fileCount":14,"integrity":"sha512-trexi9pZF6v9NY8jGXQeHACV41wA7/d7bcE7Njw322ocOKF4MzxrW9FN3wMEpxDbql/HFQ2NQxNfexNSVfnzwg==","signatures":[{"sig":"MEUCIQDtw2VYfS+EZTYy2eTntVTWtUZ4EeFdYEjKkK2EqtIbLwIgRlJP0RMk/cPn5J4hX77XNyIF2RJZj92we+1Bf5CMgxg=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":54575},"main":"dist/index.js","types":"dist/index.d.ts","gitHead":"3849a10639eca910d3cb0ef9ccfd8ab8a3374757","scripts":{"lint":"eslint . --ext .ts","test":"jest","build":"tsc -p tsconfig.json","clean":"rm -rf dist coverage","typecheck":"tsc --noEmit"},"_npmUser":{"name":"giorgos-marinos","actor":{"name":"giorgos-marinos","type":"user","email":"giorgos.marinos@gmail.com"},"email":"giorgos.marinos@gmail.com"},"_npmVersion":"10.9.2","description":"PostgreSQL storage for configuration assets with version history","directories":{},"_nodeVersion":"23.11.0","dependencies":{"pg":"^8.11.5","crypto":"^1.0.1"},"publishConfig":{"access":"public"},"_hasShrinkwrap":false,"devDependencies":{"jest":"^29.7.0","ts-jest":"^29.1.2","@types/pg":"^8.11.4","typescript":"^5.4.3","@types/jest":"^29.5.12","@types/node":"^20.11.30"},"peerDependencies":{"@types/node":">=18"},"_npmOperationalInternal":{"tmp":"tmp/asset-database_1.0.1_1750925624339_0.6177281166206223","host":"s3://npm-registry-packages-npm-production"}},"1.0.2":{"name":"@biks2013/asset-database","version":"1.0.2","description":"PostgreSQL storage for configuration assets with version history","main":"dist/index.js","types":"dist/index.d.ts","scripts":{"build":"tsc -p tsconfig.json","test":"jest","lint":"eslint . --ext .ts","clean":"rm -rf dist coverage","typecheck":"tsc --noEmit"},"dependencies":{"pg":"^8.11.5","crypto":"^1.0.1"},"devDependencies":{"@types/jest":"^29.5.12","@types/node":"^20.11.30","@types/pg":"^8.11.4","jest":"^29.7.0","ts-jest":"^29.1.2","typescript":"^5.4.3"},"peerDependencies":{"@types/node":">=18"},"publishConfig":{"access":"public"},"license":"MIT","_id":"@biks2013/asset-database@1.0.2","gitHead":"f5600780d833f3038dbf0cbd5f11f2bfd6e962fb","_nodeVersion":"23.11.0","_npmVersion":"10.9.2","dist":{"integrity":"sha512-AeA7pLg86VpbpMgWTvw6gCiAxz+OpRWTgGDoY4bCcgc+D2eOgalItpFV4CPBeQ2YRjQI03kcnSKhS+yt2s6xbw==","shasum":"0c06675e713f8ffa2944cb5a9fee2350b1eca183","tarball":"https://registry.npmjs.org/@biks2013/asset-database/-/asset-database-1.0.2.tgz","fileCount":14,"unpackedSize":54599,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEQCIHwLJI96Kqy9iQt4s5UYUoWiaDuIHjSHNafIsuUeA837AiALBfGj5fz27j6WHW9QVzMqjpyQQz/qImd40epOFmYaXw=="}]},"_npmUser":{"name":"giorgos-marinos","email":"giorgos.marinos@gmail.com"},"directories":{},"maintainers":[{"name":"giorgos-marinos","email":"giorgos.marinos@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/asset-database_1.0.2_1752189092560_0.11239700103742134"},"_hasShrinkwrap":false}},"time":{"created":"2025-06-25T17:35:51.204Z","modified":"2025-07-10T23:11:32.959Z","1.0.0":"2025-06-25T17:35:51.502Z","1.0.1":"2025-06-26T08:13:44.520Z","1.0.2":"2025-07-10T23:11:32.750Z"},"license":"MIT","description":"PostgreSQL storage for configuration assets with version history","maintainers":[{"name":"giorgos-marinos","email":"giorgos.marinos@gmail.com"}],"readme":"# @biks2013/asset-database\n\nPostgreSQL storage service for configuration assets with version history and audit logging.\n\n## Installation\n\n```bash\nnpm install @biks2013/asset-database\n```\n\n## Features\n\n- 🗄️ PostgreSQL storage with JSONB support\n- 📝 Full version history and audit logging\n- 🔐 SHA256 hash tracking for change detection\n- 🏷️ Category-based organization\n- 🔄 Connection pooling and retry logic\n- ☁️ Azure PostgreSQL support\n\n## Usage\n\n```typescript\nimport { AssetDatabaseService } from '@biks2013/asset-database';\n\nconst service = new AssetDatabaseService({\n  connectionString: 'postgresql://user:pass@localhost:5432/mydb',\n  ownerCategory: 'application',\n  ownerKey: 'my-app',\n  ssl: true,\n  poolSize: 10,\n});\n\n// Ensure database schema exists\nawait service.ensureSchema();\n\n// Store an asset\nawait service.storeAsset(\n  'app-config',\n  JSON.stringify({ version: '1.0.0' }),\n  'config',\n  'Application configuration'\n);\n\n// Retrieve an asset\nconst asset = await service.getAsset('app-config', 'config');\nif (asset) {\n  console.log(asset.data.content);\n}\n\n// List all assets\nconst assets = await service.listAssets('config');\n\n// Get asset history\nconst history = await service.getAssetHistory('app-config');\n\n// Delete an asset\nawait service.deleteAsset('app-config');\n\n// Close connection pool\nawait service.close();\n```\n\n## Database Schema\n\nThe service automatically creates two tables:\n\n### `asset` Table\n\n```sql\nCREATE TABLE public.asset (\n  id UUID PRIMARY KEY DEFAULT gen_random_uuid(),\n  created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,\n  owner_category VARCHAR(255) NOT NULL,\n  asset_category VARCHAR(255) NOT NULL,\n  owner_key VARCHAR(255) NOT NULL,\n  asset_key VARCHAR(255) NOT NULL,\n  description TEXT,\n  data JSONB NOT NULL,\n  data_hash VARCHAR(64) NOT NULL,\n  UNIQUE(owner_key, asset_key)\n);\n```\n\n### `asset_log` Table\n\n```sql\nCREATE TABLE public.asset_log (\n  id UUID PRIMARY KEY DEFAULT gen_random_uuid(),\n  asset_id UUID REFERENCES public.asset(id),\n  created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,\n  owner_category VARCHAR(255) NOT NULL,\n  asset_category VARCHAR(255) NOT NULL,\n  owner_key VARCHAR(255) NOT NULL,\n  asset_key VARCHAR(255) NOT NULL,\n  description TEXT,\n  data JSONB NOT NULL,\n  data_hash VARCHAR(64) NOT NULL\n);\n```\n\n## API\n\n### Constructor Options\n\n```typescript\ninterface AssetDatabaseOptions {\n  connectionString: string;  // PostgreSQL connection string\n  ownerCategory: string;     // Category for this service instance\n  ownerKey: string;          // Unique key for this service instance\n  ssl?: boolean;             // Enable SSL (default: auto-detect)\n  poolSize?: number;         // Connection pool size (default: 10)\n}\n```\n\n### Methods\n\n#### `ensureSchema(): Promise<void>`\n\nCreates the database schema if it doesn't exist.\n\n#### `getAsset(key: string, category?: string): Promise<AssetRecord | null>`\n\nRetrieves an asset by key and optional category.\n\n#### `storeAsset(key: string, content: string, category?: string, description?: string): Promise<void>`\n\nStores or updates an asset. Automatically creates history entries.\n\n#### `listAssets(category?: string): Promise<AssetMetadata[]>`\n\nLists all assets, optionally filtered by category.\n\n#### `getAssetHistory(key: string): Promise<AssetHistoryRecord[]>`\n\nRetrieves the complete history for an asset.\n\n#### `deleteAsset(key: string): Promise<boolean>`\n\nDeletes an asset and its history. Returns true if deleted.\n\n#### `close(): Promise<void>`\n\nCloses the database connection pool.\n\n## Connection String Format\n\nStandard PostgreSQL:\n```\npostgresql://username:password@host:port/database\n```\n\nAzure PostgreSQL:\n```\npostgresql://username@servername:password@servername.postgres.database.azure.com:5432/database?sslmode=require\n```\n\n## License\n\nMIT","readmeFilename":"README.md"}