@prisma/orm-postgres 8.0.0-rc.4-dev.6 → 8.0.0-rc.4-dev.8
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/runtime.mjs
CHANGED
|
@@ -7,7 +7,7 @@ import postgresAdapter from "@prisma/orm-target-postgres/adapter/runtime";
|
|
|
7
7
|
import { sql } from "@prisma/orm-family-sql/builder/runtime";
|
|
8
8
|
import { createExecutionContext, createSqlExecutionStack, withTransaction } from "@prisma/orm-family-sql/runtime";
|
|
9
9
|
import postgresTarget, { PostgresContractSerializer } from "@prisma/orm-target-postgres/target/runtime";
|
|
10
|
-
import postgresDriver from "@prisma/orm-target-postgres/driver/runtime";
|
|
10
|
+
import postgresDriver, { suppressIdleConnectionErrors } from "@prisma/orm-target-postgres/driver/runtime";
|
|
11
11
|
import { instantiateExecutionStack } from "@prisma/orm-framework/components/execution";
|
|
12
12
|
import { orm } from "@prisma/orm-family-sql/orm-client";
|
|
13
13
|
import { Pool } from "pg";
|
|
@@ -83,11 +83,11 @@ function toRuntimeBinding(binding, options) {
|
|
|
83
83
|
if (binding.kind !== "url") return binding;
|
|
84
84
|
return {
|
|
85
85
|
kind: "pgPool",
|
|
86
|
-
pool: new Pool({
|
|
86
|
+
pool: suppressIdleConnectionErrors(new Pool({
|
|
87
87
|
connectionString: binding.url,
|
|
88
88
|
connectionTimeoutMillis: options.poolOptions?.connectionTimeoutMillis ?? 2e4,
|
|
89
89
|
idleTimeoutMillis: options.poolOptions?.idleTimeoutMillis ?? 3e4
|
|
90
|
-
})
|
|
90
|
+
}))
|
|
91
91
|
};
|
|
92
92
|
}
|
|
93
93
|
function postgres(options) {
|
package/dist/runtime.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"runtime.mjs","names":[],"sources":["../../../../3-extensions/postgres/dist/runtime.mjs"],"sourcesContent":["import { t as postgresError } from \"./errors-DfWK9xep.mjs\";\nimport { r as buildNamespacedNativeEnums, t as buildPostgresStaticContext } from \"./postgres-static-DBYpkrmX.mjs\";\nimport { t as PostgresRuntimeImpl } from \"./postgres-runtime-GybTEgP4.mjs\";\nimport { ifDefined } from \"@internal/utils/defined\";\nimport { InternalError } from \"@internal/utils/internal-error\";\nimport postgresAdapter from \"@internal/adapter-postgres/runtime\";\nimport postgresDriver from \"@internal/driver-postgres/runtime\";\nimport { instantiateExecutionStack } from \"@internal/framework-components/execution\";\nimport { sql } from \"@internal/sql-builder/runtime\";\nimport { orm } from \"@internal/sql-orm-client\";\nimport { createExecutionContext, createSqlExecutionStack, withTransaction } from \"@internal/sql-runtime\";\nimport postgresTarget, { PostgresContractSerializer } from \"@internal/target-postgres/runtime\";\nimport { Pool } from \"pg\";\n//#region src/runtime/binding.ts\nconst isPgPool = (pg) => \"totalCount\" in pg && \"idleCount\" in pg && \"waitingCount\" in pg;\nconst isPgClient = (pg) => \"escapeIdentifier\" in pg && \"escapeLiteral\" in pg;\nfunction validatePostgresUrl(url) {\n\tconst trimmed = url.trim();\n\tif (trimmed.length === 0) throw postgresError(\"RUNTIME.BINDING_INVALID\", \"Postgres URL must be a non-empty string\", { meta: {\n\t\textension: \"postgres\",\n\t\treason: \"empty url\"\n\t} });\n\tlet parsed;\n\ttry {\n\t\tparsed = new URL(trimmed);\n\t} catch {\n\t\tthrow postgresError(\"RUNTIME.BINDING_INVALID\", \"Postgres URL must be a valid URL\", { meta: {\n\t\t\textension: \"postgres\",\n\t\t\treason: \"unparseable url\"\n\t\t} });\n\t}\n\tif (parsed.protocol !== \"postgres:\" && parsed.protocol !== \"postgresql:\") throw postgresError(\"RUNTIME.BINDING_INVALID\", \"Postgres URL must use postgres:// or postgresql://\", { meta: {\n\t\textension: \"postgres\",\n\t\treason: \"wrong scheme\",\n\t\treceived: parsed.protocol\n\t} });\n\treturn trimmed;\n}\nfunction resolvePostgresBinding(options) {\n\tif (Number(options.binding !== void 0) + Number(options.url !== void 0) + Number(options.pg !== void 0) !== 1) throw postgresError(\"RUNTIME.BINDING_INVALID\", \"Provide one binding input: binding, url, or pg\", {\n\t\tfix: \"Pass exactly one of `binding`, `url`, or `pg`.\",\n\t\tmeta: {\n\t\t\textension: \"postgres\",\n\t\t\treason: \"zero or multiple binding inputs\"\n\t\t}\n\t});\n\tif (options.binding !== void 0) return options.binding;\n\tif (options.url !== void 0) return {\n\t\tkind: \"url\",\n\t\turl: validatePostgresUrl(options.url)\n\t};\n\tconst pgBinding = options.pg;\n\tif (pgBinding === void 0) throw new InternalError(\"Invariant violation: expected pg binding after validation\");\n\tif (isPgPool(pgBinding)) return {\n\t\tkind: \"pgPool\",\n\t\tpool: pgBinding\n\t};\n\tif (isPgClient(pgBinding)) return {\n\t\tkind: \"pgClient\",\n\t\tclient: pgBinding\n\t};\n\tthrow postgresError(\"RUNTIME.BINDING_INVALID\", \"Unable to determine pg binding type from pg input; use binding with explicit kind\", {\n\t\tfix: \"Pass `binding: { kind: \\\"pgPool\\\", pool }` or `binding: { kind: \\\"pgClient\\\", client }` instead of `pg`.\",\n\t\tmeta: {\n\t\t\textension: \"postgres\",\n\t\t\treason: \"unrecognizable pg object\"\n\t\t}\n\t});\n}\nfunction resolveOptionalPostgresBinding(options) {\n\tif (Number(options.binding !== void 0) + Number(options.url !== void 0) + Number(options.pg !== void 0) === 0) return;\n\treturn resolvePostgresBinding(options);\n}\n//#endregion\n//#region src/runtime/postgres.ts\nfunction hasContractJson(options) {\n\treturn \"contractJson\" in options;\n}\nconst contractSerializer = new PostgresContractSerializer();\nfunction resolveContract(options) {\n\tconst contractJson = hasContractJson(options) ? options.contractJson : contractSerializer.serializeContract(options.contract);\n\treturn contractSerializer.deserializeContract(contractJson);\n}\nfunction toRuntimeBinding(binding, options) {\n\tif (binding.kind !== \"url\") return binding;\n\treturn {\n\t\tkind: \"pgPool\",\n\t\tpool: new Pool({\n\t\t\tconnectionString: binding.url,\n\t\t\tconnectionTimeoutMillis: options.poolOptions?.connectionTimeoutMillis ?? 2e4,\n\t\t\tidleTimeoutMillis: options.poolOptions?.idleTimeoutMillis ?? 3e4\n\t\t})\n\t};\n}\nfunction postgres(options) {\n\tconst contract = resolveContract(options);\n\tlet binding = resolveOptionalPostgresBinding(options);\n\tconst stack = createSqlExecutionStack({\n\t\ttarget: postgresTarget,\n\t\tadapter: postgresAdapter,\n\t\tdriver: postgresDriver,\n\t\textensions: options.extensions ?? []\n\t});\n\tconst context = createExecutionContext({\n\t\tcontract,\n\t\tstack,\n\t\tdriver: postgresDriver\n\t});\n\tconst { sql: sql$1, raw: rawSqlTag, enums, nativeEnums } = buildPostgresStaticContext(context, stack.adapter.rawCodecInferer);\n\tlet runtimeInstance;\n\tlet runtimeDriver;\n\tlet driverConnected = false;\n\tlet connectPromise;\n\tlet backgroundConnectError;\n\tlet closed = false;\n\tlet ownedDispose;\n\tconst connectDriver = async (resolvedBinding) => {\n\t\tif (driverConnected) return;\n\t\tif (!runtimeDriver) throw new InternalError(\"Postgres runtime driver missing\");\n\t\tif (connectPromise) return connectPromise;\n\t\tconst runtimeBinding = toRuntimeBinding(resolvedBinding, options);\n\t\tif (resolvedBinding.kind === \"url\" && runtimeBinding.kind === \"pgPool\") {\n\t\t\tconst pool = runtimeBinding.pool;\n\t\t\tlet disposed = false;\n\t\t\townedDispose = async () => {\n\t\t\t\tif (disposed) return;\n\t\t\t\tdisposed = true;\n\t\t\t\tawait pool.end().then(() => void 0);\n\t\t\t};\n\t\t}\n\t\tconnectPromise = runtimeDriver.connect(runtimeBinding).then(() => {\n\t\t\tdriverConnected = true;\n\t\t}).catch(async (err) => {\n\t\t\tbackgroundConnectError = err;\n\t\t\tconnectPromise = void 0;\n\t\t\tawait ownedDispose?.().catch(() => void 0);\n\t\t\tthrow err;\n\t\t});\n\t\treturn connectPromise;\n\t};\n\tconst getRuntime = () => {\n\t\tif (closed) throw postgresError(\"DRIVER.NOT_CONNECTED\", \"Postgres client is closed\", {\n\t\t\twhy: \"close() was called on this client.\",\n\t\t\tfix: \"Create a new postgres(...) client.\",\n\t\t\tmeta: { extension: \"postgres\" }\n\t\t});\n\t\tif (backgroundConnectError !== void 0) throw backgroundConnectError;\n\t\tif (runtimeInstance) return runtimeInstance;\n\t\tconst stackInstance = instantiateExecutionStack(stack);\n\t\tconst driverDescriptor = stack.driver;\n\t\tif (!driverDescriptor) throw new InternalError(\"Driver descriptor missing from execution stack\");\n\t\tconst driver = driverDescriptor.create({ cursor: { disabled: true } });\n\t\truntimeDriver = driver;\n\t\tif (binding !== void 0) connectDriver(binding).catch(() => void 0);\n\t\truntimeInstance = new PostgresRuntimeImpl({\n\t\t\tcontext,\n\t\t\tadapter: stackInstance.adapter,\n\t\t\tdriver,\n\t\t\t...ifDefined(\"verifyMarker\", options.verifyMarker),\n\t\t\t...ifDefined(\"middleware\", options.middleware)\n\t\t});\n\t\treturn runtimeInstance;\n\t};\n\treturn {\n\t\tsql: sql$1,\n\t\torm: orm({\n\t\t\truntime: {\n\t\t\t\tquery(plan) {\n\t\t\t\t\treturn getRuntime().query(plan);\n\t\t\t\t},\n\t\t\t\texecute(plan) {\n\t\t\t\t\treturn getRuntime().execute(plan);\n\t\t\t\t},\n\t\t\t\tconnection() {\n\t\t\t\t\treturn getRuntime().connection();\n\t\t\t\t}\n\t\t\t},\n\t\t\tcontext\n\t\t}),\n\t\tenums,\n\t\tnativeEnums,\n\t\traw: rawSqlTag,\n\t\tcontext,\n\t\tcontract,\n\t\tstack,\n\t\tasync connect(bindingInput) {\n\t\t\tif (closed) throw postgresError(\"DRIVER.NOT_CONNECTED\", \"Postgres client is closed\", {\n\t\t\t\twhy: \"close() was called on this client.\",\n\t\t\t\tfix: \"Create a new postgres(...) client.\",\n\t\t\t\tmeta: { extension: \"postgres\" }\n\t\t\t});\n\t\t\tif (driverConnected || connectPromise) throw postgresError(\"DRIVER.ALREADY_CONNECTED\", \"Postgres client already connected\", {\n\t\t\t\tfix: \"Call connect() at most once per client.\",\n\t\t\t\tmeta: { extension: \"postgres\" }\n\t\t\t});\n\t\t\tif (bindingInput !== void 0) binding = resolvePostgresBinding(bindingInput);\n\t\t\tif (binding === void 0) throw postgresError(\"RUNTIME.BINDING_MISSING\", \"Postgres binding not configured. Pass url/pg/binding to postgres(...) or call db.connect({ ... }).\", { meta: { extension: \"postgres\" } });\n\t\t\tconst runtime = getRuntime();\n\t\t\tif (driverConnected) return runtime;\n\t\t\tawait connectDriver(binding);\n\t\t\treturn runtime;\n\t\t},\n\t\truntime() {\n\t\t\treturn getRuntime();\n\t\t},\n\t\tprepare(declaration, callback) {\n\t\t\treturn getRuntime().prepare(declaration, (params) => callback(sql$1, params));\n\t\t},\n\t\ttransaction(fn) {\n\t\t\treturn withTransaction(getRuntime(), (txCtx) => {\n\t\t\t\tconst rawCodecInferer = stack.adapter.rawCodecInferer;\n\t\t\t\tconst txSql = sql({\n\t\t\t\t\tcontext,\n\t\t\t\t\trawCodecInferer\n\t\t\t\t});\n\t\t\t\tconst txOrm = orm({\n\t\t\t\t\truntime: {\n\t\t\t\t\t\tquery(plan) {\n\t\t\t\t\t\t\treturn txCtx.query(plan);\n\t\t\t\t\t\t},\n\t\t\t\t\t\texecute(plan) {\n\t\t\t\t\t\t\treturn txCtx.execute(plan);\n\t\t\t\t\t\t}\n\t\t\t\t\t},\n\t\t\t\t\tcontext\n\t\t\t\t});\n\t\t\t\treturn fn(Object.assign(Object.create(txCtx), {\n\t\t\t\t\tsql: txSql,\n\t\t\t\t\torm: txOrm,\n\t\t\t\t\tenums,\n\t\t\t\t\tnativeEnums\n\t\t\t\t}));\n\t\t\t});\n\t\t},\n\t\tasync close() {\n\t\t\tif (closed) return;\n\t\t\tclosed = true;\n\t\t\tawait connectPromise?.catch(() => void 0);\n\t\t\tawait ownedDispose?.();\n\t\t},\n\t\t[Symbol.asyncDispose]() {\n\t\t\treturn this.close();\n\t\t}\n\t};\n}\n//#endregion\nexport { PostgresRuntimeImpl, buildNamespacedNativeEnums, postgres as default, isPgClient, isPgPool };\n\n//# sourceMappingURL=runtime.mjs.map"],"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OAAO,OAAO,OAAO,OAAO,KAAK,GAAG;KAC7C,KAAK;KACL,KAAK;KACL;KACA;IACD,CAAC,CAAC;GACH,CAAC;EACF;EACA,MAAM,QAAQ;GACb,IAAI,QAAQ;GACZ,SAAS;GACT,MAAM,gBAAgB,YAAY,KAAK,CAAC;GACxC,MAAM,eAAe;EACtB;EACA,CAAC,OAAO,gBAAgB;GACvB,OAAO,KAAK,MAAM;EACnB;CACD;AACD"}
|
|
1
|
+
{"version":3,"file":"runtime.mjs","names":[],"sources":["../../../../3-extensions/postgres/dist/runtime.mjs"],"sourcesContent":["import { t as postgresError } from \"./errors-DfWK9xep.mjs\";\nimport { r as buildNamespacedNativeEnums, t as buildPostgresStaticContext } from \"./postgres-static-DBYpkrmX.mjs\";\nimport { t as PostgresRuntimeImpl } from \"./postgres-runtime-GybTEgP4.mjs\";\nimport { ifDefined } from \"@internal/utils/defined\";\nimport { InternalError } from \"@internal/utils/internal-error\";\nimport postgresAdapter from \"@internal/adapter-postgres/runtime\";\nimport postgresDriver, { suppressIdleConnectionErrors } from \"@internal/driver-postgres/runtime\";\nimport { instantiateExecutionStack } from \"@internal/framework-components/execution\";\nimport { sql } from \"@internal/sql-builder/runtime\";\nimport { orm } from \"@internal/sql-orm-client\";\nimport { createExecutionContext, createSqlExecutionStack, withTransaction } from \"@internal/sql-runtime\";\nimport postgresTarget, { PostgresContractSerializer } from \"@internal/target-postgres/runtime\";\nimport { Pool } from \"pg\";\n//#region src/runtime/binding.ts\nconst isPgPool = (pg) => \"totalCount\" in pg && \"idleCount\" in pg && \"waitingCount\" in pg;\nconst isPgClient = (pg) => \"escapeIdentifier\" in pg && \"escapeLiteral\" in pg;\nfunction validatePostgresUrl(url) {\n\tconst trimmed = url.trim();\n\tif (trimmed.length === 0) throw postgresError(\"RUNTIME.BINDING_INVALID\", \"Postgres URL must be a non-empty string\", { meta: {\n\t\textension: \"postgres\",\n\t\treason: \"empty url\"\n\t} });\n\tlet parsed;\n\ttry {\n\t\tparsed = new URL(trimmed);\n\t} catch {\n\t\tthrow postgresError(\"RUNTIME.BINDING_INVALID\", \"Postgres URL must be a valid URL\", { meta: {\n\t\t\textension: \"postgres\",\n\t\t\treason: \"unparseable url\"\n\t\t} });\n\t}\n\tif (parsed.protocol !== \"postgres:\" && parsed.protocol !== \"postgresql:\") throw postgresError(\"RUNTIME.BINDING_INVALID\", \"Postgres URL must use postgres:// or postgresql://\", { meta: {\n\t\textension: \"postgres\",\n\t\treason: \"wrong scheme\",\n\t\treceived: parsed.protocol\n\t} });\n\treturn trimmed;\n}\nfunction resolvePostgresBinding(options) {\n\tif (Number(options.binding !== void 0) + Number(options.url !== void 0) + Number(options.pg !== void 0) !== 1) throw postgresError(\"RUNTIME.BINDING_INVALID\", \"Provide one binding input: binding, url, or pg\", {\n\t\tfix: \"Pass exactly one of `binding`, `url`, or `pg`.\",\n\t\tmeta: {\n\t\t\textension: \"postgres\",\n\t\t\treason: \"zero or multiple binding inputs\"\n\t\t}\n\t});\n\tif (options.binding !== void 0) return options.binding;\n\tif (options.url !== void 0) return {\n\t\tkind: \"url\",\n\t\turl: validatePostgresUrl(options.url)\n\t};\n\tconst pgBinding = options.pg;\n\tif (pgBinding === void 0) throw new InternalError(\"Invariant violation: expected pg binding after validation\");\n\tif (isPgPool(pgBinding)) return {\n\t\tkind: \"pgPool\",\n\t\tpool: pgBinding\n\t};\n\tif (isPgClient(pgBinding)) return {\n\t\tkind: \"pgClient\",\n\t\tclient: pgBinding\n\t};\n\tthrow postgresError(\"RUNTIME.BINDING_INVALID\", \"Unable to determine pg binding type from pg input; use binding with explicit kind\", {\n\t\tfix: \"Pass `binding: { kind: \\\"pgPool\\\", pool }` or `binding: { kind: \\\"pgClient\\\", client }` instead of `pg`.\",\n\t\tmeta: {\n\t\t\textension: \"postgres\",\n\t\t\treason: \"unrecognizable pg object\"\n\t\t}\n\t});\n}\nfunction resolveOptionalPostgresBinding(options) {\n\tif (Number(options.binding !== void 0) + Number(options.url !== void 0) + Number(options.pg !== void 0) === 0) return;\n\treturn resolvePostgresBinding(options);\n}\n//#endregion\n//#region src/runtime/postgres.ts\nfunction hasContractJson(options) {\n\treturn \"contractJson\" in options;\n}\nconst contractSerializer = new PostgresContractSerializer();\nfunction resolveContract(options) {\n\tconst contractJson = hasContractJson(options) ? options.contractJson : contractSerializer.serializeContract(options.contract);\n\treturn contractSerializer.deserializeContract(contractJson);\n}\nfunction toRuntimeBinding(binding, options) {\n\tif (binding.kind !== \"url\") return binding;\n\treturn {\n\t\tkind: \"pgPool\",\n\t\tpool: suppressIdleConnectionErrors(new Pool({\n\t\t\tconnectionString: binding.url,\n\t\t\tconnectionTimeoutMillis: options.poolOptions?.connectionTimeoutMillis ?? 2e4,\n\t\t\tidleTimeoutMillis: options.poolOptions?.idleTimeoutMillis ?? 3e4\n\t\t}))\n\t};\n}\nfunction postgres(options) {\n\tconst contract = resolveContract(options);\n\tlet binding = resolveOptionalPostgresBinding(options);\n\tconst stack = createSqlExecutionStack({\n\t\ttarget: postgresTarget,\n\t\tadapter: postgresAdapter,\n\t\tdriver: postgresDriver,\n\t\textensions: options.extensions ?? []\n\t});\n\tconst context = createExecutionContext({\n\t\tcontract,\n\t\tstack,\n\t\tdriver: postgresDriver\n\t});\n\tconst { sql: sql$1, raw: rawSqlTag, enums, nativeEnums } = buildPostgresStaticContext(context, stack.adapter.rawCodecInferer);\n\tlet runtimeInstance;\n\tlet runtimeDriver;\n\tlet driverConnected = false;\n\tlet connectPromise;\n\tlet backgroundConnectError;\n\tlet closed = false;\n\tlet ownedDispose;\n\tconst connectDriver = async (resolvedBinding) => {\n\t\tif (driverConnected) return;\n\t\tif (!runtimeDriver) throw new InternalError(\"Postgres runtime driver missing\");\n\t\tif (connectPromise) return connectPromise;\n\t\tconst runtimeBinding = toRuntimeBinding(resolvedBinding, options);\n\t\tif (resolvedBinding.kind === \"url\" && runtimeBinding.kind === \"pgPool\") {\n\t\t\tconst pool = runtimeBinding.pool;\n\t\t\tlet disposed = false;\n\t\t\townedDispose = async () => {\n\t\t\t\tif (disposed) return;\n\t\t\t\tdisposed = true;\n\t\t\t\tawait pool.end().then(() => void 0);\n\t\t\t};\n\t\t}\n\t\tconnectPromise = runtimeDriver.connect(runtimeBinding).then(() => {\n\t\t\tdriverConnected = true;\n\t\t}).catch(async (err) => {\n\t\t\tbackgroundConnectError = err;\n\t\t\tconnectPromise = void 0;\n\t\t\tawait ownedDispose?.().catch(() => void 0);\n\t\t\tthrow err;\n\t\t});\n\t\treturn connectPromise;\n\t};\n\tconst getRuntime = () => {\n\t\tif (closed) throw postgresError(\"DRIVER.NOT_CONNECTED\", \"Postgres client is closed\", {\n\t\t\twhy: \"close() was called on this client.\",\n\t\t\tfix: \"Create a new postgres(...) client.\",\n\t\t\tmeta: { extension: \"postgres\" }\n\t\t});\n\t\tif (backgroundConnectError !== void 0) throw backgroundConnectError;\n\t\tif (runtimeInstance) return runtimeInstance;\n\t\tconst stackInstance = instantiateExecutionStack(stack);\n\t\tconst driverDescriptor = stack.driver;\n\t\tif (!driverDescriptor) throw new InternalError(\"Driver descriptor missing from execution stack\");\n\t\tconst driver = driverDescriptor.create({ cursor: { disabled: true } });\n\t\truntimeDriver = driver;\n\t\tif (binding !== void 0) connectDriver(binding).catch(() => void 0);\n\t\truntimeInstance = new PostgresRuntimeImpl({\n\t\t\tcontext,\n\t\t\tadapter: stackInstance.adapter,\n\t\t\tdriver,\n\t\t\t...ifDefined(\"verifyMarker\", options.verifyMarker),\n\t\t\t...ifDefined(\"middleware\", options.middleware)\n\t\t});\n\t\treturn runtimeInstance;\n\t};\n\treturn {\n\t\tsql: sql$1,\n\t\torm: orm({\n\t\t\truntime: {\n\t\t\t\tquery(plan) {\n\t\t\t\t\treturn getRuntime().query(plan);\n\t\t\t\t},\n\t\t\t\texecute(plan) {\n\t\t\t\t\treturn getRuntime().execute(plan);\n\t\t\t\t},\n\t\t\t\tconnection() {\n\t\t\t\t\treturn getRuntime().connection();\n\t\t\t\t}\n\t\t\t},\n\t\t\tcontext\n\t\t}),\n\t\tenums,\n\t\tnativeEnums,\n\t\traw: rawSqlTag,\n\t\tcontext,\n\t\tcontract,\n\t\tstack,\n\t\tasync connect(bindingInput) {\n\t\t\tif (closed) throw postgresError(\"DRIVER.NOT_CONNECTED\", \"Postgres client is closed\", {\n\t\t\t\twhy: \"close() was called on this client.\",\n\t\t\t\tfix: \"Create a new postgres(...) client.\",\n\t\t\t\tmeta: { extension: \"postgres\" }\n\t\t\t});\n\t\t\tif (driverConnected || connectPromise) throw postgresError(\"DRIVER.ALREADY_CONNECTED\", \"Postgres client already connected\", {\n\t\t\t\tfix: \"Call connect() at most once per client.\",\n\t\t\t\tmeta: { extension: \"postgres\" }\n\t\t\t});\n\t\t\tif (bindingInput !== void 0) binding = resolvePostgresBinding(bindingInput);\n\t\t\tif (binding === void 0) throw postgresError(\"RUNTIME.BINDING_MISSING\", \"Postgres binding not configured. Pass url/pg/binding to postgres(...) or call db.connect({ ... }).\", { meta: { extension: \"postgres\" } });\n\t\t\tconst runtime = getRuntime();\n\t\t\tif (driverConnected) return runtime;\n\t\t\tawait connectDriver(binding);\n\t\t\treturn runtime;\n\t\t},\n\t\truntime() {\n\t\t\treturn getRuntime();\n\t\t},\n\t\tprepare(declaration, callback) {\n\t\t\treturn getRuntime().prepare(declaration, (params) => callback(sql$1, params));\n\t\t},\n\t\ttransaction(fn) {\n\t\t\treturn withTransaction(getRuntime(), (txCtx) => {\n\t\t\t\tconst rawCodecInferer = stack.adapter.rawCodecInferer;\n\t\t\t\tconst txSql = sql({\n\t\t\t\t\tcontext,\n\t\t\t\t\trawCodecInferer\n\t\t\t\t});\n\t\t\t\tconst txOrm = orm({\n\t\t\t\t\truntime: {\n\t\t\t\t\t\tquery(plan) {\n\t\t\t\t\t\t\treturn txCtx.query(plan);\n\t\t\t\t\t\t},\n\t\t\t\t\t\texecute(plan) {\n\t\t\t\t\t\t\treturn txCtx.execute(plan);\n\t\t\t\t\t\t}\n\t\t\t\t\t},\n\t\t\t\t\tcontext\n\t\t\t\t});\n\t\t\t\treturn fn(Object.assign(Object.create(txCtx), {\n\t\t\t\t\tsql: txSql,\n\t\t\t\t\torm: txOrm,\n\t\t\t\t\tenums,\n\t\t\t\t\tnativeEnums\n\t\t\t\t}));\n\t\t\t});\n\t\t},\n\t\tasync close() {\n\t\t\tif (closed) return;\n\t\t\tclosed = true;\n\t\t\tawait connectPromise?.catch(() => void 0);\n\t\t\tawait ownedDispose?.();\n\t\t},\n\t\t[Symbol.asyncDispose]() {\n\t\t\treturn this.close();\n\t\t}\n\t};\n}\n//#endregion\nexport { PostgresRuntimeImpl, buildNamespacedNativeEnums, postgres as default, isPgClient, isPgPool };\n\n//# sourceMappingURL=runtime.mjs.map"],"mappings":";;;;;;;;;;;;;;AAcA,MAAM,YAAY,OAAO,gBAAgB,MAAM,eAAe,MAAM,kBAAkB;AACtF,MAAM,cAAc,OAAO,sBAAsB,MAAM,mBAAmB;AAC1E,SAAS,oBAAoB,KAAK;CACjC,MAAM,UAAU,IAAI,KAAK;CACzB,IAAI,QAAQ,WAAW,GAAG,MAAM,cAAc,2BAA2B,2CAA2C,EAAE,MAAM;EAC3H,WAAW;EACX,QAAQ;CACT,EAAE,CAAC;CACH,IAAI;CACJ,IAAI;EACH,SAAS,IAAI,IAAI,OAAO;CACzB,QAAQ;EACP,MAAM,cAAc,2BAA2B,oCAAoC,EAAE,MAAM;GAC1F,WAAW;GACX,QAAQ;EACT,EAAE,CAAC;CACJ;CACA,IAAI,OAAO,aAAa,eAAe,OAAO,aAAa,eAAe,MAAM,cAAc,2BAA2B,sDAAsD,EAAE,MAAM;EACtL,WAAW;EACX,QAAQ;EACR,UAAU,OAAO;CAClB,EAAE,CAAC;CACH,OAAO;AACR;AACA,SAAS,uBAAuB,SAAS;CACxC,IAAI,OAAO,QAAQ,YAAY,KAAK,CAAC,IAAI,OAAO,QAAQ,QAAQ,KAAK,CAAC,IAAI,OAAO,QAAQ,OAAO,KAAK,CAAC,MAAM,GAAG,MAA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,OAAO;EACR;EACA,UAAU;GACT,OAAO,WAAW;EACnB;EACA,QAAQ,aAAa,UAAU;GAC9B,OAAO,WAAW,CAAC,CAAC,QAAQ,cAAc,WAAW,SAAS,OAAO,MAAM,CAAC;EAC7E;EACA,YAAY,IAAI;GACf,OAAO,gBAAgB,WAAW,IAAI,UAAU;IAC/C,MAAM,kBAAkB,MAAM,QAAQ;IACtC,MAAM,QAAQ,IAAI;KACjB;KACA;IACD,CAAC;IACD,MAAM,QAAQ,IAAI;KACjB,SAAS;MACR,MAAM,MAAM;OACX,OAAO,MAAM,MAAM,IAAI;MACxB;MACA,QAAQ,MAAM;OACb,OAAO,MAAM,QAAQ,IAAI;MAC1B;KACD;KACA;IACD,CAAC;IACD,OAAO,GAAG,OAAO,OAAO,OAAO,OAAO,KAAK,GAAG;KAC7C,KAAK;KACL,KAAK;KACL;KACA;IACD,CAAC,CAAC;GACH,CAAC;EACF;EACA,MAAM,QAAQ;GACb,IAAI,QAAQ;GACZ,SAAS;GACT,MAAM,gBAAgB,YAAY,KAAK,CAAC;GACxC,MAAM,eAAe;EACtB;EACA,CAAC,OAAO,gBAAgB;GACvB,OAAO,KAAK,MAAM;EACnB;CACD;AACD"}
|
package/dist/serverless.mjs
CHANGED
|
@@ -6,7 +6,7 @@ import postgresAdapter from "@prisma/orm-target-postgres/adapter/runtime";
|
|
|
6
6
|
import { sql } from "@prisma/orm-family-sql/builder/runtime";
|
|
7
7
|
import { createExecutionContext, createSqlExecutionStack } from "@prisma/orm-family-sql/runtime";
|
|
8
8
|
import postgresTarget, { PostgresContractSerializer } from "@prisma/orm-target-postgres/target/runtime";
|
|
9
|
-
import postgresDriver from "@prisma/orm-target-postgres/driver/runtime";
|
|
9
|
+
import postgresDriver, { suppressIdleConnectionErrors } from "@prisma/orm-target-postgres/driver/runtime";
|
|
10
10
|
import { instantiateExecutionStack } from "@prisma/orm-framework/components/execution";
|
|
11
11
|
import { Client } from "pg";
|
|
12
12
|
//#region ../../../3-extensions/postgres/dist/serverless.mjs
|
|
@@ -52,7 +52,7 @@ function postgresServerless(options) {
|
|
|
52
52
|
if (!driverDescriptor) throw new InternalError("Driver descriptor missing from execution stack");
|
|
53
53
|
const stackInstance = instantiateExecutionStack(stack);
|
|
54
54
|
const driver = driverDescriptor.create({ ...ifDefined("cursor", options.cursor) });
|
|
55
|
-
const client = new Client({ connectionString: url });
|
|
55
|
+
const client = suppressIdleConnectionErrors(new Client({ connectionString: url }));
|
|
56
56
|
await driver.connect({
|
|
57
57
|
kind: "pgClient",
|
|
58
58
|
client
|
package/dist/serverless.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"serverless.mjs","names":[],"sources":["../../../../3-extensions/postgres/dist/serverless.mjs"],"sourcesContent":["import { t as postgresError } from \"./errors-DfWK9xep.mjs\";\nimport { t as PostgresRuntimeImpl } from \"./postgres-runtime-GybTEgP4.mjs\";\nimport { ifDefined } from \"@internal/utils/defined\";\nimport { InternalError } from \"@internal/utils/internal-error\";\nimport postgresAdapter from \"@internal/adapter-postgres/runtime\";\nimport postgresDriver from \"@internal/driver-postgres/runtime\";\nimport { instantiateExecutionStack } from \"@internal/framework-components/execution\";\nimport { sql } from \"@internal/sql-builder/runtime\";\nimport { createExecutionContext, createSqlExecutionStack } from \"@internal/sql-runtime\";\nimport postgresTarget, { PostgresContractSerializer } from \"@internal/target-postgres/runtime\";\nimport { Client } from \"pg\";\n//#region src/runtime/postgres-serverless.ts\nfunction hasContractJson(options) {\n\treturn \"contractJson\" in options;\n}\nconst contractSerializer = new PostgresContractSerializer();\nfunction resolveContract(options) {\n\tconst contractJson = hasContractJson(options) ? options.contractJson : contractSerializer.serializeContract(options.contract);\n\treturn contractSerializer.deserializeContract(contractJson);\n}\nfunction validateConnectionString(url) {\n\tconst trimmed = url.trim();\n\tif (trimmed.length === 0) throw postgresError(\"RUNTIME.BINDING_INVALID\", \"Postgres URL must be a non-empty string\", { meta: {\n\t\textension: \"postgres\",\n\t\treason: \"empty url\"\n\t} });\n\treturn trimmed;\n}\nfunction postgresServerless(options) {\n\tconst contract = resolveContract(options);\n\tconst stack = createSqlExecutionStack({\n\t\ttarget: postgresTarget,\n\t\tadapter: postgresAdapter,\n\t\tdriver: postgresDriver,\n\t\textensions: options.extensions ?? []\n\t});\n\tconst context = createExecutionContext({\n\t\tcontract,\n\t\tstack\n\t});\n\treturn {\n\t\tsql: sql({\n\t\t\tcontext,\n\t\t\trawCodecInferer: stack.adapter.rawCodecInferer\n\t\t}),\n\t\tcontext,\n\t\tstack,\n\t\tcontract,\n\t\tasync connect(binding) {\n\t\t\tconst url = validateConnectionString(binding.url);\n\t\t\tconst driverDescriptor = stack.driver;\n\t\t\tif (!driverDescriptor) throw new InternalError(\"Driver descriptor missing from execution stack\");\n\t\t\tconst stackInstance = instantiateExecutionStack(stack);\n\t\t\tconst driver = driverDescriptor.create({ ...ifDefined(\"cursor\", options.cursor) });\n\t\t\tconst client = new Client({ connectionString: url });\n\t\t\tawait driver.connect({\n\t\t\t\tkind: \"pgClient\",\n\t\t\t\tclient\n\t\t\t});\n\t\t\tlet runtime;\n\t\t\ttry {\n\t\t\t\truntime = new PostgresRuntimeImpl({\n\t\t\t\t\tcontext,\n\t\t\t\t\tadapter: stackInstance.adapter,\n\t\t\t\t\tdriver,\n\t\t\t\t\t...ifDefined(\"verifyMarker\", options.verifyMarker),\n\t\t\t\t\t...ifDefined(\"middleware\", options.middleware)\n\t\t\t\t});\n\t\t\t} catch (err) {\n\t\t\t\tawait driver.close().catch(() => void 0);\n\t\t\t\tthrow err;\n\t\t\t}\n\t\t\tObject.defineProperty(runtime, Symbol.asyncDispose, {\n\t\t\t\tvalue: () => runtime.close(),\n\t\t\t\tconfigurable: true,\n\t\t\t\twritable: false,\n\t\t\t\tenumerable: false\n\t\t\t});\n\t\t\treturn runtime;\n\t\t}\n\t};\n}\n//#endregion\nexport { postgresServerless as default };\n\n//# sourceMappingURL=serverless.mjs.map"],"mappings":";;;;;;;;;;;;AAYA,SAAS,gBAAgB,SAAS;CACjC,OAAO,kBAAkB;AAC1B;AACA,MAAM,qBAAqB,IAAI,2BAA2B;AAC1D,SAAS,gBAAgB,SAAS;CACjC,MAAM,eAAe,gBAAgB,OAAO,IAAI,QAAQ,eAAe,mBAAmB,kBAAkB,QAAQ,QAAQ;CAC5H,OAAO,mBAAmB,oBAAoB,YAAY;AAC3D;AACA,SAAS,yBAAyB,KAAK;CACtC,MAAM,UAAU,IAAI,KAAK;CACzB,IAAI,QAAQ,WAAW,GAAG,MAAM,cAAc,2BAA2B,2CAA2C,EAAE,MAAM;EAC3H,WAAW;EACX,QAAQ;CACT,EAAE,CAAC;CACH,OAAO;AACR;AACA,SAAS,mBAAmB,SAAS;CACpC,MAAM,WAAW,gBAAgB,OAAO;CACxC,MAAM,QAAQ,wBAAwB;EACrC,QAAQ;EACR,SAAS;EACT,QAAQ;EACR,YAAY,QAAQ,cAAc,CAAC;CACpC,CAAC;CACD,MAAM,UAAU,uBAAuB;EACtC;EACA;CACD,CAAC;CACD,OAAO;EACN,KAAK,IAAI;GACR;GACA,iBAAiB,MAAM,QAAQ;EAChC,CAAC;EACD;EACA;EACA;EACA,MAAM,QAAQ,SAAS;GACtB,MAAM,MAAM,yBAAyB,QAAQ,GAAG;GAChD,MAAM,mBAAmB,MAAM;GAC/B,IAAI,CAAC,kBAAkB,MAAM,IAAI,cAAc,gDAAgD;GAC/F,MAAM,gBAAgB,0BAA0B,KAAK;GACrD,MAAM,SAAS,iBAAiB,OAAO,EAAE,GAAG,UAAU,UAAU,QAAQ,MAAM,EAAE,CAAC;GACjF,MAAM,SAAS,IAAI,OAAO,EAAE,kBAAkB,IAAI,CAAC;
|
|
1
|
+
{"version":3,"file":"serverless.mjs","names":[],"sources":["../../../../3-extensions/postgres/dist/serverless.mjs"],"sourcesContent":["import { t as postgresError } from \"./errors-DfWK9xep.mjs\";\nimport { t as PostgresRuntimeImpl } from \"./postgres-runtime-GybTEgP4.mjs\";\nimport { ifDefined } from \"@internal/utils/defined\";\nimport { InternalError } from \"@internal/utils/internal-error\";\nimport postgresAdapter from \"@internal/adapter-postgres/runtime\";\nimport postgresDriver, { suppressIdleConnectionErrors } from \"@internal/driver-postgres/runtime\";\nimport { instantiateExecutionStack } from \"@internal/framework-components/execution\";\nimport { sql } from \"@internal/sql-builder/runtime\";\nimport { createExecutionContext, createSqlExecutionStack } from \"@internal/sql-runtime\";\nimport postgresTarget, { PostgresContractSerializer } from \"@internal/target-postgres/runtime\";\nimport { Client } from \"pg\";\n//#region src/runtime/postgres-serverless.ts\nfunction hasContractJson(options) {\n\treturn \"contractJson\" in options;\n}\nconst contractSerializer = new PostgresContractSerializer();\nfunction resolveContract(options) {\n\tconst contractJson = hasContractJson(options) ? options.contractJson : contractSerializer.serializeContract(options.contract);\n\treturn contractSerializer.deserializeContract(contractJson);\n}\nfunction validateConnectionString(url) {\n\tconst trimmed = url.trim();\n\tif (trimmed.length === 0) throw postgresError(\"RUNTIME.BINDING_INVALID\", \"Postgres URL must be a non-empty string\", { meta: {\n\t\textension: \"postgres\",\n\t\treason: \"empty url\"\n\t} });\n\treturn trimmed;\n}\nfunction postgresServerless(options) {\n\tconst contract = resolveContract(options);\n\tconst stack = createSqlExecutionStack({\n\t\ttarget: postgresTarget,\n\t\tadapter: postgresAdapter,\n\t\tdriver: postgresDriver,\n\t\textensions: options.extensions ?? []\n\t});\n\tconst context = createExecutionContext({\n\t\tcontract,\n\t\tstack\n\t});\n\treturn {\n\t\tsql: sql({\n\t\t\tcontext,\n\t\t\trawCodecInferer: stack.adapter.rawCodecInferer\n\t\t}),\n\t\tcontext,\n\t\tstack,\n\t\tcontract,\n\t\tasync connect(binding) {\n\t\t\tconst url = validateConnectionString(binding.url);\n\t\t\tconst driverDescriptor = stack.driver;\n\t\t\tif (!driverDescriptor) throw new InternalError(\"Driver descriptor missing from execution stack\");\n\t\t\tconst stackInstance = instantiateExecutionStack(stack);\n\t\t\tconst driver = driverDescriptor.create({ ...ifDefined(\"cursor\", options.cursor) });\n\t\t\tconst client = suppressIdleConnectionErrors(new Client({ connectionString: url }));\n\t\t\tawait driver.connect({\n\t\t\t\tkind: \"pgClient\",\n\t\t\t\tclient\n\t\t\t});\n\t\t\tlet runtime;\n\t\t\ttry {\n\t\t\t\truntime = new PostgresRuntimeImpl({\n\t\t\t\t\tcontext,\n\t\t\t\t\tadapter: stackInstance.adapter,\n\t\t\t\t\tdriver,\n\t\t\t\t\t...ifDefined(\"verifyMarker\", options.verifyMarker),\n\t\t\t\t\t...ifDefined(\"middleware\", options.middleware)\n\t\t\t\t});\n\t\t\t} catch (err) {\n\t\t\t\tawait driver.close().catch(() => void 0);\n\t\t\t\tthrow err;\n\t\t\t}\n\t\t\tObject.defineProperty(runtime, Symbol.asyncDispose, {\n\t\t\t\tvalue: () => runtime.close(),\n\t\t\t\tconfigurable: true,\n\t\t\t\twritable: false,\n\t\t\t\tenumerable: false\n\t\t\t});\n\t\t\treturn runtime;\n\t\t}\n\t};\n}\n//#endregion\nexport { postgresServerless as default };\n\n//# sourceMappingURL=serverless.mjs.map"],"mappings":";;;;;;;;;;;;AAYA,SAAS,gBAAgB,SAAS;CACjC,OAAO,kBAAkB;AAC1B;AACA,MAAM,qBAAqB,IAAI,2BAA2B;AAC1D,SAAS,gBAAgB,SAAS;CACjC,MAAM,eAAe,gBAAgB,OAAO,IAAI,QAAQ,eAAe,mBAAmB,kBAAkB,QAAQ,QAAQ;CAC5H,OAAO,mBAAmB,oBAAoB,YAAY;AAC3D;AACA,SAAS,yBAAyB,KAAK;CACtC,MAAM,UAAU,IAAI,KAAK;CACzB,IAAI,QAAQ,WAAW,GAAG,MAAM,cAAc,2BAA2B,2CAA2C,EAAE,MAAM;EAC3H,WAAW;EACX,QAAQ;CACT,EAAE,CAAC;CACH,OAAO;AACR;AACA,SAAS,mBAAmB,SAAS;CACpC,MAAM,WAAW,gBAAgB,OAAO;CACxC,MAAM,QAAQ,wBAAwB;EACrC,QAAQ;EACR,SAAS;EACT,QAAQ;EACR,YAAY,QAAQ,cAAc,CAAC;CACpC,CAAC;CACD,MAAM,UAAU,uBAAuB;EACtC;EACA;CACD,CAAC;CACD,OAAO;EACN,KAAK,IAAI;GACR;GACA,iBAAiB,MAAM,QAAQ;EAChC,CAAC;EACD;EACA;EACA;EACA,MAAM,QAAQ,SAAS;GACtB,MAAM,MAAM,yBAAyB,QAAQ,GAAG;GAChD,MAAM,mBAAmB,MAAM;GAC/B,IAAI,CAAC,kBAAkB,MAAM,IAAI,cAAc,gDAAgD;GAC/F,MAAM,gBAAgB,0BAA0B,KAAK;GACrD,MAAM,SAAS,iBAAiB,OAAO,EAAE,GAAG,UAAU,UAAU,QAAQ,MAAM,EAAE,CAAC;GACjF,MAAM,SAAS,6BAA6B,IAAI,OAAO,EAAE,kBAAkB,IAAI,CAAC,CAAC;GACjF,MAAM,OAAO,QAAQ;IACpB,MAAM;IACN;GACD,CAAC;GACD,IAAI;GACJ,IAAI;IACH,UAAU,IAAI,oBAAoB;KACjC;KACA,SAAS,cAAc;KACvB;KACA,GAAG,UAAU,gBAAgB,QAAQ,YAAY;KACjD,GAAG,UAAU,cAAc,QAAQ,UAAU;IAC9C,CAAC;GACF,SAAS,KAAK;IACb,MAAM,OAAO,MAAM,CAAC,CAAC,YAAY,KAAK,CAAC;IACvC,MAAM;GACP;GACA,OAAO,eAAe,SAAS,OAAO,cAAc;IACnD,aAAa,QAAQ,MAAM;IAC3B,cAAc;IACd,UAAU;IACV,YAAY;GACb,CAAC;GACD,OAAO;EACR;CACD;AACD"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "@prisma/orm-framework/utils/suppress-idle-connection-errors";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@prisma/orm-postgres",
|
|
3
|
-
"version": "8.0.0-rc.4-dev.
|
|
3
|
+
"version": "8.0.0-rc.4-dev.8",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"sideEffects": false,
|
|
@@ -9,19 +9,19 @@
|
|
|
9
9
|
"dist"
|
|
10
10
|
],
|
|
11
11
|
"dependencies": {
|
|
12
|
-
"@prisma/orm-family-sql": "8.0.0-rc.4-dev.
|
|
13
|
-
"@prisma/orm-framework": "8.0.0-rc.4-dev.
|
|
14
|
-
"@prisma/orm-target-postgres": "8.0.0-rc.4-dev.
|
|
15
|
-
"@prisma/orm-toolchain": "8.0.0-rc.4-dev.
|
|
12
|
+
"@prisma/orm-family-sql": "8.0.0-rc.4-dev.8",
|
|
13
|
+
"@prisma/orm-framework": "8.0.0-rc.4-dev.8",
|
|
14
|
+
"@prisma/orm-target-postgres": "8.0.0-rc.4-dev.8",
|
|
15
|
+
"@prisma/orm-toolchain": "8.0.0-rc.4-dev.8",
|
|
16
16
|
"@types/pg": "8.20.4",
|
|
17
17
|
"pathe": "^2.0.3",
|
|
18
18
|
"pg": "8.22.0"
|
|
19
19
|
},
|
|
20
20
|
"devDependencies": {
|
|
21
|
-
"@internal/postgres": "8.0.0-rc.4-dev.
|
|
22
|
-
"@repo/tsconfig": "8.0.0-rc.4-dev.
|
|
23
|
-
"@internal/publish-surface": "8.0.0-rc.4-dev.
|
|
24
|
-
"@repo/tsdown": "8.0.0-rc.4-dev.
|
|
21
|
+
"@internal/postgres": "8.0.0-rc.4-dev.8",
|
|
22
|
+
"@repo/tsconfig": "8.0.0-rc.4-dev.8",
|
|
23
|
+
"@internal/publish-surface": "8.0.0-rc.4-dev.8",
|
|
24
|
+
"@repo/tsdown": "8.0.0-rc.4-dev.8",
|
|
25
25
|
"tsdown": "0.22.14",
|
|
26
26
|
"typescript": "5.9.3",
|
|
27
27
|
"vitest": "4.1.10"
|
|
@@ -171,6 +171,7 @@
|
|
|
171
171
|
"./utils/result": "./dist/utils__result.mjs",
|
|
172
172
|
"./utils/simplify-deep": "./dist/utils__simplify-deep.mjs",
|
|
173
173
|
"./utils/structured-error": "./dist/utils__structured-error.mjs",
|
|
174
|
+
"./utils/suppress-idle-connection-errors": "./dist/utils__suppress-idle-connection-errors.mjs",
|
|
174
175
|
"./utils/types": "./dist/utils__types.mjs",
|
|
175
176
|
"./vite-plugin-contract-emit": "./dist/vite-plugin-contract-emit.mjs",
|
|
176
177
|
"./package.json": "./package.json"
|