{"_id":"@dokhna-tech/zatca-storage-postgres","_rev":"6-ed2c0037016a94564283be9ed9721b3d","name":"@dokhna-tech/zatca-storage-postgres","dist-tags":{"latest":"4.0.1"},"versions":{"1.0.0":{"name":"@dokhna-tech/zatca-storage-postgres","version":"1.0.0","license":"BUSL-1.1","_id":"@dokhna-tech/zatca-storage-postgres@1.0.0","maintainers":[{"name":"ameensom","email":"amin4mail@yahoo.com"}],"dist":{"shasum":"8961ee86df48621c40fd2266aaba4cae0b9abe2b","tarball":"https://registry.npmjs.org/@dokhna-tech/zatca-storage-postgres/-/zatca-storage-postgres-1.0.0.tgz","fileCount":11,"integrity":"sha512-TUuwjnUZD0r65R6hn3NWZHGECp5s02LsB7SUgaSoSoKRUvnC6gxavy73W0UWKIGx3kUgaoTN0uGxelgQOzXdGw==","signatures":[{"sig":"MEUCIQDSsD62XXU+1/KRrnWueoB8F54HF8cVeWyrXZPcFIPw8QIgQcmX7Rduweo/roN4DTUmadXn7lfKFkePK7mCODa8nmY=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":66719},"main":"./dist/index.cjs","type":"module","_from":"file:dokhna-tech-zatca-storage-postgres-1.0.0.tgz","types":"./dist/index.d.ts","module":"./dist/index.js","engines":{"node":">=20.0.0"},"exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.js","require":"./dist/index.cjs"}},"scripts":{"dev":"tsup --watch","test":"vitest run --passWithNoTests","build":"tsup","typecheck":"tsc --noEmit"},"_npmUser":{"name":"ameensom","email":"amin4mail@yahoo.com"},"_resolved":"/private/var/folders/14/y1m00gyx24b054fzqk4wb_2c0000gn/T/0d0eeecf447e020bfe2d439e8c692351/dokhna-tech-zatca-storage-postgres-1.0.0.tgz","_integrity":"sha512-TUuwjnUZD0r65R6hn3NWZHGECp5s02LsB7SUgaSoSoKRUvnC6gxavy73W0UWKIGx3kUgaoTN0uGxelgQOzXdGw==","_npmVersion":"11.6.4","description":"PostgreSQL storage adapter for @dokhna-tech/zatca (raw pg client).","directories":{},"_nodeVersion":"22.18.0","dependencies":{"debug":"^4.3.7"},"publishConfig":{"access":"public"},"_hasShrinkwrap":false,"devDependencies":{"pg":"^8.20.0","pg-mem":"^3.0.5","@types/pg":"^8.11.10","@types/debug":"^4.1.12","@dokhna-tech/zatca":"2.0.0"},"peerDependencies":{"pg":">=8.0.0","@dokhna-tech/zatca":"2.0.0"},"_npmOperationalInternal":{"tmp":"tmp/zatca-storage-postgres_1.0.0_1778762283557_0.06261073205788881","host":"s3://npm-registry-packages-npm-production"}},"2.0.2":{"name":"@dokhna-tech/zatca-storage-postgres","version":"2.0.2","license":"BUSL-1.1","_id":"@dokhna-tech/zatca-storage-postgres@2.0.2","maintainers":[{"name":"ameensom","email":"amin4mail@yahoo.com"}],"dist":{"shasum":"6a9684e2c88935c1e8bbcf709730a4bb812f56bb","tarball":"https://registry.npmjs.org/@dokhna-tech/zatca-storage-postgres/-/zatca-storage-postgres-2.0.2.tgz","fileCount":11,"integrity":"sha512-bBvSlRjCTDYhZnqcUEgx57JXkYO1KIBTlaiVJZscKdF91Fgorf8h2QbnwEXY0UBG9BNRSYmoM4McfOl0RhYeMw==","signatures":[{"sig":"MEUCIFZHyETX7tU9oEjRTSLtQJTDK1v83f2LO8tNUouuwE3CAiEA72vE7IPIPHf3YEX2hW/NzTxslOgr5DaZoBMwE3nIujI=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":68193},"main":"./dist/index.cjs","type":"module","_from":"file:dokhna-tech-zatca-storage-postgres-2.0.2.tgz","types":"./dist/index.d.ts","module":"./dist/index.js","engines":{"node":">=20.0.0"},"exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.js","require":"./dist/index.cjs"}},"scripts":{"dev":"tsup --watch","test":"vitest run --passWithNoTests","build":"tsup","typecheck":"tsc --noEmit"},"_npmUser":{"name":"ameensom","email":"amin4mail@yahoo.com"},"_resolved":"/tmp/1411f61fb37353e65e87d9fa74834cf1/dokhna-tech-zatca-storage-postgres-2.0.2.tgz","_integrity":"sha512-bBvSlRjCTDYhZnqcUEgx57JXkYO1KIBTlaiVJZscKdF91Fgorf8h2QbnwEXY0UBG9BNRSYmoM4McfOl0RhYeMw==","_npmVersion":"10.9.7","description":"PostgreSQL storage adapter for @dokhna-tech/zatca (raw pg client).","directories":{},"_nodeVersion":"22.22.2","dependencies":{"debug":"^4.3.7"},"publishConfig":{"access":"public"},"_hasShrinkwrap":false,"devDependencies":{"pg":"^8.20.0","pg-mem":"^3.0.5","@types/pg":"^8.11.10","@types/debug":"^4.1.12","@dokhna-tech/zatca":"2.0.2"},"peerDependencies":{"pg":">=8.0.0","@dokhna-tech/zatca":"2.0.2"},"_npmOperationalInternal":{"tmp":"tmp/zatca-storage-postgres_2.0.2_1778766202999_0.020845458289624252","host":"s3://npm-registry-packages-npm-production"}},"2.0.3":{"name":"@dokhna-tech/zatca-storage-postgres","version":"2.0.3","license":"BUSL-1.1","_id":"@dokhna-tech/zatca-storage-postgres@2.0.3","maintainers":[{"name":"ameensom","email":"amin4mail@yahoo.com"}],"homepage":"https://github.com/dokhna/dokhna-tech-zatca#readme","bugs":{"url":"https://github.com/dokhna/dokhna-tech-zatca/issues"},"dist":{"shasum":"85f5a9ec5abee84bc0af6d39cf073a07568e4322","tarball":"https://registry.npmjs.org/@dokhna-tech/zatca-storage-postgres/-/zatca-storage-postgres-2.0.3.tgz","fileCount":11,"integrity":"sha512-dQdHu4F9K7hgVlDZ8GjZUOpQktfBkC0NiA2Pqd4CoRSz/V1zX5QQPHODSKxWKI0jbhrSEzioVr0sEDht1gspFg==","signatures":[{"sig":"MEUCIDRI61BQsXE+rnBBMeKbHxp3kkYv6zZSg0lZTm4A3ZscAiEA7zhJjyegbqwfzNk7At/6UrNF+d/zouSltCBRvjjtjwk=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":68495},"main":"./dist/index.cjs","type":"module","_from":"file:dokhna-tech-zatca-storage-postgres-2.0.3.tgz","types":"./dist/index.d.ts","module":"./dist/index.js","engines":{"node":">=20.0.0"},"exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.js","require":"./dist/index.cjs"}},"scripts":{"dev":"tsup --watch","test":"vitest run --passWithNoTests","build":"tsup","typecheck":"tsc --noEmit"},"_npmUser":{"name":"ameensom","email":"amin4mail@yahoo.com"},"_resolved":"/tmp/6aed8bbaa7eeb604ab416f2abee8f6a4/dokhna-tech-zatca-storage-postgres-2.0.3.tgz","_integrity":"sha512-dQdHu4F9K7hgVlDZ8GjZUOpQktfBkC0NiA2Pqd4CoRSz/V1zX5QQPHODSKxWKI0jbhrSEzioVr0sEDht1gspFg==","repository":{"url":"git+https://github.com/dokhna/dokhna-tech-zatca.git","type":"git","directory":"packages/storage-postgres"},"_npmVersion":"10.9.7","description":"PostgreSQL storage adapter for @dokhna-tech/zatca (raw pg client).","directories":{},"_nodeVersion":"22.22.2","dependencies":{"debug":"^4.3.7"},"publishConfig":{"access":"public"},"_hasShrinkwrap":false,"devDependencies":{"pg":"^8.20.0","pg-mem":"^3.0.5","@types/pg":"^8.11.10","@types/debug":"^4.1.12","@dokhna-tech/zatca":"2.0.3"},"peerDependencies":{"pg":">=8.0.0","@dokhna-tech/zatca":"2.0.3"},"_npmOperationalInternal":{"tmp":"tmp/zatca-storage-postgres_2.0.3_1778781332973_0.09337059889256993","host":"s3://npm-registry-packages-npm-production"}},"2.0.4":{"name":"@dokhna-tech/zatca-storage-postgres","version":"2.0.4","license":"BUSL-1.1","_id":"@dokhna-tech/zatca-storage-postgres@2.0.4","maintainers":[{"name":"ameensom","email":"amin4mail@yahoo.com"}],"homepage":"https://github.com/dokhna/dokhna-tech-zatca#readme","bugs":{"url":"https://github.com/dokhna/dokhna-tech-zatca/issues"},"dist":{"shasum":"1000ab5e3cd94b0f20d745a3c12375ca7490f091","tarball":"https://registry.npmjs.org/@dokhna-tech/zatca-storage-postgres/-/zatca-storage-postgres-2.0.4.tgz","fileCount":11,"integrity":"sha512-F7+FTEoDG+Yl0Pop1l8TR1m+PqVoMD3HjJGQTjB3DKmT9WT3CcGsaAsA7dhphntNabAc4C9sgnZwmbPFKtW8Ew==","signatures":[{"sig":"MEUCIQCkHtxmH4eeiaVR9FwR4TavWF+dInkQtne16zB1wEU4QwIgX+r2fzyuJmp/vxMg16Mu+mvQHJ5v6PQQcxPGLnYbzjY=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":68561},"main":"./dist/index.cjs","type":"module","_from":"file:dokhna-tech-zatca-storage-postgres-2.0.4.tgz","types":"./dist/index.d.ts","module":"./dist/index.js","engines":{"node":">=20.19.0"},"exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.js","require":"./dist/index.cjs"}},"scripts":{"dev":"tsup --watch","test":"vitest run --passWithNoTests","build":"tsup","typecheck":"tsc --noEmit","test:coverage":"vitest run --coverage --passWithNoTests"},"_npmUser":{"name":"ameensom","email":"amin4mail@yahoo.com"},"_resolved":"/tmp/891452b5e209ff7c904883aed549fec3/dokhna-tech-zatca-storage-postgres-2.0.4.tgz","_integrity":"sha512-F7+FTEoDG+Yl0Pop1l8TR1m+PqVoMD3HjJGQTjB3DKmT9WT3CcGsaAsA7dhphntNabAc4C9sgnZwmbPFKtW8Ew==","repository":{"url":"git+https://github.com/dokhna/dokhna-tech-zatca.git","type":"git","directory":"packages/storage-postgres"},"_npmVersion":"10.9.7","description":"PostgreSQL storage adapter for @dokhna-tech/zatca (raw pg client).","directories":{},"_nodeVersion":"22.22.2","dependencies":{"debug":"^4.3.7"},"publishConfig":{"access":"public"},"_hasShrinkwrap":false,"devDependencies":{"pg":"^8.20.0","pg-mem":"^3.0.14","@types/pg":"^8.11.10","@types/debug":"^4.1.12","@dokhna-tech/zatca":"2.0.4"},"peerDependencies":{"pg":">=8.0.0","@dokhna-tech/zatca":"2.0.4"},"_npmOperationalInternal":{"tmp":"tmp/zatca-storage-postgres_2.0.4_1778842975912_0.02361707368910171","host":"s3://npm-registry-packages-npm-production"}},"4.0.0":{"name":"@dokhna-tech/zatca-storage-postgres","version":"4.0.0","license":"BUSL-1.1","_id":"@dokhna-tech/zatca-storage-postgres@4.0.0","maintainers":[{"name":"ameensom","email":"amin4mail@yahoo.com"}],"homepage":"https://github.com/dokhna/dokhna-tech-zatca#readme","bugs":{"url":"https://github.com/dokhna/dokhna-tech-zatca/issues"},"dist":{"shasum":"9f942285b882fe7f86fbc343c90ead224047ca17","tarball":"https://registry.npmjs.org/@dokhna-tech/zatca-storage-postgres/-/zatca-storage-postgres-4.0.0.tgz","fileCount":11,"integrity":"sha512-4xzqNYrhZhp1DYcJu3eYi108I4dkxT+f4v8i5OD6BRLCR+KAQD0Azth8o7s9k3Bf+EmStt3JyU6MztviGjliFA==","signatures":[{"sig":"MEUCIGx3Io5F6/R4NrFnkhoVqykCSbOT/JcYMlIFOhmoFP62AiEA9CBFviNeBo31w03xPrmQ9mnWH0dObRWwBUSTeIpS13I=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":68561},"main":"./dist/index.cjs","type":"module","_from":"file:dokhna-tech-zatca-storage-postgres-4.0.0.tgz","types":"./dist/index.d.ts","module":"./dist/index.js","engines":{"node":">=20.19.0"},"exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.js","require":"./dist/index.cjs"}},"scripts":{"dev":"tsup --watch","test":"vitest run --passWithNoTests","build":"tsup","typecheck":"tsc --noEmit","test:coverage":"vitest run --coverage --passWithNoTests"},"_npmUser":{"name":"ameensom","email":"amin4mail@yahoo.com"},"_resolved":"/tmp/1d810a860472dca5b25bcabe0d1c55d5/dokhna-tech-zatca-storage-postgres-4.0.0.tgz","_integrity":"sha512-4xzqNYrhZhp1DYcJu3eYi108I4dkxT+f4v8i5OD6BRLCR+KAQD0Azth8o7s9k3Bf+EmStt3JyU6MztviGjliFA==","repository":{"url":"git+https://github.com/dokhna/dokhna-tech-zatca.git","type":"git","directory":"packages/storage-postgres"},"_npmVersion":"10.9.7","description":"PostgreSQL storage adapter for @dokhna-tech/zatca (raw pg client).","directories":{},"_nodeVersion":"22.22.2","dependencies":{"debug":"^4.3.7"},"publishConfig":{"access":"public"},"_hasShrinkwrap":false,"devDependencies":{"pg":"^8.20.0","pg-mem":"^3.0.14","@types/pg":"^8.11.10","@types/debug":"^4.1.12","@dokhna-tech/zatca":"4.0.0"},"peerDependencies":{"pg":">=8.0.0","@dokhna-tech/zatca":"4.0.0"},"_npmOperationalInternal":{"tmp":"tmp/zatca-storage-postgres_4.0.0_1779089787773_0.2980454635960408","host":"s3://npm-registry-packages-npm-production"}},"4.0.1":{"name":"@dokhna-tech/zatca-storage-postgres","version":"4.0.1","description":"PostgreSQL storage adapter for @dokhna-tech/zatca (raw pg client).","license":"BUSL-1.1","repository":{"type":"git","url":"git+https://github.com/dokhna/dokhna-tech-zatca.git","directory":"packages/storage-postgres"},"homepage":"https://github.com/dokhna/dokhna-tech-zatca#readme","bugs":{"url":"https://github.com/dokhna/dokhna-tech-zatca/issues"},"type":"module","main":"./dist/index.cjs","module":"./dist/index.js","types":"./dist/index.d.ts","exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.js","require":"./dist/index.cjs"}},"engines":{"node":">=20.19.0"},"publishConfig":{"access":"public"},"dependencies":{"debug":"^4.3.7"},"peerDependencies":{"pg":">=8.0.0","@dokhna-tech/zatca":"4.0.1"},"devDependencies":{"@types/debug":"^4.1.12","@types/pg":"^8.11.10","pg":"^8.20.0","pg-mem":"^3.0.14","@dokhna-tech/zatca":"4.0.1"},"scripts":{"build":"tsup","dev":"tsup --watch","typecheck":"tsc --noEmit","test":"vitest run --passWithNoTests","test:coverage":"vitest run --coverage --passWithNoTests"},"_id":"@dokhna-tech/zatca-storage-postgres@4.0.1","_integrity":"sha512-8xCYiIYKXSwJV+TR6pBQdJJ+Z+Jz8Tf94KI/316n+Pc1inawrXgtBgaBC/7fYttEec0IEz5ObU4T/Uv6zrJgKQ==","_resolved":"/tmp/4a0f8e0cd10c1823eb0948c9b150d1a1/dokhna-tech-zatca-storage-postgres-4.0.1.tgz","_from":"file:dokhna-tech-zatca-storage-postgres-4.0.1.tgz","_nodeVersion":"22.22.3","_npmVersion":"10.9.8","dist":{"integrity":"sha512-8xCYiIYKXSwJV+TR6pBQdJJ+Z+Jz8Tf94KI/316n+Pc1inawrXgtBgaBC/7fYttEec0IEz5ObU4T/Uv6zrJgKQ==","shasum":"8f88ea8a233dd69995829afd22f5902f25afce33","tarball":"https://registry.npmjs.org/@dokhna-tech/zatca-storage-postgres/-/zatca-storage-postgres-4.0.1.tgz","fileCount":11,"unpackedSize":68561,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEUCICk9BZMwp/uVZ+/cSmFj7JwYJzNcreRbxkVeNS6pVPjHAiEA16F2/y8FA1FrsMoK1yfCw15+ES3JFrJb7NoXjaOIKSs="}]},"_npmUser":{"name":"ameensom","email":"amin4mail@yahoo.com"},"directories":{},"maintainers":[{"name":"ameensom","email":"amin4mail@yahoo.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/zatca-storage-postgres_4.0.1_1781527870992_0.2850522683698913"},"_hasShrinkwrap":false}},"time":{"created":"2026-05-14T12:38:03.498Z","modified":"2026-06-15T12:51:11.278Z","1.0.0":"2026-05-14T12:38:03.730Z","2.0.2":"2026-05-14T13:43:23.131Z","2.0.3":"2026-05-14T17:55:33.102Z","2.0.4":"2026-05-15T11:02:56.052Z","4.0.0":"2026-05-18T07:36:27.912Z","4.0.1":"2026-06-15T12:51:11.139Z"},"bugs":{"url":"https://github.com/dokhna/dokhna-tech-zatca/issues"},"license":"BUSL-1.1","homepage":"https://github.com/dokhna/dokhna-tech-zatca#readme","repository":{"type":"git","url":"git+https://github.com/dokhna/dokhna-tech-zatca.git","directory":"packages/storage-postgres"},"description":"PostgreSQL storage adapter for @dokhna-tech/zatca (raw pg client).","maintainers":[{"name":"ameensom","email":"amin4mail@yahoo.com"}],"readme":"# @dokhna-tech/zatca-storage-postgres\n\nPostgreSQL `StorageAdapter` for [`@dokhna-tech/zatca`](https://www.npmjs.com/package/@dokhna-tech/zatca). Uses the raw [`pg`](https://www.npmjs.com/package/pg) client — no Knex / Prisma / TypeORM dependency. Suitable for production single-VAT and multi-VAT (multi-tenant SaaS) deployments.\n\n[![npm](https://img.shields.io/npm/v/@dokhna-tech/zatca-storage-postgres.svg)](https://www.npmjs.com/package/@dokhna-tech/zatca-storage-postgres)\n[![license](https://img.shields.io/badge/license-BUSL--1.1-blue.svg)](./LICENSE)\n\n## Install\n\n```bash\nnpm install @dokhna-tech/zatca @dokhna-tech/zatca-storage-postgres pg\n```\n\nPeer dependencies:\n- `@dokhna-tech/zatca` — the core library\n- `pg >= 8.0.0`\n\n## Migrations\n\nThis package ships SQL migrations under `./migrations`. Apply `001_initial.sql` to your database before first use:\n\n```bash\npsql \"$DATABASE_URL\" -f node_modules/@dokhna-tech/zatca-storage-postgres/migrations/001_initial.sql\n```\n\nSee [`migrations/README.md`](./migrations/README.md) for the schema overview (`zatca_counters`, `zatca_invoices`).\n\n## Usage\n\n```ts\nimport { Pool } from \"pg\";\nimport { createPostgresStorageAdapter } from \"@dokhna-tech/zatca-storage-postgres\";\nimport { issueSimplifiedTaxInvoice, asVATNumber, asEGSUuid } from \"@dokhna-tech/zatca\";\n\nconst pool = new Pool({ connectionString: process.env.DATABASE_URL });\nconst storage = createPostgresStorageAdapter({ pool });\n\nconst result = await issueSimplifiedTaxInvoice({\n  storage,\n  vatNumber: asVATNumber(\"310123456700003\"),\n  egsUuid: asEGSUuid(\"11111111-2222-3333-4444-555555555555\"),\n  // ...rest of the invoice payload\n});\n```\n\nThe adapter uses `INSERT ... ON CONFLICT` for counter increments and `SELECT ... FOR UPDATE` semantics where needed to serialise hash-chain writes per `{vatNumber, egsUuid}` scope, so it's safe under concurrent invoice issuance from multiple Node.js processes.\n\nThe factory also accepts optional clock and invoice-number formatter overrides; see the TypeScript signature.\n\n## License\n\nBUSL-1.1 — see [LICENSE](./LICENSE). The license converts to Apache 2.0 on 2030-05-13. SaaS / multi-tenant production use requires a commercial license; see the [main repo](https://github.com/dokhna-tech/zatca) for terms.\n","readmeFilename":"README.md"}