@rebasepro/server-postgres 0.28.2 → 0.29.0-canary.g0e3a0e7

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.
Files changed (40) hide show
  1. package/dist/PostgresBackendDriver.d.ts +69 -1
  2. package/dist/PostgresBootstrapper.d.ts +34 -1
  3. package/dist/{cli-console-C0FYkICX.js → cli-console-CJLtH58M.js} +3 -3
  4. package/dist/{cli-console-C0FYkICX.js.map → cli-console-CJLtH58M.js.map} +1 -1
  5. package/dist/cli.js +12 -12
  6. package/dist/{connection-czvI7TZL.js → connection-CcYqncW5.js} +113 -36
  7. package/dist/connection-CcYqncW5.js.map +1 -0
  8. package/dist/connection.d.ts +57 -0
  9. package/dist/database-health.d.ts +23 -0
  10. package/dist/{databasePoolManager-BjoVvuAq.js → databasePoolManager-XmhMczz0.js} +2 -2
  11. package/dist/{databasePoolManager-BjoVvuAq.js.map → databasePoolManager-XmhMczz0.js.map} +1 -1
  12. package/dist/{deferred-index-build-BcJ_oulu.js → deferred-index-build-BwH6k1Og.js} +30 -1
  13. package/dist/{deferred-index-build-BcJ_oulu.js.map → deferred-index-build-BwH6k1Og.js.map} +1 -1
  14. package/dist/{ensure-collection-policies-BNwSQfVx.js → ensure-collection-policies-f0LIwiwp.js} +3 -3
  15. package/dist/{ensure-collection-policies-BNwSQfVx.js.map → ensure-collection-policies-f0LIwiwp.js.map} +1 -1
  16. package/dist/{ensure-collection-tables-CSbgkTBx.js → ensure-collection-tables-DvaCEy6X.js} +4 -4
  17. package/dist/{ensure-collection-tables-CSbgkTBx.js.map → ensure-collection-tables-DvaCEy6X.js.map} +1 -1
  18. package/dist/{enum-labels-kept-BCgFGAbJ.js → enum-labels-kept-DAbJ_IIl.js} +2 -2
  19. package/dist/{enum-labels-kept-BCgFGAbJ.js.map → enum-labels-kept-DAbJ_IIl.js.map} +1 -1
  20. package/dist/index.d.ts +5 -2
  21. package/dist/index.es.js +4 -4
  22. package/dist/{migrate-policy-stamps-B-8vTSIm.js → migrate-policy-stamps-CdljD_y1.js} +4 -4
  23. package/dist/{migrate-policy-stamps-B-8vTSIm.js.map → migrate-policy-stamps-CdljD_y1.js.map} +1 -1
  24. package/dist/{open-rebase-D9n8idex.js → open-rebase-DvmKIu7q.js} +591 -37
  25. package/dist/open-rebase-DvmKIu7q.js.map +1 -0
  26. package/dist/pooled-database.d.ts +38 -0
  27. package/dist/{push-index-prebuild-DR3P4yOw.js → push-index-prebuild-C6wKdjYV.js} +3 -3
  28. package/dist/{push-index-prebuild-DR3P4yOw.js.map → push-index-prebuild-C6wKdjYV.js.map} +1 -1
  29. package/dist/{push-legacy-renames-BIxBmVLl.js → push-legacy-renames-BFF72tHG.js} +3 -3
  30. package/dist/{push-legacy-renames-BIxBmVLl.js.map → push-legacy-renames-BFF72tHG.js.map} +1 -1
  31. package/dist/{push-policy-plan-BHsasXa7.js → push-policy-plan-lOTPeQ1u.js} +2 -2
  32. package/dist/{push-policy-plan-BHsasXa7.js.map → push-policy-plan-lOTPeQ1u.js.map} +1 -1
  33. package/dist/read-routing.d.ts +139 -0
  34. package/dist/schema/deferred-index-build.d.ts +9 -0
  35. package/dist/schema/introspect-db.js +1 -1
  36. package/dist/{websocket-D4wrzF3b.js → websocket-CCJnghvG.js} +2 -2
  37. package/dist/{websocket-D4wrzF3b.js.map → websocket-CCJnghvG.js.map} +1 -1
  38. package/package.json +7 -7
  39. package/dist/connection-czvI7TZL.js.map +0 -1
  40. package/dist/open-rebase-D9n8idex.js.map +0 -1
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rebasepro/server-postgres",
3
- "version": "0.28.2",
3
+ "version": "0.29.0-canary.g0e3a0e7",
4
4
  "description": "PostgreSQL data source backend implementation for Rebase with Drizzle ORM",
