@mastra/cloudflare-d1 1.0.0-beta.1 → 1.0.0-beta.10
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 +478 -0
- package/dist/docs/README.md +31 -0
- package/dist/docs/SKILL.md +32 -0
- package/dist/docs/SOURCE_MAP.json +6 -0
- package/dist/docs/storage/01-reference.md +110 -0
- package/dist/index.cjs +1079 -1116
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +1077 -1117
- package/dist/index.js.map +1 -1
- package/dist/storage/{domains/operations → db}/index.d.ts +42 -6
- package/dist/storage/db/index.d.ts.map +1 -0
- package/dist/storage/domains/memory/index.d.ts +6 -5
- package/dist/storage/domains/memory/index.d.ts.map +1 -1
- package/dist/storage/domains/scores/index.d.ts +12 -34
- package/dist/storage/domains/scores/index.d.ts.map +1 -1
- package/dist/storage/domains/workflows/index.d.ts +14 -14
- package/dist/storage/domains/workflows/index.d.ts.map +1 -1
- package/dist/storage/index.d.ts +55 -177
- package/dist/storage/index.d.ts.map +1 -1
- package/package.json +9 -9
- package/dist/storage/domains/operations/index.d.ts.map +0 -1
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import type { D1Database } from '@cloudflare/workers-types';
|
|
2
|
-
import {
|
|
2
|
+
import { MastraBase } from '@mastra/core/base';
|
|
3
3
|
import type { TABLE_NAMES, StorageColumn } from '@mastra/core/storage';
|
|
4
|
-
import
|
|
5
|
-
import type { SqlQueryOptions } from '
|
|
4
|
+
import Cloudflare from 'cloudflare';
|
|
5
|
+
import type { SqlQueryOptions } from '../sql-builder.js';
|
|
6
6
|
export type D1QueryResult = Awaited<ReturnType<Cloudflare['d1']['database']['query']>>['result'];
|
|
7
7
|
export interface D1Client {
|
|
8
8
|
query(args: {
|
|
@@ -12,16 +12,51 @@ export interface D1Client {
|
|
|
12
12
|
result: D1QueryResult;
|
|
13
13
|
}>;
|
|
14
14
|
}
|
|
15
|
-
export interface
|
|
15
|
+
export interface D1DBConfig {
|
|
16
16
|
client?: D1Client;
|
|
17
17
|
binding?: D1Database;
|
|
18
18
|
tablePrefix?: string;
|
|
19
19
|
}
|
|
20
|
-
|
|
20
|
+
/**
|
|
21
|
+
* Configuration for standalone domain usage.
|
|
22
|
+
* Accepts either:
|
|
23
|
+
* 1. An existing D1 client or binding
|
|
24
|
+
* 2. Config to create a new client internally
|
|
25
|
+
*/
|
|
26
|
+
export type D1DomainConfig = D1DomainClientConfig | D1DomainBindingConfig | D1DomainRestConfig;
|
|
27
|
+
/**
|
|
28
|
+
* Pass an existing D1 client (REST API)
|
|
29
|
+
*/
|
|
30
|
+
export interface D1DomainClientConfig {
|
|
31
|
+
client: D1Client;
|
|
32
|
+
tablePrefix?: string;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Pass an existing D1 binding (Workers API)
|
|
36
|
+
*/
|
|
37
|
+
export interface D1DomainBindingConfig {
|
|
38
|
+
binding: D1Database;
|
|
39
|
+
tablePrefix?: string;
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Pass config to create a new D1 client internally (REST API)
|
|
43
|
+
*/
|
|
44
|
+
export interface D1DomainRestConfig {
|
|
45
|
+
accountId: string;
|
|
46
|
+
apiToken: string;
|
|
47
|
+
databaseId: string;
|
|
48
|
+
tablePrefix?: string;
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Resolves D1DomainConfig to D1DBConfig.
|
|
52
|
+
* Handles creating a new D1 client if apiToken is provided.
|
|
53
|
+
*/
|
|
54
|
+
export declare function resolveD1Config(config: D1DomainConfig): D1DBConfig;
|
|
55
|
+
export declare class D1DB extends MastraBase {
|
|
21
56
|
private client?;
|
|
22
57
|
private binding?;
|
|
23
58
|
private tablePrefix;
|
|
24
|
-
constructor(config:
|
|
59
|
+
constructor(config: D1DBConfig);
|
|
25
60
|
hasColumn(table: string, column: string): Promise<boolean>;
|
|
26
61
|
getTableName(tableName: TABLE_NAMES): string;
|
|
27
62
|
private formatSqlParams;
|
|
@@ -31,6 +66,7 @@ export declare class StoreOperationsD1 extends StoreOperations {
|
|
|
31
66
|
private getTableColumns;
|
|
32
67
|
private serializeValue;
|
|
33
68
|
protected getSqlType(type: StorageColumn['type']): string;
|
|
69
|
+
protected getDefaultValue(type: StorageColumn['type']): string;
|
|
34
70
|
createTable({ tableName, schema, }: {
|
|
35
71
|
tableName: TABLE_NAMES;
|
|
36
72
|
schema: Record<string, StorageColumn>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/storage/db/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,2BAA2B,CAAC;AAC5D,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAG/C,OAAO,KAAK,EAAE,WAAW,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AACvE,OAAO,UAAU,MAAM,YAAY,CAAC;AAGpC,OAAO,KAAK,EAAY,eAAe,EAAE,MAAM,gBAAgB,CAAC;AAEhE,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;AAED,MAAM,WAAW,UAAU;IACzB,MAAM,CAAC,EAAE,QAAQ,CAAC;IAClB,OAAO,CAAC,EAAE,UAAU,CAAC;IACrB,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAED;;;;;GAKG;AACH,MAAM,MAAM,cAAc,GAAG,oBAAoB,GAAG,qBAAqB,GA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M,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IAQ9E;;;;OAIG;IACG,WAAW,CAAC,EAAE,SAAS,EAAE,OAAO,EAAE,EAAE;QAAE,SAAS,EAAE,WAAW,CAAC;QAAC,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EAAE,CAAA;KAAE,GAAG,OAAO,CAAC,IAAI,CAAC;CAgErH"}
|
|
@@ -2,12 +2,12 @@ import type { MastraMessageContentV2 } from '@mastra/core/agent';
|
|
|
2
2
|
import type { MastraDBMessage, StorageThreadType } from '@mastra/core/memory';
|
|
3
3
|
import { MemoryStorage } from '@mastra/core/storage';
|
|
4
4
|
import type { StorageResourceType, StorageListMessagesInput, StorageListMessagesOutput, StorageListThreadsByResourceIdInput, StorageListThreadsByResourceIdOutput } from '@mastra/core/storage';
|
|
5
|
-
import type {
|
|
5
|
+
import type { D1DomainConfig } from '../../db/index.js';
|
|
6
6
|
export declare class MemoryStorageD1 extends MemoryStorage {
|
|
7
|
-
private
|
|
8
|
-
constructor(
|
|
9
|
-
|
|
10
|
-
|
|
7
|
+
#private;
|
|
8
|
+
constructor(config: D1DomainConfig);
|
|
9
|
+
init(): Promise<void>;
|
|
10
|
+
dangerouslyClearAll(): Promise<void>;
|
|
11
11
|
getResourceById({ resourceId }: {
|
|
12
12
|
resourceId: string;
|
|
13
13
|
}): Promise<StorageResourceType | null>;
|
|
@@ -55,5 +55,6 @@ export declare class MemoryStorageD1 extends MemoryStorage {
|
|
|
55
55
|
};
|
|
56
56
|
}[];
|
|
57
57
|
}): Promise<MastraDBMessage[]>;
|
|
58
|
+
deleteMessages(messageIds: string[]): Promise<void>;
|
|
58
59
|
}
|
|
59
60
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/storage/domains/memory/index.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,oB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AAsB,CAAC,SAAS,CAAC,CAAC;aAC7C,CAAC;SACH,EAAE,CAAC;KACP,GAAG,OAAO,CAAC,eAAe,EAAE,CAAC;IAyIxB,cAAc,CAAC,UAAU,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC;CAuC1D"}
|
|
@@ -1,26 +1,16 @@
|
|
|
1
|
-
import type { ScoreRowData, ScoringSource } from '@mastra/core/evals';
|
|
1
|
+
import type { ListScoresResponse, SaveScorePayload, ScoreRowData, ScoringSource } from '@mastra/core/evals';
|
|
2
2
|
import { ScoresStorage } from '@mastra/core/storage';
|
|
3
|
-
import type { StoragePagination
|
|
4
|
-
import type
|
|
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
|
-
}
|
|
3
|
+
import type { StoragePagination } from '@mastra/core/storage';
|
|
4
|
+
import type { D1DomainConfig } from '../../db/index.js';
|
|
15
5
|
export declare class ScoresStorageD1 extends ScoresStorage {
|
|
16
|
-
private
|
|
17
|
-
constructor(
|
|
18
|
-
|
|
19
|
-
|
|
6
|
+
#private;
|
|
7
|
+
constructor(config: D1DomainConfig);
|
|
8
|
+
init(): Promise<void>;
|
|
9
|
+
dangerouslyClearAll(): Promise<void>;
|
|
20
10
|
getScoreById({ id }: {
|
|
21
11
|
id: string;
|
|
22
12
|
}): Promise<ScoreRowData | null>;
|
|
23
|
-
saveScore(score:
|
|
13
|
+
saveScore(score: SaveScorePayload): Promise<{
|
|
24
14
|
score: ScoreRowData;
|
|
25
15
|
}>;
|
|
26
16
|
listScoresByScorerId({ scorerId, entityId, entityType, source, pagination, }: {
|
|
@@ -29,32 +19,20 @@ export declare class ScoresStorageD1 extends ScoresStorage {
|
|
|
29
19
|
entityType?: string;
|
|
30
20
|
source?: ScoringSource;
|
|
31
21
|
pagination: StoragePagination;
|
|
32
|
-
}): Promise<
|
|
33
|
-
pagination: PaginationInfo;
|
|
34
|
-
scores: ScoreRowData[];
|
|
35
|
-
}>;
|
|
22
|
+
}): Promise<ListScoresResponse>;
|
|
36
23
|
listScoresByRunId({ runId, pagination, }: {
|
|
37
24
|
runId: string;
|
|
38
25
|
pagination: StoragePagination;
|
|
39
|
-
}): Promise<
|
|
40
|
-
pagination: PaginationInfo;
|
|
41
|
-
scores: ScoreRowData[];
|
|
42
|
-
}>;
|
|
26
|
+
}): Promise<ListScoresResponse>;
|
|
43
27
|
listScoresByEntityId({ entityId, entityType, pagination, }: {
|
|
44
28
|
pagination: StoragePagination;
|
|
45
29
|
entityId: string;
|
|
46
30
|
entityType: string;
|
|
47
|
-
}): Promise<
|
|
48
|
-
pagination: PaginationInfo;
|
|
49
|
-
scores: ScoreRowData[];
|
|
50
|
-
}>;
|
|
31
|
+
}): Promise<ListScoresResponse>;
|
|
51
32
|
listScoresBySpan({ traceId, spanId, pagination, }: {
|
|
52
33
|
traceId: string;
|
|
53
34
|
spanId: string;
|
|
54
35
|
pagination: StoragePagination;
|
|
55
|
-
}): Promise<
|
|
56
|
-
pagination: PaginationInfo;
|
|
57
|
-
scores: ScoreRowData[];
|
|
58
|
-
}>;
|
|
36
|
+
}): Promise<ListScoresResponse>;
|
|
59
37
|
}
|
|
60
38
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +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,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/storage/domains/scores/index.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,kBAAkB,EAAE,gBA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OAAO,CAAC,kBAAkB,CAAC;IAmEzB,gBAAgB,CAAC,EACrB,OAAO,EACP,MAAM,EACN,UAAU,GACX,EAAE;QACD,OAAO,EAAE,MAAM,CAAC;QAChB,MAAM,EAAE,MAAM,CAAC;QACf,UAAU,EAAE,iBAAiB,CAAC;KAC/B,GAAG,OAAO,CAAC,kBAAkB,CAAC;CAkEhC"}
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import type { WorkflowRun, WorkflowRuns, StorageListWorkflowRunsInput } from '@mastra/core/storage';
|
|
1
|
+
import type { WorkflowRun, WorkflowRuns, StorageListWorkflowRunsInput, UpdateWorkflowStateOptions } from '@mastra/core/storage';
|
|
2
2
|
import { WorkflowsStorage } from '@mastra/core/storage';
|
|
3
3
|
import type { StepResult, WorkflowRunState } from '@mastra/core/workflows';
|
|
4
|
-
import type {
|
|
4
|
+
import type { D1DomainConfig } from '../../db/index.js';
|
|
5
5
|
export declare class WorkflowsStorageD1 extends WorkflowsStorage {
|
|
6
|
-
private
|
|
7
|
-
constructor(
|
|
8
|
-
|
|
9
|
-
|
|
6
|
+
#private;
|
|
7
|
+
constructor(config: D1DomainConfig);
|
|
8
|
+
init(): Promise<void>;
|
|
9
|
+
dangerouslyClearAll(): Promise<void>;
|
|
10
10
|
updateWorkflowResults({}: {
|
|
11
11
|
workflowName: string;
|
|
12
12
|
runId: string;
|
|
@@ -17,19 +17,15 @@ export declare class WorkflowsStorageD1 extends WorkflowsStorage {
|
|
|
17
17
|
updateWorkflowState({}: {
|
|
18
18
|
workflowName: string;
|
|
19
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
|
-
};
|
|
20
|
+
opts: UpdateWorkflowStateOptions;
|
|
27
21
|
}): Promise<WorkflowRunState | undefined>;
|
|
28
|
-
persistWorkflowSnapshot({ workflowName, runId, resourceId, snapshot, }: {
|
|
22
|
+
persistWorkflowSnapshot({ workflowName, runId, resourceId, snapshot, createdAt, updatedAt, }: {
|
|
29
23
|
workflowName: string;
|
|
30
24
|
runId: string;
|
|
31
25
|
resourceId?: string;
|
|
32
26
|
snapshot: WorkflowRunState;
|
|
27
|
+
createdAt?: Date;
|
|
28
|
+
updatedAt?: Date;
|
|
33
29
|
}): Promise<void>;
|
|
34
30
|
loadWorkflowSnapshot(params: {
|
|
35
31
|
workflowName: string;
|
|
@@ -41,5 +37,9 @@ export declare class WorkflowsStorageD1 extends WorkflowsStorage {
|
|
|
41
37
|
runId: string;
|
|
42
38
|
workflowName?: string;
|
|
43
39
|
}): Promise<WorkflowRun | null>;
|
|
40
|
+
deleteWorkflowRunById({ runId, workflowName }: {
|
|
41
|
+
runId: string;
|
|
42
|
+
workflowName: string;
|
|
43
|
+
}): Promise<void>;
|
|
44
44
|
}
|
|
45
45
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/storage/domains/workflows/index.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/storage/domains/workflows/index.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,WAAW,EACX,YAAY,EACZ,4BAA4B,EAC5B,0BAA0B,EAC3B,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAKL,gBAAgB,EACjB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,KAAK,EAAE,UAAU,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAE3E,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AAK/C,qBAAa,kBAAmB,SAAQ,gBAAgB;;gBAG1C,MAAM,EAAE,cAAc;IAK5B,IAAI,IAAI,OAAO,CAAC,IAAI,CAA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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;IAgCzB,qBAAqB,CAAC,EAAE,KAAK,EAAE,YAAY,EAAE,EAAE;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,YAAY,EAAE,MAAM,CAAA;KAAE,GAAG,OAAO,CAAC,IAAI,CAAC;CAmB7G"}
|
package/dist/storage/index.d.ts
CHANGED
|
@@ -1,44 +1,62 @@
|
|
|
1
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
2
|
import { MastraStorage } from '@mastra/core/storage';
|
|
6
|
-
import type {
|
|
7
|
-
import type { StepResult, WorkflowRunState } from '@mastra/core/workflows';
|
|
3
|
+
import type { StorageDomains } from '@mastra/core/storage';
|
|
8
4
|
import Cloudflare from 'cloudflare';
|
|
5
|
+
import { MemoryStorageD1 } from './domains/memory/index.js';
|
|
6
|
+
import { ScoresStorageD1 } from './domains/scores/index.js';
|
|
7
|
+
import { WorkflowsStorageD1 } from './domains/workflows/index.js';
|
|
8
|
+
export { MemoryStorageD1, ScoresStorageD1, WorkflowsStorageD1 };
|
|
9
|
+
export type { D1DomainConfig } from './db/index.js';
|
|
9
10
|
/**
|
|
10
|
-
*
|
|
11
|
+
* Base configuration options shared across D1 configurations
|
|
11
12
|
*/
|
|
12
|
-
export interface
|
|
13
|
+
export interface D1BaseConfig {
|
|
13
14
|
/** Storage instance ID */
|
|
14
15
|
id: string;
|
|
16
|
+
/** Optional prefix for table names */
|
|
17
|
+
tablePrefix?: string;
|
|
18
|
+
/**
|
|
19
|
+
* When true, automatic initialization (table creation/migrations) is disabled.
|
|
20
|
+
* This is useful for CI/CD pipelines where you want to:
|
|
21
|
+
* 1. Run migrations explicitly during deployment (not at runtime)
|
|
22
|
+
* 2. Use different credentials for schema changes vs runtime operations
|
|
23
|
+
*
|
|
24
|
+
* When disableInit is true:
|
|
25
|
+
* - The storage will not automatically create/alter tables on first use
|
|
26
|
+
* - You must call `storage.init()` explicitly in your CI/CD scripts
|
|
27
|
+
*
|
|
28
|
+
* @example
|
|
29
|
+
* // In CI/CD script:
|
|
30
|
+
* const storage = new D1Store({ ...config, disableInit: false });
|
|
31
|
+
* await storage.init(); // Explicitly run migrations
|
|
32
|
+
*
|
|
33
|
+
* // In runtime application:
|
|
34
|
+
* const storage = new D1Store({ ...config, disableInit: true });
|
|
35
|
+
* // No auto-init, tables must already exist
|
|
36
|
+
*/
|
|
37
|
+
disableInit?: boolean;
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Configuration for D1 using the REST API
|
|
41
|
+
*/
|
|
42
|
+
export interface D1Config extends D1BaseConfig {
|
|
15
43
|
/** Cloudflare account ID */
|
|
16
44
|
accountId: string;
|
|
17
45
|
/** Cloudflare API token with D1 access */
|
|
18
46
|
apiToken: string;
|
|
19
47
|
/** D1 database ID */
|
|
20
48
|
databaseId: string;
|
|
21
|
-
/** Optional prefix for table names */
|
|
22
|
-
tablePrefix?: string;
|
|
23
49
|
}
|
|
24
|
-
export interface D1ClientConfig {
|
|
25
|
-
/** Storage instance ID */
|
|
26
|
-
id: string;
|
|
27
|
-
/** Optional prefix for table names */
|
|
28
|
-
tablePrefix?: string;
|
|
50
|
+
export interface D1ClientConfig extends D1BaseConfig {
|
|
29
51
|
/** D1 Client */
|
|
30
52
|
client: D1Client;
|
|
31
53
|
}
|
|
32
54
|
/**
|
|
33
55
|
* Configuration for D1 using the Workers Binding API
|
|
34
56
|
*/
|
|
35
|
-
export interface D1WorkersConfig {
|
|
36
|
-
/** Storage instance ID */
|
|
37
|
-
id: string;
|
|
57
|
+
export interface D1WorkersConfig extends D1BaseConfig {
|
|
38
58
|
/** D1 database binding from Workers environment */
|
|
39
59
|
binding: D1Database;
|
|
40
|
-
/** Optional prefix for table names */
|
|
41
|
-
tablePrefix?: string;
|
|
42
60
|
}
|
|
43
61
|
/**
|
|
44
62
|
* Combined configuration type supporting both REST API and Workers Binding API
|
|
@@ -53,6 +71,24 @@ export interface D1Client {
|
|
|
53
71
|
result: D1QueryResult;
|
|
54
72
|
}>;
|
|
55
73
|
}
|
|
74
|
+
/**
|
|
75
|
+
* Cloudflare D1 storage adapter for Mastra.
|
|
76
|
+
*
|
|
77
|
+
* Access domain-specific storage via `getStore()`:
|
|
78
|
+
*
|
|
79
|
+
* @example
|
|
80
|
+
* ```typescript
|
|
81
|
+
* const storage = new D1Store({ id: 'my-store', accountId: '...', apiToken: '...', databaseId: '...' });
|
|
82
|
+
*
|
|
83
|
+
* // Access memory domain
|
|
84
|
+
* const memory = await storage.getStore('memory');
|
|
85
|
+
* await memory?.saveThread({ thread });
|
|
86
|
+
*
|
|
87
|
+
* // Access workflows domain
|
|
88
|
+
* const workflows = await storage.getStore('workflows');
|
|
89
|
+
* await workflows?.persistWorkflowSnapshot({ workflowName, runId, snapshot });
|
|
90
|
+
* ```
|
|
91
|
+
*/
|
|
56
92
|
export declare class D1Store extends MastraStorage {
|
|
57
93
|
private client?;
|
|
58
94
|
private binding?;
|
|
@@ -63,164 +99,6 @@ export declare class D1Store extends MastraStorage {
|
|
|
63
99
|
* @param config Configuration for D1 access (either REST API or Workers Binding API)
|
|
64
100
|
*/
|
|
65
101
|
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
102
|
/**
|
|
225
103
|
* Close the database connection
|
|
226
104
|
* No explicit cleanup needed for D1 in either REST or Workers Binding mode
|
|
@@ -1 +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;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/storage/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,2BAA2B,CAAC;AAE5D,OAAO,EAAwB,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAC3E,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAC3D,OAAO,UAAU,MAAM,YAAY,CAAC;AACpC,OAAO,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AACnD,OAAO,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AACnD,OAAO,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAC;AAGzD,OAAO,EAAE,eAAe,EAAE,eAAe,EAAE,kBAAkB,EAAE,CAAC;AAChE,YAAY,EA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,EAAE,cAAc,CAAC;IAEvB;;;OAGG;gBACS,MAAM,EAAE,aAAa;IA6EjC;;;OAGG;IACG,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;CAI7B"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mastra/cloudflare-d1",
|
|
3
|
-
"version": "1.0.0-beta.
|
|
3
|
+
"version": "1.0.0-beta.10",
|
|
4
4
|
"description": "D1 provider for Mastra - includes db storage capabilities",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"files": [
|
|
@@ -27,20 +27,19 @@
|
|
|
27
27
|
},
|
|
28
28
|
"devDependencies": {
|
|
29
29
|
"@cloudflare/workers-types": "^4.20251111.0",
|
|
30
|
-
"@microsoft/api-extractor": "^7.52.8",
|
|
31
30
|
"@types/node": "22.13.17",
|
|
32
|
-
"@vitest/coverage-v8": "4.0.
|
|
33
|
-
"@vitest/ui": "4.0.
|
|
31
|
+
"@vitest/coverage-v8": "4.0.12",
|
|
32
|
+
"@vitest/ui": "4.0.12",
|
|
34
33
|
"dotenv": "^17.0.0",
|
|
35
34
|
"eslint": "^9.37.0",
|
|
36
35
|
"miniflare": "^4.20251109.0",
|
|
37
36
|
"tsup": "^8.5.0",
|
|
38
|
-
"typescript": "^5.
|
|
39
|
-
"vitest": "
|
|
40
|
-
"@internal/lint": "0.0.53",
|
|
37
|
+
"typescript": "^5.9.3",
|
|
38
|
+
"vitest": "4.0.16",
|
|
41
39
|
"@internal/storage-test-utils": "0.0.49",
|
|
42
40
|
"@internal/types-builder": "0.0.28",
|
|
43
|
-
"@
|
|
41
|
+
"@internal/lint": "0.0.53",
|
|
42
|
+
"@mastra/core": "1.0.0-beta.22"
|
|
44
43
|
},
|
|
45
44
|
"peerDependencies": {
|
|
46
45
|
"@mastra/core": ">=1.0.0-0 <2.0.0-0"
|
|
@@ -58,7 +57,8 @@
|
|
|
58
57
|
"node": ">=22.13.0"
|
|
59
58
|
},
|
|
60
59
|
"scripts": {
|
|
61
|
-
"build": "tsup --silent --config tsup.config.ts",
|
|
60
|
+
"build:lib": "tsup --silent --config tsup.config.ts",
|
|
61
|
+
"build:docs": "pnpx tsx ../../scripts/generate-package-docs.ts stores/cloudflare-d1",
|
|
62
62
|
"build:watch": "tsup --watch --silent --config tsup.config.ts",
|
|
63
63
|
"test": "vitest run",
|
|
64
64
|
"lint": "eslint ."
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/storage/domains/operations/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,2BAA2B,CAAC;AAE5D,OAAO,EAAE,eAAe,EAA2B,MAAM,sBAAsB,CAAC;AAChF,OAAO,KAAK,EAAE,WAAW,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AACvE,OAAO,KAAK,UAAU,MAAM,YAAY,CAAC;AAEzC,OAAO,KAAK,EAAY,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAGnE,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;AAED,MAAM,WAAW,uBAAuB;IACtC,MAAM,CAAC,EAAE,QAAQ,CAAC;IAClB,OAAO,CAAC,EAAE,UAAU,CAAC;IACrB,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAED,qBAAa,iBAAkB,SAAQ,eAAe;IACpD,OAAO,CAAC,MAAM,CAAC,CAAW;IAC1B,OAAO,CAAC,OAA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