akanjs 3.0.0-alpha.7 → 3.0.0-alpha.71
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 +103 -0
- package/README.ko.md +1 -1
- package/README.md +1 -1
- package/base/baseEnv.ts +7 -4
- package/base/primitiveRegistry.ts +59 -12
- package/base/symbols.ts +4 -0
- package/client/capacitor.ts +34 -0
- package/client/clientRuntime.ts +5 -0
- package/client/csrTypes.ts +4 -3
- package/client/index.ts +1 -0
- package/client/locale.ts +2 -2
- package/client/router.ts +7 -7
- package/client/sharedContext.ts +31 -0
- package/client/translator.ts +2 -2
- package/client/types.ts +3 -3
- package/common/Logger.ts +280 -67
- package/common/clientAddress.ts +40 -0
- package/common/deepObjectify.ts +24 -9
- package/common/index.ts +42 -1
- package/common/logContext.ts +27 -0
- package/common/mcpExposure.ts +114 -0
- package/common/pathGetLoose.ts +31 -0
- package/common/pathSet.ts +17 -5
- package/common/plainFieldsOf.ts +13 -0
- package/common/routeConvention.ts +22 -12
- package/common/websocketBinaryFrame.ts +46 -0
- package/constant/crystalize.ts +94 -28
- package/constant/dateSlot.ts +62 -0
- package/constant/deserialize.ts +3 -2
- package/constant/fieldInfo.ts +43 -3
- package/constant/fieldQueryMeta.ts +35 -0
- package/constant/getDefault.ts +16 -11
- package/constant/hydrationPlan.ts +72 -0
- package/constant/immerify.ts +4 -6
- package/constant/index.ts +5 -0
- package/constant/labelOf.ts +26 -0
- package/constant/mask.ts +67 -0
- package/constant/purify.ts +17 -11
- package/constant/textFieldPaths.ts +13 -7
- package/constant/types.ts +19 -13
- package/constant/via.ts +24 -17
- package/dictionary/DictionaryLookup.ts +30 -0
- package/dictionary/agent.dictionary.ts +31 -0
- package/dictionary/agentTurn.dictionary.ts +29 -0
- package/dictionary/base.dictionary.ts +81 -0
- package/dictionary/dictInfo.ts +11 -2
- package/dictionary/dictionary.ts +9 -3
- package/dictionary/index.ts +1 -0
- package/dictionary/trans.ts +2 -2
- package/document/documentQuery.ts +1 -0
- package/document/filterMeta.ts +77 -12
- package/document/index.ts +1 -0
- package/document/noDocumentError.ts +12 -0
- package/document/types.ts +0 -1
- package/fetch/agentTurn.ts +19 -0
- package/fetch/client/fetchClient.ts +137 -37
- package/fetch/client/httpClient.ts +95 -20
- package/fetch/client/wsClient.ts +27 -12
- package/fetch/fetchType/appliedReturn.type.ts +65 -44
- package/fetch/fetchType/endpointFetch.type.ts +17 -8
- package/fetch/fetchType/sliceFetch.type.ts +27 -50
- package/fetch/index.ts +1 -0
- package/index.ts +80 -6
- package/local/apps/akan/akan-local.db +0 -0
- package/local/apps/akan/akan-local.db-shm +0 -0
- package/local/apps/akan/akan-local.db-wal +0 -0
- package/local/apps/akan/akan-local_solid.db +0 -0
- package/local/apps/akan/akan-local_solid.db-shm +0 -0
- package/local/apps/akan/akan-local_solid.db-wal +0 -0
- package/local/apps/serverLifecycle/serverLifecycle-local.db +0 -0
- package/local/apps/serverLifecycle/serverLifecycle-local.db-shm +0 -0
- package/local/apps/serverLifecycle/serverLifecycle-local.db-wal +0 -0
- package/local/apps/serverLifecycle/serverLifecycle-local_solid.db +0 -0
- package/local/apps/serverLifecycle/serverLifecycle-local_solid.db-shm +0 -0
- package/local/apps/serverLifecycle/serverLifecycle-local_solid.db-wal +0 -0
- package/package.json +27 -18
- package/server/akanApp.ts +278 -138
- package/server/akanAppHeaders.ts +16 -2
- package/server/akanOption.ts +63 -8
- package/server/akanServer.ts +387 -32
- package/server/animatedImage.ts +83 -0
- package/server/assetEncoding.ts +4 -24
- package/server/binaryPubsub.ts +55 -0
- package/server/console.ts +110 -101
- package/server/consoleEvaluator.ts +51 -0
- package/server/consolePasteFilter.ts +91 -0
- package/server/consoleSession.ts +242 -0
- package/server/contentEncoding.ts +83 -0
- package/server/devtools/signalSerializer.ts +2 -2
- package/server/devtools/types.ts +4 -4
- package/server/di/diLifecycle.ts +123 -13
- package/server/di/predefinedAdaptor.ts +6 -0
- package/server/di/utils.ts +40 -0
- package/server/imageOptimizer.ts +154 -57
- package/server/lifecycle/runtimeDir.ts +14 -0
- package/server/lifecycle/shutdownManager.ts +1 -1
- package/server/logging/childOutputReader.ts +137 -0
- package/server/logging/hubFileSink.ts +39 -0
- package/server/logging/logControlSocket.ts +173 -0
- package/server/logging/logForwarder.ts +131 -0
- package/server/logging/logHub.ts +0 -0
- package/server/logging/logQuery.ts +130 -0
- package/server/logging/logStdoutWriter.ts +39 -0
- package/server/logging/logStreamRoute.ts +87 -0
- package/server/logging/logTailClient.ts +161 -0
- package/server/mcp/McpAuth.ts +177 -0
- package/server/mcp/McpDispatcher.ts +289 -0
- package/server/mcp/McpEventStream.ts +24 -0
- package/server/mcp/McpExecutionContext.ts +105 -0
- package/server/mcp/McpRouter.ts +621 -0
- package/server/mcp/index.ts +5 -0
- package/server/processMetricsCollector.ts +1 -1
- package/server/resolver/database.resolver.ts +5 -4
- package/server/resolver/signal.resolver.ts +208 -86
- package/server/routeTreeBuilder.ts +10 -8
- package/server/routing/apiRouter.ts +44 -14
- package/server/routing/appWsData.ts +24 -2
- package/server/routing/eventStream.ts +93 -0
- package/server/routing/soloAppRoutes.ts +50 -0
- package/server/rscWorker.tsx +36 -22
- package/server/rscWorkerHost.ts +59 -8
- package/server/semaphore.ts +22 -0
- package/server/subRouteIndexDocument.tsx +61 -0
- package/server/systemPageDocument.tsx +3 -3
- package/server/systemPages.tsx +49 -16
- package/server/types.tsx +28 -0
- package/server/vendor/akanjs-fetch.ts +1 -0
- package/server/webRouter.ts +96 -39
- package/service/adapt.ts +4 -4
- package/service/agent.service.ts +81 -0
- package/service/base.service.ts +2 -1
- package/service/index.ts +1 -0
- package/service/injectInfo.ts +8 -3
- package/service/ipcTypes.ts +6 -0
- package/service/predefinedAdaptor/compress.adaptor.ts +5 -1
- package/service/predefinedAdaptor/database.adaptor.ts +68 -37
- package/service/predefinedAdaptor/deepseekLlm.ts +271 -0
- package/service/predefinedAdaptor/index.ts +3 -0
- package/service/predefinedAdaptor/insightQuery.ts +183 -0
- package/service/predefinedAdaptor/llm.adaptor.ts +115 -0
- package/service/predefinedAdaptor/logging.adaptor.ts +1 -1
- package/service/predefinedAdaptor/queue.adaptor.ts +5 -2
- package/service/predefinedAdaptor/role.adaptor.ts +2 -0
- package/service/predefinedAdaptor/schedule.adaptor.ts +12 -5
- package/service/predefinedAdaptor/solidPubsub.adaptor.ts +10 -6
- package/service/predefinedAdaptor/solidQueue.adaptor.ts +6 -2
- package/service/predefinedAdaptor/solidSqlite.ts +11 -9
- package/service/predefinedAdaptor/websocket.adaptor.ts +6 -1
- package/service/serve.ts +16 -9
- package/service/toolNames.ts +119 -0
- package/signal/agent/AgentCatalogue.ts +165 -0
- package/signal/agent/index.ts +1 -0
- package/signal/agent.signal.ts +38 -0
- package/signal/agentTurn.ts +8 -0
- package/signal/agentTurnStream.ts +60 -0
- package/signal/base.signal.ts +2 -1
- package/signal/endpointInfo.ts +38 -2
- package/signal/guard.ts +28 -1
- package/signal/guards.ts +49 -1
- package/signal/index.ts +6 -0
- package/signal/intercept.ts +4 -4
- package/signal/internalArg.ts +21 -4
- package/signal/mcp/McpDocument.ts +326 -0
- package/signal/mcp/McpProgress.ts +106 -0
- package/signal/mcp/McpUriTemplate.ts +80 -0
- package/signal/mcp/Msg.ts +368 -0
- package/signal/mcp/index.ts +5 -0
- package/signal/mcp/mcpProtocol.ts +120 -0
- package/signal/middleware.ts +3 -3
- package/signal/openapi/openapi.ts +36 -173
- package/signal/schema/JsonSchemaBuilder.ts +221 -0
- package/signal/schema/index.ts +1 -0
- package/signal/serializer/fetch.serializer.ts +51 -0
- package/signal/signalContext.ts +324 -76
- package/signal/slice.ts +62 -27
- package/signal/trace.ts +268 -9
- package/signal/types.ts +55 -4
- package/store/action.ts +34 -41
- package/store/actionTag.ts +33 -0
- package/store/agent/AgentBridge.ts +87 -0
- package/store/agent/AgentContext.ts +71 -0
- package/store/agent/AgentPrompts.ts +111 -0
- package/store/agent/ScreenReader.ts +349 -0
- package/store/agent/ScreenSettle.ts +45 -0
- package/store/agent/ScreenTarget.ts +135 -0
- package/store/agent/StoreCatalogue.ts +116 -0
- package/store/agent/StoreSurfaceSource.ts +225 -0
- package/store/agent/index.ts +13 -0
- package/store/agent/storeSurface.ts +28 -0
- package/store/agent/types.ts +16 -0
- package/store/agentic/AgentValue.ts +119 -0
- package/store/agentic/StExposeBuilder.ts +47 -0
- package/store/agentic/StExposeDraft.ts +24 -0
- package/store/agentic/StStateBuilder.ts +85 -0
- package/store/agentic/StStateDraft.ts +23 -0
- package/store/agentic/StToolBuilder.ts +279 -0
- package/store/agentic/StToolDraft.ts +22 -0
- package/store/agentic/attachAgentic.ts +33 -0
- package/store/agentic/formFields.ts +194 -0
- package/store/agentic/index.ts +12 -0
- package/store/agentic/useFieldTool.ts +183 -0
- package/store/agentic/useFormTools.ts +77 -0
- package/store/agentic/useRelationFieldTool.ts +113 -0
- package/store/baseSt.ts +1 -1
- package/store/databaseStateNames.ts +31 -0
- package/store/formSetterNames.ts +35 -0
- package/store/index.ts +8 -0
- package/store/rootStore.ts +3 -1
- package/store/sliceRole.ts +36 -0
- package/store/state.ts +2 -12
- package/store/store.ts +9 -0
- package/store/storeInstance.ts +185 -20
- package/store/storeRegistry.ts +39 -1
- package/store/types.ts +5 -0
- package/store/withSelector.ts +5 -4
- package/test/index.ts +1 -1
- package/test/registerDom.ts +4 -0
- package/test/sampleOf.ts +2 -0
- package/test/signalTestRuntime.ts +5 -5
- package/test/testServer.ts +14 -11
- package/types/base/baseEnv.d.ts +1 -1
- package/types/base/primitiveRegistry.d.ts +20 -8
- package/types/base/symbols.d.ts +4 -0
- package/types/client/capacitor.d.ts +39 -0
- package/types/client/clientRuntime.d.ts +7 -0
- package/types/client/index.d.ts +1 -0
- package/types/client/sharedContext.d.ts +21 -0
- package/types/client/types.d.ts +5 -3
- package/types/common/Logger.d.ts +88 -6
- package/types/common/clientAddress.d.ts +19 -0
- package/types/common/deepObjectify.d.ts +4 -2
- package/types/common/index.d.ts +8 -2
- package/types/common/logContext.d.ts +17 -0
- package/types/common/mcpExposure.d.ts +64 -0
- package/types/common/pathGetLoose.d.ts +8 -0
- package/types/common/plainFieldsOf.d.ts +6 -0
- package/types/common/routeConvention.d.ts +6 -0
- package/types/common/websocketBinaryFrame.d.ts +17 -0
- package/types/constant/constantRegistry.d.ts +2 -10
- package/types/constant/crystalize.d.ts +5 -0
- package/types/constant/dateSlot.d.ts +14 -0
- package/types/constant/fieldInfo.d.ts +20 -3
- package/types/constant/fieldQueryMeta.d.ts +17 -0
- package/types/constant/getDefault.d.ts +8 -0
- package/types/constant/hydrationPlan.d.ts +24 -0
- package/types/constant/index.d.ts +5 -0
- package/types/constant/labelOf.d.ts +7 -0
- package/types/constant/mask.d.ts +41 -0
- package/types/constant/purify.d.ts +2 -2
- package/types/constant/types.d.ts +5 -5
- package/types/dictionary/DictionaryLookup.d.ts +14 -0
- package/types/dictionary/agent.dictionary.d.ts +1 -0
- package/types/dictionary/agentTurn.dictionary.d.ts +1 -0
- package/types/dictionary/base.dictionary.d.ts +1 -1
- package/types/dictionary/dictInfo.d.ts +7 -1
- package/types/dictionary/dictionary.d.ts +11 -9
- package/types/dictionary/index.d.ts +1 -0
- package/types/document/filterMeta.d.ts +24 -4
- package/types/document/index.d.ts +1 -0
- package/types/document/noDocumentError.d.ts +12 -0
- package/types/document/types.d.ts +0 -1
- package/types/fetch/agentTurn.d.ts +475 -0
- package/types/fetch/client/fetchClient.d.ts +12 -0
- package/types/fetch/client/httpClient.d.ts +2 -1
- package/types/fetch/fetchType/appliedReturn.type.d.ts +37 -18
- package/types/fetch/fetchType/endpointFetch.type.d.ts +8 -5
- package/types/fetch/fetchType/sliceFetch.type.d.ts +11 -15
- package/types/fetch/index.d.ts +1 -0
- package/types/index.d.ts +74 -10
- package/types/server/akanApp.d.ts +12 -0
- package/types/server/akanAppHeaders.d.ts +7 -1
- package/types/server/akanOption.d.ts +36 -6
- package/types/server/akanServer.d.ts +67 -9
- package/types/server/animatedImage.d.ts +7 -0
- package/types/server/assetEncoding.d.ts +1 -1
- package/types/server/binaryPubsub.d.ts +18 -0
- package/types/server/console.d.ts +11 -1
- package/types/server/consoleEvaluator.d.ts +2 -0
- package/types/server/consolePasteFilter.d.ts +11 -0
- package/types/server/consoleSession.d.ts +22 -0
- package/types/server/contentEncoding.d.ts +28 -0
- package/types/server/devtools/types.d.ts +4 -4
- package/types/server/di/diLifecycle.d.ts +10 -2
- package/types/server/di/predefinedAdaptor.d.ts +4 -1
- package/types/server/di/utils.d.ts +16 -0
- package/types/server/lifecycle/runtimeDir.d.ts +5 -0
- package/types/server/logging/childOutputReader.d.ts +40 -0
- package/types/server/logging/hubFileSink.d.ts +18 -0
- package/types/server/logging/logControlSocket.d.ts +60 -0
- package/types/server/logging/logForwarder.d.ts +37 -0
- package/types/server/logging/logHub.d.ts +70 -0
- package/types/server/logging/logQuery.d.ts +31 -0
- package/types/server/logging/logStdoutWriter.d.ts +35 -0
- package/types/server/logging/logStreamRoute.d.ts +20 -0
- package/types/server/logging/logTailClient.d.ts +42 -0
- package/types/server/mcp/McpAuth.d.ts +62 -0
- package/types/server/mcp/McpDispatcher.d.ts +61 -0
- package/types/server/mcp/McpEventStream.d.ts +17 -0
- package/types/server/mcp/McpExecutionContext.d.ts +44 -0
- package/types/server/mcp/McpRouter.d.ts +65 -0
- package/types/server/mcp/index.d.ts +5 -0
- package/types/server/mcp.d.ts +1 -0
- package/types/server/resolver/signal.resolver.d.ts +7 -4
- package/types/server/routing/apiRouter.d.ts +2 -1
- package/types/server/routing/appWsData.d.ts +13 -1
- package/types/server/routing/eventStream.d.ts +23 -0
- package/types/server/routing/soloAppRoutes.d.ts +17 -0
- package/types/server/rscWorkerHost.d.ts +4 -1
- package/types/server/semaphore.d.ts +5 -0
- package/types/server/subRouteIndexDocument.d.ts +8 -0
- package/types/server/systemPageDocument.d.ts +1 -0
- package/types/server/systemPages.d.ts +5 -0
- package/types/server/types.d.ts +16 -0
- package/types/server/vendor/akanjs-fetch.d.ts +1 -0
- package/types/server/webRouter.d.ts +15 -4
- package/types/service/adapt.d.ts +2 -2
- package/types/service/agent.service.d.ts +32 -0
- package/types/service/base.service.d.ts +4 -0
- package/types/service/index.d.ts +1 -0
- package/types/service/injectInfo.d.ts +2 -2
- package/types/service/ipcTypes.d.ts +12 -0
- package/types/service/predefinedAdaptor/compress.adaptor.d.ts +1 -1
- package/types/service/predefinedAdaptor/database.adaptor.d.ts +9 -3
- package/types/service/predefinedAdaptor/deepseekLlm.d.ts +76 -0
- package/types/service/predefinedAdaptor/index.d.ts +3 -0
- package/types/service/predefinedAdaptor/insightQuery.d.ts +50 -0
- package/types/service/predefinedAdaptor/llm.adaptor.d.ts +105 -0
- package/types/service/predefinedAdaptor/queue.adaptor.d.ts +3 -2
- package/types/service/predefinedAdaptor/role.adaptor.d.ts +2 -0
- package/types/service/predefinedAdaptor/schedule.adaptor.d.ts +10 -6
- package/types/service/predefinedAdaptor/solidQueue.adaptor.d.ts +6 -2
- package/types/service/predefinedAdaptor/solidSqlite.d.ts +2 -2
- package/types/service/serve.d.ts +3 -3
- package/types/service/toolNames.d.ts +35 -0
- package/types/signal/agent/AgentCatalogue.d.ts +100 -0
- package/types/signal/agent/index.d.ts +1 -0
- package/types/signal/agent.d.ts +1 -0
- package/types/signal/agent.signal.d.ts +24 -0
- package/types/signal/agentTurn.d.ts +9 -0
- package/types/signal/agentTurnStream.d.ts +24 -0
- package/types/signal/base.signal.d.ts +1 -1
- package/types/signal/endpointInfo.d.ts +21 -3
- package/types/signal/guard.d.ts +12 -0
- package/types/signal/guards.d.ts +23 -1
- package/types/signal/index.d.ts +6 -0
- package/types/signal/intercept.d.ts +2 -2
- package/types/signal/internalArg.d.ts +22 -6
- package/types/signal/mcp/McpDocument.d.ts +84 -0
- package/types/signal/mcp/McpProgress.d.ts +40 -0
- package/types/signal/mcp/McpUriTemplate.d.ts +25 -0
- package/types/signal/mcp/Msg.d.ts +143 -0
- package/types/signal/mcp/index.d.ts +5 -0
- package/types/signal/mcp/mcpProtocol.d.ts +107 -0
- package/types/signal/mcp.d.ts +1 -0
- package/types/signal/middleware.d.ts +7 -7
- package/types/signal/openapi/openapi.d.ts +3 -3
- package/types/signal/schema/JsonSchemaBuilder.d.ts +51 -0
- package/types/signal/schema/index.d.ts +1 -0
- package/types/signal/schema.d.ts +1 -0
- package/types/signal/signalContext.d.ts +67 -8
- package/types/signal/slice.d.ts +42 -15
- package/types/signal/trace.d.ts +52 -2
- package/types/signal/types.d.ts +53 -4
- package/types/store/action.d.ts +7 -5
- package/types/store/actionTag.d.ts +21 -0
- package/types/store/agent/AgentBridge.d.ts +37 -0
- package/types/store/agent/AgentContext.d.ts +16 -0
- package/types/store/agent/AgentPrompts.d.ts +31 -0
- package/types/store/agent/ScreenReader.d.ts +29 -0
- package/types/store/agent/ScreenSettle.d.ts +22 -0
- package/types/store/agent/ScreenTarget.d.ts +34 -0
- package/types/store/agent/StoreCatalogue.d.ts +26 -0
- package/types/store/agent/StoreSurfaceSource.d.ts +30 -0
- package/types/store/agent/index.d.ts +11 -0
- package/types/store/agent/storeSurface.d.ts +14 -0
- package/types/store/agent/types.d.ts +15 -0
- package/types/store/agent.d.ts +1 -0
- package/types/store/agentic/AgentValue.d.ts +43 -0
- package/types/store/agentic/StExposeBuilder.d.ts +21 -0
- package/types/store/agentic/StExposeDraft.d.ts +13 -0
- package/types/store/agentic/StStateBuilder.d.ts +21 -0
- package/types/store/agentic/StStateDraft.d.ts +12 -0
- package/types/store/agentic/StToolBuilder.d.ts +56 -0
- package/types/store/agentic/StToolDraft.d.ts +13 -0
- package/types/store/agentic/attachAgentic.d.ts +25 -0
- package/types/store/agentic/formFields.d.ts +53 -0
- package/types/store/agentic/index.d.ts +12 -0
- package/types/store/agentic/useFieldTool.d.ts +22 -0
- package/types/store/agentic/useFormTools.d.ts +19 -0
- package/types/store/agentic/useRelationFieldTool.d.ts +27 -0
- package/types/store/agentic.d.ts +1 -0
- package/types/store/baseSt.d.ts +35 -39
- package/types/store/databaseStateNames.d.ts +25 -0
- package/types/store/formSetterNames.d.ts +30 -0
- package/types/store/index.d.ts +7 -0
- package/types/store/rootStore.d.ts +5 -1
- package/types/store/sliceRole.d.ts +25 -0
- package/types/store/store.d.ts +5 -1
- package/types/store/storeInstance.d.ts +33 -1
- package/types/store/storeRegistry.d.ts +5 -0
- package/types/store/types.d.ts +4 -0
- package/types/store/withSelector.d.ts +5 -4
- package/types/test/index.d.ts +1 -1
- package/types/test/registerDom.d.ts +1 -0
- package/types/test/signalTestRuntime.d.ts +2 -3
- package/types/test/testServer.d.ts +6 -4
- package/types/ui/Agent/Approval.d.ts +8 -0
- package/types/ui/Agent/Attach.d.ts +16 -0
- package/types/ui/Agent/Bubble.d.ts +26 -0
- package/types/ui/Agent/Chat.d.ts +91 -0
- package/types/ui/Agent/ChatCommands.d.ts +34 -0
- package/types/ui/Agent/Composer.d.ts +23 -0
- package/types/ui/Agent/Context.d.ts +13 -0
- package/types/ui/Agent/Dock.d.ts +17 -0
- package/types/ui/Agent/Guide.d.ts +9 -0
- package/types/ui/Agent/History.d.ts +26 -0
- package/types/ui/Agent/Launcher.d.ts +16 -0
- package/types/ui/Agent/Markdown.d.ts +19 -0
- package/types/ui/Agent/Menu.d.ts +18 -0
- package/types/ui/Agent/Mic.d.ts +8 -0
- package/types/ui/Agent/Question.d.ts +14 -0
- package/types/ui/Agent/Section.d.ts +10 -0
- package/types/ui/Agent/Skip.d.ts +22 -0
- package/types/ui/Agent/StateKey.d.ts +16 -0
- package/types/ui/Agent/Tool.d.ts +15 -0
- package/types/ui/Agent/Transcript.d.ts +13 -0
- package/types/ui/Agent/Zone.d.ts +48 -0
- package/types/ui/Agent/agentSessionOf.d.ts +27 -0
- package/types/ui/Agent/attachment.d.ts +34 -0
- package/types/ui/Agent/fetchRunner.d.ts +12 -0
- package/types/ui/Agent/index.d.ts +19 -0
- package/types/ui/Agent/index_.d.ts +1 -0
- package/types/ui/Agent/markdownBlocks.d.ts +35 -0
- package/types/ui/Agent/markdownSpans.d.ts +2 -0
- package/types/ui/Agent/markdownTable.d.ts +16 -0
- package/types/ui/Agent/sessionHistory.d.ts +14 -0
- package/types/ui/Agent/sessionView.d.ts +15 -0
- package/types/ui/Agent/tokenCount.d.ts +6 -0
- package/types/ui/Agent/useChatAttachments.d.ts +24 -0
- package/types/ui/Agent/useChatVoice.d.ts +30 -0
- package/types/ui/Agent/useDraftRecall.d.ts +14 -0
- package/types/ui/Agent/useKeyboardInset.d.ts +8 -0
- package/types/ui/Agent/useSlashMenu.d.ts +24 -0
- package/types/ui/Agent/voice.d.ts +71 -0
- package/types/ui/Agent.d.ts +1 -0
- package/types/ui/Badge.d.ts +1 -1
- package/types/ui/Button.d.ts +1 -1
- package/types/ui/Constant/Graph.d.ts +10 -0
- package/types/ui/Constant/index.d.ts +2 -1
- package/types/ui/Constant/schemaGraph.d.ts +39 -0
- package/types/ui/Data/Dashboard.d.ts +16 -3
- package/types/ui/Data/Insight.d.ts +1 -1
- package/types/ui/Data/ListContainer.d.ts +15 -7
- package/types/ui/Data/QueryMaker.d.ts +45 -3
- package/types/ui/Data/RefPicker.d.ts +16 -0
- package/types/ui/Data/dataExport.d.ts +5 -0
- package/types/ui/Data/dataText.d.ts +6 -0
- package/types/ui/Data/index.d.ts +2 -0
- package/types/ui/Data/index_.d.ts +1 -0
- package/types/ui/DatePicker.d.ts +15 -11
- package/types/ui/Dialog/LegacyModal.d.ts +13 -0
- package/types/ui/Dialog/Provider.d.ts +3 -1
- package/types/ui/Dialog/context.d.ts +9 -1
- package/types/ui/Dialog/index.d.ts +1 -0
- package/types/ui/DraggableList.d.ts +1 -1
- package/types/ui/Dropdown.d.ts +5 -1
- package/types/ui/Field.d.ts +13 -12
- package/types/ui/Layout/BottomTab.d.ts +3 -2
- package/types/ui/LegacyModal.d.ts +24 -0
- package/types/ui/Loading/ProgressBar.d.ts +4 -0
- package/types/ui/Loading/Spin.d.ts +2 -1
- package/types/ui/Model/AdminPanel.d.ts +15 -3
- package/types/ui/Model/EditModal.d.ts +1 -1
- package/types/ui/Model/New.d.ts +3 -1
- package/types/ui/Model/NewWrapper.d.ts +2 -0
- package/types/ui/Model/NewWrapper_Client.d.ts +2 -1
- package/types/ui/Pagination.d.ts +2 -2
- package/types/ui/Radio.d.ts +1 -1
- package/types/ui/RecentTime.d.ts +18 -1
- package/types/ui/Reference/Collapse.d.ts +11 -0
- package/types/ui/Reference/Panel.d.ts +29 -0
- package/types/ui/Reference/Segmented.d.ts +17 -0
- package/types/ui/Reference/Summary.d.ts +13 -0
- package/types/ui/Reference/Toolbar.d.ts +21 -0
- package/types/ui/Reference/dictText.d.ts +6 -0
- package/types/ui/Reference/index.d.ts +7 -0
- package/types/ui/Reference/style.d.ts +20 -0
- package/types/ui/Reference.d.ts +1 -0
- package/types/ui/ScreenNavigator.d.ts +3 -1
- package/types/ui/Signal/Arg.d.ts +7 -3
- package/types/ui/Signal/Doc.d.ts +4 -6
- package/types/ui/Signal/Object.d.ts +2 -1
- package/types/ui/Signal/RestApi.d.ts +2 -1
- package/types/ui/Signal/WebSocket.d.ts +2 -1
- package/types/ui/Signal/endpointEntries.d.ts +20 -0
- package/types/ui/Signal/style.d.ts +9 -8
- package/types/ui/System/Client.d.ts +1 -2
- package/types/ui/System/Common.d.ts +3 -4
- package/types/ui/System/Messages.d.ts +1 -1
- package/types/ui/Tab/Provider.d.ts +3 -1
- package/types/ui/Tab/context.d.ts +4 -2
- package/types/ui/ToggleSelect.d.ts +1 -0
- package/types/ui/UiOverride/context.d.ts +18 -1
- package/types/ui/agentAttrs.d.ts +14 -0
- package/types/ui/index.d.ts +22 -1
- package/types/ui/overlayLayer.d.ts +13 -0
- package/types/ui/overlayPosition.d.ts +28 -0
- package/types/ui/recipe/badgeRecipe.d.ts +2 -2
- package/types/ui/recipe/buttonRecipe.d.ts +2 -2
- package/types/vendor/use-agentic/AgentAbort.d.ts +17 -0
- package/types/vendor/use-agentic/AgentProgress.d.ts +27 -0
- package/types/vendor/use-agentic/AgentProvider.d.ts +17 -0
- package/types/vendor/use-agentic/AgentScope.d.ts +9 -0
- package/types/vendor/use-agentic/AgentSession.d.ts +163 -0
- package/types/vendor/use-agentic/Agentic.d.ts +21 -0
- package/types/vendor/use-agentic/AgenticSurface.d.ts +58 -0
- package/types/vendor/use-agentic/Compaction.d.ts +48 -0
- package/types/vendor/use-agentic/ToolOutput.d.ts +21 -0
- package/types/vendor/use-agentic/Transcript.d.ts +18 -0
- package/types/vendor/use-agentic/httpRunner.d.ts +15 -0
- package/types/vendor/use-agentic/index.d.ts +19 -0
- package/types/vendor/use-agentic/sharedContext.d.ts +15 -0
- package/types/vendor/use-agentic/surfaceContext.d.ts +5 -0
- package/types/vendor/use-agentic/types.d.ts +182 -0
- package/types/vendor/use-agentic/useAgent.d.ts +4 -0
- package/types/vendor/use-agentic/useAgentGuide.d.ts +6 -0
- package/types/vendor/use-agentic/useAgentResource.d.ts +12 -0
- package/types/vendor/use-agentic/useAgentState.d.ts +16 -0
- package/types/vendor/use-agentic/useAgentTool.d.ts +16 -0
- package/types/vendor/use-agentic.d.ts +1 -0
- package/types/webkit/index.d.ts +4 -0
- package/types/webkit/useBodyScrollLock.d.ts +2 -0
- package/types/webkit/usePageTool.d.ts +19 -0
- package/types/webkit/useScreenScope.d.ts +25 -0
- package/ui/Agent/Approval.tsx +32 -0
- package/ui/Agent/Attach.tsx +77 -0
- package/ui/Agent/Bubble.tsx +192 -0
- package/ui/Agent/Chat.tsx +525 -0
- package/ui/Agent/ChatCommands.ts +141 -0
- package/ui/Agent/Composer.tsx +94 -0
- package/ui/Agent/Context.tsx +49 -0
- package/ui/Agent/Dock.tsx +77 -0
- package/ui/Agent/Guide.tsx +16 -0
- package/ui/Agent/History.tsx +49 -0
- package/ui/Agent/Launcher.tsx +60 -0
- package/ui/Agent/Markdown.tsx +142 -0
- package/ui/Agent/Menu.tsx +55 -0
- package/ui/Agent/Mic.tsx +27 -0
- package/ui/Agent/Question.tsx +63 -0
- package/ui/Agent/Section.tsx +24 -0
- package/ui/Agent/Skip.tsx +30 -0
- package/ui/Agent/StateKey.tsx +46 -0
- package/ui/Agent/Tool.tsx +59 -0
- package/ui/Agent/Transcript.tsx +33 -0
- package/ui/Agent/Zone.tsx +116 -0
- package/ui/Agent/agentSessionOf.ts +60 -0
- package/ui/Agent/attachment.ts +73 -0
- package/ui/Agent/fetchRunner.ts +44 -0
- package/ui/Agent/index.ts +27 -0
- package/ui/Agent/index_.tsx +4 -0
- package/ui/Agent/markdownBlocks.ts +137 -0
- package/ui/Agent/markdownSpans.tsx +49 -0
- package/ui/Agent/markdownTable.ts +54 -0
- package/ui/Agent/sessionHistory.ts +62 -0
- package/ui/Agent/sessionView.ts +38 -0
- package/ui/Agent/tokenCount.ts +10 -0
- package/ui/Agent/useChatAttachments.ts +84 -0
- package/ui/Agent/useChatVoice.ts +129 -0
- package/ui/Agent/useDraftRecall.ts +42 -0
- package/ui/Agent/useKeyboardInset.ts +26 -0
- package/ui/Agent/useSlashMenu.ts +58 -0
- package/ui/Agent/voice.ts +177 -0
- package/ui/Badge.tsx +1 -1
- package/ui/BottomSheet.tsx +32 -36
- package/ui/Button.tsx +3 -1
- package/ui/Clipboard.tsx +3 -6
- package/ui/Constant/Doc.tsx +265 -254
- package/ui/Constant/Graph.tsx +151 -0
- package/ui/Constant/index.ts +3 -2
- package/ui/Constant/schemaGraph.ts +232 -0
- package/ui/Data/CardList.tsx +14 -3
- package/ui/Data/Dashboard.tsx +70 -52
- package/ui/Data/Insight.tsx +18 -12
- package/ui/Data/Item.tsx +42 -56
- package/ui/Data/ListContainer.tsx +246 -132
- package/ui/Data/Pagination.tsx +10 -3
- package/ui/Data/QueryMaker.tsx +160 -11
- package/ui/Data/RefPicker.tsx +202 -0
- package/ui/Data/TableList.tsx +22 -13
- package/ui/Data/dataExport.ts +54 -0
- package/ui/Data/dataText.ts +22 -0
- package/ui/Data/index.ts +13 -1
- package/ui/Data/index_.tsx +1 -0
- package/ui/DatePicker.tsx +110 -128
- package/ui/Dialog/Close.tsx +3 -7
- package/ui/Dialog/LegacyModal.tsx +241 -0
- package/ui/Dialog/Modal.tsx +62 -195
- package/ui/Dialog/Provider.tsx +47 -3
- package/ui/Dialog/Trigger.tsx +3 -7
- package/ui/Dialog/context.ts +14 -2
- package/ui/Dialog/index.tsx +2 -0
- package/ui/DragAction.tsx +3 -2
- package/ui/DraggableList.tsx +9 -4
- package/ui/Dropdown.tsx +89 -27
- package/ui/Empty.tsx +6 -4
- package/ui/Field.tsx +128 -58
- package/ui/Input.tsx +27 -5
- package/ui/KeyboardAvoiding.tsx +2 -2
- package/ui/Layout/BottomTab.tsx +32 -37
- package/ui/Layout/Sider.tsx +37 -14
- package/ui/LegacyModal.tsx +53 -0
- package/ui/Link/CsrLink.tsx +1 -1
- package/ui/Load/Pagination.tsx +15 -8
- package/ui/Load/Units.tsx +30 -7
- package/ui/Load/View.tsx +10 -3
- package/ui/Loading/Area.tsx +7 -6
- package/ui/Loading/Button.tsx +7 -9
- package/ui/Loading/Input.tsx +7 -9
- package/ui/Loading/ProgressBar.tsx +16 -7
- package/ui/Loading/Skeleton.tsx +8 -13
- package/ui/Loading/Spin.tsx +20 -14
- package/ui/Menu.tsx +1 -1
- package/ui/Model/AdminPanel.tsx +52 -12
- package/ui/Model/EditModal.tsx +28 -6
- package/ui/Model/EditWrapper.tsx +16 -4
- package/ui/Model/New.tsx +4 -0
- package/ui/Model/NewWrapper.tsx +2 -0
- package/ui/Model/NewWrapper_Client.tsx +20 -6
- package/ui/Model/Remove.tsx +18 -6
- package/ui/Model/RemoveWrapper.tsx +12 -2
- package/ui/Model/SureToRemove.tsx +18 -6
- package/ui/Model/ViewEditModal.tsx +64 -15
- package/ui/Model/ViewModal.tsx +25 -11
- package/ui/Model/ViewWrapper.tsx +15 -4
- package/ui/Model/index_.tsx +1 -1
- package/ui/Pagination.tsx +51 -66
- package/ui/Popconfirm.tsx +88 -78
- package/ui/Radio.tsx +53 -24
- package/ui/RecentTime.tsx +83 -35
- package/ui/Reference/Collapse.tsx +26 -0
- package/ui/Reference/Panel.tsx +79 -0
- package/ui/Reference/Segmented.tsx +41 -0
- package/ui/Reference/Summary.tsx +25 -0
- package/ui/Reference/Toolbar.tsx +44 -0
- package/ui/Reference/dictText.ts +9 -0
- package/ui/Reference/index.ts +7 -0
- package/ui/Reference/style.ts +45 -0
- package/ui/ScreenNavigator.tsx +17 -2
- package/ui/Select.tsx +96 -57
- package/ui/Signal/Arg.tsx +83 -68
- package/ui/Signal/Doc.tsx +163 -129
- package/ui/Signal/Listener.tsx +40 -29
- package/ui/Signal/Message.tsx +87 -135
- package/ui/Signal/Object.tsx +79 -57
- package/ui/Signal/PubSub.tsx +72 -113
- package/ui/Signal/Request.tsx +2 -22
- package/ui/Signal/Response.tsx +19 -45
- package/ui/Signal/RestApi.tsx +170 -200
- package/ui/Signal/WebSocket.tsx +29 -26
- package/ui/Signal/endpointEntries.ts +59 -0
- package/ui/Signal/makeExample.ts +10 -3
- package/ui/Signal/style.ts +34 -29
- package/ui/Switch.tsx +4 -0
- package/ui/System/CSR.tsx +1 -1
- package/ui/System/Client.tsx +31 -15
- package/ui/System/Common.tsx +3 -4
- package/ui/System/DevModeToggle.tsx +1 -1
- package/ui/System/Gtag.tsx +2 -2
- package/ui/System/Messages.tsx +52 -31
- package/ui/System/Reconnect.tsx +22 -56
- package/ui/System/SelectLanguage.tsx +24 -15
- package/ui/System/ThemeToggle.tsx +25 -13
- package/ui/Tab/Menu.tsx +24 -12
- package/ui/Tab/Menus.tsx +6 -3
- package/ui/Tab/Provider.tsx +30 -3
- package/ui/Tab/context.ts +8 -4
- package/ui/Table.tsx +66 -60
- package/ui/ToggleSelect.tsx +8 -7
- package/ui/Tooltip.tsx +15 -1
- package/ui/UiOverride/context.ts +21 -2
- package/ui/Unauthorized.tsx +6 -4
- package/ui/agentAttrs.ts +19 -0
- package/ui/index.ts +49 -1
- package/ui/overlayLayer.ts +12 -2
- package/ui/overlayPosition.ts +104 -0
- package/ui/recipe/buttonRecipe.ts +2 -2
- package/ui/styles.css +31 -0
- package/vendor/use-agentic/AgentAbort.ts +29 -0
- package/vendor/use-agentic/AgentProgress.ts +40 -0
- package/vendor/use-agentic/AgentProvider.tsx +39 -0
- package/vendor/use-agentic/AgentScope.tsx +20 -0
- package/vendor/use-agentic/AgentSession.ts +750 -0
- package/vendor/use-agentic/Agentic.tsx +44 -0
- package/vendor/use-agentic/AgenticSurface.ts +333 -0
- package/vendor/use-agentic/Compaction.ts +120 -0
- package/vendor/use-agentic/ToolOutput.ts +60 -0
- package/vendor/use-agentic/Transcript.ts +50 -0
- package/vendor/use-agentic/WIRE.md +86 -0
- package/vendor/use-agentic/httpRunner.ts +131 -0
- package/vendor/use-agentic/index.ts +20 -0
- package/vendor/use-agentic/sharedContext.ts +25 -0
- package/vendor/use-agentic/surfaceContext.ts +10 -0
- package/vendor/use-agentic/types.ts +192 -0
- package/vendor/use-agentic/useAgent.ts +18 -0
- package/vendor/use-agentic/useAgentGuide.ts +16 -0
- package/vendor/use-agentic/useAgentResource.ts +36 -0
- package/vendor/use-agentic/useAgentState.ts +64 -0
- package/vendor/use-agentic/useAgentTool.ts +55 -0
- package/webkit/bootCsr.tsx +10 -8
- package/webkit/index.ts +4 -0
- package/webkit/lazy.tsx +5 -1
- package/webkit/useBodyScrollLock.tsx +29 -0
- package/webkit/useFrameRuntime.ts +1 -1
- package/webkit/usePageTool.tsx +37 -0
- package/webkit/useScreenScope.tsx +60 -0
- package/types/ui/Constant/Mermaid.d.ts +0 -8
- package/types/ui/Signal/Collapse.d.ts +0 -12
- package/ui/Constant/Mermaid.tsx +0 -149
- package/ui/Signal/Collapse.tsx +0 -29
|
@@ -0,0 +1,183 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { capitalize } from "akanjs/common";
|
|
3
|
+
import type { JsonSchema, ToolEntry } from "../../vendor/use-agentic";
|
|
4
|
+
import { useScopePath, useSurface } from "../../vendor/use-agentic";
|
|
5
|
+
import { actionTagOf } from "../actionTag";
|
|
6
|
+
import { formSetterNames } from "../formSetterNames";
|
|
7
|
+
|
|
8
|
+
import { useEffect, useRef } from "../hooks";
|
|
9
|
+
import { StoreRegistry } from "../storeRegistry";
|
|
10
|
+
import { type FormFieldRef, FormFields } from "./formFields";
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* A control's `transform` is what it does to every value a person types, so an agent's write goes through it too —
|
|
14
|
+
* otherwise a `Field.Phone` stores `010-1234-5678` for the person and the raw digits for the agent. It normalizes
|
|
15
|
+
* one scalar, so an array-valued control (`TextList`, `Tags`, `DoubleNumber`) applies it per element. A cleared
|
|
16
|
+
* nullable field stays null: a normalizer written for a value would turn it into one.
|
|
17
|
+
*/
|
|
18
|
+
const normalized = (value: unknown, transform: unknown): unknown => {
|
|
19
|
+
if (typeof transform !== "function" || value === null) return value;
|
|
20
|
+
const apply = transform as (input: unknown) => unknown;
|
|
21
|
+
return Array.isArray(value) ? value.map((item) => apply(item)) : apply(value);
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
const dispatcherOf = (action: string) =>
|
|
25
|
+
StoreRegistry.instance.do[action] as ((...args: unknown[]) => unknown) | undefined;
|
|
26
|
+
|
|
27
|
+
const rowsOf = (ref: FormFieldRef): unknown[] => {
|
|
28
|
+
const form = StoreRegistry.instance.get()[`${ref.refName}Form`] as { [key: string]: unknown } | undefined;
|
|
29
|
+
const rows = form?.[ref.key];
|
|
30
|
+
return Array.isArray(rows) ? rows : [];
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* Append and remove-by-index for an array of embedded rows, beside the whole-array setter.
|
|
35
|
+
*
|
|
36
|
+
* Not new authority: the setter this control already published can produce any array these two can, so they are
|
|
37
|
+
* strictly weaker — which is what makes deriving them from the same field sound. What they add is that neither can
|
|
38
|
+
* touch a row it was not given, so the agent stops having to retype the rows it is leaving alone.
|
|
39
|
+
*
|
|
40
|
+
* Both take a list and act atomically. Removing indices one call at a time would shift the ones not yet removed, so
|
|
41
|
+
* `sub` filters the whole set at once, the way the generated action already does.
|
|
42
|
+
*
|
|
43
|
+
* `add` appends and publishes no insert position: the `+` a person presses always appends, and the framework cannot
|
|
44
|
+
* see the `limit` an app may pass from its own `onAdd`. `addOrSub` is never published — it matches by `indexOf`, so
|
|
45
|
+
* on rows it compares by reference and every toggle would append.
|
|
46
|
+
*/
|
|
47
|
+
const rowEntries = (ref: FormFieldRef, arraySchema: JsonSchema): ToolEntry[] => {
|
|
48
|
+
if (!FormFields.rowModelOf(ref.field)) return [];
|
|
49
|
+
const names = formSetterNames(capitalize(ref.refName), ref.key);
|
|
50
|
+
if (!dispatcherOf(names.addFieldOnModel) || !dispatcherOf(names.subFieldOnModel)) return [];
|
|
51
|
+
return [
|
|
52
|
+
{
|
|
53
|
+
name: names.addFieldOnModel,
|
|
54
|
+
description: `Append rows to ${ref.key} on the ${ref.refName} form. Leaves every existing row untouched.`,
|
|
55
|
+
parameters: {
|
|
56
|
+
type: "object",
|
|
57
|
+
properties: { values: arraySchema },
|
|
58
|
+
required: ["values"],
|
|
59
|
+
additionalProperties: false,
|
|
60
|
+
},
|
|
61
|
+
run: (args) => {
|
|
62
|
+
const checked = FormFields.checked(names.addFieldOnModel, "values", ref.field, args.values);
|
|
63
|
+
return dispatcherOf(names.addFieldOnModel)?.(checked);
|
|
64
|
+
},
|
|
65
|
+
},
|
|
66
|
+
{
|
|
67
|
+
name: names.subFieldOnModel,
|
|
68
|
+
description: `Remove rows of ${ref.key} from the ${ref.refName} form by their positions, counting from 0.`,
|
|
69
|
+
parameters: {
|
|
70
|
+
type: "object",
|
|
71
|
+
properties: { idxs: { type: "array", items: { type: "integer" } } },
|
|
72
|
+
required: ["idxs"],
|
|
73
|
+
additionalProperties: false,
|
|
74
|
+
},
|
|
75
|
+
guard: (args) => {
|
|
76
|
+
const idxs = args.idxs;
|
|
77
|
+
if (!Array.isArray(idxs) || !idxs.length) return `"idxs" of ${names.subFieldOnModel} takes at least one index.`;
|
|
78
|
+
const length = rowsOf(ref).length;
|
|
79
|
+
const outside = idxs.filter(
|
|
80
|
+
(idx) => typeof idx !== "number" || !Number.isInteger(idx) || idx < 0 || idx >= length,
|
|
81
|
+
);
|
|
82
|
+
if (!outside.length) return true;
|
|
83
|
+
return `${ref.key} has ${length} ${length === 1 ? "row" : "rows"}, so ${outside.join(", ")} is out of range.`;
|
|
84
|
+
},
|
|
85
|
+
run: (args) => dispatcherOf(names.subFieldOnModel)?.(args.idxs),
|
|
86
|
+
},
|
|
87
|
+
];
|
|
88
|
+
};
|
|
89
|
+
|
|
90
|
+
export interface FieldToolOptions {
|
|
91
|
+
/** The control's own normalizer. Applied to the agent's write exactly as it is to the person's typing. */
|
|
92
|
+
transform?: unknown;
|
|
93
|
+
/** True while the person cannot use the control. Publishes nothing, so the agent gets no lever the screen withholds. */
|
|
94
|
+
disabled?: boolean;
|
|
95
|
+
/** The person can drag entries into a new order, so `move<Field>On<Model>` is a lever the screen really has. */
|
|
96
|
+
sortable?: boolean;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
/**
|
|
100
|
+
* Reorder-by-position for a list the person can drag, beside the whole-array setter.
|
|
101
|
+
*
|
|
102
|
+
* The drag is the lever the screen actually offers, and it changes no row's content — so an agent asked to move one
|
|
103
|
+
* row should not have to retype the nine it is leaving alone, which is the same argument that gives an embedded-row
|
|
104
|
+
* array its `add`/`sub`. There is no store action behind it: reordering *is* a whole-array write, so this splices
|
|
105
|
+
* the live rows and hands them to the setter the drag hands them to, `transform` deliberately not applied — the
|
|
106
|
+
* values are already stored, and normalizing them again is not something dragging does.
|
|
107
|
+
*/
|
|
108
|
+
const moveEntry = (ref: FormFieldRef, onChange: () => (value: unknown) => unknown): ToolEntry => {
|
|
109
|
+
const name = formSetterNames(capitalize(ref.refName), ref.key).moveFieldOnModel;
|
|
110
|
+
return {
|
|
111
|
+
name,
|
|
112
|
+
description: `Move one entry of ${ref.key} on the ${ref.refName} form to another position, counting from 0. Reorders only — no entry's content changes.`,
|
|
113
|
+
parameters: {
|
|
114
|
+
type: "object",
|
|
115
|
+
properties: { from: { type: "integer" }, to: { type: "integer" } },
|
|
116
|
+
required: ["from", "to"],
|
|
117
|
+
additionalProperties: false,
|
|
118
|
+
},
|
|
119
|
+
guard: (args) => {
|
|
120
|
+
const length = rowsOf(ref).length;
|
|
121
|
+
const outside = ["from", "to"].filter((key) => {
|
|
122
|
+
const idx = args[key];
|
|
123
|
+
return typeof idx !== "number" || !Number.isInteger(idx) || idx < 0 || idx >= length;
|
|
124
|
+
});
|
|
125
|
+
if (!outside.length) return true;
|
|
126
|
+
return `${ref.key} has ${length} ${length === 1 ? "entry" : "entries"}, so ${outside.join(" and ")} is out of range.`;
|
|
127
|
+
},
|
|
128
|
+
run: (args) => {
|
|
129
|
+
const rows = [...rowsOf(ref)];
|
|
130
|
+
const [moved] = rows.splice(args.from as number, 1);
|
|
131
|
+
rows.splice(args.to as number, 0, moved);
|
|
132
|
+
return onChange()(rows);
|
|
133
|
+
},
|
|
134
|
+
};
|
|
135
|
+
};
|
|
136
|
+
|
|
137
|
+
/**
|
|
138
|
+
* Publishes the setter a form control is already holding, for exactly as long as the control is usable.
|
|
139
|
+
*
|
|
140
|
+
* The control is the declaration — the same rule the rest of the surface follows. A handler passed by reference
|
|
141
|
+
* (`onChange={st.do.setTitleOnTask}`) names the field it writes, so the tool and the person press one function;
|
|
142
|
+
* an inline arrow names nothing and publishes nothing, which is the existing `data-akan-action` rule with
|
|
143
|
+
* consequences. Publishing from the form's subscription instead would offer every field of the model, including
|
|
144
|
+
* the ones this template draws no control for.
|
|
145
|
+
*
|
|
146
|
+
* `disabled` withdraws the tool for the same reason the whole surface is declaration-only: a field the person
|
|
147
|
+
* cannot type into is not one an agent may write in their place. It also closes the field to `fill<Model>Form`,
|
|
148
|
+
* whose guard offers only what a control published — so one gate covers both writers.
|
|
149
|
+
*/
|
|
150
|
+
export const useFieldTool = (onChange: unknown, { transform, disabled, sortable }: FieldToolOptions = {}) => {
|
|
151
|
+
const surface = useSurface();
|
|
152
|
+
const scope = useScopePath();
|
|
153
|
+
const action = actionTagOf(onChange)?.action ?? null;
|
|
154
|
+
const off = !!disabled;
|
|
155
|
+
const live = useRef({ onChange, transform });
|
|
156
|
+
live.current = { onChange, transform };
|
|
157
|
+
const scopeKey = scope.join(".");
|
|
158
|
+
useEffect(() => {
|
|
159
|
+
if (!action || off) return;
|
|
160
|
+
const ref = FormFields.ref(action);
|
|
161
|
+
const schema = ref && FormFields.schema(ref.field);
|
|
162
|
+
if (!ref || !schema) return;
|
|
163
|
+
const entries: ToolEntry[] = [
|
|
164
|
+
{
|
|
165
|
+
name: action,
|
|
166
|
+
description: `Set ${ref.key} on the ${ref.refName} form.`,
|
|
167
|
+
parameters: { type: "object", properties: { value: schema }, required: ["value"], additionalProperties: false },
|
|
168
|
+
run: (args) => {
|
|
169
|
+
const checked = FormFields.checked(action, "value", ref.field, args.value === undefined ? null : args.value);
|
|
170
|
+
return (live.current.onChange as (value: unknown) => unknown)(normalized(checked, live.current.transform));
|
|
171
|
+
},
|
|
172
|
+
},
|
|
173
|
+
...rowEntries(ref, schema),
|
|
174
|
+
...(sortable && ref.field.arrDepth > 0
|
|
175
|
+
? [moveEntry(ref, () => live.current.onChange as (value: unknown) => unknown)]
|
|
176
|
+
: []),
|
|
177
|
+
];
|
|
178
|
+
const registered = entries.map((entry) => surface.registerTool(scope, entry));
|
|
179
|
+
return () => {
|
|
180
|
+
for (const unregister of registered) unregister();
|
|
181
|
+
};
|
|
182
|
+
}, [surface, scopeKey, action, off, !!sortable]);
|
|
183
|
+
};
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { capitalize } from "akanjs/common";
|
|
3
|
+
import { AgenticSurface, useScopePath, useSurface } from "../../vendor/use-agentic";
|
|
4
|
+
|
|
5
|
+
import { useEffect, useRef } from "../hooks";
|
|
6
|
+
import { FormFields } from "./formFields";
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* One tool that fills several fields of a form at once, published while a component subscribes `<model>Form`.
|
|
10
|
+
*
|
|
11
|
+
* The per-field setters are published by the controls themselves (`useFieldTool`), which is what keeps them to
|
|
12
|
+
* the fields this screen draws. This one exists for what a control cannot reach: a list, a map, an embedded
|
|
13
|
+
* object — the shapes a `st.tool` argument cannot describe one control at a time — and for filling a fresh form
|
|
14
|
+
* in one call. It is a patch, not a replacement, so it never clears what the person already typed.
|
|
15
|
+
*
|
|
16
|
+
* Its schema is every writable field of the model, because a declaration is mount-static and cannot know which
|
|
17
|
+
* controls will render. The **guard** is where the screen gets its say: a plain field has to have published its
|
|
18
|
+
* own setter, and a composite is waved through because its rows are written with `writeOn<Model>(path, value)`,
|
|
19
|
+
* which no control can annotate — so this is the one place an agent can reach a field the screen may not show.
|
|
20
|
+
*
|
|
21
|
+
* The entry is a pure function of `refName`: the schema comes from the model, the guard re-reads the live surface,
|
|
22
|
+
* and every `write` reaches the one store instance. So a form put on screen by a shell that subscribes it
|
|
23
|
+
* (`Model.EditModal`) and by the `Template` inside it registers one declaration twice — the same description both
|
|
24
|
+
* times, which is what the surface reads as interchangeable rather than as a clash an app has to suppress.
|
|
25
|
+
*/
|
|
26
|
+
export const useFormTools = (refName: string | null, write: (action: string, value: unknown) => void) => {
|
|
27
|
+
const surface = useSurface();
|
|
28
|
+
const scope = useScopePath();
|
|
29
|
+
const live = useRef(write);
|
|
30
|
+
live.current = write;
|
|
31
|
+
const scopeKey = scope.join(".");
|
|
32
|
+
useEffect(() => {
|
|
33
|
+
if (!refName) return;
|
|
34
|
+
const fields = FormFields.patchable(refName);
|
|
35
|
+
if (!fields.length) return;
|
|
36
|
+
const byKey = new Map(fields.map((entry) => [entry.key, entry]));
|
|
37
|
+
const name = `fill${capitalize(refName)}Form`;
|
|
38
|
+
const offered = () =>
|
|
39
|
+
fields.filter(
|
|
40
|
+
(entry) =>
|
|
41
|
+
FormFields.isComposite(entry.field) || !!surface.tool(AgenticSurface.fullName(scope, entry.action), scope),
|
|
42
|
+
);
|
|
43
|
+
return surface.registerTool(scope, {
|
|
44
|
+
name,
|
|
45
|
+
description: `Fill fields of the ${refName} form. Sends a patch — a field left out keeps its value.`,
|
|
46
|
+
parameters: {
|
|
47
|
+
type: "object",
|
|
48
|
+
properties: Object.fromEntries(fields.map((entry) => [entry.key, entry.schema])),
|
|
49
|
+
additionalProperties: false,
|
|
50
|
+
},
|
|
51
|
+
guard: (args) => {
|
|
52
|
+
const keys = Object.keys(args);
|
|
53
|
+
if (!keys.length) return "Name at least one field to fill.";
|
|
54
|
+
const open = new Set(offered().map((entry) => entry.key));
|
|
55
|
+
const closed = keys.filter((key) => !open.has(key));
|
|
56
|
+
if (!closed.length) return true;
|
|
57
|
+
return `This screen offers no ${closed.join(", ")} on the ${refName} form. It offers: ${
|
|
58
|
+
[...open].join(", ") || "nothing"
|
|
59
|
+
}.`;
|
|
60
|
+
},
|
|
61
|
+
run: (args) => {
|
|
62
|
+
|
|
63
|
+
const patch = Object.entries(args).map(([key, value]) => {
|
|
64
|
+
const entry = byKey.get(key);
|
|
65
|
+
if (!entry) throw new Error(`The ${refName} form has no field "${key}".`);
|
|
66
|
+
return { entry, value: FormFields.checked(name, key, entry.field, value) };
|
|
67
|
+
});
|
|
68
|
+
|
|
69
|
+
for (const { entry, value } of patch) {
|
|
70
|
+
const control = surface.tool(AgenticSurface.fullName(scope, entry.action), scope);
|
|
71
|
+
if (control) void control.run({ value });
|
|
72
|
+
else live.current(entry.action, value);
|
|
73
|
+
}
|
|
74
|
+
},
|
|
75
|
+
});
|
|
76
|
+
}, [surface, scopeKey, refName]);
|
|
77
|
+
};
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { type Cls, type DataList, PrimitiveRegistry } from "akanjs/base";
|
|
3
|
+
import { capitalize } from "akanjs/common";
|
|
4
|
+
import { type ConstantField, ConstantRegistry } from "akanjs/constant";
|
|
5
|
+
import type { JsonSchema } from "../../vendor/use-agentic";
|
|
6
|
+
import { useScopePath, useSurface } from "../../vendor/use-agentic";
|
|
7
|
+
import { actionTagOf } from "../actionTag";
|
|
8
|
+
|
|
9
|
+
import { useEffect, useRef } from "../hooks";
|
|
10
|
+
import { FormFields } from "./formFields";
|
|
11
|
+
|
|
12
|
+
export interface RelationFieldSource<T extends { id: string }> {
|
|
13
|
+
/** Read live from the store rather than closed over: `load` below changes the list mid-call. */
|
|
14
|
+
read: () => DataList<T>;
|
|
15
|
+
/** Loads the options an agent never opened the dropdown to fetch. */
|
|
16
|
+
load: () => Promise<unknown> | unknown;
|
|
17
|
+
/** How one option reads to a person, so the agent can match what it sees on screen. */
|
|
18
|
+
label: (model: T) => string;
|
|
19
|
+
disabled?: boolean;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
/** The database model a relation field points at, or null for anything else — a primitive, an enum, a scalar. */
|
|
23
|
+
const relationOf = (field: ConstantField): string | null => {
|
|
24
|
+
const modelRef = field.modelRef as unknown as Cls;
|
|
25
|
+
if (field.fieldType !== "property" || field.enum || !modelRef || PrimitiveRegistry.has(modelRef)) return null;
|
|
26
|
+
const refName = ConstantRegistry.getRefName(modelRef, { allowEmpty: true });
|
|
27
|
+
return refName && ConstantRegistry.database.has(refName) ? refName : null;
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* The two tools a relation picker owes an agent: list the documents it can pick, then pick by id.
|
|
32
|
+
*
|
|
33
|
+
* `FormFields` publishes no schema for a relation, and it is right not to — the form holds the whole related
|
|
34
|
+
* document, so an id would need a lookup the store does not do. The picker is where that lookup lives: it holds
|
|
35
|
+
* the slice list, the loader, and the label each option renders with. So the field reaches an agent from the one
|
|
36
|
+
* component that can resolve it, which is the rule every other control follows — the control is the declaration.
|
|
37
|
+
*
|
|
38
|
+
* Listing is its own tool because loading is its own step for a person too: the options arrive when the dropdown
|
|
39
|
+
* opens, and an agent never opens it. Folding the load into the setter would leave an agent guessing ids in order
|
|
40
|
+
* to learn them from the refusal.
|
|
41
|
+
*/
|
|
42
|
+
export const useRelationFieldTool = <T extends { id: string }>(
|
|
43
|
+
onChange: unknown,
|
|
44
|
+
{ read, load, label, disabled }: RelationFieldSource<T>,
|
|
45
|
+
) => {
|
|
46
|
+
const surface = useSurface();
|
|
47
|
+
const scope = useScopePath();
|
|
48
|
+
const action = actionTagOf(onChange)?.action ?? null;
|
|
49
|
+
const live = useRef({ onChange, read, load, label });
|
|
50
|
+
live.current = { onChange, read, load, label };
|
|
51
|
+
const scopeKey = scope.join(".");
|
|
52
|
+
useEffect(() => {
|
|
53
|
+
if (!action || disabled) return;
|
|
54
|
+
const ref = FormFields.ref(action);
|
|
55
|
+
const target = ref && relationOf(ref.field);
|
|
56
|
+
|
|
57
|
+
if (!ref || !target || FormFields.schema(ref.field)) return;
|
|
58
|
+
const many = ref.field.arrDepth > 0;
|
|
59
|
+
const nullable = !!ref.field.nullable && !many;
|
|
60
|
+
const listName = `load${capitalize(ref.key)}OptionsOn${capitalize(ref.refName)}`;
|
|
61
|
+
const argName = many ? `${ref.key}Ids` : `${ref.key}Id`;
|
|
62
|
+
const id: JsonSchema = { type: "string" };
|
|
63
|
+
const options = () => live.current.read().map((model) => ({ id: model.id, label: live.current.label(model) }));
|
|
64
|
+
const idsIn = (args: Record<string, unknown>): unknown => {
|
|
65
|
+
const value = args[argName];
|
|
66
|
+
if (nullable && (value === null || value === undefined)) return [];
|
|
67
|
+
return many ? value : [value];
|
|
68
|
+
};
|
|
69
|
+
const offList = surface.registerTool(scope, {
|
|
70
|
+
name: listName,
|
|
71
|
+
description: `List the ${target}s the ${ref.refName} form can pick for ${ref.key}, loading them first. Pass an id from it to ${action}.`,
|
|
72
|
+
settle: false,
|
|
73
|
+
run: async () => {
|
|
74
|
+
await live.current.load();
|
|
75
|
+
return options();
|
|
76
|
+
},
|
|
77
|
+
});
|
|
78
|
+
const offSet = surface.registerTool(scope, {
|
|
79
|
+
name: action,
|
|
80
|
+
description: `Set ${ref.key} on the ${ref.refName} form to ${many ? `${target}s` : `one ${target}`}, by id. Call ${listName} first for the ids.`,
|
|
81
|
+
parameters: {
|
|
82
|
+
type: "object",
|
|
83
|
+
properties: { [argName]: many ? { type: "array", items: id } : id },
|
|
84
|
+
...(nullable ? {} : { required: [argName] }),
|
|
85
|
+
additionalProperties: false,
|
|
86
|
+
},
|
|
87
|
+
guard: (args) => {
|
|
88
|
+
const ids = idsIn(args);
|
|
89
|
+
if (!Array.isArray(ids)) return `"${argName}" of ${action} must be an array of ids.`;
|
|
90
|
+
const list = live.current.read();
|
|
91
|
+
const missing = ids.filter((value) => typeof value !== "string" || !list.get(value));
|
|
92
|
+
if (!missing.length) return true;
|
|
93
|
+
if (!list.length) return `No ${target} is loaded yet. Call ${listName} first for the ids.`;
|
|
94
|
+
return `The ${ref.refName} form offers no ${target} ${missing.join(", ")}. It offers: ${list
|
|
95
|
+
.map((model) => `${model.id} (${live.current.label(model)})`)
|
|
96
|
+
.join(", ")}.`;
|
|
97
|
+
},
|
|
98
|
+
run: (args) => {
|
|
99
|
+
const list = live.current.read();
|
|
100
|
+
const setter = live.current.onChange as (value: unknown) => unknown;
|
|
101
|
+
const picked = (idsIn(args) as string[]).flatMap((value) => {
|
|
102
|
+
const model = list.get(value);
|
|
103
|
+
return model ? [model] : [];
|
|
104
|
+
});
|
|
105
|
+
return setter(many ? picked : (picked[0] ?? null));
|
|
106
|
+
},
|
|
107
|
+
});
|
|
108
|
+
return () => {
|
|
109
|
+
offList();
|
|
110
|
+
offSet();
|
|
111
|
+
};
|
|
112
|
+
}, [surface, scopeKey, action, disabled]);
|
|
113
|
+
};
|
package/store/baseSt.ts
CHANGED
|
@@ -33,7 +33,7 @@ export class BaseStore extends store("base" as const, () => ({
|
|
|
33
33
|
messages: [] as (typeof defaultMessage)[],
|
|
34
34
|
tryJwt: null as string | null,
|
|
35
35
|
trySignalType: "restapi" as SignalType,
|
|
36
|
-
|
|
36
|
+
tryGuards: [] as string[],
|
|
37
37
|
tryAccount: getDefaultAccount() as Account<{ [key: string]: string | undefined }>,
|
|
38
38
|
keyboardHeight: 0,
|
|
39
39
|
pageState: {
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { capitalize } from "akanjs/common";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* The state keys every model store holds, and which of the model's five classes each one is an instance of.
|
|
5
|
+
*
|
|
6
|
+
* Shared with the agent catalogue, which needs the class rather than the key: a value read out of the store is
|
|
7
|
+
* masked by the model it belongs to, and `immerify` drops the constructor, so the live value cannot say what it is.
|
|
8
|
+
* `modelForm` is the one that matters most — it is an `Input` holding whatever the user has typed, credentials
|
|
9
|
+
* included, and it reaches the catalogue as a plain object.
|
|
10
|
+
*/
|
|
11
|
+
export const databaseStateNames = (refName: string) => {
|
|
12
|
+
const className = capitalize(refName);
|
|
13
|
+
return {
|
|
14
|
+
model: refName,
|
|
15
|
+
modelLoading: `${refName}Loading`,
|
|
16
|
+
modelForm: `${refName}Form`,
|
|
17
|
+
modelFormLoading: `${refName}FormLoading`,
|
|
18
|
+
modelSubmit: `${refName}Submit`,
|
|
19
|
+
modelViewAt: `${refName}ViewAt`,
|
|
20
|
+
modelModal: `${refName}Modal`,
|
|
21
|
+
modelOperation: `${refName}Operation`,
|
|
22
|
+
defaultModel: `default${className}`,
|
|
23
|
+
};
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
/** Which of the model's classes each generated state key holds, for the keys that hold one at all. */
|
|
27
|
+
export const databaseStateModelTypes = {
|
|
28
|
+
model: "full",
|
|
29
|
+
modelForm: "input",
|
|
30
|
+
defaultModel: "full",
|
|
31
|
+
} as const satisfies { [key in keyof ReturnType<typeof databaseStateNames>]?: "full" | "input" | "light" | "insight" };
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { capitalize, lowerlize } from "akanjs/common";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* The keys `makeFormSetter` publishes for one field of one model.
|
|
5
|
+
*
|
|
6
|
+
* Computed forward from the field metadata rather than parsed back out of a key: `set(.+)On(.+)` has more than one
|
|
7
|
+
* reading whenever a field or a model name contains `On`, so any reader that has only the name must build the same
|
|
8
|
+
* names here instead of taking one apart.
|
|
9
|
+
*/
|
|
10
|
+
export const formSetterNames = (className: string, key: string) => {
|
|
11
|
+
const classKeyName = capitalize(key);
|
|
12
|
+
return {
|
|
13
|
+
field: lowerlize(key),
|
|
14
|
+
Field: classKeyName,
|
|
15
|
+
setFieldOnModel: `set${classKeyName}On${className}`,
|
|
16
|
+
addFieldOnModel: `add${classKeyName}On${className}`,
|
|
17
|
+
subFieldOnModel: `sub${classKeyName}On${className}`,
|
|
18
|
+
addOrSubFieldOnModel: `addOrSub${classKeyName}On${className}`,
|
|
19
|
+
/**
|
|
20
|
+
* The agent tool a drag-sortable list publishes. No store action answers to it: reordering *is* the whole-array
|
|
21
|
+
* write the drag already performs, so the tool splices the live rows and hands them to the same setter.
|
|
22
|
+
*/
|
|
23
|
+
moveFieldOnModel: `move${classKeyName}On${className}`,
|
|
24
|
+
uploadFieldOnModel: `upload${classKeyName}On${className}`,
|
|
25
|
+
/**
|
|
26
|
+
* The optional hook a store declares to run after this field is written.
|
|
27
|
+
*
|
|
28
|
+
* It carries no model suffix and a leading `_`, so it can never collide with a generated action name — which is
|
|
29
|
+
* the whole point: every generated action lives in a mapped type, and a mapped type produces *properties*, so a
|
|
30
|
+
* subclass method of the same name is a TS2425 error and there is no legal way to override one. A hook under a
|
|
31
|
+
* name the base type does not declare is the only shape TypeScript permits.
|
|
32
|
+
*/
|
|
33
|
+
postSetField: `_postSet${classKeyName}`,
|
|
34
|
+
};
|
|
35
|
+
};
|
package/store/index.ts
CHANGED
|
@@ -1,8 +1,16 @@
|
|
|
1
1
|
export * from "./action";
|
|
2
|
+
export * from "./actionTag";
|
|
3
|
+
export * from "./agent";
|
|
4
|
+
export * from "./agentic";
|
|
2
5
|
export * from "./baseSt";
|
|
6
|
+
export * from "./databaseStateNames";
|
|
7
|
+
export * from "./formSetterNames";
|
|
3
8
|
export * from "./rootStore";
|
|
9
|
+
export * from "./sliceRole";
|
|
4
10
|
export * from "./state";
|
|
5
11
|
export * from "./stateBuilder";
|
|
6
12
|
export * from "./store";
|
|
13
|
+
|
|
14
|
+
export { StoreInstance } from "./storeInstance";
|
|
7
15
|
export * from "./storeRegistry";
|
|
8
16
|
export * from "./types";
|
package/store/rootStore.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import type { ACTION_META, Cls, STATE_DERIVED_META, STATE_INIT_META, STATE_META } from "akanjs/base";
|
|
1
|
+
import type { ACTION_META, ACTION_OWNER_META, Cls, STATE_DERIVED_META, STATE_INIT_META, STATE_META } from "akanjs/base";
|
|
2
2
|
import type { SerializedSlice } from "akanjs/signal";
|
|
3
|
+
import type { ActionOwner } from "./actionTag";
|
|
3
4
|
import type { StateDerivedMeta, StateInitializerMap } from "./stateBuilder";
|
|
4
5
|
import type { SetGetWritable } from "./types";
|
|
5
6
|
|
|
@@ -20,6 +21,7 @@ export type RootStoreCls<
|
|
|
20
21
|
[STATE_INIT_META]: StateInitializerMap;
|
|
21
22
|
[STATE_DERIVED_META]: StateDerivedMeta;
|
|
22
23
|
[ACTION_META]: { [key: string]: (...args: any[]) => any };
|
|
24
|
+
[ACTION_OWNER_META]: { [key: string]: ActionOwner };
|
|
23
25
|
slice: { [key: string]: { [key: string]: SerializedSlice } };
|
|
24
26
|
_slice: SliceInfoObj;
|
|
25
27
|
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import type { SerializedArg } from "akanjs/signal";
|
|
2
|
+
import type { SliceStateKey } from "./state";
|
|
3
|
+
|
|
4
|
+
/** The generated slice actions, named by what they do rather than by the key any one slice publishes them under. */
|
|
5
|
+
export type SliceActionKey =
|
|
6
|
+
| "initModel"
|
|
7
|
+
| "refreshModel"
|
|
8
|
+
| "selectModel"
|
|
9
|
+
| "setPageOfModel"
|
|
10
|
+
| "addPageOfModel"
|
|
11
|
+
| "setLimitOfModel"
|
|
12
|
+
| "setQueryArgsOfModel"
|
|
13
|
+
| "setSortOfModel";
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* What a generated key on `st.do` / `st.use` actually is.
|
|
17
|
+
*
|
|
18
|
+
* A slice publishes its keys with the model and the suffix spliced into the role name — `setPageOfUserInOrg` for the
|
|
19
|
+
* `setPageOfModel` role of `user`'s `inOrg` slice — and the splicing is string replacement over capitalized names.
|
|
20
|
+
* Recording the role while the key is being built is what saves a reader of the finished store from running that
|
|
21
|
+
* replacement backwards, which does not have one answer: on a model named `page`, `setPageOfPage` is both the
|
|
22
|
+
* paging action and a field setter.
|
|
23
|
+
*/
|
|
24
|
+
export interface SliceActionRole {
|
|
25
|
+
role: SliceActionKey;
|
|
26
|
+
refName: string;
|
|
27
|
+
sliceName: string;
|
|
28
|
+
/** The slice's own arguments, which the `initModel` and `setQueryArgsOfModel` roles take positionally. */
|
|
29
|
+
args: SerializedArg[];
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export interface SliceStateRole {
|
|
33
|
+
role: SliceStateKey;
|
|
34
|
+
refName: string;
|
|
35
|
+
sliceName: string;
|
|
36
|
+
}
|
package/store/state.ts
CHANGED
|
@@ -14,6 +14,7 @@ import type {
|
|
|
14
14
|
SlceDbSort,
|
|
15
15
|
SliceCls,
|
|
16
16
|
} from "akanjs/signal";
|
|
17
|
+
import { databaseStateNames } from "./databaseStateNames";
|
|
17
18
|
import type { StoreSliceArgs, StoreSliceMap, StoreSliceSuffixCap, Submit } from "./types";
|
|
18
19
|
|
|
19
20
|
export type SliceStateKey =
|
|
@@ -151,18 +152,7 @@ export type DefaultState<
|
|
|
151
152
|
|
|
152
153
|
export const createDatabaseState = (refName: string) => {
|
|
153
154
|
const cnst = ConstantRegistry.getDatabase(refName);
|
|
154
|
-
const
|
|
155
|
-
const names = {
|
|
156
|
-
model: fieldName,
|
|
157
|
-
Model: className,
|
|
158
|
-
modelLoading: `${fieldName}Loading`,
|
|
159
|
-
modelForm: `${fieldName}Form`,
|
|
160
|
-
modelFormLoading: `${fieldName}FormLoading`,
|
|
161
|
-
modelSubmit: `${fieldName}Submit`,
|
|
162
|
-
modelViewAt: `${fieldName}ViewAt`,
|
|
163
|
-
modelModal: `${fieldName}Modal`,
|
|
164
|
-
modelOperation: `${fieldName}Operation`,
|
|
165
|
-
};
|
|
155
|
+
const names = databaseStateNames(refName);
|
|
166
156
|
const baseState = {
|
|
167
157
|
[names.model]: null,
|
|
168
158
|
[names.modelLoading]: true,
|
package/store/store.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
ACTION_META,
|
|
3
|
+
ACTION_OWNER_META,
|
|
3
4
|
type Cls,
|
|
4
5
|
type MergeAllActionTypes,
|
|
5
6
|
type MergeAllKeyOfObjects,
|
|
@@ -24,6 +25,7 @@ import type {
|
|
|
24
25
|
SliceCls,
|
|
25
26
|
} from "akanjs/signal";
|
|
26
27
|
import { type DefaultAction, makeActions, makeFormSetter } from "./action";
|
|
28
|
+
import type { ActionOwner } from "./actionTag";
|
|
27
29
|
import { createDatabaseState, createSliceState, type DefaultState } from "./state";
|
|
28
30
|
import {
|
|
29
31
|
createDerivedStateBuilder,
|
|
@@ -120,6 +122,7 @@ export type StoreCls<
|
|
|
120
122
|
[STATE_INIT_META]: StateInitializerMap;
|
|
121
123
|
[STATE_DERIVED_META]: StateDerivedMeta;
|
|
122
124
|
[ACTION_META]: { [key: string]: (...args: any[]) => any };
|
|
125
|
+
[ACTION_OWNER_META]: { [key: string]: ActionOwner };
|
|
123
126
|
slice: { [key: string]: SerializedSlice };
|
|
124
127
|
_slice: SlceCls[typeof SLICE_META];
|
|
125
128
|
}
|
|
@@ -187,6 +190,7 @@ export function store<Sig extends ClientSignal<any, any, any> | string, State>(
|
|
|
187
190
|
static [STATE_INIT_META] = {};
|
|
188
191
|
static [STATE_DERIVED_META] = createEmptyDerivedMeta();
|
|
189
192
|
static [ACTION_META] = {};
|
|
193
|
+
static [ACTION_OWNER_META] = {};
|
|
190
194
|
static slice = {};
|
|
191
195
|
} as StoreCls;
|
|
192
196
|
const writableStateRaw = stateFactory(createWritableStateBuilder());
|
|
@@ -204,6 +208,7 @@ export function store<Sig extends ClientSignal<any, any, any> | string, State>(
|
|
|
204
208
|
writable.meta,
|
|
205
209
|
);
|
|
206
210
|
Object.assign(storeCls[ACTION_META], ...libStores.map((libStore) => libStore[ACTION_META]));
|
|
211
|
+
Object.assign(storeCls[ACTION_OWNER_META], ...libStores.map((libStore) => libStore[ACTION_OWNER_META] ?? {}));
|
|
207
212
|
applyMixins(storeCls, libStores);
|
|
208
213
|
if (signal) {
|
|
209
214
|
const signalState = {
|
|
@@ -218,6 +223,10 @@ export function store<Sig extends ClientSignal<any, any, any> | string, State>(
|
|
|
218
223
|
};
|
|
219
224
|
Object.assign(storeCls.prototype, actions);
|
|
220
225
|
Object.assign(storeCls[ACTION_META], actions);
|
|
226
|
+
Object.assign(
|
|
227
|
+
storeCls[ACTION_OWNER_META],
|
|
228
|
+
Object.fromEntries(Object.keys(actions).map((key) => [key, { refName }])),
|
|
229
|
+
);
|
|
221
230
|
Object.assign(storeCls.slice, signal.serializedSignal.slice ?? {});
|
|
222
231
|
}
|
|
223
232
|
if (derivedStateFactory) {
|