@open-mercato/shared 0.6.6-develop.5558.1.748adcd5fc → 0.6.6-develop.5588.1.a8f6c51d1f

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/AGENTS.md CHANGED
@@ -41,6 +41,7 @@ yarn workspace @open-mercato/shared build
41
41
  | `crud/` | When building CRUD routes | `@open-mercato/shared/lib/crud` |
42
42
  | `custom-fields/` | When handling custom field payloads | `@open-mercato/shared/lib/custom-fields` |
43
43
  | `data/` | When you need `DataEngine` or `QueryEngine` types | `@open-mercato/shared/lib/data/engine` |
44
+ | `db/` | When resolving the ORM/connection-pool config (`resolvePoolConfig`, pool/timeout env knobs) | `@open-mercato/shared/lib/db/mikro` |
44
45
  | `di/` | When setting up dependency injection (Awilix) | `@open-mercato/shared/lib/di` |
45
46
  | `encryption/` | When querying encrypted entities (MUST use instead of raw `em.find`) | `@open-mercato/shared/lib/encryption/find` |
46
47
  | `i18n/` | When translating strings — `useT()` client-side, `resolveTranslations()` server-side | `@open-mercato/shared/lib/i18n/context` or `/server` |
@@ -66,6 +67,17 @@ When you need shared type definitions, import from these:
66
67
 
67
68
  ## Key Patterns
68
69
 
70
+ ### Database Connection Pool — MUST keep total demand under `max_connections`
71
+
72
+ The MikroORM pool is configured from env via `resolvePoolConfig(process.env)` in
73
+ `@open-mercato/shared/lib/db/mikro` (pure and unit-testable). Each process gets
74
+ its own pool (`DB_POOL_MAX`, default 20). Because background worker jobs each run
75
+ in their own request container (one pooled connection per in-flight job), the
76
+ peak connection demand of all processes against one database is additive.
77
+
78
+ - **Invariant:** `web_pool_max + worker_pool_max + scheduler/overhead ≤ Postgres max_connections` (with headroom). Violating it lets background work starve the request/onboarding path — see `packages/queue/AGENTS.md` → Connection Budget.
79
+ - Tune per process with `DB_POOL_MAX` (and the opt-in `DB_STATEMENT_TIMEOUT_MS` / `DB_LOCK_TIMEOUT_MS`; `idle_in_transaction` defaults to a finite 120s). Bound the worker's job concurrency with `OM_WORKERS_DB_CONNECTION_BUDGET`.
80
+
69
81
  ### Encryption — MUST use instead of raw ORM queries
70
82
 
71
83
  ```typescript
@@ -1,4 +1,4 @@
1
- const APP_VERSION = "0.6.6-develop.5558.1.748adcd5fc";
1
+ const APP_VERSION = "0.6.6-develop.5588.1.a8f6c51d1f";
2
2
  const appVersion = APP_VERSION;
3
3
  export {
4
4
  APP_VERSION,
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/lib/version.ts"],
4
- "sourcesContent": ["// Build-time generated version\nexport const APP_VERSION = '0.6.6-develop.5558.1.748adcd5fc'\nexport const appVersion = APP_VERSION\n"],
4
+ "sourcesContent": ["// Build-time generated version\nexport const APP_VERSION = '0.6.6-develop.5588.1.a8f6c51d1f'\nexport const appVersion = APP_VERSION\n"],
5
5
  "mappings": "AACO,MAAM,cAAc;AACpB,MAAM,aAAa;",
6
6
  "names": []
7
7
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@open-mercato/shared",
3
- "version": "0.6.6-develop.5558.1.748adcd5fc",
3
+ "version": "0.6.6-develop.5588.1.a8f6c51d1f",
4
4
  "type": "module",
5
5
  "main": "./dist/index.js",
6
6
  "scripts": {
@@ -92,7 +92,7 @@
92
92
  "@mikro-orm/core": "^7.1.4",
93
93
  "@mikro-orm/decorators": "^7.1.4",
94
94
  "@mikro-orm/postgresql": "^7.1.4",
95
- "@open-mercato/cache": "0.6.6-develop.5558.1.748adcd5fc",
95
+ "@open-mercato/cache": "0.6.6-develop.5588.1.a8f6c51d1f",
96
96
  "dotenv": "^17.4.2",
97
97
  "rate-limiter-flexible": "^11.2.0",
98
98
  "re2js": "2.8.3",