@vrplatform/kysely 1.3.30 → 1.3.31

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.
@@ -1,9 +1,8 @@
1
1
  import type { LogConfig } from 'kysely';
2
- import { type Kysely } from 'kysely';
3
2
  export declare const root: string;
4
3
  export declare const dumpPath: string;
5
4
  export type UseLocalKyselyOptions = {
6
5
  repositoryName?: string;
7
6
  log?: true | LogConfig;
8
7
  };
9
- export declare function useLocalKysely(args?: UseLocalKyselyOptions): Promise<Kysely<import("..").DB>>;
8
+ export declare function useLocalKysely(args?: UseLocalKyselyOptions): Promise<import("kysely").Kysely<import("..").DB>>;
@@ -1,66 +1,14 @@
1
1
  "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || (function () {
19
- var ownKeys = function(o) {
20
- ownKeys = Object.getOwnPropertyNames || function (o) {
21
- var ar = [];
22
- for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
- return ar;
24
- };
25
- return ownKeys(o);
26
- };
27
- return function (mod) {
28
- if (mod && mod.__esModule) return mod;
29
- var result = {};
30
- if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
- __setModuleDefault(result, mod);
32
- return result;
33
- };
34
- })();
35
2
  Object.defineProperty(exports, "__esModule", { value: true });
36
3
  exports.dumpPath = exports.root = void 0;
37
4
  exports.useLocalKysely = useLocalKysely;
38
- const node_fs_1 = require("node:fs");
39
- const path = __importStar(require("node:path"));
40
5
  const node_path_1 = require("node:path");
41
6
  const pglite_1 = require("@electric-sql/pglite");
42
- const kysely_1 = require("kysely");
43
7
  const kysely_pglite_dialect_1 = require("kysely-pglite-dialect");
44
8
  const plugins_1 = require("../plugins");
45
9
  const digest_1 = require("./digest");
46
10
  exports.root = (0, node_path_1.join)(__dirname, '../..');
47
11
  exports.dumpPath = (0, node_path_1.join)(exports.root, '.data.tar');
48
- async function migrateKysely(kysely) {
49
- const migrator = new kysely_1.Migrator({
50
- db: kysely,
51
- migrationTableSchema: 'core',
52
- migrationTableName: 'kysely_migration',
53
- migrationLockTableName: 'kysely_migration_lock',
54
- provider: new kysely_1.FileMigrationProvider({
55
- fs: node_fs_1.promises,
56
- path,
57
- migrationFolder: path.join(exports.root, 'migrations'),
58
- }),
59
- });
60
- const { error } = await migrator.migrateToLatest();
61
- if (error)
62
- throw error;
63
- }
64
12
  async function useLocalKysely(args = {}) {
65
13
  let isDestroyed = false;
66
14
  // const now = performance.now();
@@ -75,7 +23,6 @@ async function useLocalKysely(args = {}) {
75
23
  });
76
24
  await (0, digest_1.ensureDigestFunction)(kysely);
77
25
  await (0, digest_1.ensureGenRandomBytesFunction)(kysely);
78
- await migrateKysely(kysely);
79
26
  const originalDestroy = kysely.destroy.bind(kysely);
