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
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { SerializedArg } from "akanjs/signal";
|
|
1
|
+
import type { HttpMutationMethod, SerializedArg } from "akanjs/signal";
|
|
2
2
|
|
|
3
3
|
export interface ErrorResponsePayload {
|
|
4
4
|
error: string;
|
|
@@ -22,18 +22,49 @@ export interface ErrorConstructor {
|
|
|
22
22
|
fromJSON: (payload: ErrorResponsePayload) => RestoredError;
|
|
23
23
|
}
|
|
24
24
|
|
|
25
|
-
interface
|
|
25
|
+
export interface HttpClientOptions {
|
|
26
26
|
headers?: Record<string, string>;
|
|
27
|
+
/** Milliseconds before the request is abandoned; `false` waits as long as the browser will. */
|
|
28
|
+
timeout?: number | false;
|
|
29
|
+
ErrorCls?: ErrorConstructor;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
interface FetchOptions extends Pick<HttpClientOptions, "headers" | "timeout"> {
|
|
27
33
|
baseUrl?: string;
|
|
28
34
|
}
|
|
29
35
|
|
|
36
|
+
const jsonContentType = /^application\/(?:[\w.+-]+\+)?json\b/i;
|
|
37
|
+
|
|
38
|
+
const transportErrorKeyMap = {
|
|
39
|
+
408: "base.error.gatewayTimeout",
|
|
40
|
+
502: "base.error.serverUnavailable",
|
|
41
|
+
503: "base.error.serverUnavailable",
|
|
42
|
+
504: "base.error.gatewayTimeout",
|
|
43
|
+
} as const;
|
|
44
|
+
|
|
45
|
+
const serverUnreachableKey = "base.error.serverUnreachable";
|
|
46
|
+
const unexpectedResponseKey = "base.error.unexpectedResponse";
|
|
47
|
+
const transportDetailLimit = 200;
|
|
48
|
+
/**
|
|
49
|
+
* How long a call waits before giving up.
|
|
50
|
+
*
|
|
51
|
+
* Nothing else bounds it: a gateway answers a dead upstream with a 504, but a solo process has no gateway and a
|
|
52
|
+
* severed connection produces no response at all — the request then sits until the browser's own limit, which is
|
|
53
|
+
* minutes. The dictionary already has the wording for a slow server (`gatewayTimeout`), so this is the client
|
|
54
|
+
* side of an answer that only existed for one deployment shape.
|
|
55
|
+
*/
|
|
56
|
+
const DEFAULT_TIMEOUT_MS = 30_000;
|
|
57
|
+
|
|
30
58
|
export class HttpClient {
|
|
31
59
|
readonly baseUrl: string;
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
) {
|
|
60
|
+
#headers: Record<string, string>;
|
|
61
|
+
#timeout?: number | false;
|
|
62
|
+
private ErrorCls?: ErrorConstructor;
|
|
63
|
+
constructor(baseUrl: string, options: HttpClientOptions = {}) {
|
|
36
64
|
this.baseUrl = baseUrl;
|
|
65
|
+
this.#headers = options.headers ?? {};
|
|
66
|
+
this.#timeout = options.timeout;
|
|
67
|
+
this.ErrorCls = options.ErrorCls;
|
|
37
68
|
}
|
|
38
69
|
|
|
39
70
|
setErrorConstructor(ErrorCls?: ErrorConstructor) {
|
|
@@ -42,57 +73,131 @@ export class HttpClient {
|
|
|
42
73
|
#resolveBaseUrl(baseUrl?: string) {
|
|
43
74
|
return (baseUrl ?? this.baseUrl).replace(/\/$/, "");
|
|
44
75
|
}
|
|
76
|
+
#resolveUrl(url: string, options: FetchOptions) {
|
|
77
|
+
return `${this.#resolveBaseUrl(options.baseUrl)}${url}`;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
#makeHeaders(headers: Record<string, string>, options: FetchOptions) {
|
|
81
|
+
return { Accept: "application/json", ...this.#headers, ...headers, ...options.headers };
|
|
82
|
+
}
|
|
45
83
|
async get<Returns = unknown>(url: string, options: FetchOptions = {}): Promise<Returns> {
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
84
|
+
return await this.#request<Returns>(
|
|
85
|
+
this.#resolveUrl(url, options),
|
|
86
|
+
{ headers: this.#makeHeaders({ "Content-Type": "application/json" }, options) },
|
|
87
|
+
options,
|
|
88
|
+
);
|
|
50
89
|
}
|
|
51
90
|
#makeReqContent(data: FormData | Record<string, unknown>): { body: BodyInit; headers: Record<string, string> } {
|
|
52
91
|
|
|
53
92
|
if (data instanceof FormData) return { body: data, headers: {} };
|
|
54
93
|
return { body: JSON.stringify(data), headers: { "Content-Type": "application/json" } };
|
|
55
94
|
}
|
|
56
|
-
async
|
|
95
|
+
async send<Returns = unknown>(
|
|
96
|
+
method: HttpMutationMethod,
|
|
57
97
|
url: string,
|
|
58
98
|
data: FormData | Record<string, unknown>,
|
|
59
99
|
options: FetchOptions = {},
|
|
60
100
|
): Promise<Returns> {
|
|
61
101
|
const { body, headers } = this.#makeReqContent(data);
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
body,
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
102
|
+
return await this.#request<Returns>(
|
|
103
|
+
this.#resolveUrl(url, options),
|
|
104
|
+
{ method, body, headers: this.#makeHeaders(headers, options) },
|
|
105
|
+
options,
|
|
106
|
+
);
|
|
107
|
+
}
|
|
108
|
+
async put<Returns = unknown>(
|
|
109
|
+
url: string,
|
|
110
|
+
data: FormData | Record<string, unknown>,
|
|
111
|
+
options: FetchOptions = {},
|
|
112
|
+
): Promise<Returns> {
|
|
113
|
+
return await this.send<Returns>("PUT", url, data, options);
|
|
68
114
|
}
|
|
69
115
|
async post<Returns = unknown>(
|
|
70
116
|
url: string,
|
|
71
117
|
data: FormData | Record<string, unknown>,
|
|
72
118
|
options: FetchOptions = {},
|
|
73
119
|
): Promise<Returns> {
|
|
74
|
-
|
|
75
|
-
const res = await fetch(`${this.#resolveBaseUrl(options.baseUrl)}${url}`, {
|
|
76
|
-
method: "POST",
|
|
77
|
-
body,
|
|
78
|
-
headers: { ...headers, ...options.headers },
|
|
79
|
-
});
|
|
80
|
-
return await this.#readJsonResponse<Returns>(res);
|
|
120
|
+
return await this.send<Returns>("POST", url, data, options);
|
|
81
121
|
}
|
|
82
122
|
async delete<Returns = unknown>(url: string, options: FetchOptions = {}): Promise<Returns> {
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
headers: { "Content-Type": "application/json",
|
|
86
|
-
|
|
123
|
+
return await this.#request<Returns>(
|
|
124
|
+
this.#resolveUrl(url, options),
|
|
125
|
+
{ method: "DELETE", headers: this.#makeHeaders({ "Content-Type": "application/json" }, options) },
|
|
126
|
+
options,
|
|
127
|
+
);
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
async #request<Returns>(url: string, init: RequestInit, options: FetchOptions = {}): Promise<Returns> {
|
|
131
|
+
const res = await this.#fetch(url, this.#withTimeout(init, options));
|
|
87
132
|
return await this.#readJsonResponse<Returns>(res);
|
|
88
133
|
}
|
|
89
134
|
|
|
135
|
+
/**
|
|
136
|
+
* An upload gets no deadline of its own: a large file on a slow uplink is a long request that is working, and
|
|
137
|
+
* the request body is the only thing this side can tell that from. Everything else takes the default unless
|
|
138
|
+
* the caller named one.
|
|
139
|
+
*/
|
|
140
|
+
#withTimeout(init: RequestInit, options: FetchOptions): RequestInit {
|
|
141
|
+
const timeout = options.timeout ?? (init.body instanceof FormData ? false : (this.#timeout ?? DEFAULT_TIMEOUT_MS));
|
|
142
|
+
if (timeout === false || !Number.isFinite(timeout) || timeout <= 0) return init;
|
|
143
|
+
return { ...init, signal: AbortSignal.timeout(timeout) };
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
/**
|
|
147
|
+
* `fetch` rejects only when no response arrived at all — a refused connection, a DNS failure, a socket
|
|
148
|
+
* dropped mid-flight. That is the server being unreachable, not an error this API reported, so it is
|
|
149
|
+
* restored as one rather than surfacing the runtime's own `TypeError: Failed to fetch`.
|
|
150
|
+
*/
|
|
151
|
+
async #fetch(url: string, init: RequestInit) {
|
|
152
|
+
try {
|
|
153
|
+
return await fetch(url, init);
|
|
154
|
+
} catch (error) {
|
|
155
|
+
|
|
156
|
+
if (error instanceof Error && error.name === "TimeoutError")
|
|
157
|
+
throw this.#restoreError({ error: transportErrorKeyMap[408], data: { status: 408 } }, 408);
|
|
158
|
+
if (error instanceof Error && error.name === "AbortError") throw error;
|
|
159
|
+
throw this.#restoreError({ error: serverUnreachableKey, details: String(error) }, 503);
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
|
|
90
163
|
async #readJsonResponse<Returns>(res: Response): Promise<Returns> {
|
|
91
|
-
const body = await res
|
|
164
|
+
const body = await this.#readBody(res);
|
|
92
165
|
if (res.ok) return body as Returns;
|
|
93
166
|
throw this.#restoreError(body, res.status);
|
|
94
167
|
}
|
|
95
168
|
|
|
169
|
+
/**
|
|
170
|
+
* A proxy answers a restarting upstream with a page of its own — nginx's `504 Gateway Time-out` HTML,
|
|
171
|
+
* the federation gateway's plain-text 503. That body is not this API's, so parsing it would surface the
|
|
172
|
+
* parser's complaint (`Unexpected token '<'`) instead of the fact that the server is down.
|
|
173
|
+
*/
|
|
174
|
+
async #readBody(res: Response) {
|
|
175
|
+
if (jsonContentType.test(res.headers.get("content-type") ?? "")) {
|
|
176
|
+
try {
|
|
177
|
+
return (await res.json()) as unknown;
|
|
178
|
+
} catch (error) {
|
|
179
|
+
throw this.#transportError(res.status, String(error));
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
const raw = await res.text();
|
|
183
|
+
const parsed = HttpClient.#parseJson(raw);
|
|
184
|
+
if (parsed === undefined) throw this.#transportError(res.status, raw);
|
|
185
|
+
return parsed;
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
static #parseJson(raw: string): unknown {
|
|
189
|
+
try {
|
|
190
|
+
return JSON.parse(raw) as unknown;
|
|
191
|
+
} catch {
|
|
192
|
+
return undefined;
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
#transportError(status: number, detail: string): RestoredError {
|
|
197
|
+
const error = transportErrorKeyMap[status as keyof typeof transportErrorKeyMap] ?? unexpectedResponseKey;
|
|
198
|
+
return this.#restoreError({ error, data: { status }, details: detail.slice(0, transportDetailLimit) }, status);
|
|
199
|
+
}
|
|
200
|
+
|
|
96
201
|
#restoreError(body: unknown, fallbackStatusCode: number): RestoredError {
|
|
97
202
|
const payload =
|
|
98
203
|
body && typeof body === "object" && "error" in body
|
|
@@ -112,7 +217,12 @@ export class HttpClient {
|
|
|
112
217
|
searchArgs.forEach((arg) => {
|
|
113
218
|
const argValue = argMap.get(arg.name);
|
|
114
219
|
if (argValue === null || argValue === undefined) return;
|
|
115
|
-
|
|
220
|
+
|
|
221
|
+
if (arg.refName === "Any") {
|
|
222
|
+
|
|
223
|
+
const encoded = JSON.stringify(argValue);
|
|
224
|
+
if (encoded !== undefined) searchParams.set(arg.name, encoded);
|
|
225
|
+
} else if (arg.arrDepth && Array.isArray(argValue))
|
|
116
226
|
argValue.forEach((value) => {
|
|
117
227
|
searchParams.append(arg.name, String(value));
|
|
118
228
|
});
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
import { DataList } from "akanjs/base";
|
|
2
|
+
import { type BaseInsight, type BaseObject, withSharedInstances } from "akanjs/constant";
|
|
3
|
+
|
|
4
|
+
import { FetchHandle } from "./fetchHandle";
|
|
5
|
+
|
|
6
|
+
export interface SliceInitInput {
|
|
7
|
+
refName: string;
|
|
8
|
+
capRefName: string;
|
|
9
|
+
capSuffix: string;
|
|
10
|
+
sliceName: string;
|
|
11
|
+
argLength: number;
|
|
12
|
+
queryArgs: unknown[];
|
|
13
|
+
page: number;
|
|
14
|
+
limit: number;
|
|
15
|
+
sort: string;
|
|
16
|
+
listRequest: Promise<BaseObject[]>;
|
|
17
|
+
/** `null` when the caller passed `{ insight: false }` — the aggregate query is then never made. */
|
|
18
|
+
insightRequest: Promise<BaseInsight | null>;
|
|
19
|
+
light: new (obj?: unknown) => BaseObject;
|
|
20
|
+
insight: new (obj?: unknown) => object;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* The two calls a slice's `init` makes and the three values callers read off them.
|
|
25
|
+
*
|
|
26
|
+
* The list does not wait for the aggregate: `x<Slice>List` resolves as soon as the rows land, while
|
|
27
|
+
* `x<Slice>Init` — which carries `lastPageOf<Model>` and therefore needs the count — waits for both. Every
|
|
28
|
+
* derived value is memoized, so the awaited shape and the un-awaited handle hand out the same instances.
|
|
29
|
+
*/
|
|
30
|
+
export class SliceInitHandle {
|
|
31
|
+
readonly #input: SliceInitInput;
|
|
32
|
+
#serverInit?: object;
|
|
33
|
+
#modelList?: DataList<BaseObject>;
|
|
34
|
+
#modelInsight?: object;
|
|
35
|
+
|
|
36
|
+
constructor(input: SliceInitInput) {
|
|
37
|
+
this.#input = input;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
build() {
|
|
41
|
+
const { refName, capSuffix, listRequest, insightRequest } = this.#input;
|
|
42
|
+
const keys = {
|
|
43
|
+
init: `${refName}Init${capSuffix}`,
|
|
44
|
+
list: `${refName}List${capSuffix}`,
|
|
45
|
+
insight: `${refName}Insight${capSuffix}`,
|
|
46
|
+
};
|
|
47
|
+
return FetchHandle.of<Record<string, unknown>, Record<string, Promise<unknown>>>(
|
|
48
|
+
[listRequest, insightRequest],
|
|
49
|
+
async () => {
|
|
50
|
+
const [modelObjList, modelObjInsight] = await Promise.all([listRequest, insightRequest]);
|
|
51
|
+
return FetchHandle.lazy({ [keys.init]: this.#serverInitOf(modelObjList, modelObjInsight) }, {
|
|
52
|
+
[keys.list]: () => this.#listOf(modelObjList),
|
|
53
|
+
[keys.insight]: () => this.#insightOf(modelObjInsight),
|
|
54
|
+
} as { [key: string]: () => unknown });
|
|
55
|
+
},
|
|
56
|
+
{
|
|
57
|
+
[keys.init]: () =>
|
|
58
|
+
Promise.all([listRequest, insightRequest]).then(([modelObjList, modelObjInsight]) =>
|
|
59
|
+
this.#serverInitOf(modelObjList, modelObjInsight),
|
|
60
|
+
),
|
|
61
|
+
[keys.list]: () => listRequest.then((modelObjList) => this.#listOf(modelObjList)),
|
|
62
|
+
[keys.insight]: () => insightRequest.then((modelObjInsight) => this.#insightOf(modelObjInsight)),
|
|
63
|
+
},
|
|
64
|
+
);
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
#serverInitOf(modelObjList: BaseObject[], modelObjInsight: BaseInsight | null) {
|
|
68
|
+
const { refName, capRefName, sliceName, argLength, queryArgs, page, limit, sort } = this.#input;
|
|
69
|
+
const lastPage = modelObjInsight?.count
|
|
70
|
+
? Math.max(Math.floor((modelObjInsight.count - 1) / (limit || 20)) + 1, 1)
|
|
71
|
+
: 1;
|
|
72
|
+
this.#serverInit ??= {
|
|
73
|
+
refName,
|
|
74
|
+
sliceName,
|
|
75
|
+
argLength,
|
|
76
|
+
[`${refName}ObjList`]: modelObjList,
|
|
77
|
+
[`${refName}ObjInsight`]: modelObjInsight,
|
|
78
|
+
[`pageOf${capRefName}`]: page,
|
|
79
|
+
[`lastPageOf${capRefName}`]: lastPage,
|
|
80
|
+
[`limitOf${capRefName}`]: limit,
|
|
81
|
+
[`queryArgsOf${capRefName}`]: queryArgs,
|
|
82
|
+
[`sortOf${capRefName}`]: sort,
|
|
83
|
+
[`${refName}InitAt`]: new Date(),
|
|
84
|
+
};
|
|
85
|
+
return this.#serverInit;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
#listOf(modelObjList: BaseObject[]) {
|
|
89
|
+
const { light } = this.#input;
|
|
90
|
+
this.#modelList ??= new DataList(
|
|
91
|
+
withSharedInstances(() => modelObjList.map((modelObj) => new light(modelObj) as BaseObject)),
|
|
92
|
+
);
|
|
93
|
+
return this.#modelList;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
#insightOf(modelObjInsight: BaseInsight | null) {
|
|
97
|
+
const { insight } = this.#input;
|
|
98
|
+
this.#modelInsight ??= new insight(modelObjInsight);
|
|
99
|
+
return this.#modelInsight;
|
|
100
|
+
}
|
|
101
|
+
}
|
package/fetch/client/wsClient.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Logger, websocketAuthContract } from "akanjs/common";
|
|
1
|
+
import { Logger, websocketAuthContract, websocketBinaryFrameContract } from "akanjs/common";
|
|
2
2
|
import type {
|
|
3
3
|
WebsocketAuthAck,
|
|
4
4
|
WebsocketMessageData,
|
|
@@ -41,6 +41,7 @@ export class WsClient {
|
|
|
41
41
|
#listenerMap = new Map<string, Set<Listener>>();
|
|
42
42
|
#destroyed = false;
|
|
43
43
|
#connectRequested = false;
|
|
44
|
+
#outbox: string[] = [];
|
|
44
45
|
#unconnectedWarnTimers = new Map<string, ReturnType<typeof setTimeout>>();
|
|
45
46
|
#jwt: string | null = null;
|
|
46
47
|
connected = false;
|
|
@@ -84,6 +85,7 @@ export class WsClient {
|
|
|
84
85
|
if (this.#destroyed) return;
|
|
85
86
|
|
|
86
87
|
this.#ws = new WebSocket(this.url);
|
|
88
|
+
this.#ws.binaryType = "arraybuffer";
|
|
87
89
|
this.#ws.onopen = (e) => {
|
|
88
90
|
this.#reconnectAttempts = 0;
|
|
89
91
|
this.connected = true;
|
|
@@ -94,10 +96,19 @@ export class WsClient {
|
|
|
94
96
|
const data: WebsocketReqData = { key: option.key, data: option.data, subscribe: true };
|
|
95
97
|
this.#ws?.send(JSON.stringify(data));
|
|
96
98
|
});
|
|
99
|
+
const queued = this.#outbox;
|
|
100
|
+
this.#outbox = [];
|
|
101
|
+
for (const frame of queued) this.#ws?.send(frame);
|
|
97
102
|
};
|
|
98
103
|
this.#ws.onmessage = (e) => {
|
|
99
104
|
try {
|
|
100
|
-
|
|
105
|
+
if (typeof e.data !== "string") {
|
|
106
|
+
const frame = websocketBinaryFrameContract.decode(e.data as ArrayBuffer);
|
|
107
|
+
if (frame) this.#handlePubsub(frame.roomId, frame.payload);
|
|
108
|
+
else this.logger.warn("Unknown binary WebSocket frame");
|
|
109
|
+
return;
|
|
110
|
+
}
|
|
111
|
+
const parsed = JSON.parse(e.data) as { error?: unknown } & WebsocketResData;
|
|
101
112
|
if (parsed?.error) {
|
|
102
113
|
throw this.#restoreError(parsed);
|
|
103
114
|
}
|
|
@@ -197,6 +208,7 @@ export class WsClient {
|
|
|
197
208
|
}
|
|
198
209
|
for (const timer of this.#unconnectedWarnTimers.values()) clearTimeout(timer);
|
|
199
210
|
this.#unconnectedWarnTimers.clear();
|
|
211
|
+
this.#outbox = [];
|
|
200
212
|
this.#ws?.close();
|
|
201
213
|
this.#ws = null;
|
|
202
214
|
}
|
|
@@ -240,28 +252,31 @@ export class WsClient {
|
|
|
240
252
|
`[akanjs] WebSocket is not connected. Call fetch.instance.connect(), or drop the root layout "wsConnect = false", before ${action} "${key}".`,
|
|
241
253
|
);
|
|
242
254
|
}
|
|
243
|
-
#
|
|
244
|
-
|
|
255
|
+
#warnUnconnected(action: "emit" | "subscribe", key: string) {
|
|
256
|
+
const timerKey = `${action}:${key}`;
|
|
257
|
+
if (this.#connectRequested || this.#unconnectedWarnTimers.has(timerKey)) return;
|
|
245
258
|
const timer = setTimeout(() => {
|
|
246
|
-
this.#unconnectedWarnTimers.delete(
|
|
259
|
+
this.#unconnectedWarnTimers.delete(timerKey);
|
|
247
260
|
if (this.#connectRequested || this.#destroyed) return;
|
|
248
|
-
this.#warnNotConnected(
|
|
261
|
+
this.#warnNotConnected(action, key);
|
|
249
262
|
}, 0);
|
|
250
|
-
this.#unconnectedWarnTimers.set(
|
|
263
|
+
this.#unconnectedWarnTimers.set(timerKey, timer);
|
|
251
264
|
}
|
|
252
265
|
emit(key: string, data: WsRequestPayload) {
|
|
266
|
+
const payload: WebsocketReqData = { key, data: Array.isArray(data) ? data : [data] };
|
|
267
|
+
const frame = JSON.stringify(payload);
|
|
268
|
+
|
|
253
269
|
if (this.#ws?.readyState !== WebSocket.OPEN) {
|
|
254
|
-
this.
|
|
255
|
-
this.#
|
|
270
|
+
this.#outbox.push(frame);
|
|
271
|
+
this.#warnUnconnected("emit", key);
|
|
256
272
|
return this;
|
|
257
273
|
}
|
|
258
|
-
|
|
259
|
-
this.#ws.send(JSON.stringify(payload));
|
|
274
|
+
this.#ws.send(frame);
|
|
260
275
|
return this;
|
|
261
276
|
}
|
|
262
277
|
subscribe(option: { key: string; data: unknown[]; handleEvent: (data: unknown) => void }) {
|
|
263
278
|
const roomId = WsClient.makeRoomId(option.key, option.data);
|
|
264
|
-
if (!this.#ws) this.#
|
|
279
|
+
if (!this.#ws) this.#warnUnconnected("subscribe", option.key);
|
|
265
280
|
if (!this.#roomSubscribeMap.has(roomId)) {
|
|
266
281
|
this.#roomSubscribeMap.set(roomId, { key: option.key, data: option.data, listener: new Set() });
|
|
267
282
|
if (this.#ws?.readyState === WebSocket.OPEN) {
|
|
@@ -8,33 +8,63 @@ export type SliceMeta = {
|
|
|
8
8
|
argLength: number;
|
|
9
9
|
};
|
|
10
10
|
|
|
11
|
-
|
|
11
|
+
/** What the root slice takes: one of the model's declared filter queries, and the args that filter asks for. */
|
|
12
|
+
export interface QuerySetting {
|
|
13
|
+
queryKey: string;
|
|
14
|
+
/**
|
|
15
|
+
* Read when the query is applied rather than when the setting is written, so a thunk keeps an arg relative to
|
|
16
|
+
* now — `() => [dayjs().subtract(1, "hour")]` — current at the moment the user asks for it.
|
|
17
|
+
*/
|
|
18
|
+
args?: unknown[] | (() => unknown[]);
|
|
19
|
+
/**
|
|
20
|
+
* The same list under the name the rest of the framework already uses for it — the `queryArgsOf<Model>` state
|
|
21
|
+
* key, `refresh<Model>({ queryArgs })`, and a field's own `.meta(...)` declaration. Accepted so a query a
|
|
22
|
+
* field declares is one of these as it stands, rather than something every caller has to rename by hand.
|
|
23
|
+
* `args` wins when both are given.
|
|
24
|
+
*/
|
|
25
|
+
queryArgs?: unknown[] | (() => unknown[]);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
type ServerInitShape<
|
|
12
29
|
RefName extends string,
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
_LightObj = GetStateObject<Light>,
|
|
19
|
-
_InsightObj = GetStateObject<Insight>,
|
|
20
|
-
_Sort = ExtractSort<Filter>,
|
|
30
|
+
QueryArgs,
|
|
31
|
+
CapRefName extends string,
|
|
32
|
+
LightObj,
|
|
33
|
+
InsightObj,
|
|
34
|
+
Sort,
|
|
21
35
|
> = SliceMeta & {
|
|
22
|
-
[K in `${RefName}ObjList`]:
|
|
36
|
+
[K in `${RefName}ObjList`]: LightObj[];
|
|
23
37
|
} & {
|
|
24
|
-
|
|
38
|
+
/** `null` when the caller passed `{ insight: false }`: the aggregate query was never made. */
|
|
39
|
+
[K in `${RefName}ObjInsight`]: InsightObj | null;
|
|
25
40
|
} & {
|
|
26
|
-
[K in `pageOf${
|
|
41
|
+
[K in `pageOf${CapRefName}`]: number;
|
|
27
42
|
} & {
|
|
28
|
-
[K in `lastPageOf${
|
|
43
|
+
[K in `lastPageOf${CapRefName}`]: number;
|
|
29
44
|
} & {
|
|
30
|
-
[K in `limitOf${
|
|
45
|
+
[K in `limitOf${CapRefName}`]: number;
|
|
31
46
|
} & {
|
|
32
|
-
[K in `queryArgsOf${
|
|
47
|
+
[K in `queryArgsOf${CapRefName}`]: QueryArgs;
|
|
33
48
|
} & {
|
|
34
|
-
[K in `sortOf${
|
|
49
|
+
[K in `sortOf${CapRefName}`]: Sort;
|
|
35
50
|
} & {
|
|
36
51
|
[K in `${RefName}InitAt`]: Date;
|
|
37
52
|
};
|
|
53
|
+
|
|
54
|
+
export type ServerInit<
|
|
55
|
+
RefName extends string,
|
|
56
|
+
Light,
|
|
57
|
+
Insight = any,
|
|
58
|
+
QueryArgs = any,
|
|
59
|
+
Filter extends FilterInstance = any,
|
|
60
|
+
> = ServerInitShape<
|
|
61
|
+
RefName,
|
|
62
|
+
QueryArgs,
|
|
63
|
+
Capitalize<RefName>,
|
|
64
|
+
GetStateObject<Light>,
|
|
65
|
+
GetStateObject<Insight>,
|
|
66
|
+
ExtractSort<Filter>
|
|
67
|
+
>;
|
|
38
68
|
/** Client/server-friendly return type for initialized list and insight data. */
|
|
39
69
|
export type ClientInit<
|
|
40
70
|
RefName extends string,
|
|
@@ -42,13 +72,7 @@ export type ClientInit<
|
|
|
42
72
|
Insight = any,
|
|
43
73
|
QueryArgs = any,
|
|
44
74
|
Filter extends FilterInstance = any,
|
|
45
|
-
|
|
46
|
-
_LightObj = GetStateObject<Light>,
|
|
47
|
-
_InsightObj = GetStateObject<Insight>,
|
|
48
|
-
_Sort = ExtractSort<Filter>,
|
|
49
|
-
> = PromiseOrObject<
|
|
50
|
-
ServerInit<RefName, Light, Insight, QueryArgs, Filter, _CapitalizedRefName, _LightObj, _InsightObj, _Sort>
|
|
51
|
-
>;
|
|
75
|
+
> = PromiseOrObject<ServerInit<RefName, Light, Insight, QueryArgs, Filter>>;
|
|
52
76
|
|
|
53
77
|
export type ServerView<RefName extends string, Model> = { refName: RefName } & {
|
|
54
78
|
[K in `${RefName}Obj`]: GetStateObject<Model>;
|
|
@@ -77,6 +101,43 @@ export type EditReturn<RefName extends string, Full> = {
|
|
|
77
101
|
[K in `${RefName}Edit`]: ServerEdit<RefName, Full>;
|
|
78
102
|
};
|
|
79
103
|
|
|
104
|
+
/**
|
|
105
|
+
* What `fetch.view<Model>` / `fetch.edit<Model>` / `fetch.init<Model><Suffix>` return: awaitable for the shape
|
|
106
|
+
* the helper has always given, and destructurable into one promise per field for a route that wants each
|
|
107
|
+
* section to render as its own data lands instead of holding the page for the slowest.
|
|
108
|
+
*/
|
|
109
|
+
export type FetchHandleOf<Awaited, Fields> = PromiseLike<Awaited> & Fields;
|
|
110
|
+
|
|
111
|
+
export type ViewHandle<RefName extends string, Full> = FetchHandleOf<
|
|
112
|
+
ViewReturn<RefName, Full>,
|
|
113
|
+
{
|
|
114
|
+
[K in RefName]: Promise<Full>;
|
|
115
|
+
} & {
|
|
116
|
+
[K in `${RefName}View`]: Promise<ServerView<RefName, Full>>;
|
|
117
|
+
}
|
|
118
|
+
>;
|
|
119
|
+
|
|
120
|
+
export type EditHandle<RefName extends string, Full> = FetchHandleOf<
|
|
121
|
+
EditReturn<RefName, Full>,
|
|
122
|
+
{
|
|
123
|
+
[K in RefName]: Promise<Full>;
|
|
124
|
+
} & {
|
|
125
|
+
[K in `${RefName}Edit`]: Promise<ServerEdit<RefName, Full>>;
|
|
126
|
+
}
|
|
127
|
+
>;
|
|
128
|
+
|
|
129
|
+
type InitReturnShape<
|
|
130
|
+
RefName extends string,
|
|
131
|
+
CapSuffix extends string,
|
|
132
|
+
Init,
|
|
133
|
+
ListItem extends { id: string },
|
|
134
|
+
Insight,
|
|
135
|
+
> = {
|
|
136
|
+
[K in `${RefName}Init${CapSuffix}`]: Init;
|
|
137
|
+
} & {
|
|
138
|
+
[K in `${RefName}List${CapSuffix}`]: DataList<ListItem>;
|
|
139
|
+
} & { [K in `${RefName}Insight${CapSuffix}`]: Insight };
|
|
140
|
+
|
|
80
141
|
export type InitReturn<
|
|
81
142
|
RefName extends string,
|
|
82
143
|
Suffix extends string,
|
|
@@ -84,25 +145,48 @@ export type InitReturn<
|
|
|
84
145
|
Insight,
|
|
85
146
|
Args,
|
|
86
147
|
Filter extends FilterInstance,
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
148
|
+
> = InitReturnShape<
|
|
149
|
+
RefName,
|
|
150
|
+
Capitalize<Suffix>,
|
|
151
|
+
ServerInit<RefName, Light, Insight, Args, Filter>,
|
|
152
|
+
Light extends { id: string } ? Light : { id: string },
|
|
153
|
+
Insight
|
|
154
|
+
>;
|
|
155
|
+
|
|
156
|
+
/**
|
|
157
|
+
* The list resolves without waiting for the aggregate, so `x<Slice>List` lands before `x<Slice>Init` — which
|
|
158
|
+
* carries `lastPageOf<Model>` and therefore needs the count.
|
|
159
|
+
*
|
|
160
|
+
* `x<Slice>List` and `x<Slice>Insight` hold hydrated model instances, which React Flight refuses as props to a
|
|
161
|
+
* client component: consume them in a server component and hand `x<Slice>Init` to a `Zone`.
|
|
162
|
+
*/
|
|
163
|
+
type InitHandleShape<
|
|
164
|
+
RefName extends string,
|
|
165
|
+
CapSuffix extends string,
|
|
166
|
+
Init,
|
|
167
|
+
ListItem extends { id: string },
|
|
168
|
+
Insight,
|
|
93
169
|
> = {
|
|
94
|
-
[K in `${RefName}Init${
|
|
95
|
-
RefName,
|
|
96
|
-
Light,
|
|
97
|
-
Insight,
|
|
98
|
-
Args,
|
|
99
|
-
Filter,
|
|
100
|
-
_CapitalizedRefName,
|
|
101
|
-
_LightObj,
|
|
102
|
-
_InsightObj,
|
|
103
|
-
_Sort
|
|
104
|
-
>;
|
|
170
|
+
[K in `${RefName}Init${CapSuffix}`]: Promise<Init>;
|
|
105
171
|
} & {
|
|
106
|
-
[K in `${RefName}List${
|
|
107
|
-
} & { [K in `${RefName}Insight${
|
|
172
|
+
[K in `${RefName}List${CapSuffix}`]: Promise<DataList<ListItem>>;
|
|
173
|
+
} & { [K in `${RefName}Insight${CapSuffix}`]: Promise<Insight> };
|
|
174
|
+
|
|
175
|
+
export type InitHandle<
|
|
176
|
+
RefName extends string,
|
|
177
|
+
Suffix extends string,
|
|
178
|
+
Light,
|
|
179
|
+
Insight,
|
|
180
|
+
Args,
|
|
181
|
+
Filter extends FilterInstance,
|
|
182
|
+
> = FetchHandleOf<
|
|
183
|
+
InitReturn<RefName, Suffix, Light, Insight, Args, Filter>,
|
|
184
|
+
InitHandleShape<
|
|
185
|
+
RefName,
|
|
186
|
+
Capitalize<Suffix>,
|
|
187
|
+
ServerInit<RefName, Light, Insight, Args, Filter>,
|
|
188
|
+
Light extends { id: string } ? Light : { id: string },
|
|
189
|
+
Insight
|
|
190
|
+
>
|
|
191
|
+
>;
|
|
108
192
|
|
|
@@ -7,6 +7,7 @@ import type {
|
|
|
7
7
|
EndpInfoReqType,
|
|
8
8
|
EndpointCls,
|
|
9
9
|
EndpointInfo,
|
|
10
|
+
PromptMessage,
|
|
10
11
|
SlceCnstFull,
|
|
11
12
|
SlceCnstInsight,
|
|
12
13
|
SlceCnstLight,
|
|
@@ -32,15 +33,21 @@ type EndpointClientReturns<E, SlceCls extends SliceCls | never> = [SlceCls] exte
|
|
|
32
33
|
SlceCnstInsight<SlceCls>
|
|
33
34
|
>;
|
|
34
35
|
|
|
35
|
-
type
|
|
36
|
-
|
|
37
|
-
|
|
36
|
+
type OrNull<T, Nullable> = Nullable extends true ? T | null : T;
|
|
37
|
+
|
|
38
|
+
type EndpInfoReturns<E, SlceCls extends SliceCls | never> = OrNull<
|
|
39
|
+
EndpointClientReturns<E, SlceCls>,
|
|
40
|
+
EndpInfoNullable<E>
|
|
41
|
+
>;
|
|
38
42
|
|
|
39
43
|
type QueryOrMutationFetchFn<E, SlceCls extends SliceCls | never> = (
|
|
40
44
|
...args: [...EndpInfoArgs<E>, fetchPolicy?: FetchPolicy]
|
|
41
45
|
) => Promise<EndpInfoReturns<E, SlceCls>>;
|
|
42
46
|
|
|
43
|
-
|
|
47
|
+
/** Typed off `PromptResult` rather than the endpoint's return ref, which is the `Any` carrier a prompt rides on. */
|
|
48
|
+
type PromptFetchFn<E> = (...args: [...EndpInfoArgs<E>, fetchPolicy?: FetchPolicy]) => Promise<PromptMessage[]>;
|
|
49
|
+
|
|
50
|
+
type MessageEmitFn<E> = (...args: [...EndpInfoArgs<E>, fetchPolicy?: FetchPolicy]) => void;
|
|
44
51
|
|
|
45
52
|
type MessageListenFn<E, SlceCls extends SliceCls | never> = (
|
|
46
53
|
handleEvent: (data: EndpInfoReturns<E, SlceCls>) => PromiseOrObject<void>,
|
|
@@ -58,12 +65,14 @@ type PubsubSubscribeFn<E, SlceCls extends SliceCls | never> = (
|
|
|
58
65
|
type PrimaryFetchFn<E, SlceCls extends SliceCls | never> =
|
|
59
66
|
EndpInfoReqType<E> extends "query" | "mutation"
|
|
60
67
|
? QueryOrMutationFetchFn<E, SlceCls>
|
|
61
|
-
: EndpInfoReqType<E> extends "
|
|
62
|
-
?
|
|
63
|
-
:
|
|
68
|
+
: EndpInfoReqType<E> extends "prompt"
|
|
69
|
+
? PromptFetchFn<E>
|
|
70
|
+
: EndpInfoReqType<E> extends "message"
|
|
71
|
+
? MessageEmitFn<E>
|
|
72
|
+
: never;
|
|
64
73
|
|
|
65
74
|
type PrimaryFetchType<EInfoObj extends { [key: string]: EndpointInfo }, SlceCls extends SliceCls | never> = {
|
|
66
|
-
[K in keyof EInfoObj as EndpInfoReqType<EInfoObj[K]> extends "query" | "mutation" | "message"
|
|
75
|
+
[K in keyof EInfoObj as EndpInfoReqType<EInfoObj[K]> extends "query" | "mutation" | "prompt" | "message"
|
|
67
76
|
? K
|
|
68
77
|
: never]: PrimaryFetchFn<EInfoObj[K], SlceCls>;
|
|
69
78
|
};
|