Skip to content

Commit 6ba0f6a

Browse files
feat: Add analytics endpoints to fetch identity data [DEV-4774] (#269)
* feat: Add analytics endpoints to fetch identity data * fix: Resolve testnet cronjob failures [DEV-4789] (#270) fix: Resolve testnet cronjob failures * package bump * Apply DB changes and format API responses differently * bump * Remove ledgerDenom and ledgerOperationType from response & fix typo in DB schema * Allow case-insensitive filtering --------- Co-authored-by: Ankur Banerjee <ankurdotb@users.noreply.github.com>
1 parent c5961a8 commit 6ba0f6a

21 files changed

Lines changed: 2849 additions & 136 deletions

package-lock.json

Lines changed: 77 additions & 77 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,11 @@
2020
"dependencies": {
2121
"drizzle-orm": "^0.40.0",
2222
"itty-router": "^3.0.12",
23-
"pg": "^8.13.3"
23+
"pg": "^8.14.0"
2424
},
2525
"devDependencies": {
26-
"@cloudflare/workers-types": "^4.20250303.0",
27-
"@types/node": "^20.17.23",
26+
"@cloudflare/workers-types": "^4.20250311.0",
27+
"@types/node": "^20.17.24",
2828
"@types/pg": "^8.11.11",
2929
"@typescript-eslint/eslint-plugin": "^7.18.0",
3030
"@typescript-eslint/parser": "^7.18.0",
@@ -34,7 +34,7 @@
3434
"eslint-config-typescript": "^3.0.0",
3535
"prettier": "^3.5.3",
3636
"typescript": "^5.8.2",
37-
"wrangler": "^3.113.0"
37+
"wrangler": "^3.114.1"
3838
},
3939
"engines": {
4040
"node": ">=20.0.0"

src/database/client.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
import { Client } from 'pg';
2-
import { drizzle } from 'drizzle-orm/node-postgres';
2+
import { drizzle, NodePgDatabase } from 'drizzle-orm/node-postgres';
33
import * as schema from './schema';
44

55
// Default timeout for PostgreSQL queries (30 seconds)
66
const DEFAULT_POSTGRES_TIMEOUT = 30000;
77

8+
export type DrizzleClient = NodePgDatabase<typeof schema>;
9+
810
export async function dbInit(env?: any): Promise<{ db: any; client: Client }> {
911
try {
1012
// Create a single PostgreSQL client
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
ALTER TABLE "operation_types_mainnet" RENAME COLUMN "type" TO "ledger_operation_type";--> statement-breakpoint
2+
ALTER TABLE "operation_types_testnet" RENAME COLUMN "type" TO "ledger_operation_type";--> statement-breakpoint
3+
ALTER TABLE "operation_types_mainnet" DROP CONSTRAINT "operation_types_mainnet_type_unique";--> statement-breakpoint
4+
ALTER TABLE "operation_types_testnet" DROP CONSTRAINT "operation_types_testnet_type_unique";--> statement-breakpoint
5+
ALTER TABLE "denom_mainnet" ALTER COLUMN "ledger_denom" SET DATA TYPE denoms_enum_mainnet;--> statement-breakpoint
6+
ALTER TABLE "denom_mainnet" ALTER COLUMN "ledger_denom" SET DEFAULT 'ncheq';--> statement-breakpoint
7+
ALTER TABLE "denom_mainnet" ALTER COLUMN "friendly_denom" SET DATA TYPE varchar;--> statement-breakpoint
8+
ALTER TABLE "denom_mainnet" ALTER COLUMN "friendly_denom" SET DEFAULT 'CHEQ';--> statement-breakpoint
9+
ALTER TABLE "denom_testnet" ALTER COLUMN "ledger_denom" SET DATA TYPE denoms_enum_testnet;--> statement-breakpoint
10+
ALTER TABLE "denom_testnet" ALTER COLUMN "ledger_denom" SET DEFAULT 'ncheq';--> statement-breakpoint
11+
ALTER TABLE "denom_testnet" ALTER COLUMN "friendly_denom" SET DATA TYPE varchar;--> statement-breakpoint
12+
ALTER TABLE "denom_testnet" ALTER COLUMN "friendly_denom" SET DEFAULT 'ncheq';--> statement-breakpoint
13+
ALTER TABLE "operation_types_mainnet" ADD COLUMN "friendly_operation_type" varchar DEFAULT 'friendly' NOT NULL;--> statement-breakpoint
14+
ALTER TABLE "operation_types_testnet" ADD COLUMN "friendly_operation_type" varchar DEFAULT 'friendly' NOT NULL;--> statement-breakpoint
15+
ALTER TABLE "operation_types_mainnet" ADD CONSTRAINT "operation_types_mainnet_ledger_operation_type_unique" UNIQUE("ledger_operation_type");--> statement-breakpoint
16+
ALTER TABLE "operation_types_testnet" ADD CONSTRAINT "operation_types_testnet_ledger_operation_type_unique" UNIQUE("ledger_operation_type");
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
ALTER TABLE "did_mainnet" RENAME COLUMN "operationType" TO "operation_type";--> statement-breakpoint
2+
ALTER TABLE "did_mainnet" DROP CONSTRAINT "did_mainnet_operationType_operation_types_mainnet_id_fk";
3+
--> statement-breakpoint
4+
DROP INDEX "idx_did_mainnet_tx_op_did";--> statement-breakpoint
5+
ALTER TABLE "did_mainnet" ADD CONSTRAINT "did_mainnet_operation_type_operation_types_mainnet_id_fk" FOREIGN KEY ("operation_type") REFERENCES "public"."operation_types_mainnet"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint
6+
CREATE INDEX "idx_did_mainnet_tx_op_did" ON "did_mainnet" USING btree ("transaction_hash","operation_type","did_id");

0 commit comments

Comments
 (0)