@vrplatform/kysely 1.3.8 → 1.3.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "publishConfig": {
4
4
  "access": "public"
5
5
  },
6
- "version": "1.3.8",
6
+ "version": "1.3.10",
7
7
  "description": "",
8
8
  "main": "build/main/index.js",
9
9
  "module": "build/module/index.js",
@@ -48,13 +48,13 @@
48
48
  "pub": "bun run build && cp .data.tar build/ && pnpm publish --no-git-checks",
49
49
  "generate": "bun pgdump && bun run generate:v1 && bun run generate:v2 && bun run generate:v1:sed",
50
50
  "generate:v1": "kysely-codegen --env-file=../../.env --out-file=./src/v1.generated.ts --date-parser=string --default-schema=xxx --camel-case",
51
- "generate:v1:sed": "sleep 1 && sed -i '' 's/Timestamp = ColumnType<Date, Date | string, Date | string>/Timestamp = ColumnType<Date | string, Date | string, Date | string>/g' ./src/v1.generated.ts",
51
+ "generate:v1:sed": "sed -i '' 's/Timestamp = ColumnType<Date, Date | string, Date | string>/Timestamp = ColumnType<Date | string, Date | string, Date | string>/g' ./src/v1.generated.ts",
52
52
  "generate:v2": "rm -f .data.tar && bun setup.ts",
53
53
  "pgdump": "dotenvx run -f ../../.env -- bun pg-dump:run && bun pg-dump:rm && bun pg-dump:fix-uuid",
54
54
  "pg-dump:run": "pg_dump --clean --schema-only --if-exists --no-owner --no-acl $DATABASE_URL > initial/0000000000000-init.sql",
55
55
  "pg-dump:rm": "sed -i '' '/EXTENSION/d' initial/0000000000000-init.sql",
56
56
  "pg-dump:fix-uuid": "sed -i '' 's/public\\.gen_random_uuid()/gen_random_uuid()/g' initial/0000000000000-init.sql",
57
- "build": "bun run generate:v1 && bun build:main && bun build:module",
57
+ "build": "bun run generate && bun build:main && bun build:module",
58
58
  "build:main": "tsc -b tsconfig.main.json",
59
59
  "build:module": "tsc -b tsconfig.esm.json"
60
60
  },
