@mastra/pg 1.30.0-alpha.4 → 1.30.0-alpha.6
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/docs/SKILL.md +1 -1
- package/dist/docs/assets/SOURCE_MAP.json +1 -1
- package/dist/index.cjs +36 -16
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +36 -16
- package/dist/index.js.map +1 -1
- package/dist/storage/db/index.d.ts.map +1 -1
- package/dist/vector/index.d.ts +4 -0
- package/dist/vector/index.d.ts.map +1 -1
- package/package.json +4 -4
package/dist/docs/SKILL.md
CHANGED
package/dist/index.cjs
CHANGED
|
@@ -726,17 +726,25 @@ var PgVector = class extends _mastra_core_vector.MastraVector {
|
|
|
726
726
|
await client.query(`SET search_path TO ${[...schemas].map((s) => `"${s}"`).join(", ")}`);
|
|
727
727
|
}
|
|
728
728
|
}
|
|
729
|
-
/**
|
|
730
|
-
|
|
731
|
-
* halfvec was introduced in pgvector 0.7.0.
|
|
732
|
-
*/
|
|
733
|
-
supportsHalfvec() {
|
|
729
|
+
/** Checks if the installed pgvector version is at least the given major.minor version. */
|
|
730
|
+
isVectorExtensionAtLeast(minMajor, minMinor) {
|
|
734
731
|
if (!this.vectorExtensionVersion) return false;
|
|
735
732
|
const parts = this.vectorExtensionVersion.split(".");
|
|
736
733
|
const major = parseInt(parts[0] ?? "", 10);
|
|
737
734
|
const minor = parseInt(parts[1] ?? "", 10);
|
|
738
735
|
if (isNaN(major) || isNaN(minor)) return false;
|
|
739
|
-
return major >
|
|
736
|
+
return major > minMajor || major === minMajor && minor >= minMinor;
|
|
737
|
+
}
|
|
738
|
+
/**
|
|
739
|
+
* Checks if the installed pgvector version supports halfvec type.
|
|
740
|
+
* halfvec was introduced in pgvector 0.7.0.
|
|
741
|
+
*/
|
|
742
|
+
supportsHalfvec() {
|
|
743
|
+
return this.isVectorExtensionAtLeast(0, 7);
|
|
744
|
+
}
|
|
745
|
+
/** Checks if pgvector >= 0.8.0 (required for the hnsw.iterative_scan setting). */
|
|
746
|
+
supportsIterativeScan() {
|
|
747
|
+
return this.isVectorExtensionAtLeast(0, 8);
|
|
740
748
|
}
|
|
741
749
|
/** Checks if pgvector >= 0.7.0 (required for bit type). */
|
|
742
750
|
supportsBit() {
|
|
@@ -1055,7 +1063,7 @@ var PgVector = class extends _mastra_core_vector.MastraVector {
|
|
|
1055
1063
|
const calculatedEf = ef ?? Math.max(topK, (indexInfo?.config?.m ?? 16) * topK);
|
|
1056
1064
|
const searchEf = Math.min(1e3, Math.max(1, calculatedEf));
|
|
1057
1065
|
await client.query(`SET LOCAL hnsw.ef_search = ${searchEf}`);
|
|
1058
|
-
await client.query(`SET LOCAL hnsw.iterative_scan = strict_order`);
|
|
1066
|
+
if (this.supportsIterativeScan()) await client.query(`SET LOCAL hnsw.iterative_scan = strict_order`);
|
|
1059
1067
|
}
|
|
1060
1068
|
if (indexInfo.type === "ivfflat" && probes) await client.query(`SET LOCAL ivfflat.probes = ${probes}`);
|
|
1061
1069
|
const { tableName } = this.getTableName(indexName);
|
|
@@ -2565,10 +2573,13 @@ function resolvePgConfig(config) {
|
|
|
2565
2573
|
};
|
|
2566
2574
|
}
|
|
2567
2575
|
let pool;
|
|
2568
|
-
if ("connectionString" in config) pool = new pg.Pool({
|
|
2576
|
+
if ("connectionString" in config) pool = new pg.Pool(buildConnectionStringPoolConfig({
|
|
2569
2577
|
connectionString: config.connectionString,
|
|
2570
2578
|
ssl: config.ssl
|
|
2571
|
-
}
|
|
2579
|
+
}, {
|
|
2580
|
+
max: 10,
|
|
2581
|
+
idleTimeoutMillis: 1e4
|
|
2582
|
+
}));
|
|
2572
2583
|
else pool = new pg.Pool({
|
|
2573
2584
|
host: config.host,
|
|
2574
2585
|
port: config.port,
|
|
@@ -2780,7 +2791,15 @@ BEGIN
|
|
|
2780
2791
|
END
|
|
2781
2792
|
$mastra_timestamps_trigger$;`;
|
|
2782
2793
|
}
|
|
2783
|
-
const schemaSetupRegistry = /* @__PURE__ */ new
|
|
2794
|
+
const schemaSetupRegistry = /* @__PURE__ */ new WeakMap();
|
|
2795
|
+
function getSchemaSetupRegistry(pool) {
|
|
2796
|
+
let registry = schemaSetupRegistry.get(pool);
|
|
2797
|
+
if (!registry) {
|
|
2798
|
+
registry = /* @__PURE__ */ new Map();
|
|
2799
|
+
schemaSetupRegistry.set(pool, registry);
|
|
2800
|
+
}
|
|
2801
|
+
return registry;
|
|
2802
|
+
}
|
|
2784
2803
|
/**
|
|
2785
2804
|
* Guard prune batch limits: a non-positive limit deletes nothing while callers'
|
|
2786
2805
|
* drain checks (`affected < limit`) never fire, which turns the prune loop into
|
|
@@ -3019,11 +3038,12 @@ var PgDB = class extends _mastra_core_base.MastraBase {
|
|
|
3019
3038
|
}
|
|
3020
3039
|
async setupSchema() {
|
|
3021
3040
|
if (!this.schemaName) return;
|
|
3022
|
-
|
|
3041
|
+
const registry = getSchemaSetupRegistry(this.client.$pool);
|
|
3042
|
+
let registryEntry = registry.get(this.schemaName);
|
|
3023
3043
|
if (registryEntry?.complete) return;
|
|
3024
3044
|
const snapshot = this.schemaSnapshot;
|
|
3025
3045
|
if (snapshot && snapshot.tables.size > 0) {
|
|
3026
|
-
|
|
3046
|
+
registry.set(this.schemaName, {
|
|
3027
3047
|
promise: null,
|
|
3028
3048
|
complete: true
|
|
3029
3049
|
});
|
|
@@ -3049,19 +3069,19 @@ var PgDB = class extends _mastra_core_base.MastraBase {
|
|
|
3049
3069
|
throw new Error(`Unable to create schema "${schemaNameCapture}". This requires CREATE privilege on the database. Either create the schema manually or grant CREATE privilege to the user.`);
|
|
3050
3070
|
}
|
|
3051
3071
|
}
|
|
3052
|
-
const entry =
|
|
3072
|
+
const entry = registry.get(schemaNameCapture);
|
|
3053
3073
|
if (entry) entry.complete = true;
|
|
3054
3074
|
this.logger.debug(`Schema "${quotedSchemaName}" is ready for use`);
|
|
3055
3075
|
} catch (error) {
|
|
3056
|
-
|
|
3076
|
+
registry.delete(schemaNameCapture);
|
|
3057
3077
|
throw error;
|
|
3058
3078
|
}
|
|
3059
3079
|
})();
|
|
3060
|
-
|
|
3080
|
+
registry.set(this.schemaName, {
|
|
3061
3081
|
promise: setupPromise,
|
|
3062
3082
|
complete: false
|
|
3063
3083
|
});
|
|
3064
|
-
registryEntry =
|
|
3084
|
+
registryEntry = registry.get(this.schemaName);
|
|
3065
3085
|
}
|
|
3066
3086
|
await registryEntry.promise;
|
|
3067
3087
|
}
|