akanjs 2.2.4-rc.4 → 2.2.4
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/base/base.test.ts +135 -0
- package/base/base.ts +1 -1
- package/base/baseEnv.test.ts +146 -0
- package/base/primitiveRegistry.test.ts +127 -0
- package/base/primitiveRegistry.ts +10 -6
- package/base/symbols.test.ts +29 -0
- package/base/types.ts +4 -1
- package/base/utils.test.ts +30 -0
- package/build.ts +318 -0
- package/capacitor.base.config.test.ts +83 -0
- package/capacitor.base.config.ts +1 -1
- package/client/capacitor.ts +1 -1
- package/client/client.auth-storage.test.ts +210 -0
- package/client/client.decorators.test.ts +74 -0
- package/client/client.device.test.ts +181 -0
- package/client/client.page.test.tsx +175 -0
- package/client/client.pure.test.ts +146 -0
- package/client/client.router.test.ts +290 -0
- package/client/cookie.ts +4 -2
- package/client/createFont.ts +2 -2
- package/client/csrTypes.ts +8 -2
- package/client/makePageProto.tsx +10 -4
- package/client/router.ts +8 -3
- package/client/translator.ts +12 -4
- package/common/Logger.test.ts +45 -0
- package/common/Logger.ts +4 -1
- package/common/formatAndValidation.test.ts +61 -0
- package/common/formatNumber.ts +5 -2
- package/common/hmrPhase.ts +1 -1
- package/common/httpClient.test.ts +91 -0
- package/common/isValidDate.ts +3 -0
- package/common/objectPath.test.ts +108 -0
- package/common/routeConvention.test.ts +132 -0
- package/common/runtimeConfig.test.ts +84 -0
- package/constant/constant.test.ts +374 -0
- package/constant/fieldInfo.ts +3 -3
- package/constant/purify.ts +2 -1
- package/constant/types.ts +4 -0
- package/constant/via.ts +12 -6
- package/dictionary/dictionary.test.ts +352 -0
- package/document/databaseRegistry.ts +8 -0
- package/document/document.test.ts +698 -0
- package/document/into.ts +1 -0
- package/fetch/client/fetchClient.ts +6 -1
- package/fetch/client/httpClient.ts +2 -1
- package/fetch/fetch.test.ts +838 -0
- package/fetch/fetchType/appliedReturn.type.ts +1 -0
- package/fetch/fetchType/endpointFetch.type.ts +3 -0
- package/fetch/fetchType/sliceFetch.type.ts +8 -0
- package/fetch/requestStorage.ts +10 -2
- package/package.json +24 -67
- package/server/akanApp.test.ts +130 -0
- package/server/akanApp.ts +5 -2
- package/server/akanLib.ts +1 -0
- package/server/akanServer.test.ts +157 -0
- package/server/akanServer.ts +4 -3
- package/server/artifact/builderRpc.ts +2 -2
- package/server/artifact/ipcTypes.ts +4 -0
- package/server/artifact/routeClientCache.test.ts +265 -0
- package/server/artifact/routeSeedIndex.test.ts +56 -0
- package/server/artifact/routesManifest.test.ts +64 -0
- package/server/decorators.ts +1 -1
- package/server/di/diLifecycle.contract.test.ts +168 -0
- package/server/di/diLifecycle.ts +6 -3
- package/server/hmr/clientScript.ts +20 -2
- package/server/hmr/devHmrController.ts +4 -0
- package/server/logging/rotatingLogWriter.test.ts +119 -0
- package/server/processMetrics.test.ts +24 -0
- package/server/processMetricsCollector.ts +1 -1
- package/server/proxy/webProxyRunner.test.ts +66 -0
- package/server/resolver/database.resolver.ts +2 -2
- package/server/resolver/resolver.contract.fixture.ts +1 -0
- package/server/resolver/resolver.contract.test.ts +594 -0
- package/server/resolver/signal.resolver.ts +10 -2
- package/server/robots.test.ts +16 -0
- package/server/routeTree.test.tsx +198 -0
- package/server/routing/apiRouter.test.ts +136 -0
- package/server/routing/apiRouter.ts +4 -2
- package/server/rscClient.tsx +7 -1
- package/server/rscWorkerHost.ts +33 -11
- package/server/sitemap.test.ts +61 -0
- package/server/ssrFromRscRenderer.tsx +35 -3
- package/server/systemPages.test.tsx +93 -0
- package/server/types/react-server-dom-webpack.d.ts +7 -1
- package/server/vendor/react-dom-client.ts +1 -1
- package/server/vendor/react-dom.ts +3 -2
- package/server/vendor/react-jsx-dev-runtime.ts +1 -1
- package/server/vendor/react-jsx-runtime.ts +1 -1
- package/server/vendor/react-refresh-runtime.ts +2 -2
- package/server/vendor/react-server-dom-webpack-client-browser.ts +1 -1
- package/server/vendor/react.ts +9 -2
- package/server/vendor/scheduler.ts +3 -2
- package/server/webRouter.test.ts +49 -0
- package/server/webRouter.ts +3 -2
- package/service/adapt.ts +5 -1
- package/service/predefinedAdaptor/cache.adaptor.ts +2 -1
- package/service/predefinedAdaptor/compress.adaptor.test.ts +184 -0
- package/service/predefinedAdaptor/database.adaptor.ts +20 -8
- package/service/predefinedAdaptor/solidCache.adaptor.test.ts +107 -0
- package/service/predefinedAdaptor/solidSqlite.test.ts +457 -0
- package/service/predefinedAdaptor/solidSqlite.ts +2 -1
- package/service/predefinedAdaptor/websocket.adaptor.ts +15 -3
- package/service/serve.ts +7 -3
- package/service/service.test.ts +732 -0
- package/signal/base.signal.ts +1 -0
- package/signal/endpointInfo.ts +7 -0
- package/signal/intercept.ts +2 -0
- package/signal/middleware.ts +2 -1
- package/signal/serverSignal.ts +15 -1
- package/signal/signal.test.ts +892 -0
- package/signal/signalContext.ts +1 -1
- package/signal/signalRegistry.ts +5 -0
- package/signal/sliceInfo.ts +3 -0
- package/signal/trace.ts +11 -0
- package/signal/types.ts +11 -2
- package/store/action.ts +5 -3
- package/store/stateBuilder.test.ts +168 -0
- package/store/stateBuilder.ts +2 -0
- package/store/stateInfo.ts +2 -1
- package/store/store.test.ts +427 -0
- package/store/types.ts +1 -1
- package/test/playwright.config.base.ts +28 -5
- package/test/playwright.pageAgent.ts +1 -1
- package/test/sampleOf.ts +1 -1
- package/test/testServer.ts +1 -1
- package/tsconfig.json +5 -0
- package/ui/BottomSheet.tsx +1 -1
- package/ui/Clipboard.tsx +1 -1
- package/ui/Constant/schemaDoc.test.ts +113 -0
- package/ui/CsrImage.tsx +14 -3
- package/ui/Data/ListContainer.tsx +1 -1
- package/ui/Data/Pagination.tsx +1 -1
- package/ui/Data/QueryMaker.tsx +339 -0
- package/ui/Data/index.ts +1 -0
- package/ui/DatePicker.tsx +95 -1
- package/ui/Dialog/Modal.tsx +1 -1
- package/ui/DraggableList.tsx +5 -5
- package/ui/Field.tsx +3 -2
- package/ui/Image.tsx +3 -2
- package/ui/InfiniteScroll.test.tsx +155 -0
- package/ui/InfiniteScroll.tsx +1 -0
- package/ui/Input.tsx +8 -1
- package/ui/Layout/BottomTab.tsx +2 -2
- package/ui/Link/SsrLink.tsx +2 -1
- package/ui/Load/Page.tsx +1 -1
- package/ui/Load/PageCSR.tsx +1 -0
- package/ui/Load/Units.tsx +2 -1
- package/ui/Load/View.tsx +2 -1
- package/ui/Menu.tsx +8 -5
- package/ui/Model/EditModal.tsx +5 -2
- package/ui/Popconfirm.tsx +4 -2
- package/ui/ScreenNavigator.tsx +3 -2
- package/ui/Signal/Message.tsx +3 -2
- package/ui/Signal/PubSub.tsx +2 -0
- package/ui/Signal/Response.tsx +1 -1
- package/ui/Signal/WebSocket.tsx +11 -2
- package/ui/System/Client.tsx +41 -7
- package/ui/System/Common.test.ts +37 -0
- package/ui/System/Gtag.tsx +5 -2
- package/ui/System/Messages.tsx +2 -2
- package/ui/System/Reconnect.tsx +6 -5
- package/ui/System/Root.tsx +1 -0
- package/ui/System/SSR.tsx +7 -1
- package/ui/ToggleSelect.tsx +8 -3
- package/ui/Unauthorized.tsx +1 -1
- package/webkit/bootCsr.test.tsx +153 -0
- package/webkit/bootCsr.tsx +6 -3
- package/webkit/lazy.tsx +8 -1
- package/webkit/native.test.tsx +341 -0
- package/webkit/useCamera.tsx +1 -0
- package/webkit/useCodepush.tsx +9 -4
- package/webkit/useContact.tsx +1 -0
- package/webkit/useCsrValues.ts +10 -6
- package/webkit/useDebounce.ts +2 -2
- package/webkit/usePurchase.tsx +9 -5
- package/webkit/usePushNoti.tsx +1 -0
- package/webkit/webkit.test.tsx +531 -0
- package/types/base/base.d.ts +0 -53
- package/types/base/baseEnv.d.ts +0 -68
- package/types/base/index.d.ts +0 -6
- package/types/base/primitiveRegistry.d.ts +0 -134
- package/types/base/symbols.d.ts +0 -11
- package/types/base/types.d.ts +0 -68
- package/types/base/utils.d.ts +0 -4
- package/types/base.d.ts +0 -1
- package/types/capacitor.base.config.d.ts +0 -3
- package/types/client/capacitor.d.ts +0 -233
- package/types/client/clientRuntime.d.ts +0 -63
- package/types/client/cookie.d.ts +0 -33
- package/types/client/createFont.d.ts +0 -6
- package/types/client/csrTypes.d.ts +0 -262
- package/types/client/decorators.d.ts +0 -7
- package/types/client/device.d.ts +0 -41
- package/types/client/fetch.d.ts +0 -1
- package/types/client/index.d.ts +0 -14
- package/types/client/locale.d.ts +0 -5
- package/types/client/makePageProto.d.ts +0 -17002
- package/types/client/router.d.ts +0 -66
- package/types/client/rscNavigation.d.ts +0 -19
- package/types/client/storage.d.ts +0 -5
- package/types/client/translator.d.ts +0 -18
- package/types/client/types.d.ts +0 -145
- package/types/client/useClient.d.ts +0 -1
- package/types/client.d.ts +0 -1
- package/types/common/Logger.d.ts +0 -41
- package/types/common/applyMixins.d.ts +0 -3
- package/types/common/capitalize.d.ts +0 -2
- package/types/common/deepObjectify.d.ts +0 -4
- package/types/common/fileUpload.d.ts +0 -28
- package/types/common/formatNumber.d.ts +0 -1
- package/types/common/formatPhone.d.ts +0 -2
- package/types/common/getAllPropertyDescriptors.d.ts +0 -5
- package/types/common/hmrPhase.d.ts +0 -6
- package/types/common/httpClient.d.ts +0 -20
- package/types/common/index.d.ts +0 -29
- package/types/common/isDayjs.d.ts +0 -2
- package/types/common/isEmail.d.ts +0 -2
- package/types/common/isPhoneNumber.d.ts +0 -2
- package/types/common/isQueryEqual.d.ts +0 -1
- package/types/common/isValidDate.d.ts +0 -2
- package/types/common/jwtDecode.d.ts +0 -2
- package/types/common/localeConfig.d.ts +0 -11
- package/types/common/lowerlize.d.ts +0 -2
- package/types/common/mergeVersion.d.ts +0 -10
- package/types/common/objectify.d.ts +0 -1
- package/types/common/pathGet.d.ts +0 -1
- package/types/common/pathSet.d.ts +0 -3
- package/types/common/randomPick.d.ts +0 -1
- package/types/common/randomPicks.d.ts +0 -1
- package/types/common/routeConvention.d.ts +0 -35
- package/types/common/sleep.d.ts +0 -2
- package/types/common/splitVersion.d.ts +0 -11
- package/types/common/subRoute.d.ts +0 -7
- package/types/common/types.d.ts +0 -14
- package/types/common.d.ts +0 -1
- package/types/constant/constantRegistry.d.ts +0 -89
- package/types/constant/crystalize.d.ts +0 -4
- package/types/constant/deserialize.d.ts +0 -7
- package/types/constant/fieldInfo.d.ts +0 -153
- package/types/constant/getDefault.d.ts +0 -3
- package/types/constant/immerify.d.ts +0 -2
- package/types/constant/index.d.ts +0 -10
- package/types/constant/purify.d.ts +0 -12
- package/types/constant/serialize.d.ts +0 -11
- package/types/constant/types.d.ts +0 -77
- package/types/constant/via.d.ts +0 -52
- package/types/constant.d.ts +0 -1
- package/types/dictionary/base.dictionary.d.ts +0 -1
- package/types/dictionary/dictInfo.d.ts +0 -206
- package/types/dictionary/dictionary.d.ts +0 -11
- package/types/dictionary/index.d.ts +0 -4
- package/types/dictionary/locale.d.ts +0 -128
- package/types/dictionary/trans.d.ts +0 -82
- package/types/dictionary.d.ts +0 -1
- package/types/document/by.d.ts +0 -20
- package/types/document/dataLoader.d.ts +0 -36
- package/types/document/database.d.ts +0 -96
- package/types/document/databaseRegistry.d.ts +0 -36
- package/types/document/documentQuery.d.ts +0 -105
- package/types/document/documentSchema.d.ts +0 -33
- package/types/document/filterMeta.d.ts +0 -84
- package/types/document/index.d.ts +0 -11
- package/types/document/into.d.ts +0 -65
- package/types/document/loaderInfo.d.ts +0 -35
- package/types/document/schema.d.ts +0 -5
- package/types/document/types.d.ts +0 -36
- package/types/document.d.ts +0 -1
- package/types/fetch/client/fetchClient.d.ts +0 -78
- package/types/fetch/client/httpClient.d.ts +0 -39
- package/types/fetch/client/index.d.ts +0 -3
- package/types/fetch/client/wsClient.d.ts +0 -37
- package/types/fetch/client.d.ts +0 -1
- package/types/fetch/fetchType/appliedReturn.type.d.ts +0 -67
- package/types/fetch/fetchType/buildFetch.type.d.ts +0 -11
- package/types/fetch/fetchType/clientSignal.type.d.ts +0 -16
- package/types/fetch/fetchType/endpointFetch.type.d.ts +0 -29
- package/types/fetch/fetchType/index.d.ts +0 -5
- package/types/fetch/fetchType/sliceFetch.type.d.ts +0 -76
- package/types/fetch/fetchType.d.ts +0 -1
- package/types/fetch/index.d.ts +0 -4
- package/types/fetch/requestStorage.d.ts +0 -29
- 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/fetch/types.d.ts +0 -19
- package/types/fetch.d.ts +0 -1
- package/types/index.d.ts +0 -213
- package/types/server/akanApp.d.ts +0 -17
- package/types/server/akanAppHeaders.d.ts +0 -1
- package/types/server/akanLib.d.ts +0 -33
- package/types/server/akanOption.d.ts +0 -15
- package/types/server/akanServer.d.ts +0 -47
- package/types/server/artifact/builderRpc.d.ts +0 -42
- package/types/server/artifact/index.d.ts +0 -6
- package/types/server/artifact/ipcTypes.d.ts +0 -73
- package/types/server/artifact/manifestTypes.d.ts +0 -16
- package/types/server/artifact/routeClientCache.d.ts +0 -45
- package/types/server/artifact/routeSeedIndexStore.d.ts +0 -43
- package/types/server/artifact/routesManifestStore.d.ts +0 -16
- package/types/server/artifact.d.ts +0 -1
- package/types/server/decorators.d.ts +0 -6
- package/types/server/di/diLifecycle.d.ts +0 -45
- package/types/server/di/index.d.ts +0 -4
- package/types/server/di/predefinedAdaptor.d.ts +0 -33
- package/types/server/di/resolveAdaptorHierarchy.d.ts +0 -21
- package/types/server/di/resolveHierarchy.d.ts +0 -11
- package/types/server/di/resolveServiceHierarchy.d.ts +0 -13
- package/types/server/di/utils.d.ts +0 -14
- package/types/server/di.d.ts +0 -1
- package/types/server/hmr/changeBatch.d.ts +0 -13
- package/types/server/hmr/clientScript.d.ts +0 -1
- package/types/server/hmr/devHmrController.d.ts +0 -24
- package/types/server/hmr/index.d.ts +0 -4
- package/types/server/hmr/wsHub.d.ts +0 -45
- package/types/server/hmr.d.ts +0 -1
- package/types/server/imageOptimizer.d.ts +0 -12
- package/types/server/imageOptimizerError.d.ts +0 -4
- package/types/server/index.d.ts +0 -14
- package/types/server/lifecycle/shutdownManager.d.ts +0 -13
- package/types/server/logging/rotatingLogWriter.d.ts +0 -20
- package/types/server/processMetricsCollector.d.ts +0 -10
- package/types/server/proxy/akanResponse.d.ts +0 -7
- package/types/server/proxy/bunRequestFields.d.ts +0 -1
- package/types/server/proxy/hostBasePathWebProxy.d.ts +0 -6
- package/types/server/proxy/index.d.ts +0 -6
- package/types/server/proxy/localeWebProxy.d.ts +0 -5
- package/types/server/proxy/types.d.ts +0 -37
- package/types/server/proxy/webProxyRunner.d.ts +0 -7
- package/types/server/proxy.d.ts +0 -1
- package/types/server/resolver/database.resolver.d.ts +0 -6
- package/types/server/resolver/index.d.ts +0 -3
- package/types/server/resolver/service.resolver.d.ts +0 -7
- package/types/server/resolver/signal.resolver.d.ts +0 -29
- package/types/server/resolver.d.ts +0 -1
- package/types/server/robots.d.ts +0 -1
- package/types/server/routeElementComposer.d.ts +0 -41
- package/types/server/routeTreeBuilder.d.ts +0 -28
- package/types/server/routing/apiRouter.d.ts +0 -61
- package/types/server/rscClient.d.ts +0 -15
- package/types/server/rscWorker.d.ts +0 -3
- package/types/server/rscWorkerHost.d.ts +0 -83
- package/types/server/sitemap.d.ts +0 -13
- package/types/server/ssrFromRscRenderer.d.ts +0 -6
- package/types/server/ssrTypes.d.ts +0 -47
- package/types/server/systemPages.d.ts +0 -27
- package/types/server/types/react-server-dom-webpack.d.ts +0 -91
- package/types/server/types.d.ts +0 -67
- package/types/server/vendor/akanjs-base.d.ts +0 -1
- package/types/server/vendor/akanjs-common.d.ts +0 -1
- package/types/server/vendor/akanjs-constant.d.ts +0 -1
- package/types/server/vendor/akanjs-store.d.ts +0 -1
- package/types/server/vendor/react-dom-client.d.ts +0 -3
- package/types/server/vendor/react-dom.d.ts +0 -3
- package/types/server/vendor/react-jsx-dev-runtime.d.ts +0 -3
- package/types/server/vendor/react-jsx-runtime.d.ts +0 -3
- package/types/server/vendor/react-refresh-runtime.d.ts +0 -3
- package/types/server/vendor/react-server-dom-webpack-client-browser.d.ts +0 -3
- package/types/server/vendor/react.d.ts +0 -11
- package/types/server/vendor/scheduler.d.ts +0 -3
- package/types/server/webRouter.d.ts +0 -44
- package/types/server.d.ts +0 -1
- package/types/service/adapt.d.ts +0 -15
- package/types/service/base.service.d.ts +0 -18
- package/types/service/index.d.ts +0 -10
- package/types/service/injectInfo.d.ts +0 -102
- package/types/service/ipcTypes.d.ts +0 -194
- package/types/service/predefinedAdaptor/cache.adaptor.d.ts +0 -46
- package/types/service/predefinedAdaptor/compress.adaptor.d.ts +0 -22
- package/types/service/predefinedAdaptor/database.adaptor.d.ts +0 -329
- package/types/service/predefinedAdaptor/index.d.ts +0 -13
- package/types/service/predefinedAdaptor/logging.adaptor.d.ts +0 -20
- package/types/service/predefinedAdaptor/queue.adaptor.d.ts +0 -22
- package/types/service/predefinedAdaptor/role.adaptor.d.ts +0 -17
- package/types/service/predefinedAdaptor/schedule.adaptor.d.ts +0 -60
- package/types/service/predefinedAdaptor/solidCache.adaptor.d.ts +0 -25
- package/types/service/predefinedAdaptor/solidPubsub.adaptor.d.ts +0 -20
- package/types/service/predefinedAdaptor/solidQueue.adaptor.d.ts +0 -19
- package/types/service/predefinedAdaptor/solidSqlite.d.ts +0 -24
- package/types/service/predefinedAdaptor/sqlitePath.d.ts +0 -9
- package/types/service/predefinedAdaptor/storage.adaptor.d.ts +0 -80
- package/types/service/predefinedAdaptor/websocket.adaptor.d.ts +0 -49
- package/types/service/predefinedAdaptor.d.ts +0 -1
- package/types/service/serve.d.ts +0 -31
- package/types/service/serviceModule.d.ts +0 -50
- package/types/service/serviceRegistry.d.ts +0 -9
- package/types/service/types.d.ts +0 -55
- package/types/service.d.ts +0 -1
- package/types/signal/base.signal.d.ts +0 -41
- package/types/signal/endpoint.d.ts +0 -28
- package/types/signal/endpointInfo.d.ts +0 -77
- package/types/signal/exception.d.ts +0 -54786
- package/types/signal/guard.d.ts +0 -10
- package/types/signal/guards.d.ts +0 -10
- package/types/signal/index.d.ts +0 -19
- package/types/signal/intercept.d.ts +0 -17
- package/types/signal/internal.d.ts +0 -18
- package/types/signal/internalArg.d.ts +0 -31
- package/types/signal/internalInfo.d.ts +0 -45
- package/types/signal/middleware.d.ts +0 -51
- package/types/signal/serializer/fetch.serializer.d.ts +0 -14
- package/types/signal/serializer/index.d.ts +0 -1
- package/types/signal/serializer.d.ts +0 -1
- package/types/signal/serverSignal.d.ts +0 -36
- package/types/signal/signalContext.d.ts +0 -96
- package/types/signal/signalRegistry.d.ts +0 -49
- package/types/signal/slice.d.ts +0 -42
- package/types/signal/sliceInfo.d.ts +0 -51
- package/types/signal/trace.d.ts +0 -97
- package/types/signal/types.d.ts +0 -142
- package/types/signal.d.ts +0 -1
- package/types/store/action.d.ts +0 -145
- package/types/store/baseSt.d.ts +0 -412
- package/types/store/hooks.d.ts +0 -1
- package/types/store/index.d.ts +0 -8
- package/types/store/rootStore.d.ts +0 -22
- package/types/store/state.d.ts +0 -91
- package/types/store/stateBuilder.d.ts +0 -141
- package/types/store/stateInfo.d.ts +0 -23
- package/types/store/store.d.ts +0 -36
- package/types/store/storeInstance.d.ts +0 -38
- package/types/store/storeRegistry.d.ts +0 -13
- package/types/store/types.d.ts +0 -42
- package/types/store/withSelector.d.ts +0 -42
- package/types/store.d.ts +0 -1
- package/types/test/index.d.ts +0 -4
- package/types/test/playwright.config.base.d.ts +0 -9
- package/types/test/playwright.pageAgent.d.ts +0 -12
- package/types/test/sample.d.ts +0 -15
- package/types/test/sampleOf.d.ts +0 -5
- package/types/test/signalTest.preload.d.ts +0 -1
- package/types/test/signalTestRuntime.d.ts +0 -29
- package/types/test/testServer.d.ts +0 -26
- package/types/test.d.ts +0 -1
- package/types/ui/BottomSheet.d.ts +0 -13
- package/types/ui/Button.d.ts +0 -11
- package/types/ui/ClientSide.d.ts +0 -8
- package/types/ui/Clipboard.d.ts +0 -7
- package/types/ui/Constant/Doc.d.ts +0 -29
- package/types/ui/Constant/Mermaid.d.ts +0 -8
- package/types/ui/Constant/index.d.ts +0 -6
- package/types/ui/Constant/schemaDoc.d.ts +0 -84
- package/types/ui/Constant.d.ts +0 -1
- package/types/ui/Copy.d.ts +0 -10
- package/types/ui/CsrImage.d.ts +0 -18
- package/types/ui/Data/CardList.d.ts +0 -36
- package/types/ui/Data/Dashboard.d.ts +0 -11
- package/types/ui/Data/Insight.d.ts +0 -9
- package/types/ui/Data/Item.d.ts +0 -75
- package/types/ui/Data/ListContainer.d.ts +0 -49
- package/types/ui/Data/Pagination.d.ts +0 -9
- package/types/ui/Data/QueryMaker.d.ts +0 -8
- package/types/ui/Data/TableList.d.ts +0 -26
- package/types/ui/Data/index.d.ts +0 -9
- package/types/ui/Data/index_.d.ts +0 -8
- package/types/ui/Data.d.ts +0 -1
- package/types/ui/DatePicker.d.ts +0 -36
- package/types/ui/Dialog/Action.d.ts +0 -5
- package/types/ui/Dialog/Close.d.ts +0 -6
- package/types/ui/Dialog/Content.d.ts +0 -6
- package/types/ui/Dialog/Modal.d.ts +0 -9
- package/types/ui/Dialog/Provider.d.ts +0 -11
- package/types/ui/Dialog/Title.d.ts +0 -5
- package/types/ui/Dialog/Trigger.d.ts +0 -6
- package/types/ui/Dialog/context.d.ts +0 -10
- package/types/ui/Dialog/index.d.ts +0 -9
- package/types/ui/Dialog.d.ts +0 -1
- package/types/ui/DragAction.d.ts +0 -24
- package/types/ui/DraggableList.d.ts +0 -31
- package/types/ui/Dropdown.d.ts +0 -14
- package/types/ui/Empty.d.ts +0 -12
- package/types/ui/Field.d.ts +0 -411
- package/types/ui/FontFace.d.ts +0 -6
- package/types/ui/Image.d.ts +0 -49
- package/types/ui/InfiniteScroll.d.ts +0 -10
- package/types/ui/Input.d.ts +0 -95
- package/types/ui/KeyboardAvoiding.d.ts +0 -8
- package/types/ui/Layout/BottomAction.d.ts +0 -6
- package/types/ui/Layout/BottomInset.d.ts +0 -7
- package/types/ui/Layout/BottomTab.d.ts +0 -14
- package/types/ui/Layout/Header.d.ts +0 -8
- package/types/ui/Layout/LeftSider.d.ts +0 -9
- package/types/ui/Layout/Navbar.d.ts +0 -11
- package/types/ui/Layout/RightSider.d.ts +0 -10
- package/types/ui/Layout/Sider.d.ts +0 -7
- package/types/ui/Layout/Template.d.ts +0 -7
- package/types/ui/Layout/TopLeftAction.d.ts +0 -6
- package/types/ui/Layout/Unit.d.ts +0 -9
- package/types/ui/Layout/View.d.ts +0 -8
- package/types/ui/Layout/Zone.d.ts +0 -6
- package/types/ui/Layout/index.d.ts +0 -14
- package/types/ui/Layout.d.ts +0 -1
- package/types/ui/Link/Back.d.ts +0 -7
- package/types/ui/Link/Close.d.ts +0 -7
- package/types/ui/Link/CsrLink.d.ts +0 -2
- package/types/ui/Link/Lang.d.ts +0 -8
- package/types/ui/Link/SsrLink.d.ts +0 -2
- package/types/ui/Link/index.d.ts +0 -10
- package/types/ui/Link/types.d.ts +0 -42
- package/types/ui/Link.d.ts +0 -1
- package/types/ui/Load/Edit.d.ts +0 -4
- package/types/ui/Load/Edit_Client.d.ts +0 -27
- package/types/ui/Load/Page.d.ts +0 -15
- package/types/ui/Load/PageCSR.d.ts +0 -3
- package/types/ui/Load/Pagination.d.ts +0 -8
- package/types/ui/Load/Units.d.ts +0 -30
- package/types/ui/Load/View.d.ts +0 -22
- package/types/ui/Load/index.d.ts +0 -8
- package/types/ui/Load/index_.d.ts +0 -3
- package/types/ui/Load.d.ts +0 -1
- package/types/ui/Loading/Area.d.ts +0 -1
- package/types/ui/Loading/Button.d.ts +0 -7
- package/types/ui/Loading/Input.d.ts +0 -7
- package/types/ui/Loading/ProgressBar.d.ts +0 -6
- package/types/ui/Loading/Skeleton.d.ts +0 -7
- package/types/ui/Loading/Spin.d.ts +0 -7
- package/types/ui/Loading/index.d.ts +0 -8
- package/types/ui/Loading.d.ts +0 -1
- package/types/ui/Menu.d.ts +0 -26
- package/types/ui/Modal.d.ts +0 -19
- package/types/ui/Model/AdminPanel.d.ts +0 -31
- package/types/ui/Model/Edit.d.ts +0 -16
- package/types/ui/Model/EditModal.d.ts +0 -52
- package/types/ui/Model/EditWrapper.d.ts +0 -13
- package/types/ui/Model/LoadInit.d.ts +0 -10
- package/types/ui/Model/New.d.ts +0 -16
- package/types/ui/Model/NewWrapper.d.ts +0 -13
- package/types/ui/Model/NewWrapper_Client.d.ts +0 -13
- package/types/ui/Model/Remove.d.ts +0 -13
- package/types/ui/Model/RemoveWrapper.d.ts +0 -12
- package/types/ui/Model/SureToRemove.d.ts +0 -11
- package/types/ui/Model/View.d.ts +0 -19
- package/types/ui/Model/ViewEditModal.d.ts +0 -12
- package/types/ui/Model/ViewModal.d.ts +0 -14
- package/types/ui/Model/ViewWrapper.d.ts +0 -12
- package/types/ui/Model/index.d.ts +0 -16
- package/types/ui/Model/index_.d.ts +0 -14
- package/types/ui/Model.d.ts +0 -1
- package/types/ui/More.d.ts +0 -12
- package/types/ui/ObjectId.d.ts +0 -5
- package/types/ui/Pagination.d.ts +0 -20
- package/types/ui/Popconfirm.d.ts +0 -28
- package/types/ui/Portal.d.ts +0 -6
- package/types/ui/Radio.d.ts +0 -19
- package/types/ui/RecentTime.d.ts +0 -12
- package/types/ui/Refresh.d.ts +0 -7
- package/types/ui/ScreenNavigator.d.ts +0 -18
- package/types/ui/Select.d.ts +0 -43
- package/types/ui/Signal/Arg.d.ts +0 -78
- package/types/ui/Signal/Doc.d.ts +0 -33
- package/types/ui/Signal/Listener.d.ts +0 -9
- package/types/ui/Signal/Message.d.ts +0 -23
- package/types/ui/Signal/Object.d.ts +0 -20
- package/types/ui/Signal/PubSub.d.ts +0 -24
- package/types/ui/Signal/Request.d.ts +0 -8
- package/types/ui/Signal/Response.d.ts +0 -14
- package/types/ui/Signal/RestApi.d.ts +0 -40
- package/types/ui/Signal/WebSocket.d.ts +0 -11
- package/types/ui/Signal/index.d.ts +0 -18
- package/types/ui/Signal/makeExample.d.ts +0 -4
- package/types/ui/Signal/style.d.ts +0 -15
- package/types/ui/Signal.d.ts +0 -1
- package/types/ui/System/CSR.d.ts +0 -32
- package/types/ui/System/Client.d.ts +0 -47
- package/types/ui/System/Common.d.ts +0 -47
- package/types/ui/System/DevModeToggle.d.ts +0 -1
- package/types/ui/System/Gtag.d.ts +0 -4
- package/types/ui/System/Messages.d.ts +0 -1
- package/types/ui/System/Reconnect.d.ts +0 -1
- package/types/ui/System/Root.d.ts +0 -6
- package/types/ui/System/SSR.d.ts +0 -24
- package/types/ui/System/SelectLanguage.d.ts +0 -5
- package/types/ui/System/ThemeToggle.d.ts +0 -4
- package/types/ui/System/index.d.ts +0 -12
- package/types/ui/System.d.ts +0 -1
- package/types/ui/Tab/Menu.d.ts +0 -12
- package/types/ui/Tab/Menus.d.ts +0 -6
- package/types/ui/Tab/Panel.d.ts +0 -8
- package/types/ui/Tab/Provider.d.ts +0 -10
- package/types/ui/Tab/context.d.ts +0 -9
- package/types/ui/Tab/index.d.ts +0 -7
- package/types/ui/Tab.d.ts +0 -1
- package/types/ui/Table.d.ts +0 -41
- package/types/ui/ToggleSelect.d.ts +0 -33
- package/types/ui/Unauthorized.d.ts +0 -9
- package/types/ui/animated.d.ts +0 -5
- package/types/ui/fontCss.d.ts +0 -11
- package/types/ui/index.d.ts +0 -44
- package/types/ui.d.ts +0 -1
- package/types/webkit/bootCsr.d.ts +0 -16
- package/types/webkit/createRobotPage.d.ts +0 -15
- package/types/webkit/createSitemapPage.d.ts +0 -4
- package/types/webkit/index.d.ts +0 -17
- package/types/webkit/lazy.d.ts +0 -11
- package/types/webkit/types.d.ts +0 -7
- package/types/webkit/useCamera.d.ts +0 -19
- package/types/webkit/useCodepush.d.ts +0 -16
- package/types/webkit/useContact.d.ts +0 -11
- package/types/webkit/useCsrValues.d.ts +0 -30
- package/types/webkit/useDebounce.d.ts +0 -2
- package/types/webkit/useFetch.d.ts +0 -18
- package/types/webkit/useGeoLocation.d.ts +0 -8
- package/types/webkit/useHistory.d.ts +0 -23
- package/types/webkit/useInterval.d.ts +0 -2
- package/types/webkit/useLocation.d.ts +0 -8
- package/types/webkit/usePurchase.d.ts +0 -19
- package/types/webkit/usePushNoti.d.ts +0 -7
- package/types/webkit/useThrottle.d.ts +0 -2
- package/types/webkit.d.ts +0 -1
|
@@ -0,0 +1,374 @@
|
|
|
1
|
+
import { describe, expect, test } from "bun:test";
|
|
2
|
+
import { dayjs, enumOf, FIELD_META, ID, Int, type PrimitiveScalar } from "akanjs/base";
|
|
3
|
+
import { immerable } from "immer";
|
|
4
|
+
import { ConstantField, ConstantRegistry, deserialize, immerify, serialize, via } from ".";
|
|
5
|
+
|
|
6
|
+
const Role = enumOf("ConstantTestRole", ["admin", "user"] as const);
|
|
7
|
+
|
|
8
|
+
const CoordinateInput = via((f) => ({
|
|
9
|
+
lat: f(Int, { default: 37 }),
|
|
10
|
+
lng: f(Int, { default: 127 }),
|
|
11
|
+
}));
|
|
12
|
+
ConstantRegistry.buildScalar("constantTestCoordinate", CoordinateInput, { CoordinateInput });
|
|
13
|
+
|
|
14
|
+
const AddressInput = via((f) => ({
|
|
15
|
+
city: f(String),
|
|
16
|
+
zip: f(Int, { default: 10000 }),
|
|
17
|
+
coordinate: f(CoordinateInput),
|
|
18
|
+
}));
|
|
19
|
+
ConstantRegistry.buildScalar("constantTestAddress", AddressInput, { AddressInput });
|
|
20
|
+
|
|
21
|
+
const ComplexInput = via((f) => ({
|
|
22
|
+
settings: f(Map, { of: String }),
|
|
23
|
+
cube: f([[[[Int]]]] as never),
|
|
24
|
+
addressCube: f([[[AddressInput]]] as never),
|
|
25
|
+
primaryAddress: f(AddressInput),
|
|
26
|
+
addressBook: f(Map, { of: AddressInput as unknown as typeof PrimitiveScalar }),
|
|
27
|
+
}));
|
|
28
|
+
ConstantRegistry.buildScalar("constantTestComplex", ComplexInput, { ComplexInput });
|
|
29
|
+
|
|
30
|
+
const UserInput = via((f) => ({
|
|
31
|
+
name: f(String),
|
|
32
|
+
age: f(Int, { default: 20 }),
|
|
33
|
+
role: f(String, { default: "user" }),
|
|
34
|
+
tags: f([String]),
|
|
35
|
+
metadata: f(Map, { of: String }),
|
|
36
|
+
password: f.secret(String),
|
|
37
|
+
}));
|
|
38
|
+
const UserObject = via(UserInput, (f) => ({
|
|
39
|
+
note: f(String).optional(),
|
|
40
|
+
}));
|
|
41
|
+
const UserLight = via(UserObject, ["name", "role"] as const, (r) => ({
|
|
42
|
+
profileText: r(String, { text: "search" }),
|
|
43
|
+
}));
|
|
44
|
+
const UserFull = via(UserObject, UserLight, (r) => ({
|
|
45
|
+
addressLabel: r(String, { text: "filter" }),
|
|
46
|
+
}));
|
|
47
|
+
const UserInsight = via(UserFull, (f) => ({
|
|
48
|
+
activeCount: f(Int, { default: 0, accumulate: { role: "admin" } }),
|
|
49
|
+
}));
|
|
50
|
+
const userModel = ConstantRegistry.buildModel(
|
|
51
|
+
"constantTestUser",
|
|
52
|
+
UserInput,
|
|
53
|
+
UserObject,
|
|
54
|
+
UserFull,
|
|
55
|
+
UserLight,
|
|
56
|
+
UserInsight,
|
|
57
|
+
{ UserInput, UserObject, UserFull, UserLight, UserInsight, Role, statusLabel: "active" },
|
|
58
|
+
);
|
|
59
|
+
|
|
60
|
+
const TeamInput = via((f) => ({
|
|
61
|
+
owner: f(UserLight),
|
|
62
|
+
members: f([UserLight]),
|
|
63
|
+
}));
|
|
64
|
+
const TeamObject = via(TeamInput, (f) => ({
|
|
65
|
+
title: f(String),
|
|
66
|
+
}));
|
|
67
|
+
const TeamLight = via(TeamObject, ["owner", "members", "title"] as const, (r) => ({}));
|
|
68
|
+
const TeamFull = via(TeamObject, TeamLight, (r) => ({}));
|
|
69
|
+
const TeamInsight = via(TeamFull, (f) => ({}));
|
|
70
|
+
ConstantRegistry.buildModel("constantTestTeam", TeamInput, TeamObject, TeamFull, TeamLight, TeamInsight, {
|
|
71
|
+
TeamInput,
|
|
72
|
+
TeamObject,
|
|
73
|
+
TeamFull,
|
|
74
|
+
TeamLight,
|
|
75
|
+
TeamInsight,
|
|
76
|
+
});
|
|
77
|
+
|
|
78
|
+
const validUserId = "1234567890abcdef12345678";
|
|
79
|
+
const validChildId = "abcdefabcdefabcdefabcdef";
|
|
80
|
+
const complexInput = (input: Record<string, unknown>) => input as never;
|
|
81
|
+
|
|
82
|
+
const createUser = () =>
|
|
83
|
+
new UserFull({
|
|
84
|
+
id: validUserId,
|
|
85
|
+
name: "Ada",
|
|
86
|
+
age: 31,
|
|
87
|
+
role: "admin",
|
|
88
|
+
tags: ["founder", "engineer"],
|
|
89
|
+
metadata: { locale: "ko" } as never,
|
|
90
|
+
password: "secret",
|
|
91
|
+
note: "hello",
|
|
92
|
+
profileText: "Ada profile",
|
|
93
|
+
addressLabel: "Seoul",
|
|
94
|
+
createdAt: "2026-01-01T00:00:00.000Z" as never,
|
|
95
|
+
updatedAt: "2026-01-02T00:00:00.000Z" as never,
|
|
96
|
+
});
|
|
97
|
+
|
|
98
|
+
describe("via and ConstantField", () => {
|
|
99
|
+
test("builds field metadata and default values", () => {
|
|
100
|
+
expect(UserInput.modelType).toBe("input");
|
|
101
|
+
expect(UserObject.modelType).toBe("object");
|
|
102
|
+
expect(UserLight.modelType).toBe("light");
|
|
103
|
+
expect(UserFull.modelType).toBe("full");
|
|
104
|
+
expect(UserInsight.modelType).toBe("insight");
|
|
105
|
+
|
|
106
|
+
const nameField = UserFull[FIELD_META].name;
|
|
107
|
+
const metadataField = UserFull[FIELD_META].metadata;
|
|
108
|
+
const passwordField = UserFull[FIELD_META].password;
|
|
109
|
+
|
|
110
|
+
expect(nameField).toBeInstanceOf(ConstantField);
|
|
111
|
+
expect(nameField.modelRef).toBe(String);
|
|
112
|
+
expect(metadataField.isMap).toBe(true);
|
|
113
|
+
expect(metadataField.of).toBe(String);
|
|
114
|
+
expect(passwordField.fieldType).toBe("hidden");
|
|
115
|
+
expect(passwordField.select).toBe(false);
|
|
116
|
+
|
|
117
|
+
expect(UserFull.getDefault()).toMatchObject({
|
|
118
|
+
name: "",
|
|
119
|
+
age: 20,
|
|
120
|
+
role: "user",
|
|
121
|
+
tags: [],
|
|
122
|
+
metadata: undefined,
|
|
123
|
+
note: null,
|
|
124
|
+
addressLabel: "",
|
|
125
|
+
password: null,
|
|
126
|
+
});
|
|
127
|
+
expect(UserFull.text.search.has("profileText")).toBe(true);
|
|
128
|
+
expect(UserFull.text.filter.has("addressLabel")).toBe(true);
|
|
129
|
+
});
|
|
130
|
+
|
|
131
|
+
test("crystalizes constructor input into typed runtime values", () => {
|
|
132
|
+
const user = createUser();
|
|
133
|
+
|
|
134
|
+
expect(user.createdAt.toISOString()).toBe(dayjs("2026-01-01T00:00:00.000Z").toISOString());
|
|
135
|
+
expect(user.metadata).toBeInstanceOf(Map);
|
|
136
|
+
expect(user.metadata.get("locale")).toBe("ko");
|
|
137
|
+
|
|
138
|
+
user.set({ age: 32 });
|
|
139
|
+
|
|
140
|
+
expect(user.age).toBe(32);
|
|
141
|
+
|
|
142
|
+
const address = new AddressInput({ city: "Seoul" } as never);
|
|
143
|
+
expect(address.city).toBe("Seoul");
|
|
144
|
+
expect(address.zip).toBe(10000);
|
|
145
|
+
});
|
|
146
|
+
|
|
147
|
+
test("supports maps, deep nested objects, and high-dimensional arrays", () => {
|
|
148
|
+
const cube = [
|
|
149
|
+
[
|
|
150
|
+
[
|
|
151
|
+
[1, 2],
|
|
152
|
+
[3, 4],
|
|
153
|
+
],
|
|
154
|
+
],
|
|
155
|
+
];
|
|
156
|
+
const addressCube = [
|
|
157
|
+
[
|
|
158
|
+
[
|
|
159
|
+
{ city: "Seoul", zip: 12345, coordinate: { lat: 37, lng: 127 } },
|
|
160
|
+
{ city: "Busan", zip: 23456, coordinate: { lat: 35, lng: 129 } },
|
|
161
|
+
],
|
|
162
|
+
],
|
|
163
|
+
];
|
|
164
|
+
const complex = new ComplexInput(
|
|
165
|
+
complexInput({
|
|
166
|
+
settings: { theme: "dark", locale: "ko" } as never,
|
|
167
|
+
cube,
|
|
168
|
+
addressCube,
|
|
169
|
+
primaryAddress: { city: "Jeju", coordinate: { lat: 33, lng: 126 } },
|
|
170
|
+
addressBook: {
|
|
171
|
+
home: { city: "Seoul", zip: 12345, coordinate: { lat: 37, lng: 127 } },
|
|
172
|
+
office: { city: "Pangyo", coordinate: { lat: 37, lng: 127 } },
|
|
173
|
+
} as never,
|
|
174
|
+
}),
|
|
175
|
+
);
|
|
176
|
+
const cubeField = ComplexInput[FIELD_META].cube;
|
|
177
|
+
const addressCubeField = ComplexInput[FIELD_META].addressCube;
|
|
178
|
+
const primaryAddressField = ComplexInput[FIELD_META].primaryAddress;
|
|
179
|
+
const addressBookField = ComplexInput[FIELD_META].addressBook;
|
|
180
|
+
|
|
181
|
+
expect(cubeField.arrDepth).toBe(4);
|
|
182
|
+
expect(cubeField.modelRef).toBe(Int as unknown as typeof cubeField.modelRef);
|
|
183
|
+
expect(addressCubeField.arrDepth).toBe(3);
|
|
184
|
+
expect(addressCubeField.modelRef).toBe(AddressInput as unknown as typeof addressCubeField.modelRef);
|
|
185
|
+
expect(addressCubeField.isScalar).toBe(true);
|
|
186
|
+
expect(primaryAddressField.isClass).toBe(true);
|
|
187
|
+
expect(primaryAddressField.isScalar).toBe(true);
|
|
188
|
+
expect(addressBookField.isMap).toBe(true);
|
|
189
|
+
expect(addressBookField.of).toBe(AddressInput as unknown as typeof addressBookField.of);
|
|
190
|
+
|
|
191
|
+
const complexValue = complex as {
|
|
192
|
+
settings: Map<string, string>;
|
|
193
|
+
cube: number[][][][];
|
|
194
|
+
primaryAddress: InstanceType<typeof AddressInput>;
|
|
195
|
+
addressCube: InstanceType<typeof AddressInput>[][][];
|
|
196
|
+
addressBook: Map<string, InstanceType<typeof AddressInput>>;
|
|
197
|
+
};
|
|
198
|
+
expect(complexValue.settings).toBeInstanceOf(Map);
|
|
199
|
+
expect(complexValue.settings.get("theme")).toBe("dark");
|
|
200
|
+
expect(complexValue.cube).toEqual(cube);
|
|
201
|
+
expect(complexValue.primaryAddress).toBeInstanceOf(AddressInput);
|
|
202
|
+
expect(complexValue.primaryAddress.coordinate).toBeInstanceOf(CoordinateInput);
|
|
203
|
+
expect(complexValue.primaryAddress.zip).toBe(10000);
|
|
204
|
+
expect(complexValue.addressCube[0][0][1]).toBeInstanceOf(AddressInput);
|
|
205
|
+
expect(complexValue.addressCube[0][0][1].coordinate.lat).toBe(35);
|
|
206
|
+
expect(complexValue.addressBook).toBeInstanceOf(Map);
|
|
207
|
+
expect(complexValue.addressBook.get("office")?.zip).toBe(10000);
|
|
208
|
+
});
|
|
209
|
+
});
|
|
210
|
+
|
|
211
|
+
describe("ConstantRegistry", () => {
|
|
212
|
+
test("registers model refs and resolves model names", () => {
|
|
213
|
+
expect(ConstantRegistry.getDatabase("constantTestUser")).toBe(userModel);
|
|
214
|
+
expect(ConstantRegistry.getScalar("constantTestAddress").model).toBe(AddressInput as never);
|
|
215
|
+
expect(ConstantRegistry.getRefName(UserFull)).toBe("constantTestUser");
|
|
216
|
+
expect(ConstantRegistry.getModelName(UserInput)).toBe("ConstantTestUserInput");
|
|
217
|
+
expect(ConstantRegistry.getModelName(UserObject)).toBe("ConstantTestUserObject");
|
|
218
|
+
expect(ConstantRegistry.getModelName(UserLight)).toBe("LightConstantTestUser");
|
|
219
|
+
expect(ConstantRegistry.getModelName(UserFull)).toBe("ConstantTestUser");
|
|
220
|
+
expect(ConstantRegistry.getModelName(UserInsight)).toBe("ConstantTestUserInsight");
|
|
221
|
+
expect(ConstantRegistry.getModelName(ID)).toBe("ID");
|
|
222
|
+
expect(ConstantRegistry.value.get("statusLabel")).toBe("active");
|
|
223
|
+
});
|
|
224
|
+
|
|
225
|
+
test("serializes and deserializes primitive and model values", () => {
|
|
226
|
+
expect(ConstantRegistry.serialize(Int, 7 as never)).toBe(7 as never);
|
|
227
|
+
expect(ConstantRegistry.deserialize(Int, "7")).toBe(7 as never);
|
|
228
|
+
|
|
229
|
+
const user = createUser();
|
|
230
|
+
const serialized = ConstantRegistry.serialize(UserFull, user);
|
|
231
|
+
|
|
232
|
+
expect(serialized).toMatchObject({
|
|
233
|
+
id: validUserId,
|
|
234
|
+
name: "Ada",
|
|
235
|
+
age: 31,
|
|
236
|
+
role: "admin",
|
|
237
|
+
tags: ["founder", "engineer"],
|
|
238
|
+
metadata: { locale: "ko" },
|
|
239
|
+
});
|
|
240
|
+
expect(serialized.createdAt).toBeInstanceOf(Date);
|
|
241
|
+
|
|
242
|
+
const deserialized = ConstantRegistry.deserialize(UserFull, serialized);
|
|
243
|
+
|
|
244
|
+
expect(deserialized.createdAt.toISOString()).toBe(user.createdAt.toISOString());
|
|
245
|
+
expect(deserialized.metadata).toEqual({ locale: "ko" } as never);
|
|
246
|
+
});
|
|
247
|
+
});
|
|
248
|
+
|
|
249
|
+
describe("serialize, deserialize, purify, and immerify", () => {
|
|
250
|
+
test("handles arrays and nullable values", () => {
|
|
251
|
+
const serialized = serialize(String, 1, ["a", "b"], "object", {});
|
|
252
|
+
expect(serialized).toEqual(["a", "b"] as never);
|
|
253
|
+
expect(serialize(String, 0, null, "object", { nullable: true })).toBeNull();
|
|
254
|
+
expect(() => serialize(String, 0, null, "object", { key: "name" })).toThrow("Invalid Value (Nullable)");
|
|
255
|
+
|
|
256
|
+
expect(deserialize(String, 1, ["a", "b"], {})).toEqual(["a", "b"] as never);
|
|
257
|
+
expect(deserialize(String, 0, null, { nullable: true })).toBeNull();
|
|
258
|
+
expect(() => deserialize(String, 0, null, { key: "name" })).toThrow("Invalid Value (Nullable)");
|
|
259
|
+
});
|
|
260
|
+
|
|
261
|
+
test("serializes and deserializes complex schema shapes", () => {
|
|
262
|
+
const complex = new ComplexInput(
|
|
263
|
+
complexInput({
|
|
264
|
+
settings: { theme: "dark" } as never,
|
|
265
|
+
cube: [[[[1, 2, 3]]]],
|
|
266
|
+
addressCube: [[[{ city: "Seoul", coordinate: { lat: 37, lng: 127 } }]]],
|
|
267
|
+
primaryAddress: { city: "Jeju", coordinate: { lat: 33, lng: 126 } },
|
|
268
|
+
addressBook: {
|
|
269
|
+
home: { city: "Seoul", coordinate: { lat: 37, lng: 127 } },
|
|
270
|
+
} as never,
|
|
271
|
+
}),
|
|
272
|
+
);
|
|
273
|
+
|
|
274
|
+
const serialized = serialize(ComplexInput, 0, complex, "object", {});
|
|
275
|
+
|
|
276
|
+
expect(serialized).toMatchObject({
|
|
277
|
+
settings: { theme: "dark" },
|
|
278
|
+
cube: [[[[1, 2, 3]]]],
|
|
279
|
+
addressCube: [[[{ city: "Seoul", zip: 10000, coordinate: { lat: 37, lng: 127 } }]]],
|
|
280
|
+
primaryAddress: { city: "Jeju", zip: 10000, coordinate: { lat: 33, lng: 126 } },
|
|
281
|
+
addressBook: { home: { city: "Seoul", zip: 10000, coordinate: { lat: 37, lng: 127 } } },
|
|
282
|
+
});
|
|
283
|
+
|
|
284
|
+
const deserialized = deserialize(ComplexInput, 0, serialized, {}) as unknown as {
|
|
285
|
+
settings: Record<string, string>;
|
|
286
|
+
cube: number[][][][];
|
|
287
|
+
addressCube: { coordinate: { lat: number; lng: number } }[][][];
|
|
288
|
+
primaryAddress: { coordinate: { lng: number } };
|
|
289
|
+
addressBook: Record<string, { coordinate: { lng: number } }>;
|
|
290
|
+
};
|
|
291
|
+
|
|
292
|
+
expect(deserialized.settings).toEqual({ theme: "dark" });
|
|
293
|
+
expect(deserialized.cube).toEqual([[[[1, 2, 3]]]]);
|
|
294
|
+
expect(deserialized.addressCube[0][0][0].coordinate.lat).toBe(37);
|
|
295
|
+
expect(deserialized.primaryAddress.coordinate.lng).toBe(126);
|
|
296
|
+
expect(deserialized.addressBook.home.coordinate.lng).toBe(127);
|
|
297
|
+
});
|
|
298
|
+
|
|
299
|
+
test("preserves resolved relation objects when serializing response objects", () => {
|
|
300
|
+
const user = createUser();
|
|
301
|
+
const team = new TeamFull({
|
|
302
|
+
id: validChildId,
|
|
303
|
+
owner: user,
|
|
304
|
+
members: [user],
|
|
305
|
+
title: "Core",
|
|
306
|
+
createdAt: "2026-01-01T00:00:00.000Z" as never,
|
|
307
|
+
updatedAt: "2026-01-02T00:00:00.000Z" as never,
|
|
308
|
+
});
|
|
309
|
+
|
|
310
|
+
const objectSerialized = serialize(TeamFull, 0, team, "object", {}) as unknown as {
|
|
311
|
+
owner: { id: string; name: string };
|
|
312
|
+
members: { id: string; name: string }[];
|
|
313
|
+
};
|
|
314
|
+
const inputSerialized = serialize(TeamFull, 0, team, "input", {}) as unknown as {
|
|
315
|
+
owner: string;
|
|
316
|
+
members: string[];
|
|
317
|
+
};
|
|
318
|
+
|
|
319
|
+
expect(objectSerialized.owner).toMatchObject({ id: validUserId, name: "Ada" });
|
|
320
|
+
expect(objectSerialized.members[0]).toMatchObject({ id: validUserId, name: "Ada" });
|
|
321
|
+
expect(inputSerialized.owner).toBe(validUserId);
|
|
322
|
+
expect(inputSerialized.members).toEqual([validUserId]);
|
|
323
|
+
});
|
|
324
|
+
|
|
325
|
+
test("purifies valid input and rejects invalid values", () => {
|
|
326
|
+
const user = createUser();
|
|
327
|
+
const purified = UserFull.purify(user);
|
|
328
|
+
|
|
329
|
+
expect(purified).toMatchObject({
|
|
330
|
+
id: validUserId,
|
|
331
|
+
name: "Ada",
|
|
332
|
+
role: "admin",
|
|
333
|
+
metadata: { locale: "ko" },
|
|
334
|
+
});
|
|
335
|
+
|
|
336
|
+
expect(UserFull.purify({ ...UserFull.getDefault(), id: "bad-user" })).toBeNull();
|
|
337
|
+
expect(UserObject.purify({ id: validChildId } as never, true)).toBe(validChildId as never);
|
|
338
|
+
expect(() => UserObject.purify({} as never, true)).toThrow("Invalid Value (No ID)");
|
|
339
|
+
});
|
|
340
|
+
|
|
341
|
+
test("purifies complex schema shapes", () => {
|
|
342
|
+
const complex = new ComplexInput(
|
|
343
|
+
complexInput({
|
|
344
|
+
settings: { theme: "dark" } as never,
|
|
345
|
+
cube: [[[[1]]]],
|
|
346
|
+
addressCube: [[[{ city: "Seoul", coordinate: { lat: 37, lng: 127 } }]]],
|
|
347
|
+
primaryAddress: { city: "Jeju", coordinate: { lat: 33, lng: 126 } },
|
|
348
|
+
addressBook: {
|
|
349
|
+
home: { city: "Seoul", coordinate: { lat: 37, lng: 127 } },
|
|
350
|
+
} as never,
|
|
351
|
+
}),
|
|
352
|
+
);
|
|
353
|
+
|
|
354
|
+
expect(ComplexInput.purify(complex)).toMatchObject({
|
|
355
|
+
settings: { theme: "dark" },
|
|
356
|
+
cube: [[[[1]]]],
|
|
357
|
+
addressCube: [[[{ city: "Seoul", zip: 10000, coordinate: { lat: 37, lng: 127 } }]]],
|
|
358
|
+
primaryAddress: { city: "Jeju", zip: 10000, coordinate: { lat: 33, lng: 126 } },
|
|
359
|
+
addressBook: { home: { city: "Seoul", zip: 10000, coordinate: { lat: 37, lng: 127 } } },
|
|
360
|
+
});
|
|
361
|
+
|
|
362
|
+
expect(ComplexInput.purify({ ...ComplexInput.getDefault(), cube: [[1]] } as never)).toBeNull();
|
|
363
|
+
});
|
|
364
|
+
|
|
365
|
+
test("marks plain model objects as immerable recursively", () => {
|
|
366
|
+
const user = createUser();
|
|
367
|
+
const plain = serialize(UserFull, 0, user, "object", {}) as unknown as typeof user;
|
|
368
|
+
const immered = immerify(UserFull as never, plain);
|
|
369
|
+
|
|
370
|
+
expect((immered as unknown as Record<symbol, unknown>)[immerable]).toBe(true);
|
|
371
|
+
const address = immerify(AddressInput as never, { city: "Seoul", zip: 12345 });
|
|
372
|
+
expect((address as Record<symbol, unknown>)[immerable]).toBe(true);
|
|
373
|
+
});
|
|
374
|
+
});
|
package/constant/fieldInfo.ts
CHANGED
|
@@ -78,7 +78,7 @@ export interface ConstantFieldProps<
|
|
|
78
78
|
maxlength?: number;
|
|
79
79
|
accumulate?: any;
|
|
80
80
|
example?: FieldValue;
|
|
81
|
-
of?: MapValue;
|
|
81
|
+
of?: MapValue; // for Map type fields
|
|
82
82
|
validate?: (value: FieldValue, model: any) => boolean;
|
|
83
83
|
text?: "search" | "filter";
|
|
84
84
|
meta?: Metadata;
|
|
@@ -143,7 +143,7 @@ interface ConstantFieldBuildProps<
|
|
|
143
143
|
maxlength?: number;
|
|
144
144
|
accumulate?: any;
|
|
145
145
|
example?: FieldValue;
|
|
146
|
-
of?: MapValue;
|
|
146
|
+
of?: MapValue; // for Map type fields
|
|
147
147
|
validate?: (value: FieldValue, model: any) => boolean;
|
|
148
148
|
text?: "search" | "filter";
|
|
149
149
|
modelRef: ConstantCls;
|
|
@@ -209,7 +209,7 @@ export class ConstantField<
|
|
|
209
209
|
readonly maxlength?: number;
|
|
210
210
|
readonly accumulate?: any;
|
|
211
211
|
readonly example?: FieldValue;
|
|
212
|
-
readonly of?: MapValue;
|
|
212
|
+
readonly of?: MapValue; // for Map type fields
|
|
213
213
|
readonly validate?: (value: FieldValue, model: any) => boolean;
|
|
214
214
|
readonly text?: "search" | "filter";
|
|
215
215
|
readonly modelRef: ConstantCls;
|
package/constant/purify.ts
CHANGED
|
@@ -73,7 +73,7 @@ const purify = (
|
|
|
73
73
|
value: unknown,
|
|
74
74
|
self: Record<string, unknown>,
|
|
75
75
|
): unknown => {
|
|
76
|
-
|
|
76
|
+
// 1. Check Data Validity
|
|
77
77
|
if (
|
|
78
78
|
field.nullable &&
|
|
79
79
|
(value === null ||
|
|
@@ -147,6 +147,7 @@ const purify = (
|
|
|
147
147
|
if (!field.nullable && !value && value !== 0 && value !== false)
|
|
148
148
|
throw new Error(`Invalid Value (Nullable) in ${key} for value ${value}`);
|
|
149
149
|
|
|
150
|
+
// 2. Convert Value
|
|
150
151
|
const purifyFn = getPurifyFn(field.modelRef);
|
|
151
152
|
return purifyFn(value);
|
|
152
153
|
};
|
package/constant/types.ts
CHANGED
|
@@ -51,6 +51,7 @@ export class BaseInsight {
|
|
|
51
51
|
declare count: number;
|
|
52
52
|
}
|
|
53
53
|
|
|
54
|
+
// TODO: migrate this to shared
|
|
54
55
|
export interface ProtoFile {
|
|
55
56
|
id: string;
|
|
56
57
|
filename: string;
|
|
@@ -69,6 +70,7 @@ export interface ProtoFile {
|
|
|
69
70
|
lastModifiedAt: Dayjs;
|
|
70
71
|
}
|
|
71
72
|
|
|
73
|
+
// TODO: migrate this to shared
|
|
72
74
|
export interface ProtoAppInfo {
|
|
73
75
|
appId: string | null;
|
|
74
76
|
appName: string;
|
|
@@ -83,6 +85,7 @@ export interface ProtoAppInfo {
|
|
|
83
85
|
isEmulator: boolean | null;
|
|
84
86
|
}
|
|
85
87
|
|
|
88
|
+
// TODO: migrate this to shared
|
|
86
89
|
export interface ProtoPatch {
|
|
87
90
|
source: ProtoFile;
|
|
88
91
|
build: ProtoFile;
|
|
@@ -101,5 +104,6 @@ export type NonFunctionalKeys<T> = keyof T extends (...args: never[]) => unknown
|
|
|
101
104
|
export const unsetDate = dayjs(new Date("0000"));
|
|
102
105
|
export const MAX_INT = 2147483647;
|
|
103
106
|
|
|
107
|
+
// TODO: migrate this to akanjs/client
|
|
104
108
|
export class Responsive extends enumOf("responsive", ["xl", "lg", "md", "sm", "xs"] as const) {}
|
|
105
109
|
export const responsiveWidths = [1200, 992, 768, 576, 0] as const;
|
package/constant/via.ts
CHANGED
|
@@ -137,7 +137,7 @@ const getBaseConstantClass = (field: FieldObject, modelType: ConstantType = "sca
|
|
|
137
137
|
}
|
|
138
138
|
set(obj: Partial<typeof this>) {
|
|
139
139
|
Object.entries(obj).forEach(([key, value]) => {
|
|
140
|
-
|
|
140
|
+
//check field has key
|
|
141
141
|
if (!(this.constructor as ConstantCls)[FIELD_META][key] as unknown as object | undefined) return;
|
|
142
142
|
const field = (this.constructor as ConstantCls)[FIELD_META][key];
|
|
143
143
|
if (!field) throw new Error(`Field ${key} not found`);
|
|
@@ -179,7 +179,7 @@ export type ConstantCls<Schema = any, FieldObj extends FieldObject = FieldObject
|
|
|
179
179
|
ConstantStatics<Schema, FieldObj>;
|
|
180
180
|
|
|
181
181
|
declare global {
|
|
182
|
-
|
|
182
|
+
// dummy type matching for Date, String, Boolean, Map constructors
|
|
183
183
|
interface DateConstructor extends ConstantStatics<unknown> {}
|
|
184
184
|
interface StringConstructor extends ConstantStatics<unknown> {}
|
|
185
185
|
interface BooleanConstructor extends ConstantStatics<unknown> {}
|
|
@@ -220,6 +220,7 @@ const applyConstantStatics = <Model>(model: ConstantCls<Model>, fieldMap: FieldO
|
|
|
220
220
|
return model as unknown as ConstantCls<Model>;
|
|
221
221
|
};
|
|
222
222
|
|
|
223
|
+
// light via
|
|
223
224
|
/** Builds Akan constant models such as scalar, input, object, light, full, and insight classes. */
|
|
224
225
|
export function via<
|
|
225
226
|
Obj extends BaseObject,
|
|
@@ -238,6 +239,7 @@ export function via<
|
|
|
238
239
|
...lightModelRefs: LightModels
|
|
239
240
|
): ConstantCls<_Schema, _FieldObj>;
|
|
240
241
|
|
|
242
|
+
// input or scalar via
|
|
241
243
|
export function via<
|
|
242
244
|
BuildField extends (builder: FieldBuilder) => FieldInfoObject,
|
|
243
245
|
Inputs extends Cls[],
|
|
@@ -246,6 +248,7 @@ export function via<
|
|
|
246
248
|
FieldInfoObjectToFieldObject<ReturnType<BuildField>>,
|
|
247
249
|
>(buildField: BuildField, ...extendInputRefs: Inputs): ConstantCls<_Schema, _FieldObj>;
|
|
248
250
|
|
|
251
|
+
// insight via
|
|
249
252
|
export function via<
|
|
250
253
|
Full extends BaseObject,
|
|
251
254
|
BuildField extends (builder: FieldBuilder) => FieldInfoObject,
|
|
@@ -255,6 +258,7 @@ export function via<
|
|
|
255
258
|
FieldInfoObjectToFieldObject<ReturnType<BuildField>>,
|
|
256
259
|
>(modelRef: Cls<Full>, buildField: BuildField, ...extendInsightRefs: Insights): ConstantCls<_Schema, _FieldObj>;
|
|
257
260
|
|
|
261
|
+
// object via
|
|
258
262
|
export function via<
|
|
259
263
|
Input,
|
|
260
264
|
InputFieldObj extends FieldObject,
|
|
@@ -270,6 +274,7 @@ export function via<
|
|
|
270
274
|
...extendObjectRefs: ObjectModels
|
|
271
275
|
): ConstantCls<_Schema, _FieldObj>;
|
|
272
276
|
|
|
277
|
+
// full via
|
|
273
278
|
export function via<
|
|
274
279
|
Obj,
|
|
275
280
|
ObjFieldObj extends FieldObject,
|
|
@@ -295,7 +300,7 @@ export function via(
|
|
|
295
300
|
thirdRefOrResolveField?: Cls | ((resolve: FieldResolver) => FieldInfoObject),
|
|
296
301
|
...extendRefs: Cls[]
|
|
297
302
|
): any {
|
|
298
|
-
|
|
303
|
+
// input via
|
|
299
304
|
if (
|
|
300
305
|
!firstRefOrBuildField.prototype ||
|
|
301
306
|
!(firstRefOrBuildField as Cls<unknown, { modelType?: ConstantType }>).modelType
|
|
@@ -310,7 +315,7 @@ export function via(
|
|
|
310
315
|
if (!secondRefOrFieldsOrBuildField) return makeBaseScalar(fieldMap);
|
|
311
316
|
else return extendModelInputs(fieldMap, ...extendInputRefs);
|
|
312
317
|
}
|
|
313
|
-
|
|
318
|
+
// light via
|
|
314
319
|
if (Array.isArray(secondRefOrFieldsOrBuildField)) {
|
|
315
320
|
const resolveField = thirdRefOrResolveField as (resolve: FieldResolver) => FieldInfoObject;
|
|
316
321
|
const fieldMap = resolveField(resolve);
|
|
@@ -322,13 +327,14 @@ export function via(
|
|
|
322
327
|
);
|
|
323
328
|
}
|
|
324
329
|
|
|
330
|
+
// insight or object via
|
|
325
331
|
if (
|
|
326
332
|
!(secondRefOrFieldsOrBuildField as Cls).prototype ||
|
|
327
333
|
!(secondRefOrFieldsOrBuildField as Cls<unknown, { modelType?: ConstantType }>).modelType
|
|
328
334
|
) {
|
|
329
335
|
const buildField = secondRefOrFieldsOrBuildField as (builder: FieldBuilder) => FieldInfoObject;
|
|
330
336
|
const fieldMap = buildField(field);
|
|
331
|
-
|
|
337
|
+
// object via
|
|
332
338
|
if (ConstantRegistry.isScalar(firstRefOrBuildField as Cls<unknown, { modelType: ConstantType }>)) {
|
|
333
339
|
if (!thirdRefOrResolveField) return objectModelOf(firstRefOrBuildField as ConstantCls, fieldMap);
|
|
334
340
|
else
|
|
@@ -339,7 +345,7 @@ export function via(
|
|
|
339
345
|
...(extendRefs as ConstantCls[]),
|
|
340
346
|
);
|
|
341
347
|
}
|
|
342
|
-
|
|
348
|
+
// insight via
|
|
343
349
|
if (ConstantRegistry.isFull(firstRefOrBuildField as Cls<unknown, { modelType: ConstantType }>)) {
|
|
344
350
|
const extendInsightRefs = [
|
|
345
351
|
...(thirdRefOrResolveField ? [thirdRefOrResolveField as Cls] : []),
|