@mastra/playground-ui 22.0.0 → 22.0.1-alpha.1
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 +21 -0
- package/dist/index.cjs.js +57 -3
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.es.js +56 -4
- package/dist/index.es.js.map +1 -1
- package/dist/src/domains/auth/hooks/fetch-with-refresh.d.ts +25 -0
- package/dist/src/domains/auth/hooks/index.d.ts +1 -0
- package/dist/src/domains/auth/hooks/use-current-user.d.ts +3 -0
- package/dist/src/ds/components/CodeEditor/code-editor.d.ts +4 -0
- package/package.json +9 -9
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,26 @@
|
|
|
1
1
|
# @mastra/playground-ui
|
|
2
2
|
|
|
3
|
+
## 22.0.1-alpha.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Updated dependencies [[`f32b9e1`](https://github.com/mastra-ai/mastra/commit/f32b9e115a3c754d1c8cfa3f4256fba87b09cfb7)]:
|
|
8
|
+
- @mastra/core@1.23.0-alpha.1
|
|
9
|
+
- @mastra/client-js@1.13.1-alpha.1
|
|
10
|
+
- @mastra/react@0.2.23-alpha.1
|
|
11
|
+
|
|
12
|
+
## 22.0.1-alpha.0
|
|
13
|
+
|
|
14
|
+
### Patch Changes
|
|
15
|
+
|
|
16
|
+
- Expired sessions now refresh automatically. Requests that previously returned 401 are retried after refreshing, so users stay signed in instead of being logged out. ([#15024](https://github.com/mastra-ai/mastra/pull/15024))
|
|
17
|
+
|
|
18
|
+
- Updated dependencies [[`ed425d7`](https://github.com/mastra-ai/mastra/commit/ed425d78e7c66cbda8209fee910856f98c6c6b82), [`ba6f7e9`](https://github.com/mastra-ai/mastra/commit/ba6f7e9086d8281393f2acae60fda61de3bff1f9), [`7eb2596`](https://github.com/mastra-ai/mastra/commit/7eb25960d607e07468c9a10c5437abd2deaf1e9a)]:
|
|
19
|
+
- @mastra/core@1.23.0-alpha.0
|
|
20
|
+
- @mastra/client-js@1.13.1-alpha.0
|
|
21
|
+
- @mastra/ai-sdk@1.3.1
|
|
22
|
+
- @mastra/react@0.2.23-alpha.0
|
|
23
|
+
|
|
3
24
|
## 22.0.0
|
|
4
25
|
|
|
5
26
|
### Minor Changes
|
package/dist/index.cjs.js
CHANGED
|
@@ -21,6 +21,7 @@ const langJson = require('@codemirror/lang-json');
|
|
|
21
21
|
const langMarkdown = require('@codemirror/lang-markdown');
|
|
22
22
|
const language = require('@codemirror/language');
|
|
23
23
|
const languageData = require('@codemirror/language-data');
|
|
24
|
+
const state = require('@codemirror/state');
|
|
24
25
|
const view = require('@codemirror/view');
|
|
25
26
|
const highlight$1 = require('@lezer/highlight');
|
|
26
27
|
const codemirrorThemeDracula = require('@uiw/codemirror-theme-dracula');
|
|
@@ -77,7 +78,6 @@ const features = require('@mastra/core/features');
|
|
|
77
78
|
const storage = require('@mastra/core/storage');
|
|
78
79
|
const cmdk = require('cmdk');
|
|
79
80
|
const merge = require('@codemirror/merge');
|
|
80
|
-
const state = require('@codemirror/state');
|
|
81
81
|
const reactSyntaxHighlighter$1 = require('react-syntax-highlighter');
|
|
82
82
|
const compatibility = require('./compatibility-BSEoV343.cjs');
|
|
83
83
|
|
|
@@ -5774,6 +5774,7 @@ const CodeEditor = React.forwardRef(
|
|
|
5774
5774
|
schema,
|
|
5775
5775
|
autoFocus,
|
|
5776
5776
|
lineNumbers = true,
|
|
5777
|
+
editable,
|
|
5777
5778
|
...props
|
|
5778
5779
|
}, ref) => {
|
|
5779
5780
|
const theme = useCodemirrorTheme$2();
|
|
@@ -5792,8 +5793,11 @@ const CodeEditor = React.forwardRef(
|
|
|
5792
5793
|
if (schema && language === "markdown") {
|
|
5793
5794
|
exts.push(createVariableAutocomplete(schema));
|
|
5794
5795
|
}
|
|
5796
|
+
if (editable === false) {
|
|
5797
|
+
exts.push(state.EditorState.readOnly.of(true));
|
|
5798
|
+
}
|
|
5795
5799
|
return exts;
|
|
5796
|
-
}, [language, highlightVariables, schema]);
|
|
5800
|
+
}, [language, highlightVariables, schema, editable]);
|
|
5797
5801
|
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
5798
5802
|
"div",
|
|
5799
5803
|
{
|
|
@@ -5809,6 +5813,7 @@ const CodeEditor = React.forwardRef(
|
|
|
5809
5813
|
theme,
|
|
5810
5814
|
extensions,
|
|
5811
5815
|
onChange,
|
|
5816
|
+
editable,
|
|
5812
5817
|
"aria-label": "Code editor",
|
|
5813
5818
|
placeholder,
|
|
5814
5819
|
height: "100%",
|
|
@@ -59106,12 +59111,59 @@ const useMastraPlatform = () => {
|
|
|
59106
59111
|
return { isMastraPlatform, mastraPlatformEndpoint };
|
|
59107
59112
|
};
|
|
59108
59113
|
|
|
59114
|
+
let refreshPromise = null;
|
|
59115
|
+
async function refreshSession(baseUrl, apiPrefix) {
|
|
59116
|
+
try {
|
|
59117
|
+
const res = await fetch(`${baseUrl}${apiPrefix}/auth/refresh`, {
|
|
59118
|
+
method: "POST",
|
|
59119
|
+
credentials: "include"
|
|
59120
|
+
});
|
|
59121
|
+
return res.ok;
|
|
59122
|
+
} catch {
|
|
59123
|
+
return false;
|
|
59124
|
+
}
|
|
59125
|
+
}
|
|
59126
|
+
async function fetchWithRefresh(baseUrl, input, init) {
|
|
59127
|
+
const request = new Request(input, init);
|
|
59128
|
+
const retry = request.clone();
|
|
59129
|
+
const res = await fetch(request);
|
|
59130
|
+
if (res.status !== 401) return res;
|
|
59131
|
+
if (new URL(request.url).pathname.endsWith("/auth/refresh")) return res;
|
|
59132
|
+
if (!refreshPromise) {
|
|
59133
|
+
refreshPromise = refreshSession(baseUrl, "/api").finally(() => {
|
|
59134
|
+
refreshPromise = null;
|
|
59135
|
+
});
|
|
59136
|
+
}
|
|
59137
|
+
const refreshed = await refreshPromise;
|
|
59138
|
+
if (!refreshed) return res;
|
|
59139
|
+
return fetch(retry);
|
|
59140
|
+
}
|
|
59141
|
+
function createFetchWithRefresh(baseUrl, apiPrefix = "/api") {
|
|
59142
|
+
let localRefreshPromise = null;
|
|
59143
|
+
return async (input, init) => {
|
|
59144
|
+
const request = new Request(input, init);
|
|
59145
|
+
const retry = request.clone();
|
|
59146
|
+
const res = await fetch(request);
|
|
59147
|
+
if (res.status !== 401) return res;
|
|
59148
|
+
if (request.url.includes("/auth/refresh")) return res;
|
|
59149
|
+
if (!localRefreshPromise) {
|
|
59150
|
+
localRefreshPromise = refreshSession(baseUrl, apiPrefix).finally(() => {
|
|
59151
|
+
localRefreshPromise = null;
|
|
59152
|
+
});
|
|
59153
|
+
}
|
|
59154
|
+
const refreshed = await localRefreshPromise;
|
|
59155
|
+
if (!refreshed) return res;
|
|
59156
|
+
return fetch(retry);
|
|
59157
|
+
};
|
|
59158
|
+
}
|
|
59159
|
+
|
|
59109
59160
|
function useCurrentUser() {
|
|
59110
59161
|
const client = react.useMastraClient();
|
|
59162
|
+
const baseUrl = client.options?.baseUrl || "";
|
|
59111
59163
|
return reactQuery.useQuery({
|
|
59112
59164
|
queryKey: ["auth", "me"],
|
|
59113
59165
|
queryFn: async () => {
|
|
59114
|
-
const response = await
|
|
59166
|
+
const response = await fetchWithRefresh(baseUrl, `${baseUrl}/api/auth/me`, {
|
|
59115
59167
|
credentials: "include",
|
|
59116
59168
|
headers: {
|
|
59117
59169
|
"Content-Type": "application/json"
|
|
@@ -60222,6 +60274,7 @@ exports.convertWorkflowRunStateToStreamResult = convertWorkflowRunStateToStreamR
|
|
|
60222
60274
|
exports.countLeafRules = countLeafRules;
|
|
60223
60275
|
exports.createDefaultRule = createDefaultRule;
|
|
60224
60276
|
exports.createDefaultRuleGroup = createDefaultRuleGroup;
|
|
60277
|
+
exports.createFetchWithRefresh = createFetchWithRefresh;
|
|
60225
60278
|
exports.createField = createField;
|
|
60226
60279
|
exports.createInstructionBlock = createInstructionBlock;
|
|
60227
60280
|
exports.createRefInstructionBlock = createRefInstructionBlock;
|
|
@@ -60229,6 +60282,7 @@ exports.createVariableAutocomplete = createVariableAutocomplete;
|
|
|
60229
60282
|
exports.exportItemsToCSV = exportItemsToCSV;
|
|
60230
60283
|
exports.exportItemsToJSON = exportItemsToJSON;
|
|
60231
60284
|
exports.extractPrompt = extractPrompt;
|
|
60285
|
+
exports.fetchWithRefresh = fetchWithRefresh;
|
|
60232
60286
|
exports.fieldConfig = fieldConfig;
|
|
60233
60287
|
exports.fieldsToJSONSchema = fieldsToJSONSchema;
|
|
60234
60288
|
exports.findProviderById = findProviderById;
|