@vrplatform/kysely 1.3.12 → 1.3.17

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 (63) hide show
  1. package/build/.data.tar +0 -0
  2. package/build/main/camel-case/index.d.ts +8 -0
  3. package/build/main/camel-case/index.js +61 -0
  4. package/build/main/camel-case/index.js.map +1 -0
  5. package/build/main/error.d.ts +3 -0
  6. package/build/main/error.js +11 -0
  7. package/build/main/error.js.map +1 -0
  8. package/build/main/index.d.ts +3 -1
  9. package/build/main/index.js +7 -14
  10. package/build/main/index.js.map +1 -1
  11. package/build/main/local/digest.d.ts +1 -0
  12. package/build/main/local/digest.js +27 -0
  13. package/build/main/local/digest.js.map +1 -1
  14. package/build/main/local/generate.d.ts +1 -1
  15. package/build/main/local/generate.js +7 -6
  16. package/build/main/local/generate.js.map +1 -1
  17. package/build/main/local/index.d.ts +2 -3
  18. package/build/main/local/index.js +8 -12
  19. package/build/main/local/index.js.map +1 -1
  20. package/build/main/plugins.d.ts +6 -0
  21. package/build/main/plugins.js +21 -0
  22. package/build/main/plugins.js.map +1 -0
  23. package/build/main/test/index.js +2 -1
  24. package/build/main/test/index.js.map +1 -1
  25. package/build/main/tsconfig.main.tsbuildinfo +1 -1
  26. package/build/main/v1.generated.d.ts +17 -0
  27. package/build/main/v1.generated.js.map +1 -1
  28. package/build/module/camel-case/index.d.ts +8 -0
  29. package/build/module/camel-case/index.js +57 -0
  30. package/build/module/camel-case/index.js.map +1 -0
  31. package/build/module/error.d.ts +3 -0
  32. package/build/module/error.js +7 -0
  33. package/build/module/error.js.map +1 -0
  34. package/build/module/index.d.ts +3 -1
  35. package/build/module/index.js +7 -14
  36. package/build/module/index.js.map +1 -1
  37. package/build/module/local/digest.d.ts +1 -0
  38. package/build/module/local/digest.js +26 -0
  39. package/build/module/local/digest.js.map +1 -1
  40. package/build/module/local/generate.d.ts +1 -1
  41. package/build/module/local/generate.js +8 -7
  42. package/build/module/local/generate.js.map +1 -1
  43. package/build/module/local/index.d.ts +2 -3
  44. package/build/module/local/index.js +9 -13
  45. package/build/module/local/index.js.map +1 -1
  46. package/build/module/plugins.d.ts +6 -0
  47. package/build/module/plugins.js +18 -0
  48. package/build/module/plugins.js.map +1 -0
  49. package/build/module/test/index.js +2 -1
  50. package/build/module/test/index.js.map +1 -1
  51. package/build/module/tsconfig.esm.tsbuildinfo +1 -1
  52. package/build/module/v1.generated.d.ts +17 -0
  53. package/build/module/v1.generated.js.map +1 -1
  54. package/package.json +2 -2
  55. package/src/camel-case/index.ts +68 -0
  56. package/src/error.ts +6 -0
  57. package/src/index.ts +11 -21
  58. package/src/local/digest.ts +26 -0
  59. package/src/local/generate.ts +9 -13
  60. package/src/local/index.ts +10 -14
  61. package/src/plugins.ts +30 -0
  62. package/src/test/index.ts +2 -1
  63. package/src/v1.generated.ts +17 -0
@@ -3,14 +3,10 @@ import { exists } from 'node:fs/promises';
3
3
  import * as path from 'node:path';
4
4
  import { join } from 'node:path';
5
5
  import { PGlite } from '@electric-sql/pglite';
6
- import {
7
- CamelCasePlugin,
8
- FileMigrationProvider,
9
- Kysely,
10
- Migrator,
11
- } from 'kysely';
6
+ import { FileMigrationProvider, type Kysely, Migrator } from 'kysely';
12
7
  import codegen from 'kysely-codegen';
