akanjs 3.0.2 → 3.1.0-rc.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +26 -0
- package/base/baseEnv.ts +0 -4
- package/base/primitiveRegistry.ts +2 -2
- package/client/cookie.ts +5 -1
- package/client/csrLocation.ts +122 -0
- package/client/csrTypes.ts +32 -4
- package/client/device.ts +2 -1
- package/client/frameConfig.ts +78 -7
- package/client/index.ts +3 -0
- package/client/makePageProto.tsx +3 -2
- package/client/native/external-view.ts +1 -0
- package/client/route/RootLayoutDefinition.ts +7 -1
- package/client/route/RouteHead.ts +108 -0
- package/client/route/index.ts +1 -0
- package/client/router.ts +36 -23
- package/client/rscNavigation.ts +8 -2
- package/client/viewportMeta.ts +60 -0
- package/client/webManifest.ts +18 -0
- package/common/Logger.ts +7 -2
- package/common/PipelineNames.ts +31 -0
- package/common/PipelinePattern.ts +70 -0
- package/common/PipelinePlanSchema.ts +490 -0
- package/common/backoff.ts +14 -0
- package/common/index.ts +39 -0
- package/common/pipelinePlan.ts +259 -0
- package/common/routeConvention.ts +1 -0
- package/common/types.ts +17 -0
- package/constant/constantRegistry.ts +26 -6
- package/dictionary/base.dictionary.ts +8 -0
- package/dictionary/trans.ts +9 -1
- package/document/into.ts +5 -0
- package/fetch/client/fetchClient.ts +135 -31
- package/fetch/client/httpClient.ts +45 -0
- package/fetch/client/wsClient.ts +125 -16
- package/fetch/fetchType/buildFetch.type.ts +1 -0
- package/index.ts +243 -10
- package/package.json +1 -5
- package/server/akanApp.ts +5 -2
- package/server/akanServer.ts +44 -8
- package/server/artifact/builderRpc.ts +8 -3
- package/server/artifact/ipcTypes.ts +5 -2
- package/server/di/diLifecycle.ts +39 -3
- package/server/di/utils.ts +28 -1
- package/server/ed25519Key.ts +48 -0
- package/server/index.ts +1 -0
- package/server/machine/index.ts +2 -0
- package/server/machine/machineAccount.ts +27 -0
- package/server/machine/machineToken.ts +151 -0
- package/server/mcp/McpApps.ts +256 -0
- package/server/mcp/McpDispatcher.ts +31 -7
- package/server/mcp/McpRouter.ts +209 -46
- package/server/ops/opsToken.ts +3 -10
- package/server/resolver/database.resolver.ts +3 -0
- package/server/resolver/signal.resolver.ts +40 -3
- package/server/routeElementComposer.tsx +78 -2
- package/server/routeState.ts +6 -0
- package/server/routeTreeBuilder.ts +26 -9
- package/server/routing/apiRouter.ts +6 -3
- package/server/routing/roomReplay.ts +88 -0
- package/server/rscClient.tsx +53 -8
- package/server/rscWorker.tsx +141 -27
- package/server/rscWorkerHost.ts +18 -5
- package/server/sitemap.ts +14 -0
- package/server/ssrFromRscRenderer.tsx +12 -6
- package/server/ssrTypes.ts +3 -1
- package/server/systemPageDocument.tsx +38 -30
- package/server/types.tsx +2 -0
- package/server/webRouter.ts +74 -5
- package/service/injectInfo.ts +9 -1
- package/service/ipcTypes.ts +2 -1
- package/service/predefinedAdaptor/database.adaptor.ts +1 -146
- package/service/predefinedAdaptor/queue.adaptor.ts +44 -6
- package/service/predefinedAdaptor/queueBackoff.ts +12 -0
- package/service/predefinedAdaptor/solidQueue.adaptor.ts +17 -13
- package/service/predefinedAdaptor/sql/SqlDocumentStore.ts +44 -2
- package/service/predefinedAdaptor/sql/dialect/postgres.ts +3 -0
- package/service/predefinedAdaptor/sql/dialect/sqlite.ts +5 -2
- package/service/predefinedAdaptor/sql/search/fts5.ts +1 -1
- package/service/predefinedAdaptor/sql/types.ts +8 -6
- package/service/predefinedAdaptor/sql/values.ts +0 -23
- package/service/serve.ts +5 -1
- package/signal/agent.signal.ts +1 -1
- package/signal/base.signal.ts +2 -2
- package/signal/endpointIdempotency.ts +53 -0
- package/signal/internalArg.ts +14 -0
- package/signal/mcp/McpDocument.ts +38 -1
- package/signal/mcp/mcpProtocol.ts +18 -0
- package/signal/signalContext.ts +58 -30
- package/signal/signalRegistry.ts +14 -4
- package/signal/types.ts +18 -3
- package/store/agent/StoreSurfaceSource.ts +1 -1
- package/store/agentic/StToolBuilder.ts +3 -0
- package/test/conformance.ts +9 -33
- package/types/base/baseEnv.d.ts +0 -4
- package/types/base/primitiveRegistry.d.ts +1 -1
- package/types/client/csrLocation.d.ts +32 -0
- package/types/client/csrTypes.d.ts +40 -4
- package/types/client/frameConfig.d.ts +14 -2
- package/types/client/index.d.ts +3 -0
- package/types/client/native/external-view.d.ts +1 -0
- package/types/client/route/RootLayoutDefinition.d.ts +2 -1
- package/types/client/route/RouteHead.d.ts +13 -0
- package/types/client/route/index.d.ts +1 -0
- package/types/client/router.d.ts +6 -0
- package/types/client/rscNavigation.d.ts +4 -0
- package/types/client/viewportMeta.d.ts +18 -0
- package/types/client/webManifest.d.ts +4 -0
- package/types/common/PipelineNames.d.ts +6 -0
- package/types/common/PipelinePattern.d.ts +14 -0
- package/types/common/PipelinePlanSchema.d.ts +9 -0
- package/types/common/backoff.d.ts +10 -0
- package/types/common/index.d.ts +5 -0
- package/types/common/pipelinePlan.d.ts +224 -0
- package/types/common/types.d.ts +16 -0
- package/types/constant/constantRegistry.d.ts +5 -2
- package/types/dictionary/base.dictionary.d.ts +1 -1
- package/types/dictionary/dictionary.d.ts +8 -8
- package/types/document/into.d.ts +9 -0
- package/types/fetch/client/fetchClient.d.ts +31 -4
- package/types/fetch/client/httpClient.d.ts +8 -0
- package/types/fetch/client/wsClient.d.ts +26 -2
- package/types/fetch/fetchType/buildFetch.type.d.ts +1 -0
- package/types/index.d.ts +230 -9
- package/types/server/akanServer.d.ts +16 -1
- package/types/server/artifact/builderRpc.d.ts +7 -2
- package/types/server/artifact/ipcTypes.d.ts +5 -1
- package/types/server/di/utils.d.ts +1 -0
- package/types/server/ed25519Key.d.ts +13 -0
- package/types/server/index.d.ts +1 -0
- package/types/server/machine/index.d.ts +2 -0
- package/types/server/machine/machineAccount.d.ts +5 -0
- package/types/server/machine/machineToken.d.ts +29 -0
- package/types/server/machine.d.ts +1 -0
- package/types/server/mcp/McpApps.d.ts +50 -0
- package/types/server/mcp/McpDispatcher.d.ts +4 -1
- package/types/server/mcp/McpRouter.d.ts +4 -0
- package/types/server/resolver/signal.resolver.d.ts +2 -1
- package/types/server/routeElementComposer.d.ts +24 -4
- package/types/server/routeState.d.ts +4 -1
- package/types/server/routing/roomReplay.d.ts +24 -0
- package/types/server/rscWorkerHost.d.ts +5 -2
- package/types/server/sitemap.d.ts +2 -0
- package/types/server/ssrFromRscRenderer.d.ts +3 -3
- package/types/server/ssrTypes.d.ts +4 -1
- package/types/server/systemPageDocument.d.ts +2 -0
- package/types/server/types.d.ts +4 -1
- package/types/server/webRouter.d.ts +3 -1
- package/types/service/ipcTypes.d.ts +2 -0
- package/types/service/predefinedAdaptor/database.adaptor.d.ts +1 -24
- package/types/service/predefinedAdaptor/queue.adaptor.d.ts +10 -3
- package/types/service/predefinedAdaptor/queueBackoff.d.ts +4 -0
- package/types/service/predefinedAdaptor/solidQueue.adaptor.d.ts +3 -3
- package/types/service/predefinedAdaptor/sql/SqlDocumentStore.d.ts +6 -1
- package/types/service/predefinedAdaptor/sql/dialect/postgres.d.ts +1 -0
- package/types/service/predefinedAdaptor/sql/dialect/sqlite.d.ts +1 -0
- package/types/service/predefinedAdaptor/sql/search/fts5.d.ts +1 -1
- package/types/service/predefinedAdaptor/sql/types.d.ts +9 -5
- package/types/service/predefinedAdaptor/sql/values.d.ts +0 -3
- package/types/service/serve.d.ts +3 -0
- package/types/signal/endpointIdempotency.d.ts +7 -0
- package/types/signal/internalArg.d.ts +10 -0
- package/types/signal/mcp/McpDocument.d.ts +8 -0
- package/types/signal/mcp/mcpProtocol.d.ts +17 -0
- package/types/signal/signalContext.d.ts +5 -3
- package/types/signal/signalRegistry.d.ts +4 -4
- package/types/signal/types.d.ts +21 -1
- package/types/store/agentic/StToolBuilder.d.ts +2 -0
- package/types/test/conformance.d.ts +7 -10
- package/types/ui/Agent/Chat.d.ts +5 -1
- package/types/ui/Agent/EmbedApproval.d.ts +1 -0
- package/types/ui/Agent/index.d.ts +3 -0
- package/types/ui/Agent/useKeyboardFrame.d.ts +2 -0
- package/types/ui/Agent/useScreenActions.d.ts +18 -0
- package/types/ui/BottomSheet.d.ts +1 -0
- package/types/ui/Constant/Doc.d.ts +11 -17
- package/types/ui/Constant/index.d.ts +7 -2
- package/types/ui/Constant/schemaDoc.d.ts +11 -0
- package/types/ui/Dialog/Modal.d.ts +6 -1
- package/types/ui/Dialog/index.d.ts +1 -1
- package/types/ui/Dialog/modalSurface.d.ts +12 -0
- package/types/ui/Layout/BottomTab.d.ts +11 -2
- package/types/ui/Layout/FrameSlotFallback.d.ts +9 -0
- package/types/ui/Layout/Navbar.d.ts +4 -1
- package/types/ui/Layout/TopInset.d.ts +1 -1
- package/types/ui/Layout/index.d.ts +3 -3
- package/types/ui/Link/Action.d.ts +5 -1
- package/types/ui/Link/Anchor.d.ts +5 -3
- package/types/ui/Link/activePath.d.ts +13 -0
- package/types/ui/Link/index.d.ts +1 -1
- package/types/ui/Modal.d.ts +6 -1
- package/types/ui/Model/EditModal.d.ts +6 -1
- package/types/ui/Model/New.d.ts +6 -1
- package/types/ui/Model/ViewEditModal.d.ts +6 -1
- package/types/ui/Model/ViewModal.d.ts +6 -1
- package/types/ui/Model/newFormOrigin.d.ts +7 -0
- package/types/ui/Portal.d.ts +3 -1
- package/types/ui/Reference/origin.d.ts +12 -0
- package/types/ui/Signal/Doc.d.ts +23 -18
- package/types/ui/Signal/Listener.d.ts +2 -6
- package/types/ui/Signal/Object.d.ts +6 -10
- package/types/ui/Signal/Response.d.ts +3 -6
- package/types/ui/Signal/RestApi.d.ts +11 -15
- package/types/ui/Signal/WebSocket.d.ts +11 -21
- package/types/ui/Signal/endpointEntries.d.ts +8 -0
- package/types/ui/Signal/index.d.ts +35 -12
- package/types/ui/Signal/signalText.d.ts +178 -0
- package/types/ui/System/CSR.d.ts +2 -2
- package/types/ui/System/Client.d.ts +4 -3
- package/types/ui/System/Common.d.ts +27 -6
- package/types/ui/System/SSR.d.ts +6 -6
- package/types/ui/Tooltip.d.ts +4 -2
- package/types/ui/index.d.ts +2 -1
- package/types/ui/overlayLayer.d.ts +6 -0
- package/types/ui/overlayPosition.d.ts +17 -0
- package/types/vendor/@akanjs/native/packages/cli/src/api.d.ts +14 -3
- package/types/vendor/@akanjs/native/packages/cli/src/commands/update.d.ts +1 -1
- package/types/vendor/@akanjs/native/packages/cli/src/config.d.ts +30 -5
- package/types/vendor/@akanjs/native/packages/cli/src/lib/compat.d.ts +8 -0
- package/types/vendor/@akanjs/native/packages/cli/src/lib/desktop-server.d.ts +5 -0
- package/types/vendor/@akanjs/native/packages/cli/src/lib/distribution.d.ts +22 -0
- package/types/vendor/@akanjs/native/packages/cli/src/lib/project.d.ts +4 -0
- package/types/vendor/@akanjs/native/packages/cli/src/lib/publish.d.ts +16 -10
- package/types/vendor/@akanjs/native/packages/cli/src/lib/updates.d.ts +51 -7
- package/types/vendor/@akanjs/native/packages/cli/src/lib/vectors.d.ts +1 -1
- package/types/vendor/@akanjs/native/packages/cli/src/platforms/windows-installer.d.ts +7 -0
- package/types/vendor/@akanjs/native/packages/cli/src/platforms/windows.d.ts +5 -0
- package/types/vendor/@akanjs/native/packages/core/src/kernel.d.ts +36 -0
- package/types/vendor/@akanjs/native/packages/desktop/src/plugin.d.ts +2 -0
- package/types/vendor/@akanjs/native/packages/desktop/src/server.d.ts +11 -0
- package/types/vendor/@akanjs/native/plugins/external-view/src/desktop.d.ts +17 -0
- package/types/vendor/@akanjs/native/plugins/external-view/src/index.d.ts +132 -0
- package/types/vendor/@akanjs/native/plugins/external-view/src.d.ts +1 -0
- package/types/vendor/@akanjs/native/plugins/updates/src/index.d.ts +8 -0
- package/types/vendor/@akanjs/native/plugins/window/src/desktop.d.ts +4 -1
- package/types/vendor/@akanjs/native/plugins/window/src/index.d.ts +49 -0
- package/types/vendor/use-agentic/types.d.ts +2 -0
- package/types/webkit/CsrStack.d.ts +1 -1
- package/types/webkit/McpAppAgent.d.ts +14 -0
- package/types/webkit/McpAppApprovals.d.ts +8 -0
- package/types/webkit/McpAppBridge.d.ts +101 -0
- package/types/webkit/McpAppView.d.ts +21 -0
- package/types/webkit/index.d.ts +1 -0
- package/types/webkit/useLocation.d.ts +1 -1
- package/types/webkit/useVisualViewportFrame.d.ts +13 -0
- package/ui/Agent/Chat.tsx +29 -10
- package/ui/Agent/Composer.tsx +2 -1
- package/ui/Agent/EmbedApproval.tsx +17 -0
- package/ui/Agent/RichInput.tsx +1 -1
- package/ui/Agent/index.ts +2 -0
- package/ui/Agent/useKeyboardFrame.ts +10 -0
- package/ui/Agent/useScreenActions.ts +45 -0
- package/ui/BottomSheet.tsx +82 -53
- package/ui/Constant/Doc.tsx +113 -60
- package/ui/Constant/index.ts +2 -2
- package/ui/Constant/schemaDoc.ts +86 -26
- package/ui/Dialog/LegacyModal.tsx +53 -52
- package/ui/Dialog/Modal.tsx +93 -49
- package/ui/Dialog/modalSurface.ts +61 -0
- package/ui/DragAction.tsx +1 -1
- package/ui/DraggableList.tsx +1 -1
- package/ui/Dropdown.tsx +4 -6
- package/ui/KeyboardAvoiding.tsx +1 -1
- package/ui/Layout/BottomInset.tsx +20 -14
- package/ui/Layout/BottomTab.tsx +42 -16
- package/ui/Layout/FrameSlotFallback.tsx +59 -0
- package/ui/Layout/Navbar.tsx +37 -11
- package/ui/Layout/Sider.tsx +1 -1
- package/ui/Layout/TopInset.tsx +15 -14
- package/ui/Link/Action.tsx +15 -5
- package/ui/Link/Anchor.tsx +25 -13
- package/ui/Link/activePath.ts +25 -0
- package/ui/Link/index.tsx +1 -1
- package/ui/Load/Pagination.tsx +1 -1
- package/ui/Load/Units.tsx +1 -1
- package/ui/Loading/ProgressBar.tsx +1 -1
- package/ui/Modal.tsx +9 -0
- package/ui/Model/EditModal.tsx +16 -1
- package/ui/Model/New.tsx +25 -2
- package/ui/Model/NewWrapper_Client.tsx +2 -0
- package/ui/Model/ViewEditModal.tsx +9 -0
- package/ui/Model/ViewModal.tsx +16 -1
- package/ui/Model/newFormOrigin.ts +45 -0
- package/ui/Popconfirm.tsx +5 -7
- package/ui/Portal.tsx +4 -7
- package/ui/Reference/origin.ts +31 -0
- package/ui/ScreenNavigator.tsx +1 -1
- package/ui/Select.tsx +2 -7
- package/ui/Signal/Arg.tsx +2 -2
- package/ui/Signal/Doc.tsx +125 -63
- package/ui/Signal/Endpoint.tsx +11 -10
- package/ui/Signal/Listener.tsx +7 -10
- package/ui/Signal/Object.tsx +7 -14
- package/ui/Signal/Response.tsx +24 -24
- package/ui/Signal/RestApi.tsx +63 -52
- package/ui/Signal/WebSocket.tsx +65 -72
- package/ui/Signal/endpointEntries.ts +25 -0
- package/ui/Signal/index.ts +23 -6
- package/ui/Signal/signalText.ts +59 -0
- package/ui/System/CSR.tsx +34 -8
- package/ui/System/Client.tsx +36 -5
- package/ui/System/Common.tsx +76 -32
- package/ui/System/SSR.tsx +73 -31
- package/ui/Toast.tsx +1 -1
- package/ui/Tooltip.tsx +84 -30
- package/ui/index.ts +11 -1
- package/ui/overlayLayer.ts +25 -2
- package/ui/overlayPosition.ts +90 -0
- package/ui/recipe/inputRecipe.ts +8 -1
- package/ui/styles.css +152 -0
- package/vendor/@akanjs/native/native/android/src/com/akanjs/runtime/AkanNativeActivity.kt +22 -2
- package/vendor/@akanjs/native/native/android/src/com/akanjs/runtime/AkanNativeKernel.kt +37 -0
- package/vendor/@akanjs/native/native/android/src/com/akanjs/runtime/AkanNativeUpdateReports.kt +169 -0
- package/vendor/@akanjs/native/native/android/src/com/akanjs/runtime/AkanNativeUpdates.kt +110 -38
- package/vendor/@akanjs/native/native/android/src/com/akanjs/runtime/AkanNativeVectors.kt +20 -0
- package/vendor/@akanjs/native/native/desktop/Cargo.lock +16 -16
- package/vendor/@akanjs/native/native/desktop/src/external.rs +651 -0
- package/vendor/@akanjs/native/native/desktop/src/json.rs +23 -0
- package/vendor/@akanjs/native/native/desktop/src/lib.rs +228 -5
- package/vendor/@akanjs/native/native/ios/Sources/AkanNativeApp.swift +2 -1
- package/vendor/@akanjs/native/native/ios/Sources/AkanNativeKernel.swift +47 -1
- package/vendor/@akanjs/native/native/ios/Sources/AkanNativeUpdateReports.swift +145 -0
- package/vendor/@akanjs/native/native/ios/Sources/AkanNativeUpdates.swift +112 -43
- package/vendor/@akanjs/native/native/ios/Sources/AkanNativeVectors.swift +18 -0
- package/vendor/@akanjs/native/native/ios/Sources/AkanNativeViewController.swift +24 -2
- package/vendor/@akanjs/native/packages/cli/src/api.ts +22 -6
- package/vendor/@akanjs/native/packages/cli/src/commands/build.ts +24 -8
- package/vendor/@akanjs/native/packages/cli/src/commands/update.ts +11 -9
- package/vendor/@akanjs/native/packages/cli/src/config.ts +35 -7
- package/vendor/@akanjs/native/packages/cli/src/lib/compat.ts +2 -0
- package/vendor/@akanjs/native/packages/cli/src/lib/configkeys.ts +6 -4
- package/vendor/@akanjs/native/packages/cli/src/lib/desktop-server.ts +11 -1
- package/vendor/@akanjs/native/packages/cli/src/lib/distribution.ts +73 -0
- package/vendor/@akanjs/native/packages/cli/src/lib/project.ts +15 -3
- package/vendor/@akanjs/native/packages/cli/src/lib/publish.ts +70 -23
- package/vendor/@akanjs/native/packages/cli/src/lib/updates.ts +159 -23
- package/vendor/@akanjs/native/packages/cli/src/lib/vectors.ts +2 -0
- package/vendor/@akanjs/native/packages/cli/src/platforms/android.ts +9 -4
- package/vendor/@akanjs/native/packages/cli/src/platforms/desktop-update.ts +1 -1
- package/vendor/@akanjs/native/packages/cli/src/platforms/desktop.ts +4 -2
- package/vendor/@akanjs/native/packages/cli/src/platforms/ios.ts +9 -4
- package/vendor/@akanjs/native/packages/cli/src/platforms/windows-installer.ts +25 -11
- package/vendor/@akanjs/native/packages/cli/src/platforms/windows.ts +14 -3
- package/vendor/@akanjs/native/packages/core/src/kernel.ts +49 -0
- package/vendor/@akanjs/native/packages/core/vectors/updates.json +31 -0
- package/vendor/@akanjs/native/packages/desktop/src/main.ts +3 -0
- package/vendor/@akanjs/native/packages/desktop/src/plugin.ts +2 -0
- package/vendor/@akanjs/native/packages/desktop/src/server.ts +70 -6
- package/vendor/@akanjs/native/plugins/external-view/native-plugin.json +23 -0
- package/vendor/@akanjs/native/plugins/external-view/src/desktop.ts +321 -0
- package/vendor/@akanjs/native/plugins/external-view/src/index.ts +106 -0
- package/vendor/@akanjs/native/plugins/updates/android/UpdatesPlugin.kt +133 -41
- package/vendor/@akanjs/native/plugins/updates/ios/UpdatesPlugin.swift +101 -36
- package/vendor/@akanjs/native/plugins/updates/native-plugin.json +4 -2
- package/vendor/@akanjs/native/plugins/updates/src/desktop.ts +15 -1
- package/vendor/@akanjs/native/plugins/updates/src/index.ts +7 -1
- package/vendor/@akanjs/native/plugins/window/native-plugin.json +4 -0
- package/vendor/@akanjs/native/plugins/window/src/desktop.ts +68 -1
- package/vendor/@akanjs/native/plugins/window/src/index.ts +47 -0
- package/vendor/use-agentic/ToolRunner.ts +8 -1
- package/vendor/use-agentic/types.ts +2 -0
- package/webkit/CsrRouteTable.ts +1 -0
- package/webkit/CsrStack.ts +9 -2
- package/webkit/McpAppAgent.ts +138 -0
- package/webkit/McpAppApprovals.ts +56 -0
- package/webkit/McpAppBridge.ts +291 -0
- package/webkit/McpAppView.ts +258 -0
- package/webkit/bootCsr.tsx +54 -5
- package/webkit/index.ts +1 -0
- package/webkit/useCsrValues.ts +16 -10
- package/webkit/useFrameRuntime.ts +10 -1
- package/webkit/useLocation.ts +4 -3
- package/webkit/useVisualViewportFrame.tsx +52 -0
- package/service/predefinedAdaptor/sql/driver/libsql.ts +0 -45
- package/types/service/predefinedAdaptor/sql/driver/libsql.d.ts +0 -20
- package/types/ui/Agent/useKeyboardInset.d.ts +0 -1
- package/types/ui/ServerPortal.d.ts +0 -15
- package/ui/Agent/useKeyboardInset.ts +0 -19
- package/ui/ServerPortal.tsx +0 -49
package/ui/BottomSheet.tsx
CHANGED
|
@@ -1,19 +1,21 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { useDrag } from "@use-gesture/react";
|
|
3
3
|
import { cn } from "akanjs/client";
|
|
4
|
-
import {
|
|
5
|
-
import { animated } from "akanjs/ui";
|
|
6
|
-
import { useEscapeKey } from "akanjs/webkit";
|
|
4
|
+
import { useBodyScrollLock, useEscapeKey } from "akanjs/webkit";
|
|
7
5
|
import { forwardRef, type ReactNode, useEffect, useImperativeHandle, useRef, useState } from "react";
|
|
6
|
+
import { createPortal } from "react-dom";
|
|
8
7
|
import { BiX } from "react-icons/bi";
|
|
9
8
|
import { config, useSpring } from "react-spring";
|
|
9
|
+
import { animated } from "./animated";
|
|
10
10
|
import { buttonRecipe } from "./Button";
|
|
11
|
+
import { overlayZ, useOverlayLayerProps, useOverlayPortal } from "./overlayLayer";
|
|
11
12
|
|
|
12
13
|
interface BottomSheetProps {
|
|
13
14
|
className?: string;
|
|
14
15
|
bodyClassName?: string;
|
|
15
16
|
/** Left out, the sheet opens from its own trigger and handle. */
|
|
16
17
|
open?: boolean;
|
|
18
|
+
/** Called once when the person dismisses the sheet: the backdrop, Escape, a drag down, or the close button. */
|
|
17
19
|
onCancel?: () => void;
|
|
18
20
|
trigger?: ReactNode;
|
|
19
21
|
/** Whole top row of the sheet, replacing the drag handle or the close row. */
|
|
@@ -50,44 +52,51 @@ export const BottomSheet = forwardRef<BottomSheetRef, BottomSheetProps>(
|
|
|
50
52
|
bottomSheetRef,
|
|
51
53
|
) => {
|
|
52
54
|
const ref = useRef<HTMLDivElement>(null);
|
|
53
|
-
const
|
|
55
|
+
const shown = useRef(false);
|
|
56
|
+
const portal = useOverlayPortal();
|
|
57
|
+
const overlayLayerProps = useOverlayLayerProps();
|
|
54
58
|
const [selfOpen, setSelfOpen] = useState(false);
|
|
55
59
|
const isOpen = open ?? selfOpen;
|
|
56
60
|
|
|
57
61
|
const [{ y, opacity }, api] = useSpring(() => ({ y: OFFSCREEN, opacity: 0 }));
|
|
58
62
|
|
|
59
|
-
const
|
|
60
|
-
|
|
63
|
+
const show = async () => {
|
|
64
|
+
shown.current = true;
|
|
61
65
|
await Promise.all(api.start({ y: 0, opacity: 1, immediate: false, config: config.default }));
|
|
62
66
|
};
|
|
63
|
-
const
|
|
67
|
+
const hide = async () => {
|
|
64
68
|
const height = ref.current?.clientHeight ?? OFFSCREEN;
|
|
65
69
|
await Promise.all(
|
|
66
70
|
api.start({ y: height, opacity: 0, immediate: false, config: { ...config.stiff, velocity: 0 } }),
|
|
67
71
|
);
|
|
68
|
-
|
|
72
|
+
};
|
|
73
|
+
|
|
74
|
+
const dismiss = () => {
|
|
75
|
+
if (open === undefined) setSelfOpen(false);
|
|
69
76
|
onCancel?.();
|
|
70
77
|
};
|
|
71
78
|
|
|
72
79
|
const bind = useDrag(({ down, movement: [, my] }) => {
|
|
73
80
|
const height = ref.current?.clientHeight ?? OFFSCREEN;
|
|
74
81
|
if (down) void api.start({ y: Math.max(0, my), immediate: true });
|
|
75
|
-
else if (my > height / 3)
|
|
76
|
-
else void
|
|
82
|
+
else if (my > height / 3) dismiss();
|
|
83
|
+
else void show();
|
|
77
84
|
});
|
|
78
85
|
|
|
79
86
|
useImperativeHandle(bottomSheetRef, () => ({
|
|
80
|
-
open:
|
|
81
|
-
|
|
87
|
+
open: () => {
|
|
88
|
+
setSelfOpen(true);
|
|
89
|
+
void show();
|
|
90
|
+
},
|
|
91
|
+
close: dismiss,
|
|
82
92
|
}));
|
|
83
93
|
|
|
84
|
-
useEscapeKey(isOpen,
|
|
85
|
-
|
|
86
|
-
});
|
|
94
|
+
useEscapeKey(isOpen, dismiss);
|
|
95
|
+
useBodyScrollLock(isOpen);
|
|
87
96
|
|
|
88
97
|
useEffect(() => {
|
|
89
|
-
if (isOpen) void
|
|
90
|
-
else void
|
|
98
|
+
if (isOpen) void show();
|
|
99
|
+
else if (shown.current) void hide();
|
|
91
100
|
}, [isOpen]);
|
|
92
101
|
|
|
93
102
|
return (
|
|
@@ -102,43 +111,63 @@ export const BottomSheet = forwardRef<BottomSheetRef, BottomSheetProps>(
|
|
|
102
111
|
{trigger}
|
|
103
112
|
</div>
|
|
104
113
|
) : null}
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
</animated.div>
|
|
125
|
-
) : (
|
|
126
|
-
<div className="flex shrink-0 justify-end p-2" style={{ paddingTop: pageState.topSafeArea }}>
|
|
127
|
-
<div className="contents" onClick={() => void closeModal()}>
|
|
128
|
-
{close ?? (
|
|
129
|
-
<button
|
|
130
|
-
aria-label="Close"
|
|
131
|
-
className={buttonRecipe({ variant: "ghost", size: "icon" }, "rounded-full text-foreground/50")}
|
|
132
|
-
type="button"
|
|
133
|
-
>
|
|
134
|
-
<BiX className="text-2xl" />
|
|
135
|
-
</button>
|
|
114
|
+
{portal
|
|
115
|
+
? createPortal(
|
|
116
|
+
<>
|
|
117
|
+
<animated.div
|
|
118
|
+
{...overlayLayerProps}
|
|
119
|
+
style={{ opacity, zIndex: overlayZ.modal, pointerEvents: isOpen ? "auto" : "none" }}
|
|
120
|
+
onClick={dismiss}
|
|
121
|
+
className="fixed inset-0 bg-black/50 backdrop-blur-sm"
|
|
122
|
+
/>
|
|
123
|
+
<animated.div
|
|
124
|
+
{...overlayLayerProps}
|
|
125
|
+
ref={ref}
|
|
126
|
+
style={{ y, zIndex: overlayZ.modal }}
|
|
127
|
+
className={cn(
|
|
128
|
+
"fixed bottom-0 left-0 flex w-full flex-col bg-card text-card-foreground",
|
|
129
|
+
type === "half" && "h-[90dvh] rounded-t-box border-border border-t shadow-2xl",
|
|
130
|
+
type === "full" &&
|
|
131
|
+
"h-[100dvh] pt-[max(var(--akan-top-safe-area,0px),env(safe-area-inset-top,0px))]",
|
|
132
|
+
className,
|
|
136
133
|
)}
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
134
|
+
>
|
|
135
|
+
{header ??
|
|
136
|
+
(type === "half" ? (
|
|
137
|
+
<animated.div {...bind()} className="flex shrink-0 cursor-grab touch-pan-y justify-center py-3">
|
|
138
|
+
{handle ?? <div className="h-1 w-10 rounded-full bg-foreground/15" />}
|
|
139
|
+
</animated.div>
|
|
140
|
+
) : (
|
|
141
|
+
<div className="flex shrink-0 justify-end p-2">
|
|
142
|
+
<div className="contents" onClick={dismiss}>
|
|
143
|
+
{close ?? (
|
|
144
|
+
<button
|
|
145
|
+
aria-label="Close"
|
|
146
|
+
className={buttonRecipe(
|
|
147
|
+
{ variant: "ghost", size: "icon" },
|
|
148
|
+
"rounded-full text-foreground/50",
|
|
149
|
+
)}
|
|
150
|
+
type="button"
|
|
151
|
+
>
|
|
152
|
+
<BiX className="text-2xl" />
|
|
153
|
+
</button>
|
|
154
|
+
)}
|
|
155
|
+
</div>
|
|
156
|
+
</div>
|
|
157
|
+
))}
|
|
158
|
+
<div
|
|
159
|
+
className={cn(
|
|
160
|
+
"scrollbar-thin min-h-0 flex-1 overflow-y-auto px-4 pb-[calc(1rem+max(var(--akan-bottom-safe-area,0px),env(safe-area-inset-bottom,0px)))]",
|
|
161
|
+
bodyClassName,
|
|
162
|
+
)}
|
|
163
|
+
>
|
|
164
|
+
{children}
|
|
165
|
+
</div>
|
|
166
|
+
</animated.div>
|
|
167
|
+
</>,
|
|
168
|
+
portal,
|
|
169
|
+
)
|
|
170
|
+
: null}
|
|
142
171
|
</>
|
|
143
172
|
);
|
|
144
173
|
},
|
package/ui/Constant/Doc.tsx
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
import { usePage } from "akanjs/client";
|
|
4
4
|
import { capitalize } from "akanjs/common";
|
|
5
|
-
import { useMemo, useState } from "react";
|
|
5
|
+
import { Fragment, useMemo, useState } from "react";
|
|
6
6
|
import { AiOutlineInfoCircle, AiOutlineSearch } from "react-icons/ai";
|
|
7
7
|
import { BiNetworkChart, BiTable } from "react-icons/bi";
|
|
8
8
|
|
|
@@ -24,12 +24,16 @@ import {
|
|
|
24
24
|
SummaryGrid,
|
|
25
25
|
Toolbar,
|
|
26
26
|
} from "../Reference";
|
|
27
|
+
import { originText, ownerOf } from "../Reference/origin";
|
|
27
28
|
import { Graph } from "./Graph";
|
|
28
29
|
import {
|
|
30
|
+
type ConstantSchemaOptions,
|
|
29
31
|
type DatabaseModelVariant,
|
|
30
32
|
type DatabaseSchema,
|
|
31
33
|
databaseModelVariants,
|
|
34
|
+
type EnumSchema,
|
|
32
35
|
type FieldSchema,
|
|
36
|
+
getConstantOwnerOrder,
|
|
33
37
|
getConstantSchemaDoc,
|
|
34
38
|
getDefaultVariant,
|
|
35
39
|
getVariantTitle,
|
|
@@ -37,10 +41,6 @@ import {
|
|
|
37
41
|
} from "./schemaDoc";
|
|
38
42
|
import type { SchemaGraphEdge, SchemaGraphNode, SchemaNodeKind } from "./schemaGraph";
|
|
39
43
|
|
|
40
|
-
export default function Doc() {
|
|
41
|
-
return <div />;
|
|
42
|
-
}
|
|
43
|
-
|
|
44
44
|
const docText = {
|
|
45
45
|
pageTitle: { en: "Constant Schema Docs", ko: "Constant 스키마 문서" },
|
|
46
46
|
printTitle: { en: "Constant Schema Definition", ko: "Constant 스키마 정의서" },
|
|
@@ -77,6 +77,7 @@ const docText = {
|
|
|
77
77
|
selectedModel: { en: "Selected Model", ko: "선택한 모델" },
|
|
78
78
|
external: { en: "External", ko: "외부" },
|
|
79
79
|
selectNode: { en: "Select a node in the diagram.", ko: "다이어그램에서 노드를 선택하세요." },
|
|
80
|
+
unknownOrigin: { en: "Unknown library", ko: "출처 미상" },
|
|
80
81
|
} as const;
|
|
81
82
|
|
|
82
83
|
const fieldCountText = (count: number) => ({ en: `${count} fields`, ko: `필드 ${count}개` });
|
|
@@ -97,16 +98,17 @@ const headsOf = (l: ReturnType<typeof usePage>["l"], keys: (keyof typeof docText
|
|
|
97
98
|
|
|
98
99
|
const printTable = "print:overflow-visible print:rounded-none print:border-0";
|
|
99
100
|
|
|
100
|
-
interface ZoneProps {
|
|
101
|
-
models?: string[];
|
|
102
|
-
scalars?: string[];
|
|
103
|
-
enums?: string[];
|
|
101
|
+
export interface ZoneProps extends ConstantSchemaOptions {
|
|
104
102
|
openAll?: boolean;
|
|
103
|
+
groupBy?: "lib";
|
|
105
104
|
}
|
|
106
105
|
|
|
107
|
-
const Zone = ({ models, scalars, enums, openAll }: ZoneProps) => {
|
|
106
|
+
export const Zone = ({ models, scalars, enums, include, exclude, libs, openAll, groupBy }: ZoneProps) => {
|
|
108
107
|
const { l } = usePage();
|
|
109
|
-
const schemaDoc = useMemo(
|
|
108
|
+
const schemaDoc = useMemo(
|
|
109
|
+
() => getConstantSchemaDoc({ models, scalars, enums, include, exclude, libs }),
|
|
110
|
+
[models, scalars, enums, include, exclude, libs],
|
|
111
|
+
);
|
|
110
112
|
const viewItems = [
|
|
111
113
|
{ key: "table", label: l.trans(docText.table), icon: <BiTable /> },
|
|
112
114
|
{ key: "diagram", label: l.trans(docText.diagram), icon: <BiNetworkChart /> },
|
|
@@ -128,6 +130,19 @@ const Zone = ({ models, scalars, enums, openAll }: ZoneProps) => {
|
|
|
128
130
|
),
|
|
129
131
|
[schemaDoc.enums, query],
|
|
130
132
|
);
|
|
133
|
+
const groups = useMemo(() => {
|
|
134
|
+
const owners = groupBy === "lib" ? [...getConstantOwnerOrder(), ""] : [null];
|
|
135
|
+
const inGroup = (owner: string | null) => (entry: { origin: string[] }) =>
|
|
136
|
+
owner === null || (ownerOf(entry.origin) ?? "") === owner;
|
|
137
|
+
return owners
|
|
138
|
+
.map((owner) => ({
|
|
139
|
+
owner,
|
|
140
|
+
databases: filteredDatabases.filter(inGroup(owner)),
|
|
141
|
+
scalars: filteredScalars.filter(inGroup(owner)),
|
|
142
|
+
enums: filteredEnums.filter(inGroup(owner)),
|
|
143
|
+
}))
|
|
144
|
+
.filter((group) => group.owner === null || group.databases.length + group.scalars.length + group.enums.length);
|
|
145
|
+
}, [groupBy, filteredDatabases, filteredScalars, filteredEnums]);
|
|
131
146
|
return (
|
|
132
147
|
<div className="flex break-after-page flex-col gap-6">
|
|
133
148
|
<div className="flex flex-col gap-1">
|
|
@@ -152,45 +167,81 @@ const Zone = ({ models, scalars, enums, openAll }: ZoneProps) => {
|
|
|
152
167
|
/>
|
|
153
168
|
<Segmented className="ml-auto" items={viewItems} onChange={setViewMode} value={viewMode} />
|
|
154
169
|
</Toolbar>
|
|
155
|
-
{
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
<
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
) : null}
|
|
179
|
-
{filteredEnums.length ? (
|
|
180
|
-
<Section title={l.trans(docText.enums)}>
|
|
181
|
-
<EnumList enums={filteredEnums} />
|
|
182
|
-
</Section>
|
|
183
|
-
) : null}
|
|
184
|
-
</div>
|
|
185
|
-
)}
|
|
170
|
+
{groups.map(({ owner, databases, scalars: groupScalars, enums: groupEnums }) => {
|
|
171
|
+
const body =
|
|
172
|
+
viewMode === "diagram" ? (
|
|
173
|
+
<Diagram databases={databases} scalars={groupScalars} />
|
|
174
|
+
) : (
|
|
175
|
+
<SchemaTables
|
|
176
|
+
databases={databases}
|
|
177
|
+
scalars={groupScalars}
|
|
178
|
+
enums={groupEnums}
|
|
179
|
+
openAll={openAll}
|
|
180
|
+
showEmpty={owner === null}
|
|
181
|
+
/>
|
|
182
|
+
);
|
|
183
|
+
if (owner === null) return <Fragment key="all">{body}</Fragment>;
|
|
184
|
+
return (
|
|
185
|
+
<section className="flex flex-col gap-4" key={owner}>
|
|
186
|
+
<h2 className="border-border border-b pb-2 font-bold font-mono text-2xl">
|
|
187
|
+
{owner || l.trans(docText.unknownOrigin)}
|
|
188
|
+
</h2>
|
|
189
|
+
{body}
|
|
190
|
+
</section>
|
|
191
|
+
);
|
|
192
|
+
})}
|
|
186
193
|
</div>
|
|
187
194
|
);
|
|
188
195
|
};
|
|
189
|
-
Doc.Zone = Zone;
|
|
190
196
|
|
|
191
|
-
|
|
197
|
+
interface SchemaTablesProps {
|
|
198
|
+
databases: DatabaseSchema[];
|
|
199
|
+
scalars: ScalarSchema[];
|
|
200
|
+
enums: EnumSchema[];
|
|
201
|
+
openAll?: boolean;
|
|
202
|
+
showEmpty: boolean;
|
|
203
|
+
}
|
|
204
|
+
const SchemaTables = ({ databases, scalars, enums, openAll, showEmpty }: SchemaTablesProps) => {
|
|
192
205
|
const { l } = usePage();
|
|
193
|
-
|
|
206
|
+
return (
|
|
207
|
+
<div className="flex flex-col gap-6">
|
|
208
|
+
{databases.length || showEmpty ? (
|
|
209
|
+
<Section title={l.trans(docText.databaseModels)}>
|
|
210
|
+
{databases.length ? (
|
|
211
|
+
<div className="flex flex-col gap-2">
|
|
212
|
+
{databases.map((database) => (
|
|
213
|
+
<Model key={database.refName} database={database} openAll={openAll} />
|
|
214
|
+
))}
|
|
215
|
+
</div>
|
|
216
|
+
) : (
|
|
217
|
+
<div className={docUi.emptyPanel}>{l.trans(docText.noDatabaseMatch)}</div>
|
|
218
|
+
)}
|
|
219
|
+
</Section>
|
|
220
|
+
) : null}
|
|
221
|
+
{scalars.length ? (
|
|
222
|
+
<Section title={l.trans(docText.scalarModels)}>
|
|
223
|
+
<div className="flex flex-col gap-2">
|
|
224
|
+
{scalars.map((scalar) => (
|
|
225
|
+
<Scalar key={scalar.refName} scalar={scalar} openAll={openAll} />
|
|
226
|
+
))}
|
|
227
|
+
</div>
|
|
228
|
+
</Section>
|
|
229
|
+
) : null}
|
|
230
|
+
{enums.length ? (
|
|
231
|
+
<Section title={l.trans(docText.enums)}>
|
|
232
|
+
<EnumList enums={enums} />
|
|
233
|
+
</Section>
|
|
234
|
+
) : null}
|
|
235
|
+
</div>
|
|
236
|
+
);
|
|
237
|
+
};
|
|
238
|
+
|
|
239
|
+
export const Print = ({ models, scalars, enums, include, exclude, libs }: ZoneProps) => {
|
|
240
|
+
const { l } = usePage();
|
|
241
|
+
const schemaDoc = useMemo(
|
|
242
|
+
() => getConstantSchemaDoc({ models, scalars, enums, include, exclude, libs }),
|
|
243
|
+
[models, scalars, enums, include, exclude, libs],
|
|
244
|
+
);
|
|
194
245
|
return (
|
|
195
246
|
<div className="flex flex-col gap-10 bg-background text-foreground print:bg-white print:text-black">
|
|
196
247
|
<div className="break-after-page">
|
|
@@ -223,17 +274,17 @@ const Print = ({ models, scalars, enums }: ZoneProps) => {
|
|
|
223
274
|
</div>
|
|
224
275
|
);
|
|
225
276
|
};
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
interface ModelProps {
|
|
277
|
+
export interface ModelProps {
|
|
229
278
|
refName?: string;
|
|
230
279
|
database?: DatabaseSchema;
|
|
231
280
|
openAll?: boolean;
|
|
232
281
|
}
|
|
233
282
|
|
|
234
|
-
const Model = ({ refName, database: databaseProp, openAll }: ModelProps) => {
|
|
283
|
+
export const Model = ({ refName, database: databaseProp, openAll }: ModelProps) => {
|
|
235
284
|
const database = useMemo(
|
|
236
|
-
() =>
|
|
285
|
+
() =>
|
|
286
|
+
databaseProp ??
|
|
287
|
+
getConstantSchemaDoc({ models: refName ? [refName] : [], scalars: [], enums: [] }).databases.at(0),
|
|
237
288
|
[databaseProp, refName],
|
|
238
289
|
);
|
|
239
290
|
const [variant, setVariant] = useState<DatabaseModelVariant>("full");
|
|
@@ -248,6 +299,9 @@ const Model = ({ refName, database: databaseProp, openAll }: ModelProps) => {
|
|
|
248
299
|
<div className="flex flex-wrap items-center gap-2">
|
|
249
300
|
<span className="font-bold text-lg">{database.modelName}</span>
|
|
250
301
|
<span className={docPill("info", "font-mono")}>{database.refName}</span>
|
|
302
|
+
{database.origin.length ? (
|
|
303
|
+
<span className={docPill("muted", "font-mono")}>{l.trans(originText(database.origin))}</span>
|
|
304
|
+
) : null}
|
|
251
305
|
</div>
|
|
252
306
|
<div className="text-foreground/55 text-sm">{l._(`${database.refName}.modelDesc`)}</div>
|
|
253
307
|
</div>
|
|
@@ -258,17 +312,16 @@ const Model = ({ refName, database: databaseProp, openAll }: ModelProps) => {
|
|
|
258
312
|
</Collapse>
|
|
259
313
|
);
|
|
260
314
|
};
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
interface ScalarProps {
|
|
315
|
+
export interface ScalarProps {
|
|
264
316
|
refName?: string;
|
|
265
317
|
scalar?: ScalarSchema;
|
|
266
318
|
openAll?: boolean;
|
|
267
319
|
}
|
|
268
320
|
|
|
269
|
-
const Scalar = ({ refName, scalar: scalarProp, openAll }: ScalarProps) => {
|
|
321
|
+
export const Scalar = ({ refName, scalar: scalarProp, openAll }: ScalarProps) => {
|
|
270
322
|
const scalar = useMemo(
|
|
271
|
-
() =>
|
|
323
|
+
() =>
|
|
324
|
+
scalarProp ?? getConstantSchemaDoc({ models: [], scalars: refName ? [refName] : [], enums: [] }).scalars.at(0),
|
|
272
325
|
[scalarProp, refName],
|
|
273
326
|
);
|
|
274
327
|
const { l } = usePage();
|
|
@@ -281,6 +334,9 @@ const Scalar = ({ refName, scalar: scalarProp, openAll }: ScalarProps) => {
|
|
|
281
334
|
<div className="flex flex-wrap items-center gap-2">
|
|
282
335
|
<span className="font-bold text-lg">{scalar.modelName}</span>
|
|
283
336
|
<span className={docPill("muted", "font-mono")}>{scalar.refName}</span>
|
|
337
|
+
{scalar.origin.length ? (
|
|
338
|
+
<span className={docPill("muted", "font-mono")}>{l.trans(originText(scalar.origin))}</span>
|
|
339
|
+
) : null}
|
|
284
340
|
</div>
|
|
285
341
|
<div className="text-foreground/55 text-sm">{l._(`${scalar.refName}.modelDesc`)}</div>
|
|
286
342
|
</div>
|
|
@@ -290,13 +346,11 @@ const Scalar = ({ refName, scalar: scalarProp, openAll }: ScalarProps) => {
|
|
|
290
346
|
</Collapse>
|
|
291
347
|
);
|
|
292
348
|
};
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
interface EnumProps {
|
|
349
|
+
export interface EnumProps {
|
|
296
350
|
enums?: ReturnType<typeof getConstantSchemaDoc>["enums"];
|
|
297
351
|
}
|
|
298
352
|
|
|
299
|
-
const EnumList = ({ enums = getConstantSchemaDoc().enums }: EnumProps) => {
|
|
353
|
+
export const EnumList = ({ enums = getConstantSchemaDoc().enums }: EnumProps) => {
|
|
300
354
|
const { l } = usePage();
|
|
301
355
|
return (
|
|
302
356
|
<DocTable head={headsOf(l, ["enum", "type", "values", "usedBy"])}>
|
|
@@ -343,7 +397,6 @@ const EnumList = ({ enums = getConstantSchemaDoc().enums }: EnumProps) => {
|
|
|
343
397
|
</DocTable>
|
|
344
398
|
);
|
|
345
399
|
};
|
|
346
|
-
Doc.Enum = EnumList;
|
|
347
400
|
|
|
348
401
|
const ModelVariantTable = ({ variant }: { variant: ReturnType<typeof getDefaultVariant> }) => {
|
|
349
402
|
const { l } = usePage();
|
package/ui/Constant/index.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { EnumList, Model, Print, Scalar, Zone } from "./Doc";
|
|
2
2
|
import { Graph } from "./Graph";
|
|
3
3
|
|
|
4
4
|
export * from "./schemaDoc";
|
|
5
5
|
export * from "./schemaGraph";
|
|
6
6
|
|
|
7
|
-
export const Constant = { Doc, Graph };
|
|
7
|
+
export const Constant = { Doc: { Zone, Print, Model, Scalar, Enum: EnumList }, Graph };
|
package/ui/Constant/schemaDoc.ts
CHANGED
|
@@ -11,17 +11,26 @@ import {
|
|
|
11
11
|
type ConstantCls,
|
|
12
12
|
type ConstantField,
|
|
13
13
|
type ConstantModel,
|
|
14
|
+
type ConstantOriginKind,
|
|
14
15
|
ConstantRegistry,
|
|
15
16
|
type TextFieldRole,
|
|
16
17
|
} from "akanjs/constant";
|
|
18
|
+
import { ownerOf, ownerOrderOf } from "../Reference/origin";
|
|
17
19
|
|
|
18
20
|
export const databaseModelVariants = ["input", "object", "full", "light", "insight"] as const;
|
|
19
21
|
export type DatabaseModelVariant = (typeof databaseModelVariants)[number];
|
|
20
22
|
|
|
23
|
+
/**
|
|
24
|
+
* `undefined` is "every registered one" and `[]` is "none". Once any option narrows the scope, scalars default to
|
|
25
|
+
* the ones the shown models embed and enums to the ones the shown models and scalars use.
|
|
26
|
+
*/
|
|
21
27
|
export interface ConstantSchemaOptions {
|
|
22
28
|
models?: string[];
|
|
23
29
|
scalars?: string[];
|
|
24
30
|
enums?: string[];
|
|
31
|
+
include?: string[];
|
|
32
|
+
exclude?: string[];
|
|
33
|
+
libs?: string[];
|
|
25
34
|
}
|
|
26
35
|
|
|
27
36
|
export interface ConstantSchemaDoc {
|
|
@@ -34,6 +43,7 @@ export interface ConstantSchemaDoc {
|
|
|
34
43
|
export interface DatabaseSchema {
|
|
35
44
|
kind: "database";
|
|
36
45
|
refName: string;
|
|
46
|
+
origin: string[];
|
|
37
47
|
modelName: string;
|
|
38
48
|
variants: Record<DatabaseModelVariant, ModelVariantSchema>;
|
|
39
49
|
}
|
|
@@ -41,6 +51,7 @@ export interface DatabaseSchema {
|
|
|
41
51
|
export interface ScalarSchema {
|
|
42
52
|
kind: "scalar";
|
|
43
53
|
refName: string;
|
|
54
|
+
origin: string[];
|
|
44
55
|
modelName: string;
|
|
45
56
|
modelRef: ConstantCls;
|
|
46
57
|
fields: FieldSchema[];
|
|
@@ -57,6 +68,7 @@ export interface ModelVariantSchema {
|
|
|
57
68
|
export interface EnumSchema {
|
|
58
69
|
key: string;
|
|
59
70
|
refName: string;
|
|
71
|
+
origin: string[];
|
|
60
72
|
typeName: string;
|
|
61
73
|
values: (string | number)[];
|
|
62
74
|
enumRef: EnumInstance;
|
|
@@ -105,33 +117,80 @@ export interface FieldSchema {
|
|
|
105
117
|
}
|
|
106
118
|
|
|
107
119
|
export const getConstantSchemaDoc = (options: ConstantSchemaOptions = {}): ConstantSchemaDoc => {
|
|
108
|
-
const
|
|
109
|
-
|
|
110
|
-
)
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
120
|
+
const { models, scalars: scalarKeys, enums: enumKeys, include, exclude, libs } = options;
|
|
121
|
+
const isScoped = [models, scalarKeys, enumKeys, include, exclude, libs].some((option) => option !== undefined);
|
|
122
|
+
const keeps = (kind: ConstantOriginKind) => (key: string) =>
|
|
123
|
+
!exclude?.includes(key) && (!libs || libs.includes(ownerOf(ConstantRegistry.getOrigin(kind, key)) ?? ""));
|
|
124
|
+
const isRoot = (key: string) => keeps("database")(key) && (!include || include.includes(key));
|
|
125
|
+
const databases = selectKeys(ConstantRegistry.database, models)
|
|
126
|
+
.filter(isRoot)
|
|
127
|
+
.map((refName) => buildDatabaseSchema(refName, ConstantRegistry.getDatabase(refName)));
|
|
128
|
+
const scalars = (
|
|
129
|
+
scalarKeys !== undefined
|
|
130
|
+
? selectKeys(ConstantRegistry.scalar, scalarKeys).filter(keeps("scalar"))
|
|
131
|
+
: isScoped
|
|
132
|
+
? collectEmbeddedScalars(
|
|
133
|
+
databases,
|
|
134
|
+
include ? selectKeys(ConstantRegistry.scalar, include).filter(keeps("scalar")) : [],
|
|
135
|
+
keeps("scalar"),
|
|
136
|
+
)
|
|
137
|
+
: selectKeys(ConstantRegistry.scalar)
|
|
138
|
+
).map(buildScalarSchema);
|
|
122
139
|
const enumUsages = collectEnumUsages(databases, scalars);
|
|
123
|
-
const enums =
|
|
140
|
+
const enums = selectKeys(ConstantRegistry.enum, enumKeys)
|
|
141
|
+
.filter(keeps("enum"))
|
|
142
|
+
.map((key) => buildEnumSchema(key, enumUsages))
|
|
143
|
+
.filter((enumSchema) => enumKeys !== undefined || !isScoped || enumSchema.usedBy.length);
|
|
144
|
+
const relations = collectRelations(databases, scalars);
|
|
145
|
+
return { databases, scalars, enums, relations };
|
|
146
|
+
};
|
|
147
|
+
|
|
148
|
+
const buildScalarSchema = (refName: string): ScalarSchema => {
|
|
149
|
+
const modelRef = ConstantRegistry.getScalar(refName).model;
|
|
150
|
+
return {
|
|
151
|
+
kind: "scalar",
|
|
152
|
+
refName,
|
|
153
|
+
origin: ConstantRegistry.getOrigin("scalar", refName),
|
|
154
|
+
modelName: getModelName(modelRef, refName),
|
|
155
|
+
modelRef,
|
|
156
|
+
fields: getFields(modelRef, "scalar"),
|
|
157
|
+
};
|
|
158
|
+
};
|
|
159
|
+
|
|
160
|
+
const buildEnumSchema = (key: string, enumUsages: Map<EnumInstance, EnumUsage[]>): EnumSchema => {
|
|
161
|
+
const enumRef = ConstantRegistry.enum.get(key) as EnumInstance;
|
|
162
|
+
return {
|
|
124
163
|
key,
|
|
125
164
|
refName: enumRef.refName,
|
|
165
|
+
origin: ConstantRegistry.getOrigin("enum", key),
|
|
126
166
|
typeName: PrimitiveRegistry.getName(enumRef.type as typeof PrimitiveScalar),
|
|
127
167
|
values: [...enumRef.values] as (string | number)[],
|
|
128
168
|
enumRef,
|
|
129
169
|
usedBy: enumUsages.get(enumRef) ?? [],
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
|
|
170
|
+
};
|
|
171
|
+
};
|
|
172
|
+
|
|
173
|
+
const collectEmbeddedScalars = (
|
|
174
|
+
databases: DatabaseSchema[],
|
|
175
|
+
rootScalars: string[],
|
|
176
|
+
isKept: (key: string) => boolean,
|
|
177
|
+
) => {
|
|
178
|
+
const found = new Set(rootScalars);
|
|
179
|
+
const visit = (fields: FieldSchema[]) => {
|
|
180
|
+
for (const field of fields) {
|
|
181
|
+
const refName = field.typeRefName;
|
|
182
|
+
if (!refName || found.has(refName) || !isKept(refName) || !ConstantRegistry.scalar.has(refName)) continue;
|
|
183
|
+
found.add(refName);
|
|
184
|
+
visit(getFields(ConstantRegistry.getScalar(refName).model, "scalar"));
|
|
185
|
+
}
|
|
186
|
+
};
|
|
187
|
+
for (const database of databases) for (const variant of Object.values(database.variants)) visit(variant.fields);
|
|
188
|
+
for (const refName of rootScalars) visit(getFields(ConstantRegistry.getScalar(refName).model, "scalar"));
|
|
189
|
+
return [...found].sort((a, b) => a.localeCompare(b));
|
|
133
190
|
};
|
|
134
191
|
|
|
192
|
+
export const getConstantOwnerOrder = () => ownerOrderOf([...ConstantRegistry.origin.values()]);
|
|
193
|
+
|
|
135
194
|
export const getDefaultVariant = (database: DatabaseSchema): ModelVariantSchema => database.variants.full;
|
|
136
195
|
|
|
137
196
|
export const getVariantTitle = (variant: DatabaseModelVariant | "scalar") => {
|
|
@@ -155,7 +214,13 @@ const buildDatabaseSchema = (refName: string, model: ConstantModel): DatabaseSch
|
|
|
155
214
|
];
|
|
156
215
|
}),
|
|
157
216
|
) as Record<DatabaseModelVariant, ModelVariantSchema>;
|
|
158
|
-
return {
|
|
217
|
+
return {
|
|
218
|
+
kind: "database",
|
|
219
|
+
refName,
|
|
220
|
+
origin: ConstantRegistry.getOrigin("database", refName),
|
|
221
|
+
modelName: ConstantRegistry.getModelName(model.full),
|
|
222
|
+
variants,
|
|
223
|
+
};
|
|
159
224
|
};
|
|
160
225
|
|
|
161
226
|
const getFields = (modelRef: ConstantCls, variant: DatabaseModelVariant | "scalar"): FieldSchema[] =>
|
|
@@ -265,13 +330,8 @@ const getConstraints = (props: ReturnType<ConstantField["getProps"]>) =>
|
|
|
265
330
|
props.accumulate ? "accumulate" : null,
|
|
266
331
|
].filter((constraint): constraint is string => !!constraint);
|
|
267
332
|
|
|
268
|
-
const
|
|
269
|
-
|
|
270
|
-
return selected.flatMap((key) => {
|
|
271
|
-
const value = map.get(key);
|
|
272
|
-
return value ? ([[key, value]] as [string, Value][]) : [];
|
|
273
|
-
});
|
|
274
|
-
};
|
|
333
|
+
const selectKeys = (map: Map<string, unknown>, selected?: string[]) =>
|
|
334
|
+
selected ? selected.filter((key) => map.has(key)) : [...map.keys()].sort((a, b) => a.localeCompare(b));
|
|
275
335
|
|
|
276
336
|
const collectEnumUsages = (databases: DatabaseSchema[], scalars: ScalarSchema[]) => {
|
|
277
337
|
const usages = new Map<EnumInstance, EnumUsage[]>();
|