@mastra/cloudflare-d1 0.0.0-update-stores-peerDeps-20250723031338 → 0.0.0-usechat-duplicate-20251016110554
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 +1206 -0
- package/dist/index.cjs +224 -40
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.ts +2 -7
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +225 -41
- package/dist/index.js.map +1 -0
- package/dist/storage/domains/legacy-evals/index.d.ts +20 -0
- package/dist/storage/domains/legacy-evals/index.d.ts.map +1 -0
- package/dist/storage/domains/memory/index.d.ts +90 -0
- package/dist/storage/domains/memory/index.d.ts.map +1 -0
- package/dist/storage/domains/operations/index.d.ts +72 -0
- package/dist/storage/domains/operations/index.d.ts.map +1 -0
- package/dist/storage/domains/scores/index.d.ts +60 -0
- package/dist/storage/domains/scores/index.d.ts.map +1 -0
- package/dist/storage/domains/traces/index.d.ts +18 -0
- package/dist/storage/domains/traces/index.d.ts.map +1 -0
- package/dist/storage/domains/utils.d.ts +3 -0
- package/dist/storage/domains/utils.d.ts.map +1 -0
- package/dist/storage/domains/workflows/index.d.ts +52 -0
- package/dist/storage/domains/workflows/index.d.ts.map +1 -0
- package/dist/storage/index.d.ts +295 -0
- package/dist/storage/index.d.ts.map +1 -0
- package/dist/storage/sql-builder.d.ts +128 -0
- package/dist/storage/sql-builder.d.ts.map +1 -0
- package/dist/storage/test-utils.d.ts +19 -0
- package/dist/storage/test-utils.d.ts.map +1 -0
- package/package.json +24 -13
- package/dist/_tsup-dts-rollup.d.cts +0 -706
- package/dist/_tsup-dts-rollup.d.ts +0 -706
- package/dist/index.d.cts +0 -7
|
@@ -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,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gB,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-
|
|
3
|
+
"version": "0.0.0-usechat-duplicate-20251016110554",
|
|
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,35 +16,45 @@
|
|
|
15
16
|
"default": "./dist/index.js"
|
|
16
17
|
},
|
|
17
18
|
"require": {
|
|
18
|
-
"types": "./dist/index.d.
|
|
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.
|
|
26
|
+
"cloudflare": "^4.5.0"
|
|
26
27
|
},
|
|
27
28
|
"devDependencies": {
|
|
28
|
-
"@cloudflare/workers-types": "^4.
|
|
29
|
+
"@cloudflare/workers-types": "^4.20251008.0",
|
|
29
30
|
"@microsoft/api-extractor": "^7.52.8",
|
|
30
31
|
"@types/node": "^20.19.0",
|
|
31
32
|
"dotenv": "^17.0.0",
|
|
32
|
-
"eslint": "^9.
|
|
33
|
-
"miniflare": "^4.
|
|
33
|
+
"eslint": "^9.36.0",
|
|
34
|
+
"miniflare": "^4.20251008.0",
|
|
34
35
|
"tsup": "^8.5.0",
|
|
35
36
|
"typescript": "^5.8.3",
|
|
36
37
|
"vitest": "^3.2.4",
|
|
37
|
-
"@
|
|
38
|
-
"@
|
|
39
|
-
"@internal/
|
|
38
|
+
"@mastra/core": "0.0.0-usechat-duplicate-20251016110554",
|
|
39
|
+
"@internal/lint": "0.0.0-usechat-duplicate-20251016110554",
|
|
40
|
+
"@internal/types-builder": "0.0.0-usechat-duplicate-20251016110554",
|
|
41
|
+
"@internal/storage-test-utils": "0.0.45"
|
|
40
42
|
},
|
|
41
43
|
"peerDependencies": {
|
|
42
|
-
"@mastra/core": "0.
|
|
44
|
+
"@mastra/core": "0.0.0-usechat-duplicate-20251016110554"
|
|
45
|
+
},
|
|
46
|
+
"homepage": "https://mastra.ai",
|
|
47
|
+
"repository": {
|
|
48
|
+
"type": "git",
|
|
49
|
+
"url": "git+https://github.com/mastra-ai/mastra.git",
|
|
50
|
+
"directory": "stores/cloudflare-d1"
|
|
51
|
+
},
|
|
52
|
+
"bugs": {
|
|
53
|
+
"url": "https://github.com/mastra-ai/mastra/issues"
|
|
43
54
|
},
|
|
44
55
|
"scripts": {
|
|
45
|
-
"build": "tsup
|
|
46
|
-
"build:watch": "
|
|
56
|
+
"build": "tsup --silent --config tsup.config.ts",
|
|
57
|
+
"build:watch": "tsup --watch --silent --config tsup.config.ts",
|
|
47
58
|
"test": "vitest run",
|
|
48
59
|
"lint": "eslint ."
|
|
49
60
|
}
|