@mastra/cloudflare 0.11.5-alpha.0 → 0.11.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/index.cjs +30 -15
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +31 -16
- package/dist/index.js.map +1 -1
- package/dist/storage/domains/scores/index.d.ts +5 -2
- package/dist/storage/domains/scores/index.d.ts.map +1 -1
- package/dist/storage/index.d.ts +5 -2
- package/dist/storage/index.d.ts.map +1 -1
- package/package.json +8 -8
package/dist/index.cjs
CHANGED
|
@@ -1535,18 +1535,17 @@ var StoreOperationsCloudflare = class extends storage.StoreOperations {
|
|
|
1535
1535
|
}
|
|
1536
1536
|
};
|
|
1537
1537
|
function transformScoreRow(row) {
|
|
1538
|
-
|
|
1539
|
-
|
|
1540
|
-
|
|
1541
|
-
|
|
1542
|
-
|
|
1543
|
-
|
|
1544
|
-
|
|
1545
|
-
|
|
1546
|
-
|
|
1547
|
-
|
|
1548
|
-
|
|
1549
|
-
};
|
|
1538
|
+
const deserialized = { ...row };
|
|
1539
|
+
deserialized.input = storage.safelyParseJSON(row.input);
|
|
1540
|
+
deserialized.output = storage.safelyParseJSON(row.output);
|
|
1541
|
+
deserialized.scorer = storage.safelyParseJSON(row.scorer);
|
|
1542
|
+
deserialized.preprocessStepResult = storage.safelyParseJSON(row.preprocessStepResult);
|
|
1543
|
+
deserialized.analyzeStepResult = storage.safelyParseJSON(row.analyzeStepResult);
|
|
1544
|
+
deserialized.metadata = storage.safelyParseJSON(row.metadata);
|
|
1545
|
+
deserialized.additionalContext = storage.safelyParseJSON(row.additionalContext);
|
|
1546
|
+
deserialized.runtimeContext = storage.safelyParseJSON(row.runtimeContext);
|
|
1547
|
+
deserialized.entity = storage.safelyParseJSON(row.entity);
|
|
1548
|
+
return deserialized;
|
|
1550
1549
|
}
|
|
1551
1550
|
var ScoresStorageCloudflare = class extends storage.ScoresStorage {
|
|
1552
1551
|
operations;
|
|
@@ -1578,6 +1577,7 @@ var ScoresStorageCloudflare = class extends storage.ScoresStorage {
|
|
|
1578
1577
|
}
|
|
1579
1578
|
async saveScore(score) {
|
|
1580
1579
|
try {
|
|
1580
|
+
const id = crypto.randomUUID();
|
|
1581
1581
|
const { input, ...rest } = score;
|
|
1582
1582
|
const serializedRecord = {};
|
|
1583
1583
|
for (const [key, value] of Object.entries(rest)) {
|
|
@@ -1591,12 +1591,12 @@ var ScoresStorageCloudflare = class extends storage.ScoresStorage {
|
|
|
1591
1591
|
serializedRecord[key] = null;
|
|
1592
1592
|
}
|
|
1593
1593
|
}
|
|
1594
|
-
serializedRecord.
|
|
1594
|
+
serializedRecord.id = id;
|
|
1595
1595
|
serializedRecord.createdAt = (/* @__PURE__ */ new Date()).toISOString();
|
|
1596
1596
|
serializedRecord.updatedAt = (/* @__PURE__ */ new Date()).toISOString();
|
|
1597
1597
|
await this.operations.putKV({
|
|
1598
1598
|
tableName: storage.TABLE_SCORERS,
|
|
1599
|
-
key:
|
|
1599
|
+
key: id,
|
|
1600
1600
|
value: serializedRecord
|
|
1601
1601
|
});
|
|
1602
1602
|
const scoreFromDb = await this.getScoreById({ id: score.id });
|
|
@@ -1618,6 +1618,9 @@ var ScoresStorageCloudflare = class extends storage.ScoresStorage {
|
|
|
1618
1618
|
}
|
|
1619
1619
|
async getScoresByScorerId({
|
|
1620
1620
|
scorerId,
|
|
1621
|
+
entityId,
|
|
1622
|
+
entityType,
|
|
1623
|
+
source,
|
|
1621
1624
|
pagination
|
|
1622
1625
|
}) {
|
|
1623
1626
|
try {
|
|
@@ -1625,6 +1628,15 @@ var ScoresStorageCloudflare = class extends storage.ScoresStorage {
|
|
|
1625
1628
|
const scores = [];
|
|
1626
1629
|
for (const { name: key } of keys) {
|
|
1627
1630
|
const score = await this.operations.getKV(storage.TABLE_SCORERS, key);
|
|
1631
|
+
if (entityId && score.entityId !== entityId) {
|
|
1632
|
+
continue;
|
|
1633
|
+
}
|
|
1634
|
+
if (entityType && score.entityType !== entityType) {
|
|
1635
|
+
continue;
|
|
1636
|
+
}
|
|
1637
|
+
if (source && score.source !== source) {
|
|
1638
|
+
continue;
|
|
1639
|
+
}
|
|
1628
1640
|
if (score && score.scorerId === scorerId) {
|
|
1629
1641
|
scores.push(transformScoreRow(score));
|
|
1630
1642
|
}
|
|
@@ -2329,9 +2341,12 @@ var CloudflareStore = class extends storage.MastraStorage {
|
|
|
2329
2341
|
}
|
|
2330
2342
|
async getScoresByScorerId({
|
|
2331
2343
|
scorerId,
|
|
2344
|
+
entityId,
|
|
2345
|
+
entityType,
|
|
2346
|
+
source,
|
|
2332
2347
|
pagination
|
|
2333
2348
|
}) {
|
|
2334
|
-
return this.stores.scores.getScoresByScorerId({ scorerId, pagination });
|
|
2349
|
+
return this.stores.scores.getScoresByScorerId({ scorerId, entityId, entityType, source, pagination });
|
|
2335
2350
|
}
|
|
2336
2351
|
async getResourceById({ resourceId }) {
|
|
2337
2352
|
return this.stores.memory.getResourceById({ resourceId });
|