13
8
  import { KyselyPGlite } from 'kysely-pglite';
9
+ import { getKysely } from '../plugins';
14
10
  import type { DB } from '../v1.generated';
15
11
 
16
12
  async function migrate(root: string, client: PGlite) {
@@ -25,7 +21,7 @@ async function migrate(root: string, client: PGlite) {
25
21
  }
26
22
  }
27
23
 
28
- async function migrateKysely(root: string, kysely: Kysely<any>) {
24
+ async function migrateKysely(root: string, kysely: Kysely<DB>) {
29
25
  console.log('init migrating kysely ....');
30
26
  const migrator = new Migrator({
31
27
  db: kysely,
@@ -75,9 +71,9 @@ async function generateDump(root: string, dumpPath: string) {
75
71
  process.exit(1);
76
72
  });
77
73
  const { dialect } = new KyselyPGlite(main);
78
- const kysely = new Kysely<DB>({
79
- dialect,
80
- plugins: [new CamelCasePlugin()],
74
+ const kysely = getKysely(dialect, {
75
+ repositoryName: 'localTesting',
76
+ log: undefined,
81
77
  });
82
78
  await migrateKysely(root, kysely).catch(() => {
83
79
  console.error('failed to migrate kysely');
@@ -118,9 +114,9 @@ export async function createLocalKysely(root: string, dumpPath: string) {
118
114
  // warm up
119
115
  await pglite.sql`SELECT 1`;
120
116
  const { dialect } = new KyselyPGlite(pglite);
121
- const kysely = new Kysely<DB>({
122
- dialect,
123
- plugins: [new CamelCasePlugin()],
117
+ const kysely = getKysely(dialect, {
118
+ repositoryName: 'localTesting',
119
+ log: undefined,
124
120
  });
125
121
 
126
122
  const originalDestroy = kysely.destroy.bind(kysely);
@@ -1,10 +1,9 @@
1
1
  import { join } from 'node:path';
2
2
  import { PGlite } from '@electric-sql/pglite';
3
- import { CamelCasePlugin, Kysely, type LogConfig } from 'kysely';
3
+ import type { LogConfig } from 'kysely';
4
4
  import { PGliteDialect } from 'kysely-pglite-dialect';
5
- import { KyselyPganalyzeCommentPlugin } from '../pganalyze-comment-plugin';
6
- import type { DB } from '../v1.generated';
7
- import { ensureDigestFunction } from './digest';
5
+ import { getKysely } from '../plugins';
6
+ import { ensureDigestFunction, ensureGenRandomBytesFunction } from './digest';
8
7
 
9
8
  export const root = join(__dirname, '../..');
10
9
  export const dumpPath = join(root, '.data.tar');
@@ -19,20 +18,17 @@ export async function useLocalKysely(args: UseLocalKyselyOptions = {}) {
19
18
 
20
19
  const dump = Bun.file(dumpPath);
21
20
 
22
- const pglite = new PGlite({ loadDataDir: dump });
21
+ const pglite = new PGlite({
22
+ loadDataDir: dump,
23
+ });
23
24
  // warm up
24
25
  const dialect = new PGliteDialect(pglite);
25
- const kysely = new Kysely<DB>({
26
- dialect,
27
- log: args.log === true ? ['query', 'error'] : args.log,
28
- plugins: [
29
- new CamelCasePlugin(),
30
- new KyselyPganalyzeCommentPlugin({
31
- repository: args.repositoryName ?? 'localTesting',
32
- }),
33
- ],
26
+ const kysely = getKysely(dialect, {
27
+ repositoryName: args?.repositoryName ?? 'localTesting',
28
+ log: args?.log,
34
29
  });
35
30
  await ensureDigestFunction(kysely);
31
+ await ensureGenRandomBytesFunction(kysely);
36
32
 
37
33
  const originalDestroy = kysely.destroy.bind(kysely);
38
34
  kysely.destroy = async () => {
package/src/plugins.ts ADDED
@@ -0,0 +1,30 @@
1
+ import {
2
+ type Dialect,
3
+ Kysely as K,
4
+ type KyselyPlugin,
5
+ type LogConfig,
6
+ } from 'kysely';
7
+ import { CustomCasePlugin } from './camel-case';
8
+ import { KyselyPganalyzeCommentPlugin } from './pganalyze-comment-plugin';
9
+ import type { DB } from './v1.generated';
10
+
11
+ export function getKysely(
12
+ dialect: Dialect,
13
+ options: { repositoryName?: string; log?: true | LogConfig }
14
+ ) {
15
+ const plugins: KyselyPlugin[] = [new CustomCasePlugin()];
16
+
17
+ if (options?.repositoryName) {
18
+ plugins.push(
19
+ new KyselyPganalyzeCommentPlugin({
20
+ repository: options.repositoryName,
21
+ })
22
+ );
23
+ }
24
+ const kysely = new K<DB>({
25
+ dialect,
26
+ plugins,
27
+ log: options?.log === true ? ['query', 'error'] : options?.log,
28
+ });
29
+ return kysely;
30
+ }
package/src/test/index.ts CHANGED
@@ -45,7 +45,8 @@ export async function useLocalKyselyResource(
45
45
  {},
46
46
  {
47
47
  get(_target, prop) {
48
- if (prop === Symbol.dispose) {
48
+ // somehow not working if using Symbol.dispose
49
+ if (prop === Symbol.asyncDispose) {
49
50
  return async () => {
50
51
  await kysely.destroy();
51
52
  };
@@ -180,6 +180,10 @@ export interface AccountingContact {
180
180
  name: string;
181
181
  phone: string | null;
182
182
  pmsStatus: string | null;
183
+ /**
184
+ * Human-readable system ID (CNT-XXX-XXXX-XXX).
185
+ */
186
+ shortRef: string | null;
183
187
  sourceId: string | null;
184
188
  status: Generated<string | null>;
185
189
  taxId: string | null;
@@ -298,6 +302,10 @@ export interface AccountingTransaction {
298
302
  recurringFeeId: string | null;
299
303
  recurringPattern: Json | null;
300
304
  recurringTemplateId: string | null;
305
+ /**
306
+ * Human-readable system ID (EXP/DEP/TRF-XXX-XXXX-XXX depending on transaction.type).
307
+ */
308
+ shortRef: string | null;
301
309
  sourceId: string | null;
302
310
  status: Generated<string>;
303
311
  tenantId: string;
@@ -406,6 +414,7 @@ export interface CoreFlow {
406
414
  leftType: string | null;
407
415
  mappingSchema: Json;
408
416
  rightType: string | null;
417
+ runSchema: Generated<Json>;
409
418
  settingSchema: Json;
410
419
  title: string;
411
420
  type: Generated<PublicFlowType | null>;
@@ -910,6 +919,10 @@ export interface PublicListing {
910
919
  ownerContactId: string | null;
911
920
  pmsAddressData: Json | null;
912
921
  pmsStatus: string | null;
922
+ /**
923
+ * Human-readable system ID (LST-XXX-XXXX-XXX).
924
+ */
925
+ shortRef: string | null;
913
926
  sourceId: string | null;
914
927
  status: string | null;
915
928
  tenantId: string;
@@ -1301,6 +1314,10 @@ export interface PublicReservation {
1301
1314
  paidStatus: string | null;
1302
1315
  paymentMethod: string | null;
1303
1316
  pmsReferenceCode: string | null;
1317
+ /**
1318
+ * Human-readable system ID (RES-XXX-XXXX-XXX).
1319
+ */
1320
+ shortRef: string | null;
1304
1321
  sourceId: string | null;
1305
1322
  status: Generated<string | null>;
1306
1323
  tenantId: string | null;