appos 0.3.3-0 → 0.3.5-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.
@@ -3,10 +3,12 @@ import * as drizzle_orm22 from "drizzle-orm";
3
3
  import { AnyRelations, EmptyRelations } from "drizzle-orm";
4
4
  import { PgTable } from "drizzle-orm/pg-core";
5
5
  import * as drizzle_orm_node_postgres0 from "drizzle-orm/node-postgres";
6
- import { Pool, PoolConfig } from "pg";
6
+ import * as pg0 from "pg";
7
+ import pg from "pg";
7
8
  import { MigrationConfig } from "drizzle-orm/migrator";
8
9
 
9
10
  //#region src/api/database.d.ts
11
+ type PoolConfig = pg.PoolConfig;
10
12
  /**
11
13
  * Extract qualified table names from db object.
12
14
  */
@@ -69,7 +71,7 @@ declare function dbChanges<T extends PgTable>(table: T): {
69
71
  * @returns The defined database instance.
70
72
  */
71
73
  declare function defineDatabase<TSchema extends Record<string, unknown> = Record<string, never>, TRelations extends AnyRelations = EmptyRelations>(opts: DefineDatabaseOptions<TSchema, TRelations>): Promise<drizzle_orm_node_postgres0.NodePgDatabase<TSchema, TRelations> & {
72
- $client: Pool;
74
+ $client: pg0.Pool;
73
75
  }>;
74
76
  /**
75
77
  * Options for defining a test database.
@@ -91,7 +93,7 @@ interface DefineTestDatabaseOptions<TSchema extends Record<string, unknown> = Re
91
93
  declare function defineTestDatabase<TSchema extends Record<string, unknown> = Record<string, never>, TRelations extends AnyRelations = EmptyRelations>(opts: DefineTestDatabaseOptions<TSchema, TRelations>): Promise<{
92
94
  cleanUp: () => Promise<void>;
93
95
  db: drizzle_orm_node_postgres0.NodePgDatabase<TSchema, TRelations> & {
94
- $client: Pool;
96
+ $client: pg0.Pool;
95
97
  };
96
98
  dbName: string;
97
99
  }>;
@@ -3,9 +3,10 @@ import { getTableName, sql } from "drizzle-orm";
3
3
  import { join } from "node:path";
4
4
  import { drizzle } from "drizzle-orm/node-postgres";
5
5
  import { migrate } from "drizzle-orm/node-postgres/migrator";
6
- import { Client, Pool } from "pg";
6
+ import pg from "pg";
7
7
 
8
8
  //#region src/api/database.ts
9
+ const { Client, Pool: Pool$1 } = pg;
9
10
  /**
10
11
  * The schema used for migrations.
11
12
  */
@@ -67,7 +68,7 @@ function dbChanges(table) {
67
68
  */
68
69
  async function defineDatabase(opts) {
69
70
  return drizzle({
70
- client: new Pool({
71
+ client: new Pool$1({
71
72
  application_name: "appos",
72
73
  max: 16,
73
74
  ...opts.poolConfig
@@ -98,7 +99,7 @@ async function defineTestDatabase(opts) {
98
99
  }
99
100
  const testComponents = parsePostgresUrl(opts.connectionString);
100
101
  testComponents.database = dbName;
101
- const testPool = new Pool({ connectionString: buildPostgresUrl(testComponents) });
102
+ const testPool = new Pool$1({ connectionString: buildPostgresUrl(testComponents) });
102
103
  const db = drizzle({
103
104
  client: testPool,
104
105
  logger: opts.logger ? new DatabaseLogger(opts.logger) : void 0,
@@ -198,7 +199,7 @@ async function ensureTemplateDatabase(connectionString, name, logger) {
198
199
  await maintenanceClient.query(`CREATE DATABASE ${templateDbName} WITH IS_TEMPLATE = true`);
199
200
  const components = parsePostgresUrl(connectionString);
200
201
  components.database = templateDbName;
201
- const templatePool = new Pool({ connectionString: buildPostgresUrl(components) });
202
+ const templatePool = new Pool$1({ connectionString: buildPostgresUrl(components) });
202
203
  try {
203
204
  await migrate(drizzle({
204
205
  client: templatePool,
@@ -2,10 +2,11 @@ import { Logger } from "./logger.mjs";
2
2
  import { AnyRelations, EmptyRelations } from "drizzle-orm";
3
3
  import "drizzle-orm/pg-core";
4
4
  import * as drizzle_orm_node_postgres0 from "drizzle-orm/node-postgres";
5
- import { Pool, PoolConfig } from "pg";
5
+ import * as pg0 from "pg";
6
+ import pg from "pg";
6
7
 
7
8
  //#region src/api/database.d.ts
8
-
9
+ type PoolConfig = pg.PoolConfig;
9
10
  /**
10
11
  * Extract qualified table names from db object.
11
12
  */
@@ -40,7 +41,7 @@ type Database = Awaited<ReturnType<typeof defineDatabase>>;
40
41
  * @returns The defined database instance.
41
42
  */
42
43
  declare function defineDatabase<TSchema extends Record<string, unknown> = Record<string, never>, TRelations extends AnyRelations = EmptyRelations>(opts: DefineDatabaseOptions<TSchema, TRelations>): Promise<drizzle_orm_node_postgres0.NodePgDatabase<TSchema, TRelations> & {
43
- $client: Pool;
44
+ $client: pg0.Pool;
44
45
  }>;
45
46
  //#endregion
46
47
  export { Database, QualifiedTableNames };
@@ -2,10 +2,11 @@ import { Logger } from "./logger.mjs";
2
2
  import { AnyRelations, EmptyRelations } from "drizzle-orm";
3
3
  import "drizzle-orm/pg-core";
4
4
  import * as drizzle_orm_node_postgres0 from "drizzle-orm/node-postgres";
5
- import { Pool, PoolConfig } from "pg";
5
+ import * as pg0 from "pg";
6
+ import pg from "pg";
6
7
 
7
8
  //#region src/api/database.d.ts
8
-
9
+ type PoolConfig = pg.PoolConfig;
9
10
  /**
10
11
  * Extract qualified table names from db object.
11
12
  */
@@ -40,7 +41,7 @@ type Database = Awaited<ReturnType<typeof defineDatabase>>;
40
41
  * @returns The defined database instance.
41
42
  */
42
43
  declare function defineDatabase<TSchema extends Record<string, unknown> = Record<string, never>, TRelations extends AnyRelations = EmptyRelations>(opts: DefineDatabaseOptions<TSchema, TRelations>): Promise<drizzle_orm_node_postgres0.NodePgDatabase<TSchema, TRelations> & {
43
- $client: Pool;
44
+ $client: pg0.Pool;
44
45
  }>;
45
46
  //#endregion
46
47
  export { Database, QualifiedTableNames };
@@ -2,11 +2,13 @@ import { Logger } from "./logger.mjs";
2
2
  import * as drizzle_orm0 from "drizzle-orm";
3
3
  import { AnyRelations, EmptyRelations } from "drizzle-orm";
4
4
  import * as drizzle_orm_node_postgres0 from "drizzle-orm/node-postgres";
5
- import { Pool, PoolConfig } from "pg";
5
+ import * as pg0 from "pg";
6
+ import pg from "pg";
6
7
  import { PgTable } from "drizzle-orm/pg-core";
7
8
  import { MigrationConfig } from "drizzle-orm/migrator";
8
9
 
9
10
  //#region src/api/database.d.ts
11
+ type PoolConfig = pg.PoolConfig;
10
12
  /**
11
13
  * Extract qualified table names from db object.
12
14
  */
@@ -69,7 +71,7 @@ declare function dbChanges<T extends PgTable>(table: T): {
69
71
  * @returns The defined database instance.
70
72
  */
71
73
  declare function defineDatabase<TSchema extends Record<string, unknown> = Record<string, never>, TRelations extends AnyRelations = EmptyRelations>(opts: DefineDatabaseOptions<TSchema, TRelations>): Promise<drizzle_orm_node_postgres0.NodePgDatabase<TSchema, TRelations> & {
72
- $client: Pool;
74
+ $client: pg0.Pool;
73
75
  }>;
74
76
  /**
75
77
  * Options for defining a test database.
@@ -91,7 +93,7 @@ interface DefineTestDatabaseOptions<TSchema extends Record<string, unknown> = Re
91
93
  declare function defineTestDatabase<TSchema extends Record<string, unknown> = Record<string, never>, TRelations extends AnyRelations = EmptyRelations>(opts: DefineTestDatabaseOptions<TSchema, TRelations>): Promise<{
92
94
  cleanUp: () => Promise<void>;
93
95
  db: drizzle_orm_node_postgres0.NodePgDatabase<TSchema, TRelations> & {
94
- $client: Pool;
96
+ $client: pg0.Pool;
95
97
  };
96
98
  dbName: string;
97
99
  }>;
@@ -1 +1 @@
1
- import{APPOS_DIR as e,DATABASES_DIR as t}from"../constants.mjs";import{join as n}from"node:path";import{sql as r}from"drizzle-orm";import{drizzle as i}from"drizzle-orm/node-postgres";import{migrate as a}from"drizzle-orm/node-postgres/migrator";import{Client as o,Pool as s}from"pg";function c(r,i=`schema`){let a=i===`schema`?`schema-migrations`:`data-migrations`,o=i===`schema`?`schema-migrations`:`data-migrations`;return{migrationsFolder:`${n(e,t)}/${r}/${a}`,migrationsSchema:`public`,migrationsTable:o}}var l=class{#e;constructor(e){this.#e=e}logQuery(e,t){this.#e.info(t,e)}};async function u(e){let t=`test_w${process.env.VITEST_POOL_ID||`0`}_${Date.now()}_${Math.random().toString(36).substring(2,8)}`;await h(e.connectionString,e.name,e.logger);let n=`${e.name}_test_template`,r=p(e.connectionString),a=new o({connectionString:r});await a.connect();try{await a.query(`CREATE DATABASE ${t} WITH TEMPLATE ${n}`)}finally{await a.end()}let c=d(e.connectionString);c.database=t;let u=new s({connectionString:f(c)});return{cleanUp:async()=>{await u.end();let e=new o({connectionString:r});await e.connect();try{await e.query(`SELECT pg_terminate_backend(pid) FROM pg_stat_activity WHERE datname = $1`,[t]),await e.query(`DROP DATABASE IF EXISTS ${t}`)}catch(e){console.error(`Could not drop test database:`,e)}finally{await e.end()}},db:i({client:u,logger:e.logger?new l(e.logger):void 0,relations:e.relations,schema:e.schema}),dbName:t}}function d(e){let t=new URL(e);return{database:t.pathname.slice(1)||`postgres`,host:t.hostname,password:decodeURIComponent(t.password),port:Number.parseInt(t.port||`5432`,10),user:decodeURIComponent(t.username)}}function f(e){let{user:t,password:n,host:r,port:i,database:a}=e;return`postgresql://${encodeURIComponent(t)}:${encodeURIComponent(n)}@${r}:${i}/${a}`}function p(e){let t=d(e);return t.database=`postgres`,f(t)}function m(e){let t=0;for(let n=0;n<e.length;n++){let r=e.charCodeAt(n);t=(t<<5)-t+r,t&=t}return Math.abs(t)}async function h(e,t,n){let r=`${t}_test_template`,u=new o({connectionString:p(e)});await u.connect();let h=m(r);try{if(await u.query(`SELECT pg_advisory_lock($1)`,[h]),(await u.query(`SELECT 1 FROM pg_database WHERE datname = $1`,[r])).rowCount===0){await u.query(`CREATE DATABASE ${r} WITH IS_TEMPLATE = true`);let o=d(e);o.database=r;let p=new s({connectionString:f(o)});try{await a(i({client:p,logger:n?new l(n):void 0}),c(t))}finally{await p.end()}}}finally{await u.query(`SELECT pg_advisory_unlock($1)`,[h]),await u.end()}}export{u as defineTestDatabase};
1
+ import{APPOS_DIR as e,DATABASES_DIR as t}from"../constants.mjs";import{join as n}from"node:path";import{sql as r}from"drizzle-orm";import{drizzle as i}from"drizzle-orm/node-postgres";import{migrate as a}from"drizzle-orm/node-postgres/migrator";import o from"pg";const{Client:s,Pool:c}=o;function l(r,i=`schema`){let a=i===`schema`?`schema-migrations`:`data-migrations`,o=i===`schema`?`schema-migrations`:`data-migrations`;return{migrationsFolder:`${n(e,t)}/${r}/${a}`,migrationsSchema:`public`,migrationsTable:o}}var u=class{#e;constructor(e){this.#e=e}logQuery(e,t){this.#e.info(t,e)}};async function d(e){let t=`test_w${process.env.VITEST_POOL_ID||`0`}_${Date.now()}_${Math.random().toString(36).substring(2,8)}`;await g(e.connectionString,e.name,e.logger);let n=`${e.name}_test_template`,r=m(e.connectionString),a=new s({connectionString:r});await a.connect();try{await a.query(`CREATE DATABASE ${t} WITH TEMPLATE ${n}`)}finally{await a.end()}let o=f(e.connectionString);o.database=t;let l=new c({connectionString:p(o)});return{cleanUp:async()=>{await l.end();let e=new s({connectionString:r});await e.connect();try{await e.query(`SELECT pg_terminate_backend(pid) FROM pg_stat_activity WHERE datname = $1`,[t]),await e.query(`DROP DATABASE IF EXISTS ${t}`)}catch(e){console.error(`Could not drop test database:`,e)}finally{await e.end()}},db:i({client:l,logger:e.logger?new u(e.logger):void 0,relations:e.relations,schema:e.schema}),dbName:t}}function f(e){let t=new URL(e);return{database:t.pathname.slice(1)||`postgres`,host:t.hostname,password:decodeURIComponent(t.password),port:Number.parseInt(t.port||`5432`,10),user:decodeURIComponent(t.username)}}function p(e){let{user:t,password:n,host:r,port:i,database:a}=e;return`postgresql://${encodeURIComponent(t)}:${encodeURIComponent(n)}@${r}:${i}/${a}`}function m(e){let t=f(e);return t.database=`postgres`,p(t)}function h(e){let t=0;for(let n=0;n<e.length;n++){let r=e.charCodeAt(n);t=(t<<5)-t+r,t&=t}return Math.abs(t)}async function g(e,t,n){let r=`${t}_test_template`,o=new s({connectionString:m(e)});await o.connect();let d=h(r);try{if(await o.query(`SELECT pg_advisory_lock($1)`,[d]),(await o.query(`SELECT 1 FROM pg_database WHERE datname = $1`,[r])).rowCount===0){await o.query(`CREATE DATABASE ${r} WITH IS_TEMPLATE = true`);let s=f(e);s.database=r;let d=new c({connectionString:p(s)});try{await a(i({client:d,logger:n?new u(n):void 0}),l(t))}finally{await d.end()}}}finally{await o.query(`SELECT pg_advisory_unlock($1)`,[d]),await o.end()}}export{d as defineTestDatabase};
@@ -239,14 +239,14 @@ declare class StorageService<TDiskNames extends string = string, TTableNames ext
239
239
  blobId: string;
240
240
  blob: {
241
241
  id: string;
242
- createdAt: string;
243
242
  key: string;
244
- metadata: unknown;
245
243
  filename: string;
246
244
  contentType: string | null;
245
+ metadata: unknown;
247
246
  serviceName: string;
248
247
  byteSize: number;
249
248
  checksum: string | null;
249
+ createdAt: string;
250
250
  } | null;
251
251
  }[]>;
252
252
  /**
@@ -263,14 +263,14 @@ declare class StorageService<TDiskNames extends string = string, TTableNames ext
263
263
  blobId: string;
264
264
  blob: {
265
265
  id: string;
266
- createdAt: string;
267
266
  key: string;
268
- metadata: unknown;
269
267
  filename: string;
270
268
  contentType: string | null;
269
+ metadata: unknown;
271
270
  serviceName: string;
272
271
  byteSize: number;
273
272
  checksum: string | null;
273
+ createdAt: string;
274
274
  } | null;
275
275
  }[]>;
276
276
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "appos",
3
- "version": "0.3.3-0",
3
+ "version": "0.3.5-0",
4
4
  "type": "module",
5
5
  "scripts": {
6
6
  "release": "release-it",
@@ -130,7 +130,6 @@
130
130
  "@aws-sdk/client-s3": "^3.955.0",
131
131
  "@aws-sdk/s3-request-presigner": "^3.955.0",
132
132
  "@dbos-inc/dbos-sdk": "^4.5.13",
133
- "@napi-rs/canvas": "^0.1.84",
134
133
  "@opentelemetry/api": "^1.9.0",
135
134
  "@opentelemetry/auto-instrumentations-node": "^0.67.3",
136
135
  "@opentelemetry/exporter-trace-otlp-http": "^0.208.0",