ponder 0.9.1 → 0.9.2
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/dist/bin/ponder.js +66 -8
- package/dist/bin/ponder.js.map +1 -1
- package/package.json +1 -3
- package/src/build/index.ts +5 -10
- package/src/database/index.ts +4 -4
- package/src/utils/pg.ts +6 -0
- package/src/utils/pglite.ts +79 -0
package/dist/bin/ponder.js
CHANGED
|
@@ -1078,7 +1078,7 @@ import fs2 from "node:fs";
|
|
|
1078
1078
|
import path6 from "node:path";
|
|
1079
1079
|
|
|
1080
1080
|
// src/build/index.ts
|
|
1081
|
-
import
|
|
1081
|
+
import { createHash as createHash2 } from "node:crypto";
|
|
1082
1082
|
import fs from "node:fs";
|
|
1083
1083
|
import path5 from "node:path";
|
|
1084
1084
|
|
|
@@ -3423,7 +3423,7 @@ var createBuild = async ({
|
|
|
3423
3423
|
return executeResult;
|
|
3424
3424
|
}
|
|
3425
3425
|
const config = executeResult.exports.default;
|
|
3426
|
-
const contentHash =
|
|
3426
|
+
const contentHash = createHash2("sha256").update(serialize(config)).digest("hex");
|
|
3427
3427
|
return {
|
|
3428
3428
|
status: "success",
|
|
3429
3429
|
result: { config, contentHash }
|
|
@@ -3448,7 +3448,7 @@ var createBuild = async ({
|
|
|
3448
3448
|
status: "success",
|
|
3449
3449
|
result: {
|
|
3450
3450
|
schema,
|
|
3451
|
-
contentHash:
|
|
3451
|
+
contentHash: createHash2("sha256").update(contents).digest("hex")
|
|
3452
3452
|
}
|
|
3453
3453
|
};
|
|
3454
3454
|
},
|
|
@@ -3475,7 +3475,7 @@ var createBuild = async ({
|
|
|
3475
3475
|
return executeResult;
|
|
3476
3476
|
}
|
|
3477
3477
|
}
|
|
3478
|
-
const hash =
|
|
3478
|
+
const hash = createHash2("sha256");
|
|
3479
3479
|
for (const file of files) {
|
|
3480
3480
|
try {
|
|
3481
3481
|
const contents = fs.readFileSync(file, "utf-8");
|
|
@@ -3624,7 +3624,7 @@ var createBuild = async ({
|
|
|
3624
3624
|
for (const log of buildConfigAndIndexingFunctionsResult.logs) {
|
|
3625
3625
|
common.logger[log.level]({ service: "build", msg: log.msg });
|
|
3626
3626
|
}
|
|
3627
|
-
const buildId =
|
|
3627
|
+
const buildId = createHash2("sha256").update(BUILD_ID_VERSION).update(configResult.contentHash).update(schemaResult.contentHash).update(indexingResult.contentHash).digest("hex").slice(0, 10);
|
|
3628
3628
|
return {
|
|
3629
3629
|
status: "success",
|
|
3630
3630
|
result: {
|
|
@@ -3746,6 +3746,9 @@ var createBuild = async ({
|
|
|
3746
3746
|
return build;
|
|
3747
3747
|
};
|
|
3748
3748
|
|
|
3749
|
+
// src/database/index.ts
|
|
3750
|
+
import { randomUUID } from "node:crypto";
|
|
3751
|
+
|
|
3749
3752
|
// src/drizzle/index.ts
|
|
3750
3753
|
import { getTableColumns as getTableColumns2, getTableName, is as is3 } from "drizzle-orm";
|
|
3751
3754
|
import { PgTable as PgTable3, getTableConfig as getTableConfig3 } from "drizzle-orm/pg-core";
|
|
@@ -4508,6 +4511,8 @@ function prettyPrint(args) {
|
|
|
4508
4511
|
}
|
|
4509
4512
|
|
|
4510
4513
|
// src/utils/pg.ts
|
|
4514
|
+
var bigIntArrayParser = pg.types.getTypeParser(1016);
|
|
4515
|
+
pg.types.setTypeParser(1231, bigIntArrayParser);
|
|
4511
4516
|
var originalClientQuery = pg.Client.prototype.query;
|
|
4512
4517
|
pg.Client.prototype.query = function query(...args) {
|
|
4513
4518
|
try {
|
|
@@ -4632,6 +4637,12 @@ function createReadonlyPool(config, logger, namespace) {
|
|
|
4632
4637
|
// src/utils/pglite.ts
|
|
4633
4638
|
import { mkdirSync } from "node:fs";
|
|
4634
4639
|
import { PGlite } from "@electric-sql/pglite";
|
|
4640
|
+
import {
|
|
4641
|
+
CompiledQuery,
|
|
4642
|
+
PostgresAdapter,
|
|
4643
|
+
PostgresIntrospector,
|
|
4644
|
+
PostgresQueryCompiler
|
|
4645
|
+
} from "kysely";
|
|
4635
4646
|
function createPglite(options) {
|
|
4636
4647
|
if (options.dataDir === "memory://") {
|
|
4637
4648
|
options.dataDir = void 0;
|
|
@@ -4640,6 +4651,54 @@ function createPglite(options) {
|
|
|
4640
4651
|
}
|
|
4641
4652
|
return new PGlite(options);
|
|
4642
4653
|
}
|
|
4654
|
+
function createPgliteKyselyDialect(instance) {
|
|
4655
|
+
return {
|
|
4656
|
+
createAdapter: () => new PostgresAdapter(),
|
|
4657
|
+
createDriver: () => new PGliteDriver(instance),
|
|
4658
|
+
createIntrospector: (db) => new PostgresIntrospector(db),
|
|
4659
|
+
createQueryCompiler: () => new PostgresQueryCompiler()
|
|
4660
|
+
};
|
|
4661
|
+
}
|
|
4662
|
+
var PGliteDriver = class {
|
|
4663
|
+
#client;
|
|
4664
|
+
constructor(client) {
|
|
4665
|
+
this.#client = client;
|
|
4666
|
+
}
|
|
4667
|
+
async acquireConnection() {
|
|
4668
|
+
return new PGliteConnection(this.#client);
|
|
4669
|
+
}
|
|
4670
|
+
async beginTransaction(connection, _settings) {
|
|
4671
|
+
await connection.executeQuery(CompiledQuery.raw("BEGIN"));
|
|
4672
|
+
}
|
|
4673
|
+
async commitTransaction(connection) {
|
|
4674
|
+
await connection.executeQuery(CompiledQuery.raw("COMMIT"));
|
|
4675
|
+
}
|
|
4676
|
+
async rollbackTransaction(connection) {
|
|
4677
|
+
await connection.executeQuery(CompiledQuery.raw("ROLLBACK"));
|
|
4678
|
+
}
|
|
4679
|
+
async destroy() {
|
|
4680
|
+
await this.#client.close();
|
|
4681
|
+
}
|
|
4682
|
+
async init() {
|
|
4683
|
+
}
|
|
4684
|
+
async releaseConnection(_connection) {
|
|
4685
|
+
}
|
|
4686
|
+
};
|
|
4687
|
+
var PGliteConnection = class {
|
|
4688
|
+
#client;
|
|
4689
|
+
constructor(client) {
|
|
4690
|
+
this.#client = client;
|
|
4691
|
+
}
|
|
4692
|
+
async executeQuery(compiledQuery) {
|
|
4693
|
+
return await this.#client.query(compiledQuery.sql, [
|
|
4694
|
+
...compiledQuery.parameters
|
|
4695
|
+
]);
|
|
4696
|
+
}
|
|
4697
|
+
// biome-ignore lint/correctness/useYield: <explanation>
|
|
4698
|
+
async *streamQuery() {
|
|
4699
|
+
throw new Error("PGlite does not support streaming.");
|
|
4700
|
+
}
|
|
4701
|
+
};
|
|
4643
4702
|
|
|
4644
4703
|
// src/database/index.ts
|
|
4645
4704
|
import { getTableColumns as getTableColumns3 } from "drizzle-orm";
|
|
@@ -4652,7 +4711,6 @@ import {
|
|
|
4652
4711
|
WithSchemaPlugin,
|
|
4653
4712
|
sql as sql2
|
|
4654
4713
|
} from "kysely";
|
|
4655
|
-
import { KyselyPGlite } from "kysely-pglite";
|
|
4656
4714
|
import prometheus2 from "prom-client";
|
|
4657
4715
|
var VERSION = "1";
|
|
4658
4716
|
var createDatabase = async ({
|
|
@@ -4674,7 +4732,7 @@ var createDatabase = async ({
|
|
|
4674
4732
|
driver = {
|
|
4675
4733
|
instance: dialect === "pglite" ? createPglite(preBuild.databaseConfig.options) : preBuild.databaseConfig.instance
|
|
4676
4734
|
};
|
|
4677
|
-
const kyselyDialect =
|
|
4735
|
+
const kyselyDialect = createPgliteKyselyDialect(driver.instance);
|
|
4678
4736
|
await driver.instance.query(`CREATE SCHEMA IF NOT EXISTS "${namespace}"`);
|
|
4679
4737
|
await driver.instance.query(`SET search_path TO "${namespace}"`);
|
|
4680
4738
|
qb = {
|
|
@@ -4898,7 +4956,7 @@ var createDatabase = async ({
|
|
|
4898
4956
|
let hasError = false;
|
|
4899
4957
|
for (let i = 0; i <= RETRY_COUNT2; i++) {
|
|
4900
4958
|
const endClock = startClock();
|
|
4901
|
-
const id =
|
|
4959
|
+
const id = randomUUID().slice(0, 8);
|
|
4902
4960
|
if (options.includeTraceLogs) {
|
|
4903
4961
|
common.logger.trace({
|
|
4904
4962
|
service: "database",
|