@mastra/cloudflare-d1 0.0.0-remove-unused-model-providers-api-20251030210744 → 0.0.0-remove-ai-peer-dep-from-evals-20260105220639

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.
@@ -1,8 +1,8 @@
1
1
  import type { D1Database } from '@cloudflare/workers-types';
2
- import { StoreOperations } from '@mastra/core/storage';
2
+ import { MastraBase } from '@mastra/core/base';
3
3
  import type { TABLE_NAMES, StorageColumn } from '@mastra/core/storage';
4
- import type Cloudflare from 'cloudflare';
5
- import type { SqlQueryOptions } from '../../sql-builder.js';
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 StoreOperationsD1Config {
15
+ export interface D1DBConfig {
16
16
  client?: D1Client;
17
17
  binding?: D1Database;
18
18
  tablePrefix?: string;
19
19
  }
20
- export declare class StoreOperationsD1 extends StoreOperations {
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: StoreOperationsD1Config);
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,M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S,EAAE,IAAI,EAAE,EAAE;QAAE,SAAS,EAAE,WAAW,CAAC;QAAC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;KAAE,GAAG,OAAO,CAAC,CAAC,GAAG,IAAI,CAAC;IA+CzG,aAAa,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,OAAO,CAAC,MAAM,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"}
@@ -1,13 +1,13 @@
1
1
  import type { MastraMessageContentV2 } from '@mastra/core/agent';
2
- import type { MastraMessageV1, MastraMessageV2, StorageThreadType } from '@mastra/core/memory';
2
+ import type { MastraDBMessage, StorageThreadType } from '@mastra/core/memory';
3
3
  import { MemoryStorage } from '@mastra/core/storage';
4
- import type { PaginationInfo, StorageGetMessagesArg, StorageResourceType, StorageListMessagesInput, StorageListMessagesOutput, StorageListThreadsByResourceIdInput, StorageListThreadsByResourceIdOutput } from '@mastra/core/storage';
5
- import type { StoreOperationsD1 } from '../operations/index.js';
4
+ import type { StorageResourceType, StorageListMessagesInput, StorageListMessagesOutput, StorageListThreadsByResourceIdInput, StorageListThreadsByResourceIdOutput } from '@mastra/core/storage';
5
+ import type { D1DomainConfig } from '../../db/index.js';
6
6
  export declare class MemoryStorageD1 extends MemoryStorage {
7
- private operations;
8
- constructor({ operations }: {
9
- operations: StoreOperationsD1;
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>;
@@ -22,19 +22,7 @@ export declare class MemoryStorageD1 extends MemoryStorage {
22
22
  getThreadById({ threadId }: {
23
23
  threadId: string;
24
24
  }): Promise<StorageThreadType | null>;
25
- /**
26
- * @deprecated use getThreadsByResourceIdPaginated instead
27
- */
28
- getThreadsByResourceId({ resourceId }: {
29
- resourceId: string;
30
- }): Promise<StorageThreadType[]>;
31
- getThreadsByResourceIdPaginated(args: {
32
- resourceId: string;
33
- page: number;
34
- perPage: number;
35
- }): Promise<PaginationInfo & {
36
- threads: StorageThreadType[];
37
- }>;
25
+ listThreadsByResourceId(args: StorageListThreadsByResourceIdInput): Promise<StorageListThreadsByResourceIdOutput>;
38
26
  saveThread({ thread }: {
39
27
  thread: StorageThreadType;
40
28
  }): Promise<StorageThreadType>;
@@ -47,45 +35,26 @@ export declare class MemoryStorageD1 extends MemoryStorage {
47
35
  threadId: string;
48
36
  }): Promise<void>;
49
37
  saveMessages(args: {
50
- messages: MastraMessageV1[];
51
- format?: undefined | 'v1';
52
- }): Promise<MastraMessageV1[]>;
53
- saveMessages(args: {
54
- messages: MastraMessageV2[];
55
- format: 'v2';
56
- }): Promise<MastraMessageV2[]>;
38
+ messages: MastraDBMessage[];
39
+ }): Promise<{
40
+ messages: MastraDBMessage[];
41
+ }>;
57
42
  private _getIncludedMessages;
58
- /**
59
- * @deprecated use getMessagesPaginated instead
60
- */
61
- getMessages(args: StorageGetMessagesArg & {
62
- format?: 'v1';
63
- }): Promise<MastraMessageV1[]>;
64
- getMessages(args: StorageGetMessagesArg & {
65
- format: 'v2';
66
- }): Promise<MastraMessageV2[]>;
67
43
  listMessagesById({ messageIds }: {
68
44
  messageIds: string[];
69
- }): Promise<MastraMessageV2[]>;
70
- listMessages(args: StorageListMessagesInput): Promise<StorageListMessagesOutput>;
71
- /**
72
- * @todo When migrating from getThreadsByResourceIdPaginated to this method,
73
- * implement orderBy and sortDirection support for full sorting capabilities
74
- */
75
- listThreadsByResourceId(args: StorageListThreadsByResourceIdInput): Promise<StorageListThreadsByResourceIdOutput>;
76
- getMessagesPaginated({ threadId, resourceId, selectBy, format, }: StorageGetMessagesArg & {
77
- format?: 'v1' | 'v2';
78
- }): Promise<PaginationInfo & {
79
- messages: MastraMessageV1[] | MastraMessageV2[];
45
+ }): Promise<{
46
+ messages: MastraDBMessage[];
80
47
  }>;
48
+ listMessages(args: StorageListMessagesInput): Promise<StorageListMessagesOutput>;
81
49
  updateMessages(args: {
82
- messages: Partial<Omit<MastraMessageV2, 'createdAt'>> & {
50
+ messages: Partial<Omit<MastraDBMessage, 'createdAt'>> & {
83
51
  id: string;
84
52
  content?: {
85
53
  metadata?: MastraMessageContentV2['metadata'];
86
54
  content?: MastraMessageContentV2['content'];
87
55
  };
88
56
  }[];
89
- }): Promise<MastraMessageV2[]>;
57
+ }): Promise<MastraDBMessage[]>;
58
+ deleteMessages(messageIds: string[]): Promise<void>;
90
59
  }
91
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,oBAAoB,CAAC;AAEjE,OAAO,KAAK,EAAE,eAAe,EAAE,eAAe,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AAC/F,OAAO,EAEL,aAAa,EAMd,MAAM,sBAAsB,CAAC;AAC9B,OAAO,KAAK,EACV,cAAc,EACd,qBAAqB,EACrB,mBAAmB,EACnB,wBAAwB,EACxB,yBAAyB,EACzB,mCAAmC,EACnC,oCAAoC,EACrC,MAAM,sBAAsB,CAAC;AAE9B,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAC;AAGvD,qBAAa,eAAgB,SAAQ,aAAa;IAChD,OAAO,CAAC,UAAU,CAAoB;gBAC1B,EAAE,UAAU,EAAE,EAAE;QAAE,UAAU,EAAE,iBAAiB,CAAA;KAAE;IAKvD,eAAe,CAAC,EAAE,UA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C,yBAAyB,CAAC;IA0NvF,cAAc,CAAC,IAAI,EAAE;QACzB,QAAQ,EAAE,OAAO,CAAC,IAAI,CAAC,eAAe,EAAE,WAAW,CAAC,CAAC,GACnD;YACE,EAAE,EAAE,MAAM,CAAC;YACX,OAAO,CAAC,EAAE;gBACR,QAAQ,CAAC,EAAE,sBAAsB,CAAC,UAAU,CAAC,CAAC;gBAC9C,OAAO,CAAC,EAAE,sBAAsB,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,60 +1,38 @@
1
- import type { ScoreRowData, ScoringSource } from '@mastra/core/scores';
1
+ import type { ListScoresResponse, SaveScorePayload, ScoreRowData, ScoringSource } from '@mastra/core/evals';
2
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
- }
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 operations;
17
- constructor({ operations }: {
18
- operations: StoreOperationsD1;
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: Omit<ScoreRowData, 'createdAt' | 'updatedAt'>): Promise<{
13
+ saveScore(score: SaveScorePayload): Promise<{
24
14
  score: ScoreRowData;
25
15
  }>;
26
- getScoresByScorerId({ scorerId, entityId, entityType, source, pagination, }: {
16
+ listScoresByScorerId({ scorerId, entityId, entityType, source, pagination, }: {
27
17
  scorerId: string;
28
18
  entityId?: string;
29
19
  entityType?: string;
30
20
  source?: ScoringSource;
31
21
  pagination: StoragePagination;
32
- }): Promise<{
33
- pagination: PaginationInfo;
34
- scores: ScoreRowData[];
35
- }>;
36
- getScoresByRunId({ runId, pagination, }: {
22
+ }): Promise<ListScoresResponse>;
23
+ listScoresByRunId({ runId, pagination, }: {
37
24
  runId: string;
38
25
  pagination: StoragePagination;
39
- }): Promise<{
40
- pagination: PaginationInfo;
41
- scores: ScoreRowData[];
42
- }>;
43
- getScoresByEntityId({ entityId, entityType, pagination, }: {
26
+ }): Promise<ListScoresResponse>;
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
- }>;
51
- getScoresBySpan({ traceId, spanId, pagination, }: {
31
+ }): Promise<ListScoresResponse>;
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,EAA6B,MAAM,qBAAqB,CAAC;AAElG,OAAO,EAAE,aAAa,EAAkC,MAAM,sBAAsB,CAAC;AACrF,OAAO,KAAK,EAAE,iBAAiB,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAC9E,OAAO,KAA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AY,CAAC,EAAE,EAAE,EAAE,EAAE;QAAE,EAAE,EAAE,MAAM,CAAA;KAAE,GAAG,OAAO,CAAC,YAAY,GAAG,IAAI,CAAC;IAyBlE,SAAS,CAAC,KAAK,EAAE,gBAAgB,GAAG,OAAO,CAAC;QAAE,KAAK,EAAE,YAAY,CAAA;KAAE,CAAC;IAoEpE,oBAAoB,CAAC,EACzB,QAAQ,EACR,QAAQ,EACR,UAAU,EACV,MAAM,EACN,UAAU,GACX,EAAE;QACD,QAAQ,EAAE,MAAM,CAAC;QACjB,QAAQ,CAAC,EAAE,MAAM,CAAC;QAClB,UAAU,CAAC,EAAE,MAAM,CAAC;QACpB,MAAM,CAAC,EAAE,aAAa,CAAC;QACvB,UAAU,EAAE,iBAAiB,CAAC;KAC/B,GAAG,OAAO,CAAC,kBAAkB,CAAC;IA6EzB,iBAAiB,CAAC,EACtB,KAAK,EACL,UAAU,GACX,EAAE;QACD,KAAK,EAAE,MAAM,CAAC;QACd,UAAU,EAAE,iBAAiB,CAAC;KAC/B,GAAG,OAAO,CAAC,kBAAkB,CAAC;IA8DzB,oBAAoB,CAAC,EACzB,QAAQ,EACR,UAAU,EACV,UAAU,GACX,EAAE;QACD,UAAU,EAAE,iBAAiB,CAAC;QAC9B,QAAQ,EAAE,MAAM,CAAC;QACjB,UAAU,EAAE,MAAM,CAAC;KACpB,GAAG,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 { StoreOperationsD1 } from '../operations/index.js';
4
+ import type { D1DomainConfig } from '../../db/index.js';
5
5
  export declare class WorkflowsStorageD1 extends WorkflowsStorage {
6
- private operations;
7
- constructor({ operations }: {
8
- operations: StoreOperationsD1;
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,29 +17,29 @@ 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;
36
32
  runId: string;
37
33
  }): Promise<WorkflowRunState | null>;
38
34
  private parseWorkflowRun;
39
- listWorkflowRuns({ workflowName, fromDate, toDate, limit, offset, resourceId, }?: StorageListWorkflowRunsInput): Promise<WorkflowRuns>;
35
+ listWorkflowRuns({ workflowName, fromDate, toDate, page, perPage, resourceId, status, }?: StorageListWorkflowRunsInput): Promise<WorkflowRuns>;
40
36
  getWorkflowRunById({ runId, workflowName, }: {
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,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,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,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;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"}
@@ -1,38 +1,62 @@
1
1
  import type { D1Database } from '@cloudflare/workers-types';
2
- import type { MastraMessageContentV2 } from '@mastra/core/agent';
3
- import type { StorageThreadType, MastraMessageV1, MastraMessageV2 } from '@mastra/core/memory';
4
- import type { ScoreRowData, ScoringSource } from '@mastra/core/scores';
5
2
  import { MastraStorage } from '@mastra/core/storage';
6
- import type { PaginationInfo, StorageColumn, StorageGetMessagesArg, StorageResourceType, TABLE_NAMES, WorkflowRun, StoragePagination, WorkflowRuns, StorageDomains } from '@mastra/core/storage';
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';
10
+ /**
11
+ * Base configuration options shared across D1 configurations
12
+ */
13
+ export interface D1BaseConfig {
14
+ /** Storage instance ID */
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
+ }
9
39
  /**
10
40
  * Configuration for D1 using the REST API
11
41
  */
12
- export interface D1Config {
42
+ export interface D1Config extends D1BaseConfig {
13
43
  /** Cloudflare account ID */
14
44
  accountId: string;
15
45
  /** Cloudflare API token with D1 access */
16
46
  apiToken: string;
17
47
  /** D1 database ID */
18
48
  databaseId: string;
19
- /** Optional prefix for table names */
20
- tablePrefix?: string;
21
49
  }
22
- export interface D1ClientConfig {
23
- /** Optional prefix for table names */
24
- tablePrefix?: string;
50
+ export interface D1ClientConfig extends D1BaseConfig {
25
51
  /** D1 Client */
26
52
  client: D1Client;
27
53
  }
28
54
  /**
29
55
  * Configuration for D1 using the Workers Binding API
30
56
  */
31
- export interface D1WorkersConfig {
57
+ export interface D1WorkersConfig extends D1BaseConfig {
32
58
  /** D1 database binding from Workers environment */
33
59
  binding: D1Database;
34
- /** Optional prefix for table names */
35
- tablePrefix?: string;
36
60
  }
37
61
  /**
38
62
  * Combined configuration type supporting both REST API and Workers Binding API
@@ -47,6 +71,24 @@ export interface D1Client {
47
71
  result: D1QueryResult;
48
72
  }>;
49
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
+ */
50
92
  export declare class D1Store extends MastraStorage {
51
93
  private client?;
52
94
  private binding?;
@@ -57,201 +99,6 @@ export declare class D1Store extends MastraStorage {
57
99
  * @param config Configuration for D1 access (either REST API or Workers Binding API)
58
100
  */
59
101
  constructor(config: D1StoreConfig);
60
- get supports(): {
61
- selectByIncludeResourceScope: boolean;
62
- resourceWorkingMemory: boolean;
63
- hasColumn: boolean;
64
- createTable: boolean;
65
- deleteMessages: boolean;
66
- getScoresBySpan: boolean;
67
- };
68
- createTable({ tableName, schema, }: {
69
- tableName: TABLE_NAMES;
70
- schema: Record<string, StorageColumn>;
71
- }): Promise<void>;
72
- /**
73
- * Alters table schema to add columns if they don't exist
74
- * @param tableName Name of the table
75
- * @param schema Schema of the table
76
- * @param ifNotExists Array of column names to add if they don't exist
77
- */
78
- alterTable({ tableName, schema, ifNotExists, }: {
79
- tableName: TABLE_NAMES;
80
- schema: Record<string, StorageColumn>;
81
- ifNotExists: string[];
82
- }): Promise<void>;
83
- clearTable({ tableName }: {
84
- tableName: TABLE_NAMES;
85
- }): Promise<void>;
86
- dropTable({ tableName }: {
87
- tableName: TABLE_NAMES;
88
- }): Promise<void>;
89
- hasColumn(table: string, column: string): Promise<boolean>;
90
- insert({ tableName, record }: {
91
- tableName: TABLE_NAMES;
92
- record: Record<string, any>;
93
- }): Promise<void>;
94
- load<R>({ tableName, keys }: {
95
- tableName: TABLE_NAMES;
96
- keys: Record<string, string>;
97
- }): Promise<R | null>;
98
- getThreadById({ threadId }: {
99
- threadId: string;
100
- }): Promise<StorageThreadType | null>;
101
- /**
102
- * @deprecated use getThreadsByResourceIdPaginated instead
103
- */
104
- getThreadsByResourceId({ resourceId }: {
105
- resourceId: string;
106
- }): Promise<StorageThreadType[]>;
107
- getThreadsByResourceIdPaginated(args: {
108
- resourceId: string;
109
- page: number;
110
- perPage: number;
111
- }): Promise<PaginationInfo & {
112
- threads: StorageThreadType[];
113
- }>;
114
- saveThread({ thread }: {
115
- thread: StorageThreadType;
116
- }): Promise<StorageThreadType>;
117
- updateThread({ id, title, metadata, }: {
118
- id: string;
119
- title: string;
120
- metadata: Record<string, unknown>;
121
- }): Promise<StorageThreadType>;
122
- deleteThread({ threadId }: {
123
- threadId: string;
124
- }): Promise<void>;
125
- saveMessages(args: {
126
- messages: MastraMessageV1[];
127
- format?: undefined | 'v1';
128
- }): Promise<MastraMessageV1[]>;
129
- saveMessages(args: {
130
- messages: MastraMessageV2[];
131
- format: 'v2';
132
- }): Promise<MastraMessageV2[]>;
133
- /**
134
- * @deprecated use getMessagesPaginated instead
135
- */
136
- getMessages(args: StorageGetMessagesArg & {
137
- format?: 'v1';
138
- }): Promise<MastraMessageV1[]>;
139
- getMessages(args: StorageGetMessagesArg & {
140
- format: 'v2';
141
- }): Promise<MastraMessageV2[]>;
142
- getMessagesPaginated({ threadId, selectBy, format, }: StorageGetMessagesArg & {
143
- format?: 'v1' | 'v2';
144
- }): Promise<PaginationInfo & {
145
- messages: MastraMessageV1[] | MastraMessageV2[];
146
- }>;
147
- updateWorkflowResults({ workflowName, runId, stepId, result, requestContext, }: {
148
- workflowName: string;
149
- runId: string;
150
- stepId: string;
151
- result: StepResult<any, any, any, any>;
152
- requestContext: Record<string, any>;
153
- }): Promise<Record<string, StepResult<any, any, any, any>>>;
154
- updateWorkflowState({ workflowName, runId, opts, }: {
155
- workflowName: string;
156
- runId: string;
157
- opts: {
158
- status: string;
159
- result?: StepResult<any, any, any, any>;
160
- error?: string;
161
- suspendedPaths?: Record<string, number[]>;
162
- waitingPaths?: Record<string, number[]>;
163
- };
164
- }): Promise<WorkflowRunState | undefined>;
165
- persistWorkflowSnapshot({ workflowName, runId, resourceId, snapshot, }: {
166
- workflowName: string;
167
- runId: string;
168
- resourceId?: string;
169
- snapshot: WorkflowRunState;
170
- }): Promise<void>;
171
- loadWorkflowSnapshot(params: {
172
- workflowName: string;
173
- runId: string;
174
- }): Promise<WorkflowRunState | null>;
175
- listWorkflowRuns({ workflowName, fromDate, toDate, limit, offset, resourceId, }?: {
176
- workflowName?: string;
177
- fromDate?: Date;
178
- toDate?: Date;
179
- limit?: number;
180
- offset?: number;
181
- resourceId?: string;
182
- }): Promise<WorkflowRuns>;
183
- getWorkflowRunById({ runId, workflowName, }: {
184
- runId: string;
185
- workflowName?: string;
186
- }): Promise<WorkflowRun | null>;
187
- /**
188
- * Insert multiple records in a batch operation
189
- * @param tableName The table to insert into
190
- * @param records The records to insert
191
- */
192
- batchInsert({ tableName, records }: {
193
- tableName: TABLE_NAMES;
194
- records: Record<string, any>[];
195
- }): Promise<void>;
196
- updateMessages(_args: {
197
- messages: Partial<Omit<MastraMessageV2, 'createdAt'>> & {
198
- id: string;
199
- content?: {
200
- metadata?: MastraMessageContentV2['metadata'];
201
- content?: MastraMessageContentV2['content'];
202
- };
203
- }[];
204
- }): Promise<MastraMessageV2[]>;
205
- getResourceById({ resourceId }: {
206
- resourceId: string;
207
- }): Promise<StorageResourceType | null>;
208
- saveResource({ resource }: {
209
- resource: StorageResourceType;
210
- }): Promise<StorageResourceType>;
211
- updateResource({ resourceId, workingMemory, metadata, }: {
212
- resourceId: string;
213
- workingMemory?: string;
214
- metadata?: Record<string, unknown>;
215
- }): Promise<StorageResourceType>;
216
- getScoreById({ id: _id }: {
217
- id: string;
218
- }): Promise<ScoreRowData | null>;
219
- saveScore(_score: ScoreRowData): Promise<{
220
- score: ScoreRowData;
221
- }>;
222
- getScoresByRunId({ runId: _runId, pagination: _pagination, }: {
223
- runId: string;
224
- pagination: StoragePagination;
225
- }): Promise<{
226
- pagination: PaginationInfo;
227
- scores: ScoreRowData[];
228
- }>;
229
- getScoresByEntityId({ entityId: _entityId, entityType: _entityType, pagination: _pagination, }: {
230
- pagination: StoragePagination;
231
- entityId: string;
232
- entityType: string;
233
- }): Promise<{
234
- pagination: PaginationInfo;
235
- scores: ScoreRowData[];
236
- }>;
237
- getScoresByScorerId({ scorerId, pagination, entityId, entityType, source, }: {
238
- scorerId: string;
239
- pagination: StoragePagination;
240
- entityId?: string;
241
- entityType?: string;
242
- source?: ScoringSource;
243
- }): Promise<{
244
- pagination: PaginationInfo;
245
- scores: ScoreRowData[];
246
- }>;
247
- getScoresBySpan({ traceId, spanId, pagination, }: {
248
- traceId: string;
249
- spanId: string;
250
- pagination: StoragePagination;
251
- }): Promise<{
252
- pagination: PaginationInfo;
253
- scores: ScoreRowData[];
254
- }>;
255
102
  /**
256
103
  * Close the database connection
257
104
  * No explicit cleanup needed for D1 in either REST or Workers Binding mode