5
5
  "keywords": [
6
6
  "cms",
@@ -50,11 +50,11 @@
50
50
  "execa": "^9.6.1",
51
51
  "pg": "^8.22.0",
52
52
  "ws": "^8.21.1",
53
- "@rebasepro/codegen": "0.28.2",
54
- "@rebasepro/server": "0.28.2",
55
- "@rebasepro/common": "0.28.2",
56
- "@rebasepro/types": "0.28.2",
57
- "@rebasepro/utils": "0.28.2"
53
+ "@rebasepro/codegen": "0.29.0-canary.g0e3a0e7",
54
+ "@rebasepro/server": "0.29.0-canary.g0e3a0e7",
55
+ "@rebasepro/common": "0.29.0-canary.g0e3a0e7",
56
+ "@rebasepro/utils": "0.29.0-canary.g0e3a0e7",
57
+ "@rebasepro/types": "0.29.0-canary.g0e3a0e7"
58
58
  },
59
59
  "devDependencies": {
60
60
  "@electric-sql/pglite": "0.5.6",
@@ -70,7 +70,7 @@
70
70
  "typescript": "^6.0.3",
71
71
  "vite": "^8.1.5",
72
72
  "vitest": "^4.1.11",
73
- "@rebasepro/client": "0.28.2"
73
+ "@rebasepro/client": "0.29.0-canary.g0e3a0e7"
74
74
  },
75
75
  "gitHead": "d935eefa5aa8d1009a2398cfac2c1e4ee9aeb6b6",
