@mastra/cloudflare 1.5.0 → 1.5.1

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/CHANGELOG.md CHANGED
@@ -1,5 +1,45 @@
1
1
  # @mastra/cloudflare
2
2
 
3
+ ## 1.5.1
4
+
5
+ ### Patch Changes
6
+
7
+ - Added optional `organizationId` and `projectId` fields to scores for multi-tenant isolation. Scores can now be saved with tenancy metadata and the `listScoresBy*` methods accept a `filters` option to scope results by organization and project. ([#18331](https://github.com/mastra-ai/mastra/pull/18331))
8
+
9
+ ```ts
10
+ await storage.saveScore({ ...score, organizationId: 'org-a', projectId: 'proj-1' });
11
+
12
+ const result = await storage.listScoresByScorerId({
13
+ scorerId,
14
+ filters: { organizationId: 'org-a', projectId: 'proj-1' },
15
+ });
16
+ ```
17
+
18
+ `projectId` identifies the project scope, separate from `resourceId` which continues to mean the agent memory resource.
19
+
20
+ - Updated dependencies [[`700619b`](https://github.com/mastra-ai/mastra/commit/700619b61d572e592cbaaf758121d168844ca4d2), [`0f69865`](https://github.com/mastra-ai/mastra/commit/0f69865aced225d98eac812e22699dc445ee18cb), [`9250acd`](https://github.com/mastra-ai/mastra/commit/9250acd1357f0f1f33d0dcca16f9655084c58eca), [`0c3d4bc`](https://github.com/mastra-ai/mastra/commit/0c3d4bcae13ea3699d379403e6f350d5cf4efe9f), [`cc440a3`](https://github.com/mastra-ai/mastra/commit/cc440a39400d8ce06655462b26c1666a1b3d4320), [`6a61846`](https://github.com/mastra-ai/mastra/commit/6a61846eeda29fb714549b70f1bee2bf6b141c44), [`215f9b0`](https://github.com/mastra-ai/mastra/commit/215f9b0f3f3f6fc165edad360582dd4d3d7ea748), [`17369b2`](https://github.com/mastra-ai/mastra/commit/17369b25250561e9ed994ae509be1d15bfb33bcb), [`c64c2a8`](https://github.com/mastra-ai/mastra/commit/c64c2a8503a50252f9ca6b8e8c54cadee31b92a2), [`bcae929`](https://github.com/mastra-ai/mastra/commit/bcae929945cbf265bd9f327cc715ecafa072b5b9), [`ea6327b`](https://github.com/mastra-ai/mastra/commit/ea6327ba2d63ca647804bc97b347e03a58617162), [`3439fa8`](https://github.com/mastra-ai/mastra/commit/3439fa836ecfcaa257b40c20b30ac2a8be22e9ea), [`85107f2`](https://github.com/mastra-ai/mastra/commit/85107f2758b527147fccbedff962961927c2d3b8), [`b33822e`](https://github.com/mastra-ai/mastra/commit/b33822e8d470884954b02f7b0745407ee4ef74b1), [`06e2680`](https://github.com/mastra-ai/mastra/commit/06e26806b51d2cbd858afdc66daa2b86ff3ba64a), [`06ff9e0`](https://github.com/mastra-ai/mastra/commit/06ff9e0befd1d642ab87ff749285ee4091205c7e), [`d5c11e3`](https://github.com/mastra-ai/mastra/commit/d5c11e3ba5045969caa7272a7bd1fd141c93ab6c), [`7f5e1ff`](https://github.com/mastra-ai/mastra/commit/7f5e1ff695a92f672bb3976363925d1e9136b54a), [`ff80671`](https://github.com/mastra-ai/mastra/commit/ff8067185e208b27198b4e5b71803013175c3643), [`b8375c1`](https://github.com/mastra-ai/mastra/commit/b8375c1f8fe905df8ae2ae9a893bb365f17aec4e), [`dab1257`](https://github.com/mastra-ai/mastra/commit/dab1257b64e4ed576dc5038bb7a3f7072338bc9f), [`1240f05`](https://github.com/mastra-ai/mastra/commit/1240f051c8e5371f1c014448bf37b1a1b9a05e47), [`705ff39`](https://github.com/mastra-ai/mastra/commit/705ff3969e57214ff2fdaf3815d751dd558886ed), [`e6fbd5b`](https://github.com/mastra-ai/mastra/commit/e6fbd5bfdc28e92c0c0433f29aa1bc152d3430f6), [`215f9b0`](https://github.com/mastra-ai/mastra/commit/215f9b0f3f3f6fc165edad360582dd4d3d7ea748), [`24c10d3`](https://github.com/mastra-ai/mastra/commit/24c10d333e6649ac06075903aeeee13a933db3b3), [`24c10d3`](https://github.com/mastra-ai/mastra/commit/24c10d333e6649ac06075903aeeee13a933db3b3), [`24c10d3`](https://github.com/mastra-ai/mastra/commit/24c10d333e6649ac06075903aeeee13a933db3b3), [`6f2026c`](https://github.com/mastra-ai/mastra/commit/6f2026cdf114ff1e21e49133ca774ec7d5085059), [`24c10d3`](https://github.com/mastra-ai/mastra/commit/24c10d333e6649ac06075903aeeee13a933db3b3), [`215f9b0`](https://github.com/mastra-ai/mastra/commit/215f9b0f3f3f6fc165edad360582dd4d3d7ea748), [`215f9b0`](https://github.com/mastra-ai/mastra/commit/215f9b0f3f3f6fc165edad360582dd4d3d7ea748), [`003f35d`](https://github.com/mastra-ai/mastra/commit/003f35d19e07b23b4bacc591c8bc0c59b42124ae), [`f890eda`](https://github.com/mastra-ai/mastra/commit/f890eda2c8a2ae83d9b30bc6d85842f93b6c266b), [`1340fb7`](https://github.com/mastra-ai/mastra/commit/1340fb76262a3ca062130aa71859f07257a0a5a4)]:
21
+ - @mastra/core@1.49.0
22
+
23
+ ## 1.5.1-alpha.0
24
+
25
+ ### Patch Changes
26
+
27
+ - Added optional `organizationId` and `projectId` fields to scores for multi-tenant isolation. Scores can now be saved with tenancy metadata and the `listScoresBy*` methods accept a `filters` option to scope results by organization and project. ([#18331](https://github.com/mastra-ai/mastra/pull/18331))
28
+
29
+ ```ts
30
+ await storage.saveScore({ ...score, organizationId: 'org-a', projectId: 'proj-1' });
31
+
32
+ const result = await storage.listScoresByScorerId({
33
+ scorerId,
34
+ filters: { organizationId: 'org-a', projectId: 'proj-1' },
35
+ });
36
+ ```
37
+
38
+ `projectId` identifies the project scope, separate from `resourceId` which continues to mean the agent memory resource.
39
+
40
+ - Updated dependencies [[`9250acd`](https://github.com/mastra-ai/mastra/commit/9250acd1357f0f1f33d0dcca16f9655084c58eca), [`215f9b0`](https://github.com/mastra-ai/mastra/commit/215f9b0f3f3f6fc165edad360582dd4d3d7ea748), [`c64c2a8`](https://github.com/mastra-ai/mastra/commit/c64c2a8503a50252f9ca6b8e8c54cadee31b92a2), [`06e2680`](https://github.com/mastra-ai/mastra/commit/06e26806b51d2cbd858afdc66daa2b86ff3ba64a), [`1240f05`](https://github.com/mastra-ai/mastra/commit/1240f051c8e5371f1c014448bf37b1a1b9a05e47), [`215f9b0`](https://github.com/mastra-ai/mastra/commit/215f9b0f3f3f6fc165edad360582dd4d3d7ea748), [`24c10d3`](https://github.com/mastra-ai/mastra/commit/24c10d333e6649ac06075903aeeee13a933db3b3), [`24c10d3`](https://github.com/mastra-ai/mastra/commit/24c10d333e6649ac06075903aeeee13a933db3b3), [`24c10d3`](https://github.com/mastra-ai/mastra/commit/24c10d333e6649ac06075903aeeee13a933db3b3), [`24c10d3`](https://github.com/mastra-ai/mastra/commit/24c10d333e6649ac06075903aeeee13a933db3b3), [`215f9b0`](https://github.com/mastra-ai/mastra/commit/215f9b0f3f3f6fc165edad360582dd4d3d7ea748), [`215f9b0`](https://github.com/mastra-ai/mastra/commit/215f9b0f3f3f6fc165edad360582dd4d3d7ea748)]:
41
+ - @mastra/core@1.49.0-alpha.5
42
+
3
43
  ## 1.5.0
4
44
 
5
45
  ### Minor Changes
@@ -1735,6 +1735,11 @@ var MemoryStorageCloudflare = class extends MemoryStorage {
1735
1735
  function transformScoreRow(row) {
1736
1736
  return transformScoreRow$1(row);
1737
1737
  }
1738
+ function matchesTenancy(score, filters) {
1739
+ if (filters?.organizationId !== void 0 && score.organizationId !== filters.organizationId) return false;
1740
+ if (filters?.projectId !== void 0 && score.projectId !== filters.projectId) return false;
1741
+ return true;
1742
+ }
1738
1743
  var ScoresStorageCloudflare = class extends ScoresStorage {
1739
1744
  #db;
1740
1745
  constructor(config) {
@@ -1833,7 +1838,8 @@ var ScoresStorageCloudflare = class extends ScoresStorage {
1833
1838
  entityId,
1834
1839
  entityType,
1835
1840
  source,
1836
- pagination
1841
+ pagination,
1842
+ filters
1837
1843
  }) {
1838
1844
  try {
1839
1845
  const keys = await this.#db.listKV(TABLE_SCORERS);
@@ -1849,6 +1855,9 @@ var ScoresStorageCloudflare = class extends ScoresStorage {
1849
1855
  if (source && score.source !== source) {
1850
1856
  continue;
1851
1857
  }
1858
+ if (!matchesTenancy(score, filters)) {
1859
+ continue;
1860
+ }
1852
1861
  if (score && score.scorerId === scorerId) {
1853
1862
  scores.push(transformScoreRow(score));
1854
1863
  }
@@ -1890,14 +1899,15 @@ var ScoresStorageCloudflare = class extends ScoresStorage {
1890
1899
  }
1891
1900
  async listScoresByRunId({
1892
1901
  runId,
1893
- pagination
1902
+ pagination,
1903
+ filters
1894
1904
  }) {
1895
1905
  try {
1896
1906
  const keys = await this.#db.listKV(TABLE_SCORERS);
1897
1907
  const scores = [];
1898
1908
  for (const { name: key } of keys) {
1899
1909
  const score = await this.#db.getKV(TABLE_SCORERS, key);
1900
- if (score && score.runId === runId) {
1910
+ if (score && score.runId === runId && matchesTenancy(score, filters)) {
1901
1911
  scores.push(transformScoreRow(score));
1902
1912
  }
1903
1913
  }
@@ -1939,14 +1949,15 @@ var ScoresStorageCloudflare = class extends ScoresStorage {
1939
1949
  async listScoresByEntityId({
1940
1950
  entityId,
1941
1951
  entityType,
1942
- pagination
1952
+ pagination,
1953
+ filters
1943
1954
  }) {
1944
1955
  try {
1945
1956
  const keys = await this.#db.listKV(TABLE_SCORERS);
1946
1957
  const scores = [];
1947
1958
  for (const { name: key } of keys) {
1948
1959
  const score = await this.#db.getKV(TABLE_SCORERS, key);
1949
- if (score && score.entityId === entityId && score.entityType === entityType) {
1960
+ if (score && score.entityId === entityId && score.entityType === entityType && matchesTenancy(score, filters)) {
1950
1961
  scores.push(transformScoreRow(score));
1951
1962
  }
1952
1963
  }
@@ -1988,14 +1999,15 @@ var ScoresStorageCloudflare = class extends ScoresStorage {
1988
1999
  async listScoresBySpan({
1989
2000
  traceId,
1990
2001
  spanId,
1991
- pagination
2002
+ pagination,
2003
+ filters
1992
2004
  }) {
1993
2005
  try {
1994
2006
  const keys = await this.#db.listKV(TABLE_SCORERS);
1995
2007
  const scores = [];
1996
2008
  for (const { name: key } of keys) {
1997
2009
  const score = await this.#db.getKV(TABLE_SCORERS, key);
1998
- if (score && score.traceId === traceId && score.spanId === spanId) {
2010
+ if (score && score.traceId === traceId && score.spanId === spanId && matchesTenancy(score, filters)) {
1999
2011
  scores.push(transformScoreRow(score));
2000
2012
  }
2001
2013
  }
@@ -2405,5 +2417,5 @@ var CloudflareKVStorage = class extends MastraCompositeStore {
2405
2417
  var CloudflareStore = CloudflareKVStorage;
2406
2418
 
2407
2419
  export { BackgroundTasksStorageCloudflare, CloudflareKVStorage, CloudflareStore, MemoryStorageCloudflare, ScoresStorageCloudflare, WorkflowsStorageCloudflare };
2408
- //# sourceMappingURL=chunk-5NOOV27A.js.map
2409
- //# sourceMappingURL=chunk-5NOOV27A.js.map
2420
+ //# sourceMappingURL=chunk-CD6XB3H3.js.map
2421
+ //# sourceMappingURL=chunk-CD6XB3H3.js.map