@notis_ai/cli 0.2.30 → 0.2.31
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/README.md +1 -0
- package/dist/agent-hooks/notis-agent-hook.mjs +37890 -10794
- package/dist/base-skills/notis-cli/.notis-base-skill.json +1 -1
- package/dist/base-skills/notis-cli/references/native-databases.md +1 -1
- package/dist/base-skills/notis-query/.notis-base-skill.json +1 -1
- package/dist/base-skills/notis-query/references/query.md +6 -4
- package/dist/base-skills/notis-spaces/.notis-base-skill.json +1 -1
- package/dist/base-skills/notis-spaces/SKILL.md +8 -3
- package/dist/base-skills/notis-spaces/references/architecture.md +4 -1
- package/dist/base-skills/notis-spaces/references/design.md +7 -1
- package/dist/base-skills/notis-spaces/references/fixtures.md +27 -2
- package/dist/base-skills/notis-spaces/references/sdk.md +90 -31
- package/dist/base-skills/notis-spaces/references/troubleshooting.md +3 -0
- package/dist/base-skills/notis-spaces/references/views.md +20 -0
- package/dist/sdk/src/hooks/useNativeDocuments.ts +50 -12
- package/dist/sdk/src/index.ts +1 -1
- package/dist/sdk/src/space.ts +3 -1
- package/dist/sdk/src/tailwind.ts +53 -3
- package/dist/sdk/src/ui/icons.tsx +1 -0
- package/dist/sdk/src/words/types.ts +28 -0
- package/dist/skill-sync/index.js +10 -90
- package/dist/skill-sync-worker.mjs +50 -93
- package/dist/space-harness/host.js +150 -81
- package/dist/space-sdk/dist/chunk-3DFOGU26.js +3 -0
- package/dist/space-sdk/dist/index.js +2 -2
- package/dist/space-sdk/dist/ui.js +12 -12
- package/dist/space-sdk/src/hooks/useNativeDocuments.d.ts +23 -0
- package/dist/space-sdk/src/index.d.ts +1 -1
- package/dist/space-sdk/src/space.ts +3 -1
- package/dist/space-sdk/src/tailwind-candidates.d.ts +273 -2
- package/dist/space-sdk/src/tailwind.ts +53 -3
- package/dist/space-sdk/src/ui/blocks/DataTable.d.ts +19 -4
- package/dist/space-sdk/src/ui/blocks/Meter.d.ts +12 -3
- package/dist/space-sdk/src/ui/blocks/Tabs.d.ts +7 -1
- package/dist/space-sdk/src/ui/blocks/index.d.ts +1 -1
- package/dist/space-sdk/src/ui/charts/CalendarHeatmap.d.ts +69 -0
- package/dist/space-sdk/src/ui/charts/Chart.d.ts +18 -3
- package/dist/space-sdk/src/ui/charts/chartData.d.ts +19 -0
- package/dist/space-sdk/src/ui/charts/heatmapData.d.ts +81 -0
- package/dist/space-sdk/src/ui/index.d.ts +4 -2
- package/dist/space-sdk/src/ui/list/Row.d.ts +11 -1
- package/dist/space-sdk/src/ui/period/dateFormat.d.ts +2 -0
- package/dist/space-sdk/src/ui/period/dateWords.d.ts +9 -0
- package/dist/space-sdk/src/ui/period/periods.d.ts +15 -2
- package/dist/space-sdk/src/words/types.ts +28 -0
- package/dist/view-renderer/dist/host.js +219 -150
- package/dist/view-renderer/src/dom.js +3 -2
- package/dist/view-renderer/src/errors.js +9 -0
- package/dist/view-renderer/src/host.tsx +12 -5
- package/dist/view-renderer/src/remote-broker.js +3 -1
- package/dist/view-renderer/src/renderer.js +63 -16
- package/dist/view-renderer/src/skeleton.js +70 -18
- package/package.json +5 -4
- package/skills/notis-query/cli.md +3 -0
- package/src/command-specs/spaces.js +71 -15
- package/src/command-specs/tools.js +3 -0
- package/src/runtime/api-hosts.generated.js +35 -0
- package/src/runtime/api-hosts.js +27 -10
- package/src/runtime/app-platform.js +68 -24
- package/src/runtime/http-agent.js +53 -0
- package/src/runtime/native-record-files.js +11 -0
- package/src/runtime/oauth.js +2 -1
- package/src/runtime/skill-sync/cloud-client.ts +0 -10
- package/src/runtime/skill-sync/index.ts +13 -15
- package/src/runtime/skill-sync/local-scanner.ts +0 -67
- package/src/runtime/skill-sync/types.ts +1 -0
- package/src/runtime/skill-sync/write-cloud-skill.ts +7 -23
- package/src/runtime/space-dependencies.js +66 -0
- package/src/runtime/space-fixture-broker.js +23 -8
- package/src/runtime/space-platform.js +47 -3
- package/src/runtime/space-source.js +10 -1
- package/src/runtime/space-test-server.js +105 -6
- package/src/runtime/space-verification.js +103 -43
- package/src/runtime/space-view-manifest.js +38 -5
- package/src/runtime/transport.js +19 -4
- package/src/runtime/view-render.js +4 -1
- package/template/tailwind.config.ts +2 -35
- package/dist/space-sdk/dist/chunk-6GJ2BS7B.js +0 -3
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
import { createHash } from 'node:crypto';
|
|
3
3
|
import { existsSync, readFileSync } from 'node:fs';
|
|
4
4
|
import { fileURLToPath } from 'node:url';
|
|
5
|
-
import { appFilesDigest } from './app-platform.js';
|
|
6
|
-
import { createSpaceFixtureBroker, fixtureSkeletonParams } from './space-fixture-broker.js';
|
|
5
|
+
import { appFilesDigest, VERIFY_LOCALES, VERIFY_WIDTHS } from './app-platform.js';
|
|
6
|
+
import { createSpaceFixtureBroker, fixtureContexts, fixtureSkeletonParams } from './space-fixture-broker.js';
|
|
7
7
|
|
|
8
8
|
// Kept for the standalone legacy worker's lifecycle tests while that diagnostic
|
|
9
9
|
// entrypoint is retired. The primary verifier below never starts that worker.
|
|
@@ -43,7 +43,16 @@ async function acquire(signal) {
|
|
|
43
43
|
}
|
|
44
44
|
function releaseSlot() { const next = waiting.shift(); if (next) next.accept(); else active--; }
|
|
45
45
|
|
|
46
|
-
|
|
46
|
+
const LANGUAGES = { en: 'English', fr: 'French' };
|
|
47
|
+
/** Where one render was taken, for messages: "390 px in French" and, with several contexts, the context's name. */
|
|
48
|
+
const placeOf = ({ width, locale, context }) => `${width} px in ${LANGUAGES[locale]}${context ? `, context ${context}` : ''}`;
|
|
49
|
+
// The reads a reader's loading pass holds: the opened item's record and body; the list around it answers.
|
|
50
|
+
const READER_HOLDS = ['record', 'document_body', 'html', 'report'];
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* Initial deployment checks the exact captured bytes at both product widths, in English and French, once per fixture
|
|
54
|
+
* context (`contexts` in the fixtures, else the one `context`).
|
|
55
|
+
*/
|
|
47
56
|
export async function verifySpaceRelease(release, { capabilities, timeoutMs = 45_000, signal, loadRenderer = loadSpaceVerificationRenderer,
|
|
48
57
|
authorizationMode = 'authorize_missing', unavailableActions = [] } = {}) {
|
|
49
58
|
const diagnostic = { schema: 'notis-space-render/v1', local_key: release.manifest.local_key,
|
|
@@ -54,13 +63,18 @@ export async function verifySpaceRelease(release, { capabilities, timeoutMs = 45
|
|
|
54
63
|
if (signal?.aborted) return { ...diagnostic, status: 'failed', errors: [{ phase: 'browser', message: 'Verification cancelled.' }] };
|
|
55
64
|
if (release.manifest.kind === 'container') return { ...diagnostic, status: 'not_applicable_container' };
|
|
56
65
|
let pool, held = false, rendererDigest;
|
|
57
|
-
|
|
66
|
+
// Several contexts name their images and messages; one context keeps the plain names.
|
|
67
|
+
const contexts = fixtureContexts(release), named = contexts.length > 1;
|
|
68
|
+
const brokers = [];
|
|
69
|
+
for (const { name } of contexts.length ? contexts : [{ name: undefined }]) for (const locale of VERIFY_LOCALES) for (const width of VERIFY_WIDTHS) {
|
|
70
|
+
brokers.push({ width, locale, contextName: name, ...(named ? { context: name } : {}), broker: null, stop: new AbortController(), timer: null });
|
|
71
|
+
}
|
|
58
72
|
try {
|
|
59
73
|
// Validate fixture authority before opening a browser or acquiring a slot.
|
|
60
74
|
// A failed fixture read already fails the check, and the view usually waits on it until the timeout: the
|
|
61
75
|
// render stops shortly after, once the reads the view sends together have had their say.
|
|
62
76
|
for (const item of brokers) item.broker = createSpaceFixtureBroker({ release, capabilities, width: item.width,
|
|
63
|
-
authorizationMode, unavailableActions, onFailure: () => {
|
|
77
|
+
authorizationMode, unavailableActions, context: item.contextName, onFailure: () => {
|
|
64
78
|
item.timer ??= setTimeout(() => item.stop.abort(), FIXTURE_FAILURE_GRACE_MS);
|
|
65
79
|
} });
|
|
66
80
|
await acquire(signal); held = true;
|
|
@@ -70,55 +84,70 @@ export async function verifySpaceRelease(release, { capabilities, timeoutMs = 45
|
|
|
70
84
|
// waits; a view still loading after the bounded wait keeps a screenshot of what it showed, and says so.
|
|
71
85
|
const readyTimeoutMs = readyWait(timeoutMs);
|
|
72
86
|
const screenshots = [];
|
|
73
|
-
const
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
87
|
+
const tag = ({ width, locale, context }) => ({ width, locale, ...(context ? { context } : {}) });
|
|
88
|
+
const observations = [];
|
|
89
|
+
// Both widths of one context and locale render together: the pool holds two renders at a time.
|
|
90
|
+
for (let index = 0; index < brokers.length; index += VERIFY_WIDTHS.length) {
|
|
91
|
+
observations.push(...await Promise.allSettled(brokers.slice(index, index + VERIFY_WIDTHS.length).map(async (item) => {
|
|
92
|
+
const { width, locale, broker, stop } = item;
|
|
93
|
+
const cancel = signal ? AbortSignal.any([signal, stop.signal]) : stop.signal;
|
|
94
|
+
const result = await library.renderView({ broker, pool, outputs: ['markdown', 'screenshot'], width, locale, timeoutMs, signal: cancel,
|
|
95
|
+
...(readyTimeoutMs ? { readyTimeoutMs } : {}) });
|
|
96
|
+
const blocked = result.blocked_calls || [];
|
|
97
|
+
const png = Buffer.from(result.screenshot.data_base64, 'base64');
|
|
98
|
+
screenshots.push({ ...tag(item), png });
|
|
99
|
+
return { ...tag(item), mounted: true, status: blocked.length ? 'failed' : 'passed', loaded: true,
|
|
100
|
+
markdown_sha256: createHash('sha256').update(result.markdown).digest('hex'),
|
|
101
|
+
screenshot_sha256: sha256(png),
|
|
102
|
+
screenshot_width: result.screenshot.width, screenshot_height: result.screenshot.height,
|
|
103
|
+
rendered_at: result.rendered_at, blocked_calls: blocked };
|
|
104
|
+
})));
|
|
105
|
+
}
|
|
86
106
|
const renders = observations.map((value, index) => {
|
|
87
107
|
if (value.status === 'fulfilled') return value.value;
|
|
88
|
-
const
|
|
108
|
+
const item = brokers[index], where = tag(item), place = placeOf(item);
|
|
109
|
+
const shot = value.reason?.code === 'render_not_ready' ? value.reason.screenshot : null;
|
|
89
110
|
if (value.reason?.code === 'render_view_failed') {
|
|
90
|
-
return {
|
|
91
|
-
message: `At ${
|
|
111
|
+
return { ...where, mounted: false, status: 'failed', error: 'render_view_failed', loaded: false,
|
|
112
|
+
message: `At ${place} the view's code failed before it showed anything${value.reason.reason ? `: ${value.reason.reason}` : '.'}` };
|
|
92
113
|
}
|
|
93
|
-
if (!shot?.data_base64) return {
|
|
114
|
+
if (!shot?.data_base64) return { ...where, mounted: false, status: 'failed', error: value.reason?.code || 'render_failed',
|
|
115
|
+
...(Array.isArray(value.reason?.blocked) && value.reason.blocked.length ? { blocked_calls: value.reason.blocked } : {}) };
|
|
94
116
|
const png = Buffer.from(shot.data_base64, 'base64');
|
|
95
|
-
screenshots.push({
|
|
117
|
+
screenshots.push({ ...where, png });
|
|
96
118
|
const mounted = value.reason.mounted === true;
|
|
97
119
|
const seconds = value.reason.waitedSeconds || Math.round((readyTimeoutMs || 0) / 1000);
|
|
98
|
-
return {
|
|
99
|
-
message: mounted ? `At ${
|
|
100
|
-
: `At ${
|
|
120
|
+
return { ...where, mounted, status: 'failed', error: 'render_not_ready', loaded: false,
|
|
121
|
+
message: mounted ? `At ${place} the view had not finished loading its data after ${seconds} s.`
|
|
122
|
+
: `At ${place} the view had not shown anything after ${seconds} s.`,
|
|
101
123
|
screenshot_sha256: sha256(png), screenshot_width: shot.width, screenshot_height: shot.height,
|
|
102
124
|
blocked_calls: Array.isArray(value.reason.blocked) ? value.reason.blocked : [] };
|
|
103
125
|
});
|
|
104
|
-
|
|
105
|
-
|
|
126
|
+
const order = item => brokers.findIndex(value => value.width === item.width && value.locale === item.locale && value.context === item.context);
|
|
127
|
+
screenshots.sort((left, right) => order(left) - order(right));
|
|
128
|
+
const runtimeCalls = brokers.flatMap(item => item.broker.calls.map(call => ({ ...tag(item), ...call })));
|
|
106
129
|
const passed = renders.every(value => value.status === 'passed') && runtimeCalls.every(call => call.ok);
|
|
107
130
|
// Each distinct fixture reason once (both widths usually hit the same one), ahead of the generic line.
|
|
108
131
|
const fixtureErrors = [...new Map(runtimeCalls.filter(call => !call.ok && call.error)
|
|
109
132
|
.map(call => [call.error, { phase: 'fixture', operation: call.operation,
|
|
110
133
|
...(call.recordKey ? { record_key: call.recordKey } : {}), ...(call.actionId ? { action_id: call.actionId } : {}),
|
|
111
134
|
message: call.error }])).values()].slice(0, 10);
|
|
135
|
+
// An image URL the fixtures do not provide is named once, whatever width or language met it.
|
|
136
|
+
const images = [...new Set(renders.flatMap(value => (value.blocked_calls || []).map(call => call.image)).filter(Boolean))];
|
|
137
|
+
if (images.length) fixtureErrors.push({ phase: 'fixture', operation: 'asset',
|
|
138
|
+
message: `The view shows ${images.length === 1 ? 'an image' : `${images.length} images`} its fixtures do not provide (${images.slice(0, 3).join(', ')}${images.length > 3 ? ', ...' : ''}). `
|
|
139
|
+
+ 'Add each URL to "images" in the fixtures, mapped to a picture file next to them: {"images": {"https://example.com/photo.jpg": "./photos/photo.jpg"}}.' });
|
|
112
140
|
const notReady = renders.filter(value => value.error === 'render_not_ready' || value.error === 'render_view_failed')
|
|
113
|
-
.map(value => ({ phase: 'renderer',
|
|
141
|
+
.map(value => ({ phase: 'renderer', ...tag(value), message: value.message }));
|
|
114
142
|
const result = { ...diagnostic, status: passed ? 'passed' : 'failed', mounted: renders.every(value => value.mounted),
|
|
115
143
|
fixture_digest: brokers[0].broker.fixtureDigest, renderer_digest: rendererDigest,
|
|
116
|
-
render_count: renders.length, browser_count: 1, renders, runtimeCalls,
|
|
144
|
+
render_count: renders.length, browser_count: 1, ...(named ? { contexts: contexts.map(value => value.name) } : {}), renders, runtimeCalls,
|
|
117
145
|
errors: passed ? [] : [...fixtureErrors, ...notReady, { phase: 'renderer', message: 'At least one width or read-only fixture failed verification.' }] };
|
|
118
146
|
Object.defineProperty(result, 'screenshots', { value: screenshots, enumerable: false });
|
|
119
147
|
// The skeleton is measured only from a view that rendered cleanly, with a renderer that can measure it.
|
|
120
148
|
if (passed && typeof library.buildSkeletonDocument === 'function') {
|
|
121
|
-
const capture = await captureSpaceSkeleton({ library, pool, release, capabilities, timeoutMs, signal, authorizationMode, unavailableActions
|
|
149
|
+
const capture = await captureSpaceSkeleton({ library, pool, release, capabilities, timeoutMs, signal, authorizationMode, unavailableActions,
|
|
150
|
+
contexts, named });
|
|
122
151
|
result.skeleton = capture.skeleton;
|
|
123
152
|
Object.defineProperty(result, 'skeletonDocument', { value: capture.document, enumerable: false });
|
|
124
153
|
Object.defineProperty(result, 'pendingScreenshots', { value: capture.screenshots, enumerable: false });
|
|
@@ -140,15 +169,19 @@ const READY_MARGIN_MS = 5_000;
|
|
|
140
169
|
const readyWait = timeoutMs => (timeoutMs - READY_MARGIN_MS >= 1_000 ? timeoutMs - READY_MARGIN_MS : undefined);
|
|
141
170
|
|
|
142
171
|
const sha256 = bytes => createHash('sha256').update(bytes).digest('hex');
|
|
143
|
-
const captureFailure = (width, locale, error) => ({ check: 'capture_failed', severity: 'warning', width, locale,
|
|
172
|
+
const captureFailure = (width, locale, error, extra = {}) => ({ check: 'capture_failed', severity: 'warning', width, locale, ...extra,
|
|
144
173
|
message: `The loading skeleton could not be measured: ${String(error?.code || error?.message || error).slice(0, 300)}` });
|
|
145
174
|
|
|
146
175
|
/**
|
|
147
176
|
* Loading skeleton capture, per width and locale: (1) pending with the view's fallback skeleton gives the region
|
|
148
177
|
* boxes and landmarks, (2) final measures the bones inside those boxes, (3) pending again with the measured bones
|
|
149
178
|
* injected is checked and screenshotted. Never throws: failures become warnings and status `failed`.
|
|
179
|
+
* The first fixture context is the opening view; `context.skeletonParams` and every other context add the regions they
|
|
180
|
+
* show. (4) A context whose params open a list item (`open`) is also drawn with the list answered and the item's record
|
|
181
|
+
* held: the reader's loading state, checked and screenshotted as `state: 'reader'`.
|
|
150
182
|
*/
|
|
151
|
-
async function captureSpaceSkeleton({ library, pool, release, capabilities, timeoutMs, signal, authorizationMode, unavailableActions
|
|
183
|
+
async function captureSpaceSkeleton({ library, pool, release, capabilities, timeoutMs, signal, authorizationMode, unavailableActions,
|
|
184
|
+
contexts = [], named = false }) {
|
|
152
185
|
const findings = [], screenshots = [], combos = [];
|
|
153
186
|
let failed = false, document = null;
|
|
154
187
|
const widths = library.SKELETON_WIDTHS || [390, 1440], locales = library.SKELETON_LOCALES || ['en', 'fr'];
|
|
@@ -157,8 +190,10 @@ async function captureSpaceSkeleton({ library, pool, release, capabilities, time
|
|
|
157
190
|
// view that is wholly editor-only does not exist for the public: it keeps the editors' skeleton.
|
|
158
191
|
const marks = release.manifest.editors_only;
|
|
159
192
|
const audience = marks && !marks.view ? 'public' : 'editor';
|
|
160
|
-
const render = (width, options, params) => library.renderView({ broker: createSpaceFixtureBroker({ release, capabilities, width,
|
|
161
|
-
outputs: ['markdown'], authorizationMode, unavailableActions, params, audience }), pool, outputs: ['markdown'], width, timeoutMs, signal, ...options });
|
|
193
|
+
const render = (width, options, params, context) => library.renderView({ broker: createSpaceFixtureBroker({ release, capabilities, width,
|
|
194
|
+
outputs: ['markdown'], authorizationMode, unavailableActions, params, audience, context }), pool, outputs: ['markdown'], width, timeoutMs, signal, ...options });
|
|
195
|
+
// The pending landmarks end a region's measurement at the next one below it (a section head under a KPI row).
|
|
196
|
+
const measuring = (regions, pending) => ({ measure: { regions, landmarks: pending?.landmarks || [] } });
|
|
162
197
|
// Both widths of one locale run together: the pool holds two renders at a time.
|
|
163
198
|
const each = async (step) => {
|
|
164
199
|
for (const locale of locales) {
|
|
@@ -178,28 +213,30 @@ async function captureSpaceSkeleton({ library, pool, release, capabilities, time
|
|
|
178
213
|
combo.regions = combo.first?.pending?.static ? [] : (combo.first?.pending?.regions || []);
|
|
179
214
|
const valid = combo.regions.filter(region => region.valid);
|
|
180
215
|
if (!valid.length) return;
|
|
181
|
-
combo.final = (await render(combo.width, {
|
|
216
|
+
combo.final = (await render(combo.width, { ...measuring(valid, combo.first.pending), locale: combo.locale })).skeleton_measure;
|
|
182
217
|
});
|
|
183
218
|
const measurements = {};
|
|
184
219
|
for (const combo of combos) if (combo.final) (measurements[combo.width] ||= {})[combo.locale] = { regions: combo.final.regions };
|
|
185
220
|
// Regions a view shows only under other params (a tab it can open on), declared in the fixtures as
|
|
186
|
-
// context.skeletonParams: measured the same way and added beside the opening
|
|
187
|
-
// is a warning and never drops the regions already measured.
|
|
188
|
-
|
|
221
|
+
// context.skeletonParams, or in another fixture context: measured the same way and added beside the opening
|
|
222
|
+
// view's own regions. A failure here is a warning and never drops the regions already measured.
|
|
223
|
+
const extras = [...fixtureSkeletonParams(release).map(params => ({ params })),
|
|
224
|
+
...contexts.slice(1).map(value => ({ context: value.name }))];
|
|
225
|
+
for (const { params, context } of extras) {
|
|
189
226
|
for (const locale of locales) {
|
|
190
227
|
const settled = await Promise.allSettled(widths.map(async (width) => {
|
|
191
|
-
const pending = (await render(width, { pending: true, locale }, params))?.pending;
|
|
228
|
+
const pending = (await render(width, { pending: true, locale }, params, context))?.pending;
|
|
192
229
|
const known = new Set((measurements[width]?.[locale]?.regions || []).map(region => region.key));
|
|
193
230
|
const valid = pending?.static ? [] : (pending?.regions || []).filter(region => region.valid && !known.has(region.key));
|
|
194
231
|
if (!valid.length) return;
|
|
195
|
-
const final = (await render(width, {
|
|
232
|
+
const final = (await render(width, { ...measuring(valid, pending), locale }, params, context)).skeleton_measure;
|
|
196
233
|
const added = (final?.regions || []).filter(region => !known.has(region.key));
|
|
197
234
|
if (!added.length) return;
|
|
198
235
|
const entry = ((measurements[width] ||= {})[locale] ||= { regions: [] });
|
|
199
236
|
entry.regions = [...entry.regions, ...added];
|
|
200
237
|
}));
|
|
201
238
|
settled.forEach((value, index) => {
|
|
202
|
-
if (value.status === 'rejected') findings.push(captureFailure(widths[index], locale, value.reason));
|
|
239
|
+
if (value.status === 'rejected') findings.push(captureFailure(widths[index], locale, value.reason, context && named ? { context } : {}));
|
|
203
240
|
});
|
|
204
241
|
}
|
|
205
242
|
}
|
|
@@ -225,6 +262,20 @@ async function captureSpaceSkeleton({ library, pool, release, capabilities, time
|
|
|
225
262
|
} catch (error) {
|
|
226
263
|
failed = true; findings.push(captureFailure(null, null, error));
|
|
227
264
|
}
|
|
265
|
+
// The reader's loading state: the list answers, the opened item's reads stay held. A view that opens nothing
|
|
266
|
+
// with these params is static there and adds nothing.
|
|
267
|
+
const readers = [];
|
|
268
|
+
for (const value of contexts.filter(item => item.open)) {
|
|
269
|
+
const extra = { state: 'reader', ...(named ? { context: value.name } : {}) };
|
|
270
|
+
for (const locale of locales) {
|
|
271
|
+
const settled = await Promise.allSettled(widths.map(width => render(width, { pending: { hold: READER_HOLDS }, locale,
|
|
272
|
+
...(document ? { skeleton: document } : {}) }, undefined, value.name)));
|
|
273
|
+
settled.forEach((result, index) => {
|
|
274
|
+
if (result.status === 'rejected') { findings.push(captureFailure(widths[index], locale, result.reason, extra)); return; }
|
|
275
|
+
readers.push({ width: widths[index], locale, extra, shown: result.value });
|
|
276
|
+
});
|
|
277
|
+
}
|
|
278
|
+
}
|
|
228
279
|
for (const combo of combos) {
|
|
229
280
|
const shown = combo.checked || combo.first;
|
|
230
281
|
if (!shown) continue;
|
|
@@ -237,7 +288,16 @@ async function captureSpaceSkeleton({ library, pool, release, capabilities, time
|
|
|
237
288
|
const png = Buffer.from(shown.screenshot.data_base64, 'base64');
|
|
238
289
|
screenshots.push({ width: combo.width, locale: combo.locale, png, sha256: sha256(png) });
|
|
239
290
|
}
|
|
291
|
+
for (const { width, locale, extra, shown } of readers) {
|
|
292
|
+
if (!shown?.pending || shown.pending.static) continue;
|
|
293
|
+
try {
|
|
294
|
+
findings.push(...library.runSkeletonChecks({ width, locale, pending: shown.pending, regions: [] }).map(finding => ({ ...finding, ...extra })));
|
|
295
|
+
} catch (error) { findings.push(captureFailure(width, locale, error, extra)); }
|
|
296
|
+
if (!shown.screenshot?.data_base64) continue;
|
|
297
|
+
const png = Buffer.from(shown.screenshot.data_base64, 'base64');
|
|
298
|
+
screenshots.push({ width, locale, ...extra, png, sha256: sha256(png) });
|
|
299
|
+
}
|
|
240
300
|
const status = document ? 'captured' : failed ? 'failed' : 'none';
|
|
241
301
|
return { document, screenshots, skeleton: { status, audience, regions: document ? Object.keys(document.regions).sort() : [], findings,
|
|
242
|
-
pending_screenshots: screenshots.map(({
|
|
302
|
+
pending_screenshots: screenshots.map(({ png: _png, ...value }) => value) } };
|
|
243
303
|
}
|
|
@@ -38,7 +38,23 @@ const OPS = new Set(['equals', 'not_equals', 'in', 'contains', 'not_contains', '
|
|
|
38
38
|
const PAGE_COLUMN_OPS = { record_key: ['equals', 'not_equals', 'in'], id: ['equals', 'not_equals', 'in'],
|
|
39
39
|
content_type: ['equals', 'not_equals', 'is_empty', 'is_not_empty'], file_type: ['equals', 'not_equals', 'is_empty', 'is_not_empty'],
|
|
40
40
|
title: ['equals', 'not_equals', 'is_empty', 'is_not_empty'] };
|
|
41
|
-
const PAGE_PROPERTY_OPS = { select: ['equals', 'not_equals', 'is_empty', 'is_not_empty'], checkbox: ['equals', 'not_equals'] };
|
|
41
|
+
const PAGE_PROPERTY_OPS = { select: ['equals', 'not_equals', 'in', 'is_empty', 'is_not_empty'], checkbox: ['equals', 'not_equals'] };
|
|
42
|
+
// `in` lists up to 500 record ids, or up to 100 options of a select or status property (in_list_limit in
|
|
43
|
+
// server/lib/native_data_query.py).
|
|
44
|
+
const IN_LIMITS = { column: [500, 'record ids'], property: [100, 'options'] };
|
|
45
|
+
// A filter nests at most 12 levels and holds at most 200 conditions (normalize_native_filter).
|
|
46
|
+
const MAX_FILTER_DEPTH = 12;
|
|
47
|
+
const MAX_FILTER_CONDITIONS = 200;
|
|
48
|
+
|
|
49
|
+
function inLimit(field) {
|
|
50
|
+
return IN_LIMITS[plain(field) && 'column' in field ? 'column' : 'property'];
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
// What an `in` adds to the filter: a property `in` listing more than one value reads as an `or` of them, so it adds
|
|
54
|
+
// that many conditions and one level; a column `in` adds nothing (in_expansion in server/lib/native_data_query.py).
|
|
55
|
+
function inExpansion(field, value) {
|
|
56
|
+
return plain(field) && !('column' in field) && Array.isArray(value) && value.length > 1 ? value.length : 0;
|
|
57
|
+
}
|
|
42
58
|
const EMPTY_OPS = new Set(['is_empty', 'is_not_empty']);
|
|
43
59
|
const KIND_ALIASES = { phone: 'phone_number', string: 'text' };
|
|
44
60
|
const CRON_BOUNDS = [[0, 59], [0, 23], [1, 31], [1, 12], [0, 7]];
|
|
@@ -197,9 +213,9 @@ function checkPlaceholder(value, params, collection, where) {
|
|
|
197
213
|
if (property !== undefined && params[name].type !== 'record') throw usageError(`${where}: only record params have properties, such as {${name}}.`);
|
|
198
214
|
}
|
|
199
215
|
|
|
200
|
-
function walkFilter(node, visit, where, depth = 0, budget = { left:
|
|
216
|
+
function walkFilter(node, visit, where, depth = 0, budget = { left: MAX_FILTER_CONDITIONS }) {
|
|
201
217
|
budget.left -= 1;
|
|
202
|
-
if (depth >
|
|
218
|
+
if (depth > MAX_FILTER_DEPTH || budget.left < 0) throw usageError(`${where}: the filter is too complex; use fewer conditions.`);
|
|
203
219
|
if (depth === 0 && plain(node) && !Object.keys(node).length) return;
|
|
204
220
|
if (!plain(node)) throw usageError(`${where}: a filter is an object.`);
|
|
205
221
|
for (const group of ['and', 'or']) {
|
|
@@ -215,6 +231,13 @@ function walkFilter(node, visit, where, depth = 0, budget = { left: 200 }) {
|
|
|
215
231
|
|| typeof Object.values(field)[0] !== 'string' || !OPS.has(node.op)) {
|
|
216
232
|
throw usageError(`${where}: each condition is { field: { property }, op, value } in the native filter language.`);
|
|
217
233
|
}
|
|
234
|
+
// A list over its length limit is left to visit(), which names the limit instead of calling the filter too complex.
|
|
235
|
+
const fits = !Array.isArray(node.value) || node.value.length <= inLimit(field)[0];
|
|
236
|
+
const extra = node.op === 'in' && fits ? inExpansion(field, node.value) : 0;
|
|
237
|
+
budget.left -= extra;
|
|
238
|
+
if (extra && (depth + 1 > MAX_FILTER_DEPTH || budget.left < 0)) {
|
|
239
|
+
throw usageError(`${where}: the filter is too complex; use fewer conditions.`);
|
|
240
|
+
}
|
|
218
241
|
visit(node);
|
|
219
242
|
}
|
|
220
243
|
|
|
@@ -268,8 +291,9 @@ function validatePage(name, page, resource) {
|
|
|
268
291
|
return;
|
|
269
292
|
}
|
|
270
293
|
if (!('value' in condition)) throw usageError(`${where}: ${condition.op} needs a value.`);
|
|
271
|
-
|
|
272
|
-
|
|
294
|
+
const [cap, items] = inLimit(condition.field);
|
|
295
|
+
if (condition.op === 'in' && (!Array.isArray(condition.value) || condition.value.length < 1 || condition.value.length > cap)) {
|
|
296
|
+
throw usageError(`${where}: in takes a list of 1 to ${cap} ${items}.`);
|
|
273
297
|
}
|
|
274
298
|
for (const value of condition.op === 'in' ? condition.value : [condition.value]) {
|
|
275
299
|
// Fixed values only: neither {param} nor {{param}} is ever bound in a page rule (the server refuses both).
|
|
@@ -315,6 +339,15 @@ function validateShows(name, declaration, params, resources, collection) {
|
|
|
315
339
|
throw usageError(`${where}: when names a declared boolean param.`);
|
|
316
340
|
}
|
|
317
341
|
if (!('value' in condition)) return;
|
|
342
|
+
if (condition.op === 'in') {
|
|
343
|
+
// A property `in` (select or status) always lists 1 to 100 values; a column `in` given as a list lists 1 to
|
|
344
|
+
// 500 (a scalar there stays as before). Each value is fixed or one placeholder.
|
|
345
|
+
const [cap, items] = inLimit(condition.field);
|
|
346
|
+
const listed = condition.value;
|
|
347
|
+
if ((Array.isArray(listed) || !('column' in condition.field)) && (!Array.isArray(listed) || listed.length < 1 || listed.length > cap)) {
|
|
348
|
+
throw usageError(`${where}: in takes a list of 1 to ${cap} ${items}.`);
|
|
349
|
+
}
|
|
350
|
+
}
|
|
318
351
|
const values = condition.op === 'in' && Array.isArray(condition.value) ? condition.value : [condition.value];
|
|
319
352
|
values.forEach(value => checkPlaceholder(value, params, collection, where));
|
|
320
353
|
}, where);
|
package/src/runtime/transport.js
CHANGED
|
@@ -3,6 +3,7 @@ import { createReadStream } from 'node:fs';
|
|
|
3
3
|
import { dirname } from 'node:path';
|
|
4
4
|
import { CliError, EXIT_CODES } from './errors.js';
|
|
5
5
|
import { agentIdentityHeaders } from './agent-identity.js';
|
|
6
|
+
import { deadlineDispatcher, isTransportTimeout, networkCauseCode } from './http-agent.js';
|
|
6
7
|
import {
|
|
7
8
|
credentialIsExpired,
|
|
8
9
|
getJwtExpiration,
|
|
@@ -401,6 +402,8 @@ export async function httpRequest({
|
|
|
401
402
|
};
|
|
402
403
|
};
|
|
403
404
|
|
|
405
|
+
// The AbortController above is this request's one deadline (http-agent.js).
|
|
406
|
+
const dispatcher = await deadlineDispatcher();
|
|
404
407
|
try {
|
|
405
408
|
let requestBody = resolveBody();
|
|
406
409
|
let response = await fetch(`${runtime.apiBase}${path}`, {
|
|
@@ -408,6 +411,7 @@ export async function httpRequest({
|
|
|
408
411
|
headers: { ...headers, ...requestBody.headers },
|
|
409
412
|
body: requestBody.body,
|
|
410
413
|
signal: controller.signal,
|
|
414
|
+
...(dispatcher ? { dispatcher } : {}),
|
|
411
415
|
...(requestBody.duplex ? { duplex: requestBody.duplex } : {}),
|
|
412
416
|
});
|
|
413
417
|
|
|
@@ -435,6 +439,7 @@ export async function httpRequest({
|
|
|
435
439
|
headers: { ...headers, ...requestBody.headers },
|
|
436
440
|
body: requestBody.body,
|
|
437
441
|
signal: controller.signal,
|
|
442
|
+
...(dispatcher ? { dispatcher } : {}),
|
|
438
443
|
...(requestBody.duplex ? { duplex: requestBody.duplex } : {}),
|
|
439
444
|
});
|
|
440
445
|
payloadReadError = null;
|
|
@@ -487,24 +492,34 @@ export async function httpRequest({
|
|
|
487
492
|
throw error;
|
|
488
493
|
}
|
|
489
494
|
|
|
490
|
-
|
|
495
|
+
// This attempt's own limit, which a command may set longer or a retry shorter than --timeout-ms.
|
|
496
|
+
if (error?.name === 'AbortError' || isTransportTimeout(error)) {
|
|
497
|
+
// Our own deadline names its limit; a transport that stopped first (a checkout without undici) names its code.
|
|
498
|
+
const limit = error?.name === 'AbortError'
|
|
499
|
+
? `within ${timeoutMs >= 1000 ? `${Math.round(timeoutMs / 1000)} s` : `${timeoutMs} ms`}` : `before the transport gave up (${networkCauseCode(error)})`;
|
|
491
500
|
throw new CliError({
|
|
492
501
|
code: 'network_timeout',
|
|
493
|
-
message:
|
|
502
|
+
message: `${path} got no answer from ${runtime.apiBase} ${limit} (request ${requestId}).`,
|
|
494
503
|
exitCode: EXIT_CODES.network,
|
|
495
504
|
retryable: true,
|
|
505
|
+
details: { path, request_id: requestId, timeout_ms: timeoutMs },
|
|
496
506
|
hints: [
|
|
497
507
|
{ command: 'notis doctor', reason: 'Check API reachability' },
|
|
498
|
-
|
|
508
|
+
// A retry's attempt gets only what is left of the budget: never suggest less than the limit already set.
|
|
509
|
+
{ command: `--timeout-ms ${Math.max(timeoutMs, runtime.timeoutMs || 0) * 2}`, reason: 'Retry with a longer timeout' },
|
|
499
510
|
],
|
|
500
511
|
});
|
|
501
512
|
}
|
|
502
513
|
|
|
514
|
+
// fetch says only "fetch failed": the network code under it (ECONNRESET, ENOTFOUND, ...) is what a user can act on.
|
|
515
|
+
const causeCode = networkCauseCode(error);
|
|
516
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
503
517
|
throw new CliError({
|
|
504
518
|
code: 'network_error',
|
|
505
|
-
message:
|
|
519
|
+
message: `${path} failed before ${runtime.apiBase} answered: ${message}${causeCode && !message.includes(causeCode) ? ` (${causeCode})` : ''} (request ${requestId}).`,
|
|
506
520
|
exitCode: EXIT_CODES.network,
|
|
507
521
|
retryable: true,
|
|
522
|
+
details: { path, request_id: requestId, ...(causeCode ? { cause_code: causeCode } : {}) },
|
|
508
523
|
cause: error,
|
|
509
524
|
});
|
|
510
525
|
}
|
|
@@ -31,7 +31,10 @@ export async function renderViewWithCliRuntime({ runtime, url, outputs = ['markd
|
|
|
31
31
|
// The stage a render stopped at (a fixed step name, never page content) makes a rare failure diagnosable.
|
|
32
32
|
if (error instanceof library.ViewRenderError) throw new CliError({ code: error.code,
|
|
33
33
|
message: error.message, exitCode: EXIT_CODES.backend, retryable: error.status >= 500 || error.status === 429, cause: error,
|
|
34
|
-
details: typeof error.stage === 'string' && /^[a-z_]{1,40}$/.test(error.stage) ? { stage: error.stage } : {}
|
|
34
|
+
details: { ...(typeof error.stage === 'string' && /^[a-z_]{1,40}$/.test(error.stage) ? { stage: error.stage } : {}),
|
|
35
|
+
// A refused read names its action and reason code; a failed view's reason is page text and stays out.
|
|
36
|
+
...(error.code === 'render_read_unavailable' ? { ...(typeof error.actionId === 'string' ? { action_id: error.actionId } : {}),
|
|
37
|
+
...(typeof error.reason === 'string' && /^[a-z_]{1,40}$/.test(error.reason) ? { reason: error.reason } : {}) } : {}) } });
|
|
35
38
|
throw error;
|
|
36
39
|
}
|
|
37
40
|
if (!directory) return { result, artifacts: null };
|
|
@@ -1,45 +1,12 @@
|
|
|
1
1
|
import type { Config } from 'tailwindcss';
|
|
2
2
|
import tailwindAnimate from 'tailwindcss-animate';
|
|
3
3
|
|
|
4
|
+
// The Notis theme colours (bg-accent, text-muted-foreground, bg-chart-2/40...) come from @notis/sdk/vite.
|
|
5
|
+
// A colour defined here wins over the Notis one of the same name.
|
|
4
6
|
const config: Config = {
|
|
5
7
|
darkMode: 'class',
|
|
6
8
|
theme: {
|
|
7
9
|
extend: {
|
|
8
|
-
colors: {
|
|
9
|
-
border: 'hsl(var(--border))',
|
|
10
|
-
input: 'hsl(var(--input))',
|
|
11
|
-
ring: 'hsl(var(--ring))',
|
|
12
|
-
background: 'hsl(var(--background))',
|
|
13
|
-
foreground: 'hsl(var(--foreground))',
|
|
14
|
-
primary: {
|
|
15
|
-
DEFAULT: 'hsl(var(--primary))',
|
|
16
|
-
foreground: 'hsl(var(--primary-foreground))',
|
|
17
|
-
},
|
|
18
|
-
secondary: {
|
|
19
|
-
DEFAULT: 'hsl(var(--secondary))',
|
|
20
|
-
foreground: 'hsl(var(--secondary-foreground))',
|
|
21
|
-
},
|
|
22
|
-
destructive: {
|
|
23
|
-
DEFAULT: 'hsl(var(--destructive))',
|
|
24
|
-
foreground: 'hsl(var(--destructive-foreground))',
|
|
25
|
-
},
|
|
26
|
-
muted: {
|
|
27
|
-
DEFAULT: 'hsl(var(--muted))',
|
|
28
|
-
foreground: 'hsl(var(--muted-foreground))',
|
|
29
|
-
},
|
|
30
|
-
accent: {
|
|
31
|
-
DEFAULT: 'hsl(var(--accent))',
|
|
32
|
-
foreground: 'hsl(var(--accent-foreground))',
|
|
33
|
-
},
|
|
34
|
-
popover: {
|
|
35
|
-
DEFAULT: 'hsl(var(--popover))',
|
|
36
|
-
foreground: 'hsl(var(--popover-foreground))',
|
|
37
|
-
},
|
|
38
|
-
card: {
|
|
39
|
-
DEFAULT: 'hsl(var(--card))',
|
|
40
|
-
foreground: 'hsl(var(--card-foreground))',
|
|
41
|
-
},
|
|
42
|
-
},
|
|
43
10
|
borderRadius: {
|
|
44
11
|
lg: 'var(--radius)',
|
|
45
12
|
md: 'calc(var(--radius) - 2px)',
|