76
76
  "publishConfig": {
@@ -1 +0,0 @@
1
- {"version":3,"file":"connection-czvI7TZL.js","names":[],"sources":["../src/pool-disconnects.ts","../src/connection.ts"],"sourcesContent":["/**\n * What a pool says when the server ends its idle connections.\n *\n * `pg_terminate_backend` ends every connection to a database at once, and an\n * idle pool client hears it as an `error` event: one per connection, from\n * every pool the process holds. `rebase db branch create --force` does exactly\n * that to the database it copies, so fifteen forced creates beside a running\n * `rebase dev` printed 220 `❌ [ERROR] [pg-pool] Unexpected pool error\n * {\"detail\":\"terminating connection due to administrator command\"}` lines. It\n * read as an outage, and nothing was wrong: the pool opens new connections on\n * the next query. A database restart looks the same.\n */\nimport { logger } from \"@rebasepro/server\";\n\n/** SQLSTATEs of a connection the server ended: admin_shutdown, crash_shutdown, cannot_connect_now. */\nconst SERVER_ENDED_CODES = new Set([\"57P01\", \"57P02\", \"57P03\"]);\n\n/** Did the server end this connection, rather than something go wrong with it? */\nexport function serverEndedConnection(err: Error): boolean {\n const code = \"code\" in err ? err.code : undefined;\n return (typeof code === \"string\" && SERVER_ENDED_CODES.has(code))\n || /terminating connection due to administrator command/i.test(err.message);\n}\n\n/** How long one line stands for every server-ended connection after it, across all pools. */\nexport const DISCONNECT_BURST_MS = 10_000;\n\n/** When the current burst's line stops covering further disconnects. */\nlet burstUntil = 0;\n\n/** The logger methods a pool's error listener writes through. */\nexport type PoolErrorLog = Pick<typeof logger, \"warn\" | \"error\" | \"debug\">;\n\n/**\n * Say a pool's `error` event: a connection the server ended is one WARN line\n * per burst for the whole process, and the rest of the burst is at debug;\n * anything else is the ERROR it always was.\n *\n * The window is fixed from the first disconnect, not extended by each, so a\n * second burst ten seconds later is said again.\n */\nexport function reportPoolError(label: string, err: Error, log: PoolErrorLog = logger, now: () => number = Date.now): void {\n if (!serverEndedConnection(err)) {\n log.error(`[${label}] Unexpected pool error`, { detail: err.message });\n return;\n }\n const at = now();\n if (at < burstUntil) {\n log.debug(`[${label}] The database ended another idle connection`, { detail: err.message });\n return;\n }\n burstUntil = at + DISCONNECT_BURST_MS;\n const code = \"code\" in err && typeof err.code === \"string\" ? `, ${err.code}` : \"\";\n log.warn(\n `[${label}] The database ended this server's idle connections (${err.message}${code}). ` +\n \"New ones open on the next query. A database restart does this, and so does \" +\n \"`rebase db branch create --force`, which closes the database it copies.\"\n );\n}\n","import { Pool, PoolConfig } from \"pg\";\nimport { drizzle } from \"drizzle-orm/node-postgres\";\nimport { logger } from \"@rebasepro/server\";\n\nimport { reportPoolError } from \"./pool-disconnects\";\n\n/**\n * Configuration for the Postgres connection pool.\n *\n * Sensible defaults are provided for production Cloud Run / single-instance\n * deployments. Override via environment variables or explicit config.\n */\nexport interface PostgresPoolConfig {\n /** Maximum number of connections in the pool (default: 20) */\n max?: number;\n /** Close idle connections after this many ms (default: 30 000) */\n idleTimeoutMillis?: number;\n /** Abort connection attempts after this many ms (default: 10 000) */\n connectionTimeoutMillis?: number;\n /** Per-query timeout in ms (default: 30 000) */\n queryTimeout?: number;\n /** Per-statement timeout in ms (default: 30 000) */\n statementTimeout?: number;\n /** Enable TCP keep-alive (default: true) */\n keepAlive?: boolean;\n /**\n * `search_path` pinned on every connection (default: `\"public\"`).\n *\n * Pass `false` to send no `search_path` at all and inherit whatever the\n * server/role defaults to. See {@link pinSearchPath} for why the default\n * is not \"inherit\".\n */\n searchPath?: string | false;\n}\n\n/**\n * Ceiling on pool size, from the environment.\n *\n * Exists for the managed development database. PGlite is a single session\n * behind a multiplexing socket server, and two pooled clients holding\n * overlapping transactions deadlock there — which a request-per-transaction\n * server produces the moment two requests overlap. One connection turns that\n * deadlock into ordinary queueing.\n *\n * A ceiling rather than a value, so it constrains every pool in the process\n * without any of them having to know why. Ignored when unset or unparseable,\n * because a malformed limit must not silently serialize a production server.\n */\nexport function poolMaxCeiling(env: NodeJS.ProcessEnv = process.env): number | null {\n const raw = env.REBASE_DB_POOL_MAX;\n if (typeof raw !== \"string\") return null;\n\n // Plain decimal digits only. `Number` would also accept `1e3`, `0x10` and\n // ` 4 ` — none of which anyone writes on purpose in a config value, and all\n // of which would mean this silently did something other than it appears to.\n if (!/^[0-9]+$/.test(raw.trim())) return null;\n\n const parsed = Number(raw.trim());\n\n return parsed >= 1 ? parsed : null;\n}\n\n/** Apply {@link poolMaxCeiling} to a requested pool size. */\nexport function cappedPoolMax(requested: number, env: NodeJS.ProcessEnv = process.env): number {\n const ceiling = poolMaxCeiling(env);\n\n return ceiling === null ? requested : Math.min(requested, ceiling);\n}\n\nconst DEFAULT_POOL: Required<PostgresPoolConfig> = {\n max: 20,\n searchPath: \"public\",\n idleTimeoutMillis: 30_000,\n connectionTimeoutMillis: 10_000,\n // The client-side read timeout MUST be comfortably above the server-side\n // statement_timeout. When the client timer fires first, node-postgres\n // abandons the in-flight statement but keeps the connection — inside a\n // transaction that leaves the tx open (and any pending ROLLBACK is\n // spliced out of the client queue before it ever reaches the wire), so\n // the pooled connection is returned still in-transaction with its RLS\n // GUCs set. The server abort (SQLSTATE 57014) is the clean path; the\n // client timeout is only a backstop for a dead network.\n queryTimeout: 60_000,\n statementTimeout: 30_000,\n keepAlive: true\n};\n\n/**\n * The time limits every pool to this server shares: how long to wait for a\n * connection (then 503), the server-side statement timeout, the client-side\n * read backstop above it, and TCP keep-alive. Exported for the per-database\n * pools (`DatabasePoolManager`), which had none of them — pg's default\n * `connectionTimeoutMillis` is 0, wait forever.\n */\nexport function defaultPoolTimeouts(): Pick<PoolConfig,\n \"connectionTimeoutMillis\" | \"query_timeout\" | \"statement_timeout\" | \"keepAlive\" | \"keepAliveInitialDelayMillis\"> {\n return {\n connectionTimeoutMillis: DEFAULT_POOL.connectionTimeoutMillis,\n query_timeout: DEFAULT_POOL.queryTimeout,\n statement_timeout: DEFAULT_POOL.statementTimeout,\n keepAlive: DEFAULT_POOL.keepAlive,\n keepAliveInitialDelayMillis: 0\n };\n}\n\n/** ReadyForQuery status byte: `I` idle, `T` in transaction, `E` failed transaction. */\nconst TX_IDLE = \"I\";\n\n/**\n * Pin `search_path` into a connection string, so unqualified SQL resolves to a\n * schema this framework chose rather than to one Postgres inferred.\n *\n * Postgres defaults `search_path` to `\"$user\", public`: the *first* candidate\n * is a schema named after the connecting role. Rebase creates a schema called\n * `rebase` (auth, history, api keys), and every template, compose file and\n * deployment doc names the database role `rebase` too — so `$user` resolves to\n * a schema that exists, and every unqualified statement lands there instead of\n * in `public`. The generated Drizzle schema emits bare `pgTable(\"posts\", …)`\n * for any collection without an explicit `schema`, which makes the *runtime's*\n * own reads and writes unqualified; a developer's raw `rebase.sql(...)`, the\n * Studio SQL editor and any hand-written migration are unqualified too. The\n * result is collection tables created in, and served from, `rebase`.\n *\n * Drizzle cannot express the fix on its side: `pgSchema(\"public\")` throws by\n * design (\"just use pgTable() instead\"), so there is no way to emit a\n * public-qualified table from the generator. The pin has to live on the\n * connection.\n *\n * Precedence is deliberate and verified against node-postgres: `options` in\n * the connection string wins over the `options` field passed to `Pool`, so\n * rewriting the URL — rather than setting the field — is what makes this\n * authoritative. Two escape hatches survive it:\n *\n * - an `options` that already mentions `search_path` is left untouched, so a\n * deployment that deliberately pins something else keeps it;\n * - `searchPath: false` (or an unparseable, non-URL connection string) sends\n * nothing and inherits the server default.\n *\n * Anything else in `options` (a `statement_timeout`, say) is preserved and the\n * `search_path` flag is appended to it.\n */\nexport function pinSearchPath(connectionString: string, searchPath: string | false = \"public\"): string {\n if (searchPath === false) return connectionString;\n\n let url: URL;\n try {\n url = new URL(connectionString);\n } catch {\n // Key/value DSNs and anything else we cannot parse are returned as\n // given: a connection that works unpinned beats one we corrupted.\n return connectionString;\n }\n if (url.protocol !== \"postgres:\" && url.protocol !== \"postgresql:\") return connectionString;\n\n const existing = url.searchParams.get(\"options\");\n if (existing && /(^|\\s)-c\\s*search_path\\s*=/.test(existing)) return connectionString;\n\n const flag = `-c search_path=${searchPath}`;\n url.searchParams.set(\"options\", existing ? `${existing} ${flag}` : flag);\n // Re-serialize by hand. `URLSearchParams` writes a space as `+`, which\n // node-postgres happens to decode but libpq does not — and this same string\n // is handed to `pg_dump`/`psql` for backups. Percent-encoding is the form\n // both agree on, and is what the scaffolded `.env` already ships.\n url.search = Array.from(url.searchParams.entries())\n .map(([key, value]) => `${encodeURIComponent(key)}=${encodeURIComponent(value)}`)\n .join(\"&\");\n return url.toString();\n}\n\n/**\n * Destroy pool clients that are released while still inside a transaction.\n *\n * pg-pool returns a client to the idle list whenever `release()` is called\n * without an error — even if the connection is still mid-transaction (status\n * `T`/`E`). That happens in practice: drizzle's pool transaction releases in\n * a `finally` after attempting ROLLBACK, and if the ROLLBACK itself fails\n * (e.g. it was queued behind a statement that hit the client-side\n * query_timeout), the client goes back dirty. The next checkout then runs\n * its statements inside the zombie transaction — with the previous request's\n * `app.*` RLS GUCs still applied, which turns unrelated queries into\n * RLS-scoped ones (observed in production as registration failing with\n * SQLSTATE 42501 under a leaked anonymous context).\n *\n * pg-pool emits `release` before it consults its private `_expired` set, so\n * marking the client expired here makes `_release()` destroy it instead of\n * pooling it. Both `client._txStatus` (pg ≥ 8.16) and `pool._expired` are\n * private APIs — feature-detect and fall back to loud logging so an upstream\n * change degrades to observability, never to silent corruption.\n */\nexport function guardPoolAgainstDirtyRelease(pool: Pool, label: string): void {\n pool.on(\"release\", (err: Error | undefined, client: unknown) => {\n if (err) return; // errored clients are already destroyed by pg-pool\n const txStatus = (client as { _txStatus?: string | null })?._txStatus;\n if (typeof txStatus !== \"string\" || txStatus === TX_IDLE) return;\n\n // pg-pool keeps expired clients in a WeakSet (a plain object works too\n // if upstream ever changes it — duck-type on add/has).\n const expired = (pool as unknown as { _expired?: { add(c: object): unknown; has(c: object): boolean } })._expired;\n if (expired && typeof expired.add === \"function\" && typeof expired.has === \"function\" && client && typeof client === \"object\") {\n expired.add(client);\n logger.error(\n `[${label}] Client released back to the pool while still in a transaction ` +\n `(status '${txStatus}') — destroying it so the open transaction and its ` +\n `session state (RLS GUCs) cannot leak into the next request.`\n );\n } else {\n logger.error(\n `[${label}] Client released mid-transaction (status '${txStatus}') but the ` +\n `pool's internal expiry set is unavailable (pg-pool internals changed?). ` +\n `The connection may leak its open transaction into subsequent requests.`\n );\n }\n });\n}\n\n/**\n * Create a Drizzle-backed Postgres connection with a production-grade\n * connection pool.\n *\n * @param connectionString Postgres connection URL\n * @param schema Optional Drizzle schema for the relational API\n * @param poolConfig Optional pool tuning (merged over defaults)\n * @param env Where the pool-size ceiling `REBASE_DB_POOL_MAX`\n * is read from (see {@link poolMaxCeiling}); pass\n * `{}` to read none.\n *\n * @returns `{ db, pool, connectionString }` — the `pool` is exposed so\n * callers can register shutdown hooks (`pool.end()`) or monitor\n * pool metrics.\n */\nexport function createPostgresDatabaseConnection(\n connectionString: string,\n schema?: Record<string, unknown>,\n poolConfig?: PostgresPoolConfig,\n env: NodeJS.ProcessEnv = process.env\n) {\n const opts = { ...DEFAULT_POOL,\n...poolConfig };\n connectionString = pinSearchPath(connectionString, opts.searchPath);\n\n const pgPoolConfig: PoolConfig = {\n connectionString,\n max: cappedPoolMax(opts.max, env),\n idleTimeoutMillis: opts.idleTimeoutMillis,\n connectionTimeoutMillis: opts.connectionTimeoutMillis,\n query_timeout: opts.queryTimeout,\n statement_timeout: opts.statementTimeout,\n keepAlive: opts.keepAlive,\n keepAliveInitialDelayMillis: 0\n };\n\n const pool = new Pool(pgPoolConfig);\n\n // ── Pool event logging ────────────────────────────────────────────────\n // Uses console.* because the structured logger lives in server\n // (a separate package). The caller can replace these with the structured\n // logger if desired via pool.on() after creation.\n pool.on(\"error\", (err) => {\n reportPoolError(\"pg-pool\", err);\n if (err.message.includes(\"ETIMEDOUT\")) {\n logger.warn(\"[pg-pool] Connection timeout detected — pool will auto-retry\");\n }\n });\n guardPoolAgainstDirtyRelease(pool, \"pg-pool\");\n\n // Create drizzle instance — pass schema when available to enable db.query relational API\n const db = schema ? drizzle(pool, { schema }) : drizzle(pool);\n\n return { db,\npool,\nconnectionString };\n}\n\n/**\n * Create a direct (non-pooled) connection for operations that require\n * session-level features incompatible with PgBouncer transaction mode,\n * such as LISTEN/NOTIFY, prepared statements, or advisory locks.\n *\n * Uses a smaller pool since this is only for specific use cases.\n */\nexport function createDirectDatabaseConnection(\n connectionString: string,\n schema?: Record<string, unknown>,\n poolConfig?: PostgresPoolConfig\n) {\n const opts = {\n ...DEFAULT_POOL,\n max: 5,\n ...poolConfig\n };\n connectionString = pinSearchPath(connectionString, opts.searchPath);\n\n const pgPoolConfig: PoolConfig = {\n connectionString,\n max: cappedPoolMax(opts.max),\n idleTimeoutMillis: opts.idleTimeoutMillis,\n connectionTimeoutMillis: opts.connectionTimeoutMillis,\n query_timeout: opts.queryTimeout,\n statement_timeout: opts.statementTimeout,\n keepAlive: opts.keepAlive,\n keepAliveInitialDelayMillis: 0\n };\n\n const pool = new Pool(pgPoolConfig);\n\n pool.on(\"error\", (err) => reportPoolError(\"pg-direct-pool\", err));\n guardPoolAgainstDirtyRelease(pool, \"pg-direct-pool\");\n\n const db = schema ? drizzle(pool, { schema }) : drizzle(pool);\n\n return { db,\npool,\nconnectionString };\n}\n\n/**\n * Create a read-only connection for routing read queries to replicas.\n * Uses a moderate pool size since reads are distributed across replicas.\n */\nexport function createReadReplicaConnection(\n connectionString: string,\n schema?: Record<string, unknown>,\n poolConfig?: PostgresPoolConfig\n) {\n const opts = {\n ...DEFAULT_POOL,\n max: 10,\n ...poolConfig\n };\n connectionString = pinSearchPath(connectionString, opts.searchPath);\n\n const pgPoolConfig: PoolConfig = {\n connectionString,\n max: cappedPoolMax(opts.max),\n idleTimeoutMillis: opts.idleTimeoutMillis,\n connectionTimeoutMillis: opts.connectionTimeoutMillis,\n query_timeout: opts.queryTimeout,\n statement_timeout: opts.statementTimeout,\n keepAlive: opts.keepAlive,\n keepAliveInitialDelayMillis: 0\n };\n\n const pool = new Pool(pgPoolConfig);\n\n pool.on(\"error\", (err) => reportPoolError(\"pg-replica-pool\", err));\n guardPoolAgainstDirtyRelease(pool, \"pg-replica-pool\");\n\n const db = schema ? drizzle(pool, { schema }) : drizzle(pool);\n\n return { db,\npool,\nconnectionString };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAeA,IAAM,qCAAqB,IAAI,IAAI;CAAC;CAAS;CAAS;AAAO,CAAC;;AAG9D,SAAgB,sBAAsB,KAAqB;CACvD,MAAM,OAAO,UAAU,MAAM,IAAI,OAAO,KAAA;CACxC,OAAQ,OAAO,SAAS,YAAY,mBAAmB,IAAI,IAAI,KACxD,uDAAuD,KAAK,IAAI,OAAO;AAClF;;AAGA,IAAa,sBAAsB;;AAGnC,IAAI,aAAa;;;;;;;;;AAajB,SAAgB,gBAAgB,OAAe,KAAY,MAAoB,QAAQ,MAAoB,KAAK,KAAW;CACvH,IAAI,CAAC,sBAAsB,GAAG,GAAG;EAC7B,IAAI,MAAM,IAAI,MAAM,0BAA0B,EAAE,QAAQ,IAAI,QAAQ,CAAC;EACrE;CACJ;CACA,MAAM,KAAK,IAAI;CACf,IAAI,KAAK,YAAY;EACjB,IAAI,MAAM,IAAI,MAAM,+CAA+C,EAAE,QAAQ,IA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