@mastra/mysql 0.13.0 → 0.13.1-alpha.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/dist/_types/@internal_core/dist/memory/index.d.ts +102 -0
- package/dist/_types/@internal_core/package.json +1 -0
- package/dist/docs/SKILL.md +1 -1
- package/dist/docs/assets/SOURCE_MAP.json +1 -1
- package/dist/index.cjs +1045 -449
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +1046 -450
- package/dist/index.js.map +1 -1
- package/dist/storage/db/run-fencing.d.ts +34 -0
- package/dist/storage/db/run-fencing.d.ts.map +1 -0
- package/dist/storage/domains/memory/index.d.ts +51 -5
- package/dist/storage/domains/memory/index.d.ts.map +1 -1
- package/dist/storage/domains/workflows/index.d.ts +16 -5
- package/dist/storage/domains/workflows/index.d.ts.map +1 -1
- package/package.json +5 -4
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import type { RunFence } from '@mastra/core/storage';
|
|
2
|
+
import type { Connection, Pool, PoolConnection } from 'mysql2/promise';
|
|
3
|
+
/** The query method both the pool and a pooled connection offer. */
|
|
4
|
+
export type Queryable = Pick<Connection, 'execute'>;
|
|
5
|
+
/**
|
|
6
|
+
* Epoch milliseconds on the database clock. `UTC_TIMESTAMP` is the time the
|
|
7
|
+
* statement started and doesn't depend on the session time zone. Every lease
|
|
8
|
+
* comparison runs in a statement that already holds the run's owner row, so
|
|
9
|
+
* no lock wait sits between that start time and the comparison.
|
|
10
|
+
*/
|
|
11
|
+
export declare const DB_NOW_MS = "(TIMESTAMPDIFF(MICROSECOND, '1970-01-01 00:00:00', UTC_TIMESTAMP(3)) DIV 1000)";
|
|
12
|
+
/**
|
|
13
|
+
* The check half of a fenced write; call it first inside the write's
|
|
14
|
+
* transaction. The shared lock holds the claim row until commit, so a claim
|
|
15
|
+
* that updates the row waits for the write to finish, and every later write
|
|
16
|
+
* sees the new claim.
|
|
17
|
+
*/
|
|
18
|
+
export declare function assertRunFence(q: Queryable, claimsTable: string, fence: RunFence, operation: string): Promise<void>;
|
|
19
|
+
/** Runs `fn` in a transaction on its own pooled connection. */
|
|
20
|
+
export declare function inTransaction<T>(pool: Pool, fn: (connection: PoolConnection) => Promise<T>): Promise<T>;
|
|
21
|
+
/**
|
|
22
|
+
* Runs `write` directly when it carries no fence, or in a transaction behind
|
|
23
|
+
* the fence check when it does.
|
|
24
|
+
*/
|
|
25
|
+
export declare function withRunFence<T>(pool: Pool, claimsTable: string, fence: RunFence | undefined, operation: string, write: (q: Queryable) => Promise<T>): Promise<T>;
|
|
26
|
+
/**
|
|
27
|
+
* Runs a transaction that creates or updates a run's claim row, retrying when
|
|
28
|
+
* two first claims race to insert it. Under REPEATABLE READ both lock the gap
|
|
29
|
+
* where the row would go and one is chosen as a deadlock victim; under READ
|
|
30
|
+
* COMMITTED the later insert hits the duplicate key. On retry the row exists
|
|
31
|
+
* and the claim serializes behind its row lock.
|
|
32
|
+
*/
|
|
33
|
+
export declare function claimTransaction<T>(pool: Pool, fn: (connection: PoolConnection) => Promise<T>): Promise<T>;
|
|
34
|
+
//# sourceMappingURL=run-fencing.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"run-fencing.d.ts","sourceRoot":"","sources":["../../../src/storage/db/run-fencing.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAErD,OAAO,KAAK,EAAE,UAAU,EAAE,IAAI,EAAE,cAAc,EAAiB,MAAM,gBAAgB,CAAC;AAGtF,oEAAoE;AACpE,MAAM,MAAM,SAAS,GAAG,IAAI,CAAC,UAAU,EAAE,SAAS,CAAC,CAAC;AAEpD;;;;;GAKG;AACH,eAAO,MAAM,SAAS,mFAAmF,CAAC;AAM1G;;;;;GAKG;AACH,wBAAsB,cAAc,CAClC,CAAC,EAAE,SAAS,EACZ,WAAW,EAAE,MAAM,EACnB,KAAK,EAAE,QAAQ,EACf,SAAS,EAAE,MAAM,GAChB,OAAO,CAAC,IAAI,CAAC,CAWf;AAED,+DAA+D;AAC/D,wBAAsB,aAAa,CAAC,CAAC,EAAE,IAAI,EAAE,IAAI,EAAE,EAAE,EAAE,CAAC,UAAU,EAAE,cAAc,KAAK,OAAO,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,CAa7G;AAED;;;GAGG;AACH,wBAAgB,YAAY,CAAC,CAAC,EAC5B,IAAI,EAAE,IAAI,EACV,WAAW,EAAE,MAAM,EACnB,KAAK,EAAE,QAAQ,GAAG,SAAS,EAC3B,SAAS,EAAE,MAAM,EACjB,KAAK,EAAE,CAAC,CAAC,EAAE,SAAS,KAAK,OAAO,CAAC,CAAC,CAAC,GAClC,OAAO,CAAC,CAAC,CAAC,CAMZ;AAED;;;;;;GAMG;AACH,wBAAsB,gBAAgB,CAAC,CAAC,EAAE,IAAI,EAAE,IAAI,EAAE,EAAE,EAAE,CAAC,UAAU,EAAE,cAAc,KAAK,OAAO,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,CAShH"}
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
+
import { type UpdateActiveObservationsResult, type UpdateBufferedObservationsResult } from '../../../_types/@internal_core/dist/memory/index.js';
|
|
1
2
|
import type { MastraDBMessage, MastraMessageContentV2 } from '@mastra/core/agent';
|
|
2
3
|
import type { StorageThreadType } from '@mastra/core/memory';
|
|
3
4
|
import { MemoryStorage } from '@mastra/core/storage';
|
|
4
|
-
import type { CreateIndexOptions, CreateObservationalMemoryInput, CreateReflectionGenerationInput, ObservationalMemoryHistoryOptions, ObservationalMemoryRecord, PaginationArgs, PaginationInfo, StorageCloneThreadInput, StorageCloneThreadOutput, StorageListMessagesByResourceIdInput, StorageListMessagesInput, StorageListMessagesOutput, StorageListThreadsInput, StorageListThreadsOutput, StorageResourceType, SwapBufferedReflectionToActiveInput, SwapBufferedToActiveInput, SwapBufferedToActiveResult, ThreadSortOptions, UpdateActiveObservationsInput, UpdateBufferedObservationsInput, UpdateBufferedReflectionInput } from '@mastra/core/storage';
|
|
5
|
+
import type { CreateIndexOptions, CreateObservationalMemoryInput, CreateReflectionGenerationInput, ObservationalMemoryHistoryOptions, ObservationalMemoryRecord, PaginationArgs, PaginationInfo, RunFence, StorageCloneThreadInput, StorageCloneThreadOutput, StorageListMessagesByResourceIdInput, StorageListMessagesInput, StorageListMessagesOutput, StorageListThreadsInput, StorageListThreadsOutput, StorageResourceType, SwapBufferedReflectionToActiveInput, SwapBufferedToActiveInput, SwapBufferedToActiveResult, ThreadSortOptions, UpdateActiveObservationsInput, UpdateBufferedObservationsInput, UpdateBufferedReflectionInput } from '@mastra/core/storage';
|
|
5
6
|
import type { Pool } from 'mysql2/promise';
|
|
6
7
|
import type { StoreOperationsMySQL } from '../operations/index.js';
|
|
7
8
|
export declare class MemoryMySQL extends MemoryStorage {
|
|
@@ -18,6 +19,9 @@ export declare class MemoryMySQL extends MemoryStorage {
|
|
|
18
19
|
skipDefaultIndexes?: boolean;
|
|
19
20
|
indexes?: CreateIndexOptions[];
|
|
20
21
|
});
|
|
22
|
+
supportsRunFencing(): boolean;
|
|
23
|
+
raiseRunFence(fence: RunFence): Promise<boolean>;
|
|
24
|
+
retireRunFence(fence: RunFence): Promise<boolean>;
|
|
21
25
|
init(): Promise<void>;
|
|
22
26
|
static getDefaultIndexDefs(prefix?: string): CreateIndexOptions[];
|
|
23
27
|
static getExportDDL(): string[];
|
|
@@ -82,13 +86,15 @@ export declare class MemoryMySQL extends MemoryStorage {
|
|
|
82
86
|
} & PaginationArgs & ThreadSortOptions): Promise<PaginationInfo & {
|
|
83
87
|
threads: StorageThreadType[];
|
|
84
88
|
}>;
|
|
85
|
-
saveThread({ thread }: {
|
|
89
|
+
saveThread({ thread, fence }: {
|
|
86
90
|
thread: StorageThreadType;
|
|
91
|
+
fence?: RunFence;
|
|
87
92
|
}): Promise<StorageThreadType>;
|
|
88
|
-
updateThread({ id, title, metadata, }: {
|
|
93
|
+
updateThread({ id, title, metadata, fence, }: {
|
|
89
94
|
id: string;
|
|
90
95
|
title?: string;
|
|
91
96
|
metadata?: Record<string, unknown>;
|
|
97
|
+
fence?: RunFence;
|
|
92
98
|
}): Promise<StorageThreadType>;
|
|
93
99
|
deleteThread({ threadId }: {
|
|
94
100
|
threadId: string;
|
|
@@ -100,6 +106,7 @@ export declare class MemoryMySQL extends MemoryStorage {
|
|
|
100
106
|
}>;
|
|
101
107
|
saveMessages(args: {
|
|
102
108
|
messages: MastraDBMessage[];
|
|
109
|
+
fence?: RunFence;
|
|
103
110
|
}): Promise<{
|
|
104
111
|
messages: MastraDBMessage[];
|
|
105
112
|
}>;
|
|
@@ -108,8 +115,11 @@ export declare class MemoryMySQL extends MemoryStorage {
|
|
|
108
115
|
id: string;
|
|
109
116
|
content?: Partial<MastraMessageContentV2>;
|
|
110
117
|
})[];
|
|
118
|
+
fence?: RunFence;
|
|
111
119
|
}): Promise<MastraDBMessage[]>;
|
|
112
|
-
deleteMessages(messageIds: string[]
|
|
120
|
+
deleteMessages(messageIds: string[], options?: {
|
|
121
|
+
fence?: RunFence;
|
|
122
|
+
}): Promise<void>;
|
|
113
123
|
cloneThread(args: StorageCloneThreadInput): Promise<StorageCloneThreadOutput>;
|
|
114
124
|
listMessages(args: StorageListMessagesInput): Promise<StorageListMessagesOutput>;
|
|
115
125
|
listMessagesByResourceId(args: StorageListMessagesByResourceIdInput): Promise<StorageListMessagesOutput>;
|
|
@@ -119,15 +129,17 @@ export declare class MemoryMySQL extends MemoryStorage {
|
|
|
119
129
|
saveResource({ resource }: {
|
|
120
130
|
resource: StorageResourceType;
|
|
121
131
|
}): Promise<StorageResourceType>;
|
|
122
|
-
updateResource({ resourceId, workingMemory, metadata, }: {
|
|
132
|
+
updateResource({ resourceId, workingMemory, metadata, fence, }: {
|
|
123
133
|
resourceId: string;
|
|
124
134
|
workingMemory?: string;
|
|
125
135
|
metadata?: Record<string, unknown>;
|
|
136
|
+
fence?: RunFence;
|
|
126
137
|
}): Promise<StorageResourceType>;
|
|
127
138
|
getObservationalMemory(threadId: string | null, resourceId: string): Promise<ObservationalMemoryRecord | null>;
|
|
128
139
|
getObservationalMemoryHistory(threadId: string | null, resourceId: string, limit?: number, options?: ObservationalMemoryHistoryOptions): Promise<ObservationalMemoryRecord[]>;
|
|
129
140
|
initializeObservationalMemory(input: CreateObservationalMemoryInput): Promise<ObservationalMemoryRecord>;
|
|
130
141
|
updateActiveObservations(input: UpdateActiveObservationsInput): Promise<void>;
|
|
142
|
+
commitActiveObservations(input: UpdateActiveObservationsInput): Promise<UpdateActiveObservationsResult>;
|
|
131
143
|
createReflectionGeneration(input: CreateReflectionGenerationInput): Promise<ObservationalMemoryRecord>;
|
|
132
144
|
setReflectingFlag(id: string, isReflecting: boolean): Promise<void>;
|
|
133
145
|
setObservingFlag(id: string, isObserving: boolean): Promise<void>;
|
|
@@ -136,9 +148,43 @@ export declare class MemoryMySQL extends MemoryStorage {
|
|
|
136
148
|
clearObservationalMemory(threadId: string | null, resourceId: string): Promise<void>;
|
|
137
149
|
setPendingMessageTokens(id: string, tokenCount: number): Promise<void>;
|
|
138
150
|
updateBufferedObservations(input: UpdateBufferedObservationsInput): Promise<void>;
|
|
151
|
+
appendBufferedObservations(input: UpdateBufferedObservationsInput): Promise<UpdateBufferedObservationsResult>;
|
|
139
152
|
swapBufferedToActive(input: SwapBufferedToActiveInput): Promise<SwapBufferedToActiveResult>;
|
|
140
153
|
updateBufferedReflection(input: UpdateBufferedReflectionInput): Promise<void>;
|
|
141
154
|
swapBufferedReflectionToActive(input: SwapBufferedReflectionToActiveInput): Promise<ObservationalMemoryRecord>;
|
|
155
|
+
/**
|
|
156
|
+
* Runs `fn` in one transaction on a dedicated connection. Every OM lifecycle write locks its
|
|
157
|
+
* target row by primary key (`SELECT … FOR UPDATE`, a record lock — never a range), so the
|
|
158
|
+
* only expected lock conflict is a wait; a deadlock or lock-wait timeout (e.g. against the
|
|
159
|
+
* startup backfill's scan) is retried a bounded number of times.
|
|
160
|
+
*/
|
|
161
|
+
private withOMTransaction;
|
|
162
|
+
/** Row-locks one OM record by primary key for the rest of the transaction. */
|
|
163
|
+
private lockOMRow;
|
|
164
|
+
/**
|
|
165
|
+
* The live, row-locked record a lifecycle write aimed at `row` lands on: `row` itself while
|
|
166
|
+
* live, otherwise the head. The head is found with a plain (non-locking, so no range locks)
|
|
167
|
+
* canonical head read, then locked by primary key. Under REPEATABLE READ that read can predate
|
|
168
|
+
* a rollover committed after this transaction started; the locking read sees the latest
|
|
169
|
+
* committed row, so a head retired since is followed through `supersededBy` (bounded).
|
|
170
|
+
*/
|
|
171
|
+
private resolveLiveOMRow;
|
|
172
|
+
/**
|
|
173
|
+
* Create the next generation from the stored (live, row-locked) record and retire the stored
|
|
174
|
+
* record in the same transaction. Carried columns are copied in SQL from the stored row, so
|
|
175
|
+
* nothing round-trips through a client-side date conversion. Buffered chunks move to the new
|
|
176
|
+
* generation; the cursor, buffering markers, flags, and counters carry over; buffered
|
|
177
|
+
* reflection state does not (and is cleared on the retired row after a buffered swap).
|
|
178
|
+
*/
|
|
179
|
+
private rollOverOMRow;
|
|
180
|
+
/**
|
|
181
|
+
* Retire every live row that sorts after its key's canonical head, marking it superseded by
|
|
182
|
+
* the head. Rows retired by older adapter versions (which never set `supersededBy`) become
|
|
183
|
+
* frozen. Only keys with more than one live row are touched; each update embeds the head's
|
|
184
|
+
* ordering key, so a row created by a concurrent rollover (a newer generation) never matches.
|
|
185
|
+
* Runs at READ COMMITTED so the scan takes no gap locks.
|
|
186
|
+
*/
|
|
187
|
+
private backfillSupersededBy;
|
|
142
188
|
private updateOMFlag;
|
|
143
189
|
private getOMKey;
|
|
144
190
|
private parseOMRow;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/storage/domains/memory/index.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,eAAe,EAAE,sBAAsB,EAAE,MAAM,oBAAoB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AG,IAAI,EAAE,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAOzF;IAEK,uBAAuB,CAAC,EAAE,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAkB3E;IAEK,0BAA0B,CAAC,KAAK,EAAE,+BAA+B,GAAG,OAAO,CAAC,IAAI,CAAC,CAEtF;IAEK,0BAA0B,CAAC,KAAK,EAAE,+BAA+B,GAAG,OAAO,CAAC,gCAAgC,CAAC,CAwDlH;IAEK,oBAAoB,CAAC,KAAK,EAAE,yBAAyB,GAAG,OAAO,CAAC,0BAA0B,CAAC,CA0JhG;IAEK,wBAAwB,CAAC,KAAK,EAAE,6BAA6B,GAAG,OAAO,CAAC,IAAI,CAAC,CAoClF;IAEK,8BAA8B,CAAC,KAAK,EAAE,mCAAmC,GAAG,OAAO,CAAC,yBAAyB,CAAC,CA+CnH;IAED;;;;;OAKG;YACW,iBAAiB;IAsB/B,8EAA8E;YAChE,SAAS;IAQvB;;;;;;OAMG;YACW,gBAAgB;IAwB9B;;;;;;OAMG;YACW,aAAa;IA+D3B;;;;;;OAMG;YACW,oBAAoB;YAwCpB,YAAY;IAe1B,OAAO,CAAC,QAAQ;IAIhB,OAAO,CAAC,UAAU;CA2CnB"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { WorkflowsStorage } from '@mastra/core/storage';
|
|
2
|
-
import type { CreateIndexOptions, StorageListWorkflowRunsInput, UpdateWorkflowStateOptions, WorkflowRun, WorkflowRuns } from '@mastra/core/storage';
|
|
2
|
+
import type { ClaimRunOwnershipInput, ClaimRunOwnershipResult, CreateIndexOptions, RenewRunOwnershipInput, RenewRunOwnershipResult, RunFence, RunOwnershipRecord, StorageListWorkflowRunsInput, UpdateWorkflowStateOptions, WorkflowRun, WorkflowRuns } from '@mastra/core/storage';
|
|
3
3
|
import type { StepResult, WorkflowRunState } from '@mastra/core/workflows';
|
|
4
4
|
import type { Pool } from 'mysql2/promise';
|
|
5
5
|
import type { StoreOperationsMySQL } from '../operations/index.js';
|
|
@@ -40,30 +40,41 @@ export declare class WorkflowsMySQL extends WorkflowsStorage {
|
|
|
40
40
|
createCustomIndexes(): Promise<void>;
|
|
41
41
|
init(): Promise<void>;
|
|
42
42
|
dangerouslyClearAll(): Promise<void>;
|
|
43
|
-
|
|
43
|
+
supportsRunFencing(): boolean;
|
|
44
|
+
claimRunOwnership({ runId, ownerId, leaseMs, force, expectedGeneration, }: ClaimRunOwnershipInput): Promise<ClaimRunOwnershipResult>;
|
|
45
|
+
renewRunOwnership({ leaseMs, ...fence }: RenewRunOwnershipInput): Promise<RenewRunOwnershipResult>;
|
|
46
|
+
releaseRunOwnership(fence: RunFence): Promise<boolean>;
|
|
47
|
+
getRunOwnership({ runId }: {
|
|
48
|
+
runId: string;
|
|
49
|
+
}): Promise<RunOwnershipRecord | null>;
|
|
50
|
+
deleteWorkflowRunById({ runId, workflowName, fence, }: {
|
|
44
51
|
runId: string;
|
|
45
52
|
workflowName: string;
|
|
53
|
+
fence?: RunFence;
|
|
46
54
|
}): Promise<void>;
|
|
47
|
-
updateWorkflowResults({ workflowName, runId, stepId, result, requestContext, state, }: {
|
|
55
|
+
updateWorkflowResults({ workflowName, runId, stepId, result, requestContext, state, fence: explicitFence, }: {
|
|
48
56
|
workflowName: string;
|
|
49
57
|
runId: string;
|
|
50
58
|
stepId: string;
|
|
51
59
|
result: StepResult<any, any, any, any>;
|
|
52
60
|
requestContext?: Record<string, any>;
|
|
53
61
|
state?: Record<string, any>;
|
|
62
|
+
fence?: RunFence;
|
|
54
63
|
}): Promise<Record<string, StepResult<any, any, any, any>>>;
|
|
55
|
-
updateWorkflowState({ workflowName, runId, opts, }: {
|
|
64
|
+
updateWorkflowState({ workflowName, runId, opts, fence: explicitFence, }: {
|
|
56
65
|
workflowName: string;
|
|
57
66
|
runId: string;
|
|
58
67
|
opts: UpdateWorkflowStateOptions;
|
|
68
|
+
fence?: RunFence;
|
|
59
69
|
}): Promise<WorkflowRunState | undefined>;
|
|
60
|
-
persistWorkflowSnapshot({ workflowName, runId, resourceId, snapshot, createdAt, updatedAt, }: {
|
|
70
|
+
persistWorkflowSnapshot({ workflowName, runId, resourceId, snapshot, createdAt, updatedAt, fence, }: {
|
|
61
71
|
workflowName: string;
|
|
62
72
|
runId: string;
|
|
63
73
|
resourceId?: string;
|
|
64
74
|
snapshot: WorkflowRunState;
|
|
65
75
|
createdAt?: Date;
|
|
66
76
|
updatedAt?: Date;
|
|
77
|
+
fence?: RunFence;
|
|
67
78
|
}): Promise<void>;
|
|
68
79
|
loadWorkflowSnapshot({ workflowName, runId, }: {
|
|
69
80
|
workflowName: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/storage/domains/workflows/index.ts"],"names":[],"mappings":"AACA,OAAO,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/storage/domains/workflows/index.ts"],"names":[],"mappings":"AACA,OAAO,EAKL,gBAAgB,EAOjB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,KAAK,EACV,sBAAsB,EACtB,uBAAuB,EACvB,kBAAkB,EAClB,sBAAsB,EACtB,uBAAuB,EACvB,QAAQ,EACR,kBAAkB,EAClB,4BAA4B,EAE5B,0BAA0B,EAC1B,WAAW,EACX,YAAY,EACb,MAAM,sBAAsB,CAAC;AAC9B,OAAO,KAAK,EAAE,UAAU,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAC3E,OAAO,KAAK,EAAE,IAAI,EAAkC,MAAM,gBAAgB,CAAC;AAG3E,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,eAAe,CAAC;AA6D1D,qBAAa,cAAe,SAAQ,gBAAgB;;IAClD,OAAO,CAAC,UAAU,CAAuB;IACzC,OAAO,CAAC,IAAI,CAAO;IAInB,oCAAoC;IACpC,MAAM,CAAC,QAAQ,CAAC,cAAc,wCA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,CAAC;QACpB,QAAQ,EAAE,gBAAgB,CAAC;QAC3B,SAAS,CAAC,EAAE,IAAI,CAAC;QACjB,SAAS,CAAC,EAAE,IAAI,CAAC;QACjB,KAAK,CAAC,EAAE,QAAQ,CAAC;KAClB,GAAG,OAAO,CAAC,IAAI,CAAC,CAoDhB;IAEK,oBAAoB,CAAC,EACzB,YAAY,EACZ,KAAK,GACN,EAAE;QACD,YAAY,EAAE,MAAM,CAAC;QACrB,KAAK,EAAE,MAAM,CAAC;KACf,GAAG,OAAO,CAAC,gBAAgB,GAAG,IAAI,CAAC,CAkBnC;IAEK,gBAAgB,CAAC,IAAI,GAAE,4BAAiC,GAAG,OAAO,CAAC,YAAY,CAAC,CA2ErF;IAEK,eAAe,CAAC,IAAI,GAAE,4BAAiC,GAAG,OAAO,CAAC,YAAY,CAAC,CAEpF;IAEK,kBAAkB,CAAC,EACvB,KAAK,EACL,YAAY,GACb,EAAE;QACD,KAAK,EAAE,MAAM,CAAC;QACd,YAAY,CAAC,EAAE,MAAM,CAAC;KACvB,GAAG,OAAO,CAAC,WAAW,GAAG,IAAI,CAAC,CAwB9B;CACF"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mastra/mysql",
|
|
3
|
-
"version": "0.13.
|
|
3
|
+
"version": "0.13.1-alpha.1",
|
|
4
4
|
"description": "MySQL provider for Mastra - db storage capabilities",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -32,12 +32,13 @@
|
|
|
32
32
|
"typescript": "^7.0.2",
|
|
33
33
|
"vitest": "4.1.11",
|
|
34
34
|
"@internal/lint": "0.0.142",
|
|
35
|
+
"@internal/core": "0.1.2",
|
|
35
36
|
"@internal/storage-test-utils": "0.0.138",
|
|
36
|
-
"@
|
|
37
|
-
"@
|
|
37
|
+
"@internal/types-builder": "0.0.117",
|
|
38
|
+
"@mastra/core": "1.77.0-alpha.4"
|
|
38
39
|
},
|
|
39
40
|
"peerDependencies": {
|
|
40
|
-
"@mastra/core": ">=1.
|
|
41
|
+
"@mastra/core": ">=1.76.0-0 <2.0.0-0"
|
|
41
42
|
},
|
|
42
43
|
"files": [
|
|
43
44
|
"dist"
|