@event-driven-io/dumbo 0.11.1 → 0.12.0-alpha.2
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/index.cjs +17 -6
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +22 -3
- package/dist/index.d.ts +22 -3
- package/dist/index.js +17 -6
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -220,12 +220,16 @@ interface ObjectCodec<T, Payload> {
|
|
|
220
220
|
decode(payload: Payload): T;
|
|
221
221
|
}
|
|
222
222
|
|
|
223
|
+
declare const prettyJson: (obj: unknown, options?: {
|
|
224
|
+
handleMultiline?: boolean;
|
|
225
|
+
}) => string;
|
|
226
|
+
|
|
223
227
|
declare const tracer: {
|
|
224
228
|
(): void;
|
|
225
|
-
|
|
229
|
+
info(eventName: string, attributes?: Record<string, any>): void;
|
|
226
230
|
warn(eventName: string, attributes?: Record<string, any>): void;
|
|
231
|
+
log(eventName: string, attributes?: Record<string, any>): void;
|
|
227
232
|
error(eventName: string, attributes?: Record<string, any>): void;
|
|
228
|
-
info(eventName: string, attributes?: Record<string, any>): void;
|
|
229
233
|
};
|
|
230
234
|
type LogLevel = 'DISABLED' | 'INFO' | 'LOG' | 'WARN' | 'ERROR';
|
|
231
235
|
declare const LogLevel: {
|
|
@@ -235,6 +239,12 @@ declare const LogLevel: {
|
|
|
235
239
|
WARN: LogLevel;
|
|
236
240
|
ERROR: LogLevel;
|
|
237
241
|
};
|
|
242
|
+
type LogType = 'CONSOLE';
|
|
243
|
+
type LogStyle = 'RAW' | 'PRETTY';
|
|
244
|
+
declare const LogStyle: {
|
|
245
|
+
RAW: LogStyle;
|
|
246
|
+
PRETTY: LogStyle;
|
|
247
|
+
};
|
|
238
248
|
|
|
239
249
|
type DatabaseLockOptions = {
|
|
240
250
|
lockId: number;
|
|
@@ -309,6 +319,15 @@ declare const nodePostgresClientConnection: (options: NodePostgresClientOptions)
|
|
|
309
319
|
declare const nodePostgresPoolClientConnection: (options: NodePostgresPoolClientOptions) => NodePostgresPoolClientConnection;
|
|
310
320
|
declare function nodePostgresConnection(options: NodePostgresPoolClientOptions): NodePostgresPoolClientConnection;
|
|
311
321
|
declare function nodePostgresConnection(options: NodePostgresClientOptions): NodePostgresClientConnection;
|
|
322
|
+
type ConnectionCheckResult = {
|
|
323
|
+
successful: true;
|
|
324
|
+
} | {
|
|
325
|
+
successful: false;
|
|
326
|
+
code: string | undefined;
|
|
327
|
+
errorType: 'ConnectionRefused' | 'Authentication' | 'Unknown';
|
|
328
|
+
error: unknown;
|
|
329
|
+
};
|
|
330
|
+
declare const checkConnection: (connectionString: string) => Promise<ConnectionCheckResult>;
|
|
312
331
|
|
|
313
332
|
type NodePostgresNativePool = ConnectionPool<NodePostgresPoolClientConnection>;
|
|
314
333
|
type NodePostgresAmbientClientPool = ConnectionPool<NodePostgresClientConnection>;
|
|
@@ -421,4 +440,4 @@ type Dumbo = PostgresPool;
|
|
|
421
440
|
declare const connectionPool: <PoolOptionsType extends DumboOptions>(options: PoolOptionsType) => NodePostgresNativePool;
|
|
422
441
|
declare const dumbo: <DumboOptionsType extends DumboOptions = DumboOptions>(options: DumboOptionsType) => Dumbo;
|
|
423
442
|
|
|
424
|
-
export { type AcquireDatabaseLockMode, type AcquireDatabaseLockOptions, AdvisoryLock, type BatchQueryOptions, type Connection, type ConnectionFactory, type ConnectionPool, type ConnectionPoolFactory, type ConnectorType, type CountSQLQueryResult, type CreateConnectionOptions, type DatabaseLock, type DatabaseLockOptions, type DatabaseTransaction, type DatabaseTransactionFactory, type DbSQLExecutor, type Dumbo, type DumboOptions, type ExistsSQLQueryResult, JSONObjectCodec, type JSONObjectCodecOptions, JSONReplacer, JSONReplacers, JSONReviver, JSONRevivers, JSONSerializer, LogLevel, MIGRATIONS_LOCK_ID, type MigrationRecord, type MigrationStyle, type MigratorOptions, type NodePostgresAmbientClientPool, type NodePostgresAmbientConnectionPool, type NodePostgresClient, type NodePostgresClientConnection, type NodePostgresClientOptions, type NodePostgresConnection, type NodePostgresConnector, NodePostgresConnectorType, type NodePostgresNativePool, type NodePostgresPool, type NodePostgresPoolClientConnection, type NodePostgresPoolClientOptions, type NodePostgresPoolNotPooledOptions, type NodePostgresPoolOptions, type NodePostgresPoolOrClient, type NodePostgresPoolPooledOptions, type NodePostgresSQLExecutor, type NodePostgresTransaction, type ObjectCodec, type PoolOptions, type PostgreSQLMigratorOptions, type PostgresConnection, type PostgresConnector, type PostgresPool, type PostgresPoolOptions, type QueryResult, type QueryResultRow, RawJSONSerializer, type ReleaseDatabaseLockOptions, SQL, type SQLCommandOptions, type SQLExecutor, type SQLMigration, type SQLQueryOptions, type SchemaComponent, type SchemaComponentMigrationsOptions, type Serializer, type TransactionResult, type WithSQLExecutor, acquireAdvisoryLock, advisoryLock, combineMigrations, composeJSONReplacers, composeJSONRevivers, connectionPool, count, createConnection, createConnectionPool, defaultDatabaseLockOptions, defaultPostgreSQLConenctionString, defaultPostgreSqlDatabase, dumbo, endAllPools, endPool, executeInNewConnection, executeInNewDbClient, executeInTransaction, exists, first, firstOrNull, functionExists, functionExistsSQL, getDatabaseNameOrDefault, getPool, identifier, isNodePostgresClient, isNodePostgresNativePool, isNodePostgresPoolClient, isSQL, jsonSerializer, literal, mapRows, mapToCamelCase, migrationTableSchemaComponent, nodePostgresAmbientClientPool, nodePostgresAmbientConnectionPool, nodePostgresAmbientNativePool, nodePostgresClientConnection, nodePostgresClientPool, nodePostgresConnection, nodePostgresExecute, nodePostgresNativePool, nodePostgresPool, nodePostgresPoolClientConnection, nodePostgresSQLExecutor, nodePostgresTransaction, onEndPool, plainString, postgresPool, rawSql, releaseAdvisoryLock, runPostgreSQLMigrations, runSQLMigrations, schemaComponent, setNodePostgresTypeParser, single, singleOrNull, sql, sqlExecutor, sqlExecutorInNewConnection, sqlMigration, tableExists, tableExistsSQL, toCamelCase, tracer, transactionFactoryWithDbClient, transactionFactoryWithNewConnection, tryAcquireAdvisoryLock };
|
|
443
|
+
export { type AcquireDatabaseLockMode, type AcquireDatabaseLockOptions, AdvisoryLock, type BatchQueryOptions, type Connection, type ConnectionCheckResult, type ConnectionFactory, type ConnectionPool, type ConnectionPoolFactory, type ConnectorType, type CountSQLQueryResult, type CreateConnectionOptions, type DatabaseLock, type DatabaseLockOptions, type DatabaseTransaction, type DatabaseTransactionFactory, type DbSQLExecutor, type Dumbo, type DumboOptions, type ExistsSQLQueryResult, JSONObjectCodec, type JSONObjectCodecOptions, JSONReplacer, JSONReplacers, JSONReviver, JSONRevivers, JSONSerializer, LogLevel, LogStyle, type LogType, MIGRATIONS_LOCK_ID, type MigrationRecord, type MigrationStyle, type MigratorOptions, type NodePostgresAmbientClientPool, type NodePostgresAmbientConnectionPool, type NodePostgresClient, type NodePostgresClientConnection, type NodePostgresClientOptions, type NodePostgresConnection, type NodePostgresConnector, NodePostgresConnectorType, type NodePostgresNativePool, type NodePostgresPool, type NodePostgresPoolClientConnection, type NodePostgresPoolClientOptions, type NodePostgresPoolNotPooledOptions, type NodePostgresPoolOptions, type NodePostgresPoolOrClient, type NodePostgresPoolPooledOptions, type NodePostgresSQLExecutor, type NodePostgresTransaction, type ObjectCodec, type PoolOptions, type PostgreSQLMigratorOptions, type PostgresConnection, type PostgresConnector, type PostgresPool, type PostgresPoolOptions, type QueryResult, type QueryResultRow, RawJSONSerializer, type ReleaseDatabaseLockOptions, SQL, type SQLCommandOptions, type SQLExecutor, type SQLMigration, type SQLQueryOptions, type SchemaComponent, type SchemaComponentMigrationsOptions, type Serializer, type TransactionResult, type WithSQLExecutor, acquireAdvisoryLock, advisoryLock, checkConnection, combineMigrations, composeJSONReplacers, composeJSONRevivers, connectionPool, count, createConnection, createConnectionPool, defaultDatabaseLockOptions, defaultPostgreSQLConenctionString, defaultPostgreSqlDatabase, dumbo, endAllPools, endPool, executeInNewConnection, executeInNewDbClient, executeInTransaction, exists, first, firstOrNull, functionExists, functionExistsSQL, getDatabaseNameOrDefault, getPool, identifier, isNodePostgresClient, isNodePostgresNativePool, isNodePostgresPoolClient, isSQL, jsonSerializer, literal, mapRows, mapToCamelCase, migrationTableSchemaComponent, nodePostgresAmbientClientPool, nodePostgresAmbientConnectionPool, nodePostgresAmbientNativePool, nodePostgresClientConnection, nodePostgresClientPool, nodePostgresConnection, nodePostgresExecute, nodePostgresNativePool, nodePostgresPool, nodePostgresPoolClientConnection, nodePostgresSQLExecutor, nodePostgresTransaction, onEndPool, plainString, postgresPool, prettyJson, rawSql, releaseAdvisoryLock, runPostgreSQLMigrations, runSQLMigrations, schemaComponent, setNodePostgresTypeParser, single, singleOrNull, sql, sqlExecutor, sqlExecutorInNewConnection, sqlMigration, tableExists, tableExistsSQL, toCamelCase, tracer, transactionFactoryWithDbClient, transactionFactoryWithNewConnection, tryAcquireAdvisoryLock };
|
package/dist/index.d.ts
CHANGED
|
@@ -220,12 +220,16 @@ interface ObjectCodec<T, Payload> {
|
|
|
220
220
|
decode(payload: Payload): T;
|
|
221
221
|
}
|
|
222
222
|
|
|
223
|
+
declare const prettyJson: (obj: unknown, options?: {
|
|
224
|
+
handleMultiline?: boolean;
|
|
225
|
+
}) => string;
|
|
226
|
+
|
|
223
227
|
declare const tracer: {
|
|
224
228
|
(): void;
|
|
225
|
-
|
|
229
|
+
info(eventName: string, attributes?: Record<string, any>): void;
|
|
226
230
|
warn(eventName: string, attributes?: Record<string, any>): void;
|
|
231
|
+
log(eventName: string, attributes?: Record<string, any>): void;
|
|
227
232
|
error(eventName: string, attributes?: Record<string, any>): void;
|
|
228
|
-
info(eventName: string, attributes?: Record<string, any>): void;
|
|
229
233
|
};
|
|
230
234
|
type LogLevel = 'DISABLED' | 'INFO' | 'LOG' | 'WARN' | 'ERROR';
|
|
231
235
|
declare const LogLevel: {
|
|
@@ -235,6 +239,12 @@ declare const LogLevel: {
|
|
|
235
239
|
WARN: LogLevel;
|
|
236
240
|
ERROR: LogLevel;
|
|
237
241
|
};
|
|
242
|
+
type LogType = 'CONSOLE';
|
|
243
|
+
type LogStyle = 'RAW' | 'PRETTY';
|
|
244
|
+
declare const LogStyle: {
|
|
245
|
+
RAW: LogStyle;
|
|
246
|
+
PRETTY: LogStyle;
|
|
247
|
+
};
|
|
238
248
|
|
|
239
249
|
type DatabaseLockOptions = {
|
|
240
250
|
lockId: number;
|
|
@@ -309,6 +319,15 @@ declare const nodePostgresClientConnection: (options: NodePostgresClientOptions)
|
|
|
309
319
|
declare const nodePostgresPoolClientConnection: (options: NodePostgresPoolClientOptions) => NodePostgresPoolClientConnection;
|
|
310
320
|
declare function nodePostgresConnection(options: NodePostgresPoolClientOptions): NodePostgresPoolClientConnection;
|
|
311
321
|
declare function nodePostgresConnection(options: NodePostgresClientOptions): NodePostgresClientConnection;
|
|
322
|
+
type ConnectionCheckResult = {
|
|
323
|
+
successful: true;
|
|
324
|
+
} | {
|
|
325
|
+
successful: false;
|
|
326
|
+
code: string | undefined;
|
|
327
|
+
errorType: 'ConnectionRefused' | 'Authentication' | 'Unknown';
|
|
328
|
+
error: unknown;
|
|
329
|
+
};
|
|
330
|
+
declare const checkConnection: (connectionString: string) => Promise<ConnectionCheckResult>;
|
|
312
331
|
|
|
313
332
|
type NodePostgresNativePool = ConnectionPool<NodePostgresPoolClientConnection>;
|
|
314
333
|
type NodePostgresAmbientClientPool = ConnectionPool<NodePostgresClientConnection>;
|
|
@@ -421,4 +440,4 @@ type Dumbo = PostgresPool;
|
|
|
421
440
|
declare const connectionPool: <PoolOptionsType extends DumboOptions>(options: PoolOptionsType) => NodePostgresNativePool;
|
|
422
441
|
declare const dumbo: <DumboOptionsType extends DumboOptions = DumboOptions>(options: DumboOptionsType) => Dumbo;
|
|
423
442
|
|
|
424
|
-
export { type AcquireDatabaseLockMode, type AcquireDatabaseLockOptions, AdvisoryLock, type BatchQueryOptions, type Connection, type ConnectionFactory, type ConnectionPool, type ConnectionPoolFactory, type ConnectorType, type CountSQLQueryResult, type CreateConnectionOptions, type DatabaseLock, type DatabaseLockOptions, type DatabaseTransaction, type DatabaseTransactionFactory, type DbSQLExecutor, type Dumbo, type DumboOptions, type ExistsSQLQueryResult, JSONObjectCodec, type JSONObjectCodecOptions, JSONReplacer, JSONReplacers, JSONReviver, JSONRevivers, JSONSerializer, LogLevel, MIGRATIONS_LOCK_ID, type MigrationRecord, type MigrationStyle, type MigratorOptions, type NodePostgresAmbientClientPool, type NodePostgresAmbientConnectionPool, type NodePostgresClient, type NodePostgresClientConnection, type NodePostgresClientOptions, type NodePostgresConnection, type NodePostgresConnector, NodePostgresConnectorType, type NodePostgresNativePool, type NodePostgresPool, type NodePostgresPoolClientConnection, type NodePostgresPoolClientOptions, type NodePostgresPoolNotPooledOptions, type NodePostgresPoolOptions, type NodePostgresPoolOrClient, type NodePostgresPoolPooledOptions, type NodePostgresSQLExecutor, type NodePostgresTransaction, type ObjectCodec, type PoolOptions, type PostgreSQLMigratorOptions, type PostgresConnection, type PostgresConnector, type PostgresPool, type PostgresPoolOptions, type QueryResult, type QueryResultRow, RawJSONSerializer, type ReleaseDatabaseLockOptions, SQL, type SQLCommandOptions, type SQLExecutor, type SQLMigration, type SQLQueryOptions, type SchemaComponent, type SchemaComponentMigrationsOptions, type Serializer, type TransactionResult, type WithSQLExecutor, acquireAdvisoryLock, advisoryLock, combineMigrations, composeJSONReplacers, composeJSONRevivers, connectionPool, count, createConnection, createConnectionPool, defaultDatabaseLockOptions, defaultPostgreSQLConenctionString, defaultPostgreSqlDatabase, dumbo, endAllPools, endPool, executeInNewConnection, executeInNewDbClient, executeInTransaction, exists, first, firstOrNull, functionExists, functionExistsSQL, getDatabaseNameOrDefault, getPool, identifier, isNodePostgresClient, isNodePostgresNativePool, isNodePostgresPoolClient, isSQL, jsonSerializer, literal, mapRows, mapToCamelCase, migrationTableSchemaComponent, nodePostgresAmbientClientPool, nodePostgresAmbientConnectionPool, nodePostgresAmbientNativePool, nodePostgresClientConnection, nodePostgresClientPool, nodePostgresConnection, nodePostgresExecute, nodePostgresNativePool, nodePostgresPool, nodePostgresPoolClientConnection, nodePostgresSQLExecutor, nodePostgresTransaction, onEndPool, plainString, postgresPool, rawSql, releaseAdvisoryLock, runPostgreSQLMigrations, runSQLMigrations, schemaComponent, setNodePostgresTypeParser, single, singleOrNull, sql, sqlExecutor, sqlExecutorInNewConnection, sqlMigration, tableExists, tableExistsSQL, toCamelCase, tracer, transactionFactoryWithDbClient, transactionFactoryWithNewConnection, tryAcquireAdvisoryLock };
|
|
443
|
+
export { type AcquireDatabaseLockMode, type AcquireDatabaseLockOptions, AdvisoryLock, type BatchQueryOptions, type Connection, type ConnectionCheckResult, type ConnectionFactory, type ConnectionPool, type ConnectionPoolFactory, type ConnectorType, type CountSQLQueryResult, type CreateConnectionOptions, type DatabaseLock, type DatabaseLockOptions, type DatabaseTransaction, type DatabaseTransactionFactory, type DbSQLExecutor, type Dumbo, type DumboOptions, type ExistsSQLQueryResult, JSONObjectCodec, type JSONObjectCodecOptions, JSONReplacer, JSONReplacers, JSONReviver, JSONRevivers, JSONSerializer, LogLevel, LogStyle, type LogType, MIGRATIONS_LOCK_ID, type MigrationRecord, type MigrationStyle, type MigratorOptions, type NodePostgresAmbientClientPool, type NodePostgresAmbientConnectionPool, type NodePostgresClient, type NodePostgresClientConnection, type NodePostgresClientOptions, type NodePostgresConnection, type NodePostgresConnector, NodePostgresConnectorType, type NodePostgresNativePool, type NodePostgresPool, type NodePostgresPoolClientConnection, type NodePostgresPoolClientOptions, type NodePostgresPoolNotPooledOptions, type NodePostgresPoolOptions, type NodePostgresPoolOrClient, type NodePostgresPoolPooledOptions, type NodePostgresSQLExecutor, type NodePostgresTransaction, type ObjectCodec, type PoolOptions, type PostgreSQLMigratorOptions, type PostgresConnection, type PostgresConnector, type PostgresPool, type PostgresPoolOptions, type QueryResult, type QueryResultRow, RawJSONSerializer, type ReleaseDatabaseLockOptions, SQL, type SQLCommandOptions, type SQLExecutor, type SQLMigration, type SQLQueryOptions, type SchemaComponent, type SchemaComponentMigrationsOptions, type Serializer, type TransactionResult, type WithSQLExecutor, acquireAdvisoryLock, advisoryLock, checkConnection, combineMigrations, composeJSONReplacers, composeJSONRevivers, connectionPool, count, createConnection, createConnectionPool, defaultDatabaseLockOptions, defaultPostgreSQLConenctionString, defaultPostgreSqlDatabase, dumbo, endAllPools, endPool, executeInNewConnection, executeInNewDbClient, executeInTransaction, exists, first, firstOrNull, functionExists, functionExistsSQL, getDatabaseNameOrDefault, getPool, identifier, isNodePostgresClient, isNodePostgresNativePool, isNodePostgresPoolClient, isSQL, jsonSerializer, literal, mapRows, mapToCamelCase, migrationTableSchemaComponent, nodePostgresAmbientClientPool, nodePostgresAmbientConnectionPool, nodePostgresAmbientNativePool, nodePostgresClientConnection, nodePostgresClientPool, nodePostgresConnection, nodePostgresExecute, nodePostgresNativePool, nodePostgresPool, nodePostgresPoolClientConnection, nodePostgresSQLExecutor, nodePostgresTransaction, onEndPool, plainString, postgresPool, prettyJson, rawSql, releaseAdvisoryLock, runPostgreSQLMigrations, runSQLMigrations, schemaComponent, setNodePostgresTypeParser, single, singleOrNull, sql, sqlExecutor, sqlExecutorInNewConnection, sqlMigration, tableExists, tableExistsSQL, toCamelCase, tracer, transactionFactoryWithDbClient, transactionFactoryWithNewConnection, tryAcquireAdvisoryLock };
|
package/dist/index.js
CHANGED
|
@@ -1,8 +1,19 @@
|
|
|
1
|
-
var
|
|
2
|
-
`),
|
|
1
|
+
var Ne=(e,t)=>typeof t=="bigint"?t.toString():t,be=(e,t)=>typeof t=="string"&&/^[+-]?\d+n?$/.test(t)?BigInt(t):t,Ee=(...e)=>(t,o)=>e.reduce((n,r)=>r(t,n),o),we=(...e)=>(t,o)=>e.reduce((n,r)=>r(t,n),o),j=e=>e?.disableBigIntSerialization==!0?e.replacer?e.replacer:void 0:e?.replacer?Ee(V.bigInt,e.replacer):V.bigInt,K=e=>e?.disableBigIntSerialization==!0?e.reviver?e.reviver:void 0:e?.reviver?we(X.bigInt,e.reviver):X.bigInt,V={bigInt:Ne},X={bigInt:be},Z=e=>{let t=j(e),o=K(e);return{serialize:(n,r)=>JSON.stringify(n,r?j(r):t),deserialize:(n,r)=>JSON.parse(n,r?K(r):o)}},C=Z({disableBigIntSerialization:!1}),yt=Z({disableBigIntSerialization:!0});var De={AES128:!0,AES256:!0,ALL:!0,ALLOWOVERWRITE:!0,ANALYSE:!0,ANALYZE:!0,AND:!0,ANY:!0,ARRAY:!0,AS:!0,ASC:!0,AUTHORIZATION:!0,BACKUP:!0,BETWEEN:!0,BINARY:!0,BLANKSASNULL:!0,BOTH:!0,BYTEDICT:!0,CASE:!0,CAST:!0,CHECK:!0,COLLATE:!0,COLUMN:!0,CONSTRAINT:!0,CREATE:!0,CREDENTIALS:!0,CROSS:!0,CURRENT_DATE:!0,CURRENT_TIME:!0,CURRENT_TIMESTAMP:!0,CURRENT_USER:!0,CURRENT_USER_ID:!0,DEFAULT:!0,DEFERRABLE:!0,DEFLATE:!0,DEFRAG:!0,DELTA:!0,DELTA32K:!0,DESC:!0,DISABLE:!0,DISTINCT:!0,DO:!0,ELSE:!0,EMPTYASNULL:!0,ENABLE:!0,ENCODE:!0,ENCRYPT:!0,ENCRYPTION:!0,END:!0,EXCEPT:!0,EXPLICIT:!0,FALSE:!0,FOR:!0,FOREIGN:!0,FREEZE:!0,FROM:!0,FULL:!0,GLOBALDICT256:!0,GLOBALDICT64K:!0,GRANT:!0,GROUP:!0,GZIP:!0,HAVING:!0,IDENTITY:!0,IGNORE:!0,ILIKE:!0,IN:!0,INITIALLY:!0,INNER:!0,INTERSECT:!0,INTO:!0,IS:!0,ISNULL:!0,JOIN:!0,LEADING:!0,LEFT:!0,LIKE:!0,LIMIT:!0,LOCALTIME:!0,LOCALTIMESTAMP:!0,LUN:!0,LUNS:!0,LZO:!0,LZOP:!0,MINUS:!0,MOSTLY13:!0,MOSTLY32:!0,MOSTLY8:!0,NATURAL:!0,NEW:!0,NOT:!0,NOTNULL:!0,NULL:!0,NULLS:!0,OFF:!0,OFFLINE:!0,OFFSET:!0,OLD:!0,ON:!0,ONLY:!0,OPEN:!0,OR:!0,ORDER:!0,OUTER:!0,OVERLAPS:!0,PARALLEL:!0,PARTITION:!0,PERCENT:!0,PLACING:!0,PRIMARY:!0,RAW:!0,READRATIO:!0,RECOVER:!0,REFERENCES:!0,REJECTLOG:!0,RESORT:!0,RESTORE:!0,RIGHT:!0,SELECT:!0,SESSION_USER:!0,SIMILAR:!0,SOME:!0,SYSDATE:!0,SYSTEM:!0,TABLE:!0,TAG:!0,TDES:!0,TEXT255:!0,TEXT32K:!0,THEN:!0,TO:!0,TOP:!0,TRAILING:!0,TRUE:!0,TRUNCATECOLUMNS:!0,UNION:!0,UNIQUE:!0,USER:!0,USING:!0,VERBOSE:!0,WALLET:!0,WHEN:!0,WHERE:!0,WITH:!0,WITHOUT:!0},ee=De;var l={ident:"I",literal:"L",string:"s"},z=e=>(e=e.replace("T"," "),e=e.replace("Z","+00"),e),Qe=e=>!!ee[e.toUpperCase()],te=(e,t,o)=>{let n="";n+=e?" (":"(";for(let r=0;r<t.length;r++)n+=(r===0?"":", ")+o(t[r]);return n+=")",n},J=e=>{if(e==null)throw new Error("SQL identifier cannot be null or undefined");if(e===!1)return'"f"';if(e===!0)return'"t"';if(e instanceof Date)return'"'+z(e.toISOString())+'"';if(e instanceof Buffer)throw new Error("SQL identifier cannot be a buffer");if(Array.isArray(e))return e.map(n=>{if(Array.isArray(n))throw new Error("Nested array to grouped list conversion is not supported for SQL identifier");return J(n)}).toString();if(e===Object(e))throw new Error("SQL identifier cannot be an object");let t=e.toString().slice(0);if(/^[a-z_][a-z0-9_$]*$/.test(t)&&!Qe(t))return t;let o='"';for(let n=0;n<t.length;n++){let r=t[n];o+=r==='"'?r+r:r}return o+='"',o},b=e=>{let t=null,o=null;if(e==null)return"NULL";if(e===!1)return"'f'";if(e===!0)return"'t'";if(e instanceof Date)return"'"+z(e.toISOString())+"'";if(e instanceof Buffer)return"E'\\\\x"+e.toString("hex")+"'";if(Array.isArray(e))return e.map((s,i)=>Array.isArray(s)?te(i!==0,s,b):b(s)).toString();e===Object(e)?(o="jsonb",t=C.serialize(e)):t=e.toString().slice(0);let n=!1,r="'";for(let s=0;s<t.length;s++){let i=t[s];i==="'"?r+=i+i:i==="\\"?(r+=i+i,n=!0):r+=i}return r+="'",n&&(r="E"+r),o&&(r+="::"+o),r},E=e=>e==null?"":e===!1?"f":e===!0?"t":e instanceof Date?z(e.toISOString()):e instanceof Buffer?"\\x"+e.toString("hex"):Array.isArray(e)?e.map((t,o)=>t!=null?Array.isArray(t)?te(o!==0,t,E):E(t):"").filter(t=>t!=="").toString():e===Object(e)?C.serialize(e):e.toString().slice(0),Ae=e=>{l.ident="I",l.literal="L",l.string="s",e&&e.pattern&&(e.pattern.ident&&(l.ident=e.pattern.ident),e.pattern.literal&&(l.literal=e.pattern.literal),e.pattern.string&&(l.string=e.pattern.string))},oe=(e,t)=>{let o=0,n=t,r="%(%|(\\d+\\$)?[";return r+=l.ident,r+=l.literal,r+=l.string,r+="])",r=new RegExp(r,"g"),e.replace(r,(s,i)=>{if(i==="%")return"%";let a=o,y=i.split("$");if(y.length>1&&(a=parseInt(y[0],10)-1,i=y[1]),a<0)throw new Error("specified argument 0 but arguments start at 1");if(a>n.length-1)throw new Error("too few arguments");if(o=a+1,i===l.ident)return J(n[a]);if(i===l.literal)return b(n[a]);if(i===l.string)return E(n[a])})},m=(e,...t)=>oe(e,t);m.config=Ae;m.format=m;m.ident=J;m.literal=b;m.string=E;m.withArray=oe;var g=m;var d=(e,...t)=>g(e,...t),O=e=>e,Ot=e=>e!=null&&typeof e=="string",Lt=e=>({type:"literal",value:e}),xt=e=>({type:"identifier",value:e}),Tt=e=>({type:"plainString",value:e}),he=e=>typeof e=="string"?g("%L",e):typeof e=="number"?e.toString():typeof e=="bigint"?g("%L",e):e instanceof Date?g("%L",e):Array.isArray(e)?g("(%L)",e):g("%L",e);function Nt(e,...t){return e.map((o,n)=>{let r="";if(n<t.length){let s=t[n];if(s&&typeof s=="object"&&"type"in s&&"value"in s){let i=s;switch(i.type){case"literal":r=g("%L",i.value);break;case"identifier":r=g("%I",i.value);break;case"plainString":r=i.value;break}}else r=he(s)}return o+r}).join("")}var D=(e,t)=>({query:(o,n)=>w(r=>e.query(r,o,n),t),batchQuery:(o,n)=>w(r=>e.batchQuery(r,o,n),t),command:(o,n)=>w(r=>e.command(r,o,n),t),batchCommand:(o,n)=>w(r=>e.batchQuery(r,o,n),t)}),ne=e=>({query:t=>R(o=>o.execute.query(t),e),batchQuery:t=>R(o=>o.execute.batchQuery(t),e),command:t=>R(o=>o.execute.command(t),e),batchCommand:t=>R(o=>o.execute.batchCommand(t),e)}),w=async(e,t)=>{let{connect:o,close:n}=t,r=await o();try{return await e(r)}catch(s){throw n&&await n(r,s),s}},R=async(e,t)=>{let o=await t.connection();try{return await e(o)}finally{await o.close()}};var ke=e=>e!=null&&typeof e=="object"&&"success"in e?e:{success:!0,result:e},Ie=async(e,t)=>{await e.begin();try{let{success:o,result:n}=ke(await t(e));return o?await e.commit():await e.rollback(),n}catch(o){throw await e.rollback(),o}},re=(e,t)=>({transaction:()=>t(e()),withTransaction:o=>Ie(t(e()),o)}),F=async(e,t)=>{try{return await t()}finally{await e.close()}},se=e=>({transaction:()=>{let t=e(),o=t.transaction();return{...o,commit:()=>F(t,()=>o.commit()),rollback:()=>F(t,()=>o.rollback())}},withTransaction:t=>{let o=e();return F(o,()=>o.withTransaction(t))}});var v=e=>{let{type:t,connect:o,close:n,initTransaction:r,executor:s}=e,i=null,a=async()=>i??(i=await o),P={type:t,open:a,close:()=>i?n(i):Promise.resolve(),...re(a,r(()=>P)),execute:D(s(),{connect:a})};return P};var S=e=>{let{type:t,getConnection:o}=e,n="connection"in e?e.connection:()=>Promise.resolve(o()),r="withConnection"in e?e.withConnection:P=>R(P,{connection:n}),s="close"in e?e.close:()=>Promise.resolve(),i="execute"in e?e.execute:ne({connection:n}),a="transaction"in e&&"withTransaction"in e?{transaction:e.transaction,withTransaction:e.withTransaction}:se(o);return{type:t,connection:n,withConnection:r,close:s,execute:i,...a}};var Wt=async(e,t)=>(await e).rows.map(t),Me=e=>e.replace(/_([a-z])/g,t=>t[1]?.toUpperCase()??""),ie=e=>{let t={};for(let o in e)Object.prototype.hasOwnProperty.call(e,o)&&(t[Me(o)]=e[o]);return t};var Yt=async e=>{let t=await e;return t.rows.length>0?t.rows[0]??null:null},Ht=async e=>{let t=await e;if(t.rows.length===0)throw new Error("Query didn't return any result");return t.rows[0]},ce=async e=>{let t=await e;if(t.rows.length>1)throw new Error("Query had more than one result");return t.rows.length>0?t.rows[0]??null:null},L=async e=>{let t=await e;if(t.rows.length===0)throw new Error("Query didn't return any result");if(t.rows.length>1)throw new Error("Query had more than one result");return t.rows[0]},$t=async e=>(await L(e)).count,U=async e=>(await L(e)).exists===!0;var ae=(e,t)=>({name:e,sqls:t}),_=999956789,le=(e,t,o)=>e.withTransaction(async({execute:n})=>{let{databaseLock:r,...s}=o.lock,i={lockId:_,...s},a=o.schema.migrationTable.migrations({connector:"PostgreSQL:pg"});return await r.withAcquire(n,async()=>{for(let y of a){let P=ue(y);await n.command(O(P))}for(let y of t)await qe(n,y)},i),{success:!o.dryRun,result:void 0}}),qe=async(e,t)=>{let o=ue(t),n=await ze(o);try{let r={name:t.name,sqlHash:n};if(await Je(e,r))return;await e.command(O(o)),await Fe(e,r)}catch(r){throw p.error("migration-error",{migationName:t.name,error:r}),r}},ze=async e=>{let o=new TextEncoder().encode(e),n=await crypto.subtle.digest("SHA-256",o);return Array.from(new Uint8Array(n)).map(s=>s.toString(16).padStart(2,"0")).join("")},ue=(...e)=>e.flatMap(t=>t.sqls).join(`
|
|
2
|
+
`),Je=async(e,t)=>{let o=await ce(e.query(d("SELECT sql_hash FROM migrations WHERE name = %L",t.name)));if(o===null)return!1;let{sqlHash:n}=ie(o);if(n!==t.sqlHash)throw new Error(`Migration hash mismatch for "${t.name}". Aborting migration.`);return!0},Fe=async(e,t)=>{await e.command(d(`
|
|
3
3
|
INSERT INTO migrations (name, sql_hash)
|
|
4
4
|
VALUES (%L, %L)
|
|
5
|
-
`,t.name,t.sqlHash))};var
|
|
5
|
+
`,t.name,t.sqlHash))};var pe=(e,t)=>{let o="components"in t?t.components:void 0,n="migrations"in t?t.migrations:void 0;return{schemaComponentType:e,components:o,migrations:r=>[...n?n(r):[],...o?o.flatMap(s=>s.migrations(r)):[]]}};import f from"chalk";var ye=" ",Q=f.hex("#98c379"),ve=f.hex("#61afef"),Ue=f.hex("#d19a66"),_e=f.hex("#c678dd"),Be=f.hex("#c678dd"),A=f.hex("#abb2bf"),We=(e,t,o)=>{if(o&&e.includes(`
|
|
6
|
+
`)){let r=e.split(`
|
|
7
|
+
`).map(s=>t+ye+Q(s));return Q('"')+`
|
|
8
|
+
`+r.join(`
|
|
9
|
+
`)+`
|
|
10
|
+
`+t+Q('"')}return Q(`"${e}"`)},B=(e,t=0,o=!1)=>{let n=ye.repeat(t);if(e===null)return Be("null");if(typeof e=="string")return We(e,n,o);if(typeof e=="number")return Ue(String(e));if(typeof e=="boolean")return _e(String(e));if(Array.isArray(e)){let s=e.map(i=>B(i,t+1,o));return`${A("[")}
|
|
11
|
+
${n} ${s.join(`,
|
|
12
|
+
${n} `)}
|
|
13
|
+
${n}${A("]")}`}let r=Object.entries(e).map(([s,i])=>`${ve(`"${s}"`)}: ${B(i,t+1,o)}`);return`${A("{")}
|
|
14
|
+
${n} ${r.join(`,
|
|
15
|
+
${n} `)}
|
|
16
|
+
${n}${A("}")}`},ge=(e,t)=>B(e,0,t?.handleMultiline);var p=()=>{},c={DISABLED:"DISABLED",INFO:"INFO",LOG:"LOG",WARN:"WARN",ERROR:"ERROR"},mo={RAW:"RAW",PRETTY:"PRETTY"},Ge=e=>{let t=process.env.DUMBO_LOG_LEVEL??c.DISABLED;return!!(t===c.ERROR&&e===c.ERROR||t===c.WARN&&[c.ERROR,c.WARN].includes(e)||t===c.LOG&&[c.ERROR,c.WARN,c.LOG].includes(e)||t===c.INFO&&[c.ERROR,c.WARN,c.INFO].includes(e))},Ye=()=>{},He=e=>t=>{switch(e){case"RAW":return C.serialize(t);case"PRETTY":return ge(t,{handleMultiline:!0})}},$e=(e,t)=>{let o=He(t);switch(e){case"DISABLED":return Ye;case"INFO":return n=>console.info(o(n));case"LOG":return n=>console.log(o(n));case"WARN":return n=>console.warn(o(n));case"ERROR":return n=>console.error(o(n))}},h=(e,t,o)=>{if(!Ge(c.LOG))return;let n={name:t,timestamp:new Date().getTime(),...o};$e(e,process.env.DUMBO_LOG_STYLE??"RAW")(n)};p.info=(e,t)=>h(c.INFO,e,t);p.warn=(e,t)=>h(c.WARN,e,t);p.log=(e,t)=>h(c.LOG,e,t);p.error=(e,t)=>h(c.ERROR,e,t);var W={timeoutMs:1e4};import Ze from"pg-connection-string";var je=O(`
|
|
6
17
|
CREATE TABLE IF NOT EXISTS migrations (
|
|
7
18
|
id SERIAL PRIMARY KEY,
|
|
8
19
|
name VARCHAR(255) NOT NULL UNIQUE,
|
|
@@ -10,15 +21,15 @@ var Se=(e,t)=>typeof t=="bigint"?t.toString():t,fe=(e,t)=>typeof t=="string"&&/^
|
|
|
10
21
|
sql_hash VARCHAR(64) NOT NULL,
|
|
11
22
|
timestamp TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP
|
|
12
23
|
);
|
|
13
|
-
`),
|
|
24
|
+
`),Ke=pe("dumbo:schema-component:migrations-table",{migrations:()=>[ae("dumbo:migrationTable:001",[je])]}),ko=(e,t,o)=>le(e,t,{schema:{migrationTable:Ke},lock:{databaseLock:de,options:{...o??{},lockId:_}},dryRun:o?.dryRun});var k="postgres",Ve=e=>d(`
|
|
14
25
|
SELECT EXISTS (
|
|
15
26
|
SELECT FROM pg_tables
|
|
16
27
|
WHERE tablename = %L
|
|
17
|
-
) AS exists;`,e),
|
|
28
|
+
) AS exists;`,e),qo=async(e,t)=>U(e.execute.query(Ve(t))),Xe=e=>d(`
|
|
18
29
|
SELECT EXISTS (
|
|
19
30
|
SELECT FROM pg_proc
|
|
20
31
|
WHERE
|
|
21
32
|
proname = %L
|
|
22
33
|
) AS exists;
|
|
23
|
-
`,e),
|
|
34
|
+
`,e),zo=async(e,t)=>U(e.execute.query(Xe(t)));var Go="postgresql://postgres@localhost:5432/postgres",G=e=>Ze.parse(e).database??k;var Y=async(e,t)=>{let o=t.timeoutMs??W.timeoutMs,n=t.mode==="Permanent"?"pg_advisory_lock":"pg_advisory_xact_lock";try{return await L(e.query(d("SELECT %s(%s) AS locked",n,t.lockId),{timeoutMs:o})),!0}catch(r){if(r instanceof Error&&"code"in r&&r.code==="57014")return!1;throw r}},I=async(e,t)=>{let o=t.timeoutMs??W.timeoutMs;try{return await L(e.query(d("SELECT pg_advisory_unlock(%s) AS locked",t.lockId),{timeoutMs:o})),!0}catch(n){if(n instanceof Error&&"code"in n&&n.code==="57014")return!1;throw n}},M=async(e,t)=>{if(!await Y(e,t))throw new Error("Failed to acquire advisory lock within the specified timeout. Migration aborted.")},de={acquire:M,tryAcquire:Y,release:I,withAcquire:async(e,t,o)=>{await M(e,o);try{return await t()}finally{o.mode==="Permanent"&&await I(e,o)}}},tn=(e,t)=>({acquire:o=>M(e,{...t,...o??{}}),tryAcquire:o=>Y(e,{...t,...o??{}}),release:()=>I(e,t),withAcquire:async(o,n)=>{await M(e,{...t,...n??{}});try{return await o()}finally{await I(e,t)}}});import tt from"pg";import Ce from"pg";var me=e=>e instanceof Ce.Pool,ln=e=>e instanceof Ce.Client,et=e=>"release"in e&&typeof e.release=="function",un=async(e,t)=>{let o=me(e)?await e.connect():e;try{return await t(o)}finally{me(e)&&et(o)&&o.release()}},x=()=>({type:u,query:q,batchQuery:q,command:q,batchCommand:q});async function q(e,t,o){let n=Array.isArray(t)?t:[t],r=Array(n.length);o?.timeoutMs&&await e.query(`SET statement_timeout = ${o?.timeoutMs}`);for(let s=0;s<n.length;s++){p.info("db:sql:query",{sql:n[s]});let i=await e.query(n[s]);r[s]={rowCount:i.rowCount,rows:i.rows}}return Array.isArray(t)?r:r[0]}var H=e=>(t,o)=>({connection:e(),type:u,begin:async()=>{await(await t).query("BEGIN")},commit:async()=>{let n=await t;await n.query("COMMIT"),o?.close&&await o?.close(n)},rollback:async n=>{let r=await t;await r.query("ROLLBACK"),o?.close&&await o?.close(r,n)},execute:D(x(),{connect:()=>t})});var u="PostgreSQL:pg",ot=e=>{let{connect:t,close:o}=e;return v({type:u,connect:t,close:o,initTransaction:n=>H(n),executor:x})},nt=e=>{let{connect:t,close:o}=e;return v({type:u,connect:t,close:o,initTransaction:n=>H(n),executor:x})};function T(e){return e.type==="Client"?ot(e):nt(e)}var Ln=async e=>{let t=new tt.Client({connectionString:e});try{return await t.connect(),{successful:!0}}catch(o){let n=o instanceof Error&&"code"in o&&typeof o.code=="string"?o.code:void 0;return{successful:!1,errorType:n==="ECONNREFUSED"?"ConnectionRefused":n==="28P01"?"Authentication":"Unknown",code:n,error:o}}finally{await t.end()}};import Se from"pg";import $ from"pg";var Pe=e=>{$.types.setTypeParser(20,t=>BigInt(t)),$.types.setTypeParser(3802,t=>e.deserialize(t)),$.types.setTypeParser(114,t=>e.deserialize(t))};var rt=e=>{let{connectionString:t,database:o}=e,n=lt({connectionString:t,database:o}),r=()=>T({type:"PoolClient",connect:n.connect(),close:a=>Promise.resolve(a.release())});return S({type:u,connection:()=>Promise.resolve(r()),close:()=>ut({connectionString:t,database:o}),getConnection:r})},st=e=>{let{pool:t}=e;return S({type:u,getConnection:()=>T({type:"PoolClient",connect:t.connect(),close:o=>Promise.resolve(o.release())})})},it=e=>{let{connection:t}=e;return S({type:u,getConnection:()=>t,execute:t.execute,transaction:()=>t.transaction(),withTransaction:o=>t.withTransaction(o)})},ct=e=>{let{connectionString:t,database:o}=e;return S({type:u,getConnection:()=>{let n=Promise.resolve(new Se.Client({connectionString:t,database:o})).then(async r=>(await r.connect(),r));return T({type:"Client",connect:n,close:r=>r.end()})}})},at=e=>{let{client:t}=e,o=()=>{let s=Promise.resolve(t);return T({type:"Client",connect:s,close:()=>Promise.resolve()})};return S({type:u,connection:()=>Promise.resolve(o()),close:()=>Promise.resolve(),getConnection:o})};function fe(e){let{connectionString:t,database:o,serializer:n}=e;return Pe(n??C),"client"in e&&e.client?at({client:e.client}):"connection"in e&&e.connection?it({connection:e.connection}):"pooled"in e&&e.pooled===!1?ct({connectionString:t,database:o}):"pool"in e&&e.pool?st({pool:e.pool}):rt({connectionString:t,database:o})}var N=new Map,Re=new Map,lt=e=>{let t=typeof e=="string"?e:e.connectionString,o=typeof e=="string"?{connectionString:t}:e,n=o.database??(o.connectionString?G(o.connectionString):void 0),r=Le(t,n);return xe(r,1),N.get(r)??N.set(r,new Se.Pool(o)).get(r)},ut=async({connectionString:e,database:t,force:o})=>{t=t??G(e);let n=Le(e,t),r=N.get(n);r&&(xe(n,-1)<=0||o===!0)&&await Oe(n,r)},Oe=async(e,t)=>{try{await t.end()}catch(o){p.error("connection-closing-error",{lookupKey:e,error:o})}N.delete(e)},kn=()=>Promise.all([...N.entries()].map(([e,t])=>Oe(e,t))),Le=(e,t)=>`${e}|${t??k}`,xe=(e,t)=>{let o=Re.get(e)??0,n=o+t;return Re.set(e,o+t),n};var Te=fe;var pt=e=>Te(e),jn=e=>pt(e);export{de as AdvisoryLock,j as JSONReplacer,V as JSONReplacers,K as JSONReviver,X as JSONRevivers,C as JSONSerializer,c as LogLevel,mo as LogStyle,_ as MIGRATIONS_LOCK_ID,u as NodePostgresConnectorType,yt as RawJSONSerializer,Nt as SQL,M as acquireAdvisoryLock,tn as advisoryLock,Ln as checkConnection,ue as combineMigrations,Ee as composeJSONReplacers,we as composeJSONRevivers,pt as connectionPool,$t as count,v as createConnection,S as createConnectionPool,W as defaultDatabaseLockOptions,Go as defaultPostgreSQLConenctionString,k as defaultPostgreSqlDatabase,jn as dumbo,kn as endAllPools,ut as endPool,R as executeInNewConnection,w as executeInNewDbClient,Ie as executeInTransaction,U as exists,Ht as first,Yt as firstOrNull,zo as functionExists,Xe as functionExistsSQL,G as getDatabaseNameOrDefault,lt as getPool,xt as identifier,ln as isNodePostgresClient,me as isNodePostgresNativePool,et as isNodePostgresPoolClient,Ot as isSQL,Z as jsonSerializer,Lt as literal,Wt as mapRows,ie as mapToCamelCase,Ke as migrationTableSchemaComponent,at as nodePostgresAmbientClientPool,it as nodePostgresAmbientConnectionPool,st as nodePostgresAmbientNativePool,ot as nodePostgresClientConnection,ct as nodePostgresClientPool,T as nodePostgresConnection,un as nodePostgresExecute,rt as nodePostgresNativePool,fe as nodePostgresPool,nt as nodePostgresPoolClientConnection,x as nodePostgresSQLExecutor,H as nodePostgresTransaction,Oe as onEndPool,Tt as plainString,Te as postgresPool,ge as prettyJson,O as rawSql,I as releaseAdvisoryLock,ko as runPostgreSQLMigrations,le as runSQLMigrations,pe as schemaComponent,Pe as setNodePostgresTypeParser,L as single,ce as singleOrNull,d as sql,D as sqlExecutor,ne as sqlExecutorInNewConnection,ae as sqlMigration,qo as tableExists,Ve as tableExistsSQL,Me as toCamelCase,p as tracer,re as transactionFactoryWithDbClient,se as transactionFactoryWithNewConnection,Y as tryAcquireAdvisoryLock};
|
|
24
35
|
//# sourceMappingURL=index.js.map
|