@lowdefy/server-dev 0.0.0-experimental-20260829192306 → 0.0.0-experimental-20260830202815

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.
Files changed (131) hide show
  1. package/client/App.jsx +4 -1
  2. package/client/Reload.jsx +13 -0
  3. package/lib/client/ErrorBar.jsx +50 -14
  4. package/lib/client/utils/formatErrorsForCopy.js +49 -0
  5. package/lib/client/utils/formatErrorsForCopy.test.mjs +94 -0
  6. package/lib/client/utils/getErrorBarColor.js +31 -0
  7. package/lib/client/utils/getErrorBarColor.test.mjs +47 -0
  8. package/lib/client/utils/groupNotices.js +40 -0
  9. package/lib/client/utils/groupNotices.test.mjs +47 -0
  10. package/lib/client/utils/usePageConfig.js +8 -4
  11. package/lib/docs/clientErrorStore.js +3 -0
  12. package/lib/docs/clientErrorStore.test.mjs +42 -0
  13. package/lib/docs/createDocsMcpServer.js +249 -16
  14. package/lib/docs/createDocsMcpServer.test.mjs +340 -2
  15. package/lib/docs/createHandleDevNotice.js +64 -0
  16. package/lib/docs/createHandleDevNotice.test.mjs +132 -0
  17. package/lib/docs/dataModel.test.mjs +300 -0
  18. package/lib/docs/devEventBus.js +136 -0
  19. package/lib/docs/devEventBus.test.mjs +225 -0
  20. package/lib/docs/devNoticeChannel.js +42 -0
  21. package/lib/docs/devNoticeStore.js +51 -0
  22. package/lib/docs/devNoticeStore.test.mjs +60 -0
  23. package/lib/docs/docs.test.mjs +204 -4
  24. package/lib/docs/evalOperatorHeadless.js +7 -1
  25. package/lib/docs/evalOperatorHeadless.test.mjs +2 -0
  26. package/lib/docs/findConfig.js +82 -37
  27. package/lib/docs/formatExplainTrace.js +44 -0
  28. package/lib/docs/getBrowser.js +41 -24
  29. package/lib/docs/getBrowser.test.mjs +96 -2
  30. package/lib/docs/getBuildStatus.js +9 -2
  31. package/lib/docs/getCoreDoc.js +9 -1
  32. package/lib/docs/getDataModel.js +469 -0
  33. package/lib/docs/getHazards.js +115 -0
  34. package/lib/docs/getHazards.test.mjs +175 -0
  35. package/lib/docs/getOverview.js +22 -6
  36. package/lib/docs/getSchema.js +5 -1
  37. package/lib/docs/getStaleStatus.js +36 -0
  38. package/lib/docs/getStaleStatus.test.mjs +74 -0
  39. package/lib/docs/getStateSchemaDrift.js +54 -0
  40. package/lib/docs/getStateSchemaDrift.test.mjs +49 -0
  41. package/lib/docs/inspectState.js +26 -2
  42. package/lib/docs/inspectState.test.mjs +63 -0
  43. package/lib/docs/inspectStateHeadless.js +7 -1
  44. package/lib/docs/inspectStateHeadless.test.mjs +2 -0
  45. package/lib/docs/isPageReady.js +53 -0
  46. package/lib/docs/isPageReady.test.mjs +129 -0
  47. package/lib/docs/loadFrameworkHazards.js +40 -0
  48. package/lib/docs/loadFrameworkHazards.test.mjs +43 -0
  49. package/lib/docs/loadState.js +15 -3
  50. package/lib/docs/requestRestart.js +30 -0
  51. package/lib/docs/requestRestart.test.mjs +49 -0
  52. package/lib/docs/resolveCollectionJoin.js +107 -0
  53. package/lib/docs/runCheck.js +75 -0
  54. package/lib/docs/runCheck.test.mjs +91 -0
  55. package/lib/docs/runCheckChild.js +47 -0
  56. package/lib/docs/runEndpoint.js +132 -0
  57. package/lib/docs/runEndpoint.test.mjs +335 -0
  58. package/lib/docs/runJourney.js +539 -0
  59. package/lib/docs/runJourney.test.mjs +585 -0
  60. package/lib/docs/runRequest.js +38 -21
  61. package/lib/docs/runRequest.test.mjs +268 -0
  62. package/lib/docs/screenshotPage.js +6 -1
  63. package/lib/docs/screenshotPage.test.mjs +2 -0
  64. package/lib/docs/seedFixture.js +133 -0
  65. package/lib/docs/seedFixture.test.mjs +232 -0
  66. package/lib/docs/serverErrorStore.js +40 -0
  67. package/lib/docs/serverErrorStore.test.mjs +45 -0
  68. package/lib/docs/setupTestFixtures.mjs +370 -8
  69. package/lib/docs/snapshotPage.js +150 -0
  70. package/lib/docs/snapshotPage.test.mjs +254 -0
  71. package/lib/docs/stateCheckpoints.test.mjs +2 -0
  72. package/lib/docs/truncateResponse.js +39 -0
  73. package/lib/docs/truncateResponse.test.mjs +49 -0
  74. package/lib/docs/unsettledPageNote.js +24 -0
  75. package/lib/docs/validateJourneySteps.js +173 -0
  76. package/lib/docs/validateJourneySteps.test.mjs +103 -0
  77. package/lib/server/applyConnectionOverrides.js +77 -0
  78. package/lib/server/applyConnectionOverrides.test.mjs +116 -0
  79. package/lib/server/auth/createSystemContext.js +2 -2
  80. package/lib/server/auth/getDevUsers.js +36 -0
  81. package/lib/server/auth/getDevUsers.test.mjs +96 -0
  82. package/lib/server/auth/resolveDevUser.js +56 -0
  83. package/lib/server/auth/resolveDevUser.test.mjs +83 -0
  84. package/lib/server/auth/resolveHeadlessUser.js +6 -6
  85. package/lib/server/auth/resolveHeadlessUser.test.mjs +30 -6
  86. package/lib/server/createLowdefyContext.js +23 -4
  87. package/lib/server/getPageJitEnrichment.test.mjs +62 -2
  88. package/lib/server/jitPageBuilder.js +52 -3
  89. package/lib/server/loadDynamicJsMap.js +28 -14
  90. package/lib/server/log/createHandleError.js +26 -0
  91. package/lib/server/log/createHandleError.test.mjs +74 -2
  92. package/manager/processes/startWatchers.mjs +6 -0
  93. package/manager/utils/setupWatcher.mjs +1 -1
  94. package/manager/watchers/jsModuleWatcher.mjs +91 -0
  95. package/manager/watchers/jsModuleWatcher.test.mjs +122 -0
  96. package/manager/watchers/pluginSourceWatcher.mjs +57 -0
  97. package/manager/watchers/pluginSourceWatcher.test.mjs +103 -0
  98. package/manager/watchers/restartRequestWatcher.mjs +62 -0
  99. package/manager/watchers/restartRequestWatcher.test.mjs +76 -0
  100. package/manager/watchers/selectWatchedPluginPackages.mjs +74 -0
  101. package/manager/watchers/selectWatchedPluginPackages.test.mjs +112 -0
  102. package/package.json +36 -34
  103. package/package.original.json +36 -34
  104. package/src/app.js +30 -2
  105. package/src/middleware/errorHandler.js +25 -0
  106. package/src/middleware/errorHandler.test.mjs +70 -0
  107. package/src/middleware/staleFlag.js +76 -0
  108. package/src/middleware/staleFlag.test.mjs +127 -0
  109. package/src/routes/docs/dataModel.js +23 -0
  110. package/src/routes/docs/devUsers.js +26 -0
  111. package/src/routes/docs/devUsers.test.mjs +36 -0
  112. package/src/routes/docs/events.js +50 -0
  113. package/src/routes/docs/events.test.mjs +117 -0
  114. package/src/routes/docs/journey.js +66 -0
  115. package/src/routes/docs/journey.test.mjs +153 -0
  116. package/src/routes/docs/mcp.js +28 -2
  117. package/src/routes/docs/mcp.test.mjs +130 -0
  118. package/src/routes/docs/parseUserParam.js +12 -10
  119. package/src/routes/docs/parseUserParam.test.mjs +47 -7
  120. package/src/routes/docs/restart.js +35 -0
  121. package/src/routes/docs/restart.test.mjs +64 -0
  122. package/src/routes/docs/runEndpoint.js +52 -0
  123. package/src/routes/docs/runEndpoint.test.mjs +156 -0
  124. package/src/routes/docs/runRequest.js +14 -2
  125. package/src/routes/docs/runRequest.test.mjs +118 -0
  126. package/src/routes/docs/seedFixture.js +41 -0
  127. package/src/routes/docs/seedFixture.test.mjs +89 -0
  128. package/src/routes/docs/snapshot.js +91 -0
  129. package/src/routes/docs/snapshot.test.mjs +130 -0
  130. package/src/routes/reload.js +9 -1
  131. package/vite.config.js +5 -0
package/client/App.jsx CHANGED
@@ -79,15 +79,18 @@ function App({ config, router }) {
79
79
  } = lowdefyRef.current.theme?.antd ?? {};
80
80
 
81
81
  // Runtime error callback — pushes errors to state for ErrorBar display.
82
- // Accepts Error objects (with .name) or plain objects (with .type) from build warnings.
82
+ // Accepts Error objects (with .name) or plain objects (with .type) from build warnings
83
+ // and dev notices; `level: 'info'` marks an entry that is not an error.
83
84
  lowdefyRef.current._runtimeErrorCallback = useCallback((error) => {
84
85
  setRuntimeErrors((prev) => [
85
86
  ...prev,
86
87
  {
87
88
  type: error.type ?? error.name,
89
+ level: error.level ?? 'error',
88
90
  message: error.message,
89
91
  source: error.source,
90
92
  stack: error.stack,
93
+ prodError: error.prodError === true,
91
94
  },
92
95
  ]);
93
96
  }, []);
package/client/Reload.jsx CHANGED
@@ -50,6 +50,19 @@ const Reload = ({ children, basePath, lowdefy }) => {
50
50
  }, 600);
51
51
  });
52
52
 
53
+ // Dev notices (lib/docs/devNoticeChannel.js) - not errors, but things the
54
+ // developer should see while building, e.g. a tenant: none request that
55
+ // ran unscoped. Shown by the ErrorBar at info level.
56
+ sse.addEventListener('dev-notice', (event) => {
57
+ const entry = JSON.parse(event.data);
58
+ lowdefy._runtimeErrorCallback?.({
59
+ type: entry.name,
60
+ level: 'info',
61
+ message: entry.message,
62
+ source: entry.source,
63
+ });
64
+ });
65
+
53
66
  sse.onerror = () => {
54
67
  setRestarting(true);
55
68
  console.log('Rebuilding Lowdefy App.');
@@ -16,15 +16,18 @@
16
16
 
17
17
  import React, { useCallback, useState } from 'react';
18
18
 
19
+ import formatErrorsForCopy from './utils/formatErrorsForCopy.js';
20
+ import getErrorBarColor from './utils/getErrorBarColor.js';
21
+ import groupNotices from './utils/groupNotices.js';
22
+
19
23
  function getBarStyle(errors) {
20
- const hasError = errors.some((e) => e.type !== 'ConfigWarning');
21
24
  return {
22
25
  position: 'fixed',
23
26
  bottom: 0,
24
27
  left: 0,
25
28
  right: 0,
26
29
  height: 28,
27
- backgroundColor: hasError ? '#cf1322' : '#d48806',
30
+ backgroundColor: getErrorBarColor(errors),
28
31
  color: '#fff',
29
32
  display: 'flex',
30
33
  alignItems: 'center',
@@ -38,17 +41,6 @@ function getBarStyle(errors) {
38
41
  };
39
42
  }
40
43
 
41
- function formatErrorsForCopy(errors) {
42
- return errors
43
- .map((e) => {
44
- let text = `[${e.type}] ${e.message}`;
45
- if (e.source) text += `\n Source: ${e.source}`;
46
- if (e.stack) text += `\n${e.stack}`;
47
- return text;
48
- })
49
- .join('\n\n');
50
- }
51
-
52
44
  function CopyIcon() {
53
45
  return (
54
46
  <svg
@@ -98,7 +90,10 @@ const ErrorBar = ({ errors }) => {
98
90
  if (!errors || errors.length === 0) return null;
99
91
 
100
92
  const latest = errors[errors.length - 1];
101
- const count = errors.length;
93
+ // tenant: none notices are counted as their own group beside the error
94
+ // count, so an unscoped read never hides inside an error total.
95
+ const { entries, tenantNotices, runAsNotices } = groupNotices(errors);
96
+ const count = entries.length;
102
97
 
103
98
  return (
104
99
  <div style={getBarStyle(errors)}>
@@ -112,6 +107,19 @@ const ErrorBar = ({ errors }) => {
112
107
  }}
113
108
  >
114
109
  <span style={{ opacity: 0.8 }}>{latest.type}: </span>
110
+ {latest.prodError === true && (
111
+ <span
112
+ style={{
113
+ backgroundColor: 'rgba(255,255,255,0.25)',
114
+ borderRadius: 8,
115
+ padding: '1px 7px',
116
+ fontSize: 11,
117
+ marginRight: 6,
118
+ }}
119
+ >
120
+ fails in prod
121
+ </span>
122
+ )}
115
123
  <span>{latest.message}</span>
116
124
  {latest.source && <span style={{ opacity: 0.7, marginLeft: 8 }}>{latest.source}</span>}
117
125
  </div>
@@ -128,6 +136,34 @@ const ErrorBar = ({ errors }) => {
128
136
  {count}
129
137
  </span>
130
138
  )}
139
+ {tenantNotices.length > 0 && (
140
+ <span
141
+ title="Requests that ran with tenant: none read and write rows of every organization"
142
+ style={{
143
+ backgroundColor: 'rgba(255,255,255,0.25)',
144
+ borderRadius: 8,
145
+ padding: '1px 7px',
146
+ fontSize: 11,
147
+ whiteSpace: 'nowrap',
148
+ }}
149
+ >
150
+ unscoped reads ({tenantNotices.length})
151
+ </span>
152
+ )}
153
+ {runAsNotices.length > 0 && (
154
+ <span
155
+ title="Steps that ran scoped to an organization declared with runAs"
156
+ style={{
157
+ backgroundColor: 'rgba(255,255,255,0.25)',
158
+ borderRadius: 8,
159
+ padding: '1px 7px',
160
+ fontSize: 11,
161
+ whiteSpace: 'nowrap',
162
+ }}
163
+ >
164
+ scoped runs ({runAsNotices.length})
165
+ </span>
166
+ )}
131
167
  <button
132
168
  onClick={handleCopy}
133
169
  title={copied ? 'Copied!' : 'Copy all errors'}
@@ -0,0 +1,49 @@
1
+ /*
2
+ Copyright 2020-2026 Lowdefy, Inc
3
+
4
+ Licensed under the Apache License, Version 2.0 (the "License");
5
+ you may not use this file except in compliance with the License.
6
+ You may obtain a copy of the License at
7
+
8
+ http://www.apache.org/licenses/LICENSE-2.0
9
+
10
+ Unless required by applicable law or agreed to in writing, software
11
+ distributed under the License is distributed on an "AS IS" BASIS,
12
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ See the License for the specific language governing permissions and
14
+ limitations under the License.
15
+ */
16
+
17
+ import groupNotices from './groupNotices.js';
18
+
19
+ function formatEntry(error) {
20
+ const prefix = error.prodError === true ? `[${error.type}] (fails in prod)` : `[${error.type}]`;
21
+ let text = `${prefix} ${error.message}`;
22
+ if (error.source) text += `\n Source: ${error.source}`;
23
+ if (error.stack) text += `\n${error.stack}`;
24
+ return text;
25
+ }
26
+
27
+ // Errors and warnings first, then the tenant: none notices under their own
28
+ // heading with their source lines, so a pasted bar reads as two lists.
29
+ function formatErrorsForCopy(errors) {
30
+ const { entries, tenantNotices, runAsNotices } = groupNotices(errors);
31
+ const sections = [entries.map(formatEntry).join('\n\n')];
32
+ if (tenantNotices.length > 0) {
33
+ const lines = tenantNotices.map((notice) => {
34
+ const source = notice.source ? `\n Source: ${notice.source}` : '';
35
+ return `${notice.message}${source}`;
36
+ });
37
+ sections.push(`Unscoped reads (tenant: none):\n${lines.join('\n')}`);
38
+ }
39
+ if (runAsNotices.length > 0) {
40
+ const lines = runAsNotices.map((notice) => {
41
+ const source = notice.source ? `\n Source: ${notice.source}` : '';
42
+ return `${notice.message}${source}`;
43
+ });
44
+ sections.push(`Scoped runs (runAs):\n${lines.join('\n')}`);
45
+ }
46
+ return sections.filter((section) => section !== '').join('\n\n');
47
+ }
48
+
49
+ export default formatErrorsForCopy;
@@ -0,0 +1,94 @@
1
+ /*
2
+ Copyright 2020-2026 Lowdefy, Inc
3
+
4
+ Licensed under the Apache License, Version 2.0 (the "License");
5
+ you may not use this file except in compliance with the License.
6
+ You may obtain a copy of the License at
7
+
8
+ http://www.apache.org/licenses/LICENSE-2.0
9
+
10
+ Unless required by applicable law or agreed to in writing, software
11
+ distributed under the License is distributed on an "AS IS" BASIS,
12
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ See the License for the specific language governing permissions and
14
+ limitations under the License.
15
+ */
16
+ import formatErrorsForCopy from './formatErrorsForCopy.js';
17
+
18
+ test('formatErrorsForCopy marks a prod-gated warning after the type prefix', () => {
19
+ expect(
20
+ formatErrorsForCopy([
21
+ { type: 'ConfigWarning', message: '_state is not available.', prodError: true },
22
+ ])
23
+ ).toBe('[ConfigWarning] (fails in prod) _state is not available.');
24
+ });
25
+
26
+ test('formatErrorsForCopy leaves a plain warning prefix unmarked', () => {
27
+ expect(formatErrorsForCopy([{ type: 'ConfigWarning', message: 'Duplicate shortcut.' }])).toBe(
28
+ '[ConfigWarning] Duplicate shortcut.'
29
+ );
30
+ });
31
+
32
+ test('formatErrorsForCopy appends source and stack and joins entries with a blank line', () => {
33
+ expect(
34
+ formatErrorsForCopy([
35
+ { type: 'ConfigError', message: 'Bad type.', source: 'home.yaml:3' },
36
+ { type: 'BlockError', message: 'Render failed.', stack: 'at Block' },
37
+ ])
38
+ ).toBe('[ConfigError] Bad type.\n Source: home.yaml:3\n\n[BlockError] Render failed.\nat Block');
39
+ });
40
+
41
+ test('formatErrorsForCopy lists tenant none notices under their own heading after the errors', () => {
42
+ expect(
43
+ formatErrorsForCopy([
44
+ {
45
+ type: 'TenantNoneNotice',
46
+ level: 'info',
47
+ message: 'Request "list_all" ran unscoped on tenant connection "app_data" (tenant: none).',
48
+ source: 'pages/admin.yaml:12',
49
+ },
50
+ { type: 'ConfigError', message: 'Bad type.', source: 'home.yaml:3' },
51
+ {
52
+ type: 'TenantNoneNotice',
53
+ level: 'info',
54
+ message: 'Request "sync" ran unscoped on tenant connection "app_data" (tenant: none).',
55
+ },
56
+ ])
57
+ ).toBe(
58
+ '[ConfigError] Bad type.\n Source: home.yaml:3\n\n' +
59
+ 'Unscoped reads (tenant: none):\n' +
60
+ 'Request "list_all" ran unscoped on tenant connection "app_data" (tenant: none).\n Source: pages/admin.yaml:12\n' +
61
+ 'Request "sync" ran unscoped on tenant connection "app_data" (tenant: none).'
62
+ );
63
+ });
64
+
65
+ test('formatErrorsForCopy with only tenant none notices has no leading blank section', () => {
66
+ expect(
67
+ formatErrorsForCopy([
68
+ { type: 'TenantNoneNotice', level: 'info', message: 'ran unscoped', source: 'a.yaml:1' },
69
+ ])
70
+ ).toBe('Unscoped reads (tenant: none):\nran unscoped\n Source: a.yaml:1');
71
+ });
72
+
73
+ test('formatErrorsForCopy lists runAs scope notices under their own heading after unscoped reads', () => {
74
+ expect(
75
+ formatErrorsForCopy([
76
+ {
77
+ type: 'RunAsScope',
78
+ level: 'info',
79
+ message: 'Step "rows" ran scoped to organization "org-9" (runAs).',
80
+ source: 'api/jobs.yaml:8',
81
+ },
82
+ {
83
+ type: 'TenantNoneNotice',
84
+ level: 'info',
85
+ message: 'Request "sync" ran unscoped on tenant connection "app_data" (tenant: none).',
86
+ },
87
+ ])
88
+ ).toBe(
89
+ 'Unscoped reads (tenant: none):\n' +
90
+ 'Request "sync" ran unscoped on tenant connection "app_data" (tenant: none).\n\n' +
91
+ 'Scoped runs (runAs):\n' +
92
+ 'Step "rows" ran scoped to organization "org-9" (runAs).\n Source: api/jobs.yaml:8'
93
+ );
94
+ });
@@ -0,0 +1,31 @@
1
+ /*
2
+ Copyright 2020-2026 Lowdefy, Inc
3
+
4
+ Licensed under the Apache License, Version 2.0 (the "License");
5
+ you may not use this file except in compliance with the License.
6
+ You may obtain a copy of the License at
7
+
8
+ http://www.apache.org/licenses/LICENSE-2.0
9
+
10
+ Unless required by applicable law or agreed to in writing, software
11
+ distributed under the License is distributed on an "AS IS" BASIS,
12
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ See the License for the specific language governing permissions and
14
+ limitations under the License.
15
+ */
16
+
17
+ // Three severities: a real error is red, a warning that fails the production
18
+ // build is dark orange, and a plain warning is yellow. An info-level entry (a
19
+ // dev notice such as an unscoped tenant: none read) is not an error - an app
20
+ // with only notices shows the amber bar.
21
+ function isError(error) {
22
+ return error.level !== 'info' && error.type !== 'ConfigWarning';
23
+ }
24
+
25
+ function getErrorBarColor(errors) {
26
+ if (errors.some(isError)) return '#cf1322';
27
+ if (errors.some((error) => error.prodError === true)) return '#ad4e00';
28
+ return '#d48806';
29
+ }
30
+
31
+ export default getErrorBarColor;
@@ -0,0 +1,47 @@
1
+ /*
2
+ Copyright 2020-2026 Lowdefy, Inc
3
+
4
+ Licensed under the Apache License, Version 2.0 (the "License");
5
+ you may not use this file except in compliance with the License.
6
+ You may obtain a copy of the License at
7
+
8
+ http://www.apache.org/licenses/LICENSE-2.0
9
+
10
+ Unless required by applicable law or agreed to in writing, software
11
+ distributed under the License is distributed on an "AS IS" BASIS,
12
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ See the License for the specific language governing permissions and
14
+ limitations under the License.
15
+ */
16
+ import getErrorBarColor from './getErrorBarColor.js';
17
+
18
+ test('getErrorBarColor returns red when any entry is not a warning', () => {
19
+ expect(
20
+ getErrorBarColor([{ type: 'ConfigWarning', prodError: true }, { type: 'ConfigError' }])
21
+ ).toBe('#cf1322');
22
+ });
23
+
24
+ test('getErrorBarColor returns dark orange when every entry is a warning and one fails in prod', () => {
25
+ expect(
26
+ getErrorBarColor([{ type: 'ConfigWarning' }, { type: 'ConfigWarning', prodError: true }])
27
+ ).toBe('#ad4e00');
28
+ });
29
+
30
+ test('getErrorBarColor returns yellow when every entry is a plain warning', () => {
31
+ expect(
32
+ getErrorBarColor([{ type: 'ConfigWarning' }, { type: 'ConfigWarning', prodError: false }])
33
+ ).toBe('#d48806');
34
+ });
35
+
36
+ test('getErrorBarColor treats info-level notices as non-errors and shows the amber bar', () => {
37
+ expect(getErrorBarColor([{ type: 'TenantNoneNotice', level: 'info' }])).toBe('#d48806');
38
+ expect(
39
+ getErrorBarColor([{ type: 'TenantNoneNotice', level: 'info' }, { type: 'ConfigWarning' }])
40
+ ).toBe('#d48806');
41
+ });
42
+
43
+ test('getErrorBarColor stays red when an error sits beside info-level notices', () => {
44
+ expect(
45
+ getErrorBarColor([{ type: 'TenantNoneNotice', level: 'info' }, { type: 'OperatorError' }])
46
+ ).toBe('#cf1322');
47
+ });
@@ -0,0 +1,40 @@
1
+ /*
2
+ Copyright 2020-2026 Lowdefy, Inc
3
+
4
+ Licensed under the Apache License, Version 2.0 (the "License");
5
+ you may not use this file except in compliance with the License.
6
+ You may obtain a copy of the License at
7
+
8
+ http://www.apache.org/licenses/LICENSE-2.0
9
+
10
+ Unless required by applicable law or agreed to in writing, software
11
+ distributed under the License is distributed on an "AS IS" BASIS,
12
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ See the License for the specific language governing permissions and
14
+ limitations under the License.
15
+ */
16
+ // Splits the ErrorBar's entries into errors/warnings and the tenant: none
17
+ // notices, which the bar renders as their own "unscoped reads" group and the
18
+ // copy text lists under their own heading.
19
+ const TENANT_NONE_NOTICE = 'TenantNoneNotice';
20
+ // Steps that ran scoped to an authored organization (runAs) sit beside the
21
+ // unscoped ones: neither is an error, and both say which rows a step touched.
22
+ const RUN_AS_NOTICE = 'RunAsScope';
23
+
24
+ function groupNotices(errors) {
25
+ const entries = [];
26
+ const tenantNotices = [];
27
+ const runAsNotices = [];
28
+ (errors ?? []).forEach((error) => {
29
+ if (error.type === TENANT_NONE_NOTICE) {
30
+ tenantNotices.push(error);
31
+ } else if (error.type === RUN_AS_NOTICE) {
32
+ runAsNotices.push(error);
33
+ } else {
34
+ entries.push(error);
35
+ }
36
+ });
37
+ return { entries, tenantNotices, runAsNotices };
38
+ }
39
+
40
+ export default groupNotices;
@@ -0,0 +1,47 @@
1
+ /*
2
+ Copyright 2020-2026 Lowdefy, Inc
3
+
4
+ Licensed under the Apache License, Version 2.0 (the "License");
5
+ you may not use this file except in compliance with the License.
6
+ You may obtain a copy of the License at
7
+
8
+ http://www.apache.org/licenses/LICENSE-2.0
9
+
10
+ Unless required by applicable law or agreed to in writing, software
11
+ distributed under the License is distributed on an "AS IS" BASIS,
12
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ See the License for the specific language governing permissions and
14
+ limitations under the License.
15
+ */
16
+ import groupNotices from './groupNotices.js';
17
+
18
+ test('groupNotices splits tenant none notices from errors and warnings in order', () => {
19
+ const error = { type: 'ConfigError', message: 'Bad type.' };
20
+ const warning = { type: 'ConfigWarning', message: 'Deprecated.' };
21
+ const notice = { type: 'TenantNoneNotice', level: 'info', message: 'ran unscoped' };
22
+ expect(groupNotices([notice, error, warning])).toEqual({
23
+ entries: [error, warning],
24
+ tenantNotices: [notice],
25
+ runAsNotices: [],
26
+ });
27
+ });
28
+
29
+ test('groupNotices returns empty groups for no entries', () => {
30
+ expect(groupNotices([])).toEqual({ entries: [], tenantNotices: [], runAsNotices: [] });
31
+ expect(groupNotices(undefined)).toEqual({ entries: [], tenantNotices: [], runAsNotices: [] });
32
+ });
33
+
34
+ test('groupNotices keeps other info-level entries with the errors', () => {
35
+ const info = { type: 'OtherNotice', level: 'info', message: 'fyi' };
36
+ expect(groupNotices([info])).toEqual({ entries: [info], tenantNotices: [], runAsNotices: [] });
37
+ });
38
+
39
+ test('groupNotices splits runAs scope notices into their own group', () => {
40
+ const notice = { type: 'RunAsScope', level: 'info', message: 'ran scoped' };
41
+ const error = { type: 'ConfigError', message: 'Bad type.' };
42
+ expect(groupNotices([notice, error])).toEqual({
43
+ entries: [error],
44
+ tenantNotices: [],
45
+ runAsNotices: [notice],
46
+ });
47
+ });
@@ -22,10 +22,14 @@ import { getNavVersion, getReloadVersion } from './useMutateCache.js';
22
22
  // every later navigation refetches.
23
23
  const dynamicUrls = new Set();
24
24
 
25
- function parseJsModule(text) {
26
- const fn = new Function('exports', text.replace('export default', 'exports.default ='));
25
+ // _js module references arrive as an `await import('/@fs/...')` preamble
26
+ // (getPageJitEnrichment), so the compiled text runs as an async function.
27
+ const AsyncFunction = Object.getPrototypeOf(async function () {}).constructor;
28
+
29
+ async function parseJsModule(text) {
30
+ const fn = new AsyncFunction('exports', text.replace('export default', 'exports.default ='));
27
31
  const mod = {};
28
- fn(mod);
32
+ await fn(mod);
29
33
  return mod.default ?? {};
30
34
  }
31
35
 
@@ -85,7 +89,7 @@ export async function fetchPageConfig(url) {
85
89
  // response, so first paint needs no secondary fetch. _jsEntries arrives as
86
90
  // module text — compile it to the { hash: fn } object Page expects.
87
91
  // _dynamicIcons is already plain data — leave it for Page to inject.
88
- if (data._jsEntries) data._jsEntries = parseJsModule(data._jsEntries);
92
+ if (data._jsEntries) data._jsEntries = await parseJsModule(data._jsEntries);
89
93
 
90
94
  if (data?.dynamic === true) {
91
95
  dynamicUrls.add(url);
@@ -14,6 +14,8 @@
14
14
  limitations under the License.
15
15
  */
16
16
 
17
+ import { publish } from './devEventBus.js';
18
+
17
19
  // Module-level ring buffer of recent client-reported errors — feeds the
18
20
  // getBuildStatus feedback endpoint so agents can see browser errors without
19
21
  // tailing server logs. Deliberately in-memory only: entries are lost on
@@ -27,6 +29,7 @@ function push(entry) {
27
29
  if (entries.length > MAX_ENTRIES) {
28
30
  entries.shift();
29
31
  }
32
+ publish({ type: 'client_error', ...entry });
30
33
  }
31
34
 
32
35
  function list() {
@@ -0,0 +1,42 @@
1
+ /*
2
+ Copyright 2020-2026 Lowdefy, Inc
3
+
4
+ Licensed under the Apache License, Version 2.0 (the "License");
5
+ you may not use this file except in compliance with the License.
6
+ You may obtain a copy of the License at
7
+
8
+ http://www.apache.org/licenses/LICENSE-2.0
9
+
10
+ Unless required by applicable law or agreed to in writing, software
11
+ distributed under the License is distributed on an "AS IS" BASIS,
12
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ See the License for the specific language governing permissions and
14
+ limitations under the License.
15
+ */
16
+
17
+ import { jest } from '@jest/globals';
18
+
19
+ const mockPublish = jest.fn();
20
+ jest.unstable_mockModule('./devEventBus.js', () => ({
21
+ publish: mockPublish,
22
+ }));
23
+
24
+ const { default: clientErrorStore } = await import('./clientErrorStore.js');
25
+
26
+ test('clientErrorStore push adds an entry, lists it, and publishes it as a client_error event', () => {
27
+ const entry = { timestamp: '2026-01-01T00:00:00.000Z', name: 'OperatorError', message: 'bad' };
28
+ clientErrorStore.push(entry);
29
+ expect(clientErrorStore.list()).toEqual([entry]);
30
+ expect(mockPublish).toHaveBeenCalledWith({ type: 'client_error', ...entry });
31
+ });
32
+
33
+ test('clientErrorStore caps at 50 entries and drops the oldest', () => {
34
+ for (let i = 0; i < 60; i++) {
35
+ clientErrorStore.push({ index: i });
36
+ }
37
+ const entries = clientErrorStore.list();
38
+ expect(entries.length).toEqual(50);
39
+ expect(entries[0].index).toEqual(10);
40
+ expect(entries[49].index).toEqual(59);
41
+ expect(mockPublish).toHaveBeenCalledTimes(60);
42
+ });