package/src/isomorphic.ts CHANGED
@@ -8,6 +8,7 @@ export type {
8
8
  Generated,
9
9
  Insertable,
10
10
  JSONColumnType,
11
+ Nullable,
11
12
  OperandExpression,
12
13
  Selectable,
13
14
  SelectQueryBuilder,
@@ -29,7 +29,7 @@ export type PublicFlowType = "pull" | "push";
29
29
 
30
30
  export type StoreEffectStatus = "claimed" | "completed" | "dead_letter" | "failed" | "pending" | "running";
31
31
 
32
- export type Timestamp = ColumnType<Date, Date | string, Date | string>;
32
+ export type Timestamp = ColumnType<Date | string, Date | string, Date | string>;
33
33
 
34
34
  export interface AccountingAccount {
35
35
  bankingCategory: string | null;
@@ -290,6 +290,7 @@ export interface AccountingTransaction {
290
290
  description: string;
291
291
  dueAt: Timestamp | null;
292
292
  id: Generated<string>;
293
+ matchBankAccountLast4: string | null;
293
294
  matchers: Json | null;
294
295
  matchStatus: Generated<string | null>;
295
296
  paidAt: Timestamp | null;
@@ -832,7 +833,7 @@ export interface PublicFileStorage {
832
833
  connectionId: string | null;
833
834
  contactId: string | null;
834
835
  createdAt: Generated<Timestamp>;
835
- endDate: string | null;
836
+ endDate: Timestamp | null;
836
837
  extension: string | null;
837
838
  filename: string;
838
839
  fileUri: string | null;
@@ -842,7 +843,7 @@ export interface PublicFileStorage {
842
843
  ownerUserId: string | null;
843
844
  reservationId: string | null;
844
845
  rowDateField: string | null;
845
- startDate: string | null;
846
+ startDate: Timestamp | null;
846
847
  status: string | null;
847
848
  tenantId: string;
848
849
  type: string;
@@ -1164,6 +1165,7 @@ export interface PublicPaymentLine {
1164
1165
  connectionId: string | null;
1165
1166
  createdAt: Generated<Timestamp>;
1166
1167
  description: string | null;
1168
+ generalLedgerPostingAt: Timestamp | null;
1167
1169
  id: Generated<string>;
1168
1170
  lineId: string | null;
1169
1171
  listingId: string | null;
@@ -1204,70 +1206,6 @@ export interface PublicPaymentType {
1204
1206
  name: string;
1205
1207
  }
1206
1208
 
1207
- export interface PublicPgpodmanStatus {
1208
- containerId: string;
1209
- runCmd: string | null;
1210
- started: Timestamp | null;
1211
- status: string | null;
1212
- }
1213
-
1214
- export interface PublicPgStatStatements {
1215
- calls: Int8 | null;
1216
- dbid: number | null;
1217
- jitDeformCount: Int8 | null;
1218
- jitDeformTime: number | null;
1219
- jitEmissionCount: Int8 | null;
1220
- jitEmissionTime: number | null;
1221
- jitFunctions: Int8 | null;
1222
- jitGenerationTime: number | null;
1223
- jitInliningCount: Int8 | null;
1224
- jitInliningTime: number | null;
1225
- jitOptimizationCount: Int8 | null;
1226
- jitOptimizationTime: number | null;
1227
- localBlkReadTime: number | null;
1228
- localBlksDirtied: Int8 | null;
1229
- localBlksHit: Int8 | null;
1230
- localBlksRead: Int8 | null;
1231
- localBlksWritten: Int8 | null;
1232
- localBlkWriteTime: number | null;
1233
- maxExecTime: number | null;
1234
- maxPlanTime: number | null;
1235
- meanExecTime: number | null;
1236
- meanPlanTime: number | null;
1237
- minExecTime: number | null;
1238
- minmaxStatsSince: Timestamp | null;
1239
- minPlanTime: number | null;
1240
- plans: Int8 | null;
1241
- query: string | null;
1242
- queryid: Int8 | null;
1243
- rows: Int8 | null;
1244
- sharedBlkReadTime: number | null;
1245
- sharedBlksDirtied: Int8 | null;
1246
- sharedBlksHit: Int8 | null;
1247
- sharedBlksRead: Int8 | null;
1248
- sharedBlksWritten: Int8 | null;
1249
- sharedBlkWriteTime: number | null;
1250
- statsSince: Timestamp | null;
1251
- stddevExecTime: number | null;
1252
- stddevPlanTime: number | null;
1253
- tempBlkReadTime: number | null;
1254
- tempBlksRead: Int8 | null;
1255
- tempBlksWritten: Int8 | null;
1256
- tempBlkWriteTime: number | null;
1257
- toplevel: boolean | null;
1258
- totalExecTime: number | null;
1259
- totalPlanTime: number | null;
1260
- userid: number | null;
1261
- walBytes: Numeric | null;
1262
- walFpi: Int8 | null;
1263
- walRecords: Int8 | null;
1264
- }
1265
-
1266
- export interface PublicPgStatStatementsInfo {
1267
- dealloc: Int8 | null;
1268
- statsReset: Timestamp | null;
1269
- }
1270
-
1271
1209
  export interface PublicRecurringFee {
1272
1210
  bookingChannelsFilter: string[] | null;
1273
1211
  createdAt: Generated<Timestamp>;
@@ -1457,6 +1395,7 @@ export interface PublicSource {
1457
1395
  indexedJson: Json | null;
1458
1396
  isArchived: Generated<boolean | null>;
1459
1397
  json: Json | null;
1398
+ lastWebhookAt: Timestamp | null;
1460
1399
  /**
1461
1400
  * deprecated
1462
1401
  */
@@ -1519,14 +1458,14 @@ export interface PublicTenant {
1519
1458
  billingPaymentMethodType: string | null;
1520
1459
  billingPlan: string | null;
1521
1460
  billingSubscriptionStatus: string | null;
1522
- booksClosedAt: string | null;
1461
+ booksClosedAt: Timestamp | null;
1523
1462
  calculatedBillingPartnerId: Generated<string | null>;
1524
1463
  calculatedIsBillable: Generated<boolean | null>;
1525
1464
  calculatedStatus: Generated<string | null>;
1526
1465
  /**
1527
1466
  * Billing subscription is getting cancelled at date
1528
1467
  */
1529
- cancelledAt: string | null;
1468
+ cancelledAt: Timestamp | null;
1530
1469
  chartOfAccountTenantId: string | null;
1531
1470
  clerkId: string | null;
1532
1471
  colorPrimary: string | null;
@@ -1559,7 +1498,7 @@ export interface PublicTenant {
1559
1498
  supportEmail: string | null;
1560
1499
  supportPhone: string | null;
1561
1500
  svixEndpoints: boolean | null;
1562
- trialUntil: string | null;
1501
+ trialUntil: Timestamp | null;
1563
1502
  type: Generated<string | null>;
1564
1503
  updatedAt: Generated<Timestamp | null>;
1565
1504
  website: string | null;
@@ -1782,6 +1721,17 @@ export interface TrackingIntercomReportConversation {
1782
1721
  reportId: string;
1783
1722
  }
1784
1723
 
1724
+ export interface TrackingMetricCache {
1725
+ connectionId: Generated<string>;
1726
+ date: Timestamp;
1727
+ name: Generated<string>;
1728
+ refreshedAt: Generated<Timestamp>;
1729
+ status: Generated<string>;
1730
+ tenantId: string;
1731
+ total: Numeric;
1732
+ type: string;
1733
+ }
1734
+
1785
1735
  export interface TrackingMonitorConnection {
1786
1736
  appId: string;
1787
1737
  connectionId: string;
@@ -1906,9 +1856,6 @@ export interface DB {
1906
1856
  "public.paymentLineClassification": PublicPaymentLineClassification;
1907
1857
  "public.paymentStatus": PublicPaymentStatus;
1908
1858
  "public.paymentType": PublicPaymentType;
1909
- "public.pgpodmanStatus": PublicPgpodmanStatus;
1910
- "public.pgStatStatements": PublicPgStatStatements;
1911
- "public.pgStatStatementsInfo": PublicPgStatStatementsInfo;
1912
1859
  "public.recurringFee": PublicRecurringFee;
1913
1860
  "public.recurringFeeAccount": PublicRecurringFeeAccount;
1914
1861
  "public.recurringFeeListingSubscription": PublicRecurringFeeListingSubscription;
@@ -1942,6 +1889,7 @@ export interface DB {
1942
1889
  "tracking.intercomConversationUser": TrackingIntercomConversationUser;
1943
1890
  "tracking.intercomReport": TrackingIntercomReport;
1944
1891
  "tracking.intercomReportConversation": TrackingIntercomReportConversation;
1892
+ "tracking.metricCache": TrackingMetricCache;
1945
1893
  "tracking.monitorConnection": TrackingMonitorConnection;
1946
1894
  "tracking.monitorConnectionState": TrackingMonitorConnectionState;
1947
1895
  }
@@ -1,17 +0,0 @@
1
- import { type LogConfig } from 'kysely';
2
- import type { Kysely } from '../isomorphic';
3
- export * from '../isomorphic';
4
- export type UseBrowserKyselyOptions = {
5
- repositoryName?: string;
6
- log?: true | LogConfig;
7
- adapter?: 'memory' | 'idb';
8
- };
9
- /**
10
- * Initialize Kysely with PGlite for browser environments.
11
- *
12
- * @param dumpData - The database dump data as a Blob, ArrayBuffer, or Uint8Array.
13
- * This should be the .data.tar file loaded as a blob.
14
- * @param options - Configuration options
15
- * @returns A Kysely instance connected to the in-memory PGlite database
16
- */
17
- export declare function useBrowserKysely(options?: UseBrowserKyselyOptions): Promise<Kysely>;
@@ -1,65 +0,0 @@
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 __exportStar = (this && this.__exportStar) || function(m, exports) {
14
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
- };
16
- Object.defineProperty(exports, "__esModule", { value: true });
17
- exports.useBrowserKysely = useBrowserKysely;
18
- // import { live } from '@electric-sql/pglite/live';
19
- const worker_1 = require("@electric-sql/pglite/worker");
20
- const kysely_1 = require("kysely");
21
- const kysely_pglite_dialect_1 = require("kysely-pglite-dialect");
22
- __exportStar(require("../isomorphic"), exports);
23
- // Create worker with Vite-compatible URL
24
- const worker = new Worker(new URL('./worker.ts', import.meta.url), {
25
- type: 'module',
26
- });
27
- /**
28
- * Initialize Kysely with PGlite for browser environments.
29
- *
30
- * @param dumpData - The database dump data as a Blob, ArrayBuffer, or Uint8Array.
31
- * This should be the .data.tar file loaded as a blob.
32
- * @param options - Configuration options
33
- * @returns A Kysely instance connected to the in-memory PGlite database
34
- */
35
- async function useBrowserKysely(options = {}) {
36
- let isDestroyed = false;
37
- //const now = performance.now();
38
- const pglite = new worker_1.PGliteWorker(worker, {
39
- dataDir: options.adapter === 'idb' ? 'idb://pglite' : 'memory://',
40
- extensions: {
41
- //live,
42
- },
43
- });
44
- const dialect = new kysely_pglite_dialect_1.PGliteDialect(pglite);
45
- const kysely = new kysely_1.Kysely({
46
- dialect,
47
- log: options.log === true ? ['query', 'error'] : options.log,
48
- plugins: [new kysely_1.CamelCasePlugin()],
49
- });
50
- const originalDestroy = kysely.destroy.bind(kysely);
51
- kysely.destroy = async () => {
52
- if (isDestroyed)
53
- return;
54
- isDestroyed = true;
55
- //const destroyTime = performance.now();
56
- await originalDestroy().catch(() => undefined);
57
- await pglite.close().catch(() => undefined);
58
- //console.log(
59
- // `Database destroyed: ${Math.round(performance.now() - destroyTime)}ms`
60
- //);
61
- };
62
- //console.log(`Database initialized: ${Math.round(performance.now() - now)}ms`);
63
- return kysely;
64
- }
65
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"src/","sources":["browser/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AA2BA,4CAmCC;AA9DD,oDAAoD;AACpD,wDAA2D;AAC3D,mCAAsE;AACtE,iEAAsD;AAGtD,gDAA8B;AAQ9B,yCAAyC;AACzC,MAAM,MAAM,GAAG,IAAI,MAAM,CAAC,IAAI,GAAG,CAAC,aAAa,EAAE,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE;IACjE,IAAI,EAAE,QAAQ;CACf,CAAC,CAAC;AAEH;;;;;;;GAOG;AACI,KAAK,UAAU,gBAAgB,CACpC,UAAmC,EAAE;IAErC,IAAI,WAAW,GAAG,KAAK,CAAC;IACxB,gCAAgC;IAEhC,MAAM,MAAM,GAAG,IAAI,qBAAY,CAAC,MAAM,EAAE;QACtC,OAAO,EAAE,OAAO,CAAC,OAAO,KAAK,KAAK,CAAC,CAAC,CAAC,cAAc,CAAC,CAAC,CAAC,WAAW;QACjE,UAAU,EAAE;QACV,OAAO;SACR;KACF,CAAC,CAAC;IAEH,MAAM,OAAO,GAAG,IAAI,qCAAa,CAAC,MAAM,CAAC,CAAC;IAC1C,MAAM,MAAM,GAAG,IAAI,eAAC,CAAK;QACvB,OAAO;QACP,GAAG,EAAE,OAAO,CAAC,GAAG,KAAK,IAAI,CAAC,CAAC,CAAC,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,GAAG;QAC5D,OAAO,EAAE,CAAC,IAAI,wBAAe,EAAE,CAAC;KACjC,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,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,gFAAgF;IAEhF,OAAO,MAAM,CAAC;AAChB,CAAC","sourcesContent":["// import { live } from '@electric-sql/pglite/live';\nimport { PGliteWorker } from '@electric-sql/pglite/worker';\nimport { CamelCasePlugin, Kysely as K, type LogConfig } from 'kysely';\nimport { PGliteDialect } from 'kysely-pglite-dialect';\nimport type { DB, Kysely } from '../isomorphic';\n\nexport * from '../isomorphic';\n\nexport type UseBrowserKyselyOptions = {\n repositoryName?: string;\n log?: true | LogConfig;\n adapter?: 'memory' | 'idb';\n};\n\n// Create worker with Vite-compatible URL\nconst worker = new Worker(new URL('./worker.ts', import.meta.url), {\n type: 'module',\n});\n\n/**\n * Initialize Kysely with PGlite for browser environments.\n *\n * @param dumpData - The database dump data as a Blob, ArrayBuffer, or Uint8Array.\n * This should be the .data.tar file loaded as a blob.\n * @param options - Configuration options\n * @returns A Kysely instance connected to the in-memory PGlite database\n */\nexport async function useBrowserKysely(\n options: UseBrowserKyselyOptions = {}\n): Promise<Kysely> {\n let isDestroyed = false;\n //const now = performance.now();\n\n const pglite = new PGliteWorker(worker, {\n dataDir: options.adapter === 'idb' ? 'idb://pglite' : 'memory://',\n extensions: {\n //live,\n },\n });\n\n const dialect = new PGliteDialect(pglite);\n const kysely = new K<DB>({\n dialect,\n log: options.log === true ? ['query', 'error'] : options.log,\n plugins: [new CamelCasePlugin()],\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 +0,0 @@
1
- export {};
@@ -1,42 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const pglite_1 = require("@electric-sql/pglite");
4
- const worker_1 = require("@electric-sql/pglite/worker");
5
- (0, worker_1.worker)({
6
- async init({ dataDir }) {
7
- const databases = await self.indexedDB.databases();
8
- if (dataDir?.startsWith('idb://') && databases.length) {
9
- const pglite = new pglite_1.PGlite({
10
- dataDir,
11
- });
12
- // warm up
13
- await pglite.sql `SELECT 1`;
14
- return pglite;
15
- }
16
- console.log('Loading database dump...', dataDir);
17
- // Load the database dump file
18
- const dumpResponse = await fetch('/.data.tar').catch((error) => {
19
- console.error('Failed to load database dump:', error);
20
- throw new Error(`Failed to load database dump: ${error.message}`);
21
- });
22
- if (!dumpResponse.ok) {
23
- console.error('Failed to load database dump:', dumpResponse.statusText);
24
- throw new Error(`Failed to load database dump: ${dumpResponse.statusText}`);
25
- }
26
- console.log('Loaded database dump:', dumpResponse.status);
27
- const dumpBlob = await dumpResponse.blob();
28
- if (!dumpBlob.size) {
29
- console.error('Failed to load database dump:', dumpBlob.size);
30
- throw new Error(`Failed to load database dump: ${dumpBlob.size}`);
31
- }
32
- const pglite = new pglite_1.PGlite({
33
- dataDir,
34
- loadDataDir: dumpBlob,
35
- });
36
- // warm up
37
- await pglite.sql `SELECT 1`;
38
- return pglite;
39
- },
40
- });
41
- console.log('Worker process started');
42
- //# sourceMappingURL=worker.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"worker.js","sourceRoot":"src/","sources":["browser/worker.ts"],"names":[],"mappings":";;AAEA,iDAA8C;AAC9C,wDAAqD;AAErD,IAAA,eAAM,EAAC;IACL,KAAK,CAAC,IAAI,CAAC,EAAE,OAAO,EAAE;QACpB,MAAM,SAAS,GAAG,MAAM,IAAI,CAAC,SAAS,CAAC,SAAS,EAAE,CAAC;QACnD,IAAI,OAAO,EAAE,UAAU,CAAC,QAAQ,CAAC,IAAI,SAAS,CAAC,MAAM,EAAE,CAAC;YACtD,MAAM,MAAM,GAAG,IAAI,eAAM,CAAC;gBACxB,OAAO;aACR,CAAC,CAAC;YACH,UAAU;YACV,MAAM,MAAM,CAAC,GAAG,CAAA,UAAU,CAAC;YAC3B,OAAO,MAAM,CAAC;QAChB,CAAC;QAED,OAAO,CAAC,GAAG,CAAC,0BAA0B,EAAE,OAAO,CAAC,CAAC;QACjD,8BAA8B;QAC9B,MAAM,YAAY,GAAG,MAAM,KAAK,CAAC,YAAY,CAAC,CAAC,KAAK,CAAC,CAAC,KAAK,EAAE,EAAE;YAC7D,OAAO,CAAC,KAAK,CAAC,+BAA+B,EAAE,KAAK,CAAC,CAAC;YACtD,MAAM,IAAI,KAAK,CAAC,iCAAiC,KAAK,CAAC,OAAO,EAAE,CAAC,CAAC;QACpE,CAAC,CAAC,CAAC;QACH,IAAI,CAAC,YAAY,CAAC,EAAE,EAAE,CAAC;YACrB,OAAO,CAAC,KAAK,CAAC,+BAA+B,EAAE,YAAY,CAAC,UAAU,CAAC,CAAC;YACxE,MAAM,IAAI,KAAK,CACb,iCAAiC,YAAY,CAAC,UAAU,EAAE,CAC3D,CAAC;QACJ,CAAC;QAED,OAAO,CAAC,GAAG,CAAC,uBAAuB,EAAE,YAAY,CAAC,MAAM,CAAC,CAAC;QAC1D,MAAM,QAAQ,GAAG,MAAM,YAAY,CAAC,IAAI,EAAE,CAAC;QAC3C,IAAI,CAAC,QAAQ,CAAC,IAAI,EAAE,CAAC;YACnB,OAAO,CAAC,KAAK,CAAC,+BAA+B,EAAE,QAAQ,CAAC,IAAI,CAAC,CAAC;YAC9D,MAAM,IAAI,KAAK,CAAC,iCAAiC,QAAQ,CAAC,IAAI,EAAE,CAAC,CAAC;QACpE,CAAC;QAED,MAAM,MAAM,GAAG,IAAI,eAAM,CAAC;YACxB,OAAO;YACP,WAAW,EAAE,QAAQ;SACtB,CAAC,CAAC;QACH,UAAU;QACV,MAAM,MAAM,CAAC,GAAG,CAAA,UAAU,CAAC;QAE3B,OAAO,MAAM,CAAC;IAChB,CAAC;CACF,CAAC,CAAC;AAEH,OAAO,CAAC,GAAG,CAAC,wBAAwB,CAAC,CAAC","sourcesContent":["declare var self: Worker & { indexedDB: typeof window.indexedDB };\n\nimport { PGlite } from '@electric-sql/pglite';\nimport { worker } from '@electric-sql/pglite/worker';\n\nworker({\n async init({ dataDir }) {\n const databases = await self.indexedDB.databases();\n if (dataDir?.startsWith('idb://') && databases.length) {\n const pglite = new PGlite({\n dataDir,\n });\n // warm up\n await pglite.sql`SELECT 1`;\n return pglite;\n }\n\n console.log('Loading database dump...', dataDir);\n // Load the database dump file\n const dumpResponse = await fetch('/.data.tar').catch((error) => {\n console.error('Failed to load database dump:', error);\n throw new Error(`Failed to load database dump: ${error.message}`);\n });\n if (!dumpResponse.ok) {\n console.error('Failed to load database dump:', dumpResponse.statusText);\n throw new Error(\n `Failed to load database dump: ${dumpResponse.statusText}`\n );\n }\n\n console.log('Loaded database dump:', dumpResponse.status);\n const dumpBlob = await dumpResponse.blob();\n if (!dumpBlob.size) {\n console.error('Failed to load database dump:', dumpBlob.size);\n throw new Error(`Failed to load database dump: ${dumpBlob.size}`);\n }\n\n const pglite = new PGlite({\n dataDir,\n loadDataDir: dumpBlob,\n });\n // warm up\n await pglite.sql`SELECT 1`;\n\n return pglite;\n },\n});\n\nconsole.log('Worker process started');\n"]}