@akanjs/devkit 3.2.0-rc.2 → 3.2.0-rc.20
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +315 -11
- package/DEV_RUNTIME_KNOBS.md +4 -3
- package/README.ko.md +3 -2
- package/README.md +4 -2
- package/akanApp/BackendImportGraph.test.ts +1 -1
- package/akanApp/akanApp.host.test.ts +257 -1
- package/akanApp/akanApp.host.ts +146 -1223
- package/akanApp/akanApp.host.wiring.test.ts +727 -0
- package/akanApp/builderGap.ts +68 -0
- package/akanApp/builderRequestRelay.test.ts +93 -0
- package/akanApp/builderRequestRelay.ts +100 -0
- package/akanApp/builderRssRecycler.ts +182 -0
- package/akanApp/devBackend.ts +392 -0
- package/akanApp/devBuildStatusBoard.ts +128 -0
- package/akanApp/devBuilder.ts +196 -0
- package/akanApp/devHostPolicy.test.ts +11 -11
- package/akanApp/devHostPolicy.ts +2 -4
- package/akanApp/devIdleSuspend.test.ts +221 -0
- package/akanApp/devIdleSuspend.ts +192 -0
- package/akanApp/devIdleSuspend.watcher.test.ts +120 -0
- package/akanApp/devRecycler.test.ts +66 -0
- package/akanApp/devRecycler.ts +305 -0
- package/akanApp/processRss.ts +61 -0
- package/akanConfig/akanConfig.test.ts +24 -1
- package/akanConfig/akanConfig.ts +10 -10
- package/akanConfig/akanWorkspaceConfig.ts +1 -1
- package/akanConfig/productionLockfile.ts +1 -1
- package/apiReport/apiDeclarationPrinter.ts +120 -0
- package/apiReport/apiReport.test.ts +526 -0
- package/apiReport/apiReport.ts +232 -0
- package/apiReport/apiReportDiff.ts +160 -0
- package/apiReport/apiReportPolicy.ts +65 -0
- package/apiReport/apiTargets.ts +311 -0
- package/apiReport/changesetBump.ts +19 -0
- package/{applicationBuildReporter.test.ts → app/applicationBuildReporter.test.ts} +21 -0
- package/{applicationBuildReporter.ts → app/applicationBuildReporter.ts} +10 -49
- package/{applicationBuildRunner.test.ts → app/applicationBuildRunner.test.ts} +74 -7
- package/{applicationBuildRunner.ts → app/applicationBuildRunner.ts} +20 -15
- package/{applicationTestPreload.ts → app/applicationTestPreload.ts} +1 -1
- package/{routeJsBudget.test.ts → app/routeJsBudget.test.ts} +48 -12
- package/{routeJsBudget.ts → app/routeJsBudget.ts} +90 -27
- package/{routeSourceValidator.test.ts → app/routeSourceValidator.test.ts} +17 -0
- package/{routeSourceValidator.ts → app/routeSourceValidator.ts} +5 -1
- package/artifact/implicitRootLayout.test.ts +71 -3
- package/artifact/implicitRootLayout.ts +21 -4
- package/artifact/implicitRootLayoutRender.test.tsx +297 -0
- package/biome.base.json +2 -1
- package/cloud/cloudApi.test.ts +1 -1
- package/cloud/configLock.test.ts +1 -1
- package/cloud/globalConfig.test.ts +1 -1
- package/cloud/globalConfig.ts +1 -1
- package/cloud/updatePackUpload.test.ts +1 -1
- package/codeAgent/agent/AkanCodeEnv.ts +1 -1
- package/codeAgent/agent/akanCodePaths.ts +1 -1
- package/codeAgent/agent/akanSystemPrompt.ts +1 -1
- package/codeAgent/agent/codeAgent.test.ts +1 -1
- package/codeAgent/skills/akan-debug/SKILL.md +10 -3
- package/codeAgent/skills/akan-err/SKILL.md +7 -0
- package/codeAgent/skills/akan-mcp/SKILL.md +10 -1
- package/codeAgent/skills/akan-scaffold/SKILL.md +2 -2
- package/codeAgent/skills/akan-transport/SKILL.md +2 -0
- package/codeAgent/skills/akan-validate/SKILL.md +1 -0
- package/codeAgent/tools/AkanCli.ts +1 -1
- package/codeAgent/tools/AkanToolPack.ts +1 -1
- package/codeAgent/tools/McpClient.ts +28 -6
- package/codeAgent/tools/McpToolPack.ts +1 -1
- package/codeAgent/tools/akanCodePlugins.test.ts +14 -2
- package/commandDecorators/argMeta.ts +4 -0
- package/commandDecorators/cliError.ts +72 -0
- package/commandDecorators/command.ts +165 -91
- package/commandDecorators/commandBuilder.ts +1 -1
- package/commandDecorators/commandDecorators.test.ts +191 -16
- package/commandDecorators/exitCodeError.ts +6 -7
- package/commandDecorators/index.ts +1 -0
- package/commandDecorators/targetMeta.ts +1 -0
- package/commandDecorators/workspaceVersionCheck.test.ts +1 -1
- package/commandDecorators/workspaceVersionCheck.ts +1 -1
- package/context/akanContext.ts +576 -0
- package/context/akanContextInspection.ts +296 -0
- package/{akanMcpContract.test.ts → context/akanMcpContract.test.ts} +1 -1
- package/{akanMcpContract.ts → context/akanMcpContract.ts} +33 -263
- package/context/akanMcpToolError.ts +16 -0
- package/context/doctor/agentGuideCheck.ts +81 -0
- package/context/doctor/configLeftoverCheck.ts +35 -0
- package/context/doctor/doctorFindings.ts +70 -0
- package/context/doctor/generatedFreshness.ts +56 -0
- package/context/doctor/moduleShapeCheck.ts +88 -0
- package/context/doctor/recipeDuplicateCheck.ts +39 -0
- package/context/doctor/recipeIndexCheck.ts +87 -0
- package/context/doctor/rootShapeCheck.ts +55 -0
- package/context/doctor/workflowScope.ts +97 -0
- package/{constantFieldNames.test.ts → context/moduleFieldNames.test.ts} +24 -2
- package/context/moduleFieldNames.ts +25 -0
- package/{recipeScanner.test.ts → context/recipeScanner.test.ts} +1 -1
- package/context/safeRead.ts +9 -0
- package/csrE2e/csrE2eHarness.fixture.ts +1 -1
- package/devkitUtils.test.ts +39 -5
- package/{apiReference.test.ts → docs/apiReference.test.ts} +4 -4
- package/{apiReference.ts → docs/apiReference.ts} +2 -2
- package/docs/errorCodeReference.test.ts +282 -0
- package/docs/errorCodeReference.ts +71 -0
- package/docs/errorCodeScan.ts +551 -0
- package/{frameworkGraph.test.ts → docs/frameworkGraph.test.ts} +1 -1
- package/executors/appExecutor.ts +448 -0
- package/executors/commandExecutionError.ts +53 -0
- package/executors/executor.ts +527 -0
- package/{executors.linkFallback.test.ts → executors/executors.linkFallback.test.ts} +1 -1
- package/{executors.test.ts → executors/executors.test.ts} +76 -15
- package/executors/index.ts +8 -0
- package/executors/libExecutor.ts +23 -0
- package/executors/moduleExecutor.ts +18 -0
- package/executors/pkgExecutor.ts +129 -0
- package/executors/sysExecutor.ts +301 -0
- package/executors/workspaceExecutor.ts +277 -0
- package/frontendBuild/allRoutesBuilder.test.ts +17 -5
- package/frontendBuild/allRoutesBuilder.ts +24 -6
- package/frontendBuild/autoImportSync.test.ts +1 -1
- package/frontendBuild/autoImportSync.ts +1 -1
- package/frontendBuild/buildRouteClient.test.ts +1 -1
- package/frontendBuild/bundleDefine.ts +2 -0
- package/frontendBuild/clientBuildTypes.ts +5 -2
- package/frontendBuild/clientEntriesBundler.test.ts +1 -1
- package/frontendBuild/clientEntryDiscovery.test.ts +58 -0
- package/frontendBuild/clientEntryDiscovery.ts +25 -6
- package/frontendBuild/csrArtifactBuilder.test.ts +1 -1
- package/frontendBuild/csrDevArtifactWriter.ts +1 -1
- package/frontendBuild/cssCompiler.test.ts +1 -1
- package/frontendBuild/devGeneratedIndexSync.test.ts +1 -1
- package/frontendBuild/devGeneratedIndexSync.ts +7 -38
- package/frontendBuild/dictionaryAssetBuilder.test.ts +1 -1
- package/frontendBuild/fontOptimizer.test.ts +1 -1
- package/frontendBuild/fontPruner.test.ts +1 -1
- package/frontendBuild/frontendBuild.test.ts +3 -3
- package/frontendBuild/hmrWatcher.stop.test.ts +63 -0
- package/frontendBuild/hmrWatcher.test.ts +1 -1
- package/frontendBuild/hmrWatcher.ts +22 -1
- package/frontendBuild/mcpAppViewBuilder.test.ts +1 -1
- package/frontendBuild/mcpAppViewBuilder.ts +1 -1
- package/frontendBuild/nativeCore.test.ts +148 -0
- package/frontendBuild/optionalPeers.test.ts +36 -8
- package/frontendBuild/pagesBundleBuilder.test.ts +2 -3
- package/frontendBuild/pagesBundleBuilder.ts +1 -1
- package/frontendBuild/precompressArtifacts.test.ts +1 -1
- package/frontendBuild/precompressArtifacts.ts +1 -1
- package/frontendBuild/serverGraphFile.ts +1 -1
- package/frontendBuild/sourceMtimeIndex.test.ts +1 -1
- package/frontendBuild/ssrBaseArtifactBuilder.test.ts +26 -0
- package/frontendBuild/ssrBaseArtifactBuilder.ts +23 -19
- package/frontendBuild/ssrDevBundler.test.ts +1 -1
- package/frontendBuild/vendorImportScanner.test.ts +25 -4
- package/frontendBuild/vendorImportScanner.ts +25 -10
- package/frontendBuild/vendorNarrowing.test.ts +1 -1
- package/frontendBuild/watchRootResolver.test.ts +1 -1
- package/{agentAssets.test.ts → guideline/agentAssets.test.ts} +1 -1
- package/{agentAssets.ts → guideline/agentAssets.ts} +2 -2
- package/{agentsIndex.test.ts → guideline/agentsIndex.test.ts} +2 -2
- package/{agentsIndex.ts → guideline/agentsIndex.ts} +13 -10
- package/{conventionSet.test.ts → guideline/conventionSet.test.ts} +7 -4
- package/{conventionSet.ts → guideline/conventionSet.ts} +1 -1
- package/{prompter.ts → guideline/prompter.ts} +2 -3
- package/incrementalBuilder/buildBatch.proc.ts +14 -4
- package/incrementalBuilder/buildBatchProtocol.ts +2 -0
- package/incrementalBuilder/buildBatchRunner.test.ts +108 -1
- package/incrementalBuilder/buildBatchRunner.ts +17 -4
- package/incrementalBuilder/builderBoot.ts +106 -0
- package/incrementalBuilder/builderBuildStatus.ts +23 -0
- package/incrementalBuilder/builderChannel.test.ts +1 -1
- package/incrementalBuilder/builderChannel.ts +11 -0
- package/incrementalBuilder/builderGraphPayloads.ts +3 -3
- package/incrementalBuilder/builderLanes.ts +157 -0
- package/incrementalBuilder/builderWatch.ts +213 -0
- package/incrementalBuilder/csrRegistry.ts +234 -0
- package/incrementalBuilder/incrementalBuilder.host.test.ts +30 -1
- package/incrementalBuilder/incrementalBuilder.host.ts +10 -22
- package/incrementalBuilder/incrementalBuilder.proc.test.ts +93 -2
- package/incrementalBuilder/incrementalBuilder.proc.ts +81 -823
- package/incrementalBuilder/ssrRegistry.ts +278 -0
- package/index.ts +22 -22
- package/integration/devStability.integration.test.ts +62 -56
- package/integration/devStabilityHarness.test.ts +1 -1
- package/lint/__fixtures__/no-import-common-err/bad.tsx +13 -0
- package/lint/__fixtures__/no-import-common-err/good.tsx +12 -0
- package/{biomeBase.test.ts → lint/biomeBase.test.ts} +1 -1
- package/lint/gritRules.test.ts +1 -1
- package/{linter.test.ts → lint/linter.test.ts} +1 -1
- package/lint/no-import-common-err.grit +31 -0
- package/lint/no-init-fetch-in-client.grit +1 -1
- package/lint/no-web-only-api-outside-webkit.grit +3 -3
- package/mobile/desktopBin.test.ts +1 -1
- package/mobile/desktopRelease.test.ts +1 -1
- package/mobile/desktopServerStage.test.ts +2 -2
- package/mobile/desktopServerStage.ts +1 -1
- package/mobile/nativeApi.test.ts +1 -1
- package/mobile/nativeApp.test.ts +1 -1
- package/mobile/nativeConfig.test.ts +1 -1
- package/mobile/nativePluginFolders.test.ts +1 -1
- package/mobile/nativePublicEnv.test.ts +1 -1
- package/mobile/nativeWebDir.test.ts +1 -1
- package/mobile/serverBundleSecrets.test.ts +1 -1
- package/mobile/tarWriter.test.ts +1 -1
- package/mobile/updatePackFolder.test.ts +1 -1
- package/package.json +167 -3
- package/packageExports.test.ts +20 -2
- package/piDependencyPins.test.ts +1 -1
- package/pipeline/PipelineDefinition.ts +1 -1
- package/platformTest/IdleWatchedProcess.test.ts +1 -1
- package/platformTest/PlatformTestRun.test.ts +1 -1
- package/platformTest/TestSnapshot.test.ts +1 -1
- package/preview/PreviewView.ts +32 -11
- package/preview/previewView.test.ts +76 -9
- package/{abstractDoc.test.ts → quality/abstractDoc.test.ts} +2 -2
- package/{abstractDoc.ts → quality/abstractDoc.ts} +1 -1
- package/quality/bareErrorScanner.ts +126 -0
- package/{maintainabilityBaseline.test.ts → quality/maintainabilityBaseline.test.ts} +73 -0
- package/{maintainabilityBaseline.ts → quality/maintainabilityBaseline.ts} +97 -9
- package/{maintainabilityContract.test.ts → quality/maintainabilityContract.test.ts} +383 -2
- package/{maintainabilityContract.ts → quality/maintainabilityContract.ts} +151 -29
- package/{maintainabilityExceptionScanner.test.ts → quality/maintainabilityExceptionScanner.test.ts} +15 -1
- package/{maintainabilityExceptionScanner.ts → quality/maintainabilityExceptionScanner.ts} +5 -1
- package/{maintainabilityLimits.ts → quality/maintainabilityLimits.ts} +12 -0
- package/{maintainabilityReport.ts → quality/maintainabilityReport.ts} +20 -3
- package/{qualityScanner.test.ts → quality/qualityScanner.test.ts} +1 -1
- package/{qualityScanner.ts → quality/qualityScanner.ts} +8 -8
- package/{storeAccessScanner.ts → quality/storeAccessScanner.ts} +15 -2
- package/{subspace.test.ts → subspace/subspace.test.ts} +9 -3
- package/{subspace.ts → subspace/subspace.ts} +5 -5
- package/{subspaceClone.ts → subspace/subspaceClone.ts} +8 -8
- package/{subspaceConfig.ts → subspace/subspaceConfig.ts} +5 -1
- package/{testHelpers.ts → test/testHelpers.ts} +37 -1
- package/transforms/barrelAnalyzer.ts +26 -8
- package/transforms/browserDirnamePlugin.test.ts +1 -1
- package/transforms/externalizeFrameworkPlugin.test.ts +1 -1
- package/transforms/mcpAppPageTrimmer.test.ts +1 -1
- package/transforms/pureLazyMarker.test.ts +1 -1
- package/transforms/serverEnvPlugin.test.ts +1 -1
- package/transforms/serverEnvProfile.test.ts +1 -1
- package/transforms/sideEffectImportOrder.test.ts +1 -1
- package/transforms/transforms.test.ts +29 -2
- package/transforms/tsconfigPackageResolver.test.ts +1 -1
- package/{createTunnel.test.ts → tunnel/createTunnel.test.ts} +1 -1
- package/{createTunnel.ts → tunnel/createTunnel.ts} +2 -2
- package/{sshHostKeys.ts → tunnel/sshHostKeys.ts} +2 -2
- package/typecheck/projectTypecheck.test.ts +1 -1
- package/typecheck/projectTypecheck.ts +6 -2
- package/{typeChecker.test.ts → typecheck/typeChecker.test.ts} +1 -1
- package/{typeChecker.ts → typecheck/typeChecker.ts} +1 -1
- package/typecheck/typecheck.proc.ts +4 -3
- package/typecheck/typecheckFailure.ts +7 -2
- package/util/errorReport.ts +66 -0
- package/{jsonFormatter.test.ts → util/jsonFormatter.test.ts} +1 -1
- package/workflow/artifacts.ts +8 -7
- package/workflow/constantSource.ts +187 -0
- package/workflow/dictionarySource.ts +184 -0
- package/workflow/executor.ts +6 -9
- package/workflow/fieldExpression.ts +153 -0
- package/workflow/fieldLabel.ts +61 -0
- package/workflow/fieldOrder.ts +117 -0
- package/workflow/fieldType.ts +93 -0
- package/workflow/guardCatalog.test.ts +1 -1
- package/workflow/index.ts +2 -0
- package/workflow/keyRename.ts +1 -1
- package/workflow/moduleIndex.test.ts +2 -2
- package/workflow/moduleIndex.ts +2 -2
- package/workflow/modulePaths.ts +27 -0
- package/workflow/mutationScaffold.ts +7 -15
- package/workflow/mutationSource.ts +2 -1
- package/workflow/plainName.ts +28 -0
- package/workflow/plan.ts +15 -9
- package/workflow/primitiveReport.ts +78 -0
- package/workflow/rolloutGate.test.ts +1 -1
- package/workflow/rolloutGate.ts +1 -1
- package/workflow/serviceSource.ts +33 -0
- package/workflow/signalSource.ts +96 -0
- package/workflow/source.ts +50 -1105
- package/workflow/sourceAst.ts +30 -0
- package/workflow/sourceImports.ts +105 -0
- package/workflow/sourceText.ts +13 -0
- package/workflow/templateSource.ts +30 -0
- package/workflow/testSource.ts +31 -0
- package/workflow/types.ts +1 -1
- package/workflow/uiPolicy.ts +1 -1
- package/{appSelectionMemory.ts → workspace/appSelectionMemory.ts} +1 -1
- package/{codegenLock.test.ts → workspace/codegenLock.test.ts} +1 -1
- package/{dependencyScanner.test.ts → workspace/dependencyScanner.test.ts} +1 -1
- package/{dependencyScanner.ts → workspace/dependencyScanner.ts} +2 -2
- package/{envSeed.test.ts → workspace/envSeed.test.ts} +2 -2
- package/{envSeed.ts → workspace/envSeed.ts} +1 -1
- package/{libSource.test.ts → workspace/libSource.test.ts} +2 -2
- package/{libSource.ts → workspace/libSource.ts} +1 -1
- package/{scanInfo.ts → workspace/scanInfo.ts} +21 -10
- package/{slicePlanner.test.ts → workspace/slicePlanner.test.ts} +2 -2
- package/{slicePlanner.ts → workspace/slicePlanner.ts} +1 -1
- package/{workspaceGraph.test.ts → workspace/workspaceGraph.test.ts} +85 -1
- package/{workspaceGraph.ts → workspace/workspaceGraph.ts} +41 -6
- package/{workspaceLayout.test.ts → workspace/workspaceLayout.test.ts} +1 -1
- package/{workspaceLayout.ts → workspace/workspaceLayout.ts} +3 -1
- package/akanContext.ts +0 -1084
- package/constantFieldNames.ts +0 -18
- package/executors.ts +0 -1749
- /package/{recipeScanner.ts → context/recipeScanner.ts} +0 -0
- /package/{declarationReader.ts → docs/declarationReader.ts} +0 -0
- /package/{frameworkGraph.ts → docs/frameworkGraph.ts} +0 -0
- /package/{biomeBase.ts → lint/biomeBase.ts} +0 -0
- /package/{linter.ts → lint/linter.ts} +0 -0
- /package/{commentDensityScanner.test.ts → quality/commentDensityScanner.test.ts} +0 -0
- /package/{commentDensityScanner.ts → quality/commentDensityScanner.ts} +0 -0
- /package/{componentSizeScanner.test.ts → quality/componentSizeScanner.test.ts} +0 -0
- /package/{componentSizeScanner.ts → quality/componentSizeScanner.ts} +0 -0
- /package/{componentWriteChainScanner.test.ts → quality/componentWriteChainScanner.test.ts} +0 -0
- /package/{componentWriteChainScanner.ts → quality/componentWriteChainScanner.ts} +0 -0
- /package/{deprecatedCommentScanner.test.ts → quality/deprecatedCommentScanner.test.ts} +0 -0
- /package/{deprecatedCommentScanner.ts → quality/deprecatedCommentScanner.ts} +0 -0
- /package/{endpointReach.test.ts → quality/endpointReach.test.ts} +0 -0
- /package/{endpointReach.ts → quality/endpointReach.ts} +0 -0
- /package/{formSetterScanner.test.ts → quality/formSetterScanner.test.ts} +0 -0
- /package/{formSetterScanner.ts → quality/formSetterScanner.ts} +0 -0
- /package/{kindBranchScanner.test.ts → quality/kindBranchScanner.test.ts} +0 -0
- /package/{kindBranchScanner.ts → quality/kindBranchScanner.ts} +0 -0
- /package/{maintainabilityReport.test.ts → quality/maintainabilityReport.test.ts} +0 -0
- /package/{renderMutationScanner.test.ts → quality/renderMutationScanner.test.ts} +0 -0
- /package/{renderMutationScanner.ts → quality/renderMutationScanner.ts} +0 -0
- /package/{serviceLoopCallScanner.test.ts → quality/serviceLoopCallScanner.test.ts} +0 -0
- /package/{serviceLoopCallScanner.ts → quality/serviceLoopCallScanner.ts} +0 -0
- /package/{signalMutationIndex.test.ts → quality/signalMutationIndex.test.ts} +0 -0
- /package/{signalMutationIndex.ts → quality/signalMutationIndex.ts} +0 -0
- /package/{sourceComments.test.ts → quality/sourceComments.test.ts} +0 -0
- /package/{sourceComments.ts → quality/sourceComments.ts} +0 -0
- /package/{ssrScanner.test.ts → quality/ssrScanner.test.ts} +0 -0
- /package/{ssrScanner.ts → quality/ssrScanner.ts} +0 -0
- /package/{storeAccessScanner.test.ts → quality/storeAccessScanner.test.ts} +0 -0
- /package/{storeSource.ts → quality/storeSource.ts} +0 -0
- /package/{storeWriteScanner.test.ts → quality/storeWriteScanner.test.ts} +0 -0
- /package/{storeWriteScanner.ts → quality/storeWriteScanner.ts} +0 -0
- /package/{structureScanner.test.ts → quality/structureScanner.test.ts} +0 -0
- /package/{structureScanner.ts → quality/structureScanner.ts} +0 -0
- /package/{testOnlyExportScanner.test.ts → quality/testOnlyExportScanner.test.ts} +0 -0
- /package/{testOnlyExportScanner.ts → quality/testOnlyExportScanner.ts} +0 -0
- /package/{writePath.test.ts → quality/writePath.test.ts} +0 -0
- /package/{writePath.ts → quality/writePath.ts} +0 -0
- /package/{writePlacementScanner.test.ts → quality/writePlacementScanner.test.ts} +0 -0
- /package/{writePlacementScanner.ts → quality/writePlacementScanner.ts} +0 -0
- /package/{writingActionIndex.test.ts → quality/writingActionIndex.test.ts} +0 -0
- /package/{writingActionIndex.ts → quality/writingActionIndex.ts} +0 -0
- /package/{subspaceReport.ts → subspace/subspaceReport.ts} +0 -0
- /package/{sshTunnel.ts → tunnel/sshTunnel.ts} +0 -0
- /package/{fileEditor.ts → util/fileEditor.ts} +0 -0
- /package/{fileSys.test.ts → util/fileSys.test.ts} +0 -0
- /package/{fileSys.ts → util/fileSys.ts} +0 -0
- /package/{jsonFormatter.ts → util/jsonFormatter.ts} +0 -0
- /package/{selectModel.ts → util/selectModel.ts} +0 -0
- /package/{semver.test.ts → util/semver.test.ts} +0 -0
- /package/{semver.ts → util/semver.ts} +0 -0
- /package/{shellOnlyEnv.test.ts → util/shellOnlyEnv.test.ts} +0 -0
- /package/{shellOnlyEnv.ts → util/shellOnlyEnv.ts} +0 -0
- /package/{spinner.test.ts → util/spinner.test.ts} +0 -0
- /package/{spinner.ts → util/spinner.ts} +0 -0
- /package/{stripAnsi.ts → util/stripAnsi.ts} +0 -0
- /package/{codegenLock.ts → workspace/codegenLock.ts} +0 -0
- /package/{getRelatedCnsts.ts → workspace/getRelatedCnsts.ts} +0 -0
- /package/{gitRevision.test.ts → workspace/gitRevision.test.ts} +0 -0
- /package/{gitRevision.ts → workspace/gitRevision.ts} +0 -0
- /package/{manifestDependencies.ts → workspace/manifestDependencies.ts} +0 -0
- /package/{packageExportsMap.ts → workspace/packageExportsMap.ts} +0 -0
- /package/{repoIdentity.ts → workspace/repoIdentity.ts} +0 -0
- /package/{types.ts → workspace/types.ts} +0 -0
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import ts from "typescript";
|
|
2
|
+
|
|
3
|
+
const isFieldCall = (node: ts.Expression): boolean =>
|
|
4
|
+
ts.isCallExpression(node) &&
|
|
5
|
+
(ts.isIdentifier(node.expression)
|
|
6
|
+
? node.expression.text === "field"
|
|
7
|
+
: ts.isPropertyAccessExpression(node.expression) && isFieldCall(node.expression.expression));
|
|
8
|
+
|
|
9
|
+
const propertyNames = (content: string, declares: (initializer: ts.Expression) => boolean) => {
|
|
10
|
+
const names: string[] = [];
|
|
11
|
+
const visit = (node: ts.Node) => {
|
|
12
|
+
if (ts.isPropertyAssignment(node) && ts.isIdentifier(node.name) && declares(node.initializer))
|
|
13
|
+
names.push(node.name.text);
|
|
14
|
+
ts.forEachChild(node, visit);
|
|
15
|
+
};
|
|
16
|
+
visit(ts.createSourceFile("module.ts", content, ts.ScriptTarget.Latest));
|
|
17
|
+
return names;
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
export const constantFieldNames = (content: string) => propertyNames(content, isFieldCall);
|
|
21
|
+
|
|
22
|
+
export const unlabeledFieldNames = (constantContent: string, dictionaryContent: string) => {
|
|
23
|
+
const labels = new Set(propertyNames(dictionaryContent, () => true));
|
|
24
|
+
return constantFieldNames(constantContent).filter((name) => !labels.has(name));
|
|
25
|
+
};
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { describe, expect, test } from "bun:test";
|
|
2
2
|
import { writeFile } from "node:fs/promises";
|
|
3
3
|
import path from "node:path";
|
|
4
|
+
import { tempDirs } from "../test/testHelpers";
|
|
4
5
|
import { collectRecipeSources, findInlineRecipeDuplicates, type RecipeInfo, scanRecipes } from "./recipeScanner";
|
|
5
|
-
import { tempDirs } from "./testHelpers";
|
|
6
6
|
|
|
7
7
|
const byName = (recipes: RecipeInfo[], name: string) => recipes.find((recipe) => recipe.name === name);
|
|
8
8
|
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { readdir } from "node:fs/promises";
|
|
2
|
+
import { FileSys } from "../util/fileSys";
|
|
3
|
+
|
|
4
|
+
export const safeReadDir = async (dirPath: string) =>
|
|
5
|
+
(await readdir(dirPath, { withFileTypes: true }).catch(() => [])).sort((a, b) => a.name.localeCompare(b.name));
|
|
6
|
+
|
|
7
|
+
export const safeReadText = (filePath: string) => FileSys.readText(filePath).catch(() => null);
|
|
8
|
+
|
|
9
|
+
export const safeReadJson = <T>(filePath: string) => FileSys.readJson<T>(filePath).catch(() => null);
|
|
@@ -43,7 +43,7 @@ interface CsrE2eServer {
|
|
|
43
43
|
|
|
44
44
|
const DEFAULT_PORT = 8391;
|
|
45
45
|
const RELOAD_MARKER = "__akanE2eBootMarker";
|
|
46
|
-
//? Longer than the frame's navigation lock (360ms after a transition commits, `webkit/
|
|
46
|
+
//? Longer than the frame's navigation lock (360ms after a transition commits, `webkit/useCsrNavigation.ts`).
|
|
47
47
|
const SETTLE_MS = 450;
|
|
48
48
|
|
|
49
49
|
/** Drives a page of a running `akan start` in a headless `Bun.WebView`: CSR (`?csr=true` + a mobile target) or SSR. */
|
package/devkitUtils.test.ts
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { describe, expect, test } from "bun:test";
|
|
2
2
|
import { realpath } from "node:fs/promises";
|
|
3
3
|
import path from "node:path";
|
|
4
|
-
import { ApplicationBuildReporter } from "./applicationBuildReporter";
|
|
5
|
-
import { resolveSignalTestPreloadPath } from "./applicationTestPreload";
|
|
6
|
-
import { TypeScriptDependencyScanner } from "./dependencyScanner";
|
|
4
|
+
import { ApplicationBuildReporter } from "./app/applicationBuildReporter";
|
|
5
|
+
import { resolveSignalTestPreloadPath } from "./app/applicationTestPreload";
|
|
7
6
|
import { AppExecutor, WorkspaceExecutor } from "./executors";
|
|
8
|
-
import { tempDirs, writeText as write } from "./testHelpers";
|
|
9
|
-
import
|
|
7
|
+
import { tempDirs, writeText as write } from "./test/testHelpers";
|
|
8
|
+
import { TypeScriptDependencyScanner } from "./workspace/dependencyScanner";
|
|
9
|
+
import type { PackageJson, TsConfigJson } from "./workspace/types";
|
|
10
10
|
|
|
11
11
|
const makeTempRoot = tempDirs("akan-devkit-utils-");
|
|
12
12
|
|
|
@@ -199,6 +199,40 @@ describe("ApplicationBuildReporter", () => {
|
|
|
199
199
|
);
|
|
200
200
|
});
|
|
201
201
|
|
|
202
|
+
test("shows the first 20 errors of an aggregate, counts the rest, and follows its cause", () => {
|
|
203
|
+
const many = new AggregateError(
|
|
204
|
+
Array.from({ length: 23 }, (_, index) => new Error(`log ${index + 1}`)),
|
|
205
|
+
"server graph failed",
|
|
206
|
+
{ cause: new Error("plugin licenseNotices") },
|
|
207
|
+
);
|
|
208
|
+
expect(ApplicationBuildReporter.formatError(many).split("\n")).toEqual([
|
|
209
|
+
"server graph failed",
|
|
210
|
+
...Array.from({ length: 20 }, (_, index) => ` log ${index + 1}`),
|
|
211
|
+
" …and 3 more",
|
|
212
|
+
"Caused by: plugin licenseNotices",
|
|
213
|
+
]);
|
|
214
|
+
});
|
|
215
|
+
|
|
216
|
+
test("ends a cause or an aggregate that loops back on itself", () => {
|
|
217
|
+
const looped = new Error("upload failed");
|
|
218
|
+
looped.cause = new Error("socket closed", { cause: looped });
|
|
219
|
+
expect(ApplicationBuildReporter.formatError(looped).split("\n")).toEqual([
|
|
220
|
+
"upload failed",
|
|
221
|
+
"Caused by: socket closed",
|
|
222
|
+
"Caused by: [circular]",
|
|
223
|
+
]);
|
|
224
|
+
|
|
225
|
+
const shared = new Error("disk full");
|
|
226
|
+
const aggregate = new AggregateError([shared, shared], "two writes failed");
|
|
227
|
+
aggregate.errors.push(aggregate);
|
|
228
|
+
expect(ApplicationBuildReporter.formatError(aggregate).split("\n")).toEqual([
|
|
229
|
+
"two writes failed",
|
|
230
|
+
" disk full",
|
|
231
|
+
" disk full",
|
|
232
|
+
" [circular]",
|
|
233
|
+
]);
|
|
234
|
+
});
|
|
235
|
+
|
|
202
236
|
test("says where the bundler placed each reason, relative to the workspace root", async () => {
|
|
203
237
|
const root = await makeTempRoot();
|
|
204
238
|
const refuseWith = (message: string) => ({
|
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
import { describe, expect, test } from "bun:test";
|
|
2
2
|
import path from "node:path";
|
|
3
|
-
import { AgentAssets } from "
|
|
3
|
+
import { AgentAssets } from "../guideline/agentAssets";
|
|
4
4
|
import { ApiReference } from "./apiReference";
|
|
5
5
|
|
|
6
|
-
const akanjsDir = path.resolve(import.meta.dir, "
|
|
7
|
-
const target = ApiReference.target(path.resolve(import.meta.dir, "
|
|
6
|
+
const akanjsDir = path.resolve(import.meta.dir, "../../../akanjs");
|
|
7
|
+
const target = ApiReference.target(path.resolve(import.meta.dir, "../../cli"));
|
|
8
8
|
|
|
9
9
|
describe("ApiReference", () => {
|
|
10
10
|
const rendered = ApiReference.render(akanjsDir);
|
|
11
11
|
|
|
12
|
-
test("the committed guideline matches the akanjs sources; regenerate with bun pkgs/@akanjs/devkit/apiReference.ts", async () => {
|
|
12
|
+
test("the committed guideline matches the akanjs sources; regenerate with bun pkgs/@akanjs/devkit/docs/apiReference.ts", async () => {
|
|
13
13
|
expect(await Bun.file(target).text()).toBe(rendered);
|
|
14
14
|
});
|
|
15
15
|
|
|
@@ -234,7 +234,7 @@ export class ApiReference {
|
|
|
234
234
|
}
|
|
235
235
|
|
|
236
236
|
if (import.meta.main) {
|
|
237
|
-
const akanjsDir = path.resolve(import.meta.dir, "
|
|
238
|
-
const target = ApiReference.target(path.resolve(import.meta.dir, "
|
|
237
|
+
const akanjsDir = path.resolve(import.meta.dir, "../../../akanjs");
|
|
238
|
+
const target = ApiReference.target(path.resolve(import.meta.dir, "../../cli"));
|
|
239
239
|
await Bun.write(target, ApiReference.render(akanjsDir));
|
|
240
240
|
}
|
|
@@ -0,0 +1,282 @@
|
|
|
1
|
+
import { describe, expect, test } from "bun:test";
|
|
2
|
+
import path from "node:path";
|
|
3
|
+
import { AgentAssets } from "../guideline/agentAssets";
|
|
4
|
+
import { tempDirs, writeText } from "../test/testHelpers";
|
|
5
|
+
import { ErrorCodeReference } from "./errorCodeReference";
|
|
6
|
+
import type { ErrorCodeRow } from "./errorCodeScan";
|
|
7
|
+
|
|
8
|
+
const akanjsDir = path.resolve(import.meta.dir, "../../../akanjs");
|
|
9
|
+
const target = ErrorCodeReference.target(path.resolve(import.meta.dir, "../../cli"));
|
|
10
|
+
const makeTempRoot = tempDirs("akan-error-codes-");
|
|
11
|
+
|
|
12
|
+
const git = (root: string, args: string[]) => {
|
|
13
|
+
const run = Bun.spawnSync(["git", ...args], { cwd: root, stdout: "pipe", stderr: "pipe" });
|
|
14
|
+
if (run.exitCode !== 0) throw new Error(`git ${args.join(" ")}: ${run.stderr.toString()}`);
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
const fixtureOf = async (files: Record<string, string>, untracked: Record<string, string> = {}) => {
|
|
18
|
+
const root = await makeTempRoot();
|
|
19
|
+
const akanError = await Bun.file(path.join(akanjsDir, "base/akanError.ts")).text();
|
|
20
|
+
await writeText(path.join(root, "base/akanError.ts"), akanError);
|
|
21
|
+
for (const [file, content] of Object.entries(files)) await writeText(path.join(root, file), content);
|
|
22
|
+
git(root, ["init", "-q"]);
|
|
23
|
+
git(root, ["add", "."]);
|
|
24
|
+
for (const [file, content] of Object.entries(untracked)) await writeText(path.join(root, file), content);
|
|
25
|
+
return root;
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
const statusError = `import { AkanError } from "../base/akanError";
|
|
29
|
+
export class StatusError extends AkanError {
|
|
30
|
+
constructor(statusCode: number, message: string) {
|
|
31
|
+
super(AkanError.codeOfStatus(statusCode), message, { statusCode });
|
|
32
|
+
}
|
|
33
|
+
override get forwarded() {
|
|
34
|
+
return true;
|
|
35
|
+
}
|
|
36
|
+
override toJSON() {
|
|
37
|
+
return { error: this.message, statusCode: this.statusCode };
|
|
38
|
+
}
|
|
39
|
+
static NotFound = class NotFoundError extends StatusError {
|
|
40
|
+
constructor(message = "Not Found") {
|
|
41
|
+
super(404, message);
|
|
42
|
+
}
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
`;
|
|
46
|
+
|
|
47
|
+
const rowOf = (row: Partial<ErrorCodeRow> & Pick<ErrorCodeRow, "error" | "file">): ErrorCodeRow => ({
|
|
48
|
+
code: null,
|
|
49
|
+
byStatus: false,
|
|
50
|
+
statusCode: 500,
|
|
51
|
+
forwarded: false,
|
|
52
|
+
wire: true,
|
|
53
|
+
...row,
|
|
54
|
+
});
|
|
55
|
+
|
|
56
|
+
describe("ErrorCodeReference", () => {
|
|
57
|
+
const rendered = ErrorCodeReference.render(akanjsDir);
|
|
58
|
+
|
|
59
|
+
test("the committed guideline matches the akanjs sources; regenerate with bun run error:codes", async () => {
|
|
60
|
+
expect(await Bun.file(target).text()).toBe(rendered);
|
|
61
|
+
});
|
|
62
|
+
|
|
63
|
+
test("fits one skill reference part", () => {
|
|
64
|
+
expect(AgentAssets.split(rendered)).toHaveLength(1);
|
|
65
|
+
expect(rendered.length).toBeLessThanOrEqual(AgentAssets.referenceLimit);
|
|
66
|
+
});
|
|
67
|
+
|
|
68
|
+
test("reads a literal code, a union through a conditional, a status class, options a subclass passes on and each status an error is built with", async () => {
|
|
69
|
+
const root = await fixtureOf({
|
|
70
|
+
"server/quotaError.ts": `import { AkanError } from "../base/akanError";
|
|
71
|
+
export class QuotaError extends AkanError<"quotaExceeded"> {
|
|
72
|
+
constructor(message = "") {
|
|
73
|
+
super("quotaExceeded", message, { statusCode: 429 });
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
`,
|
|
77
|
+
"server/inputError.ts": `import { AkanError } from "../base/akanError";
|
|
78
|
+
export class InputError extends AkanError<"missingInput" | "invalidInput"> {
|
|
79
|
+
constructor(expected: string | null) {
|
|
80
|
+
super(expected ? "invalidInput" : "missingInput", "input", { statusCode: 400 });
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
`,
|
|
84
|
+
"server/jobError.ts": `import { AkanError } from "../base/akanError";
|
|
85
|
+
export type JobErrorCode = "stalled" | "lost";
|
|
86
|
+
export class JobError extends AkanError<JobErrorCode> {
|
|
87
|
+
constructor(code: JobErrorCode, message: string, options?: { cause?: unknown }) {
|
|
88
|
+
super(code, message, options);
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
`,
|
|
92
|
+
"server/passError.ts": `import { AkanError } from "../base/akanError";
|
|
93
|
+
export class PassError extends AkanError {
|
|
94
|
+
constructor(code: string, options?: { statusCode?: number }) {
|
|
95
|
+
super(code, "pass", options);
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
`,
|
|
99
|
+
"signal/statusError.ts": statusError,
|
|
100
|
+
"signal/use.ts": `import { AkanError } from "../base/akanError";
|
|
101
|
+
import { PassError } from "../server/passError";
|
|
102
|
+
import { StatusError } from "./statusError";
|
|
103
|
+
export const fail = (busy: boolean) => {
|
|
104
|
+
if (busy) throw new StatusError(503, "busy");
|
|
105
|
+
throw new AkanError("plain", "plain", { statusCode: 418 });
|
|
106
|
+
};
|
|
107
|
+
export const pass = (missing: boolean) => {
|
|
108
|
+
if (missing) throw new PassError("passed", { statusCode: 404 });
|
|
109
|
+
throw new PassError("defaulted");
|
|
110
|
+
};
|
|
111
|
+
export const relay = (code: string) => new PassError(code, { statusCode: 400 });
|
|
112
|
+
export const answer = (status: number) => new StatusError(status, "answered");
|
|
113
|
+
`,
|
|
114
|
+
"signal/use.test.ts": `import { StatusError } from "./statusError";
|
|
115
|
+
throw new StatusError(409, "only in a test");
|
|
116
|
+
`,
|
|
117
|
+
});
|
|
118
|
+
|
|
119
|
+
expect(ErrorCodeReference.collect(root)).toEqual([
|
|
120
|
+
rowOf({ code: "defaulted", error: "PassError", file: "server/passError.ts" }),
|
|
121
|
+
rowOf({ code: "invalidInput", statusCode: 400, error: "InputError", file: "server/inputError.ts" }),
|
|
122
|
+
rowOf({ code: "lost", error: "JobError", file: "server/jobError.ts" }),
|
|
123
|
+
rowOf({ code: "missingInput", statusCode: 400, error: "InputError", file: "server/inputError.ts" }),
|
|
124
|
+
rowOf({
|
|
125
|
+
code: "notFound",
|
|
126
|
+
statusCode: 404,
|
|
127
|
+
error: "StatusError.NotFound",
|
|
128
|
+
forwarded: true,
|
|
129
|
+
wire: false,
|
|
130
|
+
file: "signal/statusError.ts",
|
|
131
|
+
}),
|
|
132
|
+
rowOf({ code: "passed", statusCode: 404, error: "PassError", file: "server/passError.ts" }),
|
|
133
|
+
rowOf({ code: "plain", statusCode: 418, error: "AkanError", file: "base/akanError.ts" }),
|
|
134
|
+
rowOf({ code: "quotaExceeded", statusCode: 429, error: "QuotaError", file: "server/quotaError.ts" }),
|
|
135
|
+
rowOf({
|
|
136
|
+
code: "serviceUnavailable",
|
|
137
|
+
statusCode: 503,
|
|
138
|
+
error: "StatusError",
|
|
139
|
+
forwarded: true,
|
|
140
|
+
wire: false,
|
|
141
|
+
file: "signal/statusError.ts",
|
|
142
|
+
}),
|
|
143
|
+
rowOf({ code: "stalled", error: "JobError", file: "server/jobError.ts" }),
|
|
144
|
+
rowOf({ statusCode: 400, error: "PassError", file: "server/passError.ts" }),
|
|
145
|
+
rowOf({
|
|
146
|
+
byStatus: true,
|
|
147
|
+
statusCode: null,
|
|
148
|
+
error: "StatusError",
|
|
149
|
+
forwarded: true,
|
|
150
|
+
wire: false,
|
|
151
|
+
file: "signal/statusError.ts",
|
|
152
|
+
}),
|
|
153
|
+
]);
|
|
154
|
+
const page = ErrorCodeReference.render(root);
|
|
155
|
+
expect(page).toContain("| set when thrown | 400 | `PassError` |");
|
|
156
|
+
expect(page).toContain("| by status | set when thrown | `StatusError` |");
|
|
157
|
+
});
|
|
158
|
+
|
|
159
|
+
test("reads the tracked package sources the gate measures, through classes that name no AkanError", async () => {
|
|
160
|
+
const root = await fixtureOf(
|
|
161
|
+
{
|
|
162
|
+
"signal/statusError.ts": statusError,
|
|
163
|
+
"server/wideError.ts": `import { StatusError } from "../signal/statusError";
|
|
164
|
+
export class WideError<T extends { id: string } = { id: string }> extends StatusError {
|
|
165
|
+
constructor(statusCode: number, readonly item: T) {
|
|
166
|
+
super(statusCode, "wide");
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
`,
|
|
170
|
+
"server/useWide.ts": `import { WideError } from "./wideError";
|
|
171
|
+
export const clash = () => new WideError(409, { id: "a" });
|
|
172
|
+
`,
|
|
173
|
+
"examples/demo.ts": `import { StatusError } from "../signal/statusError";
|
|
174
|
+
export const demo = () => new StatusError(413, "an example");
|
|
175
|
+
`,
|
|
176
|
+
"server/demo.fixture.ts": `import { StatusError } from "../signal/statusError";
|
|
177
|
+
export const fixture = () => new StatusError(401, "a fixture");
|
|
178
|
+
`,
|
|
179
|
+
},
|
|
180
|
+
{
|
|
181
|
+
"server/scratch.ts": `import { StatusError } from "../signal/statusError";
|
|
182
|
+
export const scratch = () => new StatusError(502, "not committed");
|
|
183
|
+
`,
|
|
184
|
+
},
|
|
185
|
+
);
|
|
186
|
+
|
|
187
|
+
expect(ErrorCodeReference.collect(root).map(({ code, error }) => `${code} ${error}`)).toEqual([
|
|
188
|
+
"conflict WideError",
|
|
189
|
+
"notFound StatusError.NotFound",
|
|
190
|
+
"null StatusError",
|
|
191
|
+
]);
|
|
192
|
+
});
|
|
193
|
+
|
|
194
|
+
test("reads a forwarded getter that compares this.code to a literal per code", async () => {
|
|
195
|
+
const root = await fixtureOf({
|
|
196
|
+
"service/queryError.ts": `import { AkanError } from "../base/akanError";
|
|
197
|
+
export class QueryError extends AkanError<"badQuery" | "queryDown"> {
|
|
198
|
+
constructor(code: "badQuery" | "queryDown") {
|
|
199
|
+
super(code, "query", { statusCode: 400 });
|
|
200
|
+
}
|
|
201
|
+
override get forwarded() {
|
|
202
|
+
return this.code !== "queryDown";
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
`,
|
|
206
|
+
});
|
|
207
|
+
|
|
208
|
+
expect(ErrorCodeReference.collect(root).map(({ code, forwarded, wire }) => `${code} ${forwarded} ${wire}`)).toEqual(
|
|
209
|
+
["badQuery true true", "queryDown false true"],
|
|
210
|
+
);
|
|
211
|
+
});
|
|
212
|
+
|
|
213
|
+
test("reads a forwarded getter on state only a restored copy holds as forwarded", async () => {
|
|
214
|
+
const root = await fixtureOf({
|
|
215
|
+
"common/restoredError.ts": `import { AkanError } from "../base/akanError";
|
|
216
|
+
const wireCodeOf = (error: unknown) => (error as { wire?: string }).wire;
|
|
217
|
+
export class RestoredError extends AkanError<"restored"> {
|
|
218
|
+
constructor() {
|
|
219
|
+
super("restored", "restored");
|
|
220
|
+
}
|
|
221
|
+
override get forwarded() {
|
|
222
|
+
return wireCodeOf(this) === undefined;
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
`,
|
|
226
|
+
});
|
|
227
|
+
|
|
228
|
+
expect(ErrorCodeReference.collect(root).map(({ code, forwarded }) => `${code} ${forwarded}`)).toEqual([
|
|
229
|
+
"restored true",
|
|
230
|
+
]);
|
|
231
|
+
});
|
|
232
|
+
|
|
233
|
+
test("lists each code with the status its own code chooses", async () => {
|
|
234
|
+
const root = await fixtureOf({
|
|
235
|
+
"service/storeError.ts": `import { AkanError } from "../base/akanError";
|
|
236
|
+
export class StoreError extends AkanError<"badValue" | "missing" | "down"> {
|
|
237
|
+
constructor(code: "badValue" | "missing" | "down", message: string) {
|
|
238
|
+
super(code, message, { statusCode: code === "badValue" ? 400 : 500 });
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
`,
|
|
242
|
+
"service/tableError.ts": `import { AkanError } from "../base/akanError";
|
|
243
|
+
type TableCode = "slow" | "refused";
|
|
244
|
+
export class TableError extends AkanError<TableCode> {
|
|
245
|
+
static readonly #statuses: Record<TableCode, number> = { slow: 504, refused: 400 };
|
|
246
|
+
constructor(code: TableCode, message: string) {
|
|
247
|
+
super(code, message, { statusCode: TableError.#statuses[code] });
|
|
248
|
+
}
|
|
249
|
+
}
|
|
250
|
+
`,
|
|
251
|
+
});
|
|
252
|
+
|
|
253
|
+
expect(
|
|
254
|
+
ErrorCodeReference.collect(root).map(({ code, statusCode, error }) => `${code} ${statusCode} ${error}`),
|
|
255
|
+
).toEqual([
|
|
256
|
+
"badValue 400 StoreError",
|
|
257
|
+
"down 500 StoreError",
|
|
258
|
+
"missing 500 StoreError",
|
|
259
|
+
"refused 400 TableError",
|
|
260
|
+
"slow 504 TableError",
|
|
261
|
+
]);
|
|
262
|
+
});
|
|
263
|
+
|
|
264
|
+
test("refuses a forwarded getter it cannot read as a literal", async () => {
|
|
265
|
+
const root = await fixtureOf({
|
|
266
|
+
"server/flagError.ts": `import { AkanError } from "../base/akanError";
|
|
267
|
+
export class FlagError extends AkanError<"flagged"> {
|
|
268
|
+
constructor(readonly relayed: boolean) {
|
|
269
|
+
super("flagged", "flag");
|
|
270
|
+
}
|
|
271
|
+
override get forwarded() {
|
|
272
|
+
return this.relayed;
|
|
273
|
+
}
|
|
274
|
+
}
|
|
275
|
+
`,
|
|
276
|
+
});
|
|
277
|
+
|
|
278
|
+
expect(() => ErrorCodeReference.collect(root)).toThrow(
|
|
279
|
+
"FlagError's forwarded getter returns more than a literal true or false",
|
|
280
|
+
);
|
|
281
|
+
});
|
|
282
|
+
});
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import path from "node:path";
|
|
2
|
+
import { type ErrorCodeRow, ErrorCodeScan } from "./errorCodeScan";
|
|
3
|
+
|
|
4
|
+
export class ErrorCodeReference {
|
|
5
|
+
static readonly guideline = "errorCodes";
|
|
6
|
+
|
|
7
|
+
static target(cliDir: string) {
|
|
8
|
+
return path.join(
|
|
9
|
+
cliDir,
|
|
10
|
+
"guidelines",
|
|
11
|
+
ErrorCodeReference.guideline,
|
|
12
|
+
`${ErrorCodeReference.guideline}.instruction.md`,
|
|
13
|
+
);
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
static collect(akanjsDir: string): ErrorCodeRow[] {
|
|
17
|
+
return new ErrorCodeScan(akanjsDir).rows();
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
static render(akanjsDir: string): string {
|
|
21
|
+
const scan = new ErrorCodeScan(akanjsDir);
|
|
22
|
+
const rows = scan.rows();
|
|
23
|
+
const yesNo = (value: boolean) => (value ? "yes" : "no");
|
|
24
|
+
return [
|
|
25
|
+
"# Akan.js error codes",
|
|
26
|
+
"",
|
|
27
|
+
"Generated from the akanjs sources of this release: every code a framework error carries, so a caller branches on",
|
|
28
|
+
"`error.code`, or the `code` of the JSON it was answered with, rather than on the message.",
|
|
29
|
+
"",
|
|
30
|
+
"- A **forwarded** error answers with its own JSON. Any other `AkanError` answers with its code and status, and in",
|
|
31
|
+
" production with the status's reason in place of its message, which can name a table, a file or what a provider",
|
|
32
|
+
" said (`akan start` and `AKAN_ERROR_DETAIL=1` keep the message).",
|
|
33
|
+
"- **Code on the wire** says whether that JSON carries `code`. A forwarded error whose JSON leaves it out is told",
|
|
34
|
+
" apart by its `error` key and status.",
|
|
35
|
+
"- An app's own failure is a dictionary `Err`, which carries its key in `error` instead of one of these codes.",
|
|
36
|
+
'- In code, `AkanError.is(error, "<code>")` tests any framework error for a code, and `<Class>.is(error)` one class.',
|
|
37
|
+
"",
|
|
38
|
+
"## Codes",
|
|
39
|
+
"",
|
|
40
|
+
"| Code | Status | Error | Forwarded | Code on the wire | Source |",
|
|
41
|
+
"|---|---|---|---|---|---|",
|
|
42
|
+
...rows.map(
|
|
43
|
+
(row) =>
|
|
44
|
+
`| ${ErrorCodeReference.#codeCell(row)} | ${row.statusCode ?? "set when thrown"} | \`${row.error}\` | ${yesNo(row.forwarded)} | ${yesNo(row.wire)} | \`${row.file}\` |`,
|
|
45
|
+
),
|
|
46
|
+
"",
|
|
47
|
+
"## Codes by status",
|
|
48
|
+
"",
|
|
49
|
+
"An error coded by its status, such as an `Exception`, takes its code from `AkanError.codeOfStatus`:",
|
|
50
|
+
"",
|
|
51
|
+
"| Status | Code | Reason |",
|
|
52
|
+
"|---|---|---|",
|
|
53
|
+
...[...scan.statuses].map(([status, [code, reason]]) => `| ${status} | \`${code}\` | ${reason} |`),
|
|
54
|
+
"",
|
|
55
|
+
"Any other status is coded `http<status>`, with the reason `Internal Server Error` from 500 and `Request Failed`",
|
|
56
|
+
"below it.",
|
|
57
|
+
"",
|
|
58
|
+
].join("\n");
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
static #codeCell(row: ErrorCodeRow) {
|
|
62
|
+
if (row.code !== null) return `\`${row.code}\``;
|
|
63
|
+
return row.byStatus ? "by status" : "set when thrown";
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
if (import.meta.main) {
|
|
68
|
+
const akanjsDir = path.resolve(import.meta.dir, "../../../akanjs");
|
|
69
|
+
const target = ErrorCodeReference.target(path.resolve(import.meta.dir, "../../cli"));
|
|
70
|
+
await Bun.write(target, ErrorCodeReference.render(akanjsDir));
|
|
71
|
+
}
|