@mastra/cloudflare-d1 0.0.0-vnext-inngest-20250508131921 → 0.0.0-vnext-20251119160359

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.
@@ -0,0 +1,60 @@
1
+ import type { ScoreRowData, ScoringSource } from '@mastra/core/evals';
2
+ import { ScoresStorage } from '@mastra/core/storage';
3
+ import type { StoragePagination, PaginationInfo } from '@mastra/core/storage';
4
+ import type Cloudflare from 'cloudflare';
5
+ import type { StoreOperationsD1 } from '../operations/index.js';
6
+ export type D1QueryResult = Awaited<ReturnType<Cloudflare['d1']['database']['query']>>['result'];
7
+ export interface D1Client {
8
+ query(args: {
9
+ sql: string;
10
+ params: string[];
11
+ }): Promise<{
12
+ result: D1QueryResult;
13
+ }>;
14
+ }
15
+ export declare class ScoresStorageD1 extends ScoresStorage {
16
+ private operations;
17
+ constructor({ operations }: {
18
+ operations: StoreOperationsD1;
19
+ });
20
+ getScoreById({ id }: {
21
+ id: string;
22
+ }): Promise<ScoreRowData | null>;
23
+ saveScore(score: Omit<ScoreRowData, 'createdAt' | 'updatedAt'>): Promise<{
24
+ score: ScoreRowData;
25
+ }>;
26
+ listScoresByScorerId({ scorerId, entityId, entityType, source, pagination, }: {
27
+ scorerId: string;
28
+ entityId?: string;
29
+ entityType?: string;
30
+ source?: ScoringSource;
31
+ pagination: StoragePagination;
32
+ }): Promise<{
33
+ pagination: PaginationInfo;
34
+ scores: ScoreRowData[];
35
+ }>;
36
+ listScoresByRunId({ runId, pagination, }: {
37
+ runId: string;
38
+ pagination: StoragePagination;
39
+ }): Promise<{
40
+ pagination: PaginationInfo;
41
+ scores: ScoreRowData[];
42
+ }>;
43
+ listScoresByEntityId({ entityId, entityType, pagination, }: {
44
+ pagination: StoragePagination;
45
+ entityId: string;
46
+ entityType: string;
47
+ }): Promise<{
48
+ pagination: PaginationInfo;
49
+ scores: ScoreRowData[];
50
+ }>;
51
+ listScoresBySpan({ traceId, spanId, pagination, }: {
52
+ traceId: string;
53
+ spanId: string;
54
+ pagination: StoragePagination;
55
+ }): Promise<{
56
+ pagination: PaginationInfo;
57
+ scores: ScoreRowData[];
58
+ }>;
59
+ }
60
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/storage/domains/scores/index.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,YAAY,EAAE,aAAa,EAA6B,MAAM,oBAAoB,CAAC;AAEjG,OAAO,EACL,aAAa,EAKd,MAAM,sBAAsB,CAAC;AAC9B,OAAO,KAAK,EAAE,iBAAiB,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAC9E,OAAO,KAAK,UAAU,MAAM,YAAY,CAAC;AAEzC,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAC;AAEvD,MAAM,MAAM,aAAa,GAAG,OAAO,CAAC,UAAU,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC,UAAU,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC;AAEjG,MAAM,WAAW,QAAQ;IACvB,KAAK,CAAC,IAAI,EAAE;QAAE,GAAG,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,EAAE,CAAA;KAAE,GAAG,OAAO,CAAC;QAAE,MAAM,EAAE,aAAa,CAAA;KAAE,CAAC,CAAC;CACpF;AAsBD,qBAAa,eAAgB,SAAQ,aAAa;IAChD,OAAO,CAAC,UAAU,CAAoB;gBAE1B,EAAE,UAAU,EAAE,EAAE;QAAE,UAAU,EAAE,iBAAiB,CAAA;KAAE;IAKvD,YAAY,CAAC,EAAE,EAAE,EAAE,EAAE;QAAE,EAAE,EAAE,MAAM,CAAA;KAAE,GAAG,OAAO,CAAC,YAAY,GAAG,IAAI,CAAC;IAyBlE,SAAS,CAAC,KAAK,EAAE,IAAI,CAAC,YAAY,EAAE,WAAW,GAAG,WAAW,CAAC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is Record<string, any>[];
2
+ export declare function deserializeValue(value: any, type?: string): any;
3
+ //# sourceMappingURL=utils.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../src/storage/domains/utils.ts"],"names":[],"mappings":"AAAA,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,GAAG,GAAG,KAAK,IAAI,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EAAE,CAE3E;AAED,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,GAAG,EAAE,IAAI,CAAC,EAAE,MAAM,GAAG,GAAG,CAwB/D"}
@@ -0,0 +1,45 @@
1
+ import type { WorkflowRun, WorkflowRuns, StorageListWorkflowRunsInput } from '@mastra/core/storage';
2
+ import { WorkflowsStorage } from '@mastra/core/storage';
3
+ import type { StepResult, WorkflowRunState } from '@mastra/core/workflows';
4
+ import type { StoreOperationsD1 } from '../operations/index.js';
5
+ export declare class WorkflowsStorageD1 extends WorkflowsStorage {
6
+ private operations;
7
+ constructor({ operations }: {
8
+ operations: StoreOperationsD1;
9
+ });
10
+ updateWorkflowResults({}: {
11
+ workflowName: string;
12
+ runId: string;
13
+ stepId: string;
14
+ result: StepResult<any, any, any, any>;
15
+ requestContext: Record<string, any>;
16
+ }): Promise<Record<string, StepResult<any, any, any, any>>>;
17
+ updateWorkflowState({}: {
18
+ workflowName: string;
19
+ runId: string;
20
+ opts: {
21
+ status: string;
22
+ result?: StepResult<any, any, any, any>;
23
+ error?: string;
24
+ suspendedPaths?: Record<string, number[]>;
25
+ waitingPaths?: Record<string, number[]>;
26
+ };
27
+ }): Promise<WorkflowRunState | undefined>;
28
+ persistWorkflowSnapshot({ workflowName, runId, resourceId, snapshot, }: {
29
+ workflowName: string;
30
+ runId: string;
31
+ resourceId?: string;
32
+ snapshot: WorkflowRunState;
33
+ }): Promise<void>;
34
+ loadWorkflowSnapshot(params: {
35
+ workflowName: string;
36
+ runId: string;
37
+ }): Promise<WorkflowRunState | null>;
38
+ private parseWorkflowRun;
39
+ listWorkflowRuns({ workflowName, fromDate, toDate, page, perPage, resourceId, status, }?: StorageListWorkflowRunsInput): Promise<WorkflowRuns>;
40
+ getWorkflowRunById({ runId, workflowName, }: {
41
+ runId: string;
42
+ workflowName?: string;
43
+ }): Promise<WorkflowRun | null>;
44
+ }
45
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/storage/domains/workflows/index.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,WAAW,EAAE,YAAY,EAAE,4BAA4B,EAAE,MAAM,sBAAsB,CAAC;AACpG,OAAO,EAAuC,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AAC7F,OAAO,KAAK,EAAE,UAAU,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAG3E,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAC;AAGvD,qBAAa,kBAAmB,SAAQ,gBAAgB;IACtD,OAAO,CAAC,UAAU,CAAoB;gBAE1B,EAAE,UAAU,EAAE,EAAE;QAAE,UAAU,EAAE,iBAAiB,CAAA;KAAE;IAK7D,qBAAqB,CACnB,EAMC,EAAE;QACD,YAAY,EAAE,MAAM,CAAC;QACrB,KAAK,EAAE,MAAM,CAAC;QACd,MAAM,EAAE,MAAM,CAAC;QACf,MAAM,EAAE,UAAU,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC,CAAC;QACvC,cAAc,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;KACrC,GACA,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,UAAU,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC,CAAC,CAAC;IAG1D,mBAAmB,CACjB,EAIC,EAAE;QACD,YAAY,EAAE,MAAM,CAAC;QACrB,KAAK,EAAE,MAAM,CAAC;QACd,IAAI,EAAE;YACJ,MAAM,EAAE,MAAM,CAAC;YACf,MAAM,CAAC,EAAE,UAAU,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC,CAAC;YACxC,KAAK,CAAC,EAAE,MAAM,CAAC;YACf,cAAc,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,CAAC,CAAC;YAC1C,YAAY,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,CAAC,CAAC;SACzC,CAAC;KACH,GACA,OAAO,CAAC,gBAAgB,GAAG,SAAS,CAAC;IAIlC,uBAAuB,CAAC,EAC5B,YAAY,EACZ,KAAK,EACL,UAAU,EACV,QAAQ,GACT,EAAE;QACD,YAAY,EAAE,MAAM,CAAC;QACrB,KAAK,EAAE,MAAM,CAAC;QACd,UAAU,CAAC,EAAE,MAAM,CAAC;QACpB,QAAQ,EAAE,gBAAgB,CAAC;KAC5B,GAAG,OAAO,CAAC,IAAI,CAAC;IA4DX,oBAAoB,CAAC,MAAM,EAAE;QAAE,YAAY,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAE,GAAG,OAAO,CAAC,gBAAgB,GAAG,IAAI,CAAC;IA6B7G,OAAO,CAAC,gBAAgB;IAqBlB,gBAAgB,CAAC,EACrB,YAAY,EACZ,QAAQ,EACR,MAAM,EACN,IAAI,EACJ,OAAO,EACP,UAAU,EACV,MAAM,GACP,GAAE,4BAAiC,GAAG,OAAO,CAAC,YAAY,CAAC;IAsEtD,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;CA+BhC"}
@@ -0,0 +1,230 @@
1
+ import type { D1Database } from '@cloudflare/workers-types';
2
+ import type { MastraMessageContentV2 } from '@mastra/core/agent';
3
+ import type { ScoreRowData, ScoringSource } from '@mastra/core/evals';
4
+ import type { StorageThreadType, MastraDBMessage } from '@mastra/core/memory';
5
+ import { MastraStorage } from '@mastra/core/storage';
6
+ import type { PaginationInfo, StorageColumn, StorageResourceType, TABLE_NAMES, WorkflowRun, StoragePagination, WorkflowRuns, StorageDomains, StorageListWorkflowRunsInput } from '@mastra/core/storage';
7
+ import type { StepResult, WorkflowRunState } from '@mastra/core/workflows';
8
+ import Cloudflare from 'cloudflare';
9
+ /**
10
+ * Configuration for D1 using the REST API
11
+ */
12
+ export interface D1Config {
13
+ /** Storage instance ID */
14
+ id: string;
15
+ /** Cloudflare account ID */
16
+ accountId: string;
17
+ /** Cloudflare API token with D1 access */
18
+ apiToken: string;
19
+ /** D1 database ID */
20
+ databaseId: string;
21
+ /** Optional prefix for table names */
22
+ tablePrefix?: string;
23
+ }
24
+ export interface D1ClientConfig {
25
+ /** Storage instance ID */
26
+ id: string;
27
+ /** Optional prefix for table names */
28
+ tablePrefix?: string;
29
+ /** D1 Client */
30
+ client: D1Client;
31
+ }
32
+ /**
33
+ * Configuration for D1 using the Workers Binding API
34
+ */
35
+ export interface D1WorkersConfig {
36
+ /** Storage instance ID */
37
+ id: string;
38
+ /** D1 database binding from Workers environment */
39
+ binding: D1Database;
40
+ /** Optional prefix for table names */
41
+ tablePrefix?: string;
42
+ }
43
+ /**
44
+ * Combined configuration type supporting both REST API and Workers Binding API
45
+ */
46
+ export type D1StoreConfig = D1Config | D1WorkersConfig | D1ClientConfig;
47
+ export type D1QueryResult = Awaited<ReturnType<Cloudflare['d1']['database']['query']>>['result'];
48
+ export interface D1Client {
49
+ query(args: {
50
+ sql: string;
51
+ params: string[];
52
+ }): Promise<{
53
+ result: D1QueryResult;
54
+ }>;
55
+ }
56
+ export declare class D1Store extends MastraStorage {
57
+ private client?;
58
+ private binding?;
59
+ private tablePrefix;
60
+ stores: StorageDomains;
61
+ /**
62
+ * Creates a new D1Store instance
63
+ * @param config Configuration for D1 access (either REST API or Workers Binding API)
64
+ */
65
+ constructor(config: D1StoreConfig);
66
+ get supports(): {
67
+ selectByIncludeResourceScope: boolean;
68
+ resourceWorkingMemory: boolean;
69
+ hasColumn: boolean;
70
+ createTable: boolean;
71
+ deleteMessages: boolean;
72
+ listScoresBySpan: boolean;
73
+ };
74
+ createTable({ tableName, schema, }: {
75
+ tableName: TABLE_NAMES;
76
+ schema: Record<string, StorageColumn>;
77
+ }): Promise<void>;
78
+ /**
79
+ * Alters table schema to add columns if they don't exist
80
+ * @param tableName Name of the table
81
+ * @param schema Schema of the table
82
+ * @param ifNotExists Array of column names to add if they don't exist
83
+ */
84
+ alterTable({ tableName, schema, ifNotExists, }: {
85
+ tableName: TABLE_NAMES;
86
+ schema: Record<string, StorageColumn>;
87
+ ifNotExists: string[];
88
+ }): Promise<void>;
89
+ clearTable({ tableName }: {
90
+ tableName: TABLE_NAMES;
91
+ }): Promise<void>;
92
+ dropTable({ tableName }: {
93
+ tableName: TABLE_NAMES;
94
+ }): Promise<void>;
95
+ hasColumn(table: string, column: string): Promise<boolean>;
96
+ insert({ tableName, record }: {
97
+ tableName: TABLE_NAMES;
98
+ record: Record<string, any>;
99
+ }): Promise<void>;
100
+ load<R>({ tableName, keys }: {
101
+ tableName: TABLE_NAMES;
102
+ keys: Record<string, string>;
103
+ }): Promise<R | null>;
104
+ getThreadById({ threadId }: {
105
+ threadId: string;
106
+ }): Promise<StorageThreadType | null>;
107
+ saveThread({ thread }: {
108
+ thread: StorageThreadType;
109
+ }): Promise<StorageThreadType>;
110
+ updateThread({ id, title, metadata, }: {
111
+ id: string;
112
+ title: string;
113
+ metadata: Record<string, unknown>;
114
+ }): Promise<StorageThreadType>;
115
+ deleteThread({ threadId }: {
116
+ threadId: string;
117
+ }): Promise<void>;
118
+ saveMessages(args: {
119
+ messages: MastraDBMessage[];
120
+ }): Promise<{
121
+ messages: MastraDBMessage[];
122
+ }>;
123
+ updateWorkflowResults({ workflowName, runId, stepId, result, requestContext, }: {
124
+ workflowName: string;
125
+ runId: string;
126
+ stepId: string;
127
+ result: StepResult<any, any, any, any>;
128
+ requestContext: Record<string, any>;
129
+ }): Promise<Record<string, StepResult<any, any, any, any>>>;
130
+ updateWorkflowState({ workflowName, runId, opts, }: {
131
+ workflowName: string;
132
+ runId: string;
133
+ opts: {
134
+ status: string;
135
+ result?: StepResult<any, any, any, any>;
136
+ error?: string;
137
+ suspendedPaths?: Record<string, number[]>;
138
+ waitingPaths?: Record<string, number[]>;
139
+ };
140
+ }): Promise<WorkflowRunState | undefined>;
141
+ persistWorkflowSnapshot({ workflowName, runId, resourceId, snapshot, }: {
142
+ workflowName: string;
143
+ runId: string;
144
+ resourceId?: string;
145
+ snapshot: WorkflowRunState;
146
+ }): Promise<void>;
147
+ loadWorkflowSnapshot(params: {
148
+ workflowName: string;
149
+ runId: string;
150
+ }): Promise<WorkflowRunState | null>;
151
+ listWorkflowRuns(args?: StorageListWorkflowRunsInput): Promise<WorkflowRuns>;
152
+ getWorkflowRunById({ runId, workflowName, }: {
153
+ runId: string;
154
+ workflowName?: string;
155
+ }): Promise<WorkflowRun | null>;
156
+ /**
157
+ * Insert multiple records in a batch operation
158
+ * @param tableName The table to insert into
159
+ * @param records The records to insert
160
+ */
161
+ batchInsert({ tableName, records }: {
162
+ tableName: TABLE_NAMES;
163
+ records: Record<string, any>[];
164
+ }): Promise<void>;
165
+ updateMessages(_args: {
166
+ messages: (Partial<Omit<MastraDBMessage, 'createdAt'>> & {
167
+ id: string;
168
+ content?: {
169
+ metadata?: MastraMessageContentV2['metadata'];
170
+ content?: MastraMessageContentV2['content'];
171
+ };
172
+ })[];
173
+ }): Promise<MastraDBMessage[]>;
174
+ getResourceById({ resourceId }: {
175
+ resourceId: string;
176
+ }): Promise<StorageResourceType | null>;
177
+ saveResource({ resource }: {
178
+ resource: StorageResourceType;
179
+ }): Promise<StorageResourceType>;
180
+ updateResource({ resourceId, workingMemory, metadata, }: {
181
+ resourceId: string;
182
+ workingMemory?: string;
183
+ metadata?: Record<string, unknown>;
184
+ }): Promise<StorageResourceType>;
185
+ getScoreById({ id: _id }: {
186
+ id: string;
187
+ }): Promise<ScoreRowData | null>;
188
+ saveScore(_score: ScoreRowData): Promise<{
189
+ score: ScoreRowData;
190
+ }>;
191
+ listScoresByRunId({ runId: _runId, pagination: _pagination, }: {
192
+ runId: string;
193
+ pagination: StoragePagination;
194
+ }): Promise<{
195
+ pagination: PaginationInfo;
196
+ scores: ScoreRowData[];
197
+ }>;
198
+ listScoresByEntityId({ entityId: _entityId, entityType: _entityType, pagination: _pagination, }: {
199
+ pagination: StoragePagination;
200
+ entityId: string;
201
+ entityType: string;
202
+ }): Promise<{
203
+ pagination: PaginationInfo;
204
+ scores: ScoreRowData[];
205
+ }>;
206
+ listScoresByScorerId({ scorerId, pagination, entityId, entityType, source, }: {
207
+ scorerId: string;
208
+ pagination: StoragePagination;
209
+ entityId?: string;
210
+ entityType?: string;
211
+ source?: ScoringSource;
212
+ }): Promise<{
213
+ pagination: PaginationInfo;
214
+ scores: ScoreRowData[];
215
+ }>;
216
+ listScoresBySpan({ traceId, spanId, pagination, }: {
217
+ traceId: string;
218
+ spanId: string;
219
+ pagination: StoragePagination;
220
+ }): Promise<{
221
+ pagination: PaginationInfo;
222
+ scores: ScoreRowData[];
223
+ }>;
224
+ /**
225
+ * Close the database connection
226
+ * No explicit cleanup needed for D1 in either REST or Workers Binding mode
227
+ */
228
+ close(): Promise<void>;
229
+ }
230
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/storage/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,2BAA2B,CAAC;AAC5D,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,oBAAoB,CAAC;AAEjE,OAAO,KAAK,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACtE,OAAO,KAAK,EAAE,iBAAiB,EAAE,eAAe,EAAE,MAAM,qBAAqB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C;QAAE,UAAU,EAAE,cAAc,CAAC;QAAC,MAAM,EAAE,YAAY,EAAE,CAAA;KAAE,CAAC;IAInE;;;OAGG;IACG,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;CAI7B"}
@@ -0,0 +1,128 @@
1
+ /**
2
+ * Type definition for SQL query parameters
3
+ */
4
+ export type SqlParam = string | number | boolean | null | undefined;
5
+ /**
6
+ * Interface for SQL query options with generic type support
7
+ */
8
+ export interface SqlQueryOptions {
9
+ /** SQL query to execute */
10
+ sql: string;
11
+ /** Parameters to bind to the query */
12
+ params?: SqlParam[];
13
+ /** Whether to return only the first result */
14
+ first?: boolean;
15
+ }
16
+ /**
17
+ * SQL Builder class for constructing type-safe SQL queries
18
+ * This helps create maintainable and secure SQL queries with proper parameter handling
19
+ */
20
+ export declare class SqlBuilder {
21
+ private sql;
22
+ private params;
23
+ private whereAdded;
24
+ select(columns?: string | string[]): SqlBuilder;
25
+ from(table: string): SqlBuilder;
26
+ /**
27
+ * Add a WHERE clause to the query
28
+ * @param condition The condition to add
29
+ * @param params Parameters to bind to the condition
30
+ */
31
+ where(condition: string, ...params: SqlParam[]): SqlBuilder;
32
+ /**
33
+ * Add a WHERE clause if it hasn't been added yet, otherwise add an AND clause
34
+ * @param condition The condition to add
35
+ * @param params Parameters to bind to the condition
36
+ */
37
+ whereAnd(condition: string, ...params: SqlParam[]): SqlBuilder;
38
+ andWhere(condition: string, ...params: SqlParam[]): SqlBuilder;
39
+ orWhere(condition: string, ...params: SqlParam[]): SqlBuilder;
40
+ orderBy(column: string, direction?: 'ASC' | 'DESC'): SqlBuilder;
41
+ limit(count: number): SqlBuilder;
42
+ offset(count: number): SqlBuilder;
43
+ count(): SqlBuilder;
44
+ /**
45
+ * Insert a row, or update specific columns on conflict (upsert).
46
+ * @param table Table name
47
+ * @param columns Columns to insert
48
+ * @param values Values to insert
49
+ * @param conflictColumns Columns to check for conflict (usually PK or UNIQUE)
50
+ * @param updateMap Object mapping columns to update to their new value (e.g. { name: 'excluded.name' })
51
+ */
52
+ insert(table: string, columns: string[], values: SqlParam[], conflictColumns?: string[], updateMap?: Record<string, string>): SqlBuilder;
53
+ update(table: string, columns: string[], values: SqlParam[]): SqlBuilder;
54
+ delete(table: string): SqlBuilder;
55
+ /**
56
+ * Create a table if it doesn't exist
57
+ * @param table The table name
58
+ * @param columnDefinitions The column definitions as an array of strings
59
+ * @param tableConstraints Optional constraints for the table
60
+ * @returns The builder instance
61
+ */
62
+ createTable(table: string, columnDefinitions: string[], tableConstraints?: string[]): SqlBuilder;
63
+ /**
64
+ * Check if an index exists in the database
65
+ * @param indexName The name of the index to check
66
+ * @param tableName The table the index is on
67
+ * @returns The builder instance
68
+ */
69
+ checkIndexExists(indexName: string, tableName: string): SqlBuilder;
70
+ /**
71
+ * Create an index if it doesn't exist
72
+ * @param indexName The name of the index to create
73
+ * @param tableName The table to create the index on
74
+ * @param columnName The column to index
75
+ * @param indexType Optional index type (e.g., 'UNIQUE')
76
+ * @returns The builder instance
77
+ */
78
+ createIndex(indexName: string, tableName: string, columnName: string, indexType?: string): SqlBuilder;
79
+ /**
80
+ * Add a LIKE condition to the query
81
+ * @param column The column to check
82
+ * @param value The value to match (will be wrapped with % for LIKE)
83
+ * @param exact If true, will not add % wildcards
84
+ */
85
+ like(column: string, value: string, exact?: boolean): SqlBuilder;
86
+ /**
87
+ * Add a JSON LIKE condition for searching in JSON fields
88
+ * @param column The JSON column to search in
89
+ * @param key The JSON key to match
90
+ * @param value The value to match
91
+ */
92
+ jsonLike(column: string, key: string, value: string): SqlBuilder;
93
+ /**
94
+ * Get the built query
95
+ * @returns Object containing the SQL string and parameters array
96
+ */
97
+ build(): {
98
+ sql: string;
99
+ params: SqlParam[];
100
+ };
101
+ /**
102
+ * Reset the builder for reuse
103
+ * @returns The reset builder instance
104
+ */
105
+ reset(): SqlBuilder;
106
+ }
107
+ export declare function createSqlBuilder(): SqlBuilder;
108
+ /** Represents a validated SQL SELECT column identifier (or '*', optionally with 'AS alias'). */
109
+ type SelectIdentifier = string & {
110
+ __brand: 'SelectIdentifier';
111
+ };
112
+ /**
113
+ * Parses and returns a valid SQL SELECT column identifier.
114
+ * Allows a single identifier (letters, numbers, underscores), or '*', optionally with 'AS alias'.
115
+ *
116
+ * @param column - The column identifier string to parse.
117
+ * @returns The validated column identifier as a branded type.
118
+ * @throws {Error} If invalid.
119
+ *
120
+ * @example
121
+ * const col = parseSelectIdentifier('user_id'); // Ok
122
+ * parseSelectIdentifier('user_id AS uid'); // Ok
123
+ * parseSelectIdentifier('*'); // Ok
124
+ * parseSelectIdentifier('user id'); // Throws error
125
+ */
126
+ export declare function parseSelectIdentifier(column: string): SelectIdentifier;
127
+ export {};
128
+ //# sourceMappingURL=sql-builder.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sql-builder.d.ts","sourceRoot":"","sources":["../../src/storage/sql-builder.ts"],"names":[],"mappings":"AAEA;;GAEG;AACH,MAAM,MAAM,QAAQ,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,IAAI,GAAG,SAAS,CAAC;AAEpE;;GAEG;AACH,MAAM,WAAW,eAAe;IAC9B,2BAA2B;IAC3B,GAAG,EAAE,MAAM,CAAC;IACZ,sCAAsC;IACtC,MAAM,CAAC,EAAE,QAAQ,EAAE,CAAC;IACpB,8CAA8C;IAC9C,KAAK,CAAC,EAAE,OAAO,CAAC;CACjB;AAED;;;GAGG;AACH,qBAAa,UAAU;IACrB,OAAO,CAAC,GAAG,CAAc;IACzB,OAAO,CAAC,MAAM,CAAkB;IAChC,OAAO,CAAC,UAAU,CAAkB;IAGpC,MAAM,CAAC,OAAO,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,GAAG,UAAU;IAW/C,IAAI,CAAC,KAAK,EAAE,MAAM,GAAG,UAAU;IAM/B;;;;OAIG;IACH,KAAK,CAAC,SAAS,EAAE,MAAM,EAAE,GAAG,MAAM,EAAE,QAAQ,EAAE,GAAG,UAAU;IAO3D;;;;OAIG;IAC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AKG;IACH,IAAI,CAAC,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK,GAAE,OAAe,GAAG,UAAU;IAavE;;;;;OAKG;IACH,QAAQ,CAAC,MAAM,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,UAAU;IAchE;;;OAGG;IACH,KAAK,IAAI;QAAE,GAAG,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,QAAQ,EAAE,CAAA;KAAE;IAO5C;;;OAGG;IACH,KAAK,IAAI,UAAU;CAMpB;AAGD,wBAAgB,gBAAgB,IAAI,UAAU,CAE7C;AAED,gGAAgG;AAChG,KAAK,gBAAgB,GAAG,MAAM,GAAG;IAAE,OAAO,EAAE,kBAAkB,CAAA;CAAE,CAAC;AAIjE;;;;;;;;;;;;;GAaG;AACH,wBAAgB,qBAAqB,CAAC,MAAM,EAAE,MAAM,GAAG,gBAAgB,CAOtE"}
@@ -0,0 +1,19 @@
1
+ export declare const createSampleTrace: (name: string, scope?: string, attributes?: Record<string, string>) => {
2
+ id: string;
3
+ parentSpanId: string;
4
+ traceId: string;
5
+ name: string;
6
+ scope: string | undefined;
7
+ kind: string;
8
+ status: string;
9
+ events: string;
10
+ links: string;
11
+ attributes: string | undefined;
12
+ startTime: string;
13
+ endTime: string;
14
+ other: string;
15
+ createdAt: string;
16
+ };
17
+ export declare const retryUntil: <T>(fn: () => Promise<T>, condition: (result: T) => boolean, timeout?: number, // REST API needs longer timeout due to higher latency
18
+ interval?: number) => Promise<T>;
19
+ //# sourceMappingURL=test-utils.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"test-utils.d.ts","sourceRoot":"","sources":["../../src/storage/test-utils.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,iBAAiB,GAAI,MAAM,MAAM,EAAE,QAAQ,MAAM,EAAE,aAAa,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC;;;;;;;;;;;;;;;CAejG,CAAC;AAGH,eAAO,MAAM,UAAU,GAAU,CAAC,EAChC,IAAI,MAAM,OAAO,CAAC,CAAC,CAAC,EACpB,WAAW,CAAC,MAAM,EAAE,CAAC,KAAK,OAAO,EACjC,gBAAe,EAAE,sDAAsD;AACvE,iBAAe,KACd,OAAO,CAAC,CAAC,CAYX,CAAC"}
package/package.json CHANGED
@@ -1,10 +1,11 @@
1
1
  {
2
2
  "name": "@mastra/cloudflare-d1",
3
- "version": "0.0.0-vnext-inngest-20250508131921",
3
+ "version": "0.0.0-vnext-20251119160359",
4
4
  "description": "D1 provider for Mastra - includes db storage capabilities",
5
5
  "type": "module",
6
6
  "files": [
7
- "dist"
7
+ "dist",
8
+ "CHANGELOG.md"
8
9
  ],
9
10
  "main": "dist/index.js",
10
11
  "types": "dist/index.d.ts",
@@ -15,31 +16,50 @@
15
16
  "default": "./dist/index.js"
16
17
  },