80
27
  kysely.destroy = async () => {
81
28
  if (isDestroyed)
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"src/","sources":["local/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,qCAAyC;AACzC,MAAY,IAAI,sCAAkB;AAClC,yCAAiC;AACjC,iDAA8C;AAE9C,mCAAsE;AACtE,iEAAsD;AACtD,wCAAuC;AACvC,qCAA8E;AAEjE,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3C,MAAM,aAAa,CAAC,MAAM,CAAC,CAAC;IAE5B,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,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;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
+ {"version":3,"file":"index.js","sourceRoot":"src/","sources":["local/index.ts"],"names":[],"mappings":";;;;AAAA,yCAAiC;AACjC,iDAA8C;AAE9C,iEAAsD;AACtD,wCAAuC;AACvC,qCAA8E;AAEjE,QAAA,IAAI,GAAG,IAAA,gBAAI,EAAC,SAAS,EAAE,OAAO,CAAC,CAAC;AAChC,QAAA,QAAQ,GAAG,IAAA,gBAAI,EAAC,QAAA,IAAI,EAAE,WAAW,CAAC,CAAC;AAMzC,KAAK,yBAAyB,IAAI,GAA0B,EAAE,EAAE;IACrE,IAAI,WAAW,GAAG,KAAK,CAAC;IACxB,iCAAiC;IAEjC,MAAM,IAAI,GAAG,GAAG,CAAC,IAAI,CAAC,QAAA,QAAQ,CAAC,CAAC;IAEhC,MAAM,MAAM,GAAG,IAAI,eAAM,CAAC;QACxB,WAAW,EAAE,IAAI;KAClB,CAAC,CAAC;IACH,MAAM,OAAO,GAAG,IAAI,qCAAa,CAAC,MAAM,CAAC,CAAC;IAC1C,MAAM,MAAM,GAAG,IAAA,mBAAS,EAAC,OAAO,EAAE;QAChC,cAAc,EAAE,IAAI,EAAE,cAAc,IAAI,cAAc;QACtD,GAAG,EAAE,IAAI,EAAE,GAAG;KACf,CAAC,CAAC;IACH,MAAM,IAAA,6BAAoB,EAAC,MAAM,CAAC,CAAC;IACnC,MAAM,IAAA,qCAA4B,EAAC,MAAM,CAAC,CAAC;IAE3C,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,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;IAHwC,CAI7C,CAAC;IAEF,iFAAiF;IAEjF,OAAO,MAAM,CAAC;AAAA,CACf","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 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,9 +1,8 @@
1
1
  import type { LogConfig } from 'kysely';
2
- import { type Kysely } from 'kysely';
3
2
  export declare const root: string;
4
3
  export declare const dumpPath: string;
5
4
  export type UseLocalKyselyOptions = {
6
5
  repositoryName?: string;
7
6
  log?: true | LogConfig;
8
7
  };
9
- export declare function useLocalKysely(args?: UseLocalKyselyOptions): Promise<Kysely<import("..").DB>>;
8
+ export declare function useLocalKysely(args?: UseLocalKyselyOptions): Promise<import("kysely").Kysely<import("..").DB>>;
@@ -1,29 +1,10 @@
1
- import { promises as fs } from 'node:fs';
2
- import * as path from 'node:path';
3
1
  import { join } from 'node:path';
4
2
  import { PGlite } from '@electric-sql/pglite';
5
- import { FileMigrationProvider, Migrator } from 'kysely';
6
3
  import { PGliteDialect } from 'kysely-pglite-dialect';
7
4
  import { getKysely } from '../plugins';
8
5
  import { ensureDigestFunction, ensureGenRandomBytesFunction } from './digest';
9
6
  export const root = join(__dirname, '../..');
10
7
  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
- }
27
8
  export async function useLocalKysely(args = {}) {
28
9
  let isDestroyed = false;
29
10
  // const now = performance.now();
@@ -38,7 +19,6 @@ export async function useLocalKysely(args = {}) {
38
19
  });
39
20
  await ensureDigestFunction(kysely);
40
21
  await ensureGenRandomBytesFunction(kysely);
41
- await migrateKysely(kysely);
42
22
  const originalDestroy = kysely.destroy.bind(kysely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CAAC,IAAI,GAA0B,EAAE,EAAE;IACrE,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,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;IAC3C,MAAM,aAAa,CAAC,MAAM,CAAC,CAAC;IAE5B,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,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;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
+ {"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;AAC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IAEF,iFAAiF;IAEjF,OAAO,MAAM,CAAC;AAAA,CACf","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 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"]}
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "publishConfig": {
4
4
  "access": "public"
5
5
  },
6
- "version": "1.3.30",
6
+ "version": "1.3.31",
7
7
  "description": "",
8
8
  "main": "build/main/index.js",
9
9
  "module": "build/module/index.js",