@vrplatform/kysely 1.3.21 → 1.3.28

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (73) hide show
  1. package/build/.data.tar +0 -0
  2. package/build/main/camel-case/index.js.map +1 -1
  3. package/build/main/error.js.map +1 -1
  4. package/build/main/index.d.ts +3 -3
  5. package/build/main/index.js +21 -2
  6. package/build/main/index.js.map +1 -1
  7. package/build/main/isomorphic.d.ts +1 -1
  8. package/build/main/isomorphic.js +2 -2
  9. package/build/main/isomorphic.js.map +1 -1
  10. package/build/main/local/digest.js.map +1 -1
  11. package/build/main/local/generate.js +3 -3
  12. package/build/main/local/generate.js.map +1 -1
  13. package/build/main/local/index.d.ts +2 -1
  14. package/build/main/local/index.js +53 -1
  15. package/build/main/local/index.js.map +1 -1
  16. package/build/main/pganalyze-comment-plugin/comment-transformer.js +1 -0
  17. package/build/main/pganalyze-comment-plugin/comment-transformer.js.map +1 -1
  18. package/build/main/pganalyze-comment-plugin/index.js +3 -16
  19. package/build/main/pganalyze-comment-plugin/index.js.map +1 -1
  20. package/build/main/plugins.js.map +1 -1
  21. package/build/main/query/listing/index.d.ts +1 -1
  22. package/build/main/query/listing/index.js +1 -1
  23. package/build/main/query/listing/index.js.map +1 -1
  24. package/build/main/query/listing/status.d.ts +26 -0
  25. package/build/main/query/listing/status.js +48 -0
  26. package/build/main/query/listing/status.js.map +1 -0
  27. package/build/main/test/index.d.ts +3 -0
  28. package/build/main/test/index.js +9 -0
  29. package/build/main/test/index.js.map +1 -1
  30. package/build/main/test.d.ts +4 -0
  31. package/build/main/test.js +19 -0
  32. package/build/main/test.js.map +1 -0
  33. package/build/main/tsconfig.main.tsbuildinfo +1 -1
  34. package/build/main/v1.generated.d.ts +33 -3
  35. package/build/main/v1.generated.js.map +1 -1
  36. package/build/module/camel-case/index.js.map +1 -1
  37. package/build/module/error.js.map +1 -1
  38. package/build/module/index.d.ts +3 -3
  39. package/build/module/index.js +21 -2
  40. package/build/module/index.js.map +1 -1
  41. package/build/module/isomorphic.d.ts +1 -1
  42. package/build/module/isomorphic.js.map +1 -1
  43. package/build/module/local/digest.js.map +1 -1
  44. package/build/module/local/generate.js +3 -3
  45. package/build/module/local/generate.js.map +1 -1
  46. package/build/module/local/index.d.ts +2 -1
  47. package/build/module/local/index.js +20 -1
  48. package/build/module/local/index.js.map +1 -1
  49. package/build/module/pganalyze-comment-plugin/comment-transformer.js.map +1 -1
  50. package/build/module/pganalyze-comment-plugin/index.js.map +1 -1
  51. package/build/module/plugins.js.map +1 -1
  52. package/build/module/query/listing/index.d.ts +1 -1
  53. package/build/module/query/listing/index.js +1 -1
  54. package/build/module/query/listing/index.js.map +1 -1
  55. package/build/module/query/listing/status.d.ts +26 -0
  56. package/build/module/query/listing/status.js +41 -0
  57. package/build/module/query/listing/status.js.map +1 -0
  58. package/build/module/test/index.d.ts +3 -0
  59. package/build/module/test/index.js +9 -0
  60. package/build/module/test/index.js.map +1 -1
  61. package/build/module/test.d.ts +4 -0
  62. package/build/module/test.js +16 -0
  63. package/build/module/test.js.map +1 -0
  64. package/build/module/tsconfig.esm.tsbuildinfo +1 -1
  65. package/build/module/v1.generated.d.ts +33 -3
  66. package/build/module/v1.generated.js.map +1 -1
  67. package/package.json +11 -27
  68. package/build/main/query/listing/is-active-or-at-least-one-ownership-period-active.d.ts +0 -6
  69. package/build/main/query/listing/is-active-or-at-least-one-ownership-period-active.js +0 -24
  70. package/build/main/query/listing/is-active-or-at-least-one-ownership-period-active.js.map +0 -1
  71. package/build/module/query/listing/is-active-or-at-least-one-ownership-period-active.d.ts +0 -6
  72. package/build/module/query/listing/is-active-or-at-least-one-ownership-period-active.js +0 -21
  73. package/build/module/query/listing/is-active-or-at-least-one-ownership-period-active.js.map +0 -1
@@ -1,5 +1,5 @@
1
1
  import type { Kysely as K, Transaction as T } from 'kysely';
2
- export type { ColumnType, Expression, ExpressionBuilder, ExpressionOrFactory, Generated, Insertable, JSONColumnType, Nullable, OperandExpression, Selectable, SelectQueryBuilder, SqlBool, Updateable, } from 'kysely';
2
+ export type { ColumnType, Expression, ExpressionBuilder, ExpressionOrFactory, Generated, Insertable, JSONColumnType, KyselyPlugin, Nullable, OperandExpression, PluginTransformQueryArgs, PluginTransformResultArgs, QueryResult, RootOperationNode, Selectable, SelectQueryBuilder, SqlBool, UnknownRow, Updateable, } from 'kysely';
3
3
  export { jsonArrayFrom } from 'kysely/helpers/postgres';
4
4
  export * from './v1.generated';
5
5
  import type { DB } from './v1.generated';
