appos 0.3.2-0 → 0.3.4-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/bin/auth-schema-CcqAJY9P.mjs +2 -0
- package/dist/bin/better-sqlite3-CuQ3hsWl.mjs +2 -0
- package/dist/bin/bun-sql-DGeo-s_M.mjs +2 -0
- package/dist/bin/cache-3oO07miM.mjs +2 -0
- package/dist/bin/chunk-l9p7A9gZ.mjs +2 -0
- package/dist/bin/cockroach-BaICwY7N.mjs +2 -0
- package/dist/bin/database-CaysWPpa.mjs +2 -0
- package/dist/bin/esm-BvsccvmM.mjs +2 -0
- package/dist/bin/esm-CGKzJ7Am.mjs +3 -0
- package/dist/bin/event-DnSe3eh0.mjs +8 -0
- package/dist/bin/extract-blob-metadata-iqwTl2ft.mjs +170 -0
- package/dist/bin/generate-image-variant-Lyx0vhM6.mjs +2 -0
- package/dist/bin/generate-preview-0MrKxslA.mjs +2 -0
- package/dist/bin/libsql-DQJrZsU9.mjs +2 -0
- package/dist/bin/logger-BAGZLUzj.mjs +2 -0
- package/dist/bin/main.mjs +1201 -190
- package/dist/bin/migrator-B7iNKM8N.mjs +2 -0
- package/dist/bin/migrator-BKE1cSQQ.mjs +2 -0
- package/dist/bin/migrator-BXcbc9zs.mjs +2 -0
- package/dist/bin/migrator-B_XhRWZC.mjs +8 -0
- package/dist/bin/migrator-Bz52Gtr8.mjs +2 -0
- package/dist/bin/migrator-C7W-cZHB.mjs +2 -0
- package/dist/bin/migrator-CEnKyGSW.mjs +2 -0
- package/dist/bin/migrator-CHzIIl5X.mjs +2 -0
- package/dist/bin/migrator-CR-rjZdM.mjs +2 -0
- package/dist/bin/migrator-CjIr1ZCx.mjs +8 -0
- package/dist/bin/migrator-Cuubh2dg.mjs +2 -0
- package/dist/bin/migrator-D8m-ORbr.mjs +8 -0
- package/dist/bin/migrator-DBFwrhZH.mjs +2 -0
- package/dist/bin/migrator-DLmhW9u_.mjs +2 -0
- package/dist/bin/migrator-DLoHx807.mjs +4 -0
- package/dist/bin/migrator-DtN_iS87.mjs +2 -0
- package/dist/bin/migrator-Yc57lb3w.mjs +2 -0
- package/dist/bin/migrator-cEVXH3xC.mjs +2 -0
- package/dist/bin/migrator-hWi-sYIq.mjs +2 -0
- package/dist/bin/mysql2-DufFWkj4.mjs +2 -0
- package/dist/bin/neon-serverless-5a4h2VFz.mjs +2 -0
- package/dist/bin/node-CiOp4xrR.mjs +22 -0
- package/dist/bin/node-mssql-DvZGaUkB.mjs +322 -0
- package/dist/bin/node-postgres-BqbJVBQY.mjs +2 -0
- package/dist/bin/node-postgres-DnhRTTO8.mjs +2 -0
- package/dist/bin/open-0ksnL0S8.mjs +2 -0
- package/dist/bin/pdf-sUYeFPr4.mjs +14 -0
- package/dist/bin/pg-CaH8ptj-.mjs +2 -0
- package/dist/bin/pg-core-BLTZt9AH.mjs +8 -0
- package/dist/bin/pg-core-CGzidKaA.mjs +2 -0
- package/dist/bin/pglite-BJB9z7Ju.mjs +2 -0
- package/dist/bin/planetscale-serverless-H3RfLlMK.mjs +13 -0
- package/dist/bin/postgres-js-DuOf1eWm.mjs +2 -0
- package/dist/bin/purge-attachment-DQXpTtTx.mjs +2 -0
- package/dist/bin/purge-audit-logs-BEt2J2gD.mjs +2 -0
- package/dist/bin/{purge-unattached-blobs-Duvv8Izd.mjs → purge-unattached-blobs-DOmk4ddJ.mjs} +1 -1
- package/dist/bin/query-builder-DSRrR6X_.mjs +8 -0
- package/dist/bin/query-builder-V8-LDhvA.mjs +3 -0
- package/dist/bin/session-CdB1A-LB.mjs +14 -0
- package/dist/bin/session-Cl2e-_i8.mjs +8 -0
- package/dist/bin/singlestore-COft6TlR.mjs +8 -0
- package/dist/bin/sql-D-eKV1Dn.mjs +2 -0
- package/dist/bin/sqlite-cloud-Co9jOn5G.mjs +2 -0
- package/dist/bin/sqlite-proxy-Cpu78gJF.mjs +2 -0
- package/dist/bin/src-C-oXmCzx.mjs +6 -0
- package/dist/bin/table-3zUpWkMg.mjs +2 -0
- package/dist/bin/track-db-changes-DWyY5jXm.mjs +2 -0
- package/dist/bin/utils-CyoeCJlf.mjs +2 -0
- package/dist/bin/utils-EoqYQKy1.mjs +2 -0
- package/dist/bin/utils-bsypyqPl.mjs +2 -0
- package/dist/bin/vercel-postgres-HWL6xtqi.mjs +2 -0
- package/dist/bin/workflow-zxHDyfLq.mjs +2 -0
- package/dist/bin/youch-handler-DrYdbUhe.mjs +2 -0
- package/dist/bin/zod-MJjkEkRY.mjs +24 -0
- package/dist/exports/api/_virtual/rolldown_runtime.mjs +36 -1
- package/dist/exports/api/app-context.mjs +24 -1
- package/dist/exports/api/auth-schema.mjs +373 -1
- package/dist/exports/api/auth.d.mts +4 -0
- package/dist/exports/api/auth.mjs +188 -1
- package/dist/exports/api/cache.d.mts +2 -2
- package/dist/exports/api/cache.mjs +28 -1
- package/dist/exports/api/config.mjs +72 -1
- package/dist/exports/api/constants.mjs +92 -1
- package/dist/exports/api/container.mjs +49 -1
- package/dist/exports/api/database.mjs +218 -1
- package/dist/exports/api/event.mjs +236 -1
- package/dist/exports/api/i18n.mjs +45 -1
- package/dist/exports/api/index.mjs +20 -1
- package/dist/exports/api/instrumentation.mjs +40 -1
- package/dist/exports/api/logger.mjs +26 -1
- package/dist/exports/api/mailer.mjs +37 -1
- package/dist/exports/api/middleware.mjs +73 -1
- package/dist/exports/api/openapi.mjs +507 -1
- package/dist/exports/api/orm.mjs +43 -1
- package/dist/exports/api/otel.mjs +56 -1
- package/dist/exports/api/redis.mjs +41 -1
- package/dist/exports/api/storage-schema.mjs +72 -1
- package/dist/exports/api/storage.mjs +833 -1
- package/dist/exports/api/web/auth.mjs +17 -1
- package/dist/exports/api/workflow.mjs +196 -1
- package/dist/exports/api/workflows/_virtual/rolldown_runtime.mjs +36 -1
- package/dist/exports/api/workflows/api/auth-schema.mjs +373 -1
- package/dist/exports/api/workflows/api/auth.d.mts +4 -0
- package/dist/exports/api/workflows/api/cache.d.mts +2 -2
- package/dist/exports/api/workflows/api/event.mjs +126 -1
- package/dist/exports/api/workflows/api/redis.mjs +3 -1
- package/dist/exports/api/workflows/api/workflow.mjs +135 -1
- package/dist/exports/api/workflows/constants.mjs +23 -1
- package/dist/exports/api/workflows/extract-blob-metadata.mjs +132 -1
- package/dist/exports/api/workflows/generate-image-variant.d.mts +2 -2
- package/dist/exports/api/workflows/generate-image-variant.mjs +118 -1
- package/dist/exports/api/workflows/generate-preview.mjs +160 -1
- package/dist/exports/api/workflows/index.mjs +3 -1
- package/dist/exports/api/workflows/purge-attachment.mjs +34 -1
- package/dist/exports/api/workflows/purge-audit-logs.mjs +47 -1
- package/dist/exports/api/workflows/purge-unattached-blobs.mjs +46 -1
- package/dist/exports/api/workflows/track-db-changes.mjs +110 -1
- package/dist/exports/cli/_virtual/rolldown_runtime.mjs +36 -1
- package/dist/exports/cli/api/auth-schema.mjs +373 -1
- package/dist/exports/cli/api/auth.d.mts +4 -0
- package/dist/exports/cli/api/cache.d.mts +2 -2
- package/dist/exports/cli/api/event.mjs +126 -1
- package/dist/exports/cli/api/redis.mjs +3 -1
- package/dist/exports/cli/api/workflow.mjs +135 -1
- package/dist/exports/cli/api/workflows/extract-blob-metadata.mjs +132 -1
- package/dist/exports/cli/api/workflows/generate-image-variant.mjs +118 -1
- package/dist/exports/cli/api/workflows/generate-preview.mjs +160 -1
- package/dist/exports/cli/api/workflows/purge-attachment.mjs +34 -1
- package/dist/exports/cli/api/workflows/purge-audit-logs.mjs +47 -1
- package/dist/exports/cli/api/workflows/purge-unattached-blobs.mjs +46 -1
- package/dist/exports/cli/api/workflows/track-db-changes.mjs +110 -1
- package/dist/exports/cli/command.d.mts +2 -0
- package/dist/exports/cli/command.mjs +43 -1
- package/dist/exports/cli/constants.mjs +23 -1
- package/dist/exports/cli/index.mjs +3 -1
- package/dist/exports/devtools/index.js +4 -1
- package/dist/exports/tests/api/auth.d.mts +4 -0
- package/dist/exports/tests/api/cache.d.mts +2 -2
- package/dist/exports/tests/api/middleware/i18n.mjs +1 -1
- package/dist/exports/tests/api/middleware/youch-handler.mjs +1 -1
- package/dist/exports/tests/api/openapi.mjs +1 -1
- package/dist/exports/tests/api/server.mjs +1 -1
- package/dist/exports/tests/api/storage.d.mts +4 -4
- package/dist/exports/tests/constants.mjs +1 -1
- package/dist/exports/vendors/date.js +1 -1
- package/dist/exports/vendors/toolkit.js +1 -1
- package/dist/exports/vendors/zod.js +1 -1
- package/dist/exports/vitest/globals.mjs +1 -1
- package/dist/exports/web/auth.js +75 -1
- package/dist/exports/web/i18n.js +45 -1
- package/dist/exports/web/index.js +8 -1
- package/package.json +19 -18
- package/dist/bin/auth-schema-Va0CYicu.mjs +0 -2
- package/dist/bin/event-8JibGFH_.mjs +0 -2
- package/dist/bin/extract-blob-metadata-DjPfHtQ2.mjs +0 -2
- package/dist/bin/generate-image-variant-D5VDFyWj.mjs +0 -2
- package/dist/bin/generate-preview-Dssw7w5U.mjs +0 -2
- package/dist/bin/purge-attachment-BBPzIxwt.mjs +0 -2
- package/dist/bin/purge-audit-logs-BeZy3IFM.mjs +0 -2
- package/dist/bin/track-db-changes-CFykw_YO.mjs +0 -2
- package/dist/bin/workflow-BNUZrj4F.mjs +0 -2
- package/dist/bin/youch-handler-BadUgHb0.mjs +0 -2
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import{u as e}from"./sql-D-eKV1Dn.mjs";import{K as t}from"./query-builder-V8-LDhvA.mjs";function n(){let n=t(`accounts`,t=>({id:t.text(`id`).primaryKey().default(e`uuidv7()`),accessToken:t.text(`access_token`),accessTokenExpiresAt:t.timestamp(`access_token_expires_at`,{mode:`string`,withTimezone:!0}),accountId:t.text(`account_id`).notNull(),createdAt:t.timestamp(`created_at`,{mode:`string`,withTimezone:!0}).default(e`NOW()`).notNull(),idToken:t.text(`id_token`),providerId:t.text(`provider_id`).notNull(),password:t.text(`password`),userId:t.text(`user_id`).notNull().references(()=>l.id,{onDelete:`cascade`}),refreshToken:t.text(`refresh_token`),refreshTokenExpiresAt:t.timestamp(`refresh_token_expires_at`,{mode:`string`,withTimezone:!0}),scope:t.text(`scope`),updatedAt:t.timestamp(`updated_at`,{mode:`string`,withTimezone:!0}).default(e`NOW()`).notNull()}),e=>[]),r=t(`api_keys`,t=>({id:t.text(`id`).primaryKey().default(e`uuidv7()`),name:t.text(`name`),enabled:t.boolean(`enabled`).default(!0),expiresAt:t.timestamp(`expires_at`,{mode:`string`,withTimezone:!0}),key:t.text(`key`).notNull(),lastRefillAt:t.timestamp(`last_refill_at`,{mode:`string`,withTimezone:!0}),lastRequest:t.timestamp(`last_request`,{mode:`string`,withTimezone:!0}),lastUsedAt:t.timestamp(`last_used_at`,{mode:`string`,withTimezone:!0}),metadata:t.text(`metadata`),permissions:t.text(`permissions`),prefix:t.text(`prefix`),rateLimitEnabled:t.boolean(`rate_limit_enabled`).default(!0),rateLimitTimeWindow:t.integer(`rate_limit_time_window`).default(864e5),rateLimitMax:t.integer(`rate_limit_max`).default(10),refillInterval:t.integer(`refill_interval`),refillAmount:t.integer(`refill_amount`),requestCount:t.integer(`request_count`),remaining:t.integer(`remaining`),start:t.text(`start`),userId:t.text(`user_id`).notNull().references(()=>l.id,{onDelete:`cascade`}),createdAt:t.timestamp(`created_at`,{mode:`string`,withTimezone:!0}).default(e`NOW()`).notNull(),updatedAt:t.timestamp(`updated_at`,{mode:`string`,withTimezone:!0}).default(e`NOW()`).notNull()}),e=>[]),i=t(`invitations`,t=>({id:t.text(`id`).primaryKey().default(e`uuidv7()`),email:t.text(`email`).notNull(),expiresAt:t.timestamp(`expires_at`,{mode:`string`,withTimezone:!0}).notNull(),inviterId:t.text(`inviter_id`).notNull().references(()=>l.id,{onDelete:`cascade`}),organizationId:t.text(`organization_id`).notNull().references(()=>o.id,{onDelete:`cascade`}),role:t.text(`role`),status:t.text(`status`).default(`pending`).notNull(),teamId:t.text(`team_id`),createdAt:t.timestamp(`created_at`,{mode:`string`,withTimezone:!0}).default(e`NOW()`).notNull(),updatedAt:t.timestamp(`updated_at`,{mode:`string`,withTimezone:!0}).default(e`NOW()`).notNull()}),e=>[]),a=t(`members`,t=>({id:t.text(`id`).primaryKey().default(e`uuidv7()`),organizationId:t.text(`organization_id`).notNull().references(()=>o.id,{onDelete:`cascade`}),role:t.text(`role`).default(`member`).notNull(),userId:t.text(`user_id`).notNull().references(()=>l.id,{onDelete:`cascade`}),createdAt:t.timestamp(`created_at`,{mode:`string`,withTimezone:!0}).default(e`NOW()`).notNull()}),e=>[]),o=t(`organizations`,t=>({id:t.text(`id`).primaryKey().default(e`uuidv7()`),name:t.text(`name`).notNull(),slug:t.text(`slug`).unique(),logo:t.text(`logo`),createdAt:t.timestamp(`created_at`,{mode:`string`,withTimezone:!0}).default(e`NOW()`).notNull(),updatedAt:t.timestamp(`updated_at`,{mode:`string`,withTimezone:!0}).default(e`NOW()`).notNull(),metadata:t.text(`metadata`)}),e=>[]),s=t(`sessions`,t=>({id:t.text(`id`).primaryKey().default(e`uuidv7()`),activeOrganizationId:t.text(`active_organization_id`).references(()=>o.id,{onDelete:`set null`}),activeTeamId:t.text(`active_team_id`),createdAt:t.timestamp(`created_at`,{mode:`string`,withTimezone:!0}).default(e`NOW()`).notNull(),expiresAt:t.timestamp(`expires_at`,{mode:`string`,withTimezone:!0}).notNull(),impersonatedBy:t.text(`impersonated_by`).references(()=>l.id,{onDelete:`set null`}),ipAddress:t.text(`ip_address`),token:t.text(`token`).notNull().unique(),updatedAt:t.timestamp(`updated_at`,{mode:`string`,withTimezone:!0}).default(e`NOW()`).notNull(),userAgent:t.text(`user_agent`),userId:t.text(`user_id`).notNull().references(()=>l.id,{onDelete:`cascade`})}),e=>[]),c=t(`sso_providers`,t=>({id:t.text(`id`).primaryKey().default(e`uuidv7()`),domain:t.text(`domain`).notNull(),issuer:t.text(`issuer`).notNull(),oidcConfig:t.text(`oidc_config`),organizationId:t.text(`organization_id`).references(()=>o.id,{onDelete:`cascade`}),providerId:t.text(`provider_id`).notNull().unique(),samlConfig:t.text(`saml_config`),userId:t.text(`user_id`).references(()=>l.id,{onDelete:`cascade`})}),e=>[]),l=t(`users`,t=>({id:t.text(`id`).primaryKey().default(e`uuidv7()`),banExpires:t.timestamp(`ban_expires`,{mode:`string`,withTimezone:!0}),banReason:t.text(`ban_reason`),banned:t.boolean(`banned`).default(!1),createdAt:t.timestamp(`created_at`,{mode:`string`,withTimezone:!0}).default(e`NOW()`).notNull(),displayUsername:t.text(`display_username`),email:t.text(`email`).notNull().unique(),emailVerified:t.boolean(`email_verified`).default(!1).notNull(),image:t.text(`image`),isAnonymous:t.boolean(`is_anonymous`),lastLoginMethod:t.text(`last_login_method`),name:t.text(`name`).notNull(),phoneNumber:t.text(`phone_number`).unique(),phoneNumberVerified:t.boolean(`phone_number_verified`),role:t.text(`role`),twoFactorEnabled:t.boolean(`two_factor_enabled`).default(!1),updatedAt:t.timestamp(`updated_at`,{mode:`string`,withTimezone:!0}).default(e`NOW()`).notNull(),username:t.text(`username`).unique()}),e=>[]),u=t(`teams`,t=>({id:t.text(`id`).primaryKey().default(e`uuidv7()`),name:t.text(`name`).notNull(),organizationId:t.text(`organization_id`).notNull().references(()=>o.id,{onDelete:`cascade`}),createdAt:t.timestamp(`created_at`,{mode:`string`,withTimezone:!0}).default(e`NOW()`).notNull(),updatedAt:t.timestamp(`updated_at`,{mode:`string`,withTimezone:!0}).default(e`NOW()`).notNull()}),e=>[]),d=t(`team_members`,t=>({id:t.text(`id`).primaryKey().default(e`uuidv7()`),teamId:t.text(`team_id`).notNull().references(()=>u.id,{onDelete:`cascade`}),userId:t.text(`user_id`).notNull().references(()=>l.id,{onDelete:`cascade`}),createdAt:t.timestamp(`created_at`,{mode:`string`,withTimezone:!0}).default(e`NOW()`).notNull()}),e=>[]),f=t(`two_factors`,t=>({id:t.text(`id`).primaryKey().default(e`uuidv7()`),secret:t.text(`secret`).notNull(),backupCodes:t.text(`backup_codes`).notNull(),userId:t.text(`user_id`).notNull().references(()=>l.id,{onDelete:`cascade`})}),e=>[]),p=t(`verifications`,t=>({id:t.text(`id`).primaryKey().default(e`uuidv7()`),createdAt:t.timestamp(`created_at`,{mode:`string`,withTimezone:!0}).default(e`NOW()`).notNull(),expiresAt:t.timestamp(`expires_at`,{mode:`string`,withTimezone:!0}).notNull(),identifier:t.text(`identifier`).notNull(),updatedAt:t.timestamp(`updated_at`,{mode:`string`,withTimezone:!0}).default(e`NOW()`).notNull(),value:t.text(`value`).notNull()}),e=>[]);return{tables:{accounts:n,apiKeys:r,auditLogs:t(`audit_logs`,t=>({id:t.text(`id`).primaryKey().default(e`uuidv7()`),tableName:t.text(`table_name`),action:t.text(`action`).notNull(),customAction:t.text(`custom_action`),oldData:t.jsonb(`old_data`),newData:t.jsonb(`new_data`),metadata:t.jsonb(`metadata`),organizationId:t.text(`organization_id`).references(()=>o.id,{onDelete:`set null`}),userId:t.text(`user_id`).references(()=>l.id,{onDelete:`set null`}),sessionId:t.text(`session_id`).references(()=>s.id,{onDelete:`set null`}),requestId:t.text(`request_id`),createdAt:t.timestamp(`created_at`,{mode:`string`,withTimezone:!0}).default(e`NOW()`).notNull()}),e=>[]),invitations:i,members:a,organizations:o,sessions:s,ssoProviders:c,teams:u,teamMembers:d,twoFactors:f,users:l,verifications:p},relations:e=>({users:{sessions:e.many.sessions({from:e.users.id,to:e.sessions.userId}),accounts:e.many.accounts({from:e.users.id,to:e.accounts.userId}),apiKeys:e.many.apiKeys({from:e.users.id,to:e.apiKeys.userId}),memberships:e.many.members({from:e.users.id,to:e.members.userId}),invitations:e.many.invitations({from:e.users.id,to:e.invitations.inviterId}),ssoProvider:e.one.ssoProviders({from:e.users.id,to:e.ssoProviders.userId}),twoFactor:e.one.twoFactors({from:e.users.id,to:e.twoFactors.userId})},sessions:{user:e.one.users({from:e.sessions.userId,to:e.users.id})},accounts:{user:e.one.users({from:e.accounts.userId,to:e.users.id})},apiKeys:{user:e.one.users({from:e.apiKeys.userId,to:e.users.id})},organizations:{members:e.many.members({from:e.organizations.id,to:e.members.organizationId}),invitations:e.many.invitations({from:e.organizations.id,to:e.invitations.organizationId}),teams:e.many.teams({from:e.organizations.id,to:e.teams.organizationId})},members:{organization:e.one.organizations({from:e.members.organizationId,to:e.organizations.id}),user:e.one.users({from:e.members.userId,to:e.users.id})},invitations:{organization:e.one.organizations({from:e.invitations.organizationId,to:e.organizations.id}),inviter:e.one.users({from:e.invitations.inviterId,to:e.users.id})},teams:{organization:e.one.organizations({from:e.teams.organizationId,to:e.organizations.id})},ssoProviders:{user:e.one.users({from:e.ssoProviders.userId,to:e.users.id})},verifications:{},twoFactors:{user:e.one.users({from:e.twoFactors.userId,to:e.users.id})},auditLogs:{organization:e.one.organizations({from:e.auditLogs.organizationId,to:e.organizations.id}),user:e.one.users({from:e.auditLogs.userId,to:e.users.id}),session:e.one.sessions({from:e.auditLogs.sessionId,to:e.sessions.id})}})}}export{n as t};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import{G as e,o as t,u as n}from"./sql-D-eKV1Dn.mjs";import{c as r,dr as i,l as a}from"./query-builder-V8-LDhvA.mjs";import{n as o,t as s}from"./logger-BAGZLUzj.mjs";import{t as c}from"./cache-3oO07miM.mjs";import{i as l,n as u,o as d,r as f,t as p}from"./session-CdB1A-LB.mjs";import m from"better-sqlite3";var h=class extends u{constructor(e,t,n,r,i={}){super(t),this.client=e,this.relations=n,this.schema=r,this.logger=i.logger??new o,this.cache=i.cache??new c}static[e]=`BetterSQLiteSession`;logger;cache;prepareQuery(e,t,n,r,i,a,o){return new _(this.client.prepare(e.sql),e,this.logger,this.cache,a,o,t,n,r,i)}prepareRelationalQuery(e,t,n,r){return new _(this.client.prepare(e.sql),e,this.logger,this.cache,void 0,void 0,t,n,!1,r,!0)}transaction(e,t={}){let n=new g(`sync`,this.dialect,this,this.relations,this.schema);return this.client.transaction(e)[t.behavior??`deferred`](n)}},g=class t extends f{static[e]=`BetterSQLiteTransaction`;transaction(e){let r=`sp${this.nestedIndex}`,i=new t(`sync`,this.dialect,this.session,this.relations,this.schema,this.nestedIndex+1);this.session.run(n.raw(`savepoint ${r}`));try{let t=e(i);return this.session.run(n.raw(`release savepoint ${r}`)),t}catch(e){throw this.session.run(n.raw(`rollback to savepoint ${r}`)),e}}},_=class extends p{constructor(e,t,n,r,i,a,o,s,c,l,u){super(`sync`,s,t,r,i,a),this.stmt=e,this.logger=n,this.fields=o,this._isResponseInArrayMode=c,this.customResultMapper=l,this.isRqbV2Query=u}static[e]=`BetterSQLitePreparedQuery`;run(e){let n=t(this.query.params,e??{});return this.logger.logQuery(this.query.sql,n),this.stmt.run(...n)}all(e){if(this.isRqbV2Query)return this.allRqbV2(e);let{fields:n,joinsNotNullableMap:r,query:a,logger:o,stmt:s,customResultMapper:c}=this;if(!n&&!c){let n=t(a.params,e??{});return o.logQuery(a.sql,n),s.all(...n)}let l=this.values(e);return c?c(l):l.map(e=>i(n,e,r))}get(e){if(this.isRqbV2Query)return this.getRqbV2(e);let n=t(this.query.params,e??{});this.logger.logQuery(this.query.sql,n);let{fields:r,stmt:a,joinsNotNullableMap:o,customResultMapper:s}=this;if(!r&&!s)return a.get(...n);let c=a.raw().get(...n);if(c)return s?s([c]):i(r,c,o)}allRqbV2(e){let{query:n,logger:r,stmt:i,customResultMapper:a}=this,o=t(n.params,e??{});return r.logQuery(n.sql,o),a(i.all(...o))}getRqbV2(e){let n=t(this.query.params,e??{});this.logger.logQuery(this.query.sql,n);let{stmt:r,customResultMapper:i}=this,a=r.get(...n);return a===void 0?a:i([a])}values(e){let n=t(this.query.params,e??{});return this.logger.logQuery(this.query.sql,n),this.stmt.raw().all(...n)}isResponseInArrayMode(){return this._isResponseInArrayMode}},v=class extends l{static[e]=`BetterSQLite3Database`};function y(e,t={}){let n=new d({casing:t.casing}),i;t.logger===!0?i=new s:t.logger!==!1&&(i=t.logger);let o;if(t.schema){let e=a(t.schema,r);o={fullSchema:t.schema,schema:e.tables,tableNamesMap:e.tableNamesMap}}let c=t.relations??{},l=new v(`sync`,n,new h(e,n,c,o,{logger:i}),c,o);return l.$client=e,l}function b(...e){if(e[0]===void 0||typeof e[0]==`string`)return y(e[0]===void 0?new m:new m(e[0]),e[1]);let{connection:t,client:n,...r}=e[0];if(n)return y(n,r);if(typeof t==`object`){let{source:e,...n}=t;return y(new m(e,n),r)}return y(new m(t),r)}(e=>{function t(e){return y({},e)}e.mock=t})(b||={});export{b as drizzle};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import{G as e,K as t,W as n,f as r,o as i}from"./sql-D-eKV1Dn.mjs";import{c as a,dr as o,l as s,n as c}from"./query-builder-V8-LDhvA.mjs";import{n as l,t as u}from"./logger-BAGZLUzj.mjs";import{t as d}from"./cache-3oO07miM.mjs";import{a as f,i as p,n as m,r as h,t as g}from"./session-Cl2e-_i8.mjs";import{L as _,n as v,r as y,t as b,x}from"./pg-core-BLTZt9AH.mjs";import{a as S,i as C,n as w,r as T,t as E}from"./session-CdB1A-LB.mjs";import{SQL as D}from"bun";var O=class extends g{constructor(e,t,n,r,i,a,o,s,c,l,u,d){super(i,a,o),this.client=e,this.query=t,this.params=n,this.logger=r,this.fields=s,this.customResultMapper=c,this.generatedIds=l,this.returningIds=u,this.isRqbV2Query=d}static[e]=`BunMySqlPreparedQuery`;async execute(e={}){if(this.isRqbV2Query)return this.executeRqbV2(e);let{fields:r,client:a,logger:s,params:c,query:l,joinsNotNullableMap:u,customResultMapper:d,returningIds:f,generatedIds:p}=this,m=i(c,e);if(s.logQuery(l,m),!r&&!d){let e=await this.queryWithCache(l,m,async()=>await a.unsafe(l,m)),r=e.lastInsertRowid,i=e.affectedRows;if(f){let e=[],a=0;for(let o=r;o<r+i;o++){for(let r of f){let i=f[0].path[0];t(r.field,n)&&(r.field.primary&&r.field.autoIncrement&&e.push({[i]:o}),r.field.defaultFn&&p&&e.push({[i]:p[a][i]}))}a++}return e}return e}let h=await this.queryWithCache(l,m,async()=>await a.unsafe(l,m).values());return d?d(h):h.map(e=>o(r,e,u))}async executeRqbV2(e={}){let t=i(this.params,e);this.logger.logQuery(this.query,t);let{client:n,query:r,customResultMapper:a}=this;return a(await n.unsafe(r,t))}async*iterator(e={}){let{fields:t,params:n,query:r,joinsNotNullableMap:a,client:s,customResultMapper:c}=this,l=i(n,e),u=await this.queryWithCache(r,l,async()=>await s.unsafe(r,l).values()),d=!!(t||c);for(let e of u){if(e===void 0||Array.isArray(e)&&e.length===0)break;if(d)if(c){let t=c([e]);yield Array.isArray(t)?t[0]:t}else yield o(t,e,a);else yield e}}},k=class t extends m{constructor(e,t,n,r,i){super(t),this.client=e,this.relations=n,this.schema=r,this.options=i,this.logger=i.logger??new l,this.cache=i.cache??new d,this.mode=i.mode}static[e]=`BunMySqlSession`;logger;mode;cache;prepareQuery(e,t,n,r,i,a,o){return new O(this.client,e.sql,e.params,this.logger,this.cache,a,o,t,n,r,i)}prepareRelationalQuery(e,t,n,r,i){return new O(this.client,e.sql,e.params,this.logger,this.cache,void 0,void 0,t,n,r,i,!0)}async query(e,t){return this.logger.logQuery(e,t),await this.client.unsafe(e,t)}all(e){let t=this.dialect.sqlToQuery(e);return this.logger.logQuery(t.sql,t.params),this.client.unsafe(t.sql,t.params)}async count(e){let t=this.dialect.sqlToQuery(e),n=(await this.client.unsafe(t.sql,t.params).values())[0][0];return typeof n==`number`?n:Number(n)}async transaction(e,n){let r=n?this.getStartTransactionSQL(n)?.inlineParams().toQuery(this.dialect).sql.slice(18)??``:``;if(n?.isolationLevel)throw Error(`Driver doesn't support setting isolation level on transaction`);return this.client.begin(r,async n=>{let r=new t(n,this.dialect,this.relations,this.schema,this.options);return e(new A(this.dialect,r,this.relations,this.schema,0,this.mode))})}},A=class t extends h{static[e]=`BunMySqlTransaction`;async transaction(e){return this.session.client.savepoint(n=>{let r=new k(n,this.dialect,this.relations,this.schema,this.session.options);return e(new t(this.dialect,r,this.relations,this.schema,this.nestedIndex+1,this.mode))})}},j=class extends p{static[e]=`BunMySqlDatabase`};function M(e,t={}){let n=new f({casing:t.casing}),r;t.logger===!0?r=new u:t.logger!==!1&&(r=t.logger);let i;if(t.schema){if(t.mode===void 0)throw new c({message:`You need to specify "mode": "planetscale" or "default" when providing a schema. Read more: https://orm.drizzle.team/docs/rqb#modes`});let e=s(t.schema,a);i={fullSchema:t.schema,schema:e.tables,tableNamesMap:e.tableNamesMap}}let o=t.mode??`default`,l=t.relations??{},d=new j(n,new k(e,n,l,i,{logger:r,mode:o,cache:t.cache}),l,i,o);return d.$client=e,d.$cache=t.cache,d.$cache&&(d.$cache.invalidate=t.cache?.onMutate),d}function N(...e){if(typeof e[0]==`string`)return M(new D(e[0]),e[1]);let{connection:t,client:n,...r}=e[0];if(n)return M(n,r);if(typeof t==`object`&&t.url!==void 0){let{url:e,...n}=t;return M(new D({url:e,...n}),r)}return M(new D(t),r)}(e=>{function t(e){return M({options:{parsers:{},serializers:{}}},e)}e.mock=t})(N||={});var P=class extends b{constructor(e,t,n,r,i,a,o,s,c,l,u){super({sql:t,params:n},i,a,o),this.client=e,this.queryString=t,this.params=n,this.logger=r,this.fields=s,this._isResponseInArrayMode=c,this.customResultMapper=l,this.isRqbV2Query=u}static[e]=`BunSQLPreparedQuery`;async execute(e={}){return this.isRqbV2Query?this.executeRqbV2(e):r.startActiveSpan(`drizzle.execute`,async t=>{let n=i(this.params,e);t?.setAttributes({"drizzle.query.text":this.queryString,"drizzle.query.params":JSON.stringify(n)}),this.logger.logQuery(this.queryString,n);let{fields:a,queryString:s,client:c,joinsNotNullableMap:l,customResultMapper:u}=this;if(!a&&!u)return r.startActiveSpan(`drizzle.driver.execute`,async()=>await this.queryWithCache(s,n,async()=>await c.unsafe(s,n)));let d=await r.startActiveSpan(`drizzle.driver.execute`,async()=>(t?.setAttributes({"drizzle.query.text":s,"drizzle.query.params":JSON.stringify(n)}),await this.queryWithCache(s,n,async()=>c.unsafe(s,n).values())));return r.startActiveSpan(`drizzle.mapResponse`,()=>u?u(d):d.map(e=>o(a,e,l)))})}async executeRqbV2(e={}){return r.startActiveSpan(`drizzle.execute`,async t=>{let n=i(this.params,e);t?.setAttributes({"drizzle.query.text":this.queryString,"drizzle.query.params":JSON.stringify(n)}),this.logger.logQuery(this.queryString,n);let{queryString:a,client:o,customResultMapper:s}=this,c=await r.startActiveSpan(`drizzle.driver.execute`,()=>(t?.setAttributes({"drizzle.query.text":a,"drizzle.query.params":JSON.stringify(n)}),o.unsafe(a,n)));return r.startActiveSpan(`drizzle.mapResponse`,()=>s(c))})}all(e={}){return r.startActiveSpan(`drizzle.execute`,async t=>{let n=i(this.params,e);return t?.setAttributes({"drizzle.query.text":this.queryString,"drizzle.query.params":JSON.stringify(n)}),this.logger.logQuery(this.queryString,n),r.startActiveSpan(`drizzle.driver.execute`,async()=>(t?.setAttributes({"drizzle.query.text":this.queryString,"drizzle.query.params":JSON.stringify(n)}),await this.queryWithCache(this.queryString,n,async()=>await this.client.unsafe(this.queryString,n))))})}isResponseInArrayMode(){return this._isResponseInArrayMode}},F=class t extends v{constructor(e,t,n,r,i={}){super(t),this.client=e,this.relations=n,this.schema=r,this.options=i,this.logger=i.logger??new l,this.cache=i.cache??new d}static[e]=`BunSQLSession`;logger;cache;prepareQuery(e,t,n,r,i,a,o){return new P(this.client,e.sql,e.params,this.logger,this.cache,a,o,t,r,i)}prepareRelationalQuery(e,t,n,r){return new P(this.client,e.sql,e.params,this.logger,this.cache,void 0,void 0,t,!0,r,!0)}query(e,t){return this.logger.logQuery(e,t),this.client.unsafe(e,t).values()}queryObjects(e,t){return this.client.unsafe(e,t)}transaction(e,n){return this.client.begin(async r=>{let i=new t(r,this.dialect,this.relations,this.schema,this.options),a=new I(this.dialect,i,this.relations,this.schema);return n&&await a.setTransaction(n),e(a)})}},I=class t extends y{constructor(e,t,n,r,i=0){super(e,t,n,r,i),this.session=t}static[e]=`BunSQLTransaction`;transaction(e){return this.session.client.savepoint(n=>{let r=new F(n,this.dialect,this.relations,this.schema,this.session.options);return e(new t(this.dialect,r,this.relations,this.schema))})}},L=class extends x{static[e]=`BunSQLDatabase`};function R(e,t={}){let n=new _({casing:t.casing}),r;t.logger===!0?r=new u:t.logger!==!1&&(r=t.logger);let i;if(t.schema){let e=s(t.schema,a);i={fullSchema:t.schema,schema:e.tables,tableNamesMap:e.tableNamesMap}}let o=t.relations??{},c=new L(n,new F(e,n,o,i,{logger:r,cache:t.cache}),o,i);return c.$client=e,c.$cache=t.cache,c.$cache&&(c.$cache.invalidate=t.cache?.onMutate),c}function z(...e){if(typeof e[0]==`string`)return R(new D(e[0]),e[1]);let{connection:t,client:n,...r}=e[0];if(n)return R(n,r);if(typeof t==`object`&&t.url!==void 0){let{url:e,...n}=t;return R(new D({url:e,...n}),r)}return R(new D(t),r)}(e=>{function t(e){return R({options:{parsers:{},serializers:{}}},e)}e.mock=t})(z||={});var B=class t extends w{constructor(e,t,n,r,i){super(t),this.client=e,this.relations=n,this.schema=r,this.options=i,this.logger=i.logger??new l,this.cache=i.cache??new d}static[e]=`BunSQLiteSession`;logger;cache;prepareQuery(e,t,n,r,i,a,o){return new H(this.client,e,this.logger,this.cache,a,o,t,n,r,i)}prepareRelationalQuery(e,t,n,r){return new H(this.client,e,this.logger,this.cache,void 0,void 0,t,n,!1,r,!0)}async run(e){let t=this.dialect.sqlToQuery(e);try{return await this.prepareOneTimeQuery(t,void 0,`run`,!1).run()}catch(e){throw new c({cause:e,message:`Failed to run the query '${t.sql}'`})}}async transaction(e,n){return this.client.begin(n?.behavior??``,async n=>{let r=new t(n,this.dialect,this.relations,this.schema,this.options);return await e(new V(`async`,this.dialect,r,this.relations,this.schema))})}},V=class t extends T{static[e]=`BunSQLiteTransaction`;async transaction(e){return this.session.client.savepoint(async n=>{let r=new B(n,this.session.dialect,this.relations,this.schema,this.session.options);return await e(new t(`async`,this.dialect,r,this.relations,this.schema,this.nestedIndex+1))})}},H=class extends E{constructor(e,t,n,r,i,a,o,s,c,l,u){super(`async`,s,t,r,i,a),this.client=e,this.logger=n,this.fields=o,this._isResponseInArrayMode=c,this.customResultMapper=l,this.isRqbV2Query=u}static[e]=`BunSQLitePreparedQuery`;async run(e={}){let{logger:t,query:n,client:r}=this,a=i(n.params,e);return t.logQuery(n.sql,a),await this.queryWithCache(n.sql,a,async()=>await r.unsafe(n.sql,a))}async all(e={}){if(this.isRqbV2Query)return this.allRqbV2(e);let{logger:t,query:n,fields:r,joinsNotNullableMap:a,customResultMapper:s,client:c}=this;if(!r&&!s){let r=i(n.params,e);return t.logQuery(n.sql,r),await this.queryWithCache(n.sql,r,async()=>await c.unsafe(n.sql,r))}let l=await this.values(e);return s?s(l):l.map(e=>o(r,e,a))}async allRqbV2(e={}){let{logger:t,query:n,customResultMapper:r,client:a}=this,o=i(n.params,e);return t.logQuery(n.sql,o),r(await a.unsafe(n.sql,o))}async get(e={}){if(this.isRqbV2Query)return this.getRqbV2(e);let{logger:t,query:n,fields:r,joinsNotNullableMap:a,customResultMapper:s,client:c}=this;if(!r&&!s){let r=i(n.params,e);return t.logQuery(n.sql,r),await this.queryWithCache(n.sql,r,async()=>(await c.unsafe(n.sql,r))[0])}let l=await this.values(e),u=l[0];return s?s(l):u===void 0?u:o(r,u,a)}async getRqbV2(e={}){let{logger:t,query:n,customResultMapper:r,client:a}=this,o=i(n.params,e);t.logQuery(n.sql,o);let s=(await a.unsafe(n.sql,o))[0];return s===void 0?s:r([s])}async values(e={}){let{client:t,logger:n,query:r}=this,a=i(r.params,e);return n.logQuery(r.sql,a),await this.queryWithCache(r.sql,a,async()=>await t.unsafe(r.sql,a).values())}isResponseInArrayMode(){return this._isResponseInArrayMode}},U=class extends C{static[e]=`BunSQLiteDatabase`};function W(e,t={}){let n=new S({casing:t.casing}),r;t.logger===!0?r=new u:t.logger!==!1&&(r=t.logger);let i;if(t.schema){let e=s(t.schema,a);i={fullSchema:t.schema,schema:e.tables,tableNamesMap:e.tableNamesMap}}let o=t.relations??{},c=new U(`async`,n,new B(e,n,o,i,{logger:r,cache:t.cache}),o,i);return c.$client=e,c.$cache=t.cache,c.$cache&&(c.$cache.invalidate=t.cache?.onMutate),c}function G(...e){if(typeof e[0]==`string`)return W(new D(e[0]),e[1]);let{connection:t,client:n,...r}=e[0];if(n)return W(n,r);if(typeof t==`object`&&t.url!==void 0){let{url:e,...n}=t;return W(new D({url:e,...n}),r)}return W(new D(t),r)}(e=>{function t(e){return W({options:{parsers:{},serializers:{}}},e)}e.mock=t})(G||={});function K(...e){return z(...e)}(e=>{function t(e){return z.mock(e)}e.mock=t;function n(...e){return z(...e)}e.postgres=n,(e=>{function t(e){return z.mock(e)}e.mock=t})(n=e.postgres||={});function r(...e){return G(...e)}e.sqlite=r,(e=>{function t(e){return G.mock(e)}e.mock=t})(r=e.sqlite||={});function i(...e){return N(...e)}e.mysql=i,(e=>{function t(e){return N.mock(e)}e.mock=t})(i=e.mysql||={})})(K||={});export{K as drizzle};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import{B as e,G as t,I as n,K as r,L as i,R as a,W as o,a as s,l as c,n as l,r as u,u as d,z as f}from"./sql-D-eKV1Dn.mjs";import{A as p,B as m,C as h,D as g,E as _,F as v,I as y,L as b,M as x,N as S,O as C,P as w,R as T,S as E,T as D,_ as O,b as k,g as A,h as j,j as M,k as N,mr as P,n as F,v as I,w as L,x as R,y as z,z as B}from"./query-builder-V8-LDhvA.mjs";var V=class{constructor(e,t){this.targetTableName=t,this.targetTable=e}static[t]=`RelationV2`;fieldName;sourceColumns;targetColumns;alias;where;sourceTable;targetTable;through;throughTable;isReversed;sourceColumnTableNames=[];targetColumnTableNames=[]},H=class extends V{static[t]=`OneV2`;relationType=`one`;optional;constructor(e,t,n,r){super(t,n),this.alias=r?.alias,this.where=r?.where,r?.from&&(this.sourceColumns=(Array.isArray(r.from)?r.from:[r.from]).map(t=>(this.throughTable??=t._.through?e[t._.through._.tableName]:void 0,this.sourceColumnTableNames.push(t._.tableName),t._.column))),r?.to&&(this.targetColumns=(Array.isArray(r.to)?r.to:[r.to]).map(t=>(this.throughTable??=t._.through?e[t._.through._.tableName]:void 0,this.targetColumnTableNames.push(t._.tableName),t._.column))),this.throughTable&&(this.through={source:(Array.isArray(r?.from)?r.from:r?.from?[r.from]:[]).map(e=>e._.through),target:(Array.isArray(r?.to)?r.to:r?.to?[r.to]:[]).map(e=>e._.through)}),this.optional=r?.optional??!0}};const U={and:O,between:R,eq:E,exists:h,gt:L,gte:D,ilike:_,inArray:g,arrayContains:z,arrayContained:I,arrayOverlaps:k,isNull:N,isNotNull:C,like:p,lt:M,lte:x,ne:S,not:w,notBetween:v,notExists:y,notLike:B,notIlike:b,notInArray:T,or:m,sql:d},W={sql:d,asc:j,desc:A};function G(e,t,n=e=>e,i=!1,l=!1,d){for(let f of t){if(f.selection){let t=`${d?`${d}.`:``}${f.key}`;if(e[f.key]===null||i&&(e[f.key]=JSON.parse(e[f.key]),e[f.key]===null))continue;if(l&&typeof e[f.key]==`string`&&(e[f.key]=JSON.parse(e[f.key])),f.isArray){for(let r of e[f.key])G(r,f.selection,n,!1,l,t);continue}G(e[f.key],f.selection,n,!1,l,t);continue}let t=f.field,p=n(e[f.key]);if(p===null)continue;let m;m=r(t,o)?t:r(t,u)?t.decoder:r(t,u.Aliased)?t.sql.decoder:r(t,a)||r(t,s)?c:t.getSQL().decoder,e[f.key]=`mapFromJsonValue`in m?m.mapFromJsonValue(p):m.mapFromDriverValue(p)}return e}function K(e,t){let n=e[f][t];return n?r(n,o)?n:r(n,u.Aliased)?d`${e}.${d.identifier(n.fieldAlias)}`:d`${e}.${d.identifier(t)}`:d`${e}.${d.identifier(t)}`}function q(e,t){if(typeof t!=`object`||r(t,l))return E(e,t);let n=Object.entries(t);if(!n.length)return;let i=[];for(let[t,r]of n)if(r!==void 0)switch(t){case`NOT`:{let t=q(e,r);if(!t)continue;i.push(w(t));continue}case`OR`:if(!r.length)continue;i.push(m(...r.map(t=>q(e,t))));continue;case`AND`:if(!r.length)continue;i.push(O(...r.map(t=>q(e,t))));continue;case`isNotNull`:case`isNull`:if(!r)continue;i.push(U[t](e));continue;case`in`:i.push(U.inArray(e,r));continue;case`notIn`:i.push(U.notInArray(e,r));continue;default:i.push(U[t](e,r));continue}if(i.length)return O(...i)}function J(e,t,n={},r={},i,a=0){let o=Object.entries(t);if(!o.length)return;let s=[];for(let[t,c]of o)if(c!==void 0)switch(t){case`RAW`:{let t=typeof c==`function`?c(e,U):c.getSQL();s.push(t);continue}case`OR`:if(!c?.length)continue;s.push(m(...c.map(t=>J(e,t,n,r,i,a))));continue;case`AND`:if(!c?.length)continue;s.push(O(...c.map(t=>J(e,t,n,r,i,a))));continue;case`NOT`:{if(c===void 0)continue;let t=J(e,c,n,r,i,a);if(!t)continue;s.push(w(t));continue}default:{if(e[f][t]){let n=q(K(e,t),c);n&&s.push(n);continue}let o=n[t];if(!o)throw new F({message:`Unknown relational filter field: "${t}"`});let l=P(o.targetTable,`f${a}`),u=o.throughTable?P(o.throughTable,`ft${a}`):void 0,p=r[o.targetTableName],{filter:m,joinCondition:g}=Z(i,o,e,l,u),_=O(m,typeof c==`boolean`?void 0:J(l,c,p.relations,r,i,a+1)),v=u?d`(select * from ${Q(l)} inner join ${Q(u)} on ${g}${d` where ${_}`.if(_)} limit 1)`:d`(select * from ${Q(l)}${d` where ${_}`.if(_)} limit 1)`;_&&s.push((c?h:y)(v))}}return O(...s)}function Y(e,t){if(typeof t==`function`){let n=t(e,W);return r(n,u)?n:Array.isArray(n)?n.length?d.join(n.map(e=>r(e,u)?e:j(e)),d`, `):void 0:r(n,o)?j(n):void 0}let n=Object.entries(t).filter(([e,t])=>t);if(n.length)return d.join(n.map(([t,n])=>(n===`asc`?j:A)(K(e,t))),d`, `)}function X(e,t){let n=[],r=[];for(let[i,a]of Object.entries(t)){if(!a)continue;let t=typeof a==`function`?a(e,{sql:U.sql}):a,o=d`(${t.getSQL()}) as ${d.identifier(i)}`;o.decoder=t.getSQL().decoder,n.push(o),r.push({key:i,field:o})}return{sql:n.length?d.join(n,d`, `):void 0,selection:r}}function Z(e,t,n,i,a){if(t.through){let s=t.sourceColumns.map((i,s)=>{let c=t.through.source[s];return E(d`${n}.${d.identifier(e.getColumnCasing(i))}`,d`${a}.${d.identifier(r(c._.column,o)?e.getColumnCasing(c._.column):c._.key)}`)}),c=t.targetColumns.map((n,s)=>{let c=t.through.target[s];return E(d`${a}.${d.identifier(r(c._.column,o)?e.getColumnCasing(c._.column):c._.key)}`,d`${i}.${d.identifier(e.getColumnCasing(n))}`)});return{filter:O(t.where?J(t.isReversed?n:i,t.where):void 0,...s),joinCondition:O(...c)}}return{filter:O(...t.sourceColumns.map((r,a)=>{let o=t.targetColumns[a];return E(d`${n}.${d.identifier(e.getColumnCasing(r))}`,d`${i}.${d.identifier(e.getColumnCasing(o))}`)}),t.where?J(t.isReversed?n:i,t.where):void 0)}}function Q(t){return d`${t[n]?d`${d`${d.identifier(t[e]??``)}.`.if(t[e])}${d.identifier(t[i])} as ${t}`:t}`}var $=class{static[t]=`Cache`},ee=class extends ${strategy(){return`all`}static[t]=`NoopCache`;async get(e){}async put(e,t,n,r){}async onMutate(e){}};async function te(e,t){let n=`${e}-${JSON.stringify(t)}`,r=new TextEncoder().encode(n),i=await crypto.subtle.digest(`SHA-256`,r);return[...new Uint8Array(i)].map(e=>e.toString(16).padStart(2,`0`)).join(``)}export{G as a,J as c,Q as i,Y as l,te as n,X as o,H as r,Z as s,ee as t};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import{createRequire as e}from"node:module";var t=Object.create,n=Object.defineProperty,r=Object.getOwnPropertyDescriptor,i=Object.getOwnPropertyNames,a=Object.getPrototypeOf,o=Object.prototype.hasOwnProperty,s=(e,t)=>()=>(e&&(t=e(e=0)),t),c=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),l=(e,t)=>{let r={};for(var i in e)n(r,i,{get:e[i],enumerable:!0});return t&&n(r,Symbol.toStringTag,{value:`Module`}),r},u=(e,t,a,s)=>{if(t&&typeof t==`object`||typeof t==`function`)for(var c=i(t),l=0,u=c.length,d;l<u;l++)d=c[l],!o.call(e,d)&&d!==a&&n(e,d,{get:(e=>t[e]).bind(null,d),enumerable:!(s=r(t,d))||s.enumerable});return e},d=(e,t,n)=>(u(e,t,`default`),n&&u(n,t,`default`)),f=(e,r,i)=>(i=e==null?{}:t(a(e)),u(r||!e||!e.__esModule?n(i,`default`,{value:e,enumerable:!0}):i,e)),p=e=>o.call(e,`module.exports`)?e[`module.exports`]:u(n({},`__esModule`,{value:!0}),e),m=e=>t=>f(t.default,e),h=e(import.meta.url);export{h as a,f as c,d as i,s as n,p as o,l as r,m as s,c as t};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import{G as e,K as t,R as n,V as r,d as i,f as a,h as o,m as s,o as c,r as l,t as u,u as d,z as f}from"./sql-D-eKV1Dn.mjs";import{c as p,cr as m,dr as h,f as g,fr as _,i as v,ir as y,l as b,lr as x,pr as S,rr as C}from"./query-builder-V8-LDhvA.mjs";import{a as w,n as T,r as E,t as D}from"./query-builder-DSRrR6X_.mjs";import{n as O,t as k}from"./logger-BAGZLUzj.mjs";import{t as A}from"./esm-CGKzJ7Am.mjs";var j=class extends y{constructor(e,t,n,r){super(),this.session=t,this.dialect=n,this.config={table:e,withList:r}}static[e]=`CockroachDelete`;config;where(e){return this.config.where=e,this}returning(e=this.config.table[n.Symbol.Columns]){return this.config.returningFields=e,this.config.returning=S(e),this}getSQL(){return this.dialect.buildDeleteQuery(this.config)}toSQL(){let{typings:e,...t}=this.dialect.sqlToQuery(this.getSQL());return t}_prepare(e){return a.startActiveSpan(`drizzle.prepareQuery`,()=>this.session.prepareQuery(this.dialect.sqlToQuery(this.getSQL()),this.config.returning,e,!0))}prepare(e){return this._prepare(e)}authToken;setToken(e){return this.authToken=e,this}execute=e=>a.startActiveSpan(`drizzle.operation`,()=>this._prepare().execute(e,this.authToken));getSelectedFields(){return this.config.returningFields?new Proxy(this.config.returningFields,new C({alias:r(this.config.table),sqlAliasedBehavior:`alias`,sqlBehavior:`error`})):void 0}$dynamic(){return this}},M=class{constructor(e,t,n,r){this.table=e,this.session=t,this.dialect=n,this.withList=r}static[e]=`CockroachInsertBuilder`;values(e){if(e=Array.isArray(e)?e:[e],e.length===0)throw Error(`values() must be called with at least one value`);let r=e.map(e=>{let r={},i=this.table[n.Symbol.Columns];for(let n of Object.keys(e)){let a=e[n];r[n]=t(a,l)?a:new u(a,i[n])}return r});return new N(this.table,r,this.session,this.dialect,this.withList,!1)}select(e){let n=typeof e==`function`?e(new D):e;if(!t(n,l)&&!x(this.table[f],n._.selectedFields))throw Error(`Insert select error: selected fields are not the same or are in a different order compared to the table definition`);return new N(this.table,n,this.session,this.dialect,this.withList,!0)}},N=class extends y{constructor(e,t,n,r,i,a){super(),this.session=n,this.dialect=r,this.config={table:e,values:t,withList:i,select:a}}static[e]=`CockroachInsert`;config;returning(e=this.config.table[n.Symbol.Columns]){return this.config.returningFields=e,this.config.returning=S(e),this}onConflictDoNothing(e={}){if(e.target===void 0)this.config.onConflict=d`do nothing`;else{let t=``;t=Array.isArray(e.target)?e.target.map(e=>this.dialect.escapeName(this.dialect.casing.getColumnCasing(e))).join(`,`):this.dialect.escapeName(this.dialect.casing.getColumnCasing(e.target));let n=e.where?d` where ${e.where}`:void 0;this.config.onConflict=d`(${d.raw(t)})${n} do nothing`}return this}onConflictDoUpdate(e){if(e.where&&(e.targetWhere||e.setWhere))throw Error(`You cannot use both "where" and "targetWhere"/"setWhere" at the same time - "where" is deprecated, use "targetWhere" or "setWhere" instead.`);let t=e.where?d` where ${e.where}`:void 0,n=e.targetWhere?d` where ${e.targetWhere}`:void 0,r=e.setWhere?d` where ${e.setWhere}`:void 0,i=this.dialect.buildUpdateSet(this.config.table,_(this.config.table,e.set)),a=``;return a=Array.isArray(e.target)?e.target.map(e=>this.dialect.escapeName(this.dialect.casing.getColumnCasing(e))).join(`,`):this.dialect.escapeName(this.dialect.casing.getColumnCasing(e.target)),this.config.onConflict=d`(${d.raw(a)})${n} do update set ${i}${t}${r}`,this}getSQL(){return this.dialect.buildInsertQuery(this.config)}toSQL(){let{typings:e,...t}=this.dialect.sqlToQuery(this.getSQL());return t}_prepare(e){return a.startActiveSpan(`drizzle.prepareQuery`,()=>this.session.prepareQuery(this.dialect.sqlToQuery(this.getSQL()),this.config.returning,e,!0))}prepare(e){return this._prepare(e)}authToken;setToken(e){return this.authToken=e,this}execute=e=>a.startActiveSpan(`drizzle.operation`,()=>this._prepare().execute(e,this.authToken));getSelectedFields(){return this.config.returningFields?new Proxy(this.config.returningFields,new C({alias:r(this.config.table),sqlAliasedBehavior:`alias`,sqlBehavior:`error`})):void 0}$dynamic(){return this}},P=class extends y{constructor(e,t,n){super(),this.session=t,this.dialect=n,this.config={view:e}}static[e]=`CockroachRefreshMaterializedView`;config;concurrently(){if(this.config.withNoData!==void 0)throw Error(`Cannot use concurrently and withNoData together`);return this.config.concurrently=!0,this}withNoData(){if(this.config.concurrently!==void 0)throw Error(`Cannot use concurrently and withNoData together`);return this.config.withNoData=!0,this}getSQL(){return this.dialect.buildRefreshMaterializedViewQuery(this.config)}toSQL(){let{typings:e,...t}=this.dialect.sqlToQuery(this.getSQL());return t}_prepare(e){return a.startActiveSpan(`drizzle.prepareQuery`,()=>this.session.prepareQuery(this.dialect.sqlToQuery(this.getSQL()),void 0,e,!0))}prepare(e){return this._prepare(e)}authToken;setToken(e){return this.authToken=e,this}execute=e=>a.startActiveSpan(`drizzle.operation`,()=>this._prepare().execute(e,this.authToken))},F=class{constructor(e,t,n,r){this.table=e,this.session=t,this.dialect=n,this.withList=r}static[e]=`CockroachUpdateBuilder`;set(e){return new I(this.table,_(this.table,e),this.session,this.dialect,this.withList)}},I=class extends y{constructor(e,t,n,r,i){super(),this.session=n,this.dialect=r,this.config={set:t,table:e,withList:i,joins:[]},this.tableName=m(e),this.joinsNotNullableMap=typeof this.tableName==`string`?{[this.tableName]:!0}:{}}static[e]=`CockroachUpdate`;config;tableName;joinsNotNullableMap;from(e){let t=e,n=m(t);return typeof n==`string`&&(this.joinsNotNullableMap[n]=!0),this.config.from=t,this}getTableLikeFields(e){return t(e,w)?e[n.Symbol.Columns]:t(e,s)?e._.selectedFields:e[i].selectedFields}createJoin(e){return((r,i)=>{let a=m(r);if(typeof a==`string`&&this.config.joins.some(e=>e.alias===a))throw Error(`Alias "${a}" is already used in this query`);if(typeof i==`function`){let e=this.config.from&&!t(this.config.from,l)?this.getTableLikeFields(this.config.from):void 0;i=i(new Proxy(this.config.table[n.Symbol.Columns],new C({sqlAliasedBehavior:`sql`,sqlBehavior:`sql`})),e&&new Proxy(e,new C({sqlAliasedBehavior:`sql`,sqlBehavior:`sql`})))}if(this.config.joins.push({on:i,table:r,joinType:e,alias:a}),typeof a==`string`)switch(e){case`left`:this.joinsNotNullableMap[a]=!1;break;case`right`:this.joinsNotNullableMap=Object.fromEntries(Object.entries(this.joinsNotNullableMap).map(([e])=>[e,!1])),this.joinsNotNullableMap[a]=!0;break;case`inner`:this.joinsNotNullableMap[a]=!0;break;case`full`:this.joinsNotNullableMap=Object.fromEntries(Object.entries(this.joinsNotNullableMap).map(([e])=>[e,!1])),this.joinsNotNullableMap[a]=!1;break}return this})}leftJoin=this.createJoin(`left`);rightJoin=this.createJoin(`right`);innerJoin=this.createJoin(`inner`);fullJoin=this.createJoin(`full`);where(e){return this.config.where=e,this}returning(e){if(!e&&(e=Object.assign({},this.config.table[n.Symbol.Columns]),this.config.from)){let n=m(this.config.from);if(typeof n==`string`&&this.config.from&&!t(this.config.from,l)){let t=this.getTableLikeFields(this.config.from);e[n]=t}for(let n of this.config.joins){let r=m(n.table);if(typeof r==`string`&&!t(n.table,l)){let t=this.getTableLikeFields(n.table);e[r]=t}}}return this.config.returningFields=e,this.config.returning=S(e),this}getSQL(){return this.dialect.buildUpdateQuery(this.config)}toSQL(){let{typings:e,...t}=this.dialect.sqlToQuery(this.getSQL());return t}_prepare(e){let t=this.session.prepareQuery(this.dialect.sqlToQuery(this.getSQL()),this.config.returning,e,!0);return t.joinsNotNullableMap=this.joinsNotNullableMap,t}prepare(e){return this._prepare(e)}authToken;setToken(e){return this.authToken=e,this}execute=e=>this._prepare().execute(e,this.authToken);getSelectedFields(){return this.config.returningFields?new Proxy(this.config.returningFields,new C({alias:r(this.config.table),sqlAliasedBehavior:`alias`,sqlBehavior:`error`})):void 0}$dynamic(){return this}},L=class t extends l{constructor(e){super(t.buildEmbeddedCount(e.source,e.filters).queryChunks),this.params=e,this.mapWith(Number),this.session=e.session,this.sql=t.buildCount(e.source,e.filters)}sql;token;static[e]=`CockroachCountBuilder`;[Symbol.toStringTag]=`CockroachCountBuilder`;session;static buildEmbeddedCount(e,t){return d`(select count(*) from ${e}${d.raw(` where `).if(t)}${t})`}static buildCount(e,t){return d`select count(*) as count from ${e}${d.raw(` where `).if(t)}${t};`}setToken(e){return this.token=e,this}then(e,t){return Promise.resolve(this.session.count(this.sql,this.token)).then(e,t)}catch(e){return this.then(void 0,e)}finally(e){return this.then(t=>(e?.(),t),t=>{throw e?.(),t})}},R=class{constructor(e,t,n,r,i,a,o){this.fullSchema=e,this.schema=t,this.tableNamesMap=n,this.table=r,this.tableConfig=i,this.dialect=a,this.session=o}static[e]=`CockroachRelationalQueryBuilder`;findMany(e){return new z(this.fullSchema,this.schema,this.tableNamesMap,this.table,this.tableConfig,this.dialect,this.session,e||{},`many`)}findFirst(e){return new z(this.fullSchema,this.schema,this.tableNamesMap,this.table,this.tableConfig,this.dialect,this.session,e?{...e,limit:1}:{limit:1},`first`)}},z=class extends y{constructor(e,t,n,r,i,a,o,s,c){super(),this.fullSchema=e,this.schema=t,this.tableNamesMap=n,this.table=r,this.tableConfig=i,this.dialect=a,this.session=o,this.config=s,this.mode=c}static[e]=`CockroachRelationalQuery`;_prepare(e){return a.startActiveSpan(`drizzle.prepareQuery`,()=>{let{query:t,builtQuery:n}=this._toSQL();return this.session.prepareQuery(n,void 0,e,!0,(e,n)=>{let r=e.map(e=>g(this.schema,this.tableConfig,e,t.selection,n));return this.mode===`first`?r[0]:r})})}prepare(e){return this._prepare(e)}_getQuery(){return this.dialect.buildRelationalQueryWithoutPK({fullSchema:this.fullSchema,schema:this.schema,tableNamesMap:this.tableNamesMap,table:this.table,tableConfig:this.tableConfig,queryConfig:this.config,tableAlias:this.tableConfig.tsName})}getSQL(){return this._getQuery().sql}_toSQL(){let e=this._getQuery(),{typings:t,...n}=this.dialect.sqlToQuery(e.sql);return{query:e,builtQuery:n}}toSQL(){return this._toSQL().builtQuery}authToken;setToken(e){return this.authToken=e,this}execute(){return a.startActiveSpan(`drizzle.operation`,()=>this._prepare().execute(void 0,this.authToken))}},B=class extends y{constructor(e,t,n,r){super(),this.execute=e,this.sql=t,this.query=n,this.mapBatchResult=r}static[e]=`CockroachRaw`;getSQL(){return this.sql}getQuery(){return this.query}mapResult(e,t){return t?this.mapBatchResult(e):e}_prepare(){return this}isResponseInArrayMode(){return!1}},V=class{constructor(e,t,n){if(this.dialect=e,this.session=t,this._=n?{schema:n.schema,fullSchema:n.fullSchema,tableNamesMap:n.tableNamesMap,session:t}:{schema:void 0,fullSchema:{},tableNamesMap:{},session:t},this._query={},this._.schema)for(let[r,i]of Object.entries(this._.schema))this._query[r]=new R(n.fullSchema,this._.schema,this._.tableNamesMap,n.fullSchema[r],i,e,t)}static[e]=`CockroachDatabase`;_query;$with=(e,t)=>{let n=this;return{as:r=>(typeof r==`function`&&(r=r(new D(n.dialect))),new Proxy(new o(r.getSQL(),t??(`getSelectedFields`in r?r.getSelectedFields()??{}:{}),e,!0),new C({alias:e,sqlAliasedBehavior:`alias`,sqlBehavior:`error`})))}};$count(e,t){return new L({source:e,filters:t,session:this.session})}with(...e){let t=this;function n(n){return new T({fields:n??void 0,session:t.session,dialect:t.dialect,withList:e})}function r(n){return new T({fields:n??void 0,session:t.session,dialect:t.dialect,withList:e,distinct:!0})}function i(n,r){return new T({fields:r??void 0,session:t.session,dialect:t.dialect,withList:e,distinct:{on:n}})}function a(n){return new F(n,t.session,t.dialect,e)}function o(n){return new M(n,t.session,t.dialect,e)}function s(n){return new j(n,t.session,t.dialect,e)}return{select:n,selectDistinct:r,selectDistinctOn:i,update:a,insert:o,delete:s}}select(e){return new T({fields:e??void 0,session:this.session,dialect:this.dialect})}selectDistinct(e){return new T({fields:e??void 0,session:this.session,dialect:this.dialect,distinct:!0})}selectDistinctOn(e,t){return new T({fields:t??void 0,session:this.session,dialect:this.dialect,distinct:{on:e}})}update(e){return new F(e,this.session,this.dialect)}insert(e){return new M(e,this.session,this.dialect)}delete(e){return new j(e,this.session,this.dialect)}refreshMaterializedView(e){return new P(e,this.session,this.dialect)}authToken;execute(e){let t=typeof e==`string`?d.raw(e):e.getSQL(),n=this.dialect.sqlToQuery(t),r=this.session.prepareQuery(n,void 0,void 0,!1);return new B(()=>r.execute(void 0,this.authToken),t,n,e=>r.mapResult(e,!0))}transaction(e,t){return this.session.transaction(e,t)}},H=class{constructor(e){this.query=e}authToken;getQuery(){return this.query}mapResult(e,t){return e}setToken(e){return this.authToken=e,this}static[e]=`CockroachPreparedQuery`;joinsNotNullableMap},U=class{constructor(e){this.dialect=e}static[e]=`CockroachSession`;execute(e,t){return a.startActiveSpan(`drizzle.operation`,()=>a.startActiveSpan(`drizzle.prepareQuery`,()=>this.prepareQuery(this.dialect.sqlToQuery(e),void 0,void 0,!1)).setToken(t).execute(void 0,t))}all(e){return this.prepareQuery(this.dialect.sqlToQuery(e),void 0,void 0,!1).all()}async count(e,t){let n=await this.execute(e,t);return Number(n[0].count)}},W=class extends V{constructor(e,t,n,r=0){super(e,t,n),this.schema=n,this.nestedIndex=r}static[e]=`CockroachTransaction`;rollback(){throw new v}getTransactionConfigSQL(e){let t=[];return e.isolationLevel&&t.push(`isolation level ${e.isolationLevel}`),e.accessMode&&t.push(e.accessMode),typeof e.deferrable==`boolean`&&t.push(e.deferrable?`deferrable`:`not deferrable`),d.raw(t.join(` `))}setTransaction(e){return this.session.execute(d`set transaction ${this.getTransactionConfigSQL(e)}`)}};const{Pool:G,types:K}=A;var q=class extends H{constructor(e,t,n,r,i,a,o,s){super({sql:t,params:n}),this.client=e,this.params=n,this.logger=r,this.fields=i,this._isResponseInArrayMode=o,this.customResultMapper=s,this.rawQueryConfig={name:a,text:t,types:{getTypeParser:(e,t)=>e===K.builtins.TIMESTAMPTZ||e===K.builtins.TIMESTAMP||e===K.builtins.DATE||e===K.builtins.INTERVAL||e===1231||e===1115||e===1185||e===1187||e===1182?e=>e:K.getTypeParser(e,t)}},this.queryConfig={name:a,text:t,rowMode:`array`,types:{getTypeParser:(e,t)=>e===K.builtins.TIMESTAMPTZ||e===K.builtins.TIMESTAMP||e===K.builtins.DATE||e===K.builtins.INTERVAL||e===1231||e===1115||e===1185||e===1187||e===1182?e=>e:K.getTypeParser(e,t)}}}static[e]=`NodeCockroachPreparedQuery`;rawQueryConfig;queryConfig;async execute(e={}){return a.startActiveSpan(`drizzle.execute`,async()=>{let t=c(this.params,e);this.logger.logQuery(this.rawQueryConfig.text,t);let{fields:n,rawQueryConfig:r,client:i,queryConfig:o,joinsNotNullableMap:s,customResultMapper:l}=this;if(!n&&!l)return a.startActiveSpan(`drizzle.driver.execute`,async e=>(e?.setAttributes({"drizzle.query.name":r.name,"drizzle.query.text":r.text,"drizzle.query.params":JSON.stringify(t)}),i.query(r,t)));let u=await a.startActiveSpan(`drizzle.driver.execute`,e=>(e?.setAttributes({"drizzle.query.name":o.name,"drizzle.query.text":o.text,"drizzle.query.params":JSON.stringify(t)}),i.query(o,t)));return a.startActiveSpan(`drizzle.mapResponse`,()=>l?l(u.rows):u.rows.map(e=>h(n,e,s)))})}all(e={}){return a.startActiveSpan(`drizzle.execute`,()=>{let t=c(this.params,e);return this.logger.logQuery(this.rawQueryConfig.text,t),a.startActiveSpan(`drizzle.driver.execute`,e=>(e?.setAttributes({"drizzle.query.name":this.rawQueryConfig.name,"drizzle.query.text":this.rawQueryConfig.text,"drizzle.query.params":JSON.stringify(t)}),this.client.query(this.rawQueryConfig,t).then(e=>e.rows)))})}isResponseInArrayMode(){return this._isResponseInArrayMode}},J=class t extends U{constructor(e,t,n,r={}){super(t),this.client=e,this.schema=n,this.options=r,this.logger=r.logger??new O}static[e]=`NodeCockroachSession`;logger;prepareQuery(e,t,n,r,i){return new q(this.client,e.sql,e.params,this.logger,t,n,r,i)}async transaction(e,n){let r=this.client instanceof G?new t(await this.client.connect(),this.dialect,this.schema,this.options):this,i=new Y(this.dialect,r,this.schema);await i.execute(d`begin${n?d` ${i.getTransactionConfigSQL(n)}`:void 0}`);try{let t=await e(i);return await i.execute(d`commit`),t}catch(e){throw await i.execute(d`rollback`),e}finally{this.client instanceof G&&r.client.release()}}async count(e){let t=await this.execute(e);return Number(t.rows[0].count)}},Y=class t extends W{static[e]=`NodeCockroachTransaction`;async transaction(e){let n=`sp${this.nestedIndex+1}`,r=new t(this.dialect,this.session,this.schema,this.nestedIndex+1);await r.execute(d.raw(`savepoint ${n}`));try{let t=await e(r);return await r.execute(d.raw(`release savepoint ${n}`)),t}catch(e){throw await r.execute(d.raw(`rollback to savepoint ${n}`)),e}}},X=class{constructor(e,t,n={}){this.client=e,this.dialect=t,this.options=n}static[e]=`NodeCockroachDriver`;createSession(e){return new J(this.client,this.dialect,e,{logger:this.options.logger})}},Z=class extends V{static[e]=`NodeCockroachDatabase`};function Q(e,t={}){let n=new E({casing:t.casing}),r;t.logger===!0?r=new k:t.logger!==!1&&(r=t.logger);let i;if(t.schema){let e=b(t.schema,p);i={fullSchema:t.schema,schema:e.tables,tableNamesMap:e.tableNamesMap}}let a=new Z(n,new X(e,n,{logger:r}).createSession(i),i);return a.$client=e,a}function $(...e){if(typeof e[0]==`string`)return Q(new A.Pool({connectionString:e[0]}),e[1]);let{connection:t,client:n,...r}=e[0];return Q(n||(typeof t==`string`?new A.Pool({connectionString:t}):new A.Pool(t)),r)}(e=>{function t(e){return Q({},e)}e.mock=t})($||={});export{$ as drizzle};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import{G as e,o as t}from"./sql-D-eKV1Dn.mjs";import{c as n,dr as r,l as i,n as a}from"./query-builder-V8-LDhvA.mjs";import{n as o,t as s}from"./logger-BAGZLUzj.mjs";import{t as c}from"./cache-3oO07miM.mjs";import{a as l,i as u,n as d,r as f,t as p}from"./session-CdB1A-LB.mjs";import{Database as m}from"@tursodatabase/database";var h=class t extends d{constructor(e,t,n,r,i){super(t),this.client=e,this.relations=n,this.schema=r,this.options=i,this.logger=i.logger??new o,this.cache=i.cache??new c}static[e]=`TursoDatabaseSession`;logger;cache;prepareQuery(e,t,n,r,i,a,o){return new _(this.client.prepare(e.sql),e,this.logger,this.cache,a,o,t,n,r,i)}prepareRelationalQuery(e,t,n,r){return new _(this.client.prepare(e.sql),e,this.logger,this.cache,void 0,void 0,t,n,!1,r,!0)}async transaction(e,n,r){let i=new t(this.client,this.dialect,this.relations,this.schema,this.options),a=r??new g(`async`,this.dialect,i,this.relations,this.schema);return await this.client.transaction(async()=>await e(a))()}async run(e){let t=this.dialect.sqlToQuery(e);try{return await this.prepareOneTimeQuery(t,void 0,`run`,!1).run()}catch(e){throw new a({cause:e,message:`Failed to run the query '${t.sql}'`})}}async all(e){return await this.prepareOneTimeQuery(this.dialect.sqlToQuery(e),void 0,`run`,!1).all()}async get(e){return await this.prepareOneTimeQuery(this.dialect.sqlToQuery(e),void 0,`run`,!1).get()}async values(e){return await this.prepareOneTimeQuery(this.dialect.sqlToQuery(e),void 0,`run`,!1).values()}},g=class extends f{static[e]=`TursoDatabaseTransaction`;async transaction(e){throw Error(`Nested transactions are not supported`)}},_=class extends p{constructor(e,t,n,r,i,a,o,s,c,l,u){super(`async`,s,t,r,i,a),this.stmt=e,this.logger=n,this.fields=o,this._isResponseInArrayMode=c,this.customResultMapper=l,this.isRqbV2Query=u}static[e]=`TursoDatabasePreparedQuery`;async run(e){let{stmt:n,query:r,logger:i}=this,a=t(r.params,e??{});return i.logQuery(r.sql,a),await this.queryWithCache(r.sql,a,async()=>await(a.length?n.run(...a):n.run()))}async all(e){if(this.isRqbV2Query)return await this.allRqbV2(e);let{fields:n,logger:i,query:a,customResultMapper:o,joinsNotNullableMap:s,stmt:c}=this;if(!n&&!o){let n=t(a.params,e??{});return i.logQuery(a.sql,n),await this.queryWithCache(a.sql,n,async()=>await(n.length?c.raw(!1).all(...n):c.raw(!1).all()))}return(await this.values(e)).map(e=>r(n,e,s))}async allRqbV2(e){let{logger:n,query:r,customResultMapper:i,stmt:a}=this,o=t(r.params,e??{});return n.logQuery(r.sql,o),i(await(o.length?a.raw(!1).all(...o):a.raw(!1).all()))}async get(e){if(this.isRqbV2Query)return await this.getRqbV2(e);let{fields:n,logger:i,query:a,stmt:o,customResultMapper:s,joinsNotNullableMap:c}=this,l=t(a.params,e??{});if(!n&&!s)return i.logQuery(a.sql,l),await this.queryWithCache(a.sql,l,async()=>await(l.length?o.raw(!1).get(...l):o.raw(!1).get()));let u=await this.queryWithCache(a.sql,l,async()=>await(l.length?o.raw(!0).get(...l):o.raw(!0).get()));return u===void 0?u:r(n,u,c)}async getRqbV2(e){let{logger:n,query:r,stmt:i,customResultMapper:a}=this,o=t(r.params,e??{});n.logQuery(r.sql,o);let s=await(o.length?i.raw(!1).get(...o):i.raw(!1).get());return s===void 0?s:a([s])}async values(e){let{logger:n,stmt:r,query:i}=this,a=t(i.params,e??{});return n.logQuery(i.sql,a),await this.queryWithCache(i.sql,a,async()=>await(a.length?r.raw(!0).all(...a):r.raw(!0).all()))}isResponseInArrayMode(){return this._isResponseInArrayMode}},v=class extends u{static[e]=`TursoDatabaseDatabase`};function y(e,t={}){let r=new l({casing:t.casing}),a;t.logger===!0?a=new s:t.logger!==!1&&(a=t.logger);let o;if(t.schema){let e=i(t.schema,n);o={fullSchema:t.schema,schema:e.tables,tableNamesMap:e.tableNamesMap}}let c=t.relations??{},u=new v(`async`,r,new h(e,r,c,o,{logger:a,cache:t.cache}),c,o);return u.$client=e,u.$cache=t.cache,u.$cache&&(u.$cache.invalidate=t.cache?.onMutate),u}function b(...e){if(typeof e[0]==`string`)return y(new m(e[0]),e[1]);let{connection:t,client:n,...r}=e[0];return y(n||(typeof t==`string`?new m(t):new m(t.path,t)),r)}(e=>{function t(e){return y({},e)}e.mock=t})(b||={});export{b as drizzle};
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import{a as e,c as t,t as n}from"./chunk-l9p7A9gZ.mjs";var r=n((e=>{e.parse=function(e,n){return new t(e,n).parse()};var t=class e{constructor(e,t){this.source=e,this.transform=t||n,this.position=0,this.entries=[],this.recorded=[],this.dimension=0}isEof(){return this.position>=this.source.length}nextCharacter(){var e=this.source[this.position++];return e===`\\`?{value:this.source[this.position++],escaped:!0}:{value:e,escaped:!1}}record(e){this.recorded.push(e)}newEntry(e){var t;(this.recorded.length>0||e)&&(t=this.recorded.join(``),t===`NULL`&&!e&&(t=null),t!==null&&(t=this.transform(t)),this.entries.push(t),this.recorded=[])}consumeDimensions(){if(this.source[0]===`[`)for(;!this.isEof()&&this.nextCharacter().value!==`=`;);}parse(t){var n,r,i;for(this.consumeDimensions();!this.isEof();)if(n=this.nextCharacter(),n.value===`{`&&!i)this.dimension++,this.dimension>1&&(r=new e(this.source.substr(this.position-1),this.transform),this.entries.push(r.parse(!0)),this.position+=r.position-2);else if(n.value===`}`&&!i){if(this.dimension--,!this.dimension&&(this.newEntry(),t))return this.entries}else n.value===`"`&&!n.escaped?(i&&this.newEntry(!0),i=!i):n.value===`,`&&!i?this.newEntry():this.record(n.value);if(this.dimension!==0)throw Error(`array dimension not balanced`);return this.entries}};function n(e){return e}})),i=n(((e,t)=>{var n=r();t.exports={create:function(e,t){return{parse:function(){return n.parse(e,t)}}}}})),a=n(((e,t)=>{var n=/(\d{1,})-(\d{2})-(\d{2}) (\d{2}):(\d{2}):(\d{2})(\.\d{1,})?.*?( BC)?$/,r=/^(\d{1,})-(\d{2})-(\d{2})( BC)?$/,i=/([Z+-])(\d{2})?:?(\d{2})?:?(\d{2})?/,a=/^-?infinity$/;t.exports=function(e){if(a.test(e))return Number(e.replace(`i`,`I`));var t=n.exec(e);if(!t)return o(e)||null;var r=!!t[8],i=parseInt(t[1],10);r&&(i=c(i));var u=parseInt(t[2],10)-1,d=t[3],f=parseInt(t[4],10),p=parseInt(t[5],10),m=parseInt(t[6],10),h=t[7];h=h?1e3*parseFloat(h):0;var g,_=s(e);return _==null?(g=new Date(i,u,d,f,p,m,h),l(i)&&g.setFullYear(i)):(g=new Date(Date.UTC(i,u,d,f,p,m,h)),l(i)&&g.setUTCFullYear(i),_!==0&&g.setTime(g.getTime()-_)),g};function o(e){var t=r.exec(e);if(t){var n=parseInt(t[1],10);t[4]&&(n=c(n));var i=parseInt(t[2],10)-1,a=t[3],o=new Date(n,i,a);return l(n)&&o.setFullYear(n),o}}function s(e){if(e.endsWith(`+00`))return 0;var t=i.exec(e.split(` `)[1]);if(t){var n=t[1];if(n===`Z`)return 0;var r=n===`-`?-1:1;return(parseInt(t[2],10)*3600+parseInt(t[3]||0,10)*60+parseInt(t[4]||0,10))*r*1e3}}function c(e){return-(e-1)}function l(e){return e>=0&&e<100}})),o=n(((e,t)=>{t.exports=r;var n=Object.prototype.hasOwnProperty;function r(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var i in r)n.call(r,i)&&(e[i]=r[i])}return e}})),s=n(((e,t)=>{var n=o();t.exports=r;function r(e){if(!(this instanceof r))return new r(e);n(this,_(e))}var i=[`seconds`,`minutes`,`hours`,`days`,`months`,`years`];r.prototype.toPostgres=function(){var e=i.filter(this.hasOwnProperty,this);return this.milliseconds&&e.indexOf(`seconds`)<0&&e.push(`seconds`),e.length===0?`0`:e.map(function(e){var t=this[e]||0;return e===`seconds`&&this.milliseconds&&(t=(t+this.milliseconds/1e3).toFixed(6).replace(/\.?0+$/,``)),t+` `+e},this).join(` `)};var a={years:`Y`,months:`M`,days:`D`,hours:`H`,minutes:`M`,seconds:`S`},s=[`years`,`months`,`days`],c=[`hours`,`minutes`,`seconds`];r.prototype.toISOString=r.prototype.toISO=function(){var e=s.map(n,this).join(``),t=c.map(n,this).join(``);return`P`+e+`T`+t;function n(e){var t=this[e]||0;return e===`seconds`&&this.milliseconds&&(t=(t+this.milliseconds/1e3).toFixed(6).replace(/0+$/,``)),t+a[e]}};var l=`([+-]?\\d+)`,u=l+`\\s+years?`,d=l+`\\s+mons?`,f=l+`\\s+days?`,p=new RegExp([u,d,f,`([+-])?([\\d]*):(\\d\\d):(\\d\\d)\\.?(\\d{1,6})?`].map(function(e){return`(`+e+`)?`}).join(`\\s*`)),m={years:2,months:4,days:6,hours:9,minutes:10,seconds:11,milliseconds:12},h=[`hours`,`minutes`,`seconds`,`milliseconds`];function g(e){var t=e+`000000`.slice(e.length);return parseInt(t,10)/1e3}function _(e){if(!e)return{};var t=p.exec(e),n=t[8]===`-`;return Object.keys(m).reduce(function(e,r){var i=t[m[r]];return!i||(i=r===`milliseconds`?g(i):parseInt(i,10),!i)?e:(n&&~h.indexOf(r)&&(i*=-1),e[r]=i,e)},{})}})),c=n(((e,t)=>{t.exports=function(e){if(/^\\x/.test(e))return new Buffer(e.substr(2),`hex`);for(var t=``,n=0;n<e.length;)if(e[n]!==`\\`)t+=e[n],++n;else if(/[0-7]{3}/.test(e.substr(n+1,3)))t+=String.fromCharCode(parseInt(e.substr(n+1,3),8)),n+=4;else{for(var r=1;n+r<e.length&&e[n+r]===`\\`;)r++;for(var i=0;i<Math.floor(r/2);++i)t+=`\\`;n+=Math.floor(r/2)*2}return new Buffer(t,`binary`)}})),l=n(((e,t)=>{var n=r(),o=i(),l=a(),u=s(),d=c();function f(e){return function(t){return t===null?t:e(t)}}function p(e){return e===null?e:e===`TRUE`||e===`t`||e===`true`||e===`y`||e===`yes`||e===`on`||e===`1`}function m(e){return e?n.parse(e,p):null}function h(e){return parseInt(e,10)}function g(e){return e?n.parse(e,f(h)):null}function _(e){return e?n.parse(e,f(function(e){return T(e).trim()})):null}var v=function(e){return e?o.create(e,function(e){return e!==null&&(e=D(e)),e}).parse():null},y=function(e){return e?o.create(e,function(e){return e!==null&&(e=parseFloat(e)),e}).parse():null},b=function(e){return e?o.create(e).parse():null},x=function(e){return e?o.create(e,function(e){return e!==null&&(e=l(e)),e}).parse():null},S=function(e){return e?o.create(e,function(e){return e!==null&&(e=u(e)),e}).parse():null},C=function(e){return e?n.parse(e,f(d)):null},w=function(e){return parseInt(e,10)},T=function(e){var t=String(e);return/^\d+$/.test(t)?t:e},E=function(e){return e?n.parse(e,f(JSON.parse)):null},D=function(e){return e[0]===`(`?(e=e.substring(1,e.length-1).split(`,`),{x:parseFloat(e[0]),y:parseFloat(e[1])}):null},O=function(e){if(e[0]!==`<`&&e[1]!==`(`)return null;for(var t=`(`,n=``,r=!1,i=2;i<e.length-1;i++){if(r||(t+=e[i]),e[i]===`)`){r=!0;continue}else if(!r)continue;e[i]!==`,`&&(n+=e[i])}var a=D(t);return a.radius=parseFloat(n),a};t.exports={init:function(e){e(20,T),e(21,w),e(23,w),e(26,w),e(700,parseFloat),e(701,parseFloat),e(16,p),e(1082,l),e(1114,l),e(1184,l),e(600,D),e(651,b),e(718,O),e(1e3,m),e(1001,C),e(1005,g),e(1007,g),e(1028,g),e(1016,_),e(1017,v),e(1021,y),e(1022,y),e(1231,y),e(1014,b),e(1015,b),e(1008,b),e(1009,b),e(1040,b),e(1041,b),e(1115,x),e(1182,x),e(1185,x),e(1186,u),e(1187,S),e(17,d),e(114,JSON.parse.bind(JSON)),e(3802,JSON.parse.bind(JSON)),e(199,E),e(3807,E),e(3907,b),e(2951,b),e(791,b),e(1183,b),e(1270,b)}}})),u=n(((e,t)=>{var n=1e6;function r(e){var t=e.readInt32BE(0),r=e.readUInt32BE(4),i=``;t<0&&(t=~t+(r===0),r=~r+1>>>0,i=`-`);var a=``,o=t%n,s,c,l,u,d;if(t=t/n>>>0,s=4294967296*o+r,r=s/n>>>0,c=``+(s-n*r),r===0&&t===0)return i+c+a;for(l=``,u=6-c.length,d=0;d<u;d++)l+=`0`;if(a=l+c+a,o=t%n,t=t/n>>>0,s=4294967296*o+r,r=s/n>>>0,c=``+(s-n*r),r===0&&t===0)return i+c+a;for(l=``,u=6-c.length,d=0;d<u;d++)l+=`0`;if(a=l+c+a,o=t%n,t=t/n>>>0,s=4294967296*o+r,r=s/n>>>0,c=``+(s-n*r),r===0&&t===0)return i+c+a;for(l=``,u=6-c.length,d=0;d<u;d++)l+=`0`;return a=l+c+a,o=t%n,s=4294967296*o+r,c=``+s%n,i+c+a}t.exports=r})),d=n(((e,t)=>{var n=u(),r=function(e,t,n,r,i){n||=0,r||=!1,i||=function(e,t,n){return e*2**n+t};var a=n>>3,o=function(e){return r?~e&255:e},s=255,c=8-n%8;t<c&&(s=255<<8-t&255,c=t),n&&(s>>=n%8);var l=0;n%8+t>=8&&(l=i(0,o(e[a])&s,c));for(var u=t+n>>3,d=a+1;d<u;d++)l=i(l,o(e[d]),8);var f=(t+n)%8;return f>0&&(l=i(l,o(e[u])>>8-f,f)),l},i=function(e,t,n){var i=2**(n-1)-1,a=r(e,1),o=r(e,n,1);if(o===0)return 0;var s=1,c=r(e,t,n+1,!1,function(e,t,n){e===0&&(e=1);for(var r=1;r<=n;r++)s/=2,(t&1<<n-r)>0&&(e+=s);return e});return o==2**(n+1)-1?c===0?a===0?1/0:-1/0:NaN:(a===0?1:-1)*2**(o-i)*c},a=function(e){return r(e,1)==1?-1*(r(e,15,1,!0)+1):r(e,15,1)},o=function(e){return r(e,1)==1?-1*(r(e,31,1,!0)+1):r(e,31,1)},s=function(e){return i(e,23,8)},c=function(e){return i(e,52,11)},l=function(e){var t=r(e,16,32);if(t==49152)return NaN;for(var n=1e4**r(e,16,16),i=0,a=r(e,16),o=0;o<a;o++)i+=r(e,16,64+16*o)*n,n/=1e4;var s=10**r(e,16,48);return(t===0?1:-1)*Math.round(i*s)/s},d=function(e,t){var n=r(t,1),i=r(t,63,1),a=new Date((n===0?1:-1)*i/1e3+9466848e5);return e||a.setTime(a.getTime()+a.getTimezoneOffset()*6e4),a.usec=i%1e3,a.getMicroSeconds=function(){return this.usec},a.setMicroSeconds=function(e){this.usec=e},a.getUTCMicroSeconds=function(){return this.usec},a},f=function(e){var t=r(e,32);r(e,32,32);for(var n=r(e,32,64),i=96,a=[],o=0;o<t;o++)a[o]=r(e,32,i),i+=32,i+=32;var s=function(t){var n=r(e,32,i);if(i+=32,n==4294967295)return null;var a;if(t==23||t==20)return a=r(e,n*8,i),i+=n*8,a;if(t==25)return a=e.toString(this.encoding,i>>3,(i+=n<<3)>>3),a;console.log(`ERROR: ElementType not implemented: `+t)},c=function(e,t){var n=[],r;if(e.length>1){var i=e.shift();for(r=0;r<i;r++)n[r]=c(e,t);e.unshift(i)}else for(r=0;r<e[0];r++)n[r]=s(t);return n};return c(a,n)},p=function(e){return e.toString(`utf8`)},m=function(e){return e===null?null:r(e,8)>0};t.exports={init:function(e){e(20,n),e(21,a),e(23,o),e(26,o),e(1700,l),e(700,s),e(701,c),e(16,m),e(1114,d.bind(null,!1)),e(1184,d.bind(null,!0)),e(1e3,f),e(1007,f),e(1016,f),e(1008,f),e(1009,f),e(25,p)}}})),f=n(((e,t)=>{t.exports={BOOL:16,BYTEA:17,CHAR:18,INT8:20,INT2:21,INT4:23,REGPROC:24,TEXT:25,OID:26,TID:27,XID:28,CID:29,JSON:114,XML:142,PG_NODE_TREE:194,SMGR:210,PATH:602,POLYGON:604,CIDR:650,FLOAT4:700,FLOAT8:701,ABSTIME:702,RELTIME:703,TINTERVAL:704,CIRCLE:718,MACADDR8:774,MONEY:790,MACADDR:829,INET:869,ACLITEM:1033,BPCHAR:1042,VARCHAR:1043,DATE:1082,TIME:1083,TIMESTAMP:1114,TIMESTAMPTZ:1184,INTERVAL:1186,TIMETZ:1266,BIT:1560,VARBIT:1562,NUMERIC:1700,REFCURSOR:1790,REGPROCEDURE:2202,REGOPER:2203,REGOPERATOR:2204,REGCLASS:2205,REGTYPE:2206,UUID:2950,TXID_SNAPSHOT:2970,PG_LSN:3220,PG_NDISTINCT:3361,PG_DEPENDENCIES:3402,TSVECTOR:3614,TSQUERY:3615,GTSVECTOR:3642,REGCONFIG:3734,REGDICTIONARY:3769,JSONB:3802,REGNAMESPACE:4089,REGROLE:4096}})),p=n((e=>{var t=l(),n=d(),r=i(),a=f();e.getTypeParser=c,e.setTypeParser=u,e.arrayParser=r,e.builtins=a;var o={text:{},binary:{}};function s(e){return String(e)}function c(e,t){return t||=`text`,o[t]&&o[t][e]||s}function u(e,t,n){typeof t==`function`&&(n=t,t=`text`),o[t][e]=n}t.init(function(e,t){o.text[e]=t}),n.init(function(e,t){o.binary[e]=t})})),m=n(((e,t)=>{t.exports={host:`localhost`,user:process.platform===`win32`?process.env.USERNAME:process.env.USER,database:void 0,password:null,connectionString:void 0,port:5432,rows:0,binary:!1,max:10,idleTimeoutMillis:3e4,client_encoding:``,ssl:!1,application_name:void 0,fallback_application_name:void 0,options:void 0,parseInputDatesAsUTC:!1,statement_timeout:!1,lock_timeout:!1,idle_in_transaction_session_timeout:!1,query_timeout:!1,connect_timeout:0,keepalives:1,keepalives_idle:0};let n=p(),r=n.getTypeParser(20,`text`),i=n.getTypeParser(1016,`text`);t.exports.__defineSetter__(`parseInt8`,function(e){n.setTypeParser(20,`text`,e?n.getTypeParser(23,`text`):r),n.setTypeParser(1016,`text`,e?n.getTypeParser(1007,`text`):i)})})),h=n(((t,n)=>{let r=m(),i=e(`util`),{isDate:a}=i.types||i;function o(e){return`"`+e.replace(/\\/g,`\\\\`).replace(/"/g,`\\"`)+`"`}function s(e){let t=`{`;for(let n=0;n<e.length;n++)if(n>0&&(t+=`,`),e[n]===null||e[n]===void 0)t+=`NULL`;else if(Array.isArray(e[n]))t+=s(e[n]);else if(ArrayBuffer.isView(e[n])){let r=e[n];if(!(r instanceof Buffer)){let e=Buffer.from(r.buffer,r.byteOffset,r.byteLength);r=e.length===r.byteLength?e:e.slice(r.byteOffset,r.byteOffset+r.byteLength)}t+=`\\\\x`+r.toString(`hex`)}else t+=o(c(e[n]));return t+=`}`,t}let c=function(e,t){if(e==null)return null;if(typeof e==`object`){if(e instanceof Buffer)return e;if(ArrayBuffer.isView(e)){let t=Buffer.from(e.buffer,e.byteOffset,e.byteLength);return t.length===e.byteLength?t:t.slice(e.byteOffset,e.byteOffset+e.byteLength)}return a(e)?r.parseInputDatesAsUTC?d(e):u(e):Array.isArray(e)?s(e):l(e,t)}return e.toString()};function l(e,t){if(e&&typeof e.toPostgres==`function`){if(t||=[],t.indexOf(e)!==-1)throw Error(`circular reference detected while preparing "`+e+`" for query`);return t.push(e),c(e.toPostgres(c),t)}return JSON.stringify(e)}function u(e){let t=-e.getTimezoneOffset(),n=e.getFullYear(),r=n<1;r&&(n=Math.abs(n)+1);let i=String(n).padStart(4,`0`)+`-`+String(e.getMonth()+1).padStart(2,`0`)+`-`+String(e.getDate()).padStart(2,`0`)+`T`+String(e.getHours()).padStart(2,`0`)+`:`+String(e.getMinutes()).padStart(2,`0`)+`:`+String(e.getSeconds()).padStart(2,`0`)+`.`+String(e.getMilliseconds()).padStart(3,`0`);return t<0?(i+=`-`,t*=-1):i+=`+`,i+=String(Math.floor(t/60)).padStart(2,`0`)+`:`+String(t%60).padStart(2,`0`),r&&(i+=` BC`),i}function d(e){let t=e.getUTCFullYear(),n=t<1;n&&(t=Math.abs(t)+1);let r=String(t).padStart(4,`0`)+`-`+String(e.getUTCMonth()+1).padStart(2,`0`)+`-`+String(e.getUTCDate()).padStart(2,`0`)+`T`+String(e.getUTCHours()).padStart(2,`0`)+`:`+String(e.getUTCMinutes()).padStart(2,`0`)+`:`+String(e.getUTCSeconds()).padStart(2,`0`)+`.`+String(e.getUTCMilliseconds()).padStart(3,`0`);return r+=`+00:00`,n&&(r+=` BC`),r}function f(e,t,n){return e=typeof e==`string`?{text:e}:e,t&&(typeof t==`function`?e.callback=t:e.values=t),n&&(e.callback=n),e}n.exports={prepareValue:function(e){return c(e)},normalizeQueryConfig:f,escapeIdentifier:function(e){return`"`+e.replace(/"/g,`""`)+`"`},escapeLiteral:function(e){let t=!1,n=`'`;if(e==null||typeof e!=`string`)return`''`;for(let r=0;r<e.length;r++){let i=e[r];i===`'`?n+=i+i:i===`\\`?(n+=i+i,t=!0):n+=i}return n+=`'`,t===!0&&(n=` E`+n),n}}})),g=n(((t,n)=>{let r=e(`crypto`);function i(e){return r.createHash(`md5`).update(e,`utf-8`).digest(`hex`)}function a(e,t,n){let r=i(t+e);return`md5`+i(Buffer.concat([Buffer.from(r),n]))}function o(e){return r.createHash(`sha256`).update(e).digest()}function s(e,t){return e=e.replace(/(\D)-/,`$1`),r.createHash(e).update(t).digest()}function c(e,t){return r.createHmac(`sha256`,e).update(t).digest()}async function l(e,t,n){return r.pbkdf2Sync(e,t,n,32,`sha256`)}n.exports={postgresMd5PasswordHash:a,randomBytes:r.randomBytes,deriveKey:l,sha256:o,hashByName:s,hmacSha256:c,md5:i}})),_=n(((t,n)=>{let r=e(`crypto`);n.exports={postgresMd5PasswordHash:l,randomBytes:s,deriveKey:p,sha256:u,hashByName:d,hmacSha256:f,md5:c};let i=r.webcrypto||globalThis.crypto,a=i.subtle,o=new TextEncoder;function s(e){return i.getRandomValues(Buffer.alloc(e))}async function c(e){try{return r.createHash(`md5`).update(e,`utf-8`).digest(`hex`)}catch{let t=typeof e==`string`?o.encode(e):e,n=await a.digest(`MD5`,t);return Array.from(new Uint8Array(n)).map(e=>e.toString(16).padStart(2,`0`)).join(``)}}async function l(e,t,n){let r=await c(t+e);return`md5`+await c(Buffer.concat([Buffer.from(r),n]))}async function u(e){return await a.digest(`SHA-256`,e)}async function d(e,t){return await a.digest(e,t)}async function f(e,t){let n=await a.importKey(`raw`,e,{name:`HMAC`,hash:`SHA-256`},!1,[`sign`]);return await a.sign(`HMAC`,n,o.encode(t))}async function p(e,t,n){let r=await a.importKey(`raw`,o.encode(e),`PBKDF2`,!1,[`deriveBits`]),i={name:`PBKDF2`,hash:`SHA-256`,salt:t,iterations:n};return await a.deriveBits(i,r,256,[`deriveBits`])}})),v=n(((e,t)=>{parseInt(process.versions&&process.versions.node&&process.versions.node.split(`.`)[0])<15?t.exports=g():t.exports=_()})),y=n(((e,t)=>{function n(e,t){return Error(`SASL channel binding: `+e+` when parsing public certificate `+t.toString(`base64`))}function r(e,t){let r=e[t++];if(r<128)return{length:r,index:t};let i=r&127;if(i>4)throw n(`bad length`,e);r=0;for(let n=0;n<i;n++)r=r<<8|e[t++];return{length:r,index:t}}function i(e,t){if(e[t++]!==6)throw n(`non-OID data`,e);let{length:i,index:a}=r(e,t);t=a;let o=t+i,s=e[t++],c=(s/40>>0)+`.`+s%40;for(;t<o;){let n=0;for(;t<o;){let r=e[t++];if(n=n<<7|r&127,r<128)break}c+=`.`+n}return{oid:c,index:t}}function a(e,t){if(e[t++]!==48)throw n(`non-sequence data`,e);return r(e,t)}function o(e,t){t===void 0&&(t=0),t=a(e,t).index;let{length:o,index:s}=a(e,t);t=s+o,t=a(e,t).index;let{oid:c,index:l}=i(e,t);switch(c){case`1.2.840.113549.1.1.4`:return`MD5`;case`1.2.840.113549.1.1.5`:return`SHA-1`;case`1.2.840.113549.1.1.11`:return`SHA-256`;case`1.2.840.113549.1.1.12`:return`SHA-384`;case`1.2.840.113549.1.1.13`:return`SHA-512`;case`1.2.840.113549.1.1.14`:return`SHA-224`;case`1.2.840.113549.1.1.15`:return`SHA512-224`;case`1.2.840.113549.1.1.16`:return`SHA512-256`;case`1.2.840.10045.4.1`:return`SHA-1`;case`1.2.840.10045.4.3.1`:return`SHA-224`;case`1.2.840.10045.4.3.2`:return`SHA-256`;case`1.2.840.10045.4.3.3`:return`SHA-384`;case`1.2.840.10045.4.3.4`:return`SHA-512`;case`1.2.840.113549.1.1.10`:{if(t=l,t=a(e,t).index,e[t++]!==160)throw n(`non-tag data`,e);t=r(e,t).index,t=a(e,t).index;let{oid:o}=i(e,t);switch(o){case`1.2.840.113549.2.5`:return`MD5`;case`1.3.14.3.2.26`:return`SHA-1`;case`2.16.840.1.101.3.4.2.1`:return`SHA-256`;case`2.16.840.1.101.3.4.2.2`:return`SHA-384`;case`2.16.840.1.101.3.4.2.3`:return`SHA-512`}throw n(`unknown hash OID `+o,e)}case`1.3.101.110`:case`1.3.101.112`:return`SHA-512`;case`1.3.101.111`:case`1.3.101.113`:throw n(`Ed448 certificate channel binding is not currently supported by Postgres`)}throw n(`unknown OID `+c,e)}t.exports={signatureAlgorithmHashFromCertificate:o}})),b=n(((e,t)=>{let n=v(),{signatureAlgorithmHashFromCertificate:r}=y();function i(e,t){let r=[`SCRAM-SHA-256`];t&&r.unshift(`SCRAM-SHA-256-PLUS`);let i=r.find(t=>e.includes(t));if(!i)throw Error(`SASL: Only mechanism(s) `+r.join(` and `)+` are supported`);if(i===`SCRAM-SHA-256-PLUS`&&typeof t.getPeerCertificate!=`function`)throw Error(`SASL: Mechanism SCRAM-SHA-256-PLUS requires a certificate`);let a=n.randomBytes(18).toString(`base64`);return{mechanism:i,clientNonce:a,response:(i===`SCRAM-SHA-256-PLUS`?`p=tls-server-end-point`:t?`y`:`n`)+`,,n=*,r=`+a,message:`SASLInitialResponse`}}async function a(e,t,i,a){if(e.message!==`SASLInitialResponse`)throw Error(`SASL: Last message was not SASLInitialResponse`);if(typeof t!=`string`)throw Error(`SASL: SCRAM-SERVER-FIRST-MESSAGE: client password must be a string`);if(t===``)throw Error(`SASL: SCRAM-SERVER-FIRST-MESSAGE: client password must be a non-empty string`);if(typeof i!=`string`)throw Error(`SASL: SCRAM-SERVER-FIRST-MESSAGE: serverData must be a string`);let o=u(i);if(o.nonce.startsWith(e.clientNonce)){if(o.nonce.length===e.clientNonce.length)throw Error(`SASL: SCRAM-SERVER-FIRST-MESSAGE: server nonce is too short`)}else throw Error(`SASL: SCRAM-SERVER-FIRST-MESSAGE: server nonce does not start with client nonce`);let s=`n=*,r=`+e.clientNonce,c=`r=`+o.nonce+`,s=`+o.salt+`,i=`+o.iteration,l=a?`eSws`:`biws`;if(e.mechanism===`SCRAM-SHA-256-PLUS`){let e=a.getPeerCertificate().raw,t=r(e);(t===`MD5`||t===`SHA-1`)&&(t=`SHA-256`);let i=await n.hashByName(t,e);l=Buffer.concat([Buffer.from(`p=tls-server-end-point,,`),Buffer.from(i)]).toString(`base64`)}let d=`c=`+l+`,r=`+o.nonce,p=s+`,`+c+`,`+d,m=Buffer.from(o.salt,`base64`),h=await n.deriveKey(t,m,o.iteration),g=await n.hmacSha256(h,`Client Key`),_=await n.sha256(g),v=await n.hmacSha256(_,p),y=f(Buffer.from(g),Buffer.from(v)).toString(`base64`),b=await n.hmacSha256(h,`Server Key`),x=await n.hmacSha256(b,p);e.message=`SASLResponse`,e.serverSignature=Buffer.from(x).toString(`base64`),e.response=d+`,p=`+y}function o(e,t){if(e.message!==`SASLResponse`)throw Error(`SASL: Last message was not SASLResponse`);if(typeof t!=`string`)throw Error(`SASL: SCRAM-SERVER-FINAL-MESSAGE: serverData must be a string`);let{serverSignature:n}=d(t);if(n!==e.serverSignature)throw Error(`SASL: SCRAM-SERVER-FINAL-MESSAGE: server signature does not match`)}function s(e){if(typeof e!=`string`)throw TypeError(`SASL: text must be a string`);return e.split(``).map((t,n)=>e.charCodeAt(n)).every(e=>e>=33&&e<=43||e>=45&&e<=126)}function c(e){return/^(?:[a-zA-Z0-9+/]{4})*(?:[a-zA-Z0-9+/]{2}==|[a-zA-Z0-9+/]{3}=)?$/.test(e)}function l(e){if(typeof e!=`string`)throw TypeError(`SASL: attribute pairs text must be a string`);return new Map(e.split(`,`).map(e=>{if(!/^.=/.test(e))throw Error(`SASL: Invalid attribute pair entry`);return[e[0],e.substring(2)]}))}function u(e){let t=l(e),n=t.get(`r`);if(n){if(!s(n))throw Error(`SASL: SCRAM-SERVER-FIRST-MESSAGE: nonce must only contain printable characters`)}else throw Error(`SASL: SCRAM-SERVER-FIRST-MESSAGE: nonce missing`);let r=t.get(`s`);if(r){if(!c(r))throw Error(`SASL: SCRAM-SERVER-FIRST-MESSAGE: salt must be base64`)}else throw Error(`SASL: SCRAM-SERVER-FIRST-MESSAGE: salt missing`);let i=t.get(`i`);if(i){if(!/^[1-9][0-9]*$/.test(i))throw Error(`SASL: SCRAM-SERVER-FIRST-MESSAGE: invalid iteration count`)}else throw Error(`SASL: SCRAM-SERVER-FIRST-MESSAGE: iteration missing`);return{nonce:n,salt:r,iteration:parseInt(i,10)}}function d(e){let t=l(e).get(`v`);if(t){if(!c(t))throw Error(`SASL: SCRAM-SERVER-FINAL-MESSAGE: server signature must be base64`)}else throw Error(`SASL: SCRAM-SERVER-FINAL-MESSAGE: server signature is missing`);return{serverSignature:t}}function f(e,t){if(!Buffer.isBuffer(e))throw TypeError(`first argument must be a Buffer`);if(!Buffer.isBuffer(t))throw TypeError(`second argument must be a Buffer`);if(e.length!==t.length)throw Error(`Buffer lengths must match`);if(e.length===0)throw Error(`Buffers cannot be empty`);return Buffer.from(e.map((n,r)=>e[r]^t[r]))}t.exports={startSession:i,continueSession:a,finalizeSession:o}})),x=n(((e,t)=>{let n=p();function r(e){this._types=e||n,this.text={},this.binary={}}r.prototype.getOverrides=function(e){switch(e){case`text`:return this.text;case`binary`:return this.binary;default:return{}}},r.prototype.setTypeParser=function(e,t,n){typeof t==`function`&&(n=t,t=`text`),this.getOverrides(t)[e]=n},r.prototype.getTypeParser=function(e,t){return t||=`text`,this.getOverrides(t)[e]||this._types.getTypeParser(e,t)},t.exports=r})),S=n(((t,n)=>{function r(t,n={}){if(t.charAt(0)===`/`){let e=t.split(` `);return{host:e[0],database:e[1]}}let r={},i,a=!1;/ |%[^a-f0-9]|%[a-f0-9][^a-f0-9]/i.test(t)&&(t=encodeURI(t).replace(/%25(\d\d)/g,`%$1`));try{try{i=new URL(t,`postgres://base`)}catch{i=new URL(t.replace(`@/`,`@___DUMMY___/`),`postgres://base`),a=!0}}catch(e){e.input&&=`*****REDACTED*****`}for(let e of i.searchParams.entries())r[e[0]]=e[1];if(r.user=r.user||decodeURIComponent(i.username),r.password=r.password||decodeURIComponent(i.password),i.protocol==`socket:`)return r.host=decodeURI(i.pathname),r.database=i.searchParams.get(`db`),r.client_encoding=i.searchParams.get(`encoding`),r;let o=a?``:i.hostname;r.host?o&&/^%2f/i.test(o)&&(i.pathname=o+i.pathname):r.host=decodeURIComponent(o),r.port||=i.port;let s=i.pathname.slice(1)||null;r.database=s?decodeURI(s):null,(r.ssl===`true`||r.ssl===`1`)&&(r.ssl=!0),r.ssl===`0`&&(r.ssl=!1),(r.sslcert||r.sslkey||r.sslrootcert||r.sslmode)&&(r.ssl={});let c=r.sslcert||r.sslkey||r.sslrootcert?e(`fs`):null;if(r.sslcert&&(r.ssl.cert=c.readFileSync(r.sslcert).toString()),r.sslkey&&(r.ssl.key=c.readFileSync(r.sslkey).toString()),r.sslrootcert&&(r.ssl.ca=c.readFileSync(r.sslrootcert).toString()),n.useLibpqCompat&&r.uselibpqcompat)throw Error(`Both useLibpqCompat and uselibpqcompat are set. Please use only one of them.`);if(r.uselibpqcompat===`true`||n.useLibpqCompat)switch(r.sslmode){case`disable`:r.ssl=!1;break;case`prefer`:r.ssl.rejectUnauthorized=!1;break;case`require`:r.sslrootcert?r.ssl.checkServerIdentity=function(){}:r.ssl.rejectUnauthorized=!1;break;case`verify-ca`:if(!r.ssl.ca)throw Error(`SECURITY WARNING: Using sslmode=verify-ca requires specifying a CA with sslrootcert. If a public CA is used, verify-ca allows connections to a server that somebody else may have registered with the CA, making you vulnerable to Man-in-the-Middle attacks. Either specify a custom CA certificate with sslrootcert parameter or use sslmode=verify-full for proper security.`);r.ssl.checkServerIdentity=function(){};break;case`verify-full`:break}else switch(r.sslmode){case`disable`:r.ssl=!1;break;case`prefer`:case`require`:case`verify-ca`:case`verify-full`:break;case`no-verify`:r.ssl.rejectUnauthorized=!1;break}return r}function i(e){return Object.entries(e).reduce((e,[t,n])=>(n!=null&&(e[t]=n),e),{})}function a(e){return Object.entries(e).reduce((e,[t,n])=>{if(t===`ssl`){let r=n;typeof r==`boolean`&&(e[t]=r),typeof r==`object`&&(e[t]=i(r))}else if(n!=null)if(t===`port`){if(n!==``){let r=parseInt(n,10);if(isNaN(r))throw Error(`Invalid ${t}: ${n}`);e[t]=r}}else e[t]=n;return e},{})}function o(e){return a(r(e))}n.exports=r,r.parse=r,r.toClientConfig=a,r.parseIntoClientConfig=o})),C=n(((t,n)=>{let r=e(`dns`),i=m(),a=S().parse,o=function(e,t,n){return n===void 0?n=process.env[`PG`+e.toUpperCase()]:n===!1||(n=process.env[n]),t[e]||n||i[e]},s=function(){switch(process.env.PGSSLMODE){case`disable`:return!1;case`prefer`:case`require`:case`verify-ca`:case`verify-full`:return!0;case`no-verify`:return{rejectUnauthorized:!1}}return i.ssl},c=function(e){return`'`+(``+e).replace(/\\/g,`\\\\`).replace(/'/g,`\\'`)+`'`},l=function(e,t,n){let r=t[n];r!=null&&e.push(n+`=`+c(r))};n.exports=class{constructor(e){e=typeof e==`string`?a(e):e||{},e.connectionString&&(e=Object.assign({},e,a(e.connectionString))),this.user=o(`user`,e),this.database=o(`database`,e),this.database===void 0&&(this.database=this.user),this.port=parseInt(o(`port`,e),10),this.host=o(`host`,e),Object.defineProperty(this,`password`,{configurable:!0,enumerable:!1,writable:!0,value:o(`password`,e)}),this.binary=o(`binary`,e),this.options=o(`options`,e),this.ssl=e.ssl===void 0?s():e.ssl,typeof this.ssl==`string`&&this.ssl===`true`&&(this.ssl=!0),this.ssl===`no-verify`&&(this.ssl={rejectUnauthorized:!1}),this.ssl&&this.ssl.key&&Object.defineProperty(this.ssl,`key`,{enumerable:!1}),this.client_encoding=o(`client_encoding`,e),this.replication=o(`replication`,e),this.isDomainSocket=!(this.host||``).indexOf(`/`),this.application_name=o(`application_name`,e,`PGAPPNAME`),this.fallback_application_name=o(`fallback_application_name`,e,!1),this.statement_timeout=o(`statement_timeout`,e,!1),this.lock_timeout=o(`lock_timeout`,e,!1),this.idle_in_transaction_session_timeout=o(`idle_in_transaction_session_timeout`,e,!1),this.query_timeout=o(`query_timeout`,e,!1),e.connectionTimeoutMillis===void 0?this.connect_timeout=process.env.PGCONNECT_TIMEOUT||0:this.connect_timeout=Math.floor(e.connectionTimeoutMillis/1e3),e.keepAlive===!1?this.keepalives=0:e.keepAlive===!0&&(this.keepalives=1),typeof e.keepAliveInitialDelayMillis==`number`&&(this.keepalives_idle=Math.floor(e.keepAliveInitialDelayMillis/1e3))}getLibpqConnectionString(e){let t=[];l(t,this,`user`),l(t,this,`password`),l(t,this,`port`),l(t,this,`application_name`),l(t,this,`fallback_application_name`),l(t,this,`connect_timeout`),l(t,this,`options`);let n=typeof this.ssl==`object`?this.ssl:this.ssl?{sslmode:this.ssl}:{};if(l(t,n,`sslmode`),l(t,n,`sslca`),l(t,n,`sslkey`),l(t,n,`sslcert`),l(t,n,`sslrootcert`),this.database&&t.push(`dbname=`+c(this.database)),this.replication&&t.push(`replication=`+c(this.replication)),this.host&&t.push(`host=`+c(this.host)),this.isDomainSocket)return e(null,t.join(` `));this.client_encoding&&t.push(`client_encoding=`+c(this.client_encoding)),r.lookup(this.host,function(n,r){return n?e(n,null):(t.push(`hostaddr=`+c(r)),e(null,t.join(` `)))})}}})),w=n(((e,t)=>{let n=p(),r=/^([A-Za-z]+)(?: (\d+))?(?: (\d+))?/;t.exports=class{constructor(e,t){this.command=null,this.rowCount=null,this.oid=null,this.rows=[],this.fields=[],this._parsers=void 0,this._types=t,this.RowCtor=null,this.rowAsArray=e===`array`,this.rowAsArray&&(this.parseRow=this._parseRowAsArray),this._prebuiltEmptyResultObject=null}addCommandComplete(e){let t;t=e.text?r.exec(e.text):r.exec(e.command),t&&(this.command=t[1],t[3]?(this.oid=parseInt(t[2],10),this.rowCount=parseInt(t[3],10)):t[2]&&(this.rowCount=parseInt(t[2],10)))}_parseRowAsArray(e){let t=Array(e.length);for(let n=0,r=e.length;n<r;n++){let r=e[n];r===null?t[n]=null:t[n]=this._parsers[n](r)}return t}parseRow(e){let t={...this._prebuiltEmptyResultObject};for(let n=0,r=e.length;n<r;n++){let r=e[n],i=this.fields[n].name;if(r!==null){let e=this.fields[n].format===`binary`?Buffer.from(r):r;t[i]=this._parsers[n](e)}else t[i]=null}return t}addRow(e){this.rows.push(e)}addFields(e){this.fields=e,this.fields.length&&(this._parsers=Array(e.length));let t={};for(let r=0;r<e.length;r++){let i=e[r];t[i.name]=null,this._types?this._parsers[r]=this._types.getTypeParser(i.dataTypeID,i.format||`text`):this._parsers[r]=n.getTypeParser(i.dataTypeID,i.format||`text`)}this._prebuiltEmptyResultObject={...t}}}})),T=n(((t,n)=>{let{EventEmitter:r}=e(`events`),i=w(),a=h();n.exports=class extends r{constructor(e,t,n){super(),e=a.normalizeQueryConfig(e,t,n),this.text=e.text,this.values=e.values,this.rows=e.rows,this.types=e.types,this.name=e.name,this.queryMode=e.queryMode,this.binary=e.binary,this.portal=e.portal||``,this.callback=e.callback,this._rowMode=e.rowMode,process.domain&&e.callback&&(this.callback=process.domain.bind(e.callback)),this._result=new i(this._rowMode,this.types),this._results=this._result,this._canceledDueToError=!1}requiresPreparation(){return this.queryMode===`extended`||this.name||this.rows?!0:!this.text||!this.values?!1:this.values.length>0}_checkForMultirow(){this._result.command&&(Array.isArray(this._results)||(this._results=[this._result]),this._result=new i(this._rowMode,this._result._types),this._results.push(this._result))}handleRowDescription(e){this._checkForMultirow(),this._result.addFields(e.fields),this._accumulateRows=this.callback||!this.listeners(`row`).length}handleDataRow(e){let t;if(!this._canceledDueToError){try{t=this._result.parseRow(e.fields)}catch(e){this._canceledDueToError=e;return}this.emit(`row`,t,this._result),this._accumulateRows&&this._result.addRow(t)}}handleCommandComplete(e,t){this._checkForMultirow(),this._result.addCommandComplete(e),this.rows&&t.sync()}handleEmptyQuery(e){this.rows&&e.sync()}handleError(e,t){if(this._canceledDueToError&&=(e=this._canceledDueToError,!1),this.callback)return this.callback(e);this.emit(`error`,e)}handleReadyForQuery(e){if(this._canceledDueToError)return this.handleError(this._canceledDueToError,e);if(this.callback)try{this.callback(null,this._results)}catch(e){process.nextTick(()=>{throw e})}this.emit(`end`,this._results)}submit(e){if(typeof this.text!=`string`&&typeof this.name!=`string`)return Error(`A query must have either text or a name. Supplying neither is unsupported.`);let t=e.parsedStatements[this.name];if(this.text&&t&&this.text!==t)return Error(`Prepared statements must be unique - '${this.name}' was used for a different statement`);if(this.values&&!Array.isArray(this.values))return Error(`Query values must be an array`);if(this.requiresPreparation()){e.stream.cork&&e.stream.cork();try{this.prepare(e)}finally{e.stream.uncork&&e.stream.uncork()}}else e.query(this.text);return null}hasBeenParsed(e){return this.name&&e.parsedStatements[this.name]}handlePortalSuspended(e){this._getRows(e,this.rows)}_getRows(e,t){e.execute({portal:this.portal,rows:t}),t?e.flush():e.sync()}prepare(e){this.hasBeenParsed(e)||e.parse({text:this.text,name:this.name,types:this.types});try{e.bind({portal:this.portal,statement:this.name,values:this.values,binary:this.binary,valueMapper:a.prepareValue})}catch(t){this.handleError(t,e);return}e.describe({type:`P`,name:this.portal||``}),this._getRows(e,this.rows)}handleCopyInResponse(e){e.sendCopyFail(`No source stream defined`)}handleCopyData(e,t){}}})),E=n((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.NoticeMessage=e.DataRowMessage=e.CommandCompleteMessage=e.ReadyForQueryMessage=e.NotificationResponseMessage=e.BackendKeyDataMessage=e.AuthenticationMD5Password=e.ParameterStatusMessage=e.ParameterDescriptionMessage=e.RowDescriptionMessage=e.Field=e.CopyResponse=e.CopyDataMessage=e.DatabaseError=e.copyDone=e.emptyQuery=e.replicationStart=e.portalSuspended=e.noData=e.closeComplete=e.bindComplete=e.parseComplete=void 0,e.parseComplete={name:`parseComplete`,length:5},e.bindComplete={name:`bindComplete`,length:5},e.closeComplete={name:`closeComplete`,length:5},e.noData={name:`noData`,length:5},e.portalSuspended={name:`portalSuspended`,length:5},e.replicationStart={name:`replicationStart`,length:4},e.emptyQuery={name:`emptyQuery`,length:4},e.copyDone={name:`copyDone`,length:4},e.DatabaseError=class extends Error{constructor(e,t,n){super(e),this.length=t,this.name=n}},e.CopyDataMessage=class{constructor(e,t){this.length=e,this.chunk=t,this.name=`copyData`}},e.CopyResponse=class{constructor(e,t,n,r){this.length=e,this.name=t,this.binary=n,this.columnTypes=Array(r)}},e.Field=class{constructor(e,t,n,r,i,a,o){this.name=e,this.tableID=t,this.columnID=n,this.dataTypeID=r,this.dataTypeSize=i,this.dataTypeModifier=a,this.format=o}},e.RowDescriptionMessage=class{constructor(e,t){this.length=e,this.fieldCount=t,this.name=`rowDescription`,this.fields=Array(this.fieldCount)}},e.ParameterDescriptionMessage=class{constructor(e,t){this.length=e,this.parameterCount=t,this.name=`parameterDescription`,this.dataTypeIDs=Array(this.parameterCount)}},e.ParameterStatusMessage=class{constructor(e,t,n){this.length=e,this.parameterName=t,this.parameterValue=n,this.name=`parameterStatus`}},e.AuthenticationMD5Password=class{constructor(e,t){this.length=e,this.salt=t,this.name=`authenticationMD5Password`}},e.BackendKeyDataMessage=class{constructor(e,t,n){this.length=e,this.processID=t,this.secretKey=n,this.name=`backendKeyData`}},e.NotificationResponseMessage=class{constructor(e,t,n,r){this.length=e,this.processId=t,this.channel=n,this.payload=r,this.name=`notification`}},e.ReadyForQueryMessage=class{constructor(e,t){this.length=e,this.status=t,this.name=`readyForQuery`}},e.CommandCompleteMessage=class{constructor(e,t){this.length=e,this.text=t,this.name=`commandComplete`}},e.DataRowMessage=class{constructor(e,t){this.length=e,this.fields=t,this.name=`dataRow`,this.fieldCount=t.length}},e.NoticeMessage=class{constructor(e,t){this.length=e,this.message=t,this.name=`notice`}}})),D=n((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.Writer=void 0,e.Writer=class{constructor(e=256){this.size=e,this.offset=5,this.headerPosition=0,this.buffer=Buffer.allocUnsafe(e)}ensure(e){if(this.buffer.length-this.offset<e){let t=this.buffer,n=t.length+(t.length>>1)+e;this.buffer=Buffer.allocUnsafe(n),t.copy(this.buffer)}}addInt32(e){return this.ensure(4),this.buffer[this.offset++]=e>>>24&255,this.buffer[this.offset++]=e>>>16&255,this.buffer[this.offset++]=e>>>8&255,this.buffer[this.offset++]=e>>>0&255,this}addInt16(e){return this.ensure(2),this.buffer[this.offset++]=e>>>8&255,this.buffer[this.offset++]=e>>>0&255,this}addCString(e){if(!e)this.ensure(1);else{let t=Buffer.byteLength(e);this.ensure(t+1),this.buffer.write(e,this.offset,`utf-8`),this.offset+=t}return this.buffer[this.offset++]=0,this}addString(e=``){let t=Buffer.byteLength(e);return this.ensure(t),this.buffer.write(e,this.offset),this.offset+=t,this}add(e){return this.ensure(e.length),e.copy(this.buffer,this.offset),this.offset+=e.length,this}join(e){if(e){this.buffer[this.headerPosition]=e;let t=this.offset-(this.headerPosition+1);this.buffer.writeInt32BE(t,this.headerPosition+1)}return this.buffer.slice(e?0:5,this.offset)}flush(e){let t=this.join(e);return this.offset=5,this.headerPosition=0,this.buffer=Buffer.allocUnsafe(this.size),t}}})),O=n((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.serialize=void 0;let t=D(),n=new t.Writer,r=e=>{n.addInt16(3).addInt16(0);for(let t of Object.keys(e))n.addCString(t).addCString(e[t]);n.addCString(`client_encoding`).addCString(`UTF8`);let r=n.addCString(``).flush(),i=r.length+4;return new t.Writer().addInt32(i).add(r).flush()},i=()=>{let e=Buffer.allocUnsafe(8);return e.writeInt32BE(8,0),e.writeInt32BE(80877103,4),e},a=e=>n.addCString(e).flush(112),o=function(e,t){return n.addCString(e).addInt32(Buffer.byteLength(t)).addString(t),n.flush(112)},s=function(e){return n.addString(e).flush(112)},c=e=>n.addCString(e).flush(81),l=[],u=e=>{let t=e.name||``;t.length>63&&(console.error(`Warning! Postgres only supports 63 characters for query names.`),console.error(`You supplied %s (%s)`,t,t.length),console.error(`This can cause conflicts and silent errors executing queries`));let r=e.types||l,i=r.length,a=n.addCString(t).addCString(e.text).addInt16(i);for(let e=0;e<i;e++)a.addInt32(r[e]);return n.flush(80)},d=new t.Writer,f=function(e,t){for(let r=0;r<e.length;r++){let i=t?t(e[r],r):e[r];i==null?(n.addInt16(0),d.addInt32(-1)):i instanceof Buffer?(n.addInt16(1),d.addInt32(i.length),d.add(i)):(n.addInt16(0),d.addInt32(Buffer.byteLength(i)),d.addString(i))}},p=(e={})=>{let t=e.portal||``,r=e.statement||``,i=e.binary||!1,a=e.values||l,o=a.length;return n.addCString(t).addCString(r),n.addInt16(o),f(a,e.valueMapper),n.addInt16(o),n.add(d.flush()),n.addInt16(1),n.addInt16(i?1:0),n.flush(66)},m=Buffer.from([69,0,0,0,9,0,0,0,0,0]),h=e=>{if(!e||!e.portal&&!e.rows)return m;let t=e.portal||``,n=e.rows||0,r=Buffer.byteLength(t),i=4+r+1+4,a=Buffer.allocUnsafe(1+i);return a[0]=69,a.writeInt32BE(i,1),a.write(t,5,`utf-8`),a[r+5]=0,a.writeUInt32BE(n,a.length-4),a},g=(e,t)=>{let n=Buffer.allocUnsafe(16);return n.writeInt32BE(16,0),n.writeInt16BE(1234,4),n.writeInt16BE(5678,6),n.writeInt32BE(e,8),n.writeInt32BE(t,12),n},_=(e,t)=>{let n=4+Buffer.byteLength(t)+1,r=Buffer.allocUnsafe(1+n);return r[0]=e,r.writeInt32BE(n,1),r.write(t,5,`utf-8`),r[n]=0,r},v=n.addCString(`P`).flush(68),y=n.addCString(`S`).flush(68),b=e=>e.name?_(68,`${e.type}${e.name||``}`):e.type===`P`?v:y,x=e=>_(67,`${e.type}${e.name||``}`),S=e=>n.add(e).flush(100),C=e=>_(102,e),w=e=>Buffer.from([e,0,0,0,4]),T=w(72),E=w(83),O=w(88),k=w(99);e.serialize={startup:r,password:a,requestSsl:i,sendSASLInitialResponseMessage:o,sendSCRAMClientFinalMessage:s,query:c,parse:u,bind:p,execute:h,describe:b,close:x,flush:()=>T,sync:()=>E,end:()=>O,copyData:S,copyDone:()=>k,copyFail:C,cancel:g}})),k=n((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.BufferReader=void 0;let t=Buffer.allocUnsafe(0);e.BufferReader=class{constructor(e=0){this.offset=e,this.buffer=t,this.encoding=`utf-8`}setBuffer(e,t){this.offset=e,this.buffer=t}int16(){let e=this.buffer.readInt16BE(this.offset);return this.offset+=2,e}byte(){let e=this.buffer[this.offset];return this.offset++,e}int32(){let e=this.buffer.readInt32BE(this.offset);return this.offset+=4,e}uint32(){let e=this.buffer.readUInt32BE(this.offset);return this.offset+=4,e}string(e){let t=this.buffer.toString(this.encoding,this.offset,this.offset+e);return this.offset+=e,t}cstring(){let e=this.offset,t=e;for(;this.buffer[t++]!==0;);return this.offset=t,this.buffer.toString(this.encoding,e,t-1)}bytes(e){let t=this.buffer.slice(this.offset,this.offset+e);return this.offset+=e,t}}})),A=n((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.Parser=void 0;let t=E(),n=k(),r=Buffer.allocUnsafe(0);e.Parser=class{constructor(e){if(this.buffer=r,this.bufferLength=0,this.bufferOffset=0,this.reader=new n.BufferReader,e?.mode===`binary`)throw Error(`Binary mode not supported yet`);this.mode=e?.mode||`text`}parse(e,t){this.mergeBuffer(e);let n=this.bufferOffset+this.bufferLength,i=this.bufferOffset;for(;i+5<=n;){let e=this.buffer[i],r=this.buffer.readUInt32BE(i+1),a=1+r;if(a+i<=n)t(this.handlePacket(i+5,e,r,this.buffer)),i+=a;else break}i===n?(this.buffer=r,this.bufferLength=0,this.bufferOffset=0):(this.bufferLength=n-i,this.bufferOffset=i)}mergeBuffer(e){if(this.bufferLength>0){let t=this.bufferLength+e.byteLength;if(t+this.bufferOffset>this.buffer.byteLength){let e;if(t<=this.buffer.byteLength&&this.bufferOffset>=this.bufferLength)e=this.buffer;else{let n=this.buffer.byteLength*2;for(;t>=n;)n*=2;e=Buffer.allocUnsafe(n)}this.buffer.copy(e,0,this.bufferOffset,this.bufferOffset+this.bufferLength),this.buffer=e,this.bufferOffset=0}e.copy(this.buffer,this.bufferOffset+this.bufferLength),this.bufferLength=t}else this.buffer=e,this.bufferOffset=0,this.bufferLength=e.byteLength}handlePacket(e,n,r,i){switch(n){case 50:return t.bindComplete;case 49:return t.parseComplete;case 51:return t.closeComplete;case 110:return t.noData;case 115:return t.portalSuspended;case 99:return t.copyDone;case 87:return t.replicationStart;case 73:return t.emptyQuery;case 68:return this.parseDataRowMessage(e,r,i);case 67:return this.parseCommandCompleteMessage(e,r,i);case 90:return this.parseReadyForQueryMessage(e,r,i);case 65:return this.parseNotificationMessage(e,r,i);case 82:return this.parseAuthenticationResponse(e,r,i);case 83:return this.parseParameterStatusMessage(e,r,i);case 75:return this.parseBackendKeyData(e,r,i);case 69:return this.parseErrorMessage(e,r,i,`error`);case 78:return this.parseErrorMessage(e,r,i,`notice`);case 84:return this.parseRowDescriptionMessage(e,r,i);case 116:return this.parseParameterDescriptionMessage(e,r,i);case 71:return this.parseCopyInMessage(e,r,i);case 72:return this.parseCopyOutMessage(e,r,i);case 100:return this.parseCopyData(e,r,i);default:return new t.DatabaseError(`received invalid response: `+n.toString(16),r,`error`)}}parseReadyForQueryMessage(e,n,r){this.reader.setBuffer(e,r);let i=this.reader.string(1);return new t.ReadyForQueryMessage(n,i)}parseCommandCompleteMessage(e,n,r){this.reader.setBuffer(e,r);let i=this.reader.cstring();return new t.CommandCompleteMessage(n,i)}parseCopyData(e,n,r){let i=r.slice(e,e+(n-4));return new t.CopyDataMessage(n,i)}parseCopyInMessage(e,t,n){return this.parseCopyMessage(e,t,n,`copyInResponse`)}parseCopyOutMessage(e,t,n){return this.parseCopyMessage(e,t,n,`copyOutResponse`)}parseCopyMessage(e,n,r,i){this.reader.setBuffer(e,r);let a=this.reader.byte()!==0,o=this.reader.int16(),s=new t.CopyResponse(n,i,a,o);for(let e=0;e<o;e++)s.columnTypes[e]=this.reader.int16();return s}parseNotificationMessage(e,n,r){this.reader.setBuffer(e,r);let i=this.reader.int32(),a=this.reader.cstring(),o=this.reader.cstring();return new t.NotificationResponseMessage(n,i,a,o)}parseRowDescriptionMessage(e,n,r){this.reader.setBuffer(e,r);let i=this.reader.int16(),a=new t.RowDescriptionMessage(n,i);for(let e=0;e<i;e++)a.fields[e]=this.parseField();return a}parseField(){let e=this.reader.cstring(),n=this.reader.uint32(),r=this.reader.int16(),i=this.reader.uint32(),a=this.reader.int16(),o=this.reader.int32(),s=this.reader.int16()===0?`text`:`binary`;return new t.Field(e,n,r,i,a,o,s)}parseParameterDescriptionMessage(e,n,r){this.reader.setBuffer(e,r);let i=this.reader.int16(),a=new t.ParameterDescriptionMessage(n,i);for(let e=0;e<i;e++)a.dataTypeIDs[e]=this.reader.int32();return a}parseDataRowMessage(e,n,r){this.reader.setBuffer(e,r);let i=this.reader.int16(),a=Array(i);for(let e=0;e<i;e++){let t=this.reader.int32();a[e]=t===-1?null:this.reader.string(t)}return new t.DataRowMessage(n,a)}parseParameterStatusMessage(e,n,r){this.reader.setBuffer(e,r);let i=this.reader.cstring(),a=this.reader.cstring();return new t.ParameterStatusMessage(n,i,a)}parseBackendKeyData(e,n,r){this.reader.setBuffer(e,r);let i=this.reader.int32(),a=this.reader.int32();return new t.BackendKeyDataMessage(n,i,a)}parseAuthenticationResponse(e,n,r){this.reader.setBuffer(e,r);let i=this.reader.int32(),a={name:`authenticationOk`,length:n};switch(i){case 0:break;case 3:a.length===8&&(a.name=`authenticationCleartextPassword`);break;case 5:if(a.length===12){a.name=`authenticationMD5Password`;let e=this.reader.bytes(4);return new t.AuthenticationMD5Password(n,e)}break;case 10:{a.name=`authenticationSASL`,a.mechanisms=[];let e;do e=this.reader.cstring(),e&&a.mechanisms.push(e);while(e)}break;case 11:a.name=`authenticationSASLContinue`,a.data=this.reader.string(n-8);break;case 12:a.name=`authenticationSASLFinal`,a.data=this.reader.string(n-8);break;default:throw Error(`Unknown authenticationOk message type `+i)}return a}parseErrorMessage(e,n,r,i){this.reader.setBuffer(e,r);let a={},o=this.reader.string(1);for(;o!==`\0`;)a[o]=this.reader.cstring(),o=this.reader.string(1);let s=a.M,c=i===`notice`?new t.NoticeMessage(n,s):new t.DatabaseError(s,n,i);return c.severity=a.S,c.code=a.C,c.detail=a.D,c.hint=a.H,c.position=a.P,c.internalPosition=a.p,c.internalQuery=a.q,c.where=a.W,c.schema=a.s,c.table=a.t,c.column=a.c,c.dataType=a.d,c.constraint=a.n,c.file=a.F,c.line=a.L,c.routine=a.R,c}}})),j=n((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.DatabaseError=e.serialize=e.parse=void 0;let t=E();Object.defineProperty(e,`DatabaseError`,{enumerable:!0,get:function(){return t.DatabaseError}});let n=O();Object.defineProperty(e,`serialize`,{enumerable:!0,get:function(){return n.serialize}});let r=A();function i(e,t){let n=new r.Parser;return e.on(`data`,e=>n.parse(e,t)),new Promise(t=>e.on(`end`,()=>t()))}e.parse=i})),M=n((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.default={}})),N=n(((t,n)=>{let{getStream:r,getSecureStream:i}=c();n.exports={getStream:r,getSecureStream:i};function a(){function t(t){return new(e(`net`)).Socket}function n(t){return e(`tls`).connect(t)}return{getStream:t,getSecureStream:n}}function o(){function e(e){let{CloudflareSocket:t}=M();return new t(e)}function t(e){return e.socket.startTls(e),e.socket}return{getStream:e,getSecureStream:t}}function s(){if(typeof navigator==`object`&&navigator!==null&&typeof navigator.userAgent==`string`)return navigator.userAgent===`Cloudflare-Workers`;if(typeof Response==`function`){let e=new Response(null,{cf:{thing:!0}});if(typeof e.cf==`object`&&e.cf!==null&&e.cf.thing)return!0}return!1}function c(){return s()?o():a()}})),P=n(((t,n)=>{let r=e(`events`).EventEmitter,{parse:i,serialize:a}=j(),{getStream:o,getSecureStream:s}=N(),c=a.flush(),l=a.sync(),u=a.end();n.exports=class extends r{constructor(e){super(),e||={},this.stream=e.stream||o(e.ssl),typeof this.stream==`function`&&(this.stream=this.stream(e)),this._keepAlive=e.keepAlive,this._keepAliveInitialDelayMillis=e.keepAliveInitialDelayMillis,this.lastBuffer=!1,this.parsedStatements={},this.ssl=e.ssl||!1,this._ending=!1,this._emitMessage=!1;let t=this;this.on(`newListener`,function(e){e===`message`&&(t._emitMessage=!0)})}connect(t,n){let r=this;this._connecting=!0,this.stream.setNoDelay(!0),this.stream.connect(t,n),this.stream.once(`connect`,function(){r._keepAlive&&r.stream.setKeepAlive(!0,r._keepAliveInitialDelayMillis),r.emit(`connect`)});let i=function(e){r._ending&&(e.code===`ECONNRESET`||e.code===`EPIPE`)||r.emit(`error`,e)};if(this.stream.on(`error`,i),this.stream.on(`close`,function(){r.emit(`end`)}),!this.ssl)return this.attachListeners(this.stream);this.stream.once(`data`,function(t){switch(t.toString(`utf8`)){case`S`:break;case`N`:return r.stream.end(),r.emit(`error`,Error(`The server does not support SSL connections`));default:return r.stream.end(),r.emit(`error`,Error(`There was an error establishing an SSL connection`))}let a={socket:r.stream};r.ssl!==!0&&(Object.assign(a,r.ssl),`key`in r.ssl&&(a.key=r.ssl.key));let o=e(`net`);o.isIP&&o.isIP(n)===0&&(a.servername=n);try{r.stream=s(a)}catch(e){return r.emit(`error`,e)}r.attachListeners(r.stream),r.stream.on(`error`,i),r.emit(`sslconnect`)})}attachListeners(e){i(e,e=>{let t=e.name===`error`?`errorMessage`:e.name;this._emitMessage&&this.emit(`message`,e),this.emit(t,e)})}requestSsl(){this.stream.write(a.requestSsl())}startup(e){this.stream.write(a.startup(e))}cancel(e,t){this._send(a.cancel(e,t))}password(e){this._send(a.password(e))}sendSASLInitialResponseMessage(e,t){this._send(a.sendSASLInitialResponseMessage(e,t))}sendSCRAMClientFinalMessage(e){this._send(a.sendSCRAMClientFinalMessage(e))}_send(e){return this.stream.writable?this.stream.write(e):!1}query(e){this._send(a.query(e))}parse(e){this._send(a.parse(e))}bind(e){this._send(a.bind(e))}execute(e){this._send(a.execute(e))}flush(){this.stream.writable&&this.stream.write(c)}sync(){this._ending=!0,this._send(l)}ref(){this.stream.ref()}unref(){this.stream.unref()}end(){if(this._ending=!0,!this._connecting||!this.stream.writable){this.stream.end();return}return this.stream.write(u,()=>{this.stream.end()})}close(e){this._send(a.close(e))}describe(e){this._send(a.describe(e))}sendCopyFromChunk(e){this._send(a.copyData(e))}endCopyFrom(){this._send(a.copyDone())}sendCopyFail(e){this._send(a.copyFail(e))}}})),F=n(((t,n)=>{let{Transform:r}=e(`stream`),{StringDecoder:i}=e(`string_decoder`),a=Symbol(`last`),o=Symbol(`decoder`);function s(e,t,n){let r;if(this.overflow){if(r=this[o].write(e).split(this.matcher),r.length===1)return n();r.shift(),this.overflow=!1}else this[a]+=this[o].write(e),r=this[a].split(this.matcher);this[a]=r.pop();for(let e=0;e<r.length;e++)try{l(this,this.mapper(r[e]))}catch(e){return n(e)}if(this.overflow=this[a].length>this.maxLength,this.overflow&&!this.skipOverflow){n(Error(`maximum buffer reached`));return}n()}function c(e){if(this[a]+=this[o].end(),this[a])try{l(this,this.mapper(this[a]))}catch(t){return e(t)}e()}function l(e,t){t!==void 0&&e.push(t)}function u(e){return e}function d(e,t,n){switch(e||=/\r?\n/,t||=u,n||={},arguments.length){case 1:typeof e==`function`?(t=e,e=/\r?\n/):typeof e==`object`&&!(e instanceof RegExp)&&!e[Symbol.split]&&(n=e,e=/\r?\n/);break;case 2:typeof e==`function`?(n=t,t=e,e=/\r?\n/):typeof t==`object`&&(n=t,t=u)}n=Object.assign({},n),n.autoDestroy=!0,n.transform=s,n.flush=c,n.readableObjectMode=!0;let l=new r(n);return l[a]=``,l[o]=new i(`utf8`),l.matcher=e,l.mapper=t,l.maxLength=n.maxLength,l.skipOverflow=n.skipOverflow||!1,l.overflow=!1,l._destroy=function(e,t){this._writableState.errorEmitted=!1,t(e)},l}n.exports=d})),I=n(((t,n)=>{var r=e(`path`),i=e(`stream`).Stream,a=F(),o=e(`util`),s=5432,c=process.platform===`win32`,l=process.stderr,u=56,d=7,f=61440,p=32768;function m(e){return(e&f)==p}var h=[`host`,`port`,`database`,`user`,`password`],g=h.length,_=h[g-1];function v(){if(l instanceof i&&!0===l.writable){var e=Array.prototype.slice.call(arguments).concat(`
|
|
3
|
+
`);l.write(o.format.apply(o,e))}}Object.defineProperty(n.exports,`isWin`,{get:function(){return c},set:function(e){c=e}}),n.exports.warnTo=function(e){var t=l;return l=e,t},n.exports.getFileName=function(e){var t=e||process.env;return t.PGPASSFILE||(c?r.join(t.APPDATA||`./`,`postgresql`,`pgpass.conf`):r.join(t.HOME||`./`,`.pgpass`))},n.exports.usePgPass=function(e,t){return Object.prototype.hasOwnProperty.call(process.env,`PGPASSWORD`)?!1:c?!0:(t||=`<unkn>`,m(e.mode)?e.mode&(u|d)?(v(`WARNING: password file "%s" has group or world access; permissions should be u=rw (0600) or less`,t),!1):!0:(v(`WARNING: password file "%s" is not a plain file`,t),!1))};var y=n.exports.match=function(e,t){return h.slice(0,-1).reduce(function(n,r,i){return i==1&&Number(e[r]||s)===Number(t[r])?n&&!0:n&&(t[r]===`*`||t[r]===e[r])},!0)};n.exports.getPassword=function(e,t,n){var r,i=t.pipe(a());function o(t){var n=b(t);n&&x(n)&&y(e,n)&&(r=n[_],i.end())}var s=function(){t.destroy(),n(r)},c=function(e){t.destroy(),v(`WARNING: error on reading file: %s`,e),n(void 0)};t.on(`error`,c),i.on(`data`,o).on(`end`,s).on(`error`,c)};var b=n.exports.parseLine=function(e){if(e.length<11||e.match(/^\s+#/))return null;for(var t=``,n=``,r=0,i=0,a={},o=!1,s=function(t,n,r){var i=e.substring(n,r);Object.hasOwnProperty.call(process.env,`PGPASS_NO_DEESCAPE`)||(i=i.replace(/\\([:\\])/g,`$1`)),a[h[t]]=i},c=0;c<e.length-1;c+=1){if(t=e.charAt(c+1),n=e.charAt(c),o=r==g-1,o){s(r,i);break}c>=0&&t==`:`&&n!==`\\`&&(s(r,i,c+1),i=c+2,r+=1)}return a=Object.keys(a).length===g?a:null,a},x=n.exports.isValidEntry=function(e){for(var t={0:function(e){return e.length>0},1:function(e){return e===`*`?!0:(e=Number(e),isFinite(e)&&e>0&&e<9007199254740992&&Math.floor(e)===e)},2:function(e){return e.length>0},3:function(e){return e.length>0},4:function(e){return e.length>0}},n=0;n<h.length;n+=1){var r=t[n];if(!r(e[h[n]]||``))return!1}return!0}})),L=n(((t,n)=>{e(`path`);var r=e(`fs`),i=I();n.exports=function(e,t){var n=i.getFileName();r.stat(n,function(a,o){if(a||!i.usePgPass(o,n))return t(void 0);var s=r.createReadStream(n);i.getPassword(e,s,t)})},n.exports.warnTo=i.warnTo})),R=n(((t,n)=>{let r=e(`events`).EventEmitter,i=h(),a=b(),o=x(),s=C(),c=T(),l=m(),u=P(),d=v();var f=class extends r{constructor(e){super(),this.connectionParameters=new s(e),this.user=this.connectionParameters.user,this.database=this.connectionParameters.database,this.port=this.connectionParameters.port,this.host=this.connectionParameters.host,Object.defineProperty(this,`password`,{configurable:!0,enumerable:!1,writable:!0,value:this.connectionParameters.password}),this.replication=this.connectionParameters.replication;let t=e||{};this._Promise=t.Promise||global.Promise,this._types=new o(t.types),this._ending=!1,this._ended=!1,this._connecting=!1,this._connected=!1,this._connectionError=!1,this._queryable=!0,this.enableChannelBinding=!!t.enableChannelBinding,this.connection=t.connection||new u({stream:t.stream,ssl:this.connectionParameters.ssl,keepAlive:t.keepAlive||!1,keepAliveInitialDelayMillis:t.keepAliveInitialDelayMillis||0,encoding:this.connectionParameters.client_encoding||`utf8`}),this.queryQueue=[],this.binary=t.binary||l.binary,this.processID=null,this.secretKey=null,this.ssl=this.connectionParameters.ssl||!1,this.ssl&&this.ssl.key&&Object.defineProperty(this.ssl,`key`,{enumerable:!1}),this._connectionTimeoutMillis=t.connectionTimeoutMillis||0}_errorAllQueries(e){let t=t=>{process.nextTick(()=>{t.handleError(e,this.connection)})};this.activeQuery&&=(t(this.activeQuery),null),this.queryQueue.forEach(t),this.queryQueue.length=0}_connect(e){let t=this,n=this.connection;if(this._connectionCallback=e,this._connecting||this._connected){let t=Error(`Client has already been connected. You cannot reuse a client.`);process.nextTick(()=>{e(t)});return}this._connecting=!0,this._connectionTimeoutMillis>0&&(this.connectionTimeoutHandle=setTimeout(()=>{n._ending=!0,n.stream.destroy(Error(`timeout expired`))},this._connectionTimeoutMillis),this.connectionTimeoutHandle.unref&&this.connectionTimeoutHandle.unref()),this.host&&this.host.indexOf(`/`)===0?n.connect(this.host+`/.s.PGSQL.`+this.port):n.connect(this.port,this.host),n.on(`connect`,function(){t.ssl?n.requestSsl():n.startup(t.getStartupConf())}),n.on(`sslconnect`,function(){n.startup(t.getStartupConf())}),this._attachListeners(n),n.once(`end`,()=>{let e=this._ending?Error(`Connection terminated`):Error(`Connection terminated unexpectedly`);clearTimeout(this.connectionTimeoutHandle),this._errorAllQueries(e),this._ended=!0,this._ending||(this._connecting&&!this._connectionError?this._connectionCallback?this._connectionCallback(e):this._handleErrorEvent(e):this._connectionError||this._handleErrorEvent(e)),process.nextTick(()=>{this.emit(`end`)})})}connect(e){if(e){this._connect(e);return}return new this._Promise((e,t)=>{this._connect(n=>{n?t(n):e()})})}_attachListeners(e){e.on(`authenticationCleartextPassword`,this._handleAuthCleartextPassword.bind(this)),e.on(`authenticationMD5Password`,this._handleAuthMD5Password.bind(this)),e.on(`authenticationSASL`,this._handleAuthSASL.bind(this)),e.on(`authenticationSASLContinue`,this._handleAuthSASLContinue.bind(this)),e.on(`authenticationSASLFinal`,this._handleAuthSASLFinal.bind(this)),e.on(`backendKeyData`,this._handleBackendKeyData.bind(this)),e.on(`error`,this._handleErrorEvent.bind(this)),e.on(`errorMessage`,this._handleErrorMessage.bind(this)),e.on(`readyForQuery`,this._handleReadyForQuery.bind(this)),e.on(`notice`,this._handleNotice.bind(this)),e.on(`rowDescription`,this._handleRowDescription.bind(this)),e.on(`dataRow`,this._handleDataRow.bind(this)),e.on(`portalSuspended`,this._handlePortalSuspended.bind(this)),e.on(`emptyQuery`,this._handleEmptyQuery.bind(this)),e.on(`commandComplete`,this._handleCommandComplete.bind(this)),e.on(`parseComplete`,this._handleParseComplete.bind(this)),e.on(`copyInResponse`,this._handleCopyInResponse.bind(this)),e.on(`copyData`,this._handleCopyData.bind(this)),e.on(`notification`,this._handleNotification.bind(this))}_checkPgPass(e){let t=this.connection;if(typeof this.password==`function`)this._Promise.resolve().then(()=>this.password()).then(n=>{if(n!==void 0){if(typeof n!=`string`){t.emit(`error`,TypeError(`Password must be a string`));return}this.connectionParameters.password=this.password=n}else this.connectionParameters.password=this.password=null;e()}).catch(e=>{t.emit(`error`,e)});else if(this.password!==null)e();else try{L()(this.connectionParameters,t=>{t!==void 0&&(this.connectionParameters.password=this.password=t),e()})}catch(e){this.emit(`error`,e)}}_handleAuthCleartextPassword(e){this._checkPgPass(()=>{this.connection.password(this.password)})}_handleAuthMD5Password(e){this._checkPgPass(async()=>{try{let t=await d.postgresMd5PasswordHash(this.user,this.password,e.salt);this.connection.password(t)}catch(e){this.emit(`error`,e)}})}_handleAuthSASL(e){this._checkPgPass(()=>{try{this.saslSession=a.startSession(e.mechanisms,this.enableChannelBinding&&this.connection.stream),this.connection.sendSASLInitialResponseMessage(this.saslSession.mechanism,this.saslSession.response)}catch(e){this.connection.emit(`error`,e)}})}async _handleAuthSASLContinue(e){try{await a.continueSession(this.saslSession,this.password,e.data,this.enableChannelBinding&&this.connection.stream),this.connection.sendSCRAMClientFinalMessage(this.saslSession.response)}catch(e){this.connection.emit(`error`,e)}}_handleAuthSASLFinal(e){try{a.finalizeSession(this.saslSession,e.data),this.saslSession=null}catch(e){this.connection.emit(`error`,e)}}_handleBackendKeyData(e){this.processID=e.processID,this.secretKey=e.secretKey}_handleReadyForQuery(e){this._connecting&&(this._connecting=!1,this._connected=!0,clearTimeout(this.connectionTimeoutHandle),this._connectionCallback&&=(this._connectionCallback(null,this),null),this.emit(`connect`));let{activeQuery:t}=this;this.activeQuery=null,this.readyForQuery=!0,t&&t.handleReadyForQuery(this.connection),this._pulseQueryQueue()}_handleErrorWhileConnecting(e){if(!this._connectionError){if(this._connectionError=!0,clearTimeout(this.connectionTimeoutHandle),this._connectionCallback)return this._connectionCallback(e);this.emit(`error`,e)}}_handleErrorEvent(e){if(this._connecting)return this._handleErrorWhileConnecting(e);this._queryable=!1,this._errorAllQueries(e),this.emit(`error`,e)}_handleErrorMessage(e){if(this._connecting)return this._handleErrorWhileConnecting(e);let t=this.activeQuery;if(!t){this._handleErrorEvent(e);return}this.activeQuery=null,t.handleError(e,this.connection)}_handleRowDescription(e){this.activeQuery.handleRowDescription(e)}_handleDataRow(e){this.activeQuery.handleDataRow(e)}_handlePortalSuspended(e){this.activeQuery.handlePortalSuspended(this.connection)}_handleEmptyQuery(e){this.activeQuery.handleEmptyQuery(this.connection)}_handleCommandComplete(e){if(this.activeQuery==null){let e=Error(`Received unexpected commandComplete message from backend.`);this._handleErrorEvent(e);return}this.activeQuery.handleCommandComplete(e,this.connection)}_handleParseComplete(){if(this.activeQuery==null){let e=Error(`Received unexpected parseComplete message from backend.`);this._handleErrorEvent(e);return}this.activeQuery.name&&(this.connection.parsedStatements[this.activeQuery.name]=this.activeQuery.text)}_handleCopyInResponse(e){this.activeQuery.handleCopyInResponse(this.connection)}_handleCopyData(e){this.activeQuery.handleCopyData(e,this.connection)}_handleNotification(e){this.emit(`notification`,e)}_handleNotice(e){this.emit(`notice`,e)}getStartupConf(){let e=this.connectionParameters,t={user:e.user,database:e.database},n=e.application_name||e.fallback_application_name;return n&&(t.application_name=n),e.replication&&(t.replication=``+e.replication),e.statement_timeout&&(t.statement_timeout=String(parseInt(e.statement_timeout,10))),e.lock_timeout&&(t.lock_timeout=String(parseInt(e.lock_timeout,10))),e.idle_in_transaction_session_timeout&&(t.idle_in_transaction_session_timeout=String(parseInt(e.idle_in_transaction_session_timeout,10))),e.options&&(t.options=e.options),t}cancel(e,t){if(e.activeQuery===t){let t=this.connection;this.host&&this.host.indexOf(`/`)===0?t.connect(this.host+`/.s.PGSQL.`+this.port):t.connect(this.port,this.host),t.on(`connect`,function(){t.cancel(e.processID,e.secretKey)})}else e.queryQueue.indexOf(t)!==-1&&e.queryQueue.splice(e.queryQueue.indexOf(t),1)}setTypeParser(e,t,n){return this._types.setTypeParser(e,t,n)}getTypeParser(e,t){return this._types.getTypeParser(e,t)}escapeIdentifier(e){return i.escapeIdentifier(e)}escapeLiteral(e){return i.escapeLiteral(e)}_pulseQueryQueue(){if(this.readyForQuery===!0)if(this.activeQuery=this.queryQueue.shift(),this.activeQuery){this.readyForQuery=!1,this.hasExecuted=!0;let e=this.activeQuery.submit(this.connection);e&&process.nextTick(()=>{this.activeQuery.handleError(e,this.connection),this.readyForQuery=!0,this._pulseQueryQueue()})}else this.hasExecuted&&(this.activeQuery=null,this.emit(`drain`))}query(e,t,n){let r,i,a,o,s;if(e==null)throw TypeError(`Client was passed a null or undefined query`);return typeof e.submit==`function`?(a=e.query_timeout||this.connectionParameters.query_timeout,i=r=e,typeof t==`function`&&(r.callback=r.callback||t)):(a=e.query_timeout||this.connectionParameters.query_timeout,r=new c(e,t,n),r.callback||(i=new this._Promise((e,t)=>{r.callback=(n,r)=>n?t(n):e(r)}).catch(e=>{throw Error.captureStackTrace(e),e}))),a&&(s=r.callback,o=setTimeout(()=>{let e=Error(`Query read timeout`);process.nextTick(()=>{r.handleError(e,this.connection)}),s(e),r.callback=()=>{};let t=this.queryQueue.indexOf(r);t>-1&&this.queryQueue.splice(t,1),this._pulseQueryQueue()},a),r.callback=(e,t)=>{clearTimeout(o),s(e,t)}),this.binary&&!r.binary&&(r.binary=!0),r._result&&!r._result._types&&(r._result._types=this._types),this._queryable?this._ending?(process.nextTick(()=>{r.handleError(Error(`Client was closed and is not queryable`),this.connection)}),i):(this.queryQueue.push(r),this._pulseQueryQueue(),i):(process.nextTick(()=>{r.handleError(Error(`Client has encountered a connection error and is not queryable`),this.connection)}),i)}ref(){this.connection.ref()}unref(){this.connection.unref()}end(e){if(this._ending=!0,!this.connection._connecting||this._ended)if(e)e();else return this._Promise.resolve();if(this.activeQuery||!this._queryable?this.connection.stream.destroy():this.connection.end(),e)this.connection.once(`end`,e);else return new this._Promise(e=>{this.connection.once(`end`,e)})}};f.Query=c,n.exports=f})),z=n(((t,n)=>{let r=e(`events`).EventEmitter,i=function(){},a=(e,t)=>{let n=e.findIndex(t);return n===-1?void 0:e.splice(n,1)[0]};var o=class{constructor(e,t,n){this.client=e,this.idleListener=t,this.timeoutId=n}},s=class{constructor(e){this.callback=e}};function c(){throw Error(`Release called on client which has already been released to the pool.`)}function l(e,t){if(t)return{callback:t,result:void 0};let n,r;return{callback:function(e,t){e?n(e):r(t)},result:new e(function(e,t){r=e,n=t}).catch(e=>{throw Error.captureStackTrace(e),e})}}function u(e,t){return function n(r){r.client=t,t.removeListener(`error`,n),t.on(`error`,()=>{e.log(`additional client error after disconnection due to error`,r)}),e._remove(t),e.emit(`error`,r,t)}}n.exports=class extends r{constructor(e,t){super(),this.options=Object.assign({},e),e!=null&&`password`in e&&Object.defineProperty(this.options,`password`,{configurable:!0,enumerable:!1,writable:!0,value:e.password}),e!=null&&e.ssl&&e.ssl.key&&Object.defineProperty(this.options.ssl,`key`,{enumerable:!1}),this.options.max=this.options.max||this.options.poolSize||10,this.options.min=this.options.min||0,this.options.maxUses=this.options.maxUses||1/0,this.options.allowExitOnIdle=this.options.allowExitOnIdle||!1,this.options.maxLifetimeSeconds=this.options.maxLifetimeSeconds||0,this.log=this.options.log||function(){},this.Client=this.options.Client||t||U().Client,this.Promise=this.options.Promise||global.Promise,this.options.idleTimeoutMillis===void 0&&(this.options.idleTimeoutMillis=1e4),this._clients=[],this._idle=[],this._expired=new WeakSet,this._pendingQueue=[],this._endCallback=void 0,this.ending=!1,this.ended=!1}_isFull(){return this._clients.length>=this.options.max}_isAboveMin(){return this._clients.length>this.options.min}_pulseQueue(){if(this.log(`pulse queue`),this.ended){this.log(`pulse queue ended`);return}if(this.ending){this.log(`pulse queue on ending`),this._idle.length&&this._idle.slice().map(e=>{this._remove(e.client)}),this._clients.length||(this.ended=!0,this._endCallback());return}if(!this._pendingQueue.length){this.log(`no queued requests`);return}if(!this._idle.length&&this._isFull())return;let e=this._pendingQueue.shift();if(this._idle.length){let t=this._idle.pop();clearTimeout(t.timeoutId);let n=t.client;n.ref&&n.ref();let r=t.idleListener;return this._acquireClient(n,e,r,!1)}if(!this._isFull())return this.newClient(e);throw Error(`unexpected condition`)}_remove(e,t){let n=a(this._idle,t=>t.client===e);n!==void 0&&clearTimeout(n.timeoutId),this._clients=this._clients.filter(t=>t!==e);let r=this;e.end(()=>{r.emit(`remove`,e),typeof t==`function`&&t()})}connect(e){if(this.ending){let t=Error(`Cannot use a pool after calling end on the pool`);return e?e(t):this.Promise.reject(t)}let t=l(this.Promise,e),n=t.result;if(this._isFull()||this._idle.length){if(this._idle.length&&process.nextTick(()=>this._pulseQueue()),!this.options.connectionTimeoutMillis)return this._pendingQueue.push(new s(t.callback)),n;let e=(e,n,r)=>{clearTimeout(i),t.callback(e,n,r)},r=new s(e),i=setTimeout(()=>{a(this._pendingQueue,t=>t.callback===e),r.timedOut=!0,t.callback(Error(`timeout exceeded when trying to connect`))},this.options.connectionTimeoutMillis);return i.unref&&i.unref(),this._pendingQueue.push(r),n}return this.newClient(new s(t.callback)),n}newClient(e){let t=new this.Client(this.options);this._clients.push(t);let n=u(this,t);this.log(`checking client timeout`);let r,a=!1;this.options.connectionTimeoutMillis&&(r=setTimeout(()=>{this.log(`ending client due to timeout`),a=!0,t.connection?t.connection.stream.destroy():t.end()},this.options.connectionTimeoutMillis)),this.log(`connecting new client`),t.connect(o=>{if(r&&clearTimeout(r),t.on(`error`,n),o)this.log(`client failed to connect`,o),this._clients=this._clients.filter(e=>e!==t),a&&(o=Error(`Connection terminated due to connection timeout`,{cause:o})),this._pulseQueue(),e.timedOut||e.callback(o,void 0,i);else{if(this.log(`new client connected`),this.options.maxLifetimeSeconds!==0){let e=setTimeout(()=>{this.log(`ending client due to expired lifetime`),this._expired.add(t),this._idle.findIndex(e=>e.client===t)!==-1&&this._acquireClient(t,new s((e,t,n)=>n()),n,!1)},this.options.maxLifetimeSeconds*1e3);e.unref(),t.once(`end`,()=>clearTimeout(e))}return this._acquireClient(t,e,n,!0)}})}_acquireClient(e,t,n,r){r&&this.emit(`connect`,e),this.emit(`acquire`,e),e.release=this._releaseOnce(e,n),e.removeListener(`error`,n),t.timedOut?r&&this.options.verify?this.options.verify(e,e.release):e.release():r&&this.options.verify?this.options.verify(e,n=>{if(n)return e.release(n),t.callback(n,void 0,i);t.callback(void 0,e,e.release)}):t.callback(void 0,e,e.release)}_releaseOnce(e,t){let n=!1;return r=>{n&&c(),n=!0,this._release(e,t,r)}}_release(e,t,n){if(e.on(`error`,t),e._poolUseCount=(e._poolUseCount||0)+1,this.emit(`release`,n,e),n||this.ending||!e._queryable||e._ending||e._poolUseCount>=this.options.maxUses)return e._poolUseCount>=this.options.maxUses&&this.log(`remove expended client`),this._remove(e,this._pulseQueue.bind(this));if(this._expired.has(e))return this.log(`remove expired client`),this._expired.delete(e),this._remove(e,this._pulseQueue.bind(this));let r;this.options.idleTimeoutMillis&&this._isAboveMin()&&(r=setTimeout(()=>{this.log(`remove idle client`),this._remove(e,this._pulseQueue.bind(this))},this.options.idleTimeoutMillis),this.options.allowExitOnIdle&&r.unref()),this.options.allowExitOnIdle&&e.unref(),this._idle.push(new o(e,t,r)),this._pulseQueue()}query(e,t,n){if(typeof e==`function`){let t=l(this.Promise,e);return setImmediate(function(){return t.callback(Error(`Passing a function as the first parameter to pool.query is not supported`))}),t.result}typeof t==`function`&&(n=t,t=void 0);let r=l(this.Promise,n);return n=r.callback,this.connect((r,i)=>{if(r)return n(r);let a=!1,o=e=>{a||(a=!0,i.release(e),n(e))};i.once(`error`,o),this.log(`dispatching query`);try{i.query(e,t,(e,t)=>{if(this.log(`query dispatched`),i.removeListener(`error`,o),!a)return a=!0,i.release(e),e?n(e):n(void 0,t)})}catch(e){return i.release(e),n(e)}}),r.result}end(e){if(this.log(`ending`),this.ending){let t=Error(`Called end on pool more than once`);return e?e(t):this.Promise.reject(t)}this.ending=!0;let t=l(this.Promise,e);return this._endCallback=t.callback,this._pulseQueue(),t.result}get waitingCount(){return this._pendingQueue.length}get idleCount(){return this._idle.length}get expiredCount(){return this._clients.reduce((e,t)=>e+(this._expired.has(t)?1:0),0)}get totalCount(){return this._clients.length}}})),B=n(((t,n)=>{let r=e(`events`).EventEmitter,i=e(`util`),a=h(),o=n.exports=function(e,t,n){r.call(this),e=a.normalizeQueryConfig(e,t,n),this.text=e.text,this.values=e.values,this.name=e.name,this.queryMode=e.queryMode,this.callback=e.callback,this.state=`new`,this._arrayMode=e.rowMode===`array`,this._emitRowEvents=!1,this.on(`newListener`,function(e){e===`row`&&(this._emitRowEvents=!0)}.bind(this))};i.inherits(o,r);let s={sqlState:`code`,statementPosition:`position`,messagePrimary:`message`,context:`where`,schemaName:`schema`,tableName:`table`,columnName:`column`,dataTypeName:`dataType`,constraintName:`constraint`,sourceFile:`file`,sourceLine:`line`,sourceFunction:`routine`};o.prototype.handleError=function(e){let t=this.native.pq.resultErrorFields();if(t)for(let n in t){let r=s[n]||n;e[r]=t[n]}this.callback?this.callback(e):this.emit(`error`,e),this.state=`error`},o.prototype.then=function(e,t){return this._getPromise().then(e,t)},o.prototype.catch=function(e){return this._getPromise().catch(e)},o.prototype._getPromise=function(){return this._promise||=new Promise(function(e,t){this._once(`end`,e),this._once(`error`,t)}.bind(this)),this._promise},o.prototype.submit=function(e){this.state=`running`;let t=this;this.native=e.native,e.native.arrayMode=this._arrayMode;let n=function(n,r,i){if(e.native.arrayMode=!1,setImmediate(function(){t.emit(`_done`)}),n)return t.handleError(n);t._emitRowEvents&&(i.length>1?r.forEach((e,n)=>{e.forEach(e=>{t.emit(`row`,e,i[n])})}):r.forEach(function(e){t.emit(`row`,e,i)})),t.state=`end`,t.emit(`end`,i),t.callback&&t.callback(null,i)};if(process.domain&&(n=process.domain.bind(n)),this.name){this.name.length>63&&(console.error(`Warning! Postgres only supports 63 characters for query names.`),console.error(`You supplied %s (%s)`,this.name,this.name.length),console.error(`This can cause conflicts and silent errors executing queries`));let r=(this.values||[]).map(a.prepareValue);if(e.namedQueries[this.name]){if(this.text&&e.namedQueries[this.name]!==this.text){let e=Error(`Prepared statements must be unique - '${this.name}' was used for a different statement`);return n(e)}return e.native.execute(this.name,r,n)}return e.native.prepare(this.name,this.text,r.length,function(i){return i?n(i):(e.namedQueries[t.name]=t.text,t.native.execute(t.name,r,n))})}else if(this.values){if(!Array.isArray(this.values))return n(Error(`Query values must be an array`));let t=this.values.map(a.prepareValue);e.native.query(this.text,t,n)}else this.queryMode===`extended`?e.native.query(this.text,[],n):e.native.query(this.text,n)}})),V=n(((t,n)=>{var r;try{r=e(`pg-native`)}catch(e){throw e}let i=x(),a=e(`events`).EventEmitter,o=e(`util`),s=C(),c=B(),l=n.exports=function(e){a.call(this),e||={},this._Promise=e.Promise||global.Promise,this._types=new i(e.types),this.native=new r({types:this._types}),this._queryQueue=[],this._ending=!1,this._connecting=!1,this._connected=!1,this._queryable=!0;let t=this.connectionParameters=new s(e);e.nativeConnectionString&&(t.nativeConnectionString=e.nativeConnectionString),this.user=t.user,Object.defineProperty(this,`password`,{configurable:!0,enumerable:!1,writable:!0,value:t.password}),this.database=t.database,this.host=t.host,this.port=t.port,this.namedQueries={}};l.Query=c,o.inherits(l,a),l.prototype._errorAllQueries=function(e){let t=t=>{process.nextTick(()=>{t.native=this.native,t.handleError(e)})};this._hasActiveQuery()&&(t(this._activeQuery),this._activeQuery=null),this._queryQueue.forEach(t),this._queryQueue.length=0},l.prototype._connect=function(e){let t=this;if(this._connecting){process.nextTick(()=>e(Error(`Client has already been connected. You cannot reuse a client.`)));return}this._connecting=!0,this.connectionParameters.getLibpqConnectionString(function(n,r){if(t.connectionParameters.nativeConnectionString&&(r=t.connectionParameters.nativeConnectionString),n)return e(n);t.native.connect(r,function(n){if(n)return t.native.end(),e(n);t._connected=!0,t.native.on(`error`,function(e){t._queryable=!1,t._errorAllQueries(e),t.emit(`error`,e)}),t.native.on(`notification`,function(e){t.emit(`notification`,{channel:e.relname,payload:e.extra})}),t.emit(`connect`),t._pulseQueryQueue(!0),e()})})},l.prototype.connect=function(e){if(e){this._connect(e);return}return new this._Promise((e,t)=>{this._connect(n=>{n?t(n):e()})})},l.prototype.query=function(e,t,n){let r,i,a,o,s;if(e==null)throw TypeError(`Client was passed a null or undefined query`);if(typeof e.submit==`function`)a=e.query_timeout||this.connectionParameters.query_timeout,i=r=e,typeof t==`function`&&(e.callback=t);else if(a=e.query_timeout||this.connectionParameters.query_timeout,r=new c(e,t,n),!r.callback){let e,t;i=new this._Promise((n,r)=>{e=n,t=r}).catch(e=>{throw Error.captureStackTrace(e),e}),r.callback=(n,r)=>n?t(n):e(r)}return a&&(s=r.callback,o=setTimeout(()=>{let e=Error(`Query read timeout`);process.nextTick(()=>{r.handleError(e,this.connection)}),s(e),r.callback=()=>{};let t=this._queryQueue.indexOf(r);t>-1&&this._queryQueue.splice(t,1),this._pulseQueryQueue()},a),r.callback=(e,t)=>{clearTimeout(o),s(e,t)}),this._queryable?this._ending?(r.native=this.native,process.nextTick(()=>{r.handleError(Error(`Client was closed and is not queryable`))}),i):(this._queryQueue.push(r),this._pulseQueryQueue(),i):(r.native=this.native,process.nextTick(()=>{r.handleError(Error(`Client has encountered a connection error and is not queryable`))}),i)},l.prototype.end=function(e){let t=this;this._ending=!0,this._connected||this.once(`connect`,this.end.bind(this,e));let n;return e||(n=new this._Promise(function(t,n){e=e=>e?n(e):t()})),this.native.end(function(){t._errorAllQueries(Error(`Connection terminated`)),process.nextTick(()=>{t.emit(`end`),e&&e()})}),n},l.prototype._hasActiveQuery=function(){return this._activeQuery&&this._activeQuery.state!==`error`&&this._activeQuery.state!==`end`},l.prototype._pulseQueryQueue=function(e){if(!this._connected||this._hasActiveQuery())return;let t=this._queryQueue.shift();if(!t){e||this.emit(`drain`);return}this._activeQuery=t,t.submit(this);let n=this;t.once(`_done`,function(){n._pulseQueryQueue()})},l.prototype.cancel=function(e){this._activeQuery===e?this.native.cancel(function(){}):this._queryQueue.indexOf(e)!==-1&&this._queryQueue.splice(this._queryQueue.indexOf(e),1)},l.prototype.ref=function(){},l.prototype.unref=function(){},l.prototype.setTypeParser=function(e,t,n){return this._types.setTypeParser(e,t,n)},l.prototype.getTypeParser=function(e,t){return this._types.getTypeParser(e,t)}})),H=n(((e,t)=>{t.exports=V()})),U=n(((e,t)=>{let n=R(),r=m(),i=P(),a=w(),o=h(),s=z(),c=x(),{DatabaseError:l}=j(),{escapeIdentifier:u,escapeLiteral:d}=h(),f=e=>class extends s{constructor(t){super(t,e)}},g=function(e){this.defaults=r,this.Client=e,this.Query=this.Client.Query,this.Pool=f(this.Client),this._pools=[],this.Connection=i,this.types=p(),this.DatabaseError=l,this.TypeOverrides=c,this.escapeIdentifier=u,this.escapeLiteral=d,this.Result=a,this.utils=o};process.env.NODE_PG_FORCE_NATIVE===void 0?(t.exports=new g(n),Object.defineProperty(t.exports,`native`,{configurable:!0,enumerable:!1,get(){let e=null;try{e=new g(H())}catch(e){if(e.code!==`MODULE_NOT_FOUND`)throw e}return Object.defineProperty(t.exports,`native`,{value:e}),e}})):t.exports=new g(H())})),W=t(U(),1);W.default.Client,W.default.Pool,W.default.Connection,W.default.types,W.default.Query,W.default.DatabaseError,W.default.escapeIdentifier,W.default.escapeLiteral,W.default.Result,W.default.TypeOverrides,W.default.defaults;var G=W.default;export{S as a,j as i,L as n,p as o,M as r,G as t};
|