17
18
  "require": {
18
- "types": "./dist/index.d.cts",
19
+ "types": "./dist/index.d.ts",
19
20
  "default": "./dist/index.cjs"
20
21
  }
21
22
  },
22
23
  "./package.json": "./package.json"
23
24
  },
24
25
  "dependencies": {
25
- "cloudflare": "^4.1.0",
26
- "@mastra/core": "0.0.0-vnext-inngest-20250508131921"
26
+ "cloudflare": "^4.5.0"
27
27
  },
28
28
  "devDependencies": {
29
- "@cloudflare/workers-types": "^4.20250417.0",
30
- "@microsoft/api-extractor": "^7.52.5",
31
- "@types/node": "^20.17.27",
32
- "dotenv": "^16.4.7",
33
- "eslint": "^9.23.0",
34
- "miniflare": "^4.20250410.1",
35
- "tsup": "^8.4.0",
36
- "typescript": "^5.8.2",
37
- "vitest": "^3.1.2",
38
- "@internal/lint": "0.0.0-vnext-inngest-20250508131921"
29
+ "@cloudflare/workers-types": "^4.20251111.0",
30
+ "@microsoft/api-extractor": "^7.52.8",
31
+ "@types/node": "22.13.17",
32
+ "@vitest/coverage-v8": "4.0.8",
33
+ "@vitest/ui": "4.0.8",
34
+ "dotenv": "^17.0.0",
35
+ "eslint": "^9.37.0",
36
+ "miniflare": "^4.20251109.0",
37
+ "tsup": "^8.5.0",
38
+ "typescript": "^5.8.3",
39
+ "vitest": "^4.0.8",
40
+ "@internal/lint": "0.0.0-vnext-20251119160359",
41
+ "@mastra/core": "0.0.0-vnext-20251119160359",
42
+ "@internal/storage-test-utils": "0.0.49",
43
+ "@internal/types-builder": "0.0.0-vnext-20251119160359"
44
+ },
45
+ "peerDependencies": {
46
+ "@mastra/core": "0.0.0-vnext-20251119160359"
47
+ },
48
+ "homepage": "https://mastra.ai",
49
+ "repository": {
50
+ "type": "git",
51
+ "url": "git+https://github.com/mastra-ai/mastra.git",
52
+ "directory": "stores/cloudflare-d1"
53
+ },
54
+ "bugs": {
55
+ "url": "https://github.com/mastra-ai/mastra/issues"
56
+ },
57
+ "engines": {
58
+ "node": ">=22.13.0"
39
59
  },
40
60
  "scripts": {
41
- "build": "tsup src/index.ts --format esm,cjs --experimental-dts --clean --treeshake=smallest --splitting",
42
- "build:watch": "pnpm build --watch",
61
+ "build": "tsup --silent --config tsup.config.ts",
62
+ "build:watch": "tsup --watch --silent --config tsup.config.ts",
43
63
  "test": "vitest run",
44
64
  "lint": "eslint ."
45
65
  }