@resvary/postgres 0.5.0 → 0.7.0

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.
package/dist/receipt.js CHANGED
@@ -8,11 +8,11 @@ class PostgresReceiptStoreView {
8
8
  this.handle = handle;
9
9
  }
10
10
  async saveInvoice(value) {
11
- await this.db.query(`INSERT INTO ${table(this.handle, 'resvary_invoices')}
12
- (id, status, customer_id, amount_units, created_at, payload)
13
- VALUES ($1, $2, $3, $4, $5, $6)
14
- ON CONFLICT (id) DO UPDATE SET status = EXCLUDED.status,
15
- customer_id = EXCLUDED.customer_id, amount_units = EXCLUDED.amount_units,
11
+ await this.db.query(`INSERT INTO ${table(this.handle, 'resvary_invoices')}
12
+ (id, status, customer_id, amount_units, created_at, payload)
13
+ VALUES ($1, $2, $3, $4, $5, $6)
14
+ ON CONFLICT (id) DO UPDATE SET status = EXCLUDED.status,
15
+ customer_id = EXCLUDED.customer_id, amount_units = EXCLUDED.amount_units,
16
16
  created_at = EXCLUDED.created_at, payload = EXCLUDED.payload`, [
17
17
  value.id,
18
18
  value.status,
@@ -30,9 +30,9 @@ class PostgresReceiptStoreView {
30
30
  (!filter.customerId || value.customerId === filter.customerId));
31
31
  }
32
32
  async saveReceipt(value) {
33
- await this.db.query(`INSERT INTO ${table(this.handle, 'resvary_receipts')}
34
- (id, invoice_id, tx_hash_norm, status, amount_units, created_at, payload)
35
- VALUES ($1, $2, $3, $4, $5, $6, $7)
33
+ await this.db.query(`INSERT INTO ${table(this.handle, 'resvary_receipts')}
34
+ (id, invoice_id, tx_hash_norm, status, amount_units, created_at, payload)
35
+ VALUES ($1, $2, $3, $4, $5, $6, $7)
36
36
  ON CONFLICT DO NOTHING`, [
37
37
  value.id,
38
38
  value.invoiceId,
@@ -47,28 +47,28 @@ class PostgresReceiptStoreView {
47
47
  return this.one(`SELECT payload::text AS payload FROM ${table(this.handle, 'resvary_receipts')} WHERE id = $1`, [id]);
48
48
  }
49
49
  getReceiptByTxHash(txHash, invoiceId) {
50
- return this.one(`SELECT payload::text AS payload FROM ${table(this.handle, 'resvary_receipts')}
50
+ return this.one(`SELECT payload::text AS payload FROM ${table(this.handle, 'resvary_receipts')}
51
51
  WHERE tx_hash_norm = $1 ${invoiceId ? 'AND invoice_id = $2' : ''} LIMIT 1`, invoiceId ? [txHash.toLowerCase(), invoiceId] : [txHash.toLowerCase()]);
52
52
  }
53
53
  listReceipts() {
54
54
  return this.all(`SELECT payload::text AS payload FROM ${table(this.handle, 'resvary_receipts')} ORDER BY created_at ASC`);
55
55
  }
56
56
  async saveWebhookEvent(value) {
57
- await this.db.query(`INSERT INTO ${table(this.handle, 'arc_webhook_events')}(id, type, created_at, payload)
58
- VALUES ($1, $2, $3, $4)
59
- ON CONFLICT (id) DO UPDATE SET type = EXCLUDED.type,
57
+ await this.db.query(`INSERT INTO ${table(this.handle, 'arc_webhook_events')}(id, type, created_at, payload)
58
+ VALUES ($1, $2, $3, $4)
59
+ ON CONFLICT (id) DO UPDATE SET type = EXCLUDED.type,
60
60
  created_at = EXCLUDED.created_at, payload = EXCLUDED.payload`, [value.id, value.type, value.createdAt, serializeReceiptStoreValue(value)]);
61
61
  }
62
62
  async listWebhookEvents(filter = {}) {
63
63
  return (await this.all(`SELECT payload::text AS payload FROM ${table(this.handle, 'arc_webhook_events')} ORDER BY created_at ASC`)).filter((value) => !filter.type || value.type === filter.type);
64
64
  }
65
65
  async saveWebhookDelivery(value) {
66
- await this.db.query(`INSERT INTO ${table(this.handle, 'arc_webhook_deliveries')}
67
- (id, event_id, event_type, attempt, status, received_at, payload)
68
- VALUES ($1, $2, $3, $4, $5, $6, $7)
69
- ON CONFLICT (id) DO UPDATE SET event_id = EXCLUDED.event_id,
70
- event_type = EXCLUDED.event_type, attempt = EXCLUDED.attempt,
71
- status = EXCLUDED.status, received_at = EXCLUDED.received_at,
66
+ await this.db.query(`INSERT INTO ${table(this.handle, 'arc_webhook_deliveries')}
67
+ (id, event_id, event_type, attempt, status, received_at, payload)
68
+ VALUES ($1, $2, $3, $4, $5, $6, $7)
69
+ ON CONFLICT (id) DO UPDATE SET event_id = EXCLUDED.event_id,
70
+ event_type = EXCLUDED.event_type, attempt = EXCLUDED.attempt,
71
+ status = EXCLUDED.status, received_at = EXCLUDED.received_at,
72
72
  payload = EXCLUDED.payload`, [
73
73
  value.id,
74
74
  value.eventId,
@@ -93,12 +93,12 @@ class PostgresReceiptStoreView {
93
93
  return this.all(`SELECT payload::text AS payload FROM ${table(this.handle, 'arc_watcher_cursors')} ORDER BY updated_at ASC`);
94
94
  }
95
95
  async saveWatcherCursor(value) {
96
- await this.db.query(`INSERT INTO ${table(this.handle, 'arc_watcher_cursors')}
97
- (key, network, invoice_id, memo_id_norm, next_from_block, updated_at, payload)
98
- VALUES ($1, $2, $3, $4, $5, $6, $7)
99
- ON CONFLICT (key) DO UPDATE SET network = EXCLUDED.network,
100
- invoice_id = EXCLUDED.invoice_id, memo_id_norm = EXCLUDED.memo_id_norm,
101
- next_from_block = EXCLUDED.next_from_block, updated_at = EXCLUDED.updated_at,
96
+ await this.db.query(`INSERT INTO ${table(this.handle, 'arc_watcher_cursors')}
97
+ (key, network, invoice_id, memo_id_norm, next_from_block, updated_at, payload)
98
+ VALUES ($1, $2, $3, $4, $5, $6, $7)
99
+ ON CONFLICT (key) DO UPDATE SET network = EXCLUDED.network,
100
+ invoice_id = EXCLUDED.invoice_id, memo_id_norm = EXCLUDED.memo_id_norm,
101
+ next_from_block = EXCLUDED.next_from_block, updated_at = EXCLUDED.updated_at,
102
102
  payload = EXCLUDED.payload`, [
103
103
  value.key,
104
104
  value.network,
package/package.json CHANGED
@@ -1,49 +1,55 @@
1
- {
2
- "name": "@resvary/postgres",
3
- "version": "0.5.0",
4
- "description": "Postgres persistence and migration tooling for Resvary",
5
- "type": "module",
6
- "main": "./dist/index.js",
7
- "types": "./dist/index.d.ts",
8
- "bin": {
9
- "resvary-postgres": "dist/cli.js"
10
- },
11
- "exports": {
12
- ".": {
13
- "types": "./dist/index.d.ts",
14
- "import": "./dist/index.js"
15
- },
16
- "./import-sqlite": {
17
- "types": "./dist/import-sqlite.d.ts",
18
- "import": "./dist/import-sqlite.js"
19
- }
20
- },
21
- "files": [
22
- "dist",
23
- "README.md",
24
- "LICENSE"
25
- ],
26
- "publishConfig": {
27
- "access": "public"
28
- },
29
- "scripts": {
30
- "build": "tsc",
31
- "dev": "tsc --watch",
32
- "clean": "node -e \"const fs=require('node:fs');fs.rmSync('dist',{recursive:true,force:true});fs.rmSync('tsconfig.tsbuildinfo',{force:true})\"",
33
- "test": "vitest run"
34
- },
35
- "engines": {
36
- "node": ">=20.0.0"
37
- },
38
- "dependencies": {
39
- "@resvary/sdk": "0.5.0",
40
- "pg": "^8.16.3"
41
- },
42
- "devDependencies": {
43
- "@types/node": "^22.0.0",
44
- "@types/pg": "^8.15.5",
45
- "typescript": "^5.6.0",
46
- "vitest": "^4.1.10"
47
- },
48
- "license": "Apache-2.0"
49
- }
1
+ {
2
+ "name": "@resvary/postgres",
3
+ "version": "0.7.0",
4
+ "description": "Postgres persistence and migration tooling for Resvary",
5
+ "type": "module",
6
+ "main": "./dist/index.js",
7
+ "types": "./dist/index.d.ts",
8
+ "bin": {
9
+ "resvary-postgres": "dist/cli.js"
10
+ },
11
+ "exports": {
12
+ ".": {
13
+ "types": "./dist/index.d.ts",
14
+ "import": "./dist/index.js"
15
+ },
16
+ "./import-sqlite": {
17
+ "types": "./dist/import-sqlite.d.ts",
18
+ "import": "./dist/import-sqlite.js"
19
+ }
20
+ },
21
+ "files": [
22
+ "dist",
23
+ "README.md",
24
+ "LICENSE"
25
+ ],
26
+ "publishConfig": {
27
+ "access": "public"
28
+ },
29
+ "scripts": {
30
+ "build": "tsc",
31
+ "dev": "tsc --watch",
32
+ "clean": "node -e \"const fs=require('node:fs');fs.rmSync('dist',{recursive:true,force:true});fs.rmSync('tsconfig.tsbuildinfo',{force:true})\"",
33
+ "test": "vitest run"
34
+ },
35
+ "engines": {
36
+ "node": ">=20.0.0"
37
+ },
38
+ "repository": {
39
+ "type": "git",
40
+ "url": "git+https://github.com/horn111/resvary.git",
41
+ "directory": "packages/postgres"
42
+ },
43
+ "dependencies": {
44
+ "@resvary/sdk": "0.7.0",
45
+ "pg": "^8.16.3"
46
+ },
47
+ "devDependencies": {
48
+ "@types/node": "^22.20.1",
49
+ "@types/pg": "^8.15.5",
50
+ "typescript": "^5.6.0",
51
+ "vitest": "^4.1.11"
52
+ },
53
+ "license": "Apache-2.0",
54
+ "gitHead": "fa0365a648186aa0330da25268a3f6626d0db8a3"
55
+ }