@@ -1 +1 @@
1
- {"version":3,"file":"isomorphic.js","sourceRoot":"src/","sources":["isomorphic.ts"],"names":[],"mappings":"AAiBA,OAAO,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AACxD,cAAc,gBAAgB,CAAC;AAK/B,OAAO,EAAE,GAAG,EAAE,MAAM,QAAQ,CAAC;AAI7B,MAAM,OAAO,aAAc,SAAQ,KAAK;IACtC,YAAY,OAAe,EAAE,KAAU;QACrC,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;IACrB,CAAC;CACF","sourcesContent":["import type { Kysely as K, Transaction as T } from 'kysely';\n\nexport type {\n ColumnType,\n Expression,\n ExpressionBuilder,\n ExpressionOrFactory,\n Generated,\n Insertable,\n JSONColumnType,\n Nullable,\n OperandExpression,\n Selectable,\n SelectQueryBuilder,\n SqlBool,\n Updateable,\n} from 'kysely';\nexport { jsonArrayFrom } from 'kysely/helpers/postgres';\nexport * from './v1.generated';\n\nimport type { DB } from './v1.generated';\n\nexport type Transaction = T<DB>;\nexport { sql } from 'kysely';\n\nexport type Kysely = K<DB>;\n\nexport class DatabaseError extends Error {\n constructor(message: string, cause: any) {\n super(message);\n this.cause = cause;\n }\n}\n"]}
1
+ {"version":3,"file":"isomorphic.js","sourceRoot":"src/","sources":["isomorphic.ts"],"names":[],"mappings":"AAuBA,OAAO,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AACxD,cAAc,gBAAgB,CAAC;AAK/B,OAAO,EAAE,GAAG,EAAE,MAAM,QAAQ,CAAC;AAI7B,MAAM,OAAO,aAAc,SAAQ,KAAK;IACtC,YAAY,OAAe,EAAE,KAAU,EAAE;QACvC,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;IAAA,CACpB;CACF","sourcesContent":["import type { Kysely as K, Transaction as T } from 'kysely';\n\nexport type {\n ColumnType,\n Expression,\n ExpressionBuilder,\n ExpressionOrFactory,\n Generated,\n Insertable,\n JSONColumnType,\n KyselyPlugin,\n Nullable,\n OperandExpression,\n PluginTransformQueryArgs,\n PluginTransformResultArgs,\n QueryResult,\n RootOperationNode,\n Selectable,\n SelectQueryBuilder,\n SqlBool,\n UnknownRow,\n Updateable,\n} from 'kysely';\nexport { jsonArrayFrom } from 'kysely/helpers/postgres';\nexport * from './v1.generated';\n\nimport type { DB } from './v1.generated';\n\nexport type Transaction = T<DB>;\nexport { sql } from 'kysely';\n\nexport type Kysely = K<DB>;\n\nexport class DatabaseError extends Error {\n constructor(message: string, cause: any) {\n super(message);\n this.cause = cause;\n }\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"digest.js","sourceRoot":"src/","sources":["local/digest.ts"],"names":[],"mappings":"AAAA,OAAO,EAAe,GAAG,EAAE,MAAM,eAAe,CAAC;AAEjD,MAAM,CAAC,KAAK,UAAU,oBAAoB,CAAC,MAAc;IACvD,IAAI,CAAC;QACH,MAAM,GAAG,CAAA,6BAA6B,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;IACzD,CAAC;IAAC,MAAM,CAAC;QACP,MAAM,GAAG,CAAA;;;;;;;;;KASR,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;IACpB,CAAC;AACH,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,4BAA4B,CAAC,MAAc;IAC/D,IAAI,CAAC;QACH,MAAM,GAAG,CAAA,4BAA4B,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;IACxD,CAAC;IAAC,MAAM,CAAC;QACP,MAAM,GAAG,CAAA;;;;;;;;;;;;;;;;;;KAkBR,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;IACpB,CAAC;AACH,CAAC","sourcesContent":["import { type Kysely, sql } from '../isomorphic';\n\nexport async function ensureDigestFunction(kysely: Kysely) {\n try {\n await sql`select digest('', 'sha256')`.execute(kysely);\n } catch {\n await sql`\n create or replace function digest(input text, algo text)\n returns bytea\n language sql\n immutable\n strict\n as $$\n select '\\\\x0000000000000000000000000000000000000000000000000000000000000000'::bytea;\n $$;\n `.execute(kysely);\n }\n}\n\nexport async function ensureGenRandomBytesFunction(kysely: Kysely) {\n try {\n await sql`select gen_random_bytes(1)`.execute(kysely);\n } catch {\n await sql`\n create or replace function gen_random_bytes(p_len integer)\n returns bytea\n language sql\n stable\n strict\n as $$\n select substring(\n decode(\n repeat(\n md5(random()::text || now()::text),\n ((p_len + 15) / 16)\n ),\n 'hex'\n )\n from 1 for p_len\n );\n $$;\n `.execute(kysely);\n }\n}\n"]}
1
+ {"version":3,"file":"digest.js","sourceRoot":"src/","sources":["local/digest.ts"],"names":[],"mappings":"AAAA,OAAO,EAAe,GAAG,EAAE,MAAM,eAAe,CAAC;AAEjD,MAAM,CAAC,KAAK,UAAU,oBAAoB,CAAC,MAAc,EAAE;IACzD,IAAI,CAAC;QACH,MAAM,GAAG,CAAA,6BAA6B,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;IACzD,CAAC;IAAC,MAAM,CAAC;QACP,MAAM,GAAG,CAAA;;;;;;;;;KASR,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;IACpB,CAAC;AAAA,CACF;AAED,MAAM,CAAC,KAAK,UAAU,4BAA4B,CAAC,MAAc,EAAE;IACjE,IAAI,CAAC;QACH,MAAM,GAAG,CAAA,4BAA4B,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;IACxD,CAAC;IAAC,MAAM,CAAC;QACP,MAAM,GAAG,CAAA;;;;;;;;;;;;;;;;;;KAkBR,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;IACpB,CAAC;AAAA,CACF","sourcesContent":["import { type Kysely, sql } from '../isomorphic';\n\nexport async function ensureDigestFunction(kysely: Kysely) {\n try {\n await sql`select digest('', 'sha256')`.execute(kysely);\n } catch {\n await sql`\n create or replace function digest(input text, algo text)\n returns bytea\n language sql\n immutable\n strict\n as $$\n select '\\\\x0000000000000000000000000000000000000000000000000000000000000000'::bytea;\n $$;\n `.execute(kysely);\n }\n}\n\nexport async function ensureGenRandomBytesFunction(kysely: Kysely) {\n try {\n await sql`select gen_random_bytes(1)`.execute(kysely);\n } catch {\n await sql`\n create or replace function gen_random_bytes(p_len integer)\n returns bytea\n language sql\n stable\n strict\n as $$\n select substring(\n decode(\n repeat(\n md5(random()::text || now()::text),\n ((p_len + 15) / 16)\n ),\n 'hex'\n )\n from 1 for p_len\n );\n $$;\n `.execute(kysely);\n }\n}\n"]}
@@ -5,7 +5,7 @@ import { join } from 'node:path';
5
5
  import { PGlite } from '@electric-sql/pglite';
6
6
  import { FileMigrationProvider, Migrator } from 'kysely';
7
7
  import codegen from 'kysely-codegen';
8
- import { KyselyPGlite } from 'kysely-pglite';
8
+ import { PGliteDialect } from 'kysely-pglite-dialect';
9
9
  import { getKysely } from '../plugins';
10
10
  async function migrate(root, client) {
11
11
  console.log('migrating pglite ....');
@@ -61,7 +61,7 @@ async function generateDump(root, dumpPath) {
61
61
  await Bun.write('../logs/migrate-initial-dump.json', JSON.stringify(err, null, 2));
62
62
  process.exit(1);
63
63
  });
64
- const { dialect } = new KyselyPGlite(main);
64
+ const dialect = new PGliteDialect(main);
65
65
  const kysely = getKysely(dialect, {
66
66
  repositoryName: 'localTesting',
67
67
  log: undefined,
@@ -101,7 +101,7 @@ export async function createLocalKysely(root, dumpPath) {
101
101
  const pglite = new PGlite({ loadDataDir: dump });
102
102
  // warm up
103
103
  await pglite.sql `SELECT 1`;
104
- const { dialect } = new KyselyPGlite(pglite);
104
+ const dialect = new PGliteDialect(pglite);
105
105
  const kysely = getKysely(dialect, {
106
106
  repositoryName: 'localTesting',
107
107
  log: undefined,
@@ -1 +1 @@
1
- {"version":3,"file":"generate.js","sourceRoot":"src/","sources":["local/generate.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,IAAI,EAAE,EAAE,MAAM,SAAS,CAAC;AACzC,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAC1C,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC;AAClC,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAC;AAC9C,OAAO,EAAE,qBAAqB,EAAe,QAAQ,EAAE,MAAM,QAAQ,CAAC;AACtE,OAAO,OAAO,MAAM,gBAAgB,CAAC;AACrC,OAAO,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAC7C,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAGvC,KAAK,UAAU,OAAO,CAAC,IAAY,EAAE,MAAc;IACjD,OAAO,CAAC,GAAG,CAAC,uBAAuB,CAAC,CAAC;IACrC,MAAM,IAAI,GAAG,IAAI,GAAG,CAAC,IAAI,CAAC,eAAe,CAAC,CAAC;IAC3C,IAAI,KAAK,EAAE,MAAM,SAAS,IAAI,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC;QAC9C,MAAM,GAAG,GAAG,MAAM,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,SAAS,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC;QACzD,yEAAyE;QACzE,oEAAoE;QACpE,MAAM,SAAS,GAAG,GAAG,CAAC,OAAO,CAAC,6BAA6B,EAAE,EAAE,CAAC,CAAC;QACjE,MAAM,MAAM,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;IAC/B,CAAC;AACH,CAAC;AAED,KAAK,U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C9B,GAAG,EAAE,SAAS;KACf,CAAC,CAAC;IAEH,MAAM,eAAe,GAAG,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;IACpD,MAAM,CAAC,OAAO,GAAG,KAAK,IAAI,EAAE;QAC1B,IAAI,WAAW;YAAE,OAAO;QACxB,WAAW,GAAG,IAAI,CAAC;QACnB,yCAAyC;QACzC,MAAM,eAAe,EAAE,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC,SAAS,CAAC,CAAC;QAC/C,MAAM,MAAM,CAAC,KAAK,EAAE,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC,SAAS,CAAC,CAAC;QAC5C,cAAc;QACd,0EAA0E;QAC1E,IAAI;IACN,CAAC,CAAC;IAEF,iFAAiF;IAEjF,OAAO,MAAM,CAAC;AAChB,CAAC","sourcesContent":["import { promises as fs } from 'node:fs';\nimport { exists } from 'node:fs/promises';\nimport * as path from 'node:path';\nimport { join } from 'node:path';\nimport { PGlite } from '@electric-sql/pglite';\nimport { FileMigrationProvider, type Kysely, Migrator } from 'kysely';\nimport codegen from 'kysely-codegen';\nimport { KyselyPGlite } from 'kysely-pglite';\nimport { getKysely } from '../plugins';\nimport type { DB } from '../v1.generated';\n\nasync function migrate(root: string, client: PGlite) {\n console.log('migrating pglite ....');\n const glob = new Bun.Glob('initial/*.sql');\n for await (const migration of glob.scan(root)) {\n const raw = await Bun.file(join(root, migration)).text();\n // `pg_dump` (v17+) prepends `\\restrict`/`\\unrestrict` psql meta commands\n // which PostgreSQL-compatible parsers (like PGlite) cannot execute.\n const sanitized = raw.replace(/^\\s*\\\\(?:un)?restrict.*$/gim, '');\n await client.exec(sanitized);\n }\n}\n\nasync function migrateKysely(root: string, kysely: Kysely<DB>) {\n console.log('init migrating kysely ....');\n const migrator = new Migrator({\n db: kysely,\n migrationTableSchema: 'core',\n migrationTableName: 'kysely_migration',\n migrationLockTableName: 'kysely_migration_lock',\n provider: new FileMigrationProvider({\n fs,\n path,\n // This needs to be an absolute path.\n migrationFolder: path.join(root, 'migrations'),\n }),\n });\n\n console.log('migrating kysely ....');\n const { error, results } = await migrator.migrateToLatest().catch(() => {\n console.error('failed to migrate');\n process.exit(1);\n });\n\n for (const it of results ?? []) {\n if (it.status === 'Success') {\n console.log(`migration \"${it.migrationName}\" was executed successfully`);\n } else if (it.status === 'Error') {\n console.error(`failed to execute migration \"${it.migrationName}\"`);\n }\n }\n\n if (error) {\n console.error('failed to migrate');\n console.error(error);\n process.exit(1);\n }\n}\n\nasync function generateDump(root: string, dumpPath: string) {\n const dataExists = await exists(dumpPath).catch(() => false);\n if (!dataExists) {\n console.log('Creating initial dump');\n const main = new PGlite();\n await migrate(root, main).catch(async (err) => {\n console.error('failed to migrate initial dump');\n await Bun.write(\n '../logs/migrate-initial-dump.json',\n JSON.stringify(err as any, null, 2)\n );\n process.exit(1);\n });\n const { dialect } = new KyselyPGlite(main);\n const kysely = getKysely(dialect, {\n repositoryName: 'localTesting',\n log: undefined,\n });\n await migrateKysely(root, kysely).catch(() => {\n console.error('failed to migrate kysely');\n process.exit(1);\n });\n await codegen\n .generate({\n db: kysely,\n outFile: path.join(root, 'src/v1.generated.ts'),\n defaultSchemas: ['xxx'],\n camelCase: true,\n dialect: codegen.getDialect('postgres'),\n })\n .catch(() => {\n console.error('failed to generate kysely');\n process.exit(1);\n });\n const content = await main.dumpDataDir('none').catch(() => {\n console.error('failed to dump data');\n process.exit(1);\n });\n await Bun.write(dumpPath, content).catch(() => {\n console.error('failed to write dump');\n process.exit(1);\n });\n return content;\n }\n return Bun.file(dumpPath);\n}\n\nexport async function createLocalKysely(root: string, dumpPath: string) {\n let isDestroyed = false;\n //const now = performance.now();\n\n const dump = await generateDump(root, dumpPath);\n\n const pglite = new PGlite({ loadDataDir: dump });\n // warm up\n await pglite.sql`SELECT 1`;\n const { dialect } = new KyselyPGlite(pglite);\n const kysely = getKysely(dialect, {\n repositoryName: 'localTesting',\n log: undefined,\n });\n\n const originalDestroy = kysely.destroy.bind(kysely);\n kysely.destroy = async () => {\n if (isDestroyed) return;\n isDestroyed = true;\n // const destroyTime = performance.now();\n await originalDestroy().catch(() => undefined);\n await pglite.close().catch(() => undefined);\n //console.log(\n // `Database destroyed: ${Math.round(performance.now() - destroyTime)}ms`\n //);\n };\n\n // console.log(`Database initialized: ${Math.round(performance.now() - now)}ms`);\n\n return kysely;\n}\n"]}
1
+ {"version":3,"file":"generate.js","sourceRoot":"src/","sources":["local/generate.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,IAAI,EAAE,EAAE,MAAM,SAAS,CAAC;AACzC,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAC1C,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC;AAClC,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAC;AAC9C,OAAO,EAAE,qBAAqB,EAAe,QAAQ,EAAE,MAAM,QAAQ,CAAC;AACtE,OAAO,OAAO,MAAM,gBAAgB,CAAC;AACrC,OAAO,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AACtD,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAGvC,KAAK,UAAU,OAAO,CAAC,IAAY,EAAE,MAAc,EAAE;IACnD,OAAO,CAAC,GAAG,CAAC,uBAAuB,CAAC,CAAC;IACrC,MAAM,IAAI,GAAG,IAAI,GAAG,CAAC,IAAI,CAAC,eAAe,CAAC,CAAC;IAC3C,IAAI,KAAK,EAAE,MAAM,SAAS,IAAI,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC;QAC9C,MAAM,GAAG,GAAG,MAAM,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,SAAS,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC;QACzD,yEAAyE;QACzE,oEAAoE;QACpE,MAAM,SAAS,GAAG,GAAG,CAAC,OAAO,CA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,CAAA,UAAU,CAAC;IAC3B,MAAM,OAAO,GAAG,IAAI,aAAa,CAAC,MAAM,CAAC,CAAC;IAC1C,MAAM,MAAM,GAAG,SAAS,CAAC,OAAO,EAAE;QAChC,cAAc,EAAE,cAAc;QAC9B,GAAG,EAAE,SAAS;KACf,CAAC,CAAC;IAEH,MAAM,eAAe,GAAG,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;IACpD,MAAM,CAAC,OAAO,GAAG,KAAK,IAAI,EAAE,CAAC;QAC3B,IAAI,WAAW;YAAE,OAAO;QACxB,WAAW,GAAG,IAAI,CAAC;QACnB,yCAAyC;QACzC,MAAM,eAAe,EAAE,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC,SAAS,CAAC,CAAC;QAC/C,MAAM,MAAM,CAAC,KAAK,EAAE,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC,SAAS,CAAC,CAAC;QAC5C,cAAc;QACd,0EAA0E;QAC1E,IAAI;IAHwC,CAI7C,CAAC;IAEF,iFAAiF;IAEjF,OAAO,MAAM,CAAC;AAAA,CACf","sourcesContent":["import { promises as fs } from 'node:fs';\nimport { exists } from 'node:fs/promises';\nimport * as path from 'node:path';\nimport { join } from 'node:path';\nimport { PGlite } from '@electric-sql/pglite';\nimport { FileMigrationProvider, type Kysely, Migrator } from 'kysely';\nimport codegen from 'kysely-codegen';\nimport { PGliteDialect } from 'kysely-pglite-dialect';\nimport { getKysely } from '../plugins';\nimport type { DB } from '../v1.generated';\n\nasync function migrate(root: string, client: PGlite) {\n console.log('migrating pglite ....');\n const glob = new Bun.Glob('initial/*.sql');\n for await (const migration of glob.scan(root)) {\n const raw = await Bun.file(join(root, migration)).text();\n // `pg_dump` (v17+) prepends `\\restrict`/`\\unrestrict` psql meta commands\n // which PostgreSQL-compatible parsers (like PGlite) cannot execute.\n const sanitized = raw.replace(/^\\s*\\\\(?:un)?restrict.*$/gim, '');\n await client.exec(sanitized);\n }\n}\n\nasync function migrateKysely(root: string, kysely: Kysely<DB>) {\n console.log('init migrating kysely ....');\n const migrator = new Migrator({\n db: kysely,\n migrationTableSchema: 'core',\n migrationTableName: 'kysely_migration',\n migrationLockTableName: 'kysely_migration_lock',\n provider: new FileMigrationProvider({\n fs,\n path,\n // This needs to be an absolute path.\n migrationFolder: path.join(root, 'migrations'),\n }),\n });\n\n console.log('migrating kysely ....');\n const { error, results } = await migrator.migrateToLatest().catch(() => {\n console.error('failed to migrate');\n process.exit(1);\n });\n\n for (const it of results ?? []) {\n if (it.status === 'Success') {\n console.log(`migration \"${it.migrationName}\" was executed successfully`);\n } else if (it.status === 'Error') {\n console.error(`failed to execute migration \"${it.migrationName}\"`);\n }\n }\n\n if (error) {\n console.error('failed to migrate');\n console.error(error);\n process.exit(1);\n }\n}\n\nasync function generateDump(root: string, dumpPath: string) {\n const dataExists = await exists(dumpPath).catch(() => false);\n if (!dataExists) {\n console.log('Creating initial dump');\n const main = new PGlite();\n await migrate(root, main).catch(async (err) => {\n console.error('failed to migrate initial dump');\n await Bun.write(\n '../logs/migrate-initial-dump.json',\n JSON.stringify(err as any, null, 2)\n );\n process.exit(1);\n });\n const dialect = new PGliteDialect(main);\n const kysely = getKysely(dialect, {\n repositoryName: 'localTesting',\n log: undefined,\n });\n await migrateKysely(root, kysely).catch(() => {\n console.error('failed to migrate kysely');\n process.exit(1);\n });\n await codegen\n .generate({\n db: kysely,\n outFile: path.join(root, 'src/v1.generated.ts'),\n defaultSchemas: ['xxx'],\n camelCase: true,\n dialect: codegen.getDialect('postgres'),\n })\n .catch(() => {\n console.error('failed to generate kysely');\n process.exit(1);\n });\n const content = await main.dumpDataDir('none').catch(() => {\n console.error('failed to dump data');\n process.exit(1);\n });\n await Bun.write(dumpPath, content).catch(() => {\n console.error('failed to write dump');\n process.exit(1);\n });\n return content;\n }\n return Bun.file(dumpPath);\n}\n\nexport async function createLocalKysely(root: string, dumpPath: string) {\n let isDestroyed = false;\n //const now = performance.now();\n\n const dump = await generateDump(root, dumpPath);\n\n const pglite = new PGlite({ loadDataDir: dump });\n // warm up\n await pglite.sql`SELECT 1`;\n const dialect = new PGliteDialect(pglite);\n const kysely = getKysely(dialect, {\n repositoryName: 'localTesting',\n log: undefined,\n });\n\n const originalDestroy = kysely.destroy.bind(kysely);\n kysely.destroy = async () => {\n if (isDestroyed) return;\n isDestroyed = true;\n // const destroyTime = performance.now();\n await originalDestroy().catch(() => undefined);\n await pglite.close().catch(() => undefined);\n //console.log(\n // `Database destroyed: ${Math.round(performance.now() - destroyTime)}ms`\n //);\n };\n\n // console.log(`Database initialized: ${Math.round(performance.now() - now)}ms`);\n\n return kysely;\n}\n"]}
@@ -1,8 +1,9 @@
1
1
  import type { LogConfig } from 'kysely';
2
+ import { type Kysely } from 'kysely';
2
3
  export declare const root: string;
3
4
  export declare const dumpPath: string;
4
5
  export type UseLocalKyselyOptions = {
5
6
  repositoryName?: string;
6
7
  log?: true | LogConfig;
7
8
  };
8
- export declare function useLocalKysely(args?: UseLocalKyselyOptions): Promise<import("kysely").Kysely<import("..").DB>>;
9
+ export declare function useLocalKysely(args?: UseLocalKyselyOptions): Promise<Kysely<import("..").DB>>;
@@ -1,10 +1,29 @@
1
+ import { promises as fs } from 'node:fs';
2
+ import * as path from 'node:path';
1
3
  import { join } from 'node:path';
2
4
  import { PGlite } from '@electric-sql/pglite';
5
+ import { FileMigrationProvider, Migrator } from 'kysely';
3
6
  import { PGliteDialect } from 'kysely-pglite-dialect';
4
7
  import { getKysely } from '../plugins';
5
8
  import { ensureDigestFunction, ensureGenRandomBytesFunction } from './digest';
6
9
  export const root = join(__dirname, '../..');
7
10
  export const dumpPath = join(root, '.data.tar');
11
+ async function migrateKysely(kysely) {
12
+ const migrator = new Migrator({
13
+ db: kysely,
14
+ migrationTableSchema: 'core',
15
+ migrationTableName: 'kysely_migration',
16
+ migrationLockTableName: 'kysely_migration_lock',
17
+ provider: new FileMigrationProvider({
18
+ fs,
19
+ path,
20
+ migrationFolder: path.join(root, 'migrations'),
21
+ }),
22
+ });
23
+ const { error } = await migrator.migrateToLatest();
24
+ if (error)
25
+ throw error;
26
+ }
8
27
  export async function useLocalKysely(args = {}) {
9
28
  let isDestroyed = false;
10
29
  // const now = performance.now();
@@ -12,7 +31,6 @@ export async function useLocalKysely(args = {}) {
12
31
  const pglite = new PGlite({
13
32
  loadDataDir: dump,
14
33
  });
15
- // warm up
16
34
  const dialect = new PGliteDialect(pglite);
17
35
  const kysely = getKysely(dialect, {
18
36
  repositoryName: args?.repositoryName ?? 'localTesting',
@@ -20,6 +38,7 @@ export async function useLocalKysely(args = {}) {
20
38
  });
21
39
  await ensureDigestFunction(kysely);
22
40
  await ensureGenRandomBytesFunction(kysely);
41
+ await migrateKysely(kysely);
23
42
  const originalDestroy = kysely.destroy.bind(kysely);
24
43
  kysely.destroy = async () => {
25
44
  if (isDestroyed)
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"src/","sources":["local/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAC;AAE9C,OAAO,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AACtD,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AACvC,OAAO,EAAE,oBAAoB,EAAE,4BAA4B,EAAE,MAAM,UAAU,CAAC;AAE9E,MAAM,CAAC,MAAM,IAAI,GAAG,IAAI,CAAC,SAAS,EAAE,OAAO,CAAC,CAAC;AAC7C,MAAM,CAAC,MAAM,QAAQ,GAAG,IAAI,CAAC,IAAI,EAAE,WAAW,CAAC,CAAC;AAMhD,MAAM,CAAC,KAAK,UAAU,cAAc,CAAC,OAA8B,EAAE;IACnE,IAAI,WAAW,GAAG,KAAK,CAAC;IACxB,iCAAiC;IAEjC,MAAM,IAAI,GAAG,GAAG,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;IAEhC,MAAM,MAAM,GAAG,IAAI,MAAM,CAAC;QACxB,WAAW,EAAE,IAAI;KAClB,CAAC,CAAC;IACH,UAAU;IACV,MAAM,OAAO,GAAG,IAAI,aAAa,CAAC,MAAM,CAAC,CAAC;IAC1C,MAAM,MAAM,GAAG,SAAS,CAAC,OAAO,EAAE;QAChC,cAAc,EAAE,IAAI,EAAE,cAAc,IAAI,cAAc;QACtD,GAAG,EAAE,IAAI,EAAE,GAAG;KACf,CAAC,CAAC;IACH,MAAM,oBAAoB,CAAC,MAAM,CAAC,CAAC;IACnC,MAAM,4BAA4B,CAAC,MAAM,CAAC,CAAC;IAE3C,MAAM,eAAe,GAAG,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;IACpD,MAAM,CAAC,OAAO,GAAG,KAAK,IAAI,EAAE;QAC1B,IAAI,WAAW;YAAE,OAAO;QACxB,WAAW,GAAG,IAAI,CAAC;QACnB,wCAAwC;QACxC,MAAM,eAAe,EAAE,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC,SAAS,CAAC,CAAC;QAC/C,MAAM,MAAM,CAAC,KAAK,EAAE,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC,SAAS,CAAC,CAAC;QAC5C,cAAc;QACd,0EAA0E;QAC1E,IAAI;IACN,CAAC,CAAC;IAEF,iFAAiF;IAEjF,OAAO,MAAM,CAAC;AAChB,CAAC","sourcesContent":["import { join } from 'node:path';\nimport { PGlite } from '@electric-sql/pglite';\nimport type { LogConfig } from 'kysely';\nimport { PGliteDialect } from 'kysely-pglite-dialect';\nimport { getKysely } from '../plugins';\nimport { ensureDigestFunction, ensureGenRandomBytesFunction } from './digest';\n\nexport const root = join(__dirname, '../..');\nexport const dumpPath = join(root, '.data.tar');\n\nexport type UseLocalKyselyOptions = {\n repositoryName?: string;\n log?: true | LogConfig;\n};\nexport async function useLocalKysely(args: UseLocalKyselyOptions = {}) {\n let isDestroyed = false;\n // const now = performance.now();\n\n const dump = Bun.file(dumpPath);\n\n const pglite = new PGlite({\n loadDataDir: dump,\n });\n // warm up\n const dialect = new PGliteDialect(pglite);\n const kysely = getKysely(dialect, {\n repositoryName: args?.repositoryName ?? 'localTesting',\n log: args?.log,\n });\n await ensureDigestFunction(kysely);\n await ensureGenRandomBytesFunction(kysely);\n\n const originalDestroy = kysely.destroy.bind(kysely);\n kysely.destroy = async () => {\n if (isDestroyed) return;\n isDestroyed = true;\n //const destroyTime = performance.now();\n await originalDestroy().catch(() => undefined);\n await pglite.close().catch(() => undefined);\n //console.log(\n // `Database destroyed: ${Math.round(performance.now() - destroyTime)}ms`\n //);\n };\n\n // console.log(`Database initialized: ${Math.round(performance.now() - now)}ms`);\n\n return kysely;\n}\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"src/","sources":["local/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,IAAI,EAAE,EAAE,MAAM,SAAS,CAAC;AACzC,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC;AAClC,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAC;AAE9C,OAAO,EAAE,qBAAqB,EAAe,QAAQ,EAAE,MAAM,QAAQ,CAAC;AACtE,OAAO,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AACtD,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AACvC,OAAO,EAAE,oBAAoB,EAAE,4BAA4B,EAAE,MAAM,UAAU,CAAC;AAE9E,MAAM,CAAC,MAAM,IAAI,GAAG,IAAI,CAAC,SAAS,EAAE,OAAO,CAAC,CAAC;AAC7C,MAAM,CAAC,MAAM,QAAQ,GAAG,IAAI,CAAC,IAAI,EAAE,WAAW,CAAC,CAAC;AAEhD,KAAK,UAAU,aAAa,CAAC,MAAmB,EAAE;IAChD,MAAM,QAAQ,GAAG,IAAI,QAAQ,CAAC;QAC5B,EAAE,EAAE,MAAM;QACV,oBAAoB,EAAE,MAAM;QAC5B,kB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AAC;QAC/C,MAAM,MAAM,CAAC,KAAK,EAAE,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC,SAAS,CAAC,CAAC;QAC5C,cAAc;QACd,0EAA0E;QAC1E,IAAI;IAHwC,CAI7C,CAAC;IAEF,iFAAiF;IAEjF,OAAO,MAAM,CAAC;AAAA,CACf","sourcesContent":["import { promises as fs } from 'node:fs';\nimport * as path from 'node:path';\nimport { join } from 'node:path';\nimport { PGlite } from '@electric-sql/pglite';\nimport type { LogConfig } from 'kysely';\nimport { FileMigrationProvider, type Kysely, Migrator } from 'kysely';\nimport { PGliteDialect } from 'kysely-pglite-dialect';\nimport { getKysely } from '../plugins';\nimport { ensureDigestFunction, ensureGenRandomBytesFunction } from './digest';\n\nexport const root = join(__dirname, '../..');\nexport const dumpPath = join(root, '.data.tar');\n\nasync function migrateKysely(kysely: Kysely<any>) {\n const migrator = new Migrator({\n db: kysely,\n migrationTableSchema: 'core',\n migrationTableName: 'kysely_migration',\n migrationLockTableName: 'kysely_migration_lock',\n provider: new FileMigrationProvider({\n fs,\n path,\n migrationFolder: path.join(root, 'migrations'),\n }),\n });\n\n const { error } = await migrator.migrateToLatest();\n if (error) throw error;\n}\n\nexport type UseLocalKyselyOptions = {\n repositoryName?: string;\n log?: true | LogConfig;\n};\nexport async function useLocalKysely(args: UseLocalKyselyOptions = {}) {\n let isDestroyed = false;\n // const now = performance.now();\n\n const dump = Bun.file(dumpPath);\n\n const pglite = new PGlite({\n loadDataDir: dump,\n });\n const dialect = new PGliteDialect(pglite);\n const kysely = getKysely(dialect, {\n repositoryName: args?.repositoryName ?? 'localTesting',\n log: args?.log,\n });\n await ensureDigestFunction(kysely);\n await ensureGenRandomBytesFunction(kysely);\n await migrateKysely(kysely);\n\n const originalDestroy = kysely.destroy.bind(kysely);\n kysely.destroy = async () => {\n if (isDestroyed) return;\n isDestroyed = true;\n //const destroyTime = performance.now();\n await originalDestroy().catch(() => undefined);\n await pglite.close().catch(() => undefined);\n //console.log(\n // `Database destroyed: ${Math.round(performance.now() - destroyTime)}ms`\n //);\n };\n\n // console.log(`Database initialized: ${Math.round(performance.now() - now)}ms`);\n\n return kysely;\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"comment-transformer.js","sourceRoot":"src/","sources":["pganalyze-comment-plugin/comment-transformer.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,wBAAwB,EAExB,kBAAkB,EAElB,GAAG,GAEJ,MAAM,QAAQ,CAAC;AAEhB,SAAS,iBAAiB,CAAC,cAAsB;IAC/C,OAAO,kBAAkB,CAAC,oBAAoB,CAC5C,GAAG,CAAC,GAAG,CAAC,kBAAkB,cAAc,KAAK,CAAC,CAAC,eAAe,EAAE,CACjE,CAAC;AACJ,CAAC;AACD;;;;;;GAMG;AACH,MAAM,OAAO,kBAAmB,SAAQ,wBAAwB;IACzC;IAArB,YAAqB,eAAuB;QAC1C,KAAK,EAAE,CAAC;QADW,oBAAe,GAAf,eAAe,CAAQ;IAE5C,CAAC;IAED,iBAAiB,CAAC,IAAuB;QACvC,IAAI,IAAI,CAAC,IAAI,KAAK,iBAAiB,EAAE,CAAC;YACpC,OAAO,IAAI,CAAC,oBAAoB,CAAC,IAAI,CAAC,CAAC;QACzC,CAAC;QACD,IAAI,IAAI,CAAC,IAAI,KAAK,iBAAiB,EAAE,CAAC;YACpC,OAAO,IAAI,CAAC,oBAAoB,CAAC,IAAI,CAAC,CAAC;QACzC,CAAC;QACD,IAAI,IAAI,CAAC,IAAI,KAAK,iBAAiB,EAAE,CAAC;YACpC,OAAO,IAAI,CAAC,oBAAoB,CAAC,IAAI,CAAC,CAAC;QACzC,CAAC;QACD,IAAI,IAAI,CAAC,IAAI,KAAK,iBAAiB,EAAE,CAAC;YACpC,OAAO,IAAI,CAAC,oBAAoB,CAAC,IAAI,CAAC,CAAC;QACzC,CAAC;QACD,OAAO,IAAI,CAAC;IACd,CAAC;IAEkB,oBAAoB,CACrC,IAAqB;QAErB,MAAM,WAAW,GAAG,KAAK,C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D,MAAM,WAAW,GAAG,iBAAiB,CAAC,IAAI,CAAC,eAAe,CAAC,CAAC;QAE5D,OAAO;YACL,GAAG,IAAI;YACP,YAAY,EAAE,IAAI,CAAC,YAAY;gBAC7B,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC,YAAY,EAAE,WAAW,CAAC;gBACrC,CAAC,CAAC,CAAC,WAAW,CAAC;SAClB,CAAC;IACJ,CAAC;IAEO,uBAAuB,CAAC,IAAqB;QACnD,MAAM,WAAW,GAAG,iBAAiB,CAAC,IAAI,CAAC,eAAe,CAAC,CAAC;QAE5D,OAAO;YACL,GAAG,IAAI;YACP,YAAY,EAAE,IAAI,CAAC,YAAY;gBAC7B,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC,YAAY,EAAE,WAAW,CAAC;gBACrC,CAAC,CAAC,CAAC,WAAW,CAAC;SAClB,CAAC;IACJ,CAAC;CACF","sourcesContent":["import {\n type DeleteQueryNode,\n type InsertQueryNode,\n OperationNodeTransformer,\n type RootOperationNode,\n SelectModifierNode,\n type SelectQueryNode,\n sql,\n type UpdateQueryNode,\n} from 'kysely';\n\nfunction createCommentNode(repositoryName: string): SelectModifierNode {\n return SelectModifierNode.createWithExpression(\n sql.raw(`/* repository: ${repositoryName} */`).toOperationNode()\n );\n}\n/**\n * Transformer that adds a SQL comment to queries for pganalyze tracking.\n * The comment format is: repository: REPOSITORY_NAME\n *\n * This works by appending the comment to queries using the endModifiers property,\n * similar to how modifyEnd works.\n */\nexport class CommentTransformer extends OperationNodeTransformer {\n constructor(readonly _repositoryName: string) {\n super();\n }\n\n transformRootNode(node: RootOperationNode): RootOperationNode {\n if (node.kind === 'SelectQueryNode') {\n return this.transformSelectQuery(node);\n }\n if (node.kind === 'InsertQueryNode') {\n return this.transformInsertQuery(node);\n }\n if (node.kind === 'UpdateQueryNode') {\n return this.transformUpdateQuery(node);\n }\n if (node.kind === 'DeleteQueryNode') {\n return this.transformDeleteQuery(node);\n }\n return node;\n }\n\n protected override transformSelectQuery(\n node: SelectQueryNode\n ): SelectQueryNode {\n const transformed = super.transformSelectQuery(node);\n return this.addCommentToSelectQuery(transformed);\n }\n\n protected override transformInsertQuery(\n node: InsertQueryNode\n ): InsertQueryNode {\n const transformed = super.transformInsertQuery(node);\n return this.addCommentToInsertQuery(transformed);\n }\n\n protected override transformUpdateQuery(\n node: UpdateQueryNode\n ): UpdateQueryNode {\n const transformed = super.transformUpdateQuery(node);\n return this.addCommentToUpdateQuery(transformed);\n }\n\n protected override transformDeleteQuery(\n node: DeleteQueryNode\n ): DeleteQueryNode {\n const transformed = super.transformDeleteQuery(node);\n return this.addCommentToDeleteQuery(transformed);\n }\n\n private addCommentToSelectQuery(node: SelectQueryNode): SelectQueryNode {\n // Append comment using endModifiers property, similar to modifyEnd\n const commentNode = createCommentNode(this._repositoryName);\n\n return {\n ...node,\n endModifiers: node.endModifiers\n ? [...node.endModifiers, commentNode]\n : [commentNode],\n };\n }\n\n private addCommentToInsertQuery(node: InsertQueryNode): InsertQueryNode {\n const commentNode = createCommentNode(this._repositoryName);\n\n return {\n ...node,\n endModifiers: node.endModifiers\n ? [...node.endModifiers, commentNode]\n : [commentNode],\n };\n }\n\n private addCommentToUpdateQuery(node: UpdateQueryNode): UpdateQueryNode {\n const commentNode = createCommentNode(this._repositoryName);\n\n return {\n ...node,\n endModifiers: node.endModifiers\n ? [...node.endModifiers, commentNode]\n : [commentNode],\n };\n }\n\n private addCommentToDeleteQuery(node: DeleteQueryNode): DeleteQueryNode {\n const commentNode = createCommentNode(this._repositoryName);\n\n return {\n ...node,\n endModifiers: node.endModifiers\n ? [...node.endModifiers, commentNode]\n : [commentNode],\n };\n }\n}\n"]}
1
+ {"version":3,"file":"comment-transformer.js","sourceRoot":"src/","sources":["pganalyze-comment-plugin/comment-transformer.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,wBAAwB,EAExB,kBAAkB,EAElB,GAAG,GAEJ,MAAM,QAAQ,CAAC;AAEhB,SAAS,iBAAiB,CAAC,c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B,CAAC,IAAqB,EAAmB;QACtE,MAAM,WAAW,GAAG,iBAAiB,CAAC,IAAI,CAAC,eAAe,CAAC,CAAC;QAE5D,OAAO;YACL,GAAG,IAAI;YACP,YAAY,EAAE,IAAI,CAAC,YAAY;gBAC7B,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC,YAAY,EAAE,WAAW,CAAC;gBACrC,CAAC,CAAC,CAAC,WAAW,CAAC;SAClB,CAAC;IAAA,CACH;CACF","sourcesContent":["import {\n type DeleteQueryNode,\n type InsertQueryNode,\n OperationNodeTransformer,\n type RootOperationNode,\n SelectModifierNode,\n type SelectQueryNode,\n sql,\n type UpdateQueryNode,\n} from 'kysely';\n\nfunction createCommentNode(repositoryName: string): SelectModifierNode {\n return SelectModifierNode.createWithExpression(\n sql.raw(`/* repository: ${repositoryName} */`).toOperationNode()\n );\n}\n/**\n * Transformer that adds a SQL comment to queries for pganalyze tracking.\n * The comment format is: repository: REPOSITORY_NAME\n *\n * This works by appending the comment to queries using the endModifiers property,\n * similar to how modifyEnd works.\n */\nexport class CommentTransformer extends OperationNodeTransformer {\n constructor(readonly _repositoryName: string) {\n super();\n }\n\n transformRootNode(node: RootOperationNode): RootOperationNode {\n if (node.kind === 'SelectQueryNode') {\n return this.transformSelectQuery(node);\n }\n if (node.kind === 'InsertQueryNode') {\n return this.transformInsertQuery(node);\n }\n if (node.kind === 'UpdateQueryNode') {\n return this.transformUpdateQuery(node);\n }\n if (node.kind === 'DeleteQueryNode') {\n return this.transformDeleteQuery(node);\n }\n return node;\n }\n\n protected override transformSelectQuery(\n node: SelectQueryNode\n ): SelectQueryNode {\n const transformed = super.transformSelectQuery(node);\n return this.addCommentToSelectQuery(transformed);\n }\n\n protected override transformInsertQuery(\n node: InsertQueryNode\n ): InsertQueryNode {\n const transformed = super.transformInsertQuery(node);\n return this.addCommentToInsertQuery(transformed);\n }\n\n protected override transformUpdateQuery(\n node: UpdateQueryNode\n ): UpdateQueryNode {\n const transformed = super.transformUpdateQuery(node);\n return this.addCommentToUpdateQuery(transformed);\n }\n\n protected override transformDeleteQuery(\n node: DeleteQueryNode\n ): DeleteQueryNode {\n const transformed = super.transformDeleteQuery(node);\n return this.addCommentToDeleteQuery(transformed);\n }\n\n private addCommentToSelectQuery(node: SelectQueryNode): SelectQueryNode {\n // Append comment using endModifiers property, similar to modifyEnd\n const commentNode = createCommentNode(this._repositoryName);\n\n return {\n ...node,\n endModifiers: node.endModifiers\n ? [...node.endModifiers, commentNode]\n : [commentNode],\n };\n }\n\n private addCommentToInsertQuery(node: InsertQueryNode): InsertQueryNode {\n const commentNode = createCommentNode(this._repositoryName);\n\n return {\n ...node,\n endModifiers: node.endModifiers\n ? [...node.endModifiers, commentNode]\n : [commentNode],\n };\n }\n\n private addCommentToUpdateQuery(node: UpdateQueryNode): UpdateQueryNode {\n const commentNode = createCommentNode(this._repositoryName);\n\n return {\n ...node,\n endModifiers: node.endModifiers\n ? [...node.endModifiers, commentNode]\n : [commentNode],\n };\n }\n\n private addCommentToDeleteQuery(node: DeleteQueryNode): DeleteQueryNode {\n const commentNode = createCommentNode(this._repositoryName);\n\n return {\n ...node,\n endModifiers: node.endModifiers\n ? [...node.endModifiers, commentNode]\n : [commentNode],\n };\n }\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"src/","sources":["pganalyze-comment-plugin/index.ts"],"names":[],"mappings":"AAQA,OAAO,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAC;AAE3D,MAAM,OAAO,4BAA4B;IAC9B,YAAY,CAAqB;IAE1C,YAAY,OAA+B;QACzC,IAAI,CAAC,YAAY,GAAG,IAAI,kBAAkB,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC;IACjE,CAAC;IAED,cAAc,CAAC,IAA8B;QAC3C,OAAO,IAAI,CAAC,YAAY,CAAC,iBAAiB,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IACxD,CAAC;IAED,KAAK,CAAC,eAAe,CACnB,IAA+B;QAE/B,OAAO,IAAI,CAAC,MAAM,CAAC;IACrB,CAAC;CACF","sourcesContent":["import type {\n KyselyPlugin,\n PluginTransformQueryArgs,\n PluginTransformResultArgs,\n QueryResult,\n RootOperationNode,\n UnknownRow,\n} from 'kysely';\nimport { CommentTransformer } from './comment-transformer';\n\nexport class KyselyPganalyzeCommentPlugin implements KyselyPlugin {\n readonly #transformer: CommentTransformer;\n\n constructor(options: { repository: string }) {\n this.#transformer = new CommentTransformer(options.repository);\n }\n\n transformQuery(args: PluginTransformQueryArgs): RootOperationNode {\n return this.#transformer.transformRootNode(args.node);\n }\n\n async transformResult(\n args: PluginTransformResultArgs\n ): Promise<QueryResult<UnknownRow>> {\n return args.result;\n }\n}\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"src/","sources":["pganalyze-comment-plugin/index.ts"],"names":[],"mappings":"AAQA,OAAO,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAC;AAE3D,MAAM,OAAO,4BAA4B;IAC9B,YAAY,CAAqB;IAE1C,YAAY,OAA+B,EAAE;QAC3C,IAAI,CAAC,YAAY,GAAG,IAAI,kBAAkB,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC;IAAA,CAChE;IAED,cAAc,CAAC,IAA8B,EAAqB;QAChE,OAAO,IAAI,CAAC,YAAY,CAAC,iBAAiB,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAAA,CACvD;IAED,KAAK,CAAC,eAAe,CACnB,IAA+B,EACG;QAClC,OAAO,IAAI,CAAC,MAAM,CAAC;IAAA,CACpB;CACF","sourcesContent":["import type {\n KyselyPlugin,\n PluginTransformQueryArgs,\n PluginTransformResultArgs,\n QueryResult,\n RootOperationNode,\n UnknownRow,\n} from 'kysely';\nimport { CommentTransformer } from './comment-transformer';\n\nexport class KyselyPganalyzeCommentPlugin implements KyselyPlugin {\n readonly #transformer: CommentTransformer;\n\n constructor(options: { repository: string }) {\n this.#transformer = new CommentTransformer(options.repository);\n }\n\n transformQuery(args: PluginTransformQueryArgs): RootOperationNode {\n return this.#transformer.transformRootNode(args.node);\n }\n\n async transformResult(\n args: PluginTransformResultArgs\n ): Promise<QueryResult<UnknownRow>> {\n return args.result;\n }\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"plugins.js","sourceRoot":"src/","sources":["plugins.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,MAAM,IAAI,CAAC,GAGZ,MAAM,QAAQ,CAAC;AAChB,OAAO,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAChD,OAAO,EAAE,4BAA4B,EAAE,MAAM,4BAA4B,CAAC;AAG1E,MAAM,UAAU,SAAS,CACvB,OAAgB,EAChB,OAA4D;IAE5D,MAAM,OAAO,GAAmB,CAAC,IAAI,gBAAgB,EAAE,CAAC,CAAC;IAEzD,IAAI,OAAO,EAAE,cAAc,EAAE,CAAC;QAC5B,OAAO,CAAC,IAAI,CACV,IAAI,4BAA4B,CAAC;YAC/B,UAAU,EAAE,OAAO,CAAC,cAAc;SACnC,CAAC,CACH,CAAC;IACJ,CAAC;IACD,MAAM,MAAM,GAAG,IAAI,CAAC,CAAK;QACvB,OAAO;QACP,OAAO;QACP,GAAG,EAAE,OAAO,EAAE,GAAG,KAAK,IAAI,CAAC,CAAC,CAAC,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC,CAAC,CAAC,OAAO,EAAE,GAAG;KAC/D,CAAC,CAAC;IACH,OAAO,MAAM,CAAC;AAChB,CAAC","sourcesContent":["import {\n type Dialect,\n Kysely as K,\n type KyselyPlugin,\n type LogConfig,\n} from 'kysely';\nimport { CustomCasePlugin } from './camel-case';\nimport { KyselyPganalyzeCommentPlugin } from './pganalyze-comment-plugin';\nimport type { DB } from './v1.generated';\n\nexport function getKysely(\n dialect: Dialect,\n options: { repositoryName?: string; log?: true | LogConfig }\n) {\n const plugins: KyselyPlugin[] = [new CustomCasePlugin()];\n\n if (options?.repositoryName) {\n plugins.push(\n new KyselyPganalyzeCommentPlugin({\n repository: options.repositoryName,\n })\n );\n }\n const kysely = new K<DB>({\n dialect,\n plugins,\n log: options?.log === true ? ['query', 'error'] : options?.log,\n });\n return kysely;\n}\n"]}
1
+ {"version":3,"file":"plugins.js","sourceRoot":"src/","sources":["plugins.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,MAAM,IAAI,CAAC,GAGZ,MAAM,QAAQ,CAAC;AAChB,OAAO,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAChD,OAAO,EAAE,4BAA4B,EAAE,MAAM,4BAA4B,CAAC;AAG1E,MAAM,UAAU,SAAS,CACvB,OAAgB,EAChB,OAA4D,EAC5D;IACA,MAAM,OAAO,GAAmB,CAAC,IAAI,gBAAgB,EAAE,CAAC,CAAC;IAEzD,IAAI,OAAO,EAAE,cAAc,EAAE,CAAC;QAC5B,OAAO,CAAC,IAAI,CACV,IAAI,4BAA4B,CAAC;YAC/B,UAAU,EAAE,OAAO,CAAC,cAAc;SACnC,CAAC,CACH,CAAC;IACJ,CAAC;IACD,MAAM,MAAM,GAAG,IAAI,CAAC,CAAK;QACvB,OAAO;QACP,OAAO;QACP,GAAG,EAAE,OAAO,EAAE,GAAG,KAAK,IAAI,CAAC,CAAC,CAAC,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC,CAAC,CAAC,OAAO,EAAE,GAAG;KAC/D,CAAC,CAAC;IACH,OAAO,MAAM,CAAC;AAAA,CACf","sourcesContent":["import {\n type Dialect,\n Kysely as K,\n type KyselyPlugin,\n type LogConfig,\n} from 'kysely';\nimport { CustomCasePlugin } from './camel-case';\nimport { KyselyPganalyzeCommentPlugin } from './pganalyze-comment-plugin';\nimport type { DB } from './v1.generated';\n\nexport function getKysely(\n dialect: Dialect,\n options: { repositoryName?: string; log?: true | LogConfig }\n) {\n const plugins: KyselyPlugin[] = [new CustomCasePlugin()];\n\n if (options?.repositoryName) {\n plugins.push(\n new KyselyPganalyzeCommentPlugin({\n repository: options.repositoryName,\n })\n );\n }\n const kysely = new K<DB>({\n dialect,\n plugins,\n log: options?.log === true ? ['query', 'error'] : options?.log,\n });\n return kysely;\n}\n"]}
@@ -1 +1 @@
1
- export * from './is-active-or-at-least-one-ownership-period-active';
1
+ export * from './status';
@@ -1,2 +1,2 @@
1
- export * from './is-active-or-at-least-one-ownership-period-active';
1
+ export * from './status';
2
2
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"src/","sources":["query/listing/index.ts"],"names":[],"mappings":"AAAA,cAAc,qDAAqD,CAAC","sourcesContent":["export * from './is-active-or-at-least-one-ownership-period-active';\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"src/","sources":["query/listing/index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAC","sourcesContent":["export * from './status';\n"]}
@@ -0,0 +1,26 @@
1
+ import type { DB, ExpressionBuilder, PublicListing } from '../../isomorphic';
2
+ export declare function whereListingIsInactive(eb: ExpressionBuilder<DB & {
3
+ l: PublicListing;
4
+ }, 'l'>, today?: string): import("kysely").ExpressionWrapper<DB & {
5
+ l: PublicListing;
6
+ }, "l", import("kysely").SqlBool>;
7
+ export declare function whereListingIsActive(eb: ExpressionBuilder<DB & {
8
+ l: PublicListing;
9
+ }, 'l'>, today?: string): import("kysely").ExpressionWrapper<DB & {
10
+ l: PublicListing;
11
+ }, "l", 0 | 1 | boolean>;
12
+ export declare function selectListingIsInactive(eb: ExpressionBuilder<DB & {
13
+ l: PublicListing;
14
+ }, 'l'>, today?: string): import("kysely").ExpressionWrapper<DB & {
15
+ l: PublicListing;
16
+ }, "l", import("kysely").SqlBool>;
17
+ export declare function selectListingIsActive(eb: ExpressionBuilder<DB & {
18
+ l: PublicListing;
19
+ }, 'l'>, today?: string): import("kysely").ExpressionWrapper<DB & {
20
+ l: PublicListing;
21
+ }, "l", 0 | 1 | boolean>;
22
+ export declare function selectListingStatus(eb: ExpressionBuilder<DB & {
23
+ l: PublicListing;
24
+ }, 'l'>, today?: string): import("kysely").ExpressionWrapper<DB & {
25
+ l: PublicListing;
26
+ }, "l", string>;
@@ -0,0 +1,41 @@
1
+ import { day } from '@vrplatform/utils';
2
+ function hasInactiveOwnership(eb, today) {
3
+ return eb.exists(eb
4
+ .selectFrom('public.listingOwnershipPeriod as lop')
5
+ .select('lop.id')
6
+ .whereRef('lop.listingId', '=', 'l.id')
7
+ .whereRef('lop.tenantId', '=', 'l.tenantId')
8
+ .where('lop.setListingInactive', '=', true)
9
+ .where((eb2) => eb2.or([
10
+ eb2.and([
11
+ eb2('lop.startAt', '<=', today),
12
+ eb2('lop.endAt', '>=', today),
13
+ ]),
14
+ eb2.and([
15
+ eb2('lop.startAt', '<=', today),
16
+ eb2('lop.endAt', 'is', null),
17
+ ]),
18
+ ]))
19
+ .limit(1));
20
+ }
21
+ export function whereListingIsInactive(eb, today = day().yyyymmdd()) {
22
+ return hasInactiveOwnership(eb, today);
23
+ }
24
+ export function whereListingIsActive(eb, today = day().yyyymmdd()) {
25
+ return eb.not(whereListingIsInactive(eb, today));
26
+ }
27
+ export function selectListingIsInactive(eb, today = day().yyyymmdd()) {
28
+ return whereListingIsInactive(eb, today);
29
+ }
30
+ export function selectListingIsActive(eb, today = day().yyyymmdd()) {
31
+ return whereListingIsActive(eb, today);
32
+ }
33
+ export function selectListingStatus(eb, today = day().yyyymmdd()) {
34
+ return eb
35
+ .case()
36
+ .when(whereListingIsInactive(eb, today))
37
+ .then('inactive')
38
+ .else('active')
39
+ .end();
40
+ }
41
+ //# sourceMappingURL=status.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"status.js","sourceRoot":"src/","sources":["query/listing/status.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,mBAAmB,CAAC;AAGxC,SAAS,oBAAoB,CAC3B,EAAqD,EACrD,KAAa,EACb;IACA,OAAO,EAAE,CAAC,MAAM,CACd,EAAE;SACC,UAAU,CAAC,sCAAsC,CAAC;SAClD,MAAM,CAAC,QAAQ,CAAC;SAChB,QAA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,EAAE,EAAE,KAAK,CAAC,CAAC;AAAA,CACxC;AAED,MAAM,UAAU,mBAAmB,CACjC,EAAqD,EACrD,KAAK,GAAW,GAAG,EAAE,CAAC,QAAQ,EAAE,EAChC;IACA,OAAO,EAAE;SACN,IAAI,EAAE;SACN,IAAI,CAAC,sBAAsB,CAAC,EAAE,EAAE,KAAK,CAAC,CAAC;SACvC,IAAI,CAAC,UAAU,CAAC;SAChB,IAAI,CAAC,QAAQ,CAAC;SACd,GAAG,EAAE,CAAC;AAAA,CACV","sourcesContent":["import { day } from '@vrplatform/utils';\nimport type { DB, ExpressionBuilder, PublicListing } from '../../isomorphic';\n\nfunction hasInactiveOwnership(\n eb: ExpressionBuilder<DB & { l: PublicListing }, 'l'>,\n today: string\n) {\n return eb.exists(\n eb\n .selectFrom('public.listingOwnershipPeriod as lop')\n .select('lop.id')\n .whereRef('lop.listingId', '=', 'l.id')\n .whereRef('lop.tenantId', '=', 'l.tenantId')\n .where('lop.setListingInactive', '=', true)\n .where((eb2) =>\n eb2.or([\n eb2.and([\n eb2('lop.startAt', '<=', today),\n eb2('lop.endAt', '>=', today),\n ]),\n eb2.and([\n eb2('lop.startAt', '<=', today),\n eb2('lop.endAt', 'is', null),\n ]),\n ])\n )\n .limit(1)\n );\n}\n\nexport function whereListingIsInactive(\n eb: ExpressionBuilder<DB & { l: PublicListing }, 'l'>,\n today: string = day().yyyymmdd()\n) {\n return hasInactiveOwnership(eb, today);\n}\n\nexport function whereListingIsActive(\n eb: ExpressionBuilder<DB & { l: PublicListing }, 'l'>,\n today: string = day().yyyymmdd()\n) {\n return eb.not(whereListingIsInactive(eb, today));\n}\n\nexport function selectListingIsInactive(\n eb: ExpressionBuilder<DB & { l: PublicListing }, 'l'>,\n today: string = day().yyyymmdd()\n) {\n return whereListingIsInactive(eb, today);\n}\n\nexport function selectListingIsActive(\n eb: ExpressionBuilder<DB & { l: PublicListing }, 'l'>,\n today: string = day().yyyymmdd()\n) {\n return whereListingIsActive(eb, today);\n}\n\nexport function selectListingStatus(\n eb: ExpressionBuilder<DB & { l: PublicListing }, 'l'>,\n today: string = day().yyyymmdd()\n) {\n return eb\n .case()\n .when(whereListingIsInactive(eb, today))\n .then('inactive')\n .else('active')\n .end();\n}\n"]}
@@ -1,6 +1,9 @@
1
1
  import type { Kysely } from 'kysely';
2
2
  import { type UseLocalKyselyOptions } from '../local';
3
3
  import type { DB } from '../v1.generated';
4
+ declare global {
5
+ var __vrplatform_testSharedKysely: Promise<Kysely<DB>> | Kysely<DB> | undefined;
6
+ }
4
7
  /**
5
8
  * @deprecated Use `useLocalKyselyResource` instead.
6
9
  */
@@ -14,6 +14,15 @@ export async function useTestKysely(cleanupStrategy, args) {
14
14
  };
15
15
  }
16
16
  export async function useTestAutoCleanupKysely(args) {
17
+ if (process.env.VR_TEST_SHARED_KYSELY === '1') {
18
+ const existing = globalThis.__vrplatform_testSharedKysely;
19
+ if (!existing) {
20
+ const created = useLocalKysely(args);
21
+ globalThis.__vrplatform_testSharedKysely = created;
22
+ return created;
23
+ }
24
+ return await existing;
25
+ }
17
26
  const kysely = await useLocalKysely(args);
18
27
  afterAll(async () => {
19
28
  await kysely.destroy();
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"src/","sources":["test/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAC;AAEpC,OAAO,EAA8B,cAAc,EAAE,MAAM,UAAU,CAAC;AAGtE;;GAEG;AACH,MAAM,CAAC,KAAK,UAAU,aAAa,CACjC,eAA2B,EAC3B,IAA4B;IAE5B,MAAM,MAAM,GAAG,MAAM,cAAc,CAAC,IAAI,CAAC,CAAC;IAE1C,IAAI,eAAe,KAAK,UAAU;QAChC,QAAQ,CAAC,KAAK,IAAI,EAAE;YAClB,MAAM,MAAM,CAAC,OAAO,EAAE,CAAC;QACzB,CAAC,CAAC,CAAC;IAEL,OAAO;QACL,MAAM;KACP,CAAC;AACJ,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,wBAAwB,CAAC,IAA4B;IACzE,MAAM,MAAM,GAAG,MAAM,cAAc,CAAC,IAAI,CAAC,CAAC;IAE1C,QAAQ,CAAC,KAAK,IAAI,EAAE;QAClB,MAAM,MAAM,CAAC,OAAO,EAAE,CAAC;IACzB,CAAC,CAAC,CAAC;IAEH,OAAO,MAAM,CAAC;AAChB,CAAC;AAMD,MAAM,CAAC,KAAK,UAAU,sBAAsB,CAC1C,IAA4B;IAE5B,MAAM,MAAM,GAAG,MAAM,cAAc,CAAC,IAAI,CAAC,CAAC;IAE1C,OAAO,IAAI,KAAK,CACd,EAAE,EACF;QACE,GAAG,CAAC,OAAO,EAAE,IAAI;YACf,8CAA8C;YAC9C,IAAI,IAAI,KAAK,MAAM,CAAC,YAAY,EAAE,CAAC;gBACjC,OAAO,KAAK,IAAI,EAAE;oBAChB,MAAM,MAAM,CAAC,OAAO,EAAE,CAAC;gBACzB,CAAC,CAAC;YACJ,CAAC;YACD,IAAI,IAAI,KAAK,QAAQ,EAAE,CAAC;gBACtB,OAAO,MAAM,CAAC;YAChB,CAAC;YACD,IAAI,OAAO,MAAM,CAAC,IAAI,CAAC,KAAK,UAAU,EAAE,CAAC;gBACvC,OAAO,MAAM,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;YACnC,CAAC;YACD,OAAO,MAAM,CAAC,IAAI,CAAC,CAAC;QACtB,CAAC;KACF,CACY,CAAC;AAClB,CAAC","sourcesContent":["import { afterAll } from 'bun:test';\nimport type { Kysely } from 'kysely';\nimport { type UseLocalKyselyOptions, useLocalKysely } from '../local';\nimport type { DB } from '../v1.generated';\n\n/**\n * @deprecated Use `useLocalKyselyResource` instead.\n */\nexport async function useTestKysely(\n cleanupStrategy: 'afterAll',\n args?: UseLocalKyselyOptions\n) {\n const kysely = await useLocalKysely(args);\n\n if (cleanupStrategy === 'afterAll')\n afterAll(async () => {\n await kysely.destroy();\n });\n\n return {\n kysely,\n };\n}\n\nexport async function useTestAutoCleanupKysely(args?: UseLocalKyselyOptions) {\n const kysely = await useLocalKysely(args);\n\n afterAll(async () => {\n await kysely.destroy();\n });\n\n return kysely;\n}\n\ntype ReturnType = Kysely<DB> & {\n [Symbol.dispose]: () => Promise<void>;\n};\n\nexport async function useLocalKyselyResource(\n args?: UseLocalKyselyOptions\n): Promise<ReturnType> {\n const kysely = await useLocalKysely(args);\n\n return new Proxy(\n {},\n {\n get(_target, prop) {\n // somehow not working if using Symbol.dispose\n if (prop === Symbol.asyncDispose) {\n return async () => {\n await kysely.destroy();\n };\n }\n if (prop === 'kysely') {\n return kysely;\n }\n if (typeof kysely[prop] === 'function') {\n return kysely[prop].bind(kysely);\n }\n return kysely[prop];\n },\n }\n ) as ReturnType;\n}\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"src/","sources":["test/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAC;AAEpC,OAAO,EAA8B,cAAc,EAAE,MAAM,UAAU,CAAC;AAYtE;;GAEG;AACH,MAAM,CAAC,KAAK,UAAU,aAAa,CACjC,eAA2B,EAC3B,IAA4B,EAC5B;IACA,MAAM,MAAM,GAAG,MAAM,cAAc,CAAC,IAAI,CAAC,CAAC;IAE1C,IAAI,eAAe,KAAK,UAAU;QAChC,QAAQ,CAAC,KAAK,IAAI,EAAE,CAAC;YACnB,MAAM,MAAM,CAAC,OAAO,EAAE,CAAC;QAAA,CACxB,CAAC,CAAC;IAEL,OAAO;QACL,MAAM;KACP,CAAC;AAAA,CACH;AAED,MAAM,CAAC,KAAK,UAAU,wBAAwB,CAAC,IAA4B,EAAE;IAC3E,IAAI,OAAO,CAAC,GAAG,CAAC,qBAAqB,KAAK,GAAG,EAAE,CAAC;QAC9C,MAAM,QAAQ,GAAG,UAAU,CAAC,6BAA6B,CAAC;QAC1D,IAAI,CAAC,QAAQ,EAAE,CAAC;YACd,MAAM,OAAO,GAAG,cAAc,CAAC,IAAI,CAAC,CAAC;YACrC,UAAU,CAAC,6BAA6B,GAAG,OAAO,CAAC;YACnD,OAAO,OAAO,CAAC;QACjB,CAAC;QACD,OAAO,MAAM,QAAQ,CAAC;IACxB,CAAC;IAED,MAAM,MAAM,GAAG,MAAM,cAAc,CAAC,IAAI,CAAC,CAAC;IAE1C,QAAQ,CAAC,KAAK,IAAI,EAAE,CAAC;QACnB,MAAM,MAAM,CAAC,OAAO,EAAE,CAAC;IAAA,CACxB,CAAC,CAAC;IAEH,OAAO,MAAM,CAAC;AAAA,CACf;AAMD,MAAM,CAAC,KAAK,UAAU,sBAAsB,CAC1C,IAA4B,EACP;IACrB,MAAM,MAAM,GAAG,MAAM,cAAc,CAAC,IAAI,CAAC,CAAC;IAE1C,OAAO,IAAI,KAAK,CACd,EAAE,EACF;QACE,GAAG,CAAC,OAAO,EAAE,IAAI,EAAE;YACjB,8CAA8C;YAC9C,IAAI,IAAI,KAAK,MAAM,CAAC,YAAY,EAAE,CAAC;gBACjC,OAAO,KAAK,IAAI,EAAE,CAAC;oBACjB,MAAM,MAAM,CAAC,OAAO,EAAE,CAAC;gBAAA,CACxB,CAAC;YACJ,CAAC;YACD,IAAI,IAAI,KAAK,QAAQ,EAAE,CAAC;gBACtB,OAAO,MAAM,CAAC;YAChB,CAAC;YACD,IAAI,OAAO,MAAM,CAAC,IAAI,CAAC,KAAK,UAAU,EAAE,CAAC;gBACvC,OAAO,MAAM,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;YACnC,CAAC;YACD,OAAO,MAAM,CAAC,IAAI,CAAC,CAAC;QAAA,CACrB;KACF,CACY,CAAC;AAAA,CACjB","sourcesContent":["import { afterAll } from 'bun:test';\nimport type { Kysely } from 'kysely';\nimport { type UseLocalKyselyOptions, useLocalKysely } from '../local';\nimport type { DB } from '../v1.generated';\n\ndeclare global {\n // Shared Kysely instance for test processes that run multiple files in one Bun process.\n // This must be process-global to allow cross-file reuse.\n var __vrplatform_testSharedKysely:\n | Promise<Kysely<DB>>\n | Kysely<DB>\n | undefined;\n}\n\n/**\n * @deprecated Use `useLocalKyselyResource` instead.\n */\nexport async function useTestKysely(\n cleanupStrategy: 'afterAll',\n args?: UseLocalKyselyOptions\n) {\n const kysely = await useLocalKysely(args);\n\n if (cleanupStrategy === 'afterAll')\n afterAll(async () => {\n await kysely.destroy();\n });\n\n return {\n kysely,\n };\n}\n\nexport async function useTestAutoCleanupKysely(args?: UseLocalKyselyOptions) {\n if (process.env.VR_TEST_SHARED_KYSELY === '1') {\n const existing = globalThis.__vrplatform_testSharedKysely;\n if (!existing) {\n const created = useLocalKysely(args);\n globalThis.__vrplatform_testSharedKysely = created;\n return created;\n }\n return await existing;\n }\n\n const kysely = await useLocalKysely(args);\n\n afterAll(async () => {\n await kysely.destroy();\n });\n\n return kysely;\n}\n\ntype ReturnType = Kysely<DB> & {\n [Symbol.dispose]: () => Promise<void>;\n};\n\nexport async function useLocalKyselyResource(\n args?: UseLocalKyselyOptions\n): Promise<ReturnType> {\n const kysely = await useLocalKysely(args);\n\n return new Proxy(\n {},\n {\n get(_target, prop) {\n // somehow not working if using Symbol.dispose\n if (prop === Symbol.asyncDispose) {\n return async () => {\n await kysely.destroy();\n };\n }\n if (prop === 'kysely') {\n return kysely;\n }\n if (typeof kysely[prop] === 'function') {\n return kysely[prop].bind(kysely);\n }\n return kysely[prop];\n },\n }\n ) as ReturnType;\n}\n"]}
@@ -0,0 +1,4 @@
1
+ export declare function useTestKysely(cleanupStrategy: 'afterAll' | 'using' | 'manual'): Promise<{
2
+ kysely: import("kysely").Kysely<import("./v1.generated").DB>;
3
+ [Symbol.dispose]: () => Promise<void>;
4
+ }>;
@@ -0,0 +1,16 @@
1
+ import { afterAll } from 'bun:test';
2
+ import { useLocalKysely } from './local';
3
+ export async function useTestKysely(cleanupStrategy) {
4
+ const kysely = await useLocalKysely();
5
+ if (cleanupStrategy === 'afterAll')
6
+ afterAll(async () => {
7
+ await kysely.destroy();
8
+ });
9
+ return {
10
+ kysely,
11
+ [Symbol.dispose]: async () => {
12
+ await kysely.destroy();
13
+ },
14
+ };
15
+ }
16
+ //# sourceMappingURL=test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"test.js","sourceRoot":"src/","sources":["test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAC;AACpC,OAAO,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AAEzC,MAAM,CAAC,KAAK,UAAU,aAAa,CACjC,eAAgD;IAEhD,MAAM,MAAM,GAAG,MAAM,cAAc,EAAE,CAAC;IAEtC,IAAI,eAAe,KAAK,UAAU;QAChC,QAAQ,CAAC,KAAK,IAAI,EAAE;YAClB,MAAM,MAAM,CAAC,OAAO,EAAE,CAAC;QACzB,CAAC,CAAC,CAAC;IACL,OAAO;QACL,MAAM;QACN,CAAC,MAAM,CAAC,OAAO,CAAC,EAAE,KAAK,IAAI,EAAE;YAC3B,MAAM,MAAM,CAAC,OAAO,EAAE,CAAC;QACzB,CAAC;KACF,CAAC;AACJ,CAAC","sourcesContent":["import { afterAll } from 'bun:test';\nimport { useLocalKysely } from './local';\n\nexport async function useTestKysely(\n cleanupStrategy: 'afterAll' | 'using' | 'manual'\n) {\n const kysely = await useLocalKysely();\n\n if (cleanupStrategy === 'afterAll')\n afterAll(async () => {\n await kysely.destroy();\n });\n return {\n kysely,\n [Symbol.dispose]: async () => {\n await kysely.destroy();\n },\n };\n}\n"]}
@@ -1 +1 @@
1
- {"root":["../../src/error.ts","../../src/index.ts","../../src/isomorphic.ts","../../src/plugins.ts","../../src/v1.generated.ts","../../src/camel-case/index.ts","../../src/local/digest.ts","../../src/local/generate.ts","../../src/local/index.ts","../../src/pganalyze-comment-plugin/comment-transformer.ts","../../src/pganalyze-comment-plugin/index.ts","../../src/query/index.ts","../../src/query/listing/index.ts","../../src/query/listing/is-active-or-at-least-one-ownership-period-active.ts","../../src/test/index.ts"],"version":"5.9.3"}
1
+ {"version":"7.0.0-dev.20251218.3","root":["../../src/error.ts","../../src/index.ts","../../src/isomorphic.ts","../../src/plugins.ts","../../src/v1.generated.ts","../../src/camel-case/index.ts","../../src/local/digest.ts","../../src/local/generate.ts","../../src/local/index.ts","../../src/pganalyze-comment-plugin/comment-transformer.ts","../../src/pganalyze-comment-plugin/index.ts","../../src/query/index.ts","../../src/query/listing/index.ts","../../src/query/listing/status.ts","../../src/test/index.ts"]}
@@ -3,6 +3,7 @@
3
3
  * Please do not edit it manually.
4
4
  */
5
5
  import type { ColumnType } from "kysely";
6
+ export type AccountingTransactionAttachmentStatus = "attached" | "deleting" | "ready" | "uploading";
6
7
  export type Generated<T> = T extends ColumnType<infer S, infer I, infer U> ? ColumnType<S, I | undefined, U> : ColumnType<T, T | undefined, T>;
7
8
  export type Int8 = ColumnType<string, bigint | number | string, bigint | number | string>;
8
9
  export type Json = JsonValue;
@@ -156,7 +157,7 @@ export interface AccountingContact {
156
157
  */
157
158
  shortRef: string | null;
158
159
  sourceId: string | null;
159
- status: Generated<string | null>;
160
+ status: string | null;
160
161
  taxId: string | null;
161
162
  tenantId: string;
162
163
  /**
@@ -254,7 +255,9 @@ export interface AccountingTransaction {
254
255
  dueAt: Timestamp | null;
255
256
  id: Generated<string>;
256
257
  matchBankAccountLast4: string | null;
257
- matchers: Json | null;
258
+ matchLineTypeClassification: string | null;
259
+ matchReservationConfirmationCode: string | null;
260
+ matchReservationStripeGuestRef: string | null;
258
261
  matchStatus: Generated<string | null>;
259
262
  paidAt: Timestamp | null;
260
263
  paidStatus: Generated<string | null>;
@@ -272,9 +275,27 @@ export interface AccountingTransaction {
272
275
  uniqueRef: string | null;
273
276
  updatedAt: Generated<Timestamp>;
274
277
  }
278
+ export interface AccountingTransactionAttachment {
279
+ byteSize: number;
280
+ contentType: string;
281
+ createdAt: Generated<Timestamp>;
282
+ expiresAt: Timestamp | null;
283
+ extension: string | null;
284
+ filename: string;
285
+ id: Generated<string>;
286
+ isOwnerAccessible: Generated<boolean>;
287
+ r2Key: string;
288
+ status: Generated<AccountingTransactionAttachmentStatus>;
289
+ tenantId: string;
290
+ transactionId: string | null;
291
+ updatedAt: Generated<Timestamp>;
292
+ uploadedAt: Timestamp | null;
293
+ }
275
294
  export interface AccountingTransactionLine {
276
295
  accountAssignmentType: string | null;
277
296
  accountId: string | null;
297
+ appliedAmountTaxBehavior: string | null;
298
+ appliedAmountTaxRateId: string | null;
278
299
  centTotal: number;
279
300
  contactId: string | null;
280
301
  createdAt: Generated<Timestamp>;
@@ -284,7 +305,6 @@ export interface AccountingTransactionLine {
284
305
  markupCentTotal: number | null;
285
306
  markupTaxBehavior: string | null;
286
307
  markupTaxRateId: string | null;
287
- matchers: Generated<Json | null>;
288
308
  matchLineTypeClassification: string | null;
289
309
  matchReservationConfirmationCode: string | null;
290
310
  matchReservationStripeGuestRef: string | null;
@@ -1176,16 +1196,19 @@ export interface PublicReservation {
1176
1196
  createdAt: Generated<Timestamp | null>;
1177
1197
  currency: string | null;
1178
1198
  generalLedgerPostingAt: Timestamp | null;
1199
+ generalLedgerStatus: Generated<string>;
1179
1200
  guestName: string | null;
1180
1201
  guests: number | null;
1181
1202
  id: Generated<string>;
1182
1203
  lineMap: Json | null;
1183
1204
  listingConnectionId: string | null;
1184
1205
  listingId: string | null;
1206
+ managerCentTotal: Int8 | null;
1185
1207
  matchPaymentCustomerRef: string | null;
1186
1208
  metadata: Json | null;
1187
1209
  nights: number | null;
1188
1210
  otaReservationId: string | null;
1211
+ ownersCentTotal: Int8 | null;
1189
1212
  paidStatus: string | null;
1190
1213
  paymentMethod: string | null;
1191
1214
  pmsReferenceCode: string | null;
@@ -1195,6 +1218,7 @@ export interface PublicReservation {
1195
1218
  shortRef: string | null;
1196
1219
  sourceId: string | null;
1197
1220
  status: Generated<string | null>;
1221
+ taxCentTotal: Int8 | null;
1198
1222
  tenantId: string | null;
1199
1223
  uniqueRef: string | null;
1200
1224
  uniqueRef2: string | null;
@@ -1375,7 +1399,12 @@ export interface PublicTenant {
1375
1399
  logo: string | null;
1376
1400
  longTermStayNights: number | null;
1377
1401
  name: string;
1402
+ ownerPortalShowDraftStatements: boolean | null;
1378
1403
  partnerId: Generated<string | null>;
1404
+ /**
1405
+ * JSON column to hold team settings like "owner_portal_show_reservation_totals" or "owner_portal_show_draft_statements
1406
+ */
1407
+ settingsData: Json | null;
1379
1408
  setup: Json | null;
1380
1409
  setupCompleted: Generated<boolean | null>;
1381
1410
  statementAddressData: Json | null;
@@ -1644,6 +1673,7 @@ export interface DB {
1644
1673
  "accounting.rateType": AccountingRateType;
1645
1674
  "accounting.taxBehavior": AccountingTaxBehavior;
1646
1675
  "accounting.transaction": AccountingTransaction;
1676
+ "accounting.transactionAttachment": AccountingTransactionAttachment;
1647
1677
  "accounting.transactionLine": AccountingTransactionLine;
1648
1678
  "accounting.transactionType": AccountingTransactionType;
1649
1679
  "core.activeStatus": CoreActiveStatus;