@mastra/spanner 1.2.2-alpha.1 → 1.2.3-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/CHANGELOG.md +135 -0
- package/dist/docs/SKILL.md +1 -1
- package/dist/docs/assets/SOURCE_MAP.json +1 -1
- package/dist/docs/references/reference-storage-spanner.md +6 -6
- package/dist/index.cjs +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +2 -2
- package/dist/index.js.map +1 -1
- package/dist/storage/domains/schedules/index.d.ts.map +1 -1
- package/package.json +6 -6
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,140 @@
|
|
|
1
1
|
# @mastra/spanner
|
|
2
2
|
|
|
3
|
+
## 1.2.3-alpha.0
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Update `@mastra/core` peer dependency for the unified schedules API ([#18874](https://github.com/mastra-ai/mastra/pull/18874))
|
|
8
|
+
|
|
9
|
+
- Schedule rows persisted with the legacy `target.type: 'heartbeat'` are now normalized to `target.type: 'agent'` when read, so existing agent schedules keep firing after the heartbeats-to-schedules rename in `@mastra/core`. ([#18874](https://github.com/mastra-ai/mastra/pull/18874))
|
|
10
|
+
|
|
11
|
+
- Updated dependencies [[`b291760`](https://github.com/mastra-ai/mastra/commit/b291760df9d6c7e4fc72606c8f0a4af2cf6e946c), [`29b7ea6`](https://github.com/mastra-ai/mastra/commit/29b7ea64e72b5523d5bdcbd34ee03d2b854d54e1), [`10959d5`](https://github.com/mastra-ai/mastra/commit/10959d509d824f682d40ff96e05ee044aec3b0e5), [`ffc3c17`](https://github.com/mastra-ai/mastra/commit/ffc3c17274ea17c11aa6f73d3140649cd7fc8abc), [`3908e53`](https://github.com/mastra-ai/mastra/commit/3908e53ce04bbea04f5e0c097d7aa298c35fabee)]:
|
|
12
|
+
- @mastra/core@1.50.0-alpha.3
|
|
13
|
+
|
|
14
|
+
## 1.2.2
|
|
15
|
+
|
|
16
|
+
### Patch Changes
|
|
17
|
+
|
|
18
|
+
- Added optional tenancy arguments to `getDataset`, `updateDataset`, and `deleteDataset`. ([#18750](https://github.com/mastra-ai/mastra/pull/18750))
|
|
19
|
+
|
|
20
|
+
You can now pass `organizationId` and `projectId` to scope dataset reads, updates, and deletes to a specific tenant. Reads and updates against a dataset in a different tenant throw `DATASET_NOT_FOUND` (surfaced as a 404 over HTTP). Deletes silently no-op on a tenancy mismatch — matching the existing "delete non-existent id is a no-op" semantics so cross-tenant existence is never leaked via error timing or status.
|
|
21
|
+
|
|
22
|
+
**Example**
|
|
23
|
+
|
|
24
|
+
```ts
|
|
25
|
+
// Before
|
|
26
|
+
await client.getDataset('abc123');
|
|
27
|
+
await client.deleteDataset('abc123');
|
|
28
|
+
await client.updateDataset({ id: 'abc123', name: 'renamed' });
|
|
29
|
+
|
|
30
|
+
// After — scope to a tenant
|
|
31
|
+
await client.getDataset('abc123', { organizationId: 'org_a', projectId: 'proj_1' });
|
|
32
|
+
await client.deleteDataset('abc123', { organizationId: 'org_a' });
|
|
33
|
+
await client.updateDataset({ id: 'abc123', name: 'renamed', organizationId: 'org_a' });
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
- Pushed remaining dataset read filters and pagination down to storage. ([#18710](https://github.com/mastra-ai/mastra/pull/18710))
|
|
37
|
+
|
|
38
|
+
`DatasetsManager.list({ filters })` now accepts `targetType`, `targetIds` (overlap/union semantics), and `name` (substring, case-insensitive) in addition to the existing tenancy and candidate filters. Filtering is pushed down to the storage layer so callers no longer have to post-filter results.
|
|
39
|
+
|
|
40
|
+
Storage adapters must also be upgraded to the versions listed below to honor the new filters. If a caller is on this version of `@mastra/core` but on an older storage adapter, the new `targetType`/`targetIds`/`name` filter keys are silently ignored by the adapter — no runtime error, but the filter has no effect and every dataset in the tenancy is returned.
|
|
41
|
+
|
|
42
|
+
`Dataset.listItems({ version, search, page, perPage })` now applies `search` and pagination at the storage layer when `version` is provided alongside any of those. Previously they were silently dropped whenever `version` was set. The return shape is unchanged: passing only `version` still returns a bare `DatasetItem[]` snapshot; passing `search`, `page`, or `perPage` (with or without `version`) returns the paginated `{ items, pagination }` shape. The bare-array branch is marked `@deprecated`; prefer passing `page` / `perPage` to always receive the paginated shape.
|
|
43
|
+
|
|
44
|
+
- Tenancy-scope experiments `getById` and `delete*` on `ExperimentsStorage`. ([#18770](https://github.com/mastra-ai/mastra/pull/18770))
|
|
45
|
+
|
|
46
|
+
`ExperimentsStorage.getExperimentById`, `getExperimentResultById`, `deleteExperiment`, and `deleteExperimentResults` used to key on the primary id alone, so any caller who knew the id could read or delete the row regardless of tenant. All four now accept an optional `filters: { organizationId?, projectId? }` argument that is enforced on every adapter (inmemory, libsql, pg, mysql, mongodb, spanner):
|
|
47
|
+
- On tenancy mismatch, `get*` returns `null` at the storage layer.
|
|
48
|
+
- On tenancy mismatch, `delete*` is a silent no-op.
|
|
49
|
+
- The tenancy predicate is folded into the destructive DML itself (scoped `WHERE` on the DELETE, an atomic gate + delete inside a transaction, or a scoped subquery for the results cascade). A concurrent tenant swap of the same id between a pre-check and the DELETE cannot let a scoped delete hit another tenant's row.
|
|
50
|
+
|
|
51
|
+
Both behaviors match how a missing id already responds, so existence does not leak through error timing or messages.
|
|
52
|
+
|
|
53
|
+
The same atomic-DML pattern is also applied to `DatasetsStorage.deleteDataset` across all 5 store adapters, closing a TOCTOU window between the pre-check and the parent DELETE that was introduced when tenancy filters were originally added.
|
|
54
|
+
|
|
55
|
+
`Dataset.getExperiment` and the shared experiment-ownership gate on `Dataset` now forward the dataset's tenancy scope to storage, so experiment reads and downstream mutations (list results, update result, delete experiment) reached through a dataset handle are automatically scoped to the owning tenant.
|
|
56
|
+
|
|
57
|
+
Legacy calls that omit `filters` are unchanged, so this is fully backwards-compatible.
|
|
58
|
+
|
|
59
|
+
```ts
|
|
60
|
+
// Before: any caller who knew the id could read/delete across tenants.
|
|
61
|
+
await store.experiments.getExperimentById({ id: experimentId });
|
|
62
|
+
await store.experiments.deleteExperiment({ id: experimentId });
|
|
63
|
+
|
|
64
|
+
// After: pass the caller's scope; wrong tenant gets null / silent no-op.
|
|
65
|
+
await store.experiments.getExperimentById({
|
|
66
|
+
id: experimentId,
|
|
67
|
+
filters: { organizationId, projectId },
|
|
68
|
+
});
|
|
69
|
+
await store.experiments.deleteExperiment({
|
|
70
|
+
id: experimentId,
|
|
71
|
+
filters: { organizationId, projectId },
|
|
72
|
+
});
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
- Fixed a cross-tenant data-access issue on datasets by scoping `DatasetsManager.get` and `DatasetsManager.delete` to tenancy filters. ([#18750](https://github.com/mastra-ai/mastra/pull/18750))
|
|
76
|
+
|
|
77
|
+
Previously `get({ id })` and `delete({ id })` looked up a dataset by its primary key alone. Any caller who knew a dataset id could read or delete it regardless of which `organizationId` / `projectId` it belonged to. This is now closed at the storage layer via a scoped SQL predicate (option (a) — no fetch-then-assert).
|
|
78
|
+
|
|
79
|
+
**What changed**
|
|
80
|
+
- `DatasetsManager.get` and `DatasetsManager.delete` accept optional `organizationId` and `projectId`.
|
|
81
|
+
- The tenancy is stashed on the returned `Dataset` handle and forwarded to every downstream storage call (`getDetails`, `update`, `addItem`, item batch ops, `startExperimentAsync`).
|
|
82
|
+
- The abstract storage contract (`getDatasetById`, `deleteDataset`) gained an optional `filters?: DatasetTenancyFilters` arg.
|
|
83
|
+
- Item-mutation inputs (`AddDatasetItemInput`, `UpdateDatasetItemInput`, `BatchInsertItemsInput`, `BatchDeleteItemsInput`) and `UpdateDatasetInput` accept optional `filters` for the internal existence check.
|
|
84
|
+
|
|
85
|
+
**Behavior**
|
|
86
|
+
- Omitting tenancy preserves the existing behavior (no predicate added) — fully backwards compatible.
|
|
87
|
+
- On tenancy mismatch, `get` throws NOT_FOUND (returns null at the storage layer) and `delete` is a silent no-op — matching how a missing id already behaves, so existence does not leak through error timing or messages.
|
|
88
|
+
|
|
89
|
+
**Example**
|
|
90
|
+
|
|
91
|
+
```ts
|
|
92
|
+
// Before
|
|
93
|
+
const ds = await mastra.datasets.get({ id });
|
|
94
|
+
await mastra.datasets.delete({ id });
|
|
95
|
+
|
|
96
|
+
// After — scope to a tenant
|
|
97
|
+
const ds = await mastra.datasets.get({ id, organizationId, projectId });
|
|
98
|
+
await mastra.datasets.delete({ id, organizationId, projectId });
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
- 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))
|
|
102
|
+
|
|
103
|
+
```ts
|
|
104
|
+
await storage.saveScore({ ...score, organizationId: 'org-a', projectId: 'proj-1' });
|
|
105
|
+
|
|
106
|
+
const result = await storage.listScoresByScorerId({
|
|
107
|
+
scorerId,
|
|
108
|
+
filters: { organizationId: 'org-a', projectId: 'proj-1' },
|
|
109
|
+
});
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
`projectId` identifies the project scope, separate from `resourceId` which continues to mean the agent memory resource.
|
|
113
|
+
|
|
114
|
+
- Widened `SpannerStore` dataset initialization to backfill `targetType`, `targetIds`, and `scorerIds` on pre-existing `mastra_datasets` tables. The `createDataset` / `updateDataset` write paths and the new `listDatasets` `targetType` / `targetIds` filters reference these columns; deployments that upgraded in place before these columns were declared would otherwise hit column-not-found errors on both writes and the new filter path. ([#18710](https://github.com/mastra-ai/mastra/pull/18710))
|
|
115
|
+
|
|
116
|
+
Fresh databases were already unaffected because `createTable` reads the full `DATASETS_SCHEMA`.
|
|
117
|
+
|
|
118
|
+
- Raise `@mastra/core` peer floor to `>=1.49.0-0` on all storage adapters so the tenancy-related named exports the adapters now consume are guaranteed to exist at install time. ([#18861](https://github.com/mastra-ai/mastra/pull/18861))
|
|
119
|
+
|
|
120
|
+
- Scoped `getDatasetById` and `deleteDataset` to tenancy filters when the caller passes `organizationId` / `projectId`. ([#18750](https://github.com/mastra-ai/mastra/pull/18750))
|
|
121
|
+
|
|
122
|
+
The adapters now push the tenancy predicate into the SQL/query when the new optional `filters` argument is present. Legacy calls that omit tenancy are unchanged. On mismatch, `getDatasetById` returns `null` and `deleteDataset` is a silent no-op — the cascade delete (dataset items and versions) is gated by a scoped parent pre-check, so cross-tenant data is never touched.
|
|
123
|
+
|
|
124
|
+
- Added optional `organizationId` and `projectId` query parameters to the dataset routes. ([#18750](https://github.com/mastra-ai/mastra/pull/18750))
|
|
125
|
+
|
|
126
|
+
`GET /datasets/:datasetId`, `PATCH /datasets/:datasetId`, and `DELETE /datasets/:datasetId` now accept optional tenancy query parameters. When provided, they are forwarded to `mastra.datasets.get` / `.delete` and the operation returns 404 if the dataset does not belong to the requested tenant. Requests that omit the query parameters keep their existing behavior.
|
|
127
|
+
|
|
128
|
+
**Example**
|
|
129
|
+
|
|
130
|
+
```
|
|
131
|
+
GET /datasets/abc123?organizationId=org_a&projectId=proj_1
|
|
132
|
+
DELETE /datasets/abc123?organizationId=org_a
|
|
133
|
+
```
|
|
134
|
+
|
|
135
|
+
- 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)]:
|
|
136
|
+
- @mastra/core@1.49.0
|
|
137
|
+
|
|
3
138
|
## 1.2.2-alpha.1
|
|
4
139
|
|
|
5
140
|
### Patch Changes
|
package/dist/docs/SKILL.md
CHANGED
|
@@ -3,7 +3,7 @@ name: mastra-spanner
|
|
|
3
3
|
description: Documentation for @mastra/spanner. Use when working with @mastra/spanner APIs, configuration, or implementation.
|
|
4
4
|
metadata:
|
|
5
5
|
package: "@mastra/spanner"
|
|
6
|
-
version: "1.2.
|
|
6
|
+
version: "1.2.3-alpha.0"
|
|
7
7
|
---
|
|
8
8
|
|
|
9
9
|
## When to use
|
|
@@ -49,23 +49,23 @@ The instance and database must already exist. The adapter creates the required t
|
|
|
49
49
|
|
|
50
50
|
**id** (`string`): Unique identifier for this storage instance.
|
|
51
51
|
|
|
52
|
-
**projectId** (`string`): Google Cloud project ID. Required unless
|
|
52
|
+
**projectId** (`string`): Google Cloud project ID. Required unless database is provided.
|
|
53
53
|
|
|
54
|
-
**instanceId** (`string`): Cloud Spanner instance ID. Required unless
|
|
54
|
+
**instanceId** (`string`): Cloud Spanner instance ID. Required unless database is provided.
|
|
55
55
|
|
|
56
|
-
**databaseId** (`string`): Cloud Spanner database ID. Required unless
|
|
56
|
+
**databaseId** (`string`): Cloud Spanner database ID. Required unless database is provided.
|
|
57
57
|
|
|
58
58
|
**database** (`@google-cloud/spanner Database`): Pre-configured Spanner Database handle. Use this when you manage the Spanner client elsewhere (for example, to share auth or connection options across services).
|
|
59
59
|
|
|
60
|
-
**spannerOptions** (`object`): Options forwarded to the
|
|
60
|
+
**spannerOptions** (`object`): Options forwarded to the @google-cloud/spanner client constructor. Use this to set credentials, custom endpoints, or to point at the local emulator.
|
|
61
61
|
|
|
62
|
-
**disableInit** (`boolean`): When true, skip automatic table creation on first use. You must call
|
|
62
|
+
**disableInit** (`boolean`): When true, skip automatic table creation on first use. You must call storage.init() explicitly during a separate deploy step. (Default: `false`)
|
|
63
63
|
|
|
64
64
|
**skipDefaultIndexes** (`boolean`): When true, skip creation of default indexes during initialization. (Default: `false`)
|
|
65
65
|
|
|
66
66
|
**indexes** (`CreateIndexOptions[]`): Custom secondary indexes to create. Each index must specify the table it belongs to. Indexes are routed to the appropriate domain based on the table name.
|
|
67
67
|
|
|
68
|
-
**initMode** (`'sync' | 'validate'`): Controls schema-initialization behavior.
|
|
68
|
+
**initMode** (`'sync' | 'validate'`): Controls schema-initialization behavior. 'sync' creates missing tables, columns, and indexes during init() (the historical behavior). 'validate' issues no DDL and instead verifies that every expected table, column, and default/custom index already exists, throwing a typed user error if anything is missing — useful when an external process (Terraform, Liquibase, a release pipeline, etc.) owns the schema and Mastra should only verify it. (Default: `'sync'`)
|
|
69
69
|
|
|
70
70
|
## Constructor examples
|
|
71
71
|
|
package/dist/index.cjs
CHANGED
|
@@ -9591,7 +9591,7 @@ function rowToSchedule(row) {
|
|
|
9591
9591
|
}
|
|
9592
9592
|
const schedule = {
|
|
9593
9593
|
id: String(transformed.id),
|
|
9594
|
-
target,
|
|
9594
|
+
target: storage.normalizeScheduleTarget(target),
|
|
9595
9595
|
cron: String(transformed.cron),
|
|
9596
9596
|
status: String(transformed.status),
|
|
9597
9597
|
nextFireAt: Number(transformed.next_fire_at),
|