@mastra/cloudflare 0.0.0-vnext-inngest-20250508131921 → 0.0.0-vnextAgentNetwork-20250527091247
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/_tsup-dts-rollup.d.cts +14 -0
- package/dist/_tsup-dts-rollup.d.ts +14 -0
- package/dist/index.cjs +47 -13
- package/dist/index.js +47 -13
- package/package.json +7 -4
|
@@ -55,6 +55,20 @@ declare class CloudflareStore extends MastraStorage {
|
|
|
55
55
|
private createNamespace;
|
|
56
56
|
private getOrCreateNamespaceId;
|
|
57
57
|
private getNamespaceId;
|
|
58
|
+
private LEGACY_NAMESPACE_MAP;
|
|
59
|
+
/**
|
|
60
|
+
* There were a few legacy mappings for tables such as
|
|
61
|
+
* - messages -> threads
|
|
62
|
+
* - workflow_snapshot -> mastra_workflows
|
|
63
|
+
* - traces -> evals
|
|
64
|
+
* This has been updated to use dedicated namespaces for each table.
|
|
65
|
+
* In the case of data for a table existing in the legacy namespace, warn the user to migrate to the new namespace.
|
|
66
|
+
*
|
|
67
|
+
* @param tableName The table name to check for legacy data
|
|
68
|
+
* @param prefix The namespace prefix
|
|
69
|
+
* @returns The legacy namespace ID if data exists; otherwise, null
|
|
70
|
+
*/
|
|
71
|
+
private checkLegacyNamespace;
|
|
58
72
|
/**
|
|
59
73
|
* Helper to safely serialize data for KV storage
|
|
60
74
|
*/
|
|
@@ -55,6 +55,20 @@ declare class CloudflareStore extends MastraStorage {
|
|
|
55
55
|
private createNamespace;
|
|
56
56
|
private getOrCreateNamespaceId;
|
|
57
57
|
private getNamespaceId;
|
|
58
|
+
private LEGACY_NAMESPACE_MAP;
|
|
59
|
+
/**
|
|
60
|
+
* There were a few legacy mappings for tables such as
|
|
61
|
+
* - messages -> threads
|
|
62
|
+
* - workflow_snapshot -> mastra_workflows
|
|
63
|
+
* - traces -> evals
|
|
64
|
+
* This has been updated to use dedicated namespaces for each table.
|
|
65
|
+
* In the case of data for a table existing in the legacy namespace, warn the user to migrate to the new namespace.
|
|
66
|
+
*
|
|
67
|
+
* @param tableName The table name to check for legacy data
|
|
68
|
+
* @param prefix The namespace prefix
|
|
69
|
+
* @returns The legacy namespace ID if data exists; otherwise, null
|
|
70
|
+
*/
|
|
71
|
+
private checkLegacyNamespace;
|
|
58
72
|
/**
|
|
59
73
|
* Helper to safely serialize data for KV storage
|
|
60
74
|
*/
|
package/dist/index.cjs
CHANGED
|
@@ -219,18 +219,57 @@ var CloudflareStore = class extends storage.MastraStorage {
|
|
|
219
219
|
async getNamespaceId(tableName) {
|
|
220
220
|
const prefix = this.namespacePrefix ? `${this.namespacePrefix}_` : "";
|
|
221
221
|
try {
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
return await this.getOrCreateNamespaceId(`${prefix}mastra_workflows`);
|
|
226
|
-
} else {
|
|
227
|
-
return await this.getOrCreateNamespaceId(`${prefix}mastra_evals`);
|
|
222
|
+
const legacyNamespaceId = await this.checkLegacyNamespace(tableName, prefix);
|
|
223
|
+
if (legacyNamespaceId) {
|
|
224
|
+
return legacyNamespaceId;
|
|
228
225
|
}
|
|
226
|
+
return await this.getOrCreateNamespaceId(`${prefix}${tableName}`);
|
|
229
227
|
} catch (error) {
|
|
230
228
|
this.logger.error("Error fetching namespace ID:", error);
|
|
231
229
|
throw new Error(`Failed to fetch namespace ID for table ${tableName}: ${error.message}`);
|
|
232
230
|
}
|
|
233
231
|
}
|
|
232
|
+
LEGACY_NAMESPACE_MAP = {
|
|
233
|
+
[storage.TABLE_MESSAGES]: storage.TABLE_THREADS,
|
|
234
|
+
[storage.TABLE_WORKFLOW_SNAPSHOT]: "mastra_workflows",
|
|
235
|
+
[storage.TABLE_TRACES]: storage.TABLE_EVALS
|
|
236
|
+
};
|
|
237
|
+
/**
|
|
238
|
+
* There were a few legacy mappings for tables such as
|
|
239
|
+
* - messages -> threads
|
|
240
|
+
* - workflow_snapshot -> mastra_workflows
|
|
241
|
+
* - traces -> evals
|
|
242
|
+
* This has been updated to use dedicated namespaces for each table.
|
|
243
|
+
* In the case of data for a table existing in the legacy namespace, warn the user to migrate to the new namespace.
|
|
244
|
+
*
|
|
245
|
+
* @param tableName The table name to check for legacy data
|
|
246
|
+
* @param prefix The namespace prefix
|
|
247
|
+
* @returns The legacy namespace ID if data exists; otherwise, null
|
|
248
|
+
*/
|
|
249
|
+
async checkLegacyNamespace(tableName, prefix) {
|
|
250
|
+
const legacyNamespaceBase = this.LEGACY_NAMESPACE_MAP[tableName];
|
|
251
|
+
if (legacyNamespaceBase) {
|
|
252
|
+
const legacyNamespace = `${prefix}${legacyNamespaceBase}`;
|
|
253
|
+
const keyPrefix = this.namespacePrefix ? `${this.namespacePrefix}:` : "";
|
|
254
|
+
const prefixKey = `${keyPrefix}${tableName}:`;
|
|
255
|
+
const legacyId = await this.getNamespaceIdByName(legacyNamespace);
|
|
256
|
+
if (legacyId) {
|
|
257
|
+
const response = await this.client.kv.namespaces.keys.list(legacyId, {
|
|
258
|
+
account_id: this.accountId,
|
|
259
|
+
prefix: prefixKey
|
|
260
|
+
});
|
|
261
|
+
const keys = response.result;
|
|
262
|
+
const hasTableData = keys.length > 0;
|
|
263
|
+
if (hasTableData) {
|
|
264
|
+
this.logger.warn(
|
|
265
|
+
`Using legacy namespace "${legacyNamespace}" for ${tableName}. Consider migrating to a dedicated namespace "${prefix}${tableName}".`
|
|
266
|
+
);
|
|
267
|
+
return legacyId;
|
|
268
|
+
}
|
|
269
|
+
}
|
|
270
|
+
}
|
|
271
|
+
return null;
|
|
272
|
+
}
|
|
234
273
|
/**
|
|
235
274
|
* Helper to safely serialize data for KV storage
|
|
236
275
|
*/
|
|
@@ -866,7 +905,7 @@ var CloudflareStore = class extends storage.MastraStorage {
|
|
|
866
905
|
}
|
|
867
906
|
}
|
|
868
907
|
validateWorkflowState(state) {
|
|
869
|
-
if (!state?.runId || !state?.value || !state?.context?.
|
|
908
|
+
if (!state?.runId || !state?.value || !state?.context?.input || !state?.activePaths) {
|
|
870
909
|
throw new Error("Invalid workflow state structure");
|
|
871
910
|
}
|
|
872
911
|
}
|
|
@@ -882,15 +921,10 @@ var CloudflareStore = class extends storage.MastraStorage {
|
|
|
882
921
|
return normalizedSteps;
|
|
883
922
|
}
|
|
884
923
|
normalizeWorkflowState(data) {
|
|
885
|
-
const steps = data.context?.stepResults || data.context?.steps || {};
|
|
886
924
|
return {
|
|
887
925
|
runId: data.runId,
|
|
888
926
|
value: data.value,
|
|
889
|
-
context:
|
|
890
|
-
steps: this.normalizeSteps(steps),
|
|
891
|
-
triggerData: data.context?.triggerData || {},
|
|
892
|
-
attempts: data.context?.attempts || {}
|
|
893
|
-
},
|
|
927
|
+
context: data.context,
|
|
894
928
|
suspendedPaths: data.suspendedPaths || {},
|
|
895
929
|
activePaths: data.activePaths || [],
|
|
896
930
|
timestamp: data.timestamp || Date.now()
|
package/dist/index.js
CHANGED
|
@@ -213,18 +213,57 @@ var CloudflareStore = class extends MastraStorage {
|
|
|
213
213
|
async getNamespaceId(tableName) {
|
|
214
214
|
const prefix = this.namespacePrefix ? `${this.namespacePrefix}_` : "";
|
|
215
215
|
try {
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
return await this.getOrCreateNamespaceId(`${prefix}mastra_workflows`);
|
|
220
|
-
} else {
|
|
221
|
-
return await this.getOrCreateNamespaceId(`${prefix}mastra_evals`);
|
|
216
|
+
const legacyNamespaceId = await this.checkLegacyNamespace(tableName, prefix);
|
|
217
|
+
if (legacyNamespaceId) {
|
|
218
|
+
return legacyNamespaceId;
|
|
222
219
|
}
|
|
220
|
+
return await this.getOrCreateNamespaceId(`${prefix}${tableName}`);
|
|
223
221
|
} catch (error) {
|
|
224
222
|
this.logger.error("Error fetching namespace ID:", error);
|
|
225
223
|
throw new Error(`Failed to fetch namespace ID for table ${tableName}: ${error.message}`);
|
|
226
224
|
}
|
|
227
225
|
}
|
|
226
|
+
LEGACY_NAMESPACE_MAP = {
|
|
227
|
+
[TABLE_MESSAGES]: TABLE_THREADS,
|
|
228
|
+
[TABLE_WORKFLOW_SNAPSHOT]: "mastra_workflows",
|
|
229
|
+
[TABLE_TRACES]: TABLE_EVALS
|
|
230
|
+
};
|
|
231
|
+
/**
|
|
232
|
+
* There were a few legacy mappings for tables such as
|
|
233
|
+
* - messages -> threads
|
|
234
|
+
* - workflow_snapshot -> mastra_workflows
|
|
235
|
+
* - traces -> evals
|
|
236
|
+
* This has been updated to use dedicated namespaces for each table.
|
|
237
|
+
* In the case of data for a table existing in the legacy namespace, warn the user to migrate to the new namespace.
|
|
238
|
+
*
|
|
239
|
+
* @param tableName The table name to check for legacy data
|
|
240
|
+
* @param prefix The namespace prefix
|
|
241
|
+
* @returns The legacy namespace ID if data exists; otherwise, null
|
|
242
|
+
*/
|
|
243
|
+
async checkLegacyNamespace(tableName, prefix) {
|
|
244
|
+
const legacyNamespaceBase = this.LEGACY_NAMESPACE_MAP[tableName];
|
|
245
|
+
if (legacyNamespaceBase) {
|
|
246
|
+
const legacyNamespace = `${prefix}${legacyNamespaceBase}`;
|
|
247
|
+
const keyPrefix = this.namespacePrefix ? `${this.namespacePrefix}:` : "";
|
|
248
|
+
const prefixKey = `${keyPrefix}${tableName}:`;
|
|
249
|
+
const legacyId = await this.getNamespaceIdByName(legacyNamespace);
|
|
250
|
+
if (legacyId) {
|
|
251
|
+
const response = await this.client.kv.namespaces.keys.list(legacyId, {
|
|
252
|
+
account_id: this.accountId,
|
|
253
|
+
prefix: prefixKey
|
|
254
|
+
});
|
|
255
|
+
const keys = response.result;
|
|
256
|
+
const hasTableData = keys.length > 0;
|
|
257
|
+
if (hasTableData) {
|
|
258
|
+
this.logger.warn(
|
|
259
|
+
`Using legacy namespace "${legacyNamespace}" for ${tableName}. Consider migrating to a dedicated namespace "${prefix}${tableName}".`
|
|
260
|
+
);
|
|
261
|
+
return legacyId;
|
|
262
|
+
}
|
|
263
|
+
}
|
|
264
|
+
}
|
|
265
|
+
return null;
|
|
266
|
+
}
|
|
228
267
|
/**
|
|
229
268
|
* Helper to safely serialize data for KV storage
|
|
230
269
|
*/
|
|
@@ -860,7 +899,7 @@ var CloudflareStore = class extends MastraStorage {
|
|
|
860
899
|
}
|
|
861
900
|
}
|
|
862
901
|
validateWorkflowState(state) {
|
|
863
|
-
if (!state?.runId || !state?.value || !state?.context?.
|
|
902
|
+
if (!state?.runId || !state?.value || !state?.context?.input || !state?.activePaths) {
|
|
864
903
|
throw new Error("Invalid workflow state structure");
|
|
865
904
|
}
|
|
866
905
|
}
|
|
@@ -876,15 +915,10 @@ var CloudflareStore = class extends MastraStorage {
|
|
|
876
915
|
return normalizedSteps;
|
|
877
916
|
}
|
|
878
917
|
normalizeWorkflowState(data) {
|
|
879
|
-
const steps = data.context?.stepResults || data.context?.steps || {};
|
|
880
918
|
return {
|
|
881
919
|
runId: data.runId,
|
|
882
920
|
value: data.value,
|
|
883
|
-
context:
|
|
884
|
-
steps: this.normalizeSteps(steps),
|
|
885
|
-
triggerData: data.context?.triggerData || {},
|
|
886
|
-
attempts: data.context?.attempts || {}
|
|
887
|
-
},
|
|
921
|
+
context: data.context,
|
|
888
922
|
suspendedPaths: data.suspendedPaths || {},
|
|
889
923
|
activePaths: data.activePaths || [],
|
|
890
924
|
timestamp: data.timestamp || Date.now()
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mastra/cloudflare",
|
|
3
|
-
"version": "0.0.0-
|
|
3
|
+
"version": "0.0.0-vnextAgentNetwork-20250527091247",
|
|
4
4
|
"description": "Cloudflare provider for Mastra - includes db storage capabilities",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"files": [
|
|
@@ -23,8 +23,7 @@
|
|
|
23
23
|
},
|
|
24
24
|
"license": "MIT",
|
|
25
25
|
"dependencies": {
|
|
26
|
-
"cloudflare": "^4.1.0"
|
|
27
|
-
"@mastra/core": "0.0.0-vnext-inngest-20250508131921"
|
|
26
|
+
"cloudflare": "^4.1.0"
|
|
28
27
|
},
|
|
29
28
|
"devDependencies": {
|
|
30
29
|
"@cloudflare/workers-types": "^4.20250313.0",
|
|
@@ -36,7 +35,11 @@
|
|
|
36
35
|
"tsup": "^8.4.0",
|
|
37
36
|
"typescript": "^5.8.2",
|
|
38
37
|
"vitest": "^3.1.2",
|
|
39
|
-
"@internal/lint": "0.0.0-
|
|
38
|
+
"@internal/lint": "0.0.0-vnextAgentNetwork-20250527091247",
|
|
39
|
+
"@mastra/core": "0.0.0-vnextAgentNetwork-20250527091247"
|
|
40
|
+
},
|
|
41
|
+
"peerDependencies": {
|
|
42
|
+
"@mastra/core": "^0.10.0"
|
|
40
43
|
},
|
|
41
44
|
"scripts": {
|
|
42
45
|
"build": "tsup src/index.ts --format esm,cjs --experimental-dts --clean --treeshake=smallest --splitting",
|