akanjs 3.0.0-alpha.8 → 3.0.0-alpha.80
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/cookie.ts +21 -34
- package/client/csrTypes.ts +4 -15
- package/client/frameConfig.ts +13 -0
- 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 +287 -67
- package/common/TrustedProxy.ts +134 -0
- package/common/clamp.ts +2 -0
- package/common/clientAddress.ts +40 -0
- package/common/deepObjectify.ts +3 -2
- package/common/dynamicRecord.ts +12 -0
- package/common/index.ts +47 -2
- package/common/isValidDate.ts +1 -1
- package/common/logContext.ts +27 -0
- package/common/mcpExposure.ts +114 -0
- package/common/pathGetLoose.ts +31 -0
- package/common/plainFieldsOf.ts +13 -0
- package/common/requestOrigin.ts +32 -0
- package/common/{httpClient.ts → restClient.ts} +16 -9
- package/common/routeConvention.ts +22 -12
- package/common/websocketBinaryFrame.ts +46 -0
- package/constant/crystalize.ts +92 -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 +41 -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 +85 -0
- package/dictionary/dictInfo.ts +11 -2
- package/dictionary/dictionary.ts +9 -3
- package/dictionary/index.ts +1 -0
- package/dictionary/trans.ts +26 -7
- package/document/dataLoader.ts +0 -4
- package/document/documentQuery.ts +1 -0
- package/document/filterMeta.ts +79 -14
- package/document/index.ts +1 -0
- package/document/loaderInfo.ts +4 -1
- package/document/noDocumentError.ts +12 -0
- package/document/types.ts +0 -1
- package/fetch/agentTurn.ts +19 -0
- package/fetch/client/fetchClient.ts +166 -89
- package/fetch/client/fetchHandle.ts +57 -0
- package/fetch/client/httpClient.ts +140 -30
- package/fetch/client/sliceInitHandle.ts +101 -0
- package/fetch/client/wsClient.ts +27 -12
- package/fetch/fetchType/appliedReturn.type.ts +126 -42
- package/fetch/fetchType/endpointFetch.type.ts +17 -8
- package/fetch/fetchType/sliceFetch.type.ts +30 -53
- package/fetch/index.ts +1 -0
- package/fetch/requestStorage.ts +19 -5
- package/index.ts +132 -8
- 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 +325 -157
- package/server/akanAppHeaders.ts +23 -3
- package/server/akanOption.ts +76 -8
- package/server/akanServer.ts +390 -32
- package/server/animatedImage.ts +83 -0
- package/server/assetEncoding.ts +4 -24
- package/server/binaryPubsub.ts +55 -0
- package/server/cachePolicy.ts +2 -11
- 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/decorators.ts +12 -3
- package/server/devtools/constantSerializer.ts +8 -1
- package/server/devtools/signalSerializer.ts +2 -2
- package/server/devtools/types.ts +4 -4
- package/server/di/diLifecycle.ts +144 -14
- package/server/di/predefinedAdaptor.ts +6 -0
- package/server/di/resolveHierarchy.ts +3 -3
- package/server/di/utils.ts +40 -0
- package/server/hmr/clientScript.ts +1 -1
- package/server/imageOptimizer.ts +156 -74
- package/server/lifecycle/runtimeDir.ts +14 -0
- package/server/lifecycle/shutdownManager.ts +17 -2
- 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 +295 -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 +18 -12
- package/server/resolver/signal.resolver.ts +211 -89
- package/server/routeTreeBuilder.ts +11 -23
- package/server/routing/apiRouter.ts +45 -16
- package/server/routing/appWsData.ts +30 -5
- package/server/routing/eventStream.ts +93 -0
- package/server/routing/soloAppRoutes.ts +50 -0
- package/server/rscWorker.tsx +63 -22
- package/server/rscWorkerHost.ts +59 -8
- package/server/semaphore.ts +22 -0
- package/server/ssrFromRscRenderer.tsx +50 -0
- package/server/staticPath.ts +34 -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 +130 -73
- package/service/adapt.ts +5 -9
- 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/cache.adaptor.ts +8 -4
- package/service/predefinedAdaptor/compress.adaptor.ts +5 -1
- package/service/predefinedAdaptor/database.adaptor.ts +59 -1757
- 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/sql/PendingStoreEnsures.ts +22 -0
- package/service/predefinedAdaptor/sql/QueryCompiler.ts +225 -0
- package/service/predefinedAdaptor/sql/SqlDocumentStore.ts +812 -0
- package/service/predefinedAdaptor/sql/UpdateCompiler.ts +67 -0
- package/service/predefinedAdaptor/sql/dialect/postgres.ts +151 -0
- package/service/predefinedAdaptor/sql/dialect/sqlite.ts +134 -0
- package/service/predefinedAdaptor/sql/driver/bunSqlite.ts +29 -0
- package/service/predefinedAdaptor/sql/driver/libsql.ts +37 -0
- package/service/predefinedAdaptor/sql/driver/postgres.ts +42 -0
- package/service/predefinedAdaptor/sql/types.ts +251 -0
- package/service/predefinedAdaptor/sql/values.ts +91 -0
- package/service/predefinedAdaptor/websocket.adaptor.ts +6 -1
- package/service/serve.ts +16 -9
- package/service/toolNames.ts +119 -0
- package/signal/CrossSiteGuard.ts +71 -0
- package/signal/SignalFailure.ts +51 -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/endpoint.ts +2 -2
- package/signal/endpointInfo.ts +38 -2
- package/signal/exception.ts +43 -6
- package/signal/guard.ts +28 -1
- package/signal/guards.ts +49 -1
- package/signal/index.ts +8 -0
- package/signal/intercept.ts +9 -6
- package/signal/internal.ts +10 -2
- 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 +62 -1
- package/signal/signalContext.ts +339 -94
- package/signal/slice.ts +63 -28
- package/signal/trace.ts +268 -9
- package/signal/types.ts +55 -4
- package/store/SliceRequest.ts +23 -0
- package/store/action.ts +210 -154
- package/store/actionTag.ts +33 -0
- package/store/agent/AgentBridge.ts +89 -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 +50 -0
- package/store/agentic/StExposeDraft.ts +24 -0
- package/store/agentic/StStateBuilder.ts +90 -0
- package/store/agentic/StStateDraft.ts +23 -0
- package/store/agentic/StToolBuilder.ts +293 -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 +10 -1
- package/store/storeInstance.ts +185 -22
- package/store/storeRegistry.ts +40 -2
- 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/cookie.d.ts +13 -2
- package/types/client/csrTypes.d.ts +0 -1
- package/types/client/frameConfig.d.ts +1 -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/TrustedProxy.d.ts +24 -0
- package/types/common/clamp.d.ts +2 -0
- package/types/common/clientAddress.d.ts +19 -0
- package/types/common/dynamicRecord.d.ts +14 -0
- package/types/common/index.d.ts +13 -3
- 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/requestOrigin.d.ts +14 -0
- package/types/common/restClient.d.ts +27 -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 +18 -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/dataLoader.d.ts +0 -3
- package/types/document/filterMeta.d.ts +26 -6
- package/types/document/index.d.ts +1 -0
- package/types/document/loaderInfo.d.ts +2 -2
- 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/fetchHandle.d.ts +24 -0
- package/types/fetch/client/httpClient.d.ts +10 -4
- package/types/fetch/client/sliceInitHandle.d.ts +29 -0
- package/types/fetch/fetchType/appliedReturn.type.d.ts +71 -15
- package/types/fetch/fetchType/endpointFetch.type.d.ts +8 -5
- package/types/fetch/fetchType/sliceFetch.type.d.ts +14 -18
- package/types/fetch/index.d.ts +1 -0
- package/types/fetch/requestStorage.d.ts +14 -0
- package/types/index.d.ts +124 -12
- package/types/server/akanApp.d.ts +12 -0
- package/types/server/akanAppHeaders.d.ts +7 -1
- package/types/server/akanOption.d.ts +43 -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/decorators.d.ts +12 -2
- package/types/server/devtools/types.d.ts +4 -4
- package/types/server/di/diLifecycle.d.ts +19 -3
- 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/lifecycle/shutdownManager.d.ts +2 -1
- 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/routeTreeBuilder.d.ts +1 -2
- package/types/server/routing/apiRouter.d.ts +2 -1
- package/types/server/routing/appWsData.d.ts +19 -3
- 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/ssrFromRscRenderer.d.ts +14 -0
- package/types/server/staticPath.d.ts +17 -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 +3 -3
- 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 +16 -402
- 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/predefinedAdaptor/sql/PendingStoreEnsures.d.ts +6 -0
- package/types/service/predefinedAdaptor/sql/QueryCompiler.d.ts +28 -0
- package/types/service/predefinedAdaptor/sql/SqlDocumentStore.d.ts +127 -0
- package/types/service/predefinedAdaptor/sql/UpdateCompiler.d.ts +17 -0
- package/types/service/predefinedAdaptor/sql/dialect/postgres.d.ts +27 -0
- package/types/service/predefinedAdaptor/sql/dialect/sqlite.d.ts +27 -0
- package/types/service/predefinedAdaptor/sql/driver/bunSqlite.d.ts +16 -0
- package/types/service/predefinedAdaptor/sql/driver/libsql.d.ts +17 -0
- package/types/service/predefinedAdaptor/sql/driver/postgres.d.ts +17 -0
- package/types/service/predefinedAdaptor/sql/types.d.ts +226 -0
- package/types/service/predefinedAdaptor/sql/values.d.ts +13 -0
- package/types/service/serve.d.ts +3 -3
- package/types/service/toolNames.d.ts +35 -0
- package/types/signal/CrossSiteGuard.d.ts +44 -0
- package/types/signal/SignalFailure.d.ts +28 -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/exception.d.ts +38 -54774
- package/types/signal/guard.d.ts +12 -0
- package/types/signal/guards.d.ts +23 -1
- package/types/signal/index.d.ts +8 -0
- package/types/signal/intercept.d.ts +5 -5
- package/types/signal/internal.d.ts +5 -1
- 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/serializer/fetch.serializer.d.ts +7 -1
- 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/SliceRequest.d.ts +16 -0
- 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 +65 -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/Choice.d.ts +52 -0
- package/types/ui/Field/Collection.d.ts +51 -0
- package/types/ui/Field/DateField.d.ts +32 -0
- package/types/ui/Field/Label.d.ts +9 -0
- package/types/ui/Field/NumberField.d.ts +43 -0
- package/types/ui/Field/Relation.d.ts +80 -0
- package/types/ui/Field/Text.d.ts +101 -0
- package/types/ui/Field/index.d.ts +50 -0
- package/types/ui/Field.d.ts +1 -411
- package/types/ui/Layout/BottomTab.d.ts +3 -2
- package/types/ui/LegacyModal.d.ts +24 -0
- package/types/ui/Load/Edit_Client.d.ts +3 -1
- package/types/ui/Load/Stream.d.ts +22 -0
- package/types/ui/Load/index.d.ts +2 -0
- package/types/ui/Loading/ProgressBar.d.ts +4 -0
- package/types/ui/Loading/Spin.d.ts +2 -1
- package/types/ui/Loading/index_.d.ts +13 -0
- 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/System/Root.d.ts +4 -0
- 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/useCamera.d.ts +10 -1
- package/types/webkit/usePageTool.d.ts +19 -0
- package/types/webkit/usePurchase.d.ts +4 -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 +10 -6
- package/ui/Dropdown.tsx +89 -27
- package/ui/Empty.tsx +6 -4
- package/ui/Field/Choice.tsx +172 -0
- package/ui/Field/Collection.tsx +293 -0
- package/ui/Field/DateField.tsx +138 -0
- package/ui/Field/Label.tsx +31 -0
- package/ui/Field/NumberField.tsx +169 -0
- package/ui/Field/Relation.tsx +387 -0
- package/ui/Field/Text.tsx +360 -0
- package/ui/Field/index.tsx +70 -0
- package/ui/Input.tsx +30 -8
- 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/Edit.tsx +2 -2
- package/ui/Load/Edit_Client.tsx +11 -3
- package/ui/Load/Pagination.tsx +35 -28
- package/ui/Load/Stream.tsx +38 -0
- package/ui/Load/Units.tsx +76 -40
- package/ui/Load/View.tsx +34 -19
- package/ui/Load/index.ts +2 -0
- 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/Loading/index.ts +15 -0
- package/ui/Loading/index_.tsx +22 -0
- package/ui/Menu.tsx +1 -1
- package/ui/Model/AdminPanel.tsx +52 -12
- package/ui/Model/EditModal.tsx +35 -13
- 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 +94 -142
- package/ui/Signal/Object.tsx +79 -57
- package/ui/Signal/PubSub.tsx +76 -114
- 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 -17
- package/ui/System/Common.tsx +3 -4
- package/ui/System/DevModeToggle.tsx +1 -1
- package/ui/System/Gtag.tsx +3 -3
- package/ui/System/Messages.tsx +52 -31
- package/ui/System/Reconnect.tsx +22 -56
- package/ui/System/Root.tsx +4 -0
- 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 +103 -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/useCamera.tsx +22 -6
- package/webkit/useCodepush.tsx +2 -2
- package/webkit/useCsrValues.ts +1 -3
- package/webkit/useFetch.ts +4 -3
- package/webkit/useFrameRuntime.ts +15 -8
- package/webkit/usePageTool.tsx +37 -0
- package/webkit/usePurchase.tsx +4 -1
- package/webkit/useScreenScope.tsx +60 -0
- package/fetch/serializer/fetch.serializer.ts +0 -142
- package/fetch/serializer/index.ts +0 -1
- package/types/common/httpClient.d.ts +0 -20
- package/types/fetch/serializer/fetch.serializer.d.ts +0 -14
- package/types/fetch/serializer/index.d.ts +0 -1
- package/types/fetch/serializer.d.ts +0 -1
- 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/Field.tsx +0 -1569
- package/ui/Loading/index.tsx +0 -22
- package/ui/Signal/Collapse.tsx +0 -29
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { type Dayjs, dayjs } from "akanjs/base";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* A Date field stores a native `Date` under a per-key symbol and builds the `Dayjs` its type promises on first
|
|
5
|
+
* read, memoized by that `Date`. A dayjs instance is ~300 bytes and eight getter calls at construction; a `Date`
|
|
6
|
+
* is 40 bytes. A listing carries every row's dates and reads a handful of them, so this is most of what a
|
|
7
|
+
* hydrated list used to cost — see `crystalize`.
|
|
8
|
+
*
|
|
9
|
+
* The slot is a function of the key, not the class (`Symbol.for`): `applyMixins` copies a light model's accessors
|
|
10
|
+
* onto the full model's prototype, so an accessor and the `set()` that fills its slot must agree on the slot
|
|
11
|
+
* whichever class defined either one.
|
|
12
|
+
*/
|
|
13
|
+
const slotByKey = new Map<string, symbol>();
|
|
14
|
+
export const dateSlotOf = (key: string): symbol => {
|
|
15
|
+
const cached = slotByKey.get(key);
|
|
16
|
+
if (cached) return cached;
|
|
17
|
+
const slot = Symbol.for(`akan.date.${key}`);
|
|
18
|
+
slotByKey.set(key, slot);
|
|
19
|
+
return slot;
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
const dayjsByDate = new WeakMap<Date, Dayjs>();
|
|
23
|
+
const lazyDayjsOf = (date: Date): Dayjs => {
|
|
24
|
+
const cached = dayjsByDate.get(date);
|
|
25
|
+
if (cached) return cached;
|
|
26
|
+
const value = dayjs(date);
|
|
27
|
+
dayjsByDate.set(date, value);
|
|
28
|
+
return value;
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
/** A caller's own `Date` is copied: the slot must not alias an object the caller can still mutate. */
|
|
32
|
+
export const toDateValue = (value: unknown): Date | null | undefined => {
|
|
33
|
+
if (value === null || value === undefined) return value;
|
|
34
|
+
if (value instanceof Date) return new Date(value.getTime());
|
|
35
|
+
if (dayjs.isDayjs(value)) return value.toDate();
|
|
36
|
+
return new Date(value as string | number);
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
type DateSlotHolder = Record<symbol, Date | null | undefined>;
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* Enumerable so `for...in` — `plainFieldsOf`, `immerify`, `deepObjectify` — still sees the field. immer calls a
|
|
43
|
+
* prototype setter with the draft as `this`, so a write through the accessor stays copy-on-write, and the getter
|
|
44
|
+
* writes nothing, so a read never marks a draft modified.
|
|
45
|
+
*/
|
|
46
|
+
export const dateAccessorOf = (key: string): PropertyDescriptor => {
|
|
47
|
+
const slot = dateSlotOf(key);
|
|
48
|
+
return {
|
|
49
|
+
enumerable: true,
|
|
50
|
+
configurable: true,
|
|
51
|
+
get(this: DateSlotHolder) {
|
|
52
|
+
const date = this[slot];
|
|
53
|
+
return date === null || date === undefined ? date : lazyDayjsOf(date);
|
|
54
|
+
},
|
|
55
|
+
set(this: DateSlotHolder, value: unknown) {
|
|
56
|
+
this[slot] = toDateValue(value);
|
|
57
|
+
},
|
|
58
|
+
};
|
|
59
|
+
};
|
|
60
|
+
|
|
61
|
+
export const isDateSlotField = (props: { modelRef: unknown; isArray: boolean; isMap: boolean }): boolean =>
|
|
62
|
+
props.modelRef === Date && !props.isArray && !props.isMap;
|
package/constant/deserialize.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Any, applyFnToArrayObjects, type Cls, FIELD_META, PrimitiveRegistry, type PrimitiveScalar } from "akanjs/base";
|
|
2
2
|
|
|
3
|
-
import { type ConstantCls, type ConstantModelRef, ConstantRegistry, type FieldProps } from ".";
|
|
3
|
+
import { type ConstantCls, type ConstantModelRef, ConstantRegistry, type FieldProps, withSharedInstances } from ".";
|
|
4
4
|
|
|
5
5
|
const getDeserializeFn = (inputRef: ConstantModelRef | PrimitiveScalar) => {
|
|
6
6
|
const deserializeFn = PrimitiveRegistry.has(inputRef as Cls)
|
|
@@ -66,5 +66,6 @@ export const deserialize = (
|
|
|
66
66
|
if (nullable && (value === null || value === undefined)) return null;
|
|
67
67
|
else if (!nullable && (value === null || value === undefined) && argRef !== Any)
|
|
68
68
|
throw new Error(`Invalid Value (Nullable) in ${key} ${argRef} for value ${value}`);
|
|
69
|
-
|
|
69
|
+
|
|
70
|
+
return withSharedInstances(() => deserializeInput(value, argRef, arrDepth, convertFn)) as object[];
|
|
70
71
|
};
|
package/constant/fieldInfo.ts
CHANGED
|
@@ -106,6 +106,13 @@ export interface ConstantFieldProps<
|
|
|
106
106
|
validate?: (value: FieldValue, model: any) => boolean;
|
|
107
107
|
text?: TextFieldRole;
|
|
108
108
|
cascade?: CascadeAction;
|
|
109
|
+
/**
|
|
110
|
+
* Renders on the page, never reaches an agent. Stripped wherever a value is masked for an AI caller — the
|
|
111
|
+
* in-page agent's reads and every MCP result — and left untouched everywhere else, so a `File`'s blur
|
|
112
|
+
* placeholder still ships to `<Image>`. Unlike `hidden`/`secret` this is about cost, not secrecy: a field
|
|
113
|
+
* nothing can answer a question with is pure spend on every turn it rides.
|
|
114
|
+
*/
|
|
115
|
+
visual?: boolean;
|
|
109
116
|
meta?: Metadata;
|
|
110
117
|
}
|
|
111
118
|
export const fieldPresets = ["email", "password", "url"] as const;
|
|
@@ -197,6 +204,7 @@ interface ConstantFieldBuildProps<
|
|
|
197
204
|
validate?: (value: FieldValue, model: any) => boolean;
|
|
198
205
|
text?: TextFieldRole;
|
|
199
206
|
cascade?: CascadeAction;
|
|
207
|
+
visual: boolean;
|
|
200
208
|
modelRef: ConstantModelRef;
|
|
201
209
|
arrDepth: number;
|
|
202
210
|
optArrDepth: number;
|
|
@@ -321,6 +329,7 @@ export class ConstantField<
|
|
|
321
329
|
readonly validate?: (value: FieldValue, model: any) => boolean;
|
|
322
330
|
readonly text?: TextFieldRole;
|
|
323
331
|
readonly cascade?: CascadeAction;
|
|
332
|
+
readonly visual: boolean;
|
|
324
333
|
readonly modelRef: ConstantModelRef;
|
|
325
334
|
readonly arrDepth: number;
|
|
326
335
|
readonly optArrDepth: number;
|
|
@@ -353,6 +362,7 @@ export class ConstantField<
|
|
|
353
362
|
this.validate = props.validate;
|
|
354
363
|
this.text = props.text;
|
|
355
364
|
this.cascade = props.cascade;
|
|
365
|
+
this.visual = props.visual;
|
|
356
366
|
this.modelRef = props.modelRef;
|
|
357
367
|
this.arrDepth = props.arrDepth;
|
|
358
368
|
this.optArrDepth = props.optArrDepth;
|
|
@@ -432,6 +442,7 @@ export class ConstantField<
|
|
|
432
442
|
validate: option.validate,
|
|
433
443
|
text: option.text,
|
|
434
444
|
cascade: option.cascade,
|
|
445
|
+
visual: option.visual ?? false,
|
|
435
446
|
modelRef,
|
|
436
447
|
arrDepth: arrDepth,
|
|
437
448
|
optArrDepth: optArrDepth,
|
|
@@ -478,6 +489,7 @@ export class ConstantField<
|
|
|
478
489
|
validate: this.validate,
|
|
479
490
|
text: this.text,
|
|
480
491
|
cascade: this.cascade,
|
|
492
|
+
visual: this.visual,
|
|
481
493
|
modelRef: this.modelRef,
|
|
482
494
|
arrDepth: this.arrDepth,
|
|
483
495
|
optArrDepth: this.optArrDepth,
|
|
@@ -493,6 +505,14 @@ export interface FieldObject {
|
|
|
493
505
|
[key: string]: ConstantField;
|
|
494
506
|
}
|
|
495
507
|
|
|
508
|
+
/**
|
|
509
|
+
* `text` names a column in the plaintext search mirror, so a masked field carrying one would publish what it
|
|
510
|
+
* masks through search — the class build refuses it (`TextFieldPaths`). Removing the key from the option type
|
|
511
|
+
* moves that refusal to the call site, where the fix is obvious. Distributive because `FieldOption` is a union:
|
|
512
|
+
* a plain `Omit` over it would collapse to the keys the members share.
|
|
513
|
+
*/
|
|
514
|
+
type WithoutTextRole<Option> = Option extends unknown ? Omit<Option, "text"> : never;
|
|
515
|
+
|
|
496
516
|
type FieldOption<
|
|
497
517
|
Value extends ConstantFieldTypeInput,
|
|
498
518
|
MapValue = Value extends MapConstructor ? typeof PrimitiveScalar : never,
|
|
@@ -530,13 +550,33 @@ export const field = <
|
|
|
530
550
|
fieldType: "property",
|
|
531
551
|
});
|
|
532
552
|
|
|
533
|
-
|
|
553
|
+
/**
|
|
554
|
+
* A stored property the page renders and an agent never sees — `field(value, { visual: true })`, spelled short
|
|
555
|
+
* because the reason to reach for it is always the same one. A blur placeholder, a rendered HTML body, a
|
|
556
|
+
* serialized geometry: real data the screen needs, and hundreds of tokens per record that no question is answered
|
|
557
|
+
* from. It stays a plain `property` everywhere else, so persistence, search, forms and the page response are
|
|
558
|
+
* untouched.
|
|
559
|
+
*/
|
|
560
|
+
field.visual = <
|
|
534
561
|
ExplicitType,
|
|
535
562
|
Value extends ConstantFieldTypeInput = PlainTypeToFieldType<ExplicitType>,
|
|
536
563
|
MapValue = Value extends MapConstructor ? typeof PrimitiveScalar : never,
|
|
537
564
|
>(
|
|
538
565
|
value: Value,
|
|
539
566
|
option: FieldOption<Value, MapValue> = {},
|
|
567
|
+
) =>
|
|
568
|
+
new FieldInfo<"property", Value, ExplicitType, MapValue>(value, {
|
|
569
|
+
...option,
|
|
570
|
+
fieldType: "property",
|
|
571
|
+
visual: true,
|
|
572
|
+
});
|
|
573
|
+
field.hidden = <
|
|
574
|
+
ExplicitType,
|
|
575
|
+
Value extends ConstantFieldTypeInput = PlainTypeToFieldType<ExplicitType>,
|
|
576
|
+
MapValue = Value extends MapConstructor ? typeof PrimitiveScalar : never,
|
|
577
|
+
>(
|
|
578
|
+
value: Value,
|
|
579
|
+
option: WithoutTextRole<FieldOption<Value, MapValue>> = {},
|
|
540
580
|
) =>
|
|
541
581
|
new FieldInfo<"hidden", Value, ExplicitType, MapValue>(value, {
|
|
542
582
|
...option,
|
|
@@ -549,7 +589,7 @@ field.secret = <
|
|
|
549
589
|
MapValue = Value extends MapConstructor ? typeof PrimitiveScalar : never,
|
|
550
590
|
>(
|
|
551
591
|
value: Value,
|
|
552
|
-
option: FieldOption<Value, MapValue
|
|
592
|
+
option: WithoutTextRole<FieldOption<Value, MapValue>> = {},
|
|
553
593
|
) =>
|
|
554
594
|
new FieldInfo<"secret", Value | null, ExplicitType | null, MapValue>(value, {
|
|
555
595
|
...option,
|
|
@@ -564,7 +604,7 @@ export const resolve = <
|
|
|
564
604
|
MapValue = Value extends MapConstructor ? typeof PrimitiveScalar : never,
|
|
565
605
|
>(
|
|
566
606
|
value: Value,
|
|
567
|
-
option: FieldOption<Value, MapValue
|
|
607
|
+
option: WithoutTextRole<FieldOption<Value, MapValue>> = {},
|
|
568
608
|
) =>
|
|
569
609
|
new FieldInfo<"resolve", Value, ExplicitType, MapValue>(value, {
|
|
570
610
|
...option,
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { FIELD_META } from "akanjs/base";
|
|
2
|
+
import { ConstantRegistry } from "./constantRegistry";
|
|
3
|
+
import type { FieldObject } from "./fieldInfo";
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* The query a field's value stands for, declared on the field itself with `.meta(...)`. A summary counter is the
|
|
7
|
+
* case this exists for: `hau` is however many rows one filter returns, so the tile showing it can open that exact
|
|
8
|
+
* listing without the page restating the filter beside it.
|
|
9
|
+
*
|
|
10
|
+
* The shape is read structurally rather than by class, so an app declares it with whatever builder it already has.
|
|
11
|
+
*/
|
|
12
|
+
export interface FieldQueryMeta {
|
|
13
|
+
/** The model the query runs against. */
|
|
14
|
+
refName: string;
|
|
15
|
+
/** One of that model's declared filter keys. */
|
|
16
|
+
queryKey: string | null;
|
|
17
|
+
/** Read when the query is applied, so an arg relative to now — `() => [dayjs().subtract(1, "hour")]` — is current. */
|
|
18
|
+
queryArgs?: unknown[] | (() => unknown[]);
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
const isFieldQueryMeta = (meta: unknown): meta is FieldQueryMeta => {
|
|
22
|
+
if (!meta || typeof meta !== "object") return false;
|
|
23
|
+
const { refName, queryKey, queryArgs } = meta as Record<string, unknown>;
|
|
24
|
+
if (typeof refName !== "string" || !refName) return false;
|
|
25
|
+
if (queryKey !== null && typeof queryKey !== "string") return false;
|
|
26
|
+
return queryArgs === undefined || Array.isArray(queryArgs) || typeof queryArgs === "function";
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
/** The query one field of `refName` names, or nothing when the model, the field, or the declaration is absent. */
|
|
30
|
+
export const fieldQueryMetaOf = (refName: string, field: string): FieldQueryMeta | undefined => {
|
|
31
|
+
const cnst = ConstantRegistry.getDatabase(refName, { allowEmpty: true });
|
|
32
|
+
const fieldMap = cnst?.full[FIELD_META] as FieldObject | undefined;
|
|
33
|
+
const meta = fieldMap?.[field]?.meta;
|
|
34
|
+
return isFieldQueryMeta(meta) ? meta : undefined;
|
|
35
|
+
};
|
package/constant/getDefault.ts
CHANGED
|
@@ -2,11 +2,11 @@ import { DEFAULT_VALUE, FIELD_META, type PrimitiveScalar } from "akanjs/base";
|
|
|
2
2
|
import type { FieldObject } from ".";
|
|
3
3
|
import type { DefaultOf } from "./types";
|
|
4
4
|
|
|
5
|
-
interface DefaultPlan {
|
|
5
|
+
export interface DefaultPlan {
|
|
6
6
|
/** Fields whose default is a value that can be shared: a primitive, `null`, or the field's own literal. */
|
|
7
7
|
shared: Record<string, unknown>;
|
|
8
8
|
/** Fields that have to be produced per call — a thunk, a fresh array, or a nested scalar record. */
|
|
9
|
-
perCall:
|
|
9
|
+
perCall: Map<string, () => unknown>;
|
|
10
10
|
}
|
|
11
11
|
|
|
12
12
|
const planCache = new WeakMap<FieldObject, DefaultPlan>();
|
|
@@ -17,28 +17,33 @@ const planCache = new WeakMap<FieldObject, DefaultPlan>();
|
|
|
17
17
|
* sharing one. Only values that were already shared before this cache existed live in `shared`.
|
|
18
18
|
*/
|
|
19
19
|
export const getDefault = <T>(fieldObj: FieldObject): DefaultOf<T> => {
|
|
20
|
-
|
|
21
|
-
if (!plan) {
|
|
22
|
-
plan = buildPlan(fieldObj);
|
|
23
|
-
planCache.set(fieldObj, plan);
|
|
24
|
-
}
|
|
20
|
+
const plan = defaultPlanOf(fieldObj);
|
|
25
21
|
const result: Record<string, unknown> = { ...plan.shared };
|
|
26
22
|
for (const [key, make] of plan.perCall) result[key] = make();
|
|
27
23
|
return result as DefaultOf<T>;
|
|
28
24
|
};
|
|
29
25
|
|
|
26
|
+
/** The per-field default rules, split as above; `HydrationPlan` reads them per field so a present value skips its thunk. */
|
|
27
|
+
export const defaultPlanOf = (fieldObj: FieldObject): DefaultPlan => {
|
|
28
|
+
const cached = planCache.get(fieldObj);
|
|
29
|
+
if (cached) return cached;
|
|
30
|
+
const plan = buildPlan(fieldObj);
|
|
31
|
+
planCache.set(fieldObj, plan);
|
|
32
|
+
return plan;
|
|
33
|
+
};
|
|
34
|
+
|
|
30
35
|
const buildPlan = (fieldObj: FieldObject): DefaultPlan => {
|
|
31
36
|
const shared: Record<string, unknown> = {};
|
|
32
|
-
const perCall
|
|
37
|
+
const perCall = new Map<string, () => unknown>();
|
|
33
38
|
for (const [key, field] of Object.entries(fieldObj)) {
|
|
34
39
|
if (field.fieldType === "hidden" || field.fieldType === "secret") shared[key] = null;
|
|
35
40
|
else if (field.default !== undefined && field.default !== null) {
|
|
36
|
-
if (typeof field.default === "function") perCall.
|
|
41
|
+
if (typeof field.default === "function") perCall.set(key, field.default as () => unknown);
|
|
37
42
|
else shared[key] = field.default as object;
|
|
38
|
-
} else if (field.isArray) perCall.
|
|
43
|
+
} else if (field.isArray) perCall.set(key, () => []);
|
|
39
44
|
else if (field.nullable) shared[key] = null;
|
|
40
45
|
else if (field.isClass) {
|
|
41
|
-
if (field.isScalar) perCall.
|
|
46
|
+
if (field.isScalar) perCall.set(key, () => getDefault(field.modelRef[FIELD_META]));
|
|
42
47
|
else shared[key] = null;
|
|
43
48
|
} else shared[key] = (field.modelRef as unknown as typeof PrimitiveScalar)[DEFAULT_VALUE];
|
|
44
49
|
}
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import { FIELD_META } from "akanjs/base";
|
|
2
|
+
|
|
3
|
+
import { type Converter, converterOf } from "./crystalize";
|
|
4
|
+
import { dateSlotOf, isDateSlotField, toDateValue } from "./dateSlot";
|
|
5
|
+
import type { FieldObject } from "./fieldInfo";
|
|
6
|
+
import { defaultPlanOf } from "./getDefault";
|
|
7
|
+
|
|
8
|
+
interface PlanEntry {
|
|
9
|
+
key: string;
|
|
10
|
+
/** The own property the value lands on: the key itself, or a Date field's slot symbol. */
|
|
11
|
+
target: string | symbol;
|
|
12
|
+
convert: Converter;
|
|
13
|
+
makeDefault: () => unknown;
|
|
14
|
+
}
|
|
15
|
+
type PlanTarget = Record<string | symbol, unknown>;
|
|
16
|
+
interface PlanOwner {
|
|
17
|
+
[FIELD_META]: FieldObject;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* One hydration plan per model class, compiled from `FIELD_META` on the first instance. Reading the field map,
|
|
22
|
+
* resolving `getProps()` and dispatching on the field kind used to happen per field per instance, and was most of
|
|
23
|
+
* what a listing paid after the dayjs objects — a plan turns a row into a plain loop over precomputed converters.
|
|
24
|
+
*
|
|
25
|
+
* Cached per class rather than per field map because `fullModelOf` extends a lib model's `FIELD_META` in place;
|
|
26
|
+
* `applyConstantStatics` resets the entry whenever it finishes wiring a class.
|
|
27
|
+
*/
|
|
28
|
+
export class HydrationPlan {
|
|
29
|
+
static #byClass = new WeakMap<object, HydrationPlan>();
|
|
30
|
+
static of(cls: PlanOwner): HydrationPlan {
|
|
31
|
+
const cached = HydrationPlan.#byClass.get(cls);
|
|
32
|
+
if (cached) return cached;
|
|
33
|
+
const plan = new HydrationPlan(cls[FIELD_META]);
|
|
34
|
+
HydrationPlan.#byClass.set(cls, plan);
|
|
35
|
+
return plan;
|
|
36
|
+
}
|
|
37
|
+
static reset(cls: object) {
|
|
38
|
+
HydrationPlan.#byClass.delete(cls);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
#entries: PlanEntry[];
|
|
42
|
+
constructor(fieldObj: FieldObject) {
|
|
43
|
+
const defaults = defaultPlanOf(fieldObj);
|
|
44
|
+
this.#entries = Object.entries(fieldObj).map(([key, field]) => {
|
|
45
|
+
const props = field.getProps();
|
|
46
|
+
const isDateSlot = isDateSlotField(props);
|
|
47
|
+
const convert: Converter = isDateSlot ? toDateValue : converterOf(props);
|
|
48
|
+
const perCall = defaults.perCall.get(key);
|
|
49
|
+
const rawDefault = perCall ?? (() => defaults.shared[key]);
|
|
50
|
+
|
|
51
|
+
return { key, target: isDateSlot ? dateSlotOf(key) : key, convert, makeDefault: () => convert(rawDefault()) };
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
/** Fills every field: the value when the source carries one, the field's default otherwise. */
|
|
56
|
+
construct(instance: object, source?: Record<string, unknown> | null) {
|
|
57
|
+
const target = instance as PlanTarget;
|
|
58
|
+
for (const entry of this.#entries) {
|
|
59
|
+
const value = source === undefined || source === null ? undefined : source[entry.key];
|
|
60
|
+
target[entry.target] = value === undefined ? entry.makeDefault() : entry.convert(value);
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
/** Overwrites only the fields the source names; `in` rather than own keys, so another instance's accessors count. */
|
|
65
|
+
assign(instance: object, source: Record<string, unknown>) {
|
|
66
|
+
const target = instance as PlanTarget;
|
|
67
|
+
for (const entry of this.#entries) {
|
|
68
|
+
if (!(entry.key in source)) continue;
|
|
69
|
+
target[entry.target] = entry.convert(source[entry.key]);
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
}
|
package/constant/immerify.ts
CHANGED
|
@@ -1,16 +1,14 @@
|
|
|
1
1
|
import { FIELD_META } from "akanjs/base";
|
|
2
|
+
import { plainFieldsOf } from "akanjs/common";
|
|
2
3
|
import { immerable } from "immer";
|
|
3
4
|
import type { ConstantModelRef } from ".";
|
|
4
5
|
|
|
5
6
|
export const immerify = <T extends object>(modelRef: ConstantModelRef, objOrArr: T): T => {
|
|
6
7
|
if (Array.isArray(objOrArr)) return objOrArr.map((val) => immerify(modelRef, val as object)) as T;
|
|
7
|
-
const immeredObj = Object.assign({}
|
|
8
|
-
[immerable]: true,
|
|
9
|
-
}) as Record<string, unknown>;
|
|
10
|
-
const objRecord = objOrArr as Record<string, unknown>;
|
|
8
|
+
const immeredObj = Object.assign(plainFieldsOf(objOrArr), { [immerable]: true }) as Record<string, unknown>;
|
|
11
9
|
Object.entries(modelRef[FIELD_META]).forEach(([key, field]) => {
|
|
12
|
-
if (field.isScalar && field.isClass &&
|
|
13
|
-
immeredObj[key] = immerify(field.modelRef,
|
|
10
|
+
if (field.isScalar && field.isClass && immeredObj[key])
|
|
11
|
+
immeredObj[key] = immerify(field.modelRef, immeredObj[key] as object);
|
|
14
12
|
});
|
|
15
13
|
return immeredObj as T;
|
|
16
14
|
};
|
package/constant/index.ts
CHANGED
|
@@ -1,10 +1,15 @@
|
|
|
1
1
|
export * from "./cascadePaths";
|
|
2
2
|
export * from "./constantRegistry";
|
|
3
3
|
export * from "./crystalize";
|
|
4
|
+
export * from "./dateSlot";
|
|
4
5
|
export * from "./deserialize";
|
|
5
6
|
export * from "./fieldInfo";
|
|
7
|
+
export * from "./fieldQueryMeta";
|
|
6
8
|
export * from "./getDefault";
|
|
9
|
+
export * from "./hydrationPlan";
|
|
7
10
|
export * from "./immerify";
|
|
11
|
+
export * from "./labelOf";
|
|
12
|
+
export * from "./mask";
|
|
8
13
|
export * from "./purify";
|
|
9
14
|
export * from "./serialize";
|
|
10
15
|
export * from "./textFieldPathSet";
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The one line a human scans for. A model that writes its own `Light<Model>.label()` owns the answer, since
|
|
3
|
+
* display logic is the Light class's job; otherwise it is derived from what the model already declared — the
|
|
4
|
+
* `text: "title"` search role names exactly that field, so an agent-facing label costs no new declaration.
|
|
5
|
+
* Falls back to the conventional `title`/`name` keys; the id is the caller's floor.
|
|
6
|
+
*/
|
|
7
|
+
export const labelOf = (model: unknown, value: unknown): string | undefined => {
|
|
8
|
+
if (!value || typeof value !== "object") return undefined;
|
|
9
|
+
const source = value as Record<string, unknown>;
|
|
10
|
+
const written = source.label;
|
|
11
|
+
if (typeof written === "function") {
|
|
12
|
+
try {
|
|
13
|
+
const label = (written as () => unknown).call(source);
|
|
14
|
+
if (typeof label === "string" && label) return label;
|
|
15
|
+
} catch {
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
const paths = (model as { text?: { title?: Iterable<string> } } | null)?.text?.title;
|
|
19
|
+
const titlePath = [...(paths ?? [])].find((path) => !path.includes(".") && !path.includes("["));
|
|
20
|
+
for (const key of [titlePath, "title", "name"]) {
|
|
21
|
+
if (!key) continue;
|
|
22
|
+
const candidate = source[key];
|
|
23
|
+
if (typeof candidate === "string" && candidate) return candidate;
|
|
24
|
+
}
|
|
25
|
+
return undefined;
|
|
26
|
+
};
|
package/constant/mask.ts
ADDED
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import { FIELD_META } from "akanjs/base";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* A model as masking reads it — the constructor, for the field metadata it carries at runtime.
|
|
5
|
+
*
|
|
6
|
+
* Structural rather than `ConstantModelRef` so that anything holding the class can name it, and read through
|
|
7
|
+
* `FIELD_META` the way `resolveReturn` reads it.
|
|
8
|
+
*/
|
|
9
|
+
export interface MaskModel {
|
|
10
|
+
name: string;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
/** The part of a field's metadata masking turns on. Mirrors what `resolveReturn` branches over. */
|
|
14
|
+
interface MaskField {
|
|
15
|
+
fieldType?: string;
|
|
16
|
+
isClass?: boolean;
|
|
17
|
+
modelRef?: MaskModel;
|
|
18
|
+
visual?: boolean;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export const maskFieldsOf = (model: MaskModel): Record<string, MaskField> | null => {
|
|
22
|
+
const fields = (model as unknown as { [key: symbol]: unknown })[FIELD_META];
|
|
23
|
+
return fields && typeof fields === "object" ? (fields as Record<string, MaskField>) : null;
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* The `hidden` and `secret` field names of `model` that `value` still carries populated.
|
|
28
|
+
*
|
|
29
|
+
* `visual` is deliberately not among them. A refusal here means a value must not be published at all, and a blur
|
|
30
|
+
* placeholder is not a secret — it is merely not worth its tokens, which masking answers by dropping it.
|
|
31
|
+
*/
|
|
32
|
+
export const leakingFieldsOf = (model: MaskModel, value: Record<string, unknown>): string[] => {
|
|
33
|
+
const fields = maskFieldsOf(model);
|
|
34
|
+
if (!fields) return [];
|
|
35
|
+
return Object.entries(fields)
|
|
36
|
+
.filter(([key, field]) => (field.fieldType === "hidden" || field.fieldType === "secret") && key in value)
|
|
37
|
+
.map(([key]) => key);
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* Strips what a model marks `hidden`, `secret`, or `visual`, by the model the caller names rather than by the one
|
|
42
|
+
* the value happens to still carry. The first two are secrecy and the third is cost, but the answer is the same
|
|
43
|
+
* one — leave the field out — and this is the only place every AI-facing read already passes through.
|
|
44
|
+
*
|
|
45
|
+
* That distinction is the whole point. A check that reads the class off the value can only mask what arrives as an
|
|
46
|
+
* instance, so a `{ ...doc }` spread, a `toJSON()`, an `immerify()`, or a round-trip through `JSON.stringify` reaches
|
|
47
|
+
* its destination with the metadata already gone and nothing can be done about it. A named model is metadata the
|
|
48
|
+
* value cannot lose, so a hydrated document and a plain object copied out of one mask identically.
|
|
49
|
+
*
|
|
50
|
+
* This is the field half of `resolveReturn` and deliberately not the whole of it. That one also loads every relation
|
|
51
|
+
* it walks past, which is right for a query's return value and wrong here, where the value is already in hand.
|
|
52
|
+
*
|
|
53
|
+
* Returns `unknown` rather than the argument's type, because what comes back is missing fields that type promises.
|
|
54
|
+
*/
|
|
55
|
+
export const mask = (model: MaskModel, value: unknown): unknown => {
|
|
56
|
+
if (value === null || value === undefined || typeof value !== "object") return value;
|
|
57
|
+
if (Array.isArray(value)) return value.map((item: unknown) => mask(model, item));
|
|
58
|
+
const fields = maskFieldsOf(model);
|
|
59
|
+
if (!fields) return value;
|
|
60
|
+
const source = value as Record<string, unknown>;
|
|
61
|
+
const masked: Record<string, unknown> = {};
|
|
62
|
+
for (const [key, field] of Object.entries(fields)) {
|
|
63
|
+
if (field.fieldType === "hidden" || field.fieldType === "secret" || field.visual || !(key in source)) continue;
|
|
64
|
+
masked[key] = field.isClass && field.modelRef ? mask(field.modelRef, source[key]) : source[key];
|
|
65
|
+
}
|
|
66
|
+
return masked;
|
|
67
|
+
};
|
package/constant/purify.ts
CHANGED
|
@@ -31,18 +31,24 @@ type Purified<O> = O extends BaseObject
|
|
|
31
31
|
: O extends object
|
|
32
32
|
? PurifiedModel<O>
|
|
33
33
|
: O;
|
|
34
|
-
type PurifiedWithObjectToId<T, StateKeys extends keyof GetStateObject<T> = keyof GetStateObject<T>> =
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
[K in StateKeys as null extends T[K] ? K : never]?: Purified<T[K]> | undefined;
|
|
38
|
-
};
|
|
39
|
-
export type PurifiedModel<T> = T extends (infer S)[]
|
|
40
|
-
? PurifiedModel<S>[]
|
|
41
|
-
: T extends string | number | boolean | Dayjs | File
|
|
34
|
+
type PurifiedWithObjectToId<T, StateKeys extends keyof GetStateObject<T> = keyof GetStateObject<T>> =
|
|
35
|
+
|
|
36
|
+
unknown extends T
|
|
42
37
|
? T
|
|
43
|
-
:
|
|
44
|
-
|
|
45
|
-
|
|
38
|
+
: {
|
|
39
|
+
[K in StateKeys as null extends T[K] ? never : K]: Purified<T[K]>;
|
|
40
|
+
} & {
|
|
41
|
+
[K in StateKeys as null extends T[K] ? K : never]?: Purified<T[K]> | undefined;
|
|
42
|
+
};
|
|
43
|
+
export type PurifiedModel<T> = unknown extends T
|
|
44
|
+
? T
|
|
45
|
+
: T extends (infer S)[]
|
|
46
|
+
? PurifiedModel<S>[]
|
|
47
|
+
: T extends string | number | boolean | Dayjs | File
|
|
48
|
+
? T
|
|
49
|
+
: T extends Map<infer K, infer V>
|
|
50
|
+
? Map<K, PurifiedModel<V>>
|
|
51
|
+
: PurifiedWithObjectToId<T>;
|
|
46
52
|
|
|
47
53
|
export type UploadableClientArg<T> = [T] extends [File[]] ? File[] | FileList : T;
|
|
48
54
|
|
|
@@ -34,17 +34,23 @@ export class TextFieldPaths extends TextFieldPathSet {
|
|
|
34
34
|
}
|
|
35
35
|
|
|
36
36
|
#assertReachable(path: string, parent: ConstantField) {
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
if (parent.fieldType === "
|
|
37
|
+
|
|
38
|
+
const fix = `Drop the text role on "${path}", or leave the parent unmasked.`;
|
|
39
|
+
if (parent.fieldType === "secret") throw new Error(`Text field "${path}" is under a secret field. ${fix}`);
|
|
40
|
+
if (parent.fieldType === "hidden") throw new Error(`Text field "${path}" is under a hidden field. ${fix}`);
|
|
41
|
+
if (parent.fieldType === "resolve") throw new Error(`Text field "${path}" is under a resolved field. ${fix}`);
|
|
40
42
|
if (parent.arrDepth > 1) throw new Error(`Text field "${path}" is under a nested array and cannot be indexed`);
|
|
41
43
|
}
|
|
42
44
|
|
|
43
45
|
#assertIndexable(key: string, role: TextFieldRole, field: ConstantField) {
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
if (field.fieldType === "
|
|
47
|
-
|
|
46
|
+
|
|
47
|
+
const masked = `The search mirror stores plaintext. Drop the text role on "${key}", or make the field plain.`;
|
|
48
|
+
if (field.fieldType === "secret")
|
|
49
|
+
throw new Error(`Text field "${key}" is secret and must not be indexed. ${masked}`);
|
|
50
|
+
if (field.fieldType === "hidden")
|
|
51
|
+
throw new Error(`Text field "${key}" is hidden and must not be indexed. ${masked}`);
|
|
52
|
+
if (field.fieldType === "resolve")
|
|
53
|
+
throw new Error(`Text field "${key}" is resolved and is absent from _doc. Drop the text role on "${key}".`);
|
|
48
54
|
if (field.isMap) throw new Error(`Text field "${key}" is a Map and cannot be indexed`);
|
|
49
55
|
if (field.arrDepth > 1) throw new Error(`Text field "${key}" is a nested array and cannot be indexed`);
|
|
50
56
|
const modelRef = field.modelRef as unknown as Cls;
|
package/constant/types.ts
CHANGED
|
@@ -14,21 +14,27 @@ type ObjectToId<O> = O extends BaseObject
|
|
|
14
14
|
? DocumentModel<O>
|
|
15
15
|
: O;
|
|
16
16
|
|
|
17
|
-
type Docify<T, _StateKeys extends keyof GetStateObject<T> = keyof GetStateObject<T>> =
|
|
18
|
-
|
|
19
|
-
} & {
|
|
20
|
-
|
|
21
|
-
};
|
|
22
|
-
export type DocumentModel<T> =
|
|
23
|
-
?
|
|
24
|
-
: T extends
|
|
25
|
-
?
|
|
26
|
-
: T extends
|
|
27
|
-
?
|
|
28
|
-
:
|
|
17
|
+
type Docify<T, _StateKeys extends keyof GetStateObject<T> = keyof GetStateObject<T>> = unknown extends T
|
|
18
|
+
? T
|
|
19
|
+
: { [K in _StateKeys as null extends T[K] ? never : K]-?: ObjectToId<NonNullable<T[K]>> } & {
|
|
20
|
+
[K in _StateKeys as null extends T[K] ? K : never]?: ObjectToId<NonNullable<T[K]>> | undefined;
|
|
21
|
+
};
|
|
22
|
+
export type DocumentModel<T> = unknown extends T
|
|
23
|
+
? T
|
|
24
|
+
: T extends (infer S)[]
|
|
25
|
+
? DocumentModel<S>[]
|
|
26
|
+
: T extends string | number | boolean | Dayjs | File
|
|
27
|
+
? T
|
|
28
|
+
: T extends Map<infer K, infer V>
|
|
29
|
+
? Map<K, DocumentModel<V>>
|
|
30
|
+
: Docify<T>;
|
|
29
31
|
|
|
30
32
|
export type FieldState<T> = T extends { id: string } ? T | null : T;
|
|
31
|
-
export type DefaultOf<S> =
|
|
33
|
+
export type DefaultOf<S> = {
|
|
34
|
+
[K in keyof S as S[K] extends (...args: never[]) => unknown ? never : K extends "prototype" ? never : K]: FieldState<
|
|
35
|
+
S[K]
|
|
36
|
+
>;
|
|
37
|
+
};
|
|
32
38
|
|
|
33
39
|
export type DefaultOfSchema<Schema, RelationKey = never> = [RelationKey] extends [never]
|
|
34
40
|
? Schema
|
|
@@ -98,6 +104,28 @@ export interface ProtoPatch {
|
|
|
98
104
|
}
|
|
99
105
|
|
|
100
106
|
export const DEFAULT_PAGE_SIZE = 20;
|
|
107
|
+
/**
|
|
108
|
+
* The most rows one list request may take, whatever it asks for.
|
|
109
|
+
*
|
|
110
|
+
* A page size arrives from the client, so without a ceiling anyone who may read one page may read the whole
|
|
111
|
+
* table in a single request — and `LIMIT 0` or `LIMIT -1` reaches SQLite as "no limit at all", so the two ways
|
|
112
|
+
* of asking for nothing were the two ways of asking for everything. `resolvePageLimit` is the one place that
|
|
113
|
+
* decides; a caller wanting more pages asks for more pages.
|
|
114
|
+
*/
|
|
115
|
+
export const MAX_PAGE_SIZE = 500;
|
|
116
|
+
|
|
117
|
+
/** Clamps a caller-supplied page size into `[1, MAX_PAGE_SIZE]`, falling back to `DEFAULT_PAGE_SIZE`. */
|
|
118
|
+
export const resolvePageLimit = (limit: unknown, fallback: number = DEFAULT_PAGE_SIZE): number => {
|
|
119
|
+
const asked = Math.trunc(Number(limit));
|
|
120
|
+
if (!Number.isFinite(asked) || asked <= 0) return Math.min(fallback, MAX_PAGE_SIZE);
|
|
121
|
+
return Math.min(asked, MAX_PAGE_SIZE);
|
|
122
|
+
};
|
|
123
|
+
|
|
124
|
+
/** Clamps an offset to a non-negative integer; a negative `OFFSET` is silently read as zero by the database. */
|
|
125
|
+
export const resolvePageSkip = (skip: unknown): number => {
|
|
126
|
+
const asked = Math.trunc(Number(skip));
|
|
127
|
+
return Number.isFinite(asked) && asked > 0 ? asked : 0;
|
|
128
|
+
};
|
|
101
129
|
export type NonFunctionalKeys<T> = {
|
|
102
130
|
[K in keyof T]: T[K] extends (...args: never[]) => unknown ? never : K;
|
|
103
131
|
}[keyof T];
|