@mastra/pg 1.28.0 → 1.28.1-alpha.0
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/docs/references/docs-deployment-workers.md +3 -1
- package/dist/index.cjs +9 -13
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +9 -13
- package/dist/index.js.map +1 -1
- package/dist/storage/domains/memory/index.d.ts.map +1 -1
- package/dist/storage/domains/notifications/index.d.ts.map +1 -1
- package/dist/storage/domains/skills/index.d.ts.map +1 -1
- package/dist/storage/domains/workspaces/index.d.ts.map +1 -1
- package/dist/storage/factory-storage.d.ts.map +1 -1
- package/dist/vector/index.d.ts.map +1 -1
- package/package.json +3 -3
package/dist/docs/SKILL.md
CHANGED
|
@@ -60,7 +60,7 @@ The background task worker manages concurrency limits, task lifecycle, and resul
|
|
|
60
60
|
|
|
61
61
|
### In-process mode (default)
|
|
62
62
|
|
|
63
|
-
With no configuration, Mastra
|
|
63
|
+
With no configuration, Mastra runs workers inside the API process. Events flow through an in-memory PubSub, and everything shares a single Node.js runtime.
|
|
64
64
|
|
|
65
65
|
```typescript
|
|
66
66
|
import { Mastra } from '@mastra/core/mastra'
|
|
@@ -71,6 +71,8 @@ export const mastra = new Mastra({
|
|
|
71
71
|
})
|
|
72
72
|
```
|
|
73
73
|
|
|
74
|
+
The server generated by `mastra build` starts these workers automatically. If you use a [server adapter](https://mastra.ai/docs/server/server-adapters) instead, add a call to `mastra.startWorkers()` after your server starts listening. See [Start background workers](https://mastra.ai/docs/server/server-adapters).
|
|
75
|
+
|
|
74
76
|
This setup needs no external infrastructure beyond your storage adapter. It doesn't survive process crashes, and you can't scale individual components.
|
|
75
77
|
|
|
76
78
|
### Split processes
|
package/dist/index.cjs
CHANGED
|
@@ -21,7 +21,6 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
21
21
|
enumerable: true
|
|
22
22
|
}) : target, mod));
|
|
23
23
|
//#endregion
|
|
24
|
-
let crypto$1 = require("crypto");
|
|
25
24
|
let _mastra_core_error = require("@mastra/core/error");
|
|
26
25
|
let _mastra_core_storage = require("@mastra/core/storage");
|
|
27
26
|
_mastra_core_storage = __toESM(_mastra_core_storage, 1);
|
|
@@ -35,6 +34,7 @@ xxhash_wasm = __toESM(xxhash_wasm, 1);
|
|
|
35
34
|
let pg_connection_string = require("pg-connection-string");
|
|
36
35
|
let _mastra_core_vector_filter = require("@mastra/core/vector/filter");
|
|
37
36
|
let _mastra_core_base = require("@mastra/core/base");
|
|
37
|
+
let crypto$1 = require("crypto");
|
|
38
38
|
let _mastra_core_agent = require("@mastra/core/agent");
|
|
39
39
|
let _mastra_core_features = require("@mastra/core/features");
|
|
40
40
|
let _mastra_core_evals = require("@mastra/core/evals");
|
|
@@ -849,7 +849,7 @@ var PgVector = class extends _mastra_core_vector.MastraVector {
|
|
|
849
849
|
AND NOT attisdropped`, [tableName])).rowCount === 0) return;
|
|
850
850
|
await client.query(`ALTER TABLE ${tableName} ADD COLUMN IF NOT EXISTS namespace VARCHAR(255) NOT NULL DEFAULT '${DEFAULT_NAMESPACE}'`);
|
|
851
851
|
if (!(await this.getNamespaceSchemaState(tableName, client)).composite_index) {
|
|
852
|
-
const namespaceIndexName = this.getNamespaceIndexName(parsedIndexName);
|
|
852
|
+
const namespaceIndexName = await this.getNamespaceIndexName(parsedIndexName);
|
|
853
853
|
await client.query(`CREATE UNIQUE INDEX IF NOT EXISTS "${namespaceIndexName}" ON ${tableName} (namespace, vector_id)`);
|
|
854
854
|
}
|
|
855
855
|
const legacyConstraints = await client.query(`SELECT c.conname
|
|
@@ -862,10 +862,10 @@ var PgVector = class extends _mastra_core_vector.MastraVector {
|
|
|
862
862
|
await client.query(`ALTER TABLE ${tableName} DROP CONSTRAINT "${parsedConstraintName}"`);
|
|
863
863
|
}
|
|
864
864
|
}
|
|
865
|
-
getNamespaceIndexName(parsedIndexName) {
|
|
865
|
+
async getNamespaceIndexName(parsedIndexName) {
|
|
866
866
|
const fullName = `${parsedIndexName}_namespace_vector_id_idx`;
|
|
867
867
|
if (fullName.length <= 63) return fullName;
|
|
868
|
-
const suffix = `_ns_${(
|
|
868
|
+
const suffix = `_ns_${Buffer.from(await globalThis.crypto.subtle.digest("SHA-256", new TextEncoder().encode(parsedIndexName))).toString("hex").slice(0, 32)}_idx`;
|
|
869
869
|
return `${parsedIndexName.slice(0, 63 - suffix.length)}${suffix}`;
|
|
870
870
|
}
|
|
871
871
|
async getNamespaceSchemaState(tableName, client) {
|
|
@@ -12677,7 +12677,7 @@ var MemoryPG = class MemoryPG extends _mastra_core_storage.MemoryStorage {
|
|
|
12677
12677
|
});
|
|
12678
12678
|
const nowStr = (/* @__PURE__ */ new Date()).toISOString();
|
|
12679
12679
|
const newChunk = {
|
|
12680
|
-
id: `ombuf-${
|
|
12680
|
+
id: `ombuf-${globalThis.crypto.randomUUID()}`,
|
|
12681
12681
|
cycleId: input.chunk.cycleId,
|
|
12682
12682
|
observations: input.chunk.observations,
|
|
12683
12683
|
tokenCount: Math.round(input.chunk.tokenCount),
|
|
@@ -13247,7 +13247,7 @@ var NotificationsPG = class NotificationsPG extends _mastra_core_storage.Notific
|
|
|
13247
13247
|
}
|
|
13248
13248
|
const now = input.createdAt ?? /* @__PURE__ */ new Date();
|
|
13249
13249
|
const record = {
|
|
13250
|
-
id: input.id ??
|
|
13250
|
+
id: input.id ?? globalThis.crypto.randomUUID(),
|
|
13251
13251
|
threadId: input.threadId,
|
|
13252
13252
|
source: input.source,
|
|
13253
13253
|
kind: input.kind,
|
|
@@ -21500,7 +21500,6 @@ var SkillsPG = class SkillsPG extends _mastra_core_storage.SkillsStorage {
|
|
|
21500
21500
|
details: { skillId: id }
|
|
21501
21501
|
});
|
|
21502
21502
|
const { authorId, visibility, activeVersionId, status, ...rawConfigFields } = updates;
|
|
21503
|
-
let versionCreated = false;
|
|
21504
21503
|
const configFields = {};
|
|
21505
21504
|
for (const [key, value] of Object.entries(rawConfigFields)) if (value !== void 0) configFields[key] = value;
|
|
21506
21505
|
if (SNAPSHOT_FIELDS$1.some((field) => field in configFields)) {
|
|
@@ -21519,7 +21518,6 @@ var SkillsPG = class SkillsPG extends _mastra_core_storage.SkillsStorage {
|
|
|
21519
21518
|
};
|
|
21520
21519
|
const changedFields = SNAPSHOT_FIELDS$1.filter((field) => field in configFields && !(0, _mastra_core_storage_domains_skills.skillSnapshotFieldValuesEqual)(configFields[field], latestConfig[field]));
|
|
21521
21520
|
if (changedFields.length > 0) {
|
|
21522
|
-
versionCreated = true;
|
|
21523
21521
|
const newVersionId = crypto.randomUUID();
|
|
21524
21522
|
await this.createVersion({
|
|
21525
21523
|
id: newVersionId,
|
|
@@ -21560,7 +21558,7 @@ var SkillsPG = class SkillsPG extends _mastra_core_storage.SkillsStorage {
|
|
|
21560
21558
|
setClauses.push(`"updatedAtZ" = $${paramIndex++}`);
|
|
21561
21559
|
values.push(now);
|
|
21562
21560
|
values.push(id);
|
|
21563
|
-
|
|
21561
|
+
await this.#db.client.none(`UPDATE ${tableName} SET ${setClauses.join(", ")} WHERE id = $${paramIndex}`, values);
|
|
21564
21562
|
const updatedSkill = await this.#getById(this.#db.client, id);
|
|
21565
21563
|
if (!updatedSkill) throw new _mastra_core_error.MastraError({
|
|
21566
21564
|
id: (0, _mastra_core_storage.createStorageErrorId)("PG", "UPDATE_SKILL", "NOT_FOUND_AFTER_UPDATE"),
|
|
@@ -23337,7 +23335,6 @@ var WorkspacesPG = class WorkspacesPG extends _mastra_core_storage.WorkspacesSto
|
|
|
23337
23335
|
details: { workspaceId: id }
|
|
23338
23336
|
});
|
|
23339
23337
|
const { authorId, activeVersionId, metadata, status, ...rawConfigFields } = updates;
|
|
23340
|
-
let versionCreated = false;
|
|
23341
23338
|
const configFields = {};
|
|
23342
23339
|
for (const [key, value] of Object.entries(rawConfigFields)) if (value !== void 0) configFields[key] = value;
|
|
23343
23340
|
if (SNAPSHOT_FIELDS.some((field) => field in configFields)) {
|
|
@@ -23360,7 +23357,6 @@ var WorkspacesPG = class WorkspacesPG extends _mastra_core_storage.WorkspacesSto
|
|
|
23360
23357
|
};
|
|
23361
23358
|
const changedFields = SNAPSHOT_FIELDS.filter((field) => field in configFields && !(0, util.isDeepStrictEqual)(normalized(configFields[field]), normalized(latestConfig[field])));
|
|
23362
23359
|
if (changedFields.length > 0) {
|
|
23363
|
-
versionCreated = true;
|
|
23364
23360
|
const newVersionId = crypto.randomUUID();
|
|
23365
23361
|
await this.createVersion({
|
|
23366
23362
|
id: newVersionId,
|
|
@@ -23406,7 +23402,7 @@ var WorkspacesPG = class WorkspacesPG extends _mastra_core_storage.WorkspacesSto
|
|
|
23406
23402
|
setClauses.push(`"updatedAtZ" = $${paramIndex++}`);
|
|
23407
23403
|
values.push(now);
|
|
23408
23404
|
values.push(id);
|
|
23409
|
-
|
|
23405
|
+
await this.#db.client.none(`UPDATE ${tableName} SET ${setClauses.join(", ")} WHERE id = $${paramIndex}`, values);
|
|
23410
23406
|
const updatedWorkspace = await this.#getById(this.#db.client, id);
|
|
23411
23407
|
if (!updatedWorkspace) throw new _mastra_core_error.MastraError({
|
|
23412
23408
|
id: (0, _mastra_core_storage.createStorageErrorId)("PG", "UPDATE_WORKSPACE", "NOT_FOUND_AFTER_UPDATE"),
|
|
@@ -23968,7 +23964,7 @@ var PgFactoryStorageOps = class {
|
|
|
23968
23964
|
const schema = this.#schema(collection);
|
|
23969
23965
|
const pk = primaryKeyOf(schema);
|
|
23970
23966
|
const values = { ...row };
|
|
23971
|
-
if (schema.columns[pk].type === "uuid-pk" && values[pk] === void 0) values[pk] =
|
|
23967
|
+
if (schema.columns[pk].type === "uuid-pk" && values[pk] === void 0) values[pk] = globalThis.crypto.randomUUID();
|
|
23972
23968
|
const columns = Object.keys(values).filter((column) => values[column] !== void 0);
|
|
23973
23969
|
for (const column of columns) this.#column(schema, column);
|
|
23974
23970
|
const sql = `INSERT INTO "${schema.name}" (${columns.map((c) => `"${c}"`).join(", ")}) VALUES (${columns.map((_, i) => `$${i + 1}`).join(", ")}) RETURNING *`;
|