@lowdefy/server-dev 7.0.0 → 7.2.0
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/client/Inspector.jsx +24 -75
- package/client/Page.jsx +8 -0
- package/client/Routing.jsx +0 -2
- package/client/clientBuildImports.test.mjs +5 -3
- package/client/devStreamConnections.test.mjs +1 -0
- package/client/journeyObserver/startJourneyObserver.test.mjs +11 -11
- package/client/openInEditor/OpenInEditorListener.jsx +36 -29
- package/client/openInEditor/OpenInEditorListener.test.mjs +116 -0
- package/client/{feedback → openInEditor}/elementInspect.js +9 -44
- package/client/openInEditor/findBlockLocation.js +2 -2
- package/client/openInEditor/openInEditorStyles.js +56 -0
- package/client/recorder/createPairingBuffer.test.mjs +27 -9
- package/client/recorder/createRecorder.js +11 -7
- package/client/recorder/createRecorder.test.mjs +9 -9
- package/client/recorder/isPasswordElement.js +41 -0
- package/client/recorder/keyChord.test.mjs +1 -0
- package/{client/recorder/toJsonSafe.js → lib/build/mobileConfig.js} +9 -12
- package/lib/client/auth/AuthConfigured.jsx +75 -48
- package/lib/client/auth/authNotConfiguredParity.test.mjs +1 -0
- package/lib/client/auth/authTemplateSync.test.mjs +1 -0
- package/lib/client/auth/betterAuthSessionContract.test.mjs +2 -1
- package/lib/client/auth/sessionCaller.js +56 -0
- package/lib/client/auth/sessionCaller.test.mjs +78 -0
- package/lib/client/getPagePath.test.mjs +1 -0
- package/lib/client/utils/formatErrorsForCopy.test.mjs +1 -0
- package/lib/client/utils/getErrorBarColor.test.mjs +1 -0
- package/lib/client/utils/usePageConfig.test.mjs +15 -15
- package/lib/configTree/buildConfigTree.test.mjs +6 -8
- package/lib/configTree/collectConfigText.test.mjs +1 -0
- package/lib/configTree/runConfigTreeBuild.mjs +2 -1
- package/lib/configTree/runConfigTreeBuild.skipPluginChecks.test.mjs +11 -11
- package/lib/configTree/runConfigTreeBuild.test.mjs +2 -2
- package/lib/docs/addNestedEndpoints.test.mjs +1 -0
- package/lib/docs/checkAgentFiles.test.mjs +1 -0
- package/lib/docs/checkStepReferences.test.mjs +3 -3
- package/lib/docs/clientErrorStore.test.mjs +4 -4
- package/lib/docs/createBrowserLifecycle.test.mjs +40 -24
- package/lib/docs/createDocsMcpServer.js +195 -138
- package/lib/docs/createDocsMcpServer.test.mjs +331 -25
- package/lib/docs/createDocsMcpServerRunJourney.test.mjs +5 -5
- package/lib/docs/createJourneyActors.chromium.test.mjs +3 -3
- package/lib/docs/createJourneyActors.test.mjs +4 -4
- package/lib/docs/dataSets/checkSharedCollectionIds.js +20 -9
- package/lib/docs/dataSets/dataSetJourneys.chromium.mongodb.test.mjs +59 -11
- package/{src/routes/docs/content.js → lib/docs/dataSets/describeTargetKey.js} +10 -14
- package/lib/docs/dataSets/drainSessionWork.test.mjs +21 -5
- package/lib/docs/dataSets/getDataStore.js +11 -3
- package/lib/docs/dataSets/getDataStore.mongodb.test.mjs +3 -3
- package/lib/docs/dataSets/getDataStore.test.mjs +32 -20
- package/lib/docs/dataSets/groupDataSetByCollection.js +19 -11
- package/lib/docs/dataSets/mergeCollectionIndexes.test.mjs +1 -0
- package/lib/docs/dataSets/openDataSession.js +36 -20
- package/lib/docs/dataSets/openDataSession.mongodb.test.mjs +175 -7
- package/lib/docs/dataSets/pickDataStorePort.test.mjs +2 -2
- package/lib/docs/dataSets/readDataSession.test.mjs +1 -0
- package/lib/docs/dataSets/readDataSet.js +34 -19
- package/lib/docs/dataSets/readDataSet.test.mjs +57 -25
- package/lib/docs/dataSets/resolveJourneyDataSet.test.mjs +1 -0
- package/lib/docs/dataSets/sessionDatabaseName.js +32 -0
- package/lib/docs/dataSets/sweepOrphanDatabases.js +7 -4
- package/lib/docs/dataSets/test/app/lowdefy.yaml +22 -0
- package/lib/docs/dataSets/test/app/tests/data/shop.yaml +4 -0
- package/lib/docs/dataSets/test/buildTestApp.mjs +1 -1
- package/lib/docs/devEventBus.js +7 -2
- package/lib/docs/devEventBus.test.mjs +12 -10
- package/lib/docs/devToolDefinitions.js +87 -135
- package/lib/docs/device/buildDeviceCommand.js +103 -0
- package/lib/docs/device/buildDeviceCommand.test.mjs +142 -0
- package/lib/docs/device/captureDevice.js +85 -0
- package/lib/docs/device/checkShownPage.js +56 -0
- package/lib/docs/device/createFakePhoneTab.mjs +77 -0
- package/lib/docs/device/deviceAction.js +74 -0
- package/lib/docs/device/deviceTools.test.mjs +604 -0
- package/lib/docs/device/findDeviceTab.js +50 -0
- package/lib/docs/device/findDeviceTarget.js +73 -0
- package/lib/docs/device/injectDevice.js +160 -0
- package/lib/docs/device/listDevices.js +100 -0
- package/lib/docs/device/listDevices.test.mjs +105 -0
- package/lib/docs/device/runDeviceJourney.js +68 -0
- package/lib/docs/device/runDeviceSteps.js +164 -0
- package/lib/docs/device/screenshotDevice.js +68 -0
- package/lib/docs/device/sendDeviceStep.js +52 -0
- package/lib/docs/device/startDevice.js +150 -0
- package/lib/docs/docs.test.mjs +44 -28
- package/lib/docs/docsIndex.test.mjs +1 -0
- package/lib/docs/findConfig.js +3 -4
- package/lib/docs/findPageBlock.js +35 -0
- package/lib/docs/findPageBlock.test.mjs +45 -0
- package/lib/docs/fitResponse.js +18 -17
- package/lib/docs/fitResponse.test.mjs +18 -0
- package/lib/docs/getBrowser.js +4 -4
- package/lib/docs/getBrowser.test.mjs +32 -16
- package/lib/docs/getBuildId.test.mjs +1 -0
- package/lib/docs/getBuildStatus.js +29 -3
- package/lib/docs/getBuildStatus.test.mjs +108 -12
- package/lib/docs/getBuildStatusAfterEdits.test.mjs +8 -8
- package/{src/routes/docs/appMap.js → lib/docs/getConfigDirectory.js} +3 -5
- package/lib/docs/getHazards.js +4 -1
- package/lib/docs/getHazards.test.mjs +9 -7
- package/lib/docs/getOverview.js +22 -44
- package/lib/docs/getOverviewBasePath.test.mjs +1 -0
- package/lib/docs/getStaleStatus.test.mjs +1 -0
- package/lib/docs/inspectState.js +78 -3
- package/lib/docs/inspectState.test.mjs +61 -9
- package/lib/docs/inspectStateFromTab.js +38 -6
- package/lib/docs/inspectStateFromTab.test.mjs +79 -0
- package/lib/docs/inspectStateHeadless.js +98 -34
- package/lib/docs/inspectStateHeadless.test.mjs +17 -5
- package/lib/docs/installHeadlessShell.failure.test.mjs +9 -5
- package/lib/docs/installHeadlessShell.js +5 -2
- package/lib/docs/installHeadlessShell.test.mjs +8 -5
- package/lib/docs/installHeadlessShell.timeout.test.mjs +32 -12
- package/lib/docs/isDeepEqual.js +37 -0
- package/lib/docs/isHeadlessShellIncomplete.test.mjs +1 -0
- package/lib/docs/isPageReady.test.mjs +1 -0
- package/lib/docs/journeyMutantCookie.chromium.test.mjs +3 -3
- package/lib/docs/journeyRunRecording.test.mjs +1 -0
- package/lib/docs/keepEventStreamAlive.test.mjs +1 -0
- package/lib/docs/launchBrowser.test.mjs +8 -8
- package/lib/docs/listTypes.js +58 -8
- package/lib/docs/loadFrameworkHazards.test.mjs +1 -0
- package/lib/docs/matchJourneyRoute.test.mjs +1 -0
- package/lib/docs/observe/createJourneyAppErrors.test.mjs +3 -3
- package/lib/docs/observe/evaluateInvariants.test.mjs +1 -0
- package/lib/docs/observe/hasNoEffect.test.mjs +1 -0
- package/lib/docs/observe/withAppErrors.test.mjs +1 -0
- package/lib/docs/openJourneyEmail.test.mjs +6 -6
- package/lib/docs/pageBuildStatus.test.mjs +6 -6
- package/lib/docs/pollTab.js +100 -0
- package/lib/docs/pollTab.test.mjs +64 -0
- package/lib/docs/rails/authEngineActions.test.mjs +1 -0
- package/lib/docs/rails/authEngineMethods.test.mjs +2 -1
- package/lib/docs/rails/checkAuthActionsRan.test.mjs +5 -5
- package/lib/docs/rails/createDataSetRails.test.mjs +1 -0
- package/lib/docs/rails/findExternalBlocks.js +3 -3
- package/lib/docs/rails/findExternalBlocks.test.mjs +1 -0
- package/lib/docs/readJourneyEmailMatch.test.mjs +2 -2
- package/lib/docs/readJourneySession.js +1 -1
- package/lib/docs/reportDevToolFault.js +29 -0
- package/lib/docs/reportDevToolFault.test.mjs +34 -0
- package/lib/docs/requestRestart.test.mjs +1 -0
- package/lib/docs/resolvePageInstance.test.mjs +1 -0
- package/lib/docs/resolveSource.js +2 -2
- package/lib/docs/resolveSource.test.mjs +6 -6
- package/lib/docs/reviewPageBuilds.test.mjs +2 -2
- package/lib/docs/runCheck.test.mjs +3 -3
- package/lib/docs/runCheckChild.js +2 -1
- package/lib/docs/runEndpoint.js +23 -10
- package/lib/docs/runEndpoint.test.mjs +42 -37
- package/lib/docs/runErrorBuffers.test.mjs +1 -0
- package/lib/docs/runJourney.js +21 -1
- package/lib/docs/runJourney.test.mjs +119 -99
- package/lib/docs/runJourneyDataSet.test.mjs +26 -26
- package/lib/docs/runJourneySteps.js +8 -29
- package/lib/docs/runRequest.js +6 -6
- package/lib/docs/runRequest.test.mjs +22 -22
- package/lib/docs/screenshotPage.js +6 -7
- package/lib/docs/screenshotPage.test.mjs +46 -46
- package/lib/docs/screenshotPageClip.test.mjs +10 -10
- package/lib/docs/searchDocs.test.mjs +1 -0
- package/lib/docs/searchIcons.test.mjs +5 -5
- package/lib/docs/selectFinalState.test.mjs +1 -0
- package/lib/docs/serverErrorStore.test.mjs +4 -4
- package/lib/docs/setupTestFixtures.mjs +25 -0
- package/lib/docs/splitSearchTerms.test.mjs +1 -0
- package/lib/docs/tabAvailable.js +1 -1
- package/lib/docs/tabChannel.js +90 -14
- package/lib/docs/tabChannel.test.mjs +40 -15
- package/lib/docs/validateJourneyTimeout.test.mjs +1 -0
- package/lib/docs/validateStateSelection.test.mjs +1 -0
- package/lib/docs/validateViewport.test.mjs +1 -0
- package/lib/docs/waitForBuild.test.mjs +1 -0
- package/lib/docs/withBrowserSlot.test.mjs +5 -5
- package/lib/docs/withDataSession.js +2 -2
- package/lib/server/applyDataSetRedirect.js +14 -5
- package/lib/server/applyDataSetRedirect.test.mjs +121 -15
- package/lib/server/applyDataSetRedirectTenantReach.test.mjs +5 -1
- package/lib/server/applyDataSetRedirectWalled.test.mjs +5 -1
- package/lib/server/auth/getHeadlessUser.js +6 -0
- package/lib/server/auth/getHeadlessUser.test.mjs +13 -2
- package/lib/server/auth/resolveHeadlessUser.test.mjs +1 -0
- package/lib/server/contextMapBudget.test.mjs +3 -3
- package/lib/server/continueJitKeys.test.mjs +1 -0
- package/lib/server/createLowdefyContext.js +8 -4
- package/lib/server/createLowdefyContext.test.mjs +38 -35
- package/lib/server/getClientAddress.test.mjs +2 -2
- package/lib/server/getPageJitEnrichment.test.mjs +1 -0
- package/lib/server/importAppCode.test.mjs +2 -2
- package/lib/server/jitPageBuilder.js +27 -3
- package/lib/server/jitPageBuilder.mobileTypes.test.mjs +65 -0
- package/lib/server/jitPageBuilder.skipPluginChecks.test.mjs +5 -6
- package/lib/server/jitPageBuilder.test.mjs +4 -4
- package/lib/server/journeyCookies.test.mjs +1 -0
- package/lib/server/loadDynamicJsMap.js +10 -1
- package/lib/server/log/createHandleError.js +10 -5
- package/lib/server/log/createHandleError.test.mjs +19 -8
- package/lib/server/log/createLogger.test.mjs +2 -2
- package/lib/server/mutantDataSetWrappers.test.mjs +5 -1
- package/lib/server/mutants/listMutants.test.mjs +1 -0
- package/lib/server/mutants/mutantRuns.test.mjs +1 -0
- package/lib/server/mutants/operators.test.mjs +1 -0
- package/lib/server/pageBuildRecords.test.mjs +1 -0
- package/lib/server/pageCache.test.mjs +1 -0
- package/lib/server/pageRebuilds.test.mjs +3 -3
- package/{src/routes/docs/examples.js → lib/server/pairingHeaders.js} +8 -15
- package/lib/server/pruneJitMaps.test.mjs +1 -0
- package/lib/server/readBuildApiArtifacts.test.mjs +1 -0
- package/lib/server/readInstanceRecord.test.mjs +24 -8
- package/lib/server/readMergedMaps.test.mjs +1 -0
- package/lib/server/recording/errorRecordingStamp.test.mjs +1 -0
- package/lib/server/recording/readRecordingCookie.test.mjs +2 -0
- package/lib/server/recording/servedBuilds.test.mjs +1 -0
- package/lib/server/sinkExternalConnections.test.mjs +6 -6
- package/lib/server/skipStaleMapWrites.test.mjs +12 -12
- package/lib/server/startIdleGc.test.mjs +25 -9
- package/lib/server/testFixtures/importAppCodeTwice.mjs +2 -2
- package/lib/vite/createDevServerExclude.test.mjs +1 -0
- package/manager/getContext.mjs +11 -2
- package/manager/processes/checkPendingPlugins.mjs +49 -0
- package/manager/processes/checkPendingPlugins.test.mjs +107 -0
- package/manager/processes/createIdleChild.mjs +141 -0
- package/manager/processes/createIdleChild.test.mjs +209 -0
- package/manager/processes/initialBuild.mjs +4 -15
- package/manager/processes/initialBuild.test.mjs +8 -37
- package/manager/processes/lowdefyBuild.mjs +11 -7
- package/manager/processes/lowdefyBuild.skipPluginChecks.test.mjs +23 -13
- package/manager/processes/lowdefyBuild.test.mjs +17 -15
- package/manager/processes/restartServer.test.mjs +63 -15
- package/manager/processes/shutdownServer.test.mjs +3 -3
- package/manager/processes/startFirstServer.test.mjs +23 -22
- package/manager/processes/startMailSink.mjs +11 -3
- package/manager/processes/startMailSink.test.mjs +28 -2
- package/manager/processes/startProxy.mjs +158 -27
- package/manager/processes/startProxy.pairing.test.mjs +204 -0
- package/manager/processes/startProxy.test.mjs +127 -2
- package/manager/processes/startServer.mjs +5 -7
- package/manager/processes/startServer.test.mjs +10 -9
- package/manager/processes/syncServer.mjs +31 -4
- package/manager/processes/syncServer.test.mjs +71 -6
- package/manager/processes/waitForDevServer.test.mjs +21 -6
- package/manager/run.mjs +32 -8
- package/manager/utils/BatchChanges.mjs +1 -1
- package/manager/utils/BatchChanges.test.mjs +4 -4
- package/manager/utils/acquireDevInstance.test.mjs +1 -0
- package/manager/utils/checkPairing.mjs +45 -0
- package/manager/utils/checkPairing.test.mjs +53 -0
- package/manager/utils/createBuildActivity.mjs +5 -1
- package/manager/utils/createBuildActivity.test.mjs +2 -2
- package/manager/utils/createChangeSignal.test.mjs +5 -5
- package/manager/utils/createCustomPluginMessagesMap.mjs +8 -3
- package/manager/utils/createCustomPluginTypesMap.mjs +48 -12
- package/manager/utils/createCustomPluginTypesMap.test.mjs +181 -19
- package/manager/utils/createDotPathIgnore.test.mjs +1 -0
- package/manager/utils/createGlobIgnore.mjs +45 -0
- package/manager/utils/createGlobIgnore.test.mjs +58 -0
- package/manager/utils/createGlobWatchPaths.mjs +75 -0
- package/manager/utils/createGlobWatchPaths.test.mjs +67 -0
- package/manager/utils/createIdleGc.test.mjs +31 -15
- package/manager/utils/createLanPairing.mjs +34 -0
- package/manager/utils/createLanPairing.test.mjs +46 -0
- package/manager/utils/createRequestActivity.mjs +30 -3
- package/manager/utils/createRequestActivity.test.mjs +76 -22
- package/manager/utils/createServerArtifactTracker.mjs +1 -0
- package/manager/utils/createServerArtifactTracker.test.mjs +1 -0
- package/manager/utils/findBuildFilesOutsideWatch.test.mjs +1 -0
- package/{client/recorder/collectEventActions.js → manager/utils/findSignInCode.mjs} +13 -10
- package/manager/utils/findSignInCode.test.mjs +33 -0
- package/manager/utils/formatLanPairing.mjs +32 -0
- package/manager/utils/formatLanPairing.test.mjs +40 -0
- package/manager/utils/getLanAddress.mjs +83 -0
- package/manager/utils/getLanAddress.test.mjs +70 -0
- package/manager/utils/importFresh.test.mjs +1 -0
- package/{src/routes/docs/icons.js → manager/utils/isLoopbackAddress.mjs} +11 -10
- package/manager/utils/pluginTypeCache.mjs +100 -0
- package/manager/utils/pluginTypeCache.test.mjs +141 -0
- package/manager/utils/pruneRecordings.test.mjs +1 -0
- package/manager/utils/publishBuildDirectory.order.test.mjs +2 -2
- package/manager/utils/publishBuildDirectory.test.mjs +6 -7
- package/manager/utils/readBasePath.test.mjs +1 -0
- package/manager/utils/readManagerVersion.test.mjs +1 -0
- package/manager/utils/readPluginDefinitions.mjs +6 -6
- package/manager/utils/renderTerminalQr.mjs +54 -0
- package/manager/utils/resolveDevAuthUrl.test.mjs +1 -0
- package/manager/utils/setupWatcher.mjs +19 -4
- package/manager/utils/startRecordingPruner.test.mjs +24 -8
- package/manager/utils/waitForChildExit.test.mjs +2 -2
- package/manager/utils/writeBuildStatus.test.mjs +1 -0
- package/manager/watchers/envWatcher.mjs +3 -0
- package/manager/watchers/envWatcher.test.mjs +19 -7
- package/manager/watchers/listServerPluginFiles.mjs +188 -0
- package/manager/watchers/listServerPluginFiles.test.mjs +257 -0
- package/manager/watchers/lowdefyBuildWatcher.mjs +5 -0
- package/manager/watchers/lowdefyBuildWatcher.test.mjs +63 -10
- package/manager/watchers/pluginSourceWatcher.mjs +45 -17
- package/manager/watchers/pluginSourceWatcher.test.mjs +97 -21
- package/manager/watchers/resolveFile.mjs +46 -0
- package/manager/watchers/resolveFile.test.mjs +67 -0
- package/manager/watchers/resolvePackageSpecifier.mjs +127 -0
- package/manager/watchers/resolvePackageSpecifier.test.mjs +151 -0
- package/manager/watchers/restartRequestWatcher.mjs +7 -4
- package/manager/watchers/restartRequestWatcher.test.mjs +43 -6
- package/manager/watchers/selectLocalPluginPackages.test.mjs +1 -0
- package/package.json +50 -49
- package/package.original.json +50 -49
- package/src/app.js +83 -85
- package/src/html/renderDevPage.test.mjs +1 -0
- package/src/lib/getPathSegments.js +16 -1
- package/src/{routes/docs/checkpointsList.js → lib/getRequestSurface.js} +6 -4
- package/src/lib/isTabAnswer.js +32 -0
- package/src/lib/isTabChannelCaller.js +35 -0
- package/src/middleware/apiContext.js +4 -2
- package/src/middleware/createSameOriginGuard.test.mjs +1 -0
- package/src/middleware/errorHandler.js +33 -45
- package/src/middleware/errorHandler.test.mjs +10 -10
- package/src/middleware/isRebindingSafeHost.test.mjs +1 -0
- package/src/middleware/localDevToolsOnly.js +13 -1
- package/src/middleware/localDevToolsOnly.test.mjs +36 -2
- package/src/middleware/noStore.test.mjs +1 -0
- package/src/middleware/staleFlag.test.mjs +1 -0
- package/src/middleware/stampCaller.test.mjs +1 -0
- package/src/routes/agentBearer.test.mjs +183 -0
- package/src/routes/auth.test.mjs +10 -10
- package/src/routes/clientError.js +21 -4
- package/src/routes/clientError.test.mjs +127 -0
- package/src/routes/devInspect.js +6 -51
- package/src/routes/devInspect.test.mjs +128 -3
- package/src/routes/devRecording.js +6 -17
- package/src/routes/devRecording.test.mjs +54 -3
- package/src/routes/docs/buildStatus.test.mjs +6 -6
- package/src/routes/docs/events.test.mjs +4 -4
- package/src/routes/docs/find.js +3 -3
- package/src/routes/docs/journey.test.mjs +8 -8
- package/src/routes/docs/journeyRefusals.test.mjs +9 -9
- package/src/routes/docs/loadDocsRoutes.js +70 -0
- package/src/routes/docs/loadDocsRoutes.test.mjs +110 -0
- package/src/routes/docs/mcp.test.mjs +5 -5
- package/src/routes/docs/mutants.js +7 -0
- package/src/routes/docs/mutants.test.mjs +20 -6
- package/src/routes/docs/parsePathParamsParam.test.mjs +1 -0
- package/src/routes/docs/parseUserParam.test.mjs +1 -0
- package/src/routes/docs/restart.test.mjs +1 -0
- package/src/routes/endpoints.js +24 -0
- package/src/routes/endpointsLink.test.mjs +111 -0
- package/src/routes/endpointsTextAnswer.test.mjs +8 -8
- package/src/routes/jitPage.js +13 -1
- package/src/routes/jitPage.test.mjs +36 -11
- package/src/routes/mcp.js +6 -0
- package/src/routes/mcp.test.mjs +23 -8
- package/src/routes/mcpMemberToken.test.mjs +8 -8
- package/src/routes/mcpProtectedResourceMetadata.test.mjs +2 -2
- package/src/routes/{docs/checkpointsRevert.js → mobileRoot.js} +10 -13
- package/src/routes/mobileRoutes.test.mjs +223 -0
- package/src/routes/mobileSignIn.js +58 -0
- package/src/routes/mobileSignIn.test.mjs +59 -0
- package/src/routes/mobileSignInCallback.js +34 -0
- package/src/routes/mobileSignInCallback.test.mjs +51 -0
- package/src/routes/mountDevPageRoutes.js +10 -2
- package/src/routes/mountDevPageRoutes.test.mjs +25 -1
- package/src/routes/mountMobileWellKnown.js +35 -0
- package/src/routes/mountMobileWellKnown.test.mjs +79 -0
- package/src/routes/mountOauthDiscovery.test.mjs +5 -5
- package/src/routes/normalizeMcpProtocolVersionHeader.test.mjs +1 -0
- package/src/routes/reload.js +101 -20
- package/src/routes/reload.test.mjs +153 -0
- package/src/routes/request.js +1 -22
- package/src/routes/request.test.mjs +7 -24
- package/src/routes/requestBody.test.mjs +14 -27
- package/src/routes/websocket.test.mjs +2 -2
- package/src/routes/wellKnownFallback.test.mjs +2 -2
- package/src/websocket/devWebSocket.test.mjs +12 -12
- package/vite.config.js +13 -1
- package/client/feedback/FeedbackMount.jsx +0 -83
- package/client/feedback/FeedbackOverlay.jsx +0 -904
- package/client/feedback/captureTabScreenshot.js +0 -84
- package/client/feedback/copyToClipboard.js +0 -45
- package/client/feedback/drawAnnotationsSvg.js +0 -119
- package/client/feedback/feedbackStyles.js +0 -304
- package/client/feedback/pinResponsiveImages.js +0 -59
- package/client/feedback/sendFeedback.js +0 -39
- package/client/feedback/useFeedbackToggle.js +0 -70
- package/client/recorder/buildEngineRecord.js +0 -37
- package/client/recorder/buildInteractionRecord.js +0 -64
- package/client/recorder/buildTraceEvent.js +0 -57
- package/client/recorder/buildTraceEvent.test.mjs +0 -81
- package/client/recorder/chunkRecords.js +0 -69
- package/client/recorder/chunkRecords.test.mjs +0 -59
- package/client/recorder/collectEventEndpoints.js +0 -40
- package/client/recorder/collectEventRequests.js +0 -39
- package/client/recorder/createPairingBuffer.js +0 -187
- package/client/recorder/createPasswordRedactor.js +0 -84
- package/client/recorder/createRecordBatcher.js +0 -54
- package/client/recorder/createRecordBatcher.test.mjs +0 -76
- package/client/recorder/createRecordingSession.js +0 -61
- package/client/recorder/createRecordingSession.test.mjs +0 -72
- package/client/recorder/diffStateWrites.js +0 -77
- package/client/recorder/diffStateWrites.test.mjs +0 -66
- package/client/recorder/isEventCall.js +0 -30
- package/client/recorder/jsonType.js +0 -39
- package/client/recorder/sendRecords.js +0 -40
- package/lib/docs/captureAnnotatedScreenshot.js +0 -99
- package/lib/docs/checkpointPaths.js +0 -91
- package/lib/docs/checkpointStore.js +0 -243
- package/lib/docs/checkpointToMocks.js +0 -65
- package/lib/docs/configCheckpoints.test.mjs +0 -156
- package/lib/docs/createConfigCheckpoint.js +0 -92
- package/lib/docs/dataSets/findCollectionCollisions.js +0 -52
- package/lib/docs/devMockRegistry.js +0 -68
- package/lib/docs/enrichFeedback.js +0 -71
- package/lib/docs/evalOperator.js +0 -49
- package/lib/docs/evalOperator.test.mjs +0 -157
- package/lib/docs/evalOperatorHeadless.js +0 -159
- package/lib/docs/evalOperatorHeadless.test.mjs +0 -78
- package/lib/docs/evalOperatorInTab.js +0 -49
- package/lib/docs/formatFeedback.js +0 -142
- package/lib/docs/formatFeedback.test.mjs +0 -252
- package/lib/docs/getPluginDoc.js +0 -53
- package/lib/docs/listConfigCheckpoints.js +0 -55
- package/lib/docs/loadState.js +0 -220
- package/lib/docs/revertConfigCheckpoint.js +0 -73
- package/lib/docs/saveAnnotatedScreenshot.js +0 -43
- package/lib/docs/scaffoldPage.js +0 -77
- package/lib/docs/scaffoldPage.test.mjs +0 -97
- package/lib/docs/snapshotState.js +0 -67
- package/lib/docs/stateCheckpoints.test.mjs +0 -443
- package/manager/watchers/listServerSidePackages.mjs +0 -47
- package/manager/watchers/listServerSidePackages.test.mjs +0 -38
- package/src/routes/docs/checkpointsCreate.js +0 -28
- package/src/routes/docs/evalOperator.js +0 -70
- package/src/routes/docs/inspectState.js +0 -59
- package/src/routes/docs/loadState.js +0 -51
- package/src/routes/docs/pluginDoc.js +0 -33
- package/src/routes/docs/plugins.js +0 -23
- package/src/routes/docs/runEndpoint.js +0 -54
- package/src/routes/docs/runEndpoint.test.mjs +0 -165
- package/src/routes/docs/runRequest.js +0 -53
- package/src/routes/docs/runRequest.test.mjs +0 -92
- package/src/routes/docs/schema.js +0 -37
- package/src/routes/docs/screenshot.js +0 -120
- package/src/routes/docs/screenshot.test.mjs +0 -117
- package/src/routes/docs/search.js +0 -40
- package/src/routes/docs/snapshotState.js +0 -50
- package/src/routes/docs/stateCheckpointsList.js +0 -26
- package/src/routes/docs/types.js +0 -33
- package/src/routes/feedback.js +0 -107
- package/src/routes/feedback.test.mjs +0 -204
|
@@ -18,14 +18,14 @@ import fs from 'node:fs';
|
|
|
18
18
|
import os from 'node:os';
|
|
19
19
|
import path from 'node:path';
|
|
20
20
|
|
|
21
|
-
import {
|
|
21
|
+
import { vi, afterEach, beforeEach, expect, test } from 'vitest';
|
|
22
22
|
import { Hono } from 'hono';
|
|
23
23
|
import { serializer } from '@lowdefy/helpers';
|
|
24
24
|
|
|
25
25
|
import { endpointFixture, pageFixture } from '../../../lib/server/mutants/test/fixtures.mjs';
|
|
26
26
|
|
|
27
|
-
const mockBuildPageIfNeeded =
|
|
28
|
-
|
|
27
|
+
const mockBuildPageIfNeeded = vi.fn();
|
|
28
|
+
vi.doMock('../../../lib/server/jitPageBuilder.js', () => ({
|
|
29
29
|
default: mockBuildPageIfNeeded,
|
|
30
30
|
}));
|
|
31
31
|
|
|
@@ -41,7 +41,7 @@ function write(name, content) {
|
|
|
41
41
|
}
|
|
42
42
|
|
|
43
43
|
beforeEach(() => {
|
|
44
|
-
|
|
44
|
+
vi.clearAllMocks();
|
|
45
45
|
mockBuildPageIfNeeded.mockResolvedValue(true);
|
|
46
46
|
serverDirectory = fs.mkdtempSync(path.join(os.tmpdir(), 'lowdefy-mutants-route-'));
|
|
47
47
|
const page = pageFixture();
|
|
@@ -146,14 +146,28 @@ test.each([
|
|
|
146
146
|
);
|
|
147
147
|
|
|
148
148
|
test('POST /lowdefy-docs/mutants answers a page that fails to build with a 422 and its errors', async () => {
|
|
149
|
-
|
|
149
|
+
const { ConfigError } = await import('@lowdefy/errors');
|
|
150
|
+
mockBuildPageIfNeeded.mockRejectedValue(new ConfigError('Block type "Buton" not found.'));
|
|
150
151
|
const { status, data } = await post({ pages: ['tickets'] });
|
|
151
152
|
expect(status).toBe(422);
|
|
152
153
|
expect(data.buildErrors).toEqual([
|
|
153
|
-
{ type: '
|
|
154
|
+
{ type: 'ConfigError', message: 'Block type "Buton" not found.', source: null },
|
|
154
155
|
]);
|
|
155
156
|
});
|
|
156
157
|
|
|
158
|
+
test('POST /lowdefy-docs/mutants does not answer a fault of its own as a page that fails to build', async () => {
|
|
159
|
+
mockBuildPageIfNeeded.mockRejectedValue(new TypeError('Cannot read properties of undefined'));
|
|
160
|
+
const app = new Hono();
|
|
161
|
+
app.post('/lowdefy-docs/mutants', docsMutantsHandler);
|
|
162
|
+
app.onError(() => new Response('fault', { status: 500 }));
|
|
163
|
+
const response = await app.request('/lowdefy-docs/mutants', {
|
|
164
|
+
method: 'POST',
|
|
165
|
+
headers: { 'content-type': 'application/json' },
|
|
166
|
+
body: JSON.stringify({ pages: ['tickets'] }),
|
|
167
|
+
});
|
|
168
|
+
expect(response.status).toBe(500);
|
|
169
|
+
});
|
|
170
|
+
|
|
157
171
|
test('POST /lowdefy-docs/mutants answers with the build id read before the pages built', async () => {
|
|
158
172
|
// An edit lands while the page builds: its keys may be the new build's, so
|
|
159
173
|
// the answer must carry the older id and the journey route refuse it as stale.
|
|
@@ -15,6 +15,7 @@
|
|
|
15
15
|
*/
|
|
16
16
|
|
|
17
17
|
import parsePathParamsParam from './parsePathParamsParam.js';
|
|
18
|
+
import { expect, test } from 'vitest';
|
|
18
19
|
|
|
19
20
|
test('parsePathParamsParam returns nothing when the param is absent', () => {
|
|
20
21
|
expect(parsePathParamsParam({ value: undefined })).toEqual({});
|
|
@@ -18,6 +18,7 @@ import fs from 'fs';
|
|
|
18
18
|
import os from 'os';
|
|
19
19
|
import path from 'path';
|
|
20
20
|
import { Hono } from 'hono';
|
|
21
|
+
import { afterAll, expect, test } from 'vitest';
|
|
21
22
|
|
|
22
23
|
const originalCwd = process.cwd();
|
|
23
24
|
const fixtureDir = fs.mkdtempSync(path.join(os.tmpdir(), 'lowdefy-restart-route-test-'));
|
package/src/routes/endpoints.js
CHANGED
|
@@ -18,12 +18,36 @@ import {
|
|
|
18
18
|
callEndpoint,
|
|
19
19
|
getEndpointConfig,
|
|
20
20
|
parseRequestBody,
|
|
21
|
+
runLinkEndpoint,
|
|
21
22
|
runWebhookEndpoint,
|
|
22
23
|
} from '@lowdefy/api';
|
|
24
|
+
import { type } from '@lowdefy/helpers';
|
|
23
25
|
|
|
24
26
|
import getPathSegments from '../lib/getPathSegments.js';
|
|
25
27
|
|
|
28
|
+
// A GET serves a link endpoint (`link: true`): typically an <img src> or a download link, sent
|
|
29
|
+
// by the browser with the session cookie and no Lowdefy headers. The routine runs as that caller
|
|
30
|
+
// and the answer is a 302 to the URL it returns, or a status with no body. The noStore middleware
|
|
31
|
+
// sets Cache-Control: private, no-store on it, so a redirect to a short-lived URL is never cached.
|
|
32
|
+
async function linkHandler(c) {
|
|
33
|
+
const context = c.get('lowdefyContext');
|
|
34
|
+
const { status, location, body } = await runLinkEndpoint(context, {
|
|
35
|
+
segments: getPathSegments(c, '/api/endpoints/'),
|
|
36
|
+
query: c.req.query(),
|
|
37
|
+
});
|
|
38
|
+
if (status === 302) {
|
|
39
|
+
return c.redirect(location, 302);
|
|
40
|
+
}
|
|
41
|
+
if (type.isNone(body)) {
|
|
42
|
+
return c.body(null, status);
|
|
43
|
+
}
|
|
44
|
+
return c.json(body, status);
|
|
45
|
+
}
|
|
46
|
+
|
|
26
47
|
async function endpointsHandler(c) {
|
|
48
|
+
if (c.req.method === 'GET') {
|
|
49
|
+
return linkHandler(c);
|
|
50
|
+
}
|
|
27
51
|
if (c.req.method !== 'POST') {
|
|
28
52
|
// A wrong-method request is client-caused: answer 405 rather than raising a
|
|
29
53
|
// fault that would be logged at error level and answered with a 500.
|
|
@@ -0,0 +1,111 @@
|
|
|
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 { Hono } from 'hono';
|
|
18
|
+
import { vi, beforeEach, expect, test } from 'vitest';
|
|
19
|
+
|
|
20
|
+
const mockRunLinkEndpoint = vi.fn();
|
|
21
|
+
const mockCallEndpoint = vi.fn();
|
|
22
|
+
vi.doMock('@lowdefy/api', () => ({
|
|
23
|
+
callEndpoint: mockCallEndpoint,
|
|
24
|
+
getEndpointConfig: vi.fn().mockRejectedValue(new Error('API Endpoint does not exist.')),
|
|
25
|
+
parseRequestBody: vi.fn(() => ({ payload: {} })),
|
|
26
|
+
runLinkEndpoint: mockRunLinkEndpoint,
|
|
27
|
+
runWebhookEndpoint: vi.fn(),
|
|
28
|
+
}));
|
|
29
|
+
|
|
30
|
+
const { default: endpointsHandler } = await import('./endpoints.js');
|
|
31
|
+
const { default: noStore } = await import('../middleware/noStore.js');
|
|
32
|
+
const { default: stampCaller } = await import('../middleware/stampCaller.js');
|
|
33
|
+
|
|
34
|
+
const logger = { debug: vi.fn(), error: vi.fn(), info: vi.fn(), warn: vi.fn() };
|
|
35
|
+
|
|
36
|
+
// The middleware app.js puts on /api/endpoints/*, so a plain browser image GET is checked
|
|
37
|
+
// against what they do with no Lowdefy headers.
|
|
38
|
+
function createApp() {
|
|
39
|
+
const app = new Hono();
|
|
40
|
+
app.use('*', async (c, next) => {
|
|
41
|
+
c.set('lowdefyContext', { logger, handleError: vi.fn(), user: { id: 'user_1' } });
|
|
42
|
+
await next();
|
|
43
|
+
});
|
|
44
|
+
app.use('/api/endpoints/*', noStore());
|
|
45
|
+
app.use('/api/endpoints/*', stampCaller());
|
|
46
|
+
app.all('/api/endpoints/*', endpointsHandler);
|
|
47
|
+
return app;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
beforeEach(() => {
|
|
51
|
+
mockRunLinkEndpoint.mockReset();
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
test('a GET answers 302 to the link, not stored by any cache', async () => {
|
|
55
|
+
mockRunLinkEndpoint.mockResolvedValue({
|
|
56
|
+
status: 302,
|
|
57
|
+
location: 'https://bucket.s3.amazonaws.com/x.png?X-Amz-Signature=sig',
|
|
58
|
+
});
|
|
59
|
+
const res = await createApp().request('/api/endpoints/files/x.png', { headers: {} });
|
|
60
|
+
expect(res.status).toBe(302);
|
|
61
|
+
expect(res.headers.get('location')).toBe(
|
|
62
|
+
'https://bucket.s3.amazonaws.com/x.png?X-Amz-Signature=sig'
|
|
63
|
+
);
|
|
64
|
+
expect(res.headers.get('cache-control')).toBe('private, no-store');
|
|
65
|
+
expect(await res.text()).toBe('');
|
|
66
|
+
});
|
|
67
|
+
|
|
68
|
+
test('a GET passes the decoded path segments and the query to runLinkEndpoint', async () => {
|
|
69
|
+
mockRunLinkEndpoint.mockResolvedValue({ status: 302, location: '/x.png' });
|
|
70
|
+
await createApp().request('/api/endpoints/a/b/log-events/2024/x%20y+z.png?v=2&w=a+b');
|
|
71
|
+
expect(mockRunLinkEndpoint).toHaveBeenCalledWith(expect.anything(), {
|
|
72
|
+
segments: ['a', 'b', 'log-events', '2024', 'x y+z.png'],
|
|
73
|
+
query: { v: '2', w: 'a b' },
|
|
74
|
+
});
|
|
75
|
+
});
|
|
76
|
+
|
|
77
|
+
test('a GET keeps an encoded slash and percent sign inside one segment', async () => {
|
|
78
|
+
mockRunLinkEndpoint.mockResolvedValue({ status: 302, location: '/x.png' });
|
|
79
|
+
await createApp().request('/api/endpoints/files/a%2Fb%25.png');
|
|
80
|
+
expect(mockRunLinkEndpoint).toHaveBeenCalledWith(expect.anything(), {
|
|
81
|
+
segments: ['files', 'a/b%.png'],
|
|
82
|
+
query: {},
|
|
83
|
+
});
|
|
84
|
+
});
|
|
85
|
+
|
|
86
|
+
test('a refused GET answers its status with no body', async () => {
|
|
87
|
+
mockRunLinkEndpoint.mockResolvedValue({ status: 401 });
|
|
88
|
+
const res = await createApp().request('/api/endpoints/files/x.png');
|
|
89
|
+
expect(res.status).toBe(401);
|
|
90
|
+
expect(res.headers.get('cache-control')).toBe('private, no-store');
|
|
91
|
+
expect(await res.text()).toBe('');
|
|
92
|
+
});
|
|
93
|
+
|
|
94
|
+
test('a GET that names no link endpoint answers 404 with an error body', async () => {
|
|
95
|
+
mockRunLinkEndpoint.mockResolvedValue({ status: 404, body: { error: 'Not found.' } });
|
|
96
|
+
const res = await createApp().request('/api/endpoints/unknown/x.png');
|
|
97
|
+
expect(res.status).toBe(404);
|
|
98
|
+
expect(await res.json()).toEqual({ error: 'Not found.' });
|
|
99
|
+
});
|
|
100
|
+
|
|
101
|
+
test('any method but GET and POST answers 405', async () => {
|
|
102
|
+
const res = await createApp().request('/api/endpoints/files/x.png', { method: 'PUT' });
|
|
103
|
+
expect(res.status).toBe(405);
|
|
104
|
+
expect(mockRunLinkEndpoint).not.toHaveBeenCalled();
|
|
105
|
+
});
|
|
106
|
+
|
|
107
|
+
test('a GET with a malformed percent escape answers 400 without running the link', async () => {
|
|
108
|
+
const res = await createApp().request('/api/endpoints/files/100%ZZ.png');
|
|
109
|
+
expect(res.status).toBe(400);
|
|
110
|
+
expect(mockRunLinkEndpoint).not.toHaveBeenCalled();
|
|
111
|
+
});
|
|
@@ -15,25 +15,25 @@
|
|
|
15
15
|
*/
|
|
16
16
|
|
|
17
17
|
import { Hono } from 'hono';
|
|
18
|
-
import {
|
|
18
|
+
import { vi, beforeEach, expect, test } from 'vitest';
|
|
19
19
|
|
|
20
|
-
const mockGetEndpointConfig =
|
|
21
|
-
const mockRunWebhookEndpoint =
|
|
22
|
-
|
|
23
|
-
callEndpoint:
|
|
20
|
+
const mockGetEndpointConfig = vi.fn();
|
|
21
|
+
const mockRunWebhookEndpoint = vi.fn();
|
|
22
|
+
vi.doMock('@lowdefy/api', () => ({
|
|
23
|
+
callEndpoint: vi.fn(),
|
|
24
24
|
getEndpointConfig: mockGetEndpointConfig,
|
|
25
|
-
parseRequestBody:
|
|
25
|
+
parseRequestBody: vi.fn(),
|
|
26
26
|
runWebhookEndpoint: mockRunWebhookEndpoint,
|
|
27
27
|
}));
|
|
28
28
|
|
|
29
29
|
const { default: endpointsHandler } = await import('./endpoints.js');
|
|
30
30
|
|
|
31
|
-
const logger = { debug:
|
|
31
|
+
const logger = { debug: vi.fn(), error: vi.fn(), info: vi.fn(), warn: vi.fn() };
|
|
32
32
|
|
|
33
33
|
function createApp() {
|
|
34
34
|
const app = new Hono();
|
|
35
35
|
app.use('*', async (c, next) => {
|
|
36
|
-
c.set('lowdefyContext', { logger, handleError:
|
|
36
|
+
c.set('lowdefyContext', { logger, handleError: vi.fn() });
|
|
37
37
|
await next();
|
|
38
38
|
});
|
|
39
39
|
app.all('/api/endpoints/*', endpointsHandler);
|
package/src/routes/jitPage.js
CHANGED
|
@@ -21,6 +21,7 @@ import authJson from '../../lib/build/auth.js';
|
|
|
21
21
|
import { buildPageWithContext, getPageJitEnrichment } from '../../lib/server/jitPageBuilder.js';
|
|
22
22
|
import getBuildId from '../../lib/docs/getBuildId.js';
|
|
23
23
|
import getRequestPath from '../lib/getRequestPath.js';
|
|
24
|
+
import getRequestSurface from '../lib/getRequestSurface.js';
|
|
24
25
|
import lowdefyConfig from '../../lib/build/config.js';
|
|
25
26
|
import servedBuilds from '../../lib/server/recording/servedBuilds.js';
|
|
26
27
|
|
|
@@ -33,6 +34,8 @@ const basePath = lowdefyConfig.basePath ?? '';
|
|
|
33
34
|
// 401 { redirect } — logged-out navigation to a protected page
|
|
34
35
|
// 403 { redirect } — authorised but second factor not yet enrolled
|
|
35
36
|
// 404 'Page not found.'
|
|
37
|
+
// 404 { pageConfig: null, surface } — the page is for the other surface
|
|
38
|
+
// (x-lowdefy-shell marks a mobile shell)
|
|
36
39
|
// 200 { pageId, pathParams, matchedPath, pageConfig } (pageConfig + _buildId,
|
|
37
40
|
// + _warnings, + _jsEntries module text, + _dynamicIcons data)
|
|
38
41
|
//
|
|
@@ -87,7 +90,11 @@ async function jitPageHandler(c) {
|
|
|
87
90
|
});
|
|
88
91
|
}
|
|
89
92
|
|
|
90
|
-
const result = await getPageConfig(context, {
|
|
93
|
+
const result = await getPageConfig(context, {
|
|
94
|
+
path,
|
|
95
|
+
urlQuery: c.req.query(),
|
|
96
|
+
surface: getRequestSurface(c),
|
|
97
|
+
});
|
|
91
98
|
if (result.status === 'unauthenticated') {
|
|
92
99
|
// The client follows this redirect with a full page load, so the login
|
|
93
100
|
// page can return to the requested page after sign-in.
|
|
@@ -119,6 +126,11 @@ async function jitPageHandler(c) {
|
|
|
119
126
|
403
|
|
120
127
|
);
|
|
121
128
|
}
|
|
129
|
+
if (result.status === 'wrong_surface') {
|
|
130
|
+
// The page is for the other surface: a shell opens a web page in the
|
|
131
|
+
// browser, and a browser shows its 404.
|
|
132
|
+
return c.json({ pageConfig: null, surface: result.surface }, 404);
|
|
133
|
+
}
|
|
122
134
|
if (result.status !== 'ok') {
|
|
123
135
|
return c.text('Page not found.', 404);
|
|
124
136
|
}
|
|
@@ -18,38 +18,38 @@ import fs from 'fs';
|
|
|
18
18
|
import os from 'os';
|
|
19
19
|
import path from 'path';
|
|
20
20
|
import { Hono } from 'hono';
|
|
21
|
-
import {
|
|
21
|
+
import { vi, afterEach, expect, test } from 'vitest';
|
|
22
22
|
|
|
23
23
|
const BUILD_A = '2026-10-03T14:02:00.000Z';
|
|
24
24
|
const BUILD_B = '2026-10-03T14:05:00.000Z';
|
|
25
25
|
let mockBuildId = BUILD_A;
|
|
26
|
-
|
|
26
|
+
vi.doMock('../../lib/docs/getBuildId.js', () => ({
|
|
27
27
|
default: () => mockBuildId,
|
|
28
28
|
}));
|
|
29
29
|
|
|
30
|
-
const mockGetPageConfig =
|
|
31
|
-
|
|
30
|
+
const mockGetPageConfig = vi.fn();
|
|
31
|
+
vi.doMock('@lowdefy/api', () => ({
|
|
32
32
|
getPageConfig: mockGetPageConfig,
|
|
33
33
|
}));
|
|
34
34
|
|
|
35
35
|
// No JIT build work in these tests — the route's build branch is exercised
|
|
36
36
|
// elsewhere; here we only drive the getPageConfig status fork.
|
|
37
|
-
const mockGetPageJitEnrichment =
|
|
37
|
+
const mockGetPageJitEnrichment = vi.fn(() => ({}));
|
|
38
38
|
const mockBuildContext = { jsMap: { client: {} } };
|
|
39
|
-
const mockBuildPageWithContext =
|
|
39
|
+
const mockBuildPageWithContext = vi.fn(async () => ({
|
|
40
40
|
result: true,
|
|
41
41
|
buildContext: mockBuildContext,
|
|
42
42
|
}));
|
|
43
|
-
|
|
43
|
+
vi.doMock('../../lib/server/jitPageBuilder.js', () => ({
|
|
44
44
|
buildPageWithContext: mockBuildPageWithContext,
|
|
45
45
|
getPageJitEnrichment: mockGetPageJitEnrichment,
|
|
46
46
|
}));
|
|
47
47
|
|
|
48
|
-
|
|
48
|
+
vi.doMock('../../lib/build/auth.js', () => ({
|
|
49
49
|
default: { authPages: { signIn: '/auth/login', twoFactorEnrol: '/two-factor-enrol' } },
|
|
50
50
|
}));
|
|
51
51
|
|
|
52
|
-
|
|
52
|
+
vi.doMock('../../lib/build/config.js', () => ({
|
|
53
53
|
default: { basePath: '' },
|
|
54
54
|
}));
|
|
55
55
|
|
|
@@ -69,8 +69,8 @@ function createApp() {
|
|
|
69
69
|
buildDirectory: '/build',
|
|
70
70
|
configDirectory: '/config',
|
|
71
71
|
readConfigFile: async (file) => (file === 'routes.json' ? routes : null),
|
|
72
|
-
logger: { debug:
|
|
73
|
-
handleError:
|
|
72
|
+
logger: { debug: vi.fn(), info: vi.fn(), error: vi.fn() },
|
|
73
|
+
handleError: vi.fn(),
|
|
74
74
|
});
|
|
75
75
|
await next();
|
|
76
76
|
});
|
|
@@ -142,6 +142,7 @@ test('jitPageHandler builds the page a patterned path matches and returns its pa
|
|
|
142
142
|
expect(mockGetPageConfig.mock.calls[0][1]).toEqual({
|
|
143
143
|
path: 'support/tickets/1234/',
|
|
144
144
|
urlQuery: { tab: '2' },
|
|
145
|
+
surface: 'web',
|
|
145
146
|
});
|
|
146
147
|
expect(res.status).toEqual(200);
|
|
147
148
|
const body = await res.json();
|
|
@@ -246,3 +247,27 @@ test('jitPageHandler names the build it served, and the recording route keeps th
|
|
|
246
247
|
delete process.env.LOWDEFY_DIRECTORY_CONFIG;
|
|
247
248
|
}
|
|
248
249
|
});
|
|
250
|
+
|
|
251
|
+
test('jitPageHandler passes the web surface to getPageConfig for a browser', async () => {
|
|
252
|
+
mockGetPageConfig.mockResolvedValue({ status: 'not_found' });
|
|
253
|
+
await createApp().request('/api/page/dashboard');
|
|
254
|
+
expect(mockGetPageConfig.mock.calls[0][1].surface).toEqual('web');
|
|
255
|
+
});
|
|
256
|
+
|
|
257
|
+
test('jitPageHandler passes the mobile surface to getPageConfig for a shell', async () => {
|
|
258
|
+
mockGetPageConfig.mockResolvedValue({ status: 'not_found' });
|
|
259
|
+
await createApp().request('/api/page/dashboard', { headers: { 'x-lowdefy-shell': '7.4.0' } });
|
|
260
|
+
expect(mockGetPageConfig.mock.calls[0][1].surface).toEqual('mobile');
|
|
261
|
+
});
|
|
262
|
+
|
|
263
|
+
test('jitPageHandler returns 404 naming the surface when the page is for the other one', async () => {
|
|
264
|
+
mockGetPageConfig.mockResolvedValue({
|
|
265
|
+
status: 'wrong_surface',
|
|
266
|
+
pageId: 'dashboard',
|
|
267
|
+
pathParams: {},
|
|
268
|
+
surface: 'mobile',
|
|
269
|
+
});
|
|
270
|
+
const res = await createApp().request('/api/page/dashboard');
|
|
271
|
+
expect(res.status).toEqual(404);
|
|
272
|
+
expect(await res.json()).toEqual({ pageConfig: null, surface: 'mobile' });
|
|
273
|
+
});
|
package/src/routes/mcp.js
CHANGED
|
@@ -102,6 +102,12 @@ async function mcpHandler(c) {
|
|
|
102
102
|
});
|
|
103
103
|
}
|
|
104
104
|
}
|
|
105
|
+
// The server is stateless and pushes nothing, so it offers no event stream:
|
|
106
|
+
// the MCP spec's answer to a GET is then 405. Opening one would hold the
|
|
107
|
+
// request, and on a serverless host its function, until the host's time limit.
|
|
108
|
+
if (c.req.method === 'GET') {
|
|
109
|
+
return c.json({ error: 'Method not allowed.' }, 405, { Allow: 'POST' });
|
|
110
|
+
}
|
|
105
111
|
const server = await createMcpServer({ context });
|
|
106
112
|
const transport = new StreamableHTTPTransport();
|
|
107
113
|
await server.connect(transport);
|
package/src/routes/mcp.test.mjs
CHANGED
|
@@ -15,20 +15,20 @@
|
|
|
15
15
|
*/
|
|
16
16
|
|
|
17
17
|
import { Hono } from 'hono';
|
|
18
|
-
import {
|
|
18
|
+
import { vi, afterAll, beforeEach, expect, test } from 'vitest';
|
|
19
19
|
|
|
20
20
|
// The real URI helpers drive the challenge strings, so the header assertions
|
|
21
21
|
// below exercise the actual BETTER_AUTH_URL derivation - only createMcpServer
|
|
22
22
|
// is stubbed out.
|
|
23
23
|
const uriHelpers = await import('@lowdefy/api/routes/mcp/getMcpUri.js');
|
|
24
24
|
|
|
25
|
-
const mockCreateMcpServer =
|
|
26
|
-
|
|
25
|
+
const mockCreateMcpServer = vi.fn();
|
|
26
|
+
vi.doMock('@lowdefy/api', () => ({
|
|
27
27
|
...uriHelpers,
|
|
28
28
|
createMcpServer: mockCreateMcpServer,
|
|
29
29
|
}));
|
|
30
30
|
|
|
31
|
-
|
|
31
|
+
vi.doMock('@hono/mcp', () => ({
|
|
32
32
|
StreamableHTTPTransport: class {
|
|
33
33
|
handleRequest() {
|
|
34
34
|
return new Response(JSON.stringify({ served: true }), {
|
|
@@ -40,7 +40,7 @@ jest.unstable_mockModule('@hono/mcp', () => ({
|
|
|
40
40
|
}));
|
|
41
41
|
|
|
42
42
|
const mockAuthJson = { configured: true, oauthProvider: { consentPage: '/oauth/consent' } };
|
|
43
|
-
|
|
43
|
+
vi.doMock('../../lib/build/auth.js', () => ({
|
|
44
44
|
default: mockAuthJson,
|
|
45
45
|
}));
|
|
46
46
|
|
|
@@ -48,7 +48,7 @@ const { default: mcpHandler } = await import('./mcp.js');
|
|
|
48
48
|
|
|
49
49
|
const originalBetterAuthUrl = process.env.BETTER_AUTH_URL;
|
|
50
50
|
|
|
51
|
-
const mockReadConfigFile =
|
|
51
|
+
const mockReadConfigFile = vi.fn();
|
|
52
52
|
|
|
53
53
|
let contextOverrides;
|
|
54
54
|
|
|
@@ -57,7 +57,7 @@ function createApp() {
|
|
|
57
57
|
app.use('*', async (c, next) => {
|
|
58
58
|
c.set('lowdefyContext', {
|
|
59
59
|
config: { basePath: '' },
|
|
60
|
-
logger: { debug:
|
|
60
|
+
logger: { debug: vi.fn(), info: vi.fn(), warn: vi.fn(), error: vi.fn() },
|
|
61
61
|
readConfigFile: mockReadConfigFile,
|
|
62
62
|
...contextOverrides,
|
|
63
63
|
});
|
|
@@ -73,7 +73,7 @@ beforeEach(() => {
|
|
|
73
73
|
contextOverrides = {};
|
|
74
74
|
mockReadConfigFile.mockReset();
|
|
75
75
|
mockCreateMcpServer.mockReset();
|
|
76
|
-
mockCreateMcpServer.mockResolvedValue({ connect:
|
|
76
|
+
mockCreateMcpServer.mockResolvedValue({ connect: vi.fn() });
|
|
77
77
|
mockReadConfigFile.mockResolvedValue({ configured: true, hasPublicTool: true, endpoints: [] });
|
|
78
78
|
});
|
|
79
79
|
|
|
@@ -213,3 +213,18 @@ test('mcpHandler serves openly with no envelope when oauthProvider is not config
|
|
|
213
213
|
expect(res.status).toEqual(200);
|
|
214
214
|
expect(await res.json()).toEqual({ served: true });
|
|
215
215
|
});
|
|
216
|
+
|
|
217
|
+
test('mcpHandler answers a GET with 405, since the stateless server offers no event stream', async () => {
|
|
218
|
+
contextOverrides.mcpAuth = { tokenStatus: 'valid' };
|
|
219
|
+
const res = await createApp().request('/api/mcp', { method: 'GET' });
|
|
220
|
+
expect(res.status).toEqual(405);
|
|
221
|
+
expect(res.headers.get('Allow')).toEqual('POST');
|
|
222
|
+
expect(await res.json()).toEqual({ error: 'Method not allowed.' });
|
|
223
|
+
expect(mockCreateMcpServer).not.toHaveBeenCalled();
|
|
224
|
+
});
|
|
225
|
+
|
|
226
|
+
test('mcpHandler challenges a GET with an invalid token before answering 405', async () => {
|
|
227
|
+
contextOverrides.mcpAuth = { tokenStatus: 'invalid', parseableJwt: true };
|
|
228
|
+
const res = await createApp().request('/api/mcp', { method: 'GET' });
|
|
229
|
+
expect(res.status).toEqual(401);
|
|
230
|
+
});
|
|
@@ -15,20 +15,20 @@
|
|
|
15
15
|
*/
|
|
16
16
|
|
|
17
17
|
import { Hono } from 'hono';
|
|
18
|
-
import {
|
|
18
|
+
import { vi, afterAll, beforeEach, expect, test } from 'vitest';
|
|
19
19
|
|
|
20
20
|
// The real URI helpers drive the challenge strings, so the header assertions
|
|
21
21
|
// below exercise the actual BETTER_AUTH_URL derivation - only createMcpServer
|
|
22
22
|
// is stubbed out.
|
|
23
23
|
const uriHelpers = await import('@lowdefy/api/routes/mcp/getMcpUri.js');
|
|
24
24
|
|
|
25
|
-
const mockCreateMcpServer =
|
|
26
|
-
|
|
25
|
+
const mockCreateMcpServer = vi.fn();
|
|
26
|
+
vi.doMock('@lowdefy/api', () => ({
|
|
27
27
|
...uriHelpers,
|
|
28
28
|
createMcpServer: mockCreateMcpServer,
|
|
29
29
|
}));
|
|
30
30
|
|
|
31
|
-
|
|
31
|
+
vi.doMock('@hono/mcp', () => ({
|
|
32
32
|
StreamableHTTPTransport: class {
|
|
33
33
|
handleRequest() {
|
|
34
34
|
return new Response(JSON.stringify({ served: true }), {
|
|
@@ -40,7 +40,7 @@ jest.unstable_mockModule('@hono/mcp', () => ({
|
|
|
40
40
|
}));
|
|
41
41
|
|
|
42
42
|
const mockAuthJson = { configured: true, oauthProvider: { consentPage: '/oauth/consent' } };
|
|
43
|
-
|
|
43
|
+
vi.doMock('../../lib/build/auth.js', () => ({
|
|
44
44
|
default: mockAuthJson,
|
|
45
45
|
}));
|
|
46
46
|
|
|
@@ -48,7 +48,7 @@ const { default: mcpHandler } = await import('./mcp.js');
|
|
|
48
48
|
|
|
49
49
|
const originalBetterAuthUrl = process.env.BETTER_AUTH_URL;
|
|
50
50
|
|
|
51
|
-
const mockReadConfigFile =
|
|
51
|
+
const mockReadConfigFile = vi.fn();
|
|
52
52
|
|
|
53
53
|
let contextOverrides;
|
|
54
54
|
|
|
@@ -57,7 +57,7 @@ function createApp() {
|
|
|
57
57
|
app.use('*', async (c, next) => {
|
|
58
58
|
c.set('lowdefyContext', {
|
|
59
59
|
config: { basePath: '' },
|
|
60
|
-
logger: { debug:
|
|
60
|
+
logger: { debug: vi.fn(), info: vi.fn(), warn: vi.fn(), error: vi.fn() },
|
|
61
61
|
readConfigFile: mockReadConfigFile,
|
|
62
62
|
...contextOverrides,
|
|
63
63
|
});
|
|
@@ -73,7 +73,7 @@ beforeEach(() => {
|
|
|
73
73
|
contextOverrides = {};
|
|
74
74
|
mockReadConfigFile.mockReset();
|
|
75
75
|
mockCreateMcpServer.mockReset();
|
|
76
|
-
mockCreateMcpServer.mockResolvedValue({ connect:
|
|
76
|
+
mockCreateMcpServer.mockResolvedValue({ connect: vi.fn() });
|
|
77
77
|
mockReadConfigFile.mockResolvedValue({ configured: true, hasPublicTool: true, endpoints: [] });
|
|
78
78
|
});
|
|
79
79
|
|
|
@@ -15,9 +15,9 @@
|
|
|
15
15
|
*/
|
|
16
16
|
|
|
17
17
|
import { Hono } from 'hono';
|
|
18
|
-
import {
|
|
18
|
+
import { vi, afterAll, beforeEach, expect, test } from 'vitest';
|
|
19
19
|
|
|
20
|
-
|
|
20
|
+
vi.doMock('../../lib/build/config.js', () => ({
|
|
21
21
|
default: { basePath: '' },
|
|
22
22
|
}));
|
|
23
23
|
|
|
@@ -14,20 +14,17 @@
|
|
|
14
14
|
limitations under the License.
|
|
15
15
|
*/
|
|
16
16
|
|
|
17
|
-
import
|
|
17
|
+
import { getMobileRootConfig } from '@lowdefy/api';
|
|
18
18
|
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
const result = revertConfigCheckpoint({ id: body.id });
|
|
27
|
-
return c.json(result);
|
|
28
|
-
} catch (error) {
|
|
29
|
-
return c.json({ error: error.message }, 400);
|
|
19
|
+
// The root config a shell syncs on start (getMobileRootConfig), filtered to
|
|
20
|
+
// the caller. An app without a mobile key has no shell, so it answers 404.
|
|
21
|
+
async function mobileRootHandler(c) {
|
|
22
|
+
const context = c.get('lowdefyContext');
|
|
23
|
+
const rootConfig = await getMobileRootConfig(context);
|
|
24
|
+
if (rootConfig === null) {
|
|
25
|
+
return c.json({ name: 'NotFoundError', message: 'This app has no mobile config.' }, 404);
|
|
30
26
|
}
|
|
27
|
+
return c.json(rootConfig);
|
|
31
28
|
}
|
|
32
29
|
|
|
33
|
-
export default
|
|
30
|
+
export default mobileRootHandler;
|