akanjs 2.2.4 → 2.2.5
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 +9 -0
- package/base/base.ts +1 -1
- package/base/primitiveRegistry.ts +6 -10
- package/base/types.ts +1 -4
- package/capacitor.base.config.ts +1 -1
- package/client/capacitor.ts +1 -1
- package/client/cookie.ts +2 -4
- package/client/createFont.ts +2 -2
- package/client/csrTypes.ts +2 -8
- package/client/makePageProto.tsx +4 -10
- package/client/router.ts +3 -8
- package/client/translator.ts +4 -12
- package/common/Logger.ts +1 -4
- package/common/formatNumber.ts +2 -5
- package/common/hmrPhase.ts +1 -1
- package/common/isValidDate.ts +0 -3
- package/constant/fieldInfo.ts +3 -3
- package/constant/purify.ts +1 -2
- package/constant/types.ts +0 -4
- package/constant/via.ts +6 -12
- package/document/databaseRegistry.ts +0 -8
- package/document/into.ts +0 -1
- package/fetch/client/fetchClient.ts +1 -6
- package/fetch/client/httpClient.ts +1 -2
- package/fetch/fetchType/appliedReturn.type.ts +0 -1
- package/fetch/fetchType/endpointFetch.type.ts +0 -3
- package/fetch/fetchType/sliceFetch.type.ts +0 -8
- package/fetch/requestStorage.ts +2 -10
- package/package.json +67 -24
- package/server/akanApp.ts +2 -5
- package/server/akanLib.ts +0 -1
- package/server/akanServer.ts +3 -4
- package/server/artifact/builderRpc.ts +2 -2
- package/server/artifact/ipcTypes.ts +0 -4
- package/server/decorators.ts +1 -1
- package/server/di/diLifecycle.ts +3 -6
- package/server/hmr/clientScript.ts +2 -20
- package/server/hmr/devHmrController.ts +0 -4
- package/server/processMetricsCollector.ts +1 -1
- package/server/resolver/database.resolver.ts +2 -2
- package/server/resolver/resolver.contract.fixture.ts +0 -1
- package/server/resolver/signal.resolver.ts +2 -10
- package/server/routing/apiRouter.ts +2 -4
- package/server/rscClient.tsx +1 -7
- package/server/rscWorkerHost.ts +11 -33
- package/server/ssrFromRscRenderer.tsx +3 -35
- package/server/types/react-server-dom-webpack.d.ts +1 -7
- package/server/vendor/react-dom-client.ts +1 -1
- package/server/vendor/react-dom.ts +2 -3
- 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 +2 -9
- package/server/vendor/scheduler.ts +2 -3
- package/server/webRouter.ts +2 -3
- package/service/adapt.ts +1 -5
- package/service/predefinedAdaptor/cache.adaptor.ts +1 -2
- package/service/predefinedAdaptor/database.adaptor.ts +2 -2
- package/service/predefinedAdaptor/solidSqlite.ts +1 -2
- package/service/predefinedAdaptor/websocket.adaptor.ts +3 -15
- package/service/serve.ts +3 -7
- package/signal/base.signal.ts +0 -1
- package/signal/endpointInfo.ts +0 -7
- package/signal/intercept.ts +0 -2
- package/signal/middleware.ts +1 -2
- package/signal/serverSignal.ts +1 -15
- package/signal/signalContext.ts +1 -1
- package/signal/signalRegistry.ts +0 -5
- package/signal/sliceInfo.ts +0 -3
- package/signal/trace.ts +0 -11
- package/signal/types.ts +2 -11
- package/store/action.ts +3 -5
- package/store/stateBuilder.ts +0 -2
- package/store/stateInfo.ts +1 -2
- package/store/types.ts +1 -1
- package/test/playwright.config.base.ts +5 -28
- package/test/playwright.pageAgent.ts +1 -1
- package/test/sampleOf.ts +1 -1
- package/test/testServer.ts +1 -1
- package/types/base/base.d.ts +53 -0
- package/types/base/baseEnv.d.ts +68 -0
- package/types/base/index.d.ts +6 -0
- package/types/base/primitiveRegistry.d.ts +134 -0
- package/types/base/symbols.d.ts +11 -0
- package/types/base/types.d.ts +68 -0
- package/types/base/utils.d.ts +4 -0
- package/types/base.d.ts +1 -0
- package/types/capacitor.base.config.d.ts +3 -0
- package/types/client/capacitor.d.ts +233 -0
- package/types/client/clientRuntime.d.ts +63 -0
- package/types/client/cookie.d.ts +33 -0
- package/types/client/createFont.d.ts +6 -0
- package/types/client/csrTypes.d.ts +262 -0
- package/types/client/decorators.d.ts +7 -0
- package/types/client/device.d.ts +41 -0
- package/types/client/fetch.d.ts +1 -0
- package/types/client/index.d.ts +14 -0
- package/types/client/locale.d.ts +5 -0
- package/types/client/makePageProto.d.ts +17002 -0
- package/types/client/router.d.ts +66 -0
- package/types/client/rscNavigation.d.ts +19 -0
- package/types/client/storage.d.ts +5 -0
- package/types/client/translator.d.ts +18 -0
- package/types/client/types.d.ts +145 -0
- package/types/client/useClient.d.ts +1 -0
- package/types/client.d.ts +1 -0
- package/types/common/Logger.d.ts +41 -0
- package/types/common/applyMixins.d.ts +3 -0
- package/types/common/capitalize.d.ts +2 -0
- package/types/common/deepObjectify.d.ts +4 -0
- package/types/common/fileUpload.d.ts +28 -0
- package/types/common/formatNumber.d.ts +1 -0
- package/types/common/formatPhone.d.ts +2 -0
- package/types/common/getAllPropertyDescriptors.d.ts +5 -0
- package/types/common/hmrPhase.d.ts +6 -0
- package/types/common/httpClient.d.ts +20 -0
- package/types/common/index.d.ts +29 -0
- package/types/common/isDayjs.d.ts +2 -0
- package/types/common/isEmail.d.ts +2 -0
- package/types/common/isPhoneNumber.d.ts +2 -0
- package/types/common/isQueryEqual.d.ts +1 -0
- package/types/common/isValidDate.d.ts +2 -0
- package/types/common/jwtDecode.d.ts +2 -0
- package/types/common/localeConfig.d.ts +11 -0
- package/types/common/lowerlize.d.ts +2 -0
- package/types/common/mergeVersion.d.ts +10 -0
- package/types/common/objectify.d.ts +1 -0
- package/types/common/pathGet.d.ts +1 -0
- package/types/common/pathSet.d.ts +3 -0
- package/types/common/randomPick.d.ts +1 -0
- package/types/common/randomPicks.d.ts +1 -0
- package/types/common/routeConvention.d.ts +35 -0
- package/types/common/sleep.d.ts +2 -0
- package/types/common/splitVersion.d.ts +11 -0
- package/types/common/subRoute.d.ts +7 -0
- package/types/common/types.d.ts +14 -0
- package/types/common.d.ts +1 -0
- package/types/constant/constantRegistry.d.ts +89 -0
- package/types/constant/crystalize.d.ts +4 -0
- package/types/constant/deserialize.d.ts +7 -0
- package/types/constant/fieldInfo.d.ts +153 -0
- package/types/constant/getDefault.d.ts +3 -0
- package/types/constant/immerify.d.ts +2 -0
- package/types/constant/index.d.ts +10 -0
- package/types/constant/purify.d.ts +12 -0
- package/types/constant/serialize.d.ts +11 -0
- package/types/constant/types.d.ts +77 -0
- package/types/constant/via.d.ts +52 -0
- package/types/constant.d.ts +1 -0
- package/types/dictionary/base.dictionary.d.ts +1 -0
- package/types/dictionary/dictInfo.d.ts +206 -0
- package/types/dictionary/dictionary.d.ts +11 -0
- package/types/dictionary/index.d.ts +4 -0
- package/types/dictionary/locale.d.ts +128 -0
- package/types/dictionary/trans.d.ts +82 -0
- package/types/dictionary.d.ts +1 -0
- package/types/document/by.d.ts +20 -0
- package/types/document/dataLoader.d.ts +36 -0
- package/types/document/database.d.ts +96 -0
- package/types/document/databaseRegistry.d.ts +36 -0
- package/types/document/documentQuery.d.ts +105 -0
- package/types/document/documentSchema.d.ts +33 -0
- package/types/document/filterMeta.d.ts +84 -0
- package/types/document/index.d.ts +11 -0
- package/types/document/into.d.ts +65 -0
- package/types/document/loaderInfo.d.ts +35 -0
- package/types/document/schema.d.ts +5 -0
- package/types/document/types.d.ts +36 -0
- package/types/document.d.ts +1 -0
- package/types/fetch/client/fetchClient.d.ts +78 -0
- package/types/fetch/client/httpClient.d.ts +39 -0
- package/types/fetch/client/index.d.ts +3 -0
- package/types/fetch/client/wsClient.d.ts +37 -0
- package/types/fetch/client.d.ts +1 -0
- package/types/fetch/fetchType/appliedReturn.type.d.ts +67 -0
- package/types/fetch/fetchType/buildFetch.type.d.ts +11 -0
- package/types/fetch/fetchType/clientSignal.type.d.ts +16 -0
- package/types/fetch/fetchType/endpointFetch.type.d.ts +29 -0
- package/types/fetch/fetchType/index.d.ts +5 -0
- package/types/fetch/fetchType/sliceFetch.type.d.ts +76 -0
- package/types/fetch/fetchType.d.ts +1 -0
- package/types/fetch/index.d.ts +4 -0
- package/types/fetch/requestStorage.d.ts +29 -0
- package/types/fetch/serializer/fetch.serializer.d.ts +14 -0
- package/types/fetch/serializer/index.d.ts +1 -0
- package/types/fetch/serializer.d.ts +1 -0
- package/types/fetch/types.d.ts +19 -0
- package/types/fetch.d.ts +1 -0
- package/types/index.d.ts +213 -0
- package/types/server/akanApp.d.ts +17 -0
- package/types/server/akanAppHeaders.d.ts +1 -0
- package/types/server/akanLib.d.ts +33 -0
- package/types/server/akanOption.d.ts +15 -0
- package/types/server/akanServer.d.ts +47 -0
- package/types/server/artifact/builderRpc.d.ts +42 -0
- package/types/server/artifact/index.d.ts +6 -0
- package/types/server/artifact/ipcTypes.d.ts +73 -0
- package/types/server/artifact/manifestTypes.d.ts +16 -0
- package/types/server/artifact/routeClientCache.d.ts +45 -0
- package/types/server/artifact/routeSeedIndexStore.d.ts +43 -0
- package/types/server/artifact/routesManifestStore.d.ts +16 -0
- package/types/server/artifact.d.ts +1 -0
- package/types/server/decorators.d.ts +6 -0
- package/types/server/di/diLifecycle.d.ts +45 -0
- package/types/server/di/index.d.ts +4 -0
- package/types/server/di/predefinedAdaptor.d.ts +33 -0
- package/types/server/di/resolveAdaptorHierarchy.d.ts +21 -0
- package/types/server/di/resolveHierarchy.d.ts +11 -0
- package/types/server/di/resolveServiceHierarchy.d.ts +13 -0
- package/types/server/di/utils.d.ts +14 -0
- package/types/server/di.d.ts +1 -0
- package/types/server/hmr/changeBatch.d.ts +13 -0
- package/types/server/hmr/clientScript.d.ts +1 -0
- package/types/server/hmr/devHmrController.d.ts +24 -0
- package/types/server/hmr/index.d.ts +4 -0
- package/types/server/hmr/wsHub.d.ts +45 -0
- package/types/server/hmr.d.ts +1 -0
- package/types/server/imageOptimizer.d.ts +12 -0
- package/types/server/imageOptimizerError.d.ts +4 -0
- package/types/server/index.d.ts +14 -0
- package/types/server/lifecycle/shutdownManager.d.ts +13 -0
- package/types/server/logging/rotatingLogWriter.d.ts +20 -0
- package/types/server/processMetricsCollector.d.ts +10 -0
- package/types/server/proxy/akanResponse.d.ts +7 -0
- package/types/server/proxy/bunRequestFields.d.ts +1 -0
- package/types/server/proxy/hostBasePathWebProxy.d.ts +6 -0
- package/types/server/proxy/index.d.ts +6 -0
- package/types/server/proxy/localeWebProxy.d.ts +5 -0
- package/types/server/proxy/types.d.ts +37 -0
- package/types/server/proxy/webProxyRunner.d.ts +7 -0
- package/types/server/proxy.d.ts +1 -0
- package/types/server/resolver/database.resolver.d.ts +6 -0
- package/types/server/resolver/index.d.ts +3 -0
- package/types/server/resolver/service.resolver.d.ts +7 -0
- package/types/server/resolver/signal.resolver.d.ts +29 -0
- package/types/server/resolver.d.ts +1 -0
- package/types/server/robots.d.ts +1 -0
- package/types/server/routeElementComposer.d.ts +41 -0
- package/types/server/routeTreeBuilder.d.ts +28 -0
- package/types/server/routing/apiRouter.d.ts +61 -0
- package/types/server/rscClient.d.ts +15 -0
- package/types/server/rscWorker.d.ts +3 -0
- package/types/server/rscWorkerHost.d.ts +83 -0
- package/types/server/sitemap.d.ts +13 -0
- package/types/server/ssrFromRscRenderer.d.ts +6 -0
- package/types/server/ssrTypes.d.ts +47 -0
- package/types/server/systemPages.d.ts +27 -0
- package/types/server/types/react-server-dom-webpack.d.ts +91 -0
- package/types/server/types.d.ts +67 -0
- package/types/server/vendor/akanjs-base.d.ts +1 -0
- package/types/server/vendor/akanjs-common.d.ts +1 -0
- package/types/server/vendor/akanjs-constant.d.ts +1 -0
- package/types/server/vendor/akanjs-store.d.ts +1 -0
- package/types/server/vendor/react-dom-client.d.ts +3 -0
- package/types/server/vendor/react-dom.d.ts +3 -0
- package/types/server/vendor/react-jsx-dev-runtime.d.ts +3 -0
- package/types/server/vendor/react-jsx-runtime.d.ts +3 -0
- package/types/server/vendor/react-refresh-runtime.d.ts +3 -0
- package/types/server/vendor/react-server-dom-webpack-client-browser.d.ts +3 -0
- package/types/server/vendor/react.d.ts +11 -0
- package/types/server/vendor/scheduler.d.ts +3 -0
- package/types/server/webRouter.d.ts +44 -0
- package/types/server.d.ts +1 -0
- package/types/service/adapt.d.ts +15 -0
- package/types/service/base.service.d.ts +18 -0
- package/types/service/index.d.ts +10 -0
- package/types/service/injectInfo.d.ts +102 -0
- package/types/service/ipcTypes.d.ts +194 -0
- package/types/service/predefinedAdaptor/cache.adaptor.d.ts +46 -0
- package/types/service/predefinedAdaptor/compress.adaptor.d.ts +22 -0
- package/types/service/predefinedAdaptor/database.adaptor.d.ts +329 -0
- package/types/service/predefinedAdaptor/index.d.ts +13 -0
- package/types/service/predefinedAdaptor/logging.adaptor.d.ts +20 -0
- package/types/service/predefinedAdaptor/queue.adaptor.d.ts +22 -0
- package/types/service/predefinedAdaptor/role.adaptor.d.ts +17 -0
- package/types/service/predefinedAdaptor/schedule.adaptor.d.ts +60 -0
- package/types/service/predefinedAdaptor/solidCache.adaptor.d.ts +25 -0
- package/types/service/predefinedAdaptor/solidPubsub.adaptor.d.ts +20 -0
- package/types/service/predefinedAdaptor/solidQueue.adaptor.d.ts +19 -0
- package/types/service/predefinedAdaptor/solidSqlite.d.ts +24 -0
- package/types/service/predefinedAdaptor/sqlitePath.d.ts +9 -0
- package/types/service/predefinedAdaptor/storage.adaptor.d.ts +80 -0
- package/types/service/predefinedAdaptor/websocket.adaptor.d.ts +49 -0
- package/types/service/predefinedAdaptor.d.ts +1 -0
- package/types/service/serve.d.ts +31 -0
- package/types/service/serviceModule.d.ts +50 -0
- package/types/service/serviceRegistry.d.ts +9 -0
- package/types/service/types.d.ts +55 -0
- package/types/service.d.ts +1 -0
- package/types/signal/base.signal.d.ts +41 -0
- package/types/signal/endpoint.d.ts +28 -0
- package/types/signal/endpointInfo.d.ts +77 -0
- package/types/signal/exception.d.ts +54786 -0
- package/types/signal/guard.d.ts +10 -0
- package/types/signal/guards.d.ts +10 -0
- package/types/signal/index.d.ts +19 -0
- package/types/signal/intercept.d.ts +17 -0
- package/types/signal/internal.d.ts +18 -0
- package/types/signal/internalArg.d.ts +31 -0
- package/types/signal/internalInfo.d.ts +45 -0
- package/types/signal/middleware.d.ts +51 -0
- package/types/signal/serializer/fetch.serializer.d.ts +14 -0
- package/types/signal/serializer/index.d.ts +1 -0
- package/types/signal/serializer.d.ts +1 -0
- package/types/signal/serverSignal.d.ts +36 -0
- package/types/signal/signalContext.d.ts +96 -0
- package/types/signal/signalRegistry.d.ts +49 -0
- package/types/signal/slice.d.ts +42 -0
- package/types/signal/sliceInfo.d.ts +51 -0
- package/types/signal/trace.d.ts +97 -0
- package/types/signal/types.d.ts +142 -0
- package/types/signal.d.ts +1 -0
- package/types/store/action.d.ts +145 -0
- package/types/store/baseSt.d.ts +412 -0
- package/types/store/hooks.d.ts +1 -0
- package/types/store/index.d.ts +8 -0
- package/types/store/rootStore.d.ts +22 -0
- package/types/store/state.d.ts +91 -0
- package/types/store/stateBuilder.d.ts +141 -0
- package/types/store/stateInfo.d.ts +23 -0
- package/types/store/store.d.ts +36 -0
- package/types/store/storeInstance.d.ts +38 -0
- package/types/store/storeRegistry.d.ts +13 -0
- package/types/store/types.d.ts +42 -0
- package/types/store/withSelector.d.ts +42 -0
- package/types/store.d.ts +1 -0
- package/types/test/index.d.ts +4 -0
- package/types/test/playwright.config.base.d.ts +9 -0
- package/types/test/playwright.pageAgent.d.ts +12 -0
- package/types/test/sample.d.ts +15 -0
- package/types/test/sampleOf.d.ts +5 -0
- package/types/test/signalTest.preload.d.ts +1 -0
- package/types/test/signalTestRuntime.d.ts +29 -0
- package/types/test/testServer.d.ts +26 -0
- package/types/test.d.ts +1 -0
- package/types/ui/BottomSheet.d.ts +13 -0
- package/types/ui/Button.d.ts +11 -0
- package/types/ui/ClientSide.d.ts +8 -0
- package/types/ui/Clipboard.d.ts +7 -0
- package/types/ui/Constant/Doc.d.ts +29 -0
- package/types/ui/Constant/Mermaid.d.ts +8 -0
- package/types/ui/Constant/index.d.ts +6 -0
- package/types/ui/Constant/schemaDoc.d.ts +84 -0
- package/types/ui/Constant.d.ts +1 -0
- package/types/ui/Copy.d.ts +10 -0
- package/types/ui/CsrImage.d.ts +18 -0
- package/types/ui/Data/CardList.d.ts +36 -0
- package/types/ui/Data/Dashboard.d.ts +11 -0
- package/types/ui/Data/Insight.d.ts +9 -0
- package/types/ui/Data/Item.d.ts +75 -0
- package/types/ui/Data/ListContainer.d.ts +49 -0
- package/types/ui/Data/Pagination.d.ts +9 -0
- package/types/ui/Data/QueryMaker.d.ts +8 -0
- package/types/ui/Data/TableList.d.ts +26 -0
- package/types/ui/Data/index.d.ts +9 -0
- package/types/ui/Data/index_.d.ts +8 -0
- package/types/ui/Data.d.ts +1 -0
- package/types/ui/DatePicker.d.ts +36 -0
- package/types/ui/Dialog/Action.d.ts +5 -0
- package/types/ui/Dialog/Close.d.ts +6 -0
- package/types/ui/Dialog/Content.d.ts +6 -0
- package/types/ui/Dialog/Modal.d.ts +9 -0
- package/types/ui/Dialog/Provider.d.ts +11 -0
- package/types/ui/Dialog/Title.d.ts +5 -0
- package/types/ui/Dialog/Trigger.d.ts +6 -0
- package/types/ui/Dialog/context.d.ts +10 -0
- package/types/ui/Dialog/index.d.ts +9 -0
- package/types/ui/Dialog.d.ts +1 -0
- package/types/ui/DragAction.d.ts +24 -0
- package/types/ui/DraggableList.d.ts +31 -0
- package/types/ui/Dropdown.d.ts +14 -0
- package/types/ui/Empty.d.ts +12 -0
- package/types/ui/Field.d.ts +411 -0
- package/types/ui/FontFace.d.ts +6 -0
- package/types/ui/Image.d.ts +49 -0
- package/types/ui/InfiniteScroll.d.ts +10 -0
- package/types/ui/Input.d.ts +95 -0
- package/types/ui/KeyboardAvoiding.d.ts +8 -0
- package/types/ui/Layout/BottomAction.d.ts +6 -0
- package/types/ui/Layout/BottomInset.d.ts +7 -0
- package/types/ui/Layout/BottomTab.d.ts +14 -0
- package/types/ui/Layout/Header.d.ts +8 -0
- package/types/ui/Layout/LeftSider.d.ts +9 -0
- package/types/ui/Layout/Navbar.d.ts +11 -0
- package/types/ui/Layout/RightSider.d.ts +10 -0
- package/types/ui/Layout/Sider.d.ts +7 -0
- package/types/ui/Layout/Template.d.ts +7 -0
- package/types/ui/Layout/TopLeftAction.d.ts +6 -0
- package/types/ui/Layout/Unit.d.ts +9 -0
- package/types/ui/Layout/View.d.ts +8 -0
- package/types/ui/Layout/Zone.d.ts +6 -0
- package/types/ui/Layout/index.d.ts +14 -0
- package/types/ui/Layout.d.ts +1 -0
- package/types/ui/Link/Back.d.ts +7 -0
- package/types/ui/Link/Close.d.ts +7 -0
- package/types/ui/Link/CsrLink.d.ts +2 -0
- package/types/ui/Link/Lang.d.ts +8 -0
- package/types/ui/Link/SsrLink.d.ts +2 -0
- package/types/ui/Link/index.d.ts +10 -0
- package/types/ui/Link/types.d.ts +42 -0
- package/types/ui/Link.d.ts +1 -0
- package/types/ui/Load/Edit.d.ts +4 -0
- package/types/ui/Load/Edit_Client.d.ts +27 -0
- package/types/ui/Load/Page.d.ts +15 -0
- package/types/ui/Load/PageCSR.d.ts +3 -0
- package/types/ui/Load/Pagination.d.ts +8 -0
- package/types/ui/Load/Units.d.ts +30 -0
- package/types/ui/Load/View.d.ts +22 -0
- package/types/ui/Load/index.d.ts +8 -0
- package/types/ui/Load/index_.d.ts +3 -0
- package/types/ui/Load.d.ts +1 -0
- package/types/ui/Loading/Area.d.ts +1 -0
- package/types/ui/Loading/Button.d.ts +7 -0
- package/types/ui/Loading/Input.d.ts +7 -0
- package/types/ui/Loading/ProgressBar.d.ts +6 -0
- package/types/ui/Loading/Skeleton.d.ts +7 -0
- package/types/ui/Loading/Spin.d.ts +7 -0
- package/types/ui/Loading/index.d.ts +8 -0
- package/types/ui/Loading.d.ts +1 -0
- package/types/ui/Menu.d.ts +26 -0
- package/types/ui/Modal.d.ts +19 -0
- package/types/ui/Model/AdminPanel.d.ts +31 -0
- package/types/ui/Model/Edit.d.ts +16 -0
- package/types/ui/Model/EditModal.d.ts +52 -0
- package/types/ui/Model/EditWrapper.d.ts +13 -0
- package/types/ui/Model/LoadInit.d.ts +10 -0
- package/types/ui/Model/New.d.ts +16 -0
- package/types/ui/Model/NewWrapper.d.ts +13 -0
- package/types/ui/Model/NewWrapper_Client.d.ts +13 -0
- package/types/ui/Model/Remove.d.ts +13 -0
- package/types/ui/Model/RemoveWrapper.d.ts +12 -0
- package/types/ui/Model/SureToRemove.d.ts +11 -0
- package/types/ui/Model/View.d.ts +19 -0
- package/types/ui/Model/ViewEditModal.d.ts +12 -0
- package/types/ui/Model/ViewModal.d.ts +14 -0
- package/types/ui/Model/ViewWrapper.d.ts +12 -0
- package/types/ui/Model/index.d.ts +16 -0
- package/types/ui/Model/index_.d.ts +14 -0
- package/types/ui/Model.d.ts +1 -0
- package/types/ui/More.d.ts +12 -0
- package/types/ui/ObjectId.d.ts +5 -0
- package/types/ui/Pagination.d.ts +20 -0
- package/types/ui/Popconfirm.d.ts +28 -0
- package/types/ui/Portal.d.ts +6 -0
- package/types/ui/Radio.d.ts +19 -0
- package/types/ui/RecentTime.d.ts +12 -0
- package/types/ui/Refresh.d.ts +7 -0
- package/types/ui/ScreenNavigator.d.ts +18 -0
- package/types/ui/Select.d.ts +43 -0
- package/types/ui/Signal/Arg.d.ts +78 -0
- package/types/ui/Signal/Doc.d.ts +33 -0
- package/types/ui/Signal/Listener.d.ts +9 -0
- package/types/ui/Signal/Message.d.ts +23 -0
- package/types/ui/Signal/Object.d.ts +20 -0
- package/types/ui/Signal/PubSub.d.ts +24 -0
- package/types/ui/Signal/Request.d.ts +8 -0
- package/types/ui/Signal/Response.d.ts +14 -0
- package/types/ui/Signal/RestApi.d.ts +40 -0
- package/types/ui/Signal/WebSocket.d.ts +11 -0
- package/types/ui/Signal/index.d.ts +18 -0
- package/types/ui/Signal/makeExample.d.ts +4 -0
- package/types/ui/Signal/style.d.ts +15 -0
- package/types/ui/Signal.d.ts +1 -0
- package/types/ui/System/CSR.d.ts +32 -0
- package/types/ui/System/Client.d.ts +47 -0
- package/types/ui/System/Common.d.ts +47 -0
- package/types/ui/System/DevModeToggle.d.ts +1 -0
- package/types/ui/System/Gtag.d.ts +4 -0
- package/types/ui/System/Messages.d.ts +1 -0
- package/types/ui/System/Reconnect.d.ts +1 -0
- package/types/ui/System/Root.d.ts +6 -0
- package/types/ui/System/SSR.d.ts +24 -0
- package/types/ui/System/SelectLanguage.d.ts +5 -0
- package/types/ui/System/ThemeToggle.d.ts +4 -0
- package/types/ui/System/index.d.ts +12 -0
- package/types/ui/System.d.ts +1 -0
- package/types/ui/Tab/Menu.d.ts +12 -0
- package/types/ui/Tab/Menus.d.ts +6 -0
- package/types/ui/Tab/Panel.d.ts +8 -0
- package/types/ui/Tab/Provider.d.ts +10 -0
- package/types/ui/Tab/context.d.ts +9 -0
- package/types/ui/Tab/index.d.ts +7 -0
- package/types/ui/Tab.d.ts +1 -0
- package/types/ui/Table.d.ts +41 -0
- package/types/ui/ToggleSelect.d.ts +33 -0
- package/types/ui/Unauthorized.d.ts +9 -0
- package/types/ui/animated.d.ts +5 -0
- package/types/ui/fontCss.d.ts +11 -0
- package/types/ui/index.d.ts +44 -0
- package/types/ui.d.ts +1 -0
- package/types/webkit/bootCsr.d.ts +16 -0
- package/types/webkit/createRobotPage.d.ts +15 -0
- package/types/webkit/createSitemapPage.d.ts +4 -0
- package/types/webkit/index.d.ts +17 -0
- package/types/webkit/lazy.d.ts +11 -0
- package/types/webkit/types.d.ts +7 -0
- package/types/webkit/useCamera.d.ts +19 -0
- package/types/webkit/useCodepush.d.ts +16 -0
- package/types/webkit/useContact.d.ts +11 -0
- package/types/webkit/useCsrValues.d.ts +30 -0
- package/types/webkit/useDebounce.d.ts +2 -0
- package/types/webkit/useFetch.d.ts +18 -0
- package/types/webkit/useGeoLocation.d.ts +8 -0
- package/types/webkit/useHistory.d.ts +23 -0
- package/types/webkit/useInterval.d.ts +2 -0
- package/types/webkit/useLocation.d.ts +8 -0
- package/types/webkit/usePurchase.d.ts +19 -0
- package/types/webkit/usePushNoti.d.ts +7 -0
- package/types/webkit/useThrottle.d.ts +2 -0
- package/types/webkit.d.ts +1 -0
- package/ui/BottomSheet.tsx +1 -1
- package/ui/Clipboard.tsx +1 -1
- package/ui/CsrImage.tsx +3 -14
- package/ui/Data/ListContainer.tsx +1 -1
- package/ui/Data/Pagination.tsx +1 -1
- package/ui/Data/QueryMaker.tsx +0 -339
- package/ui/Data/index.ts +0 -1
- package/ui/DatePicker.tsx +1 -95
- package/ui/Dialog/Modal.tsx +1 -1
- package/ui/DraggableList.tsx +5 -5
- package/ui/Field.tsx +2 -3
- package/ui/Image.tsx +2 -3
- package/ui/InfiniteScroll.tsx +0 -1
- package/ui/Input.tsx +1 -8
- package/ui/Layout/BottomTab.tsx +2 -2
- package/ui/Link/SsrLink.tsx +1 -2
- package/ui/Load/Page.tsx +1 -1
- package/ui/Load/PageCSR.tsx +0 -1
- package/ui/Load/Units.tsx +1 -2
- package/ui/Load/View.tsx +1 -2
- package/ui/Menu.tsx +5 -8
- package/ui/Model/EditModal.tsx +2 -5
- package/ui/Popconfirm.tsx +2 -4
- package/ui/ScreenNavigator.tsx +2 -3
- package/ui/Signal/Message.tsx +2 -3
- package/ui/Signal/PubSub.tsx +0 -2
- package/ui/Signal/Response.tsx +1 -1
- package/ui/Signal/WebSocket.tsx +2 -11
- package/ui/System/Client.tsx +7 -41
- package/ui/System/Gtag.tsx +2 -5
- package/ui/System/Messages.tsx +2 -2
- package/ui/System/Reconnect.tsx +5 -6
- package/ui/System/Root.tsx +0 -1
- package/ui/System/SSR.tsx +1 -7
- package/ui/ToggleSelect.tsx +3 -8
- package/ui/Unauthorized.tsx +1 -1
- package/webkit/bootCsr.tsx +3 -6
- package/webkit/lazy.tsx +1 -8
- package/webkit/useCamera.tsx +0 -1
- package/webkit/useCodepush.tsx +4 -9
- package/webkit/useContact.tsx +0 -1
- package/webkit/useCsrValues.ts +6 -10
- package/webkit/useDebounce.ts +2 -2
- package/webkit/usePurchase.tsx +5 -9
- package/webkit/usePushNoti.tsx +0 -1
- package/base/base.test.ts +0 -135
- package/base/baseEnv.test.ts +0 -146
- package/base/primitiveRegistry.test.ts +0 -127
- package/base/symbols.test.ts +0 -29
- package/base/utils.test.ts +0 -30
- package/build.ts +0 -318
- package/capacitor.base.config.test.ts +0 -83
- package/client/client.auth-storage.test.ts +0 -210
- package/client/client.decorators.test.ts +0 -74
- package/client/client.device.test.ts +0 -181
- package/client/client.page.test.tsx +0 -175
- package/client/client.pure.test.ts +0 -146
- package/client/client.router.test.ts +0 -290
- package/common/Logger.test.ts +0 -45
- package/common/formatAndValidation.test.ts +0 -61
- package/common/httpClient.test.ts +0 -91
- package/common/objectPath.test.ts +0 -108
- package/common/routeConvention.test.ts +0 -132
- package/common/runtimeConfig.test.ts +0 -84
- package/constant/constant.test.ts +0 -374
- package/dictionary/dictionary.test.ts +0 -352
- package/document/document.test.ts +0 -698
- package/fetch/fetch.test.ts +0 -838
- package/server/akanApp.test.ts +0 -130
- package/server/akanServer.test.ts +0 -157
- package/server/artifact/routeClientCache.test.ts +0 -265
- package/server/artifact/routeSeedIndex.test.ts +0 -56
- package/server/artifact/routesManifest.test.ts +0 -64
- package/server/di/diLifecycle.contract.test.ts +0 -168
- package/server/logging/rotatingLogWriter.test.ts +0 -119
- package/server/processMetrics.test.ts +0 -24
- package/server/proxy/webProxyRunner.test.ts +0 -66
- package/server/resolver/resolver.contract.test.ts +0 -594
- package/server/robots.test.ts +0 -16
- package/server/routeTree.test.tsx +0 -198
- package/server/routing/apiRouter.test.ts +0 -136
- package/server/sitemap.test.ts +0 -61
- package/server/systemPages.test.tsx +0 -93
- package/server/webRouter.test.ts +0 -49
- package/service/predefinedAdaptor/compress.adaptor.test.ts +0 -184
- package/service/predefinedAdaptor/solidCache.adaptor.test.ts +0 -107
- package/service/predefinedAdaptor/solidSqlite.test.ts +0 -457
- package/service/service.test.ts +0 -732
- package/signal/signal.test.ts +0 -892
- package/store/stateBuilder.test.ts +0 -168
- package/store/store.test.ts +0 -427
- package/tsconfig.json +0 -5
- package/ui/Constant/schemaDoc.test.ts +0 -113
- package/ui/InfiniteScroll.test.tsx +0 -155
- package/ui/System/Common.test.ts +0 -37
- package/webkit/bootCsr.test.tsx +0 -153
- package/webkit/native.test.tsx +0 -341
- package/webkit/webkit.test.tsx +0 -531
package/fetch/fetch.test.ts
DELETED
|
@@ -1,838 +0,0 @@
|
|
|
1
|
-
import { afterEach, describe, expect, test } from "bun:test";
|
|
2
|
-
import { DataList, Int } from "akanjs/base";
|
|
3
|
-
import { ConstantRegistry, via } from "akanjs/constant";
|
|
4
|
-
import type { SerializedArg, SerializedSignal } from "akanjs/signal";
|
|
5
|
-
import { FetchClient } from "./client/fetchClient";
|
|
6
|
-
import { HttpClient } from "./client/httpClient";
|
|
7
|
-
import { WsClient } from "./client/wsClient";
|
|
8
|
-
import {
|
|
9
|
-
cookies,
|
|
10
|
-
getRequestTheme,
|
|
11
|
-
headers,
|
|
12
|
-
memoizeRequestQuery,
|
|
13
|
-
parseCookieHeader,
|
|
14
|
-
requestStorage,
|
|
15
|
-
setRequestTheme,
|
|
16
|
-
} from "./requestStorage";
|
|
17
|
-
|
|
18
|
-
type FetchCall = { url: string; init?: RequestInit };
|
|
19
|
-
const originalFetch = globalThis.fetch;
|
|
20
|
-
const originalWebSocket = globalThis.WebSocket;
|
|
21
|
-
const originalSetTimeout = globalThis.setTimeout;
|
|
22
|
-
const originalClearTimeout = globalThis.clearTimeout;
|
|
23
|
-
const originalEnv = {
|
|
24
|
-
appName: process.env.AKAN_PUBLIC_APP_NAME,
|
|
25
|
-
repoName: process.env.AKAN_PUBLIC_REPO_NAME,
|
|
26
|
-
serveDomain: process.env.AKAN_PUBLIC_SERVE_DOMAIN,
|
|
27
|
-
operationMode: process.env.AKAN_PUBLIC_OPERATION_MODE,
|
|
28
|
-
};
|
|
29
|
-
const fetchCalls: FetchCall[] = [];
|
|
30
|
-
const jsonResponses: unknown[] = [];
|
|
31
|
-
const responseStatuses: number[] = [];
|
|
32
|
-
|
|
33
|
-
const setMockFetch = () => {
|
|
34
|
-
fetchCalls.length = 0;
|
|
35
|
-
jsonResponses.length = 0;
|
|
36
|
-
globalThis.fetch = (async (url: string | URL | Request, init?: RequestInit) => {
|
|
37
|
-
fetchCalls.push({ url: String(url), init });
|
|
38
|
-
const value = jsonResponses.length ? jsonResponses.shift() : { ok: true };
|
|
39
|
-
const status = responseStatuses.length ? responseStatuses.shift() : 200;
|
|
40
|
-
return Response.json(value, { status });
|
|
41
|
-
}) as typeof fetch;
|
|
42
|
-
};
|
|
43
|
-
const setAkanPublicEnv = () => {
|
|
44
|
-
process.env.AKAN_PUBLIC_APP_NAME = "fetchTest";
|
|
45
|
-
process.env.AKAN_PUBLIC_REPO_NAME = "akan";
|
|
46
|
-
process.env.AKAN_PUBLIC_SERVE_DOMAIN = "example.test";
|
|
47
|
-
process.env.AKAN_PUBLIC_OPERATION_MODE = "local";
|
|
48
|
-
};
|
|
49
|
-
|
|
50
|
-
afterEach(() => {
|
|
51
|
-
globalThis.fetch = originalFetch;
|
|
52
|
-
globalThis.WebSocket = originalWebSocket;
|
|
53
|
-
globalThis.setTimeout = originalSetTimeout;
|
|
54
|
-
globalThis.clearTimeout = originalClearTimeout;
|
|
55
|
-
if (originalEnv.appName === undefined) delete process.env.AKAN_PUBLIC_APP_NAME;
|
|
56
|
-
else process.env.AKAN_PUBLIC_APP_NAME = originalEnv.appName;
|
|
57
|
-
if (originalEnv.repoName === undefined) delete process.env.AKAN_PUBLIC_REPO_NAME;
|
|
58
|
-
else process.env.AKAN_PUBLIC_REPO_NAME = originalEnv.repoName;
|
|
59
|
-
if (originalEnv.serveDomain === undefined) delete process.env.AKAN_PUBLIC_SERVE_DOMAIN;
|
|
60
|
-
else process.env.AKAN_PUBLIC_SERVE_DOMAIN = originalEnv.serveDomain;
|
|
61
|
-
if (originalEnv.operationMode === undefined) delete process.env.AKAN_PUBLIC_OPERATION_MODE;
|
|
62
|
-
else process.env.AKAN_PUBLIC_OPERATION_MODE = originalEnv.operationMode;
|
|
63
|
-
fetchCalls.length = 0;
|
|
64
|
-
jsonResponses.length = 0;
|
|
65
|
-
responseStatuses.length = 0;
|
|
66
|
-
});
|
|
67
|
-
|
|
68
|
-
const arg = (type: SerializedArg["type"], name: string, extra: Partial<SerializedArg> = {}): SerializedArg => ({
|
|
69
|
-
type,
|
|
70
|
-
name,
|
|
71
|
-
refName: "String",
|
|
72
|
-
...extra,
|
|
73
|
-
});
|
|
74
|
-
|
|
75
|
-
class FakeWebSocket {
|
|
76
|
-
static CONNECTING = 0;
|
|
77
|
-
static OPEN = 1;
|
|
78
|
-
static CLOSING = 2;
|
|
79
|
-
static CLOSED = 3;
|
|
80
|
-
static instances: FakeWebSocket[] = [];
|
|
81
|
-
readyState = FakeWebSocket.CONNECTING;
|
|
82
|
-
sent: string[] = [];
|
|
83
|
-
onopen: ((event: unknown) => void) | null = null;
|
|
84
|
-
onmessage: ((event: { data: unknown }) => void) | null = null;
|
|
85
|
-
onerror: ((event: unknown) => void) | null = null;
|
|
86
|
-
onclose: ((event: { code: number; reason: string }) => void) | null = null;
|
|
87
|
-
|
|
88
|
-
constructor(readonly url: string) {
|
|
89
|
-
FakeWebSocket.instances.push(this);
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
open() {
|
|
93
|
-
this.readyState = FakeWebSocket.OPEN;
|
|
94
|
-
this.onopen?.({});
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
receive(data: unknown) {
|
|
98
|
-
this.onmessage?.({ data: typeof data === "string" ? data : JSON.stringify(data) });
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
close() {
|
|
102
|
-
this.readyState = FakeWebSocket.CLOSED;
|
|
103
|
-
this.onclose?.({ code: 1000, reason: "closed" });
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
send(data: string) {
|
|
107
|
-
this.sent.push(data);
|
|
108
|
-
}
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
class TestErr extends Error {
|
|
112
|
-
readonly error: string;
|
|
113
|
-
readonly statusCode?: number;
|
|
114
|
-
readonly data?: Record<string, unknown>;
|
|
115
|
-
readonly details?: unknown;
|
|
116
|
-
readonly path?: string;
|
|
117
|
-
readonly timestamp?: string;
|
|
118
|
-
|
|
119
|
-
constructor(
|
|
120
|
-
key: string,
|
|
121
|
-
data?: Record<string, unknown>,
|
|
122
|
-
option: { statusCode?: number; details?: unknown; path?: string; timestamp?: string } = {},
|
|
123
|
-
) {
|
|
124
|
-
super(key);
|
|
125
|
-
this.error = key;
|
|
126
|
-
this.statusCode = option.statusCode ?? 400;
|
|
127
|
-
this.data = data;
|
|
128
|
-
this.details = option.details;
|
|
129
|
-
this.path = option.path;
|
|
130
|
-
this.timestamp = option.timestamp;
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
static fromJSON(payload: {
|
|
134
|
-
error: string;
|
|
135
|
-
statusCode?: number;
|
|
136
|
-
data?: Record<string, unknown>;
|
|
137
|
-
details?: unknown;
|
|
138
|
-
path?: string;
|
|
139
|
-
timestamp?: string;
|
|
140
|
-
}) {
|
|
141
|
-
return new TestErr(payload.error, payload.data, payload);
|
|
142
|
-
}
|
|
143
|
-
}
|
|
144
|
-
|
|
145
|
-
const setFakeWebSocket = () => {
|
|
146
|
-
FakeWebSocket.instances = [];
|
|
147
|
-
globalThis.WebSocket = FakeWebSocket as unknown as typeof WebSocket;
|
|
148
|
-
Object.assign(globalThis.WebSocket, {
|
|
149
|
-
CONNECTING: FakeWebSocket.CONNECTING,
|
|
150
|
-
OPEN: FakeWebSocket.OPEN,
|
|
151
|
-
CLOSING: FakeWebSocket.CLOSING,
|
|
152
|
-
CLOSED: FakeWebSocket.CLOSED,
|
|
153
|
-
});
|
|
154
|
-
};
|
|
155
|
-
|
|
156
|
-
const FetchTestNested = via((f) => ({
|
|
157
|
-
label: f(String),
|
|
158
|
-
}));
|
|
159
|
-
ConstantRegistry.buildScalar("fetchTestNested", FetchTestNested, { FetchTestNested });
|
|
160
|
-
const FetchTestInput = via((f) => ({
|
|
161
|
-
title: f(String),
|
|
162
|
-
count: f(Int, { default: 0 }),
|
|
163
|
-
nested: f(FetchTestNested),
|
|
164
|
-
}));
|
|
165
|
-
const FetchTestObject = via(FetchTestInput, (f) => ({
|
|
166
|
-
memo: f(String).optional(),
|
|
167
|
-
}));
|
|
168
|
-
const FetchTestLight = via(FetchTestObject, ["title"] as const, () => ({}));
|
|
169
|
-
const FetchTestFull = via(FetchTestObject, FetchTestLight, () => ({}));
|
|
170
|
-
const FetchTestInsight = via(FetchTestFull, (f) => ({
|
|
171
|
-
count: f(Int, { default: 0, accumulate: {} }),
|
|
172
|
-
}));
|
|
173
|
-
ConstantRegistry.buildModel(
|
|
174
|
-
"fetchTestItem",
|
|
175
|
-
FetchTestInput,
|
|
176
|
-
FetchTestObject,
|
|
177
|
-
FetchTestFull,
|
|
178
|
-
FetchTestLight,
|
|
179
|
-
FetchTestInsight,
|
|
180
|
-
{
|
|
181
|
-
FetchTestInput,
|
|
182
|
-
FetchTestObject,
|
|
183
|
-
FetchTestLight,
|
|
184
|
-
FetchTestFull,
|
|
185
|
-
FetchTestInsight,
|
|
186
|
-
},
|
|
187
|
-
);
|
|
188
|
-
|
|
189
|
-
const serviceSignal: SerializedSignal = {
|
|
190
|
-
endpoint: {
|
|
191
|
-
getThing: {
|
|
192
|
-
type: "query",
|
|
193
|
-
path: "/custom/:id",
|
|
194
|
-
args: [
|
|
195
|
-
arg("param", "id", { refName: "ID" }),
|
|
196
|
-
arg("search", "tags", { arrDepth: 1 }),
|
|
197
|
-
arg("search", "empty", { nullable: true }),
|
|
198
|
-
],
|
|
199
|
-
returns: { refName: "String" },
|
|
200
|
-
},
|
|
201
|
-
createThing: {
|
|
202
|
-
type: "mutation",
|
|
203
|
-
args: [arg("body", "title"), arg("body", "count", { refName: "Int" })],
|
|
204
|
-
returns: { refName: "fetchTestItem", modelType: "full" },
|
|
205
|
-
},
|
|
206
|
-
uploadThing: {
|
|
207
|
-
type: "mutation",
|
|
208
|
-
args: [arg("upload", "file", { refName: "Upload" }), arg("body", "title")],
|
|
209
|
-
returns: { refName: "String" },
|
|
210
|
-
},
|
|
211
|
-
sendThing: {
|
|
212
|
-
type: "message",
|
|
213
|
-
args: [arg("msg", "text")],
|
|
214
|
-
returns: { refName: "String" },
|
|
215
|
-
},
|
|
216
|
-
roomThing: {
|
|
217
|
-
type: "pubsub",
|
|
218
|
-
args: [arg("room", "roomId")],
|
|
219
|
-
returns: { refName: "fetchTestItem", modelType: "light" },
|
|
220
|
-
},
|
|
221
|
-
},
|
|
222
|
-
};
|
|
223
|
-
|
|
224
|
-
const databaseSignal: SerializedSignal = {
|
|
225
|
-
prefix: "fetchTest",
|
|
226
|
-
getGuards: ["Public"],
|
|
227
|
-
cruGuards: ["Admin"],
|
|
228
|
-
slice: {
|
|
229
|
-
"": { args: [arg("search", "query", { refName: "Any", nullable: true })] },
|
|
230
|
-
byOwner: { args: [arg("param", "ownerId", { refName: "ID" })], guards: ["Public"] },
|
|
231
|
-
},
|
|
232
|
-
filter: {
|
|
233
|
-
sortKeys: ["latest", "oldest"],
|
|
234
|
-
filter: {
|
|
235
|
-
byTitle: [arg("param", "title")],
|
|
236
|
-
},
|
|
237
|
-
},
|
|
238
|
-
endpoint: {
|
|
239
|
-
custom: {
|
|
240
|
-
type: "query",
|
|
241
|
-
args: [arg("search", "q")],
|
|
242
|
-
returns: { refName: "String" },
|
|
243
|
-
},
|
|
244
|
-
},
|
|
245
|
-
};
|
|
246
|
-
|
|
247
|
-
describe("HttpClient", () => {
|
|
248
|
-
test("builds paths, urls, and bodies", () => {
|
|
249
|
-
const argMap = new Map<string, unknown>([
|
|
250
|
-
["id", "id-1"],
|
|
251
|
-
["tags", ["a", "b"]],
|
|
252
|
-
["q", "hello"],
|
|
253
|
-
]);
|
|
254
|
-
|
|
255
|
-
expect(HttpClient.makePath("getThing", [], undefined)).toBe("/getThing");
|
|
256
|
-
expect(HttpClient.makePath("getThing", [arg("param", "id"), arg("param", "childId")], "api")).toBe(
|
|
257
|
-
"/api/getThing/:id/:childId",
|
|
258
|
-
);
|
|
259
|
-
expect(
|
|
260
|
-
HttpClient.makeUrl("/items/:id/:missing", [arg("search", "tags", { arrDepth: 1 }), arg("search", "q")], argMap),
|
|
261
|
-
).toBe("/items/id-1/:missing?tags=a&tags=b&q=hello");
|
|
262
|
-
expect(HttpClient.makeUrl("/items", [arg("search", "empty", { nullable: true })], new Map())).toBe("/items");
|
|
263
|
-
expect(
|
|
264
|
-
FetchClient.makeHttpUrl(
|
|
265
|
-
"ping",
|
|
266
|
-
{ type: "query", args: [], returns: { refName: "String" } },
|
|
267
|
-
undefined,
|
|
268
|
-
new Map(),
|
|
269
|
-
),
|
|
270
|
-
).toBe("/ping");
|
|
271
|
-
expect(
|
|
272
|
-
FetchClient.makeHttpUrl(
|
|
273
|
-
"createUser",
|
|
274
|
-
{ type: "mutation", args: [], returns: { refName: "String" } },
|
|
275
|
-
"user",
|
|
276
|
-
new Map(),
|
|
277
|
-
),
|
|
278
|
-
).toBe("/user/createUser");
|
|
279
|
-
expect(
|
|
280
|
-
HttpClient.makeBody(
|
|
281
|
-
[arg("body", "title"), arg("body", "optional", { nullable: true })],
|
|
282
|
-
[],
|
|
283
|
-
new Map([["title", "T"]]),
|
|
284
|
-
),
|
|
285
|
-
).toEqual({
|
|
286
|
-
title: "T",
|
|
287
|
-
optional: undefined,
|
|
288
|
-
});
|
|
289
|
-
expect(() => HttpClient.makeBody([arg("body", "title")], [], new Map())).toThrow("Argument title is required");
|
|
290
|
-
|
|
291
|
-
const blob = new Blob(["hello"]);
|
|
292
|
-
const formData = HttpClient.makeBody([], [arg("upload", "file", { refName: "Upload" })], new Map([["file", blob]]));
|
|
293
|
-
expect(formData).toBeInstanceOf(FormData);
|
|
294
|
-
expect((formData as FormData).get("file")).toBeInstanceOf(Blob);
|
|
295
|
-
});
|
|
296
|
-
|
|
297
|
-
test("calls fetch with expected methods, headers, and bodies", async () => {
|
|
298
|
-
setMockFetch();
|
|
299
|
-
jsonResponses.push({ value: "get" }, { value: "post" }, { value: "put" }, { value: "delete" });
|
|
300
|
-
const client = new HttpClient("https://api.example");
|
|
301
|
-
const formData = new FormData();
|
|
302
|
-
formData.append("file", new Blob(["x"]));
|
|
303
|
-
|
|
304
|
-
expect(await client.get<{ value: string }>("/items", { headers: { Authorization: "Bearer t" } })).toEqual({
|
|
305
|
-
value: "get",
|
|
306
|
-
});
|
|
307
|
-
expect(await client.post<{ value: string }>("/items", { title: "A" })).toEqual({ value: "post" });
|
|
308
|
-
expect(await client.put<{ value: string }>("/items/1", formData)).toEqual({ value: "put" });
|
|
309
|
-
expect(await client.delete<{ value: string }>("/items/1")).toEqual({ value: "delete" });
|
|
310
|
-
|
|
311
|
-
expect(fetchCalls[0]).toMatchObject({
|
|
312
|
-
url: "https://api.example/items",
|
|
313
|
-
init: { headers: { "Content-Type": "application/json", Authorization: "Bearer t" } },
|
|
314
|
-
});
|
|
315
|
-
expect(fetchCalls[1]?.init).toMatchObject({
|
|
316
|
-
method: "POST",
|
|
317
|
-
body: JSON.stringify({ title: "A" }),
|
|
318
|
-
headers: { "Content-Type": "application/json" },
|
|
319
|
-
});
|
|
320
|
-
expect(fetchCalls[2]?.init?.headers).toEqual({});
|
|
321
|
-
expect(fetchCalls[3]?.init).toMatchObject({ method: "DELETE" });
|
|
322
|
-
});
|
|
323
|
-
|
|
324
|
-
test("restores non-ok responses with the provided error constructor", async () => {
|
|
325
|
-
setMockFetch();
|
|
326
|
-
responseStatuses.push(409);
|
|
327
|
-
jsonResponses.push({
|
|
328
|
-
error: "fetchTest.error.conflict",
|
|
329
|
-
statusCode: 409,
|
|
330
|
-
data: { id: "1" },
|
|
331
|
-
path: "/items/1",
|
|
332
|
-
timestamp: "2026-05-25T00:00:00.000Z",
|
|
333
|
-
});
|
|
334
|
-
const client = new HttpClient("https://api.example", TestErr);
|
|
335
|
-
|
|
336
|
-
const error = (await client.get("/items/1").catch((error) => error)) as TestErr;
|
|
337
|
-
|
|
338
|
-
expect(error).toBeInstanceOf(TestErr);
|
|
339
|
-
expect(error.message).toBe("fetchTest.error.conflict");
|
|
340
|
-
expect(error).toMatchObject({
|
|
341
|
-
error: "fetchTest.error.conflict",
|
|
342
|
-
statusCode: 409,
|
|
343
|
-
data: { id: "1" },
|
|
344
|
-
path: "/items/1",
|
|
345
|
-
timestamp: "2026-05-25T00:00:00.000Z",
|
|
346
|
-
});
|
|
347
|
-
});
|
|
348
|
-
});
|
|
349
|
-
|
|
350
|
-
describe("requestStorage utilities", () => {
|
|
351
|
-
test("parses cookies and returns empty request data outside context", () => {
|
|
352
|
-
const parsed = parseCookieHeader('jwt=abc; theme=j:"dark"; malformed; badJson=j:{nope}; spaced = value ');
|
|
353
|
-
|
|
354
|
-
expect(parsed.get("jwt")).toEqual({ name: "jwt", value: "abc" });
|
|
355
|
-
expect(parsed.get("theme")).toEqual({ name: "theme", value: "dark" });
|
|
356
|
-
expect(parsed.get("badJson")).toEqual({ name: "badJson", value: "j:{nope}" });
|
|
357
|
-
expect(parsed.has("malformed")).toBe(false);
|
|
358
|
-
expect(headers()).toEqual(new Map());
|
|
359
|
-
expect(cookies()).toEqual(new Map());
|
|
360
|
-
expect(getRequestTheme()).toBeUndefined();
|
|
361
|
-
});
|
|
362
|
-
|
|
363
|
-
test("scopes headers, cookies, theme, and memoized queries per request", async () => {
|
|
364
|
-
if (!requestStorage) return;
|
|
365
|
-
const reqA = new Request("https://example.test/a", {
|
|
366
|
-
headers: { authorization: "Bearer request", cookie: "jwt=requestJwt; theme=system" },
|
|
367
|
-
});
|
|
368
|
-
const reqB = new Request("https://example.test/b", {
|
|
369
|
-
headers: { cookie: "jwt=otherJwt" },
|
|
370
|
-
});
|
|
371
|
-
let calls = 0;
|
|
372
|
-
|
|
373
|
-
const first = await requestStorage.run(reqA, async () => {
|
|
374
|
-
setRequestTheme("css");
|
|
375
|
-
const a = await memoizeRequestQuery("same", async () => {
|
|
376
|
-
calls += 1;
|
|
377
|
-
return "a";
|
|
378
|
-
});
|
|
379
|
-
const b = await memoizeRequestQuery("same", async () => {
|
|
380
|
-
calls += 1;
|
|
381
|
-
return "b";
|
|
382
|
-
});
|
|
383
|
-
return { a, b, auth: headers().get("authorization"), jwt: cookies().get("jwt")?.value, theme: getRequestTheme() };
|
|
384
|
-
});
|
|
385
|
-
const second = await requestStorage.run(reqB, async () => {
|
|
386
|
-
const value = await memoizeRequestQuery("same", async () => {
|
|
387
|
-
calls += 1;
|
|
388
|
-
return "b";
|
|
389
|
-
});
|
|
390
|
-
return { value, jwt: cookies().get("jwt")?.value, theme: getRequestTheme() };
|
|
391
|
-
});
|
|
392
|
-
const outsideA = await memoizeRequestQuery("outside", async () => {
|
|
393
|
-
calls += 1;
|
|
394
|
-
return "outside-a";
|
|
395
|
-
});
|
|
396
|
-
const outsideB = await memoizeRequestQuery("outside", async () => {
|
|
397
|
-
calls += 1;
|
|
398
|
-
return "outside-b";
|
|
399
|
-
});
|
|
400
|
-
|
|
401
|
-
expect(first).toEqual({ a: "a", b: "a", auth: "Bearer request", jwt: "requestJwt", theme: "css" });
|
|
402
|
-
expect(second).toEqual({ value: "b", jwt: "otherJwt", theme: undefined });
|
|
403
|
-
expect(outsideA).toBe("outside-a");
|
|
404
|
-
expect(outsideB).toBe("outside-b");
|
|
405
|
-
expect(calls).toBe(4);
|
|
406
|
-
});
|
|
407
|
-
});
|
|
408
|
-
|
|
409
|
-
describe("FetchClient HTTP generation", () => {
|
|
410
|
-
test("classifies args and registers service query/mutation handlers", async () => {
|
|
411
|
-
setMockFetch();
|
|
412
|
-
jsonResponses.push("ok", { title: "Created", count: 2, nested: { label: "N" } });
|
|
413
|
-
const client = new FetchClient("https://api.example", {}, { service: serviceSignal });
|
|
414
|
-
client.setJwt("jwt-token");
|
|
415
|
-
|
|
416
|
-
expect(
|
|
417
|
-
FetchClient.classifyHttpArgs([
|
|
418
|
-
arg("param", "id"),
|
|
419
|
-
arg("search", "q"),
|
|
420
|
-
arg("body", "payload"),
|
|
421
|
-
arg("upload", "file"),
|
|
422
|
-
]),
|
|
423
|
-
).toMatchObject({
|
|
424
|
-
paramArgs: [{ name: "id" }],
|
|
425
|
-
searchArgs: [{ name: "q" }],
|
|
426
|
-
bodyArgs: [{ name: "payload" }],
|
|
427
|
-
uploadArgs: [{ name: "file" }],
|
|
428
|
-
});
|
|
429
|
-
|
|
430
|
-
expect(await client.handler.getThing("1234567890abcdef12345678", ["x", "y"], null)).toBe("ok");
|
|
431
|
-
const created = await client.handler.createThing("Created", 2);
|
|
432
|
-
|
|
433
|
-
expect(created).toBeInstanceOf(FetchTestFull);
|
|
434
|
-
expect((created as InstanceType<typeof FetchTestFull>).title).toBe("Created");
|
|
435
|
-
expect(fetchCalls[0]).toMatchObject({
|
|
436
|
-
url: "https://api.example/custom/1234567890abcdef12345678?tags=x&tags=y",
|
|
437
|
-
init: { headers: { "Content-Type": "application/json", Authorization: "Bearer jwt-token" } },
|
|
438
|
-
});
|
|
439
|
-
expect(fetchCalls[1]).toMatchObject({
|
|
440
|
-
url: "https://api.example/createThing",
|
|
441
|
-
init: {
|
|
442
|
-
method: "POST",
|
|
443
|
-
body: JSON.stringify({ title: "Created", count: 2 }),
|
|
444
|
-
headers: { "Content-Type": "application/json", Authorization: "Bearer jwt-token" },
|
|
445
|
-
},
|
|
446
|
-
});
|
|
447
|
-
});
|
|
448
|
-
|
|
449
|
-
test("supports explicit auth token, request auth, crystalize false, upload bodies, and clone", async () => {
|
|
450
|
-
setMockFetch();
|
|
451
|
-
jsonResponses.push({ title: "Raw", count: 1, nested: { label: "N" } }, "RequestAuth", "uploaded", "cloned");
|
|
452
|
-
const client = new FetchClient("https://api.example", {}, { service: serviceSignal });
|
|
453
|
-
const file = new Blob(["file"]);
|
|
454
|
-
|
|
455
|
-
const raw = await client.handler.createThing("Raw", 1, { token: "explicit", crystalize: false });
|
|
456
|
-
const requestResult = requestStorage
|
|
457
|
-
? await requestStorage.run(
|
|
458
|
-
new Request("https://example.test", { headers: { authorization: "Bearer request-token" } }),
|
|
459
|
-
async () => {
|
|
460
|
-
setAkanPublicEnv();
|
|
461
|
-
return await client.handler.getThing("abcdefabcdefabcdefabcdef", [], null);
|
|
462
|
-
},
|
|
463
|
-
)
|
|
464
|
-
: "RequestAuth";
|
|
465
|
-
const uploaded = await client.handler.uploadThing(file, "file-title");
|
|
466
|
-
const cloned = client.clone({ origin: "https://clone.example", connect: false, jwt: "clone-jwt" });
|
|
467
|
-
const cloneResult = await (
|
|
468
|
-
cloned as unknown as { getThing: (id: string, tags: string[], empty: null) => Promise<unknown> }
|
|
469
|
-
).getThing("bbbbbbbbbbbbbbbbbbbbbbbb", [], null);
|
|
470
|
-
|
|
471
|
-
expect(raw).toEqual({ title: "Raw", count: 1, nested: { label: "N" } });
|
|
472
|
-
expect(requestResult).toBe("RequestAuth");
|
|
473
|
-
expect(uploaded).toBe("uploaded");
|
|
474
|
-
expect(cloneResult).toBe("cloned");
|
|
475
|
-
expect(fetchCalls[0]?.init?.headers).toMatchObject({ Authorization: "Bearer explicit" });
|
|
476
|
-
expect(fetchCalls[1]?.init?.headers).toMatchObject({ Authorization: "Bearer request-token" });
|
|
477
|
-
expect(fetchCalls[2]?.init?.body).toBeInstanceOf(FormData);
|
|
478
|
-
expect(fetchCalls[2]?.init?.headers).toEqual({});
|
|
479
|
-
expect(fetchCalls[3]).toMatchObject({
|
|
480
|
-
url: "https://clone.example/custom/bbbbbbbbbbbbbbbbbbbbbbbb",
|
|
481
|
-
init: { headers: { "Content-Type": "application/json", Authorization: "Bearer clone-jwt" } },
|
|
482
|
-
});
|
|
483
|
-
});
|
|
484
|
-
|
|
485
|
-
test("sends requests to the FetchPolicy.origin host instead of the client origin", async () => {
|
|
486
|
-
setMockFetch();
|
|
487
|
-
jsonResponses.push("pong", { title: "Created", count: 2, nested: { label: "N" } });
|
|
488
|
-
const client = new FetchClient("https://api.example", {}, { service: serviceSignal });
|
|
489
|
-
|
|
490
|
-
// trailing slash on the override host must be normalized away
|
|
491
|
-
const queried = await client.handler.getThing("1234567890abcdef12345678", [], null, {
|
|
492
|
-
origin: "https://akasys-debug.akamir.com/",
|
|
493
|
-
});
|
|
494
|
-
const created = await client.handler.createThing("Created", 2, { origin: "https://akasys-debug.akamir.com" });
|
|
495
|
-
|
|
496
|
-
expect(queried).toBe("pong");
|
|
497
|
-
expect(created).toBeInstanceOf(FetchTestFull);
|
|
498
|
-
expect(fetchCalls[0]?.url).toBe("https://akasys-debug.akamir.com/custom/1234567890abcdef12345678");
|
|
499
|
-
expect(fetchCalls[1]?.url).toBe("https://akasys-debug.akamir.com/createThing");
|
|
500
|
-
});
|
|
501
|
-
|
|
502
|
-
test("uses FetchPolicy.origin verbatim, including the global api prefix supplied by the caller", async () => {
|
|
503
|
-
setMockFetch();
|
|
504
|
-
jsonResponses.push("pong", { title: "Created", count: 2, nested: { label: "N" } });
|
|
505
|
-
const client = new FetchClient("https://api.example/api", {}, { service: serviceSignal });
|
|
506
|
-
|
|
507
|
-
// the caller is responsible for including the server global prefix (e.g. "/api")
|
|
508
|
-
const queried = await client.handler.getThing("1234567890abcdef12345678", [], null, {
|
|
509
|
-
origin: "https://edge.example.com/api",
|
|
510
|
-
});
|
|
511
|
-
const created = await client.handler.createThing("Created", 2, { origin: "https://edge.example.com/api" });
|
|
512
|
-
|
|
513
|
-
expect(queried).toBe("pong");
|
|
514
|
-
expect(created).toBeInstanceOf(FetchTestFull);
|
|
515
|
-
expect(fetchCalls[0]?.url).toBe("https://edge.example.com/api/custom/1234567890abcdef12345678");
|
|
516
|
-
expect(fetchCalls[1]?.url).toBe("https://edge.example.com/api/createThing");
|
|
517
|
-
});
|
|
518
|
-
|
|
519
|
-
test("bypasses the request-query cache when FetchPolicy.origin is set", async () => {
|
|
520
|
-
if (!requestStorage) return;
|
|
521
|
-
setMockFetch();
|
|
522
|
-
jsonResponses.push("origin", "override-1", "override-2");
|
|
523
|
-
const client = new FetchClient("https://api.example", {}, { service: serviceSignal });
|
|
524
|
-
|
|
525
|
-
const result = await requestStorage.run(new Request("https://example.test"), async () => {
|
|
526
|
-
const cachedA = await client.handler.getThing("1234567890abcdef12345678", [], null);
|
|
527
|
-
const cachedB = await client.handler.getThing("1234567890abcdef12345678", [], null);
|
|
528
|
-
const overrideA = await client.handler.getThing("1234567890abcdef12345678", [], null, {
|
|
529
|
-
origin: "https://akasys-debug.akamir.com",
|
|
530
|
-
});
|
|
531
|
-
const overrideB = await client.handler.getThing("1234567890abcdef12345678", [], null, {
|
|
532
|
-
origin: "https://akasys-debug.akamir.com",
|
|
533
|
-
});
|
|
534
|
-
return { cachedA, cachedB, overrideA, overrideB };
|
|
535
|
-
});
|
|
536
|
-
|
|
537
|
-
// origin requests share the memoized cache: the second call reuses the first response
|
|
538
|
-
expect(result.cachedA).toBe("origin");
|
|
539
|
-
expect(result.cachedB).toBe("origin");
|
|
540
|
-
// url overrides skip the cache entirely: each call performs a fresh fetch
|
|
541
|
-
expect(result.overrideA).toBe("override-1");
|
|
542
|
-
expect(result.overrideB).toBe("override-2");
|
|
543
|
-
expect(fetchCalls.map((call) => call.url)).toEqual([
|
|
544
|
-
"https://api.example/custom/1234567890abcdef12345678",
|
|
545
|
-
"https://akasys-debug.akamir.com/custom/1234567890abcdef12345678",
|
|
546
|
-
"https://akasys-debug.akamir.com/custom/1234567890abcdef12345678",
|
|
547
|
-
]);
|
|
548
|
-
});
|
|
549
|
-
|
|
550
|
-
test("clone targets the new origin for queries and mutations while leaving the original intact", async () => {
|
|
551
|
-
setMockFetch();
|
|
552
|
-
jsonResponses.push({ title: "Created", count: 2, nested: { label: "N" } }, "clone-query", "origin-query");
|
|
553
|
-
const client = new FetchClient("https://api.example", {}, { service: serviceSignal });
|
|
554
|
-
client.setJwt("origin-jwt");
|
|
555
|
-
const cloned = client.clone({ origin: "https://clone.example", connect: false, jwt: "clone-jwt" }) as unknown as {
|
|
556
|
-
getThing: (id: string, tags: string[], empty: null) => Promise<unknown>;
|
|
557
|
-
createThing: (title: string, count: number) => Promise<unknown>;
|
|
558
|
-
};
|
|
559
|
-
|
|
560
|
-
const created = await cloned.createThing("Created", 2);
|
|
561
|
-
const cloneQuery = await cloned.getThing("1234567890abcdef12345678", [], null);
|
|
562
|
-
const originQuery = await client.handler.getThing("1234567890abcdef12345678", [], null);
|
|
563
|
-
|
|
564
|
-
expect(created).toBeInstanceOf(FetchTestFull);
|
|
565
|
-
expect(cloneQuery).toBe("clone-query");
|
|
566
|
-
expect(originQuery).toBe("origin-query");
|
|
567
|
-
// clone routes mutations and queries to the new origin with its own jwt
|
|
568
|
-
expect(fetchCalls[0]).toMatchObject({
|
|
569
|
-
url: "https://clone.example/createThing",
|
|
570
|
-
init: { headers: { Authorization: "Bearer clone-jwt" } },
|
|
571
|
-
});
|
|
572
|
-
expect(fetchCalls[1]).toMatchObject({ url: "https://clone.example/custom/1234567890abcdef12345678" });
|
|
573
|
-
// original client keeps its own origin and jwt, unaffected by the clone
|
|
574
|
-
expect(fetchCalls[2]).toMatchObject({
|
|
575
|
-
url: "https://api.example/custom/1234567890abcdef12345678",
|
|
576
|
-
init: { headers: { Authorization: "Bearer origin-jwt" } },
|
|
577
|
-
});
|
|
578
|
-
});
|
|
579
|
-
|
|
580
|
-
test("clone with a different origin does not share the request-query cache with the original", async () => {
|
|
581
|
-
if (!requestStorage) return;
|
|
582
|
-
setMockFetch();
|
|
583
|
-
jsonResponses.push("origin-resp", "clone-resp");
|
|
584
|
-
const client = new FetchClient("https://api.example", {}, { service: serviceSignal });
|
|
585
|
-
const cloned = client.clone({ origin: "https://clone.example", connect: false }) as unknown as {
|
|
586
|
-
getThing: (id: string, tags: string[], empty: null) => Promise<unknown>;
|
|
587
|
-
};
|
|
588
|
-
|
|
589
|
-
const result = await requestStorage.run(new Request("https://example.test"), async () => {
|
|
590
|
-
const originA = await client.handler.getThing("1234567890abcdef12345678", [], null);
|
|
591
|
-
const cloneA = await cloned.getThing("1234567890abcdef12345678", [], null);
|
|
592
|
-
const originB = await client.handler.getThing("1234567890abcdef12345678", [], null);
|
|
593
|
-
const cloneB = await cloned.getThing("1234567890abcdef12345678", [], null);
|
|
594
|
-
return { originA, cloneA, originB, cloneB };
|
|
595
|
-
});
|
|
596
|
-
|
|
597
|
-
// the cache key is scoped by origin, so origin and clone resolve to different responses
|
|
598
|
-
expect(result.originA).toBe("origin-resp");
|
|
599
|
-
expect(result.cloneA).toBe("clone-resp");
|
|
600
|
-
// repeated calls reuse each client's own cached response, so no extra fetches happen
|
|
601
|
-
expect(result.originB).toBe("origin-resp");
|
|
602
|
-
expect(result.cloneB).toBe("clone-resp");
|
|
603
|
-
expect(fetchCalls.map((call) => call.url)).toEqual([
|
|
604
|
-
"https://api.example/custom/1234567890abcdef12345678",
|
|
605
|
-
"https://clone.example/custom/1234567890abcdef12345678",
|
|
606
|
-
]);
|
|
607
|
-
});
|
|
608
|
-
});
|
|
609
|
-
|
|
610
|
-
describe("FetchClient database signal helpers", () => {
|
|
611
|
-
test("registers database base model, slice, and filter metadata", async () => {
|
|
612
|
-
setMockFetch();
|
|
613
|
-
jsonResponses.push(
|
|
614
|
-
{ title: "Full", count: 1, nested: { label: "N" } },
|
|
615
|
-
{ title: "Light", count: 1, nested: { label: "N" } },
|
|
616
|
-
{ title: "Created", count: 2, nested: { label: "N" } },
|
|
617
|
-
{ title: "Updated", count: 3, nested: { label: "N" } },
|
|
618
|
-
{ title: "Removed", count: 4, nested: { label: "N" } },
|
|
619
|
-
[{ title: "List", count: 1, nested: { label: "N" } }],
|
|
620
|
-
{ count: 1 },
|
|
621
|
-
[{ title: "Init", count: 1, nested: { label: "N" } }],
|
|
622
|
-
{ count: 1 },
|
|
623
|
-
[{ title: "DefaultInit", count: 1, nested: { label: "N" } }],
|
|
624
|
-
{ count: 1 },
|
|
625
|
-
);
|
|
626
|
-
const client = new FetchClient("https://api.example", {}, { fetchTestItem: databaseSignal });
|
|
627
|
-
|
|
628
|
-
const full = await client.handler.fetchTestItem("1234567890abcdef12345678");
|
|
629
|
-
const light = await client.handler.lightFetchTestItem("1234567890abcdef12345678");
|
|
630
|
-
const created = await client.handler.createFetchTestItem({ title: "Created", count: 2, nested: { label: "N" } });
|
|
631
|
-
const updated = await client.handler.updateFetchTestItem("1234567890abcdef12345678", {
|
|
632
|
-
title: "Updated",
|
|
633
|
-
count: 3,
|
|
634
|
-
nested: { label: "N" },
|
|
635
|
-
});
|
|
636
|
-
const removed = await client.handler.removeFetchTestItem("1234567890abcdef12345678");
|
|
637
|
-
const list = (await client.handler.fetchTestItemListByOwner(
|
|
638
|
-
"abcdefabcdefabcdefabcdef",
|
|
639
|
-
0,
|
|
640
|
-
10,
|
|
641
|
-
"latest",
|
|
642
|
-
)) as unknown[];
|
|
643
|
-
const insight = await client.handler.fetchTestItemInsightByOwner("abcdefabcdefabcdefabcdef");
|
|
644
|
-
const init = (await client.handler.initFetchTestItemByOwner("abcdefabcdefabcdefabcdef", {
|
|
645
|
-
page: 1,
|
|
646
|
-
limit: 10,
|
|
647
|
-
sort: "latest",
|
|
648
|
-
})) as Record<string, unknown>;
|
|
649
|
-
const defaultInit = (await client.handler.initFetchTestItem()) as Record<string, Record<string, unknown>>;
|
|
650
|
-
|
|
651
|
-
expect(full).toBeInstanceOf(FetchTestFull);
|
|
652
|
-
expect(light).toBeInstanceOf(FetchTestLight);
|
|
653
|
-
expect(created).toBeInstanceOf(FetchTestFull);
|
|
654
|
-
expect(updated).toBeInstanceOf(FetchTestFull);
|
|
655
|
-
expect(removed).toBeInstanceOf(FetchTestFull);
|
|
656
|
-
expect(list[0]).toBeInstanceOf(FetchTestLight);
|
|
657
|
-
expect(insight).toBeInstanceOf(FetchTestInsight);
|
|
658
|
-
expect(init.fetchTestItemListByOwner).toBeInstanceOf(DataList);
|
|
659
|
-
expect(init.fetchTestItemInsightByOwner).toBeInstanceOf(FetchTestInsight);
|
|
660
|
-
expect(defaultInit.fetchTestItemInit.queryArgsOfFetchTestItem).toEqual([]);
|
|
661
|
-
expect(client.slice.fetchTestItemByOwner).toEqual({
|
|
662
|
-
refName: "fetchTestItem",
|
|
663
|
-
sliceName: "fetchTestItemByOwner",
|
|
664
|
-
argLength: 1,
|
|
665
|
-
});
|
|
666
|
-
expect(client.sortKeyMap.get("fetchTestItem")).toEqual(["latest", "oldest"]);
|
|
667
|
-
expect(fetchCalls.map((call) => call.url)).toEqual([
|
|
668
|
-
"https://api.example/fetchTest/fetchTestItem/1234567890abcdef12345678",
|
|
669
|
-
"https://api.example/fetchTest/lightFetchTestItem/1234567890abcdef12345678",
|
|
670
|
-
"https://api.example/fetchTest/createFetchTestItem",
|
|
671
|
-
"https://api.example/fetchTest/updateFetchTestItem/1234567890abcdef12345678",
|
|
672
|
-
"https://api.example/fetchTest/removeFetchTestItem/1234567890abcdef12345678",
|
|
673
|
-
"https://api.example/fetchTest/fetchTestItemListByOwner/abcdefabcdefabcdefabcdef?skip=0&limit=10&sort=latest",
|
|
674
|
-
"https://api.example/fetchTest/fetchTestItemInsightByOwner/abcdefabcdefabcdefabcdef",
|
|
675
|
-
"https://api.example/fetchTest/fetchTestItemListByOwner/abcdefabcdefabcdefabcdef?skip=0&limit=10&sort=latest",
|
|
676
|
-
"https://api.example/fetchTest/fetchTestItemInsightByOwner/abcdefabcdefabcdefabcdef",
|
|
677
|
-
"https://api.example/fetchTest/fetchTestItemList?skip=0&limit=20&sort=latest",
|
|
678
|
-
"https://api.example/fetchTest/fetchTestItemInsight",
|
|
679
|
-
]);
|
|
680
|
-
});
|
|
681
|
-
|
|
682
|
-
test("creates view/edit helpers and merge helper from base model endpoints", async () => {
|
|
683
|
-
setMockFetch();
|
|
684
|
-
jsonResponses.push(
|
|
685
|
-
{ title: "View", count: 1, nested: { label: "N" } },
|
|
686
|
-
{ title: "ViewRaw", count: 1, nested: { label: "N" } },
|
|
687
|
-
{ title: "Updated", count: 2, nested: { label: "N" } },
|
|
688
|
-
);
|
|
689
|
-
const client = new FetchClient("https://api.example", {}, { fetchTestItem: databaseSignal });
|
|
690
|
-
|
|
691
|
-
const view = (await client.handler.viewFetchTestItem("1234567890abcdef12345678")) as {
|
|
692
|
-
fetchTestItem: unknown;
|
|
693
|
-
fetchTestItemView: { fetchTestItemObj: unknown };
|
|
694
|
-
};
|
|
695
|
-
const edit = (await client.handler.getFetchTestItemEdit("abcdefabcdefabcdefabcdef")) as {
|
|
696
|
-
fetchTestItemObj: unknown;
|
|
697
|
-
};
|
|
698
|
-
const merged = await client.handler.mergeFetchTestItem(
|
|
699
|
-
{ id: "bbbbbbbbbbbbbbbbbbbbbbbb" },
|
|
700
|
-
{ title: "Merged", count: 2, nested: { label: "N" } },
|
|
701
|
-
);
|
|
702
|
-
|
|
703
|
-
expect(view.fetchTestItem).toBeInstanceOf(FetchTestFull);
|
|
704
|
-
expect(view.fetchTestItemView.fetchTestItemObj).toMatchObject({ title: "View" });
|
|
705
|
-
expect(edit.fetchTestItemObj).toMatchObject({ title: "ViewRaw" });
|
|
706
|
-
expect(merged).toBeInstanceOf(FetchTestFull);
|
|
707
|
-
expect(fetchCalls.at(-1)?.url).toBe("https://api.example/fetchTest/updateFetchTestItem/bbbbbbbbbbbbbbbbbbbbbbbb");
|
|
708
|
-
});
|
|
709
|
-
});
|
|
710
|
-
|
|
711
|
-
describe("WsClient", () => {
|
|
712
|
-
test("manages websocket lifecycle, messages, listeners, and subscriptions", () => {
|
|
713
|
-
setFakeWebSocket();
|
|
714
|
-
const client = new WsClient("ws://example/ws");
|
|
715
|
-
const messages: unknown[] = [];
|
|
716
|
-
const onceMessages: unknown[] = [];
|
|
717
|
-
const pubsubMessages: unknown[] = [];
|
|
718
|
-
|
|
719
|
-
expect(WsClient.makeRoomId("room", ["a", "b"])).toBe("room-a-b");
|
|
720
|
-
client.connect();
|
|
721
|
-
const ws = FakeWebSocket.instances[0];
|
|
722
|
-
ws.open();
|
|
723
|
-
expect(client.connected).toBe(true);
|
|
724
|
-
|
|
725
|
-
client.emit("send", ["hello"]);
|
|
726
|
-
expect(JSON.parse(ws.sent.at(-1) ?? "{}")).toEqual({ key: "send", data: ["hello"] });
|
|
727
|
-
|
|
728
|
-
const listener = (data: unknown) => messages.push(data);
|
|
729
|
-
client.on("messageKey", listener).once("messageKey", (data) => onceMessages.push(data));
|
|
730
|
-
expect(client.hasListeners("messageKey")).toBe(true);
|
|
731
|
-
ws.receive({ type: "msg", key: "messageKey", data: { value: 1 } });
|
|
732
|
-
ws.receive({ type: "msg", key: "messageKey", data: { value: 2 } });
|
|
733
|
-
expect(messages).toEqual([{ value: 1 }, { value: 2 }]);
|
|
734
|
-
expect(onceMessages).toEqual([{ value: 1 }]);
|
|
735
|
-
client.off("messageKey", listener);
|
|
736
|
-
expect(client.hasListeners("messageKey")).toBe(false);
|
|
737
|
-
|
|
738
|
-
const handlePubsub = (data: unknown) => pubsubMessages.push(data);
|
|
739
|
-
client.subscribe({ key: "roomKey", data: ["r1"], handleEvent: handlePubsub });
|
|
740
|
-
expect(JSON.parse(ws.sent.at(-1) ?? "{}")).toEqual({ key: "roomKey", data: ["r1"], subscribe: true });
|
|
741
|
-
ws.receive({ type: "pub", roomId: "roomKey-r1", data: { title: "event" } });
|
|
742
|
-
expect(pubsubMessages).toEqual([{ title: "event" }]);
|
|
743
|
-
expect(client.hasListeners("roomKey-r1")).toBe(true);
|
|
744
|
-
client.unsubscribe({ key: "roomKey", data: ["r1"], handleEvent: handlePubsub });
|
|
745
|
-
expect(JSON.parse(ws.sent.at(-1) ?? "{}")).toEqual({ key: "roomKey", data: ["r1"], subscribe: false });
|
|
746
|
-
expect(client.hasListeners("roomKey-r1")).toBe(false);
|
|
747
|
-
|
|
748
|
-
client.removeAllListeners("messageKey");
|
|
749
|
-
client.destroy();
|
|
750
|
-
expect(FakeWebSocket.instances[0]?.readyState).toBe(FakeWebSocket.CLOSED);
|
|
751
|
-
});
|
|
752
|
-
|
|
753
|
-
test("restores websocket error payloads with the provided error constructor", () => {
|
|
754
|
-
setFakeWebSocket();
|
|
755
|
-
const originalConsoleError = console.error;
|
|
756
|
-
const errors: unknown[] = [];
|
|
757
|
-
console.error = ((error: unknown) => {
|
|
758
|
-
errors.push(error);
|
|
759
|
-
}) as typeof console.error;
|
|
760
|
-
try {
|
|
761
|
-
const client = new WsClient("ws://example/ws", TestErr);
|
|
762
|
-
client.connect();
|
|
763
|
-
const ws = FakeWebSocket.instances[0];
|
|
764
|
-
ws.open();
|
|
765
|
-
|
|
766
|
-
ws.receive({
|
|
767
|
-
error: "chatRoom.error.notMember",
|
|
768
|
-
statusCode: 403,
|
|
769
|
-
data: { chatRoomId: "room-1" },
|
|
770
|
-
timestamp: "2026-05-25T00:00:00.000Z",
|
|
771
|
-
});
|
|
772
|
-
|
|
773
|
-
expect(errors[0]).toBeInstanceOf(TestErr);
|
|
774
|
-
expect(errors[0]).toMatchObject({
|
|
775
|
-
error: "chatRoom.error.notMember",
|
|
776
|
-
statusCode: 403,
|
|
777
|
-
data: { chatRoomId: "room-1" },
|
|
778
|
-
timestamp: "2026-05-25T00:00:00.000Z",
|
|
779
|
-
});
|
|
780
|
-
} finally {
|
|
781
|
-
console.error = originalConsoleError;
|
|
782
|
-
}
|
|
783
|
-
});
|
|
784
|
-
|
|
785
|
-
test("resubscribes rooms on reconnect and destroy prevents reconnect", async () => {
|
|
786
|
-
setFakeWebSocket();
|
|
787
|
-
globalThis.setTimeout = ((handler: TimerHandler, _timeout?: number, ...args: unknown[]) =>
|
|
788
|
-
originalSetTimeout(handler, 0, ...args)) as typeof setTimeout;
|
|
789
|
-
const client = new WsClient("ws://example/ws");
|
|
790
|
-
const handleEvent = () => undefined;
|
|
791
|
-
client.connect();
|
|
792
|
-
const firstWs = FakeWebSocket.instances[0];
|
|
793
|
-
firstWs.open();
|
|
794
|
-
client.subscribe({ key: "roomKey", data: ["r1"], handleEvent });
|
|
795
|
-
|
|
796
|
-
firstWs.close();
|
|
797
|
-
await new Promise((resolve) => originalSetTimeout(resolve, 5));
|
|
798
|
-
const secondWs = FakeWebSocket.instances[1];
|
|
799
|
-
secondWs.open();
|
|
800
|
-
expect(JSON.parse(secondWs.sent[0] ?? "{}")).toEqual({ key: "roomKey", data: ["r1"], subscribe: true });
|
|
801
|
-
|
|
802
|
-
client.destroy();
|
|
803
|
-
const instanceCount = FakeWebSocket.instances.length;
|
|
804
|
-
secondWs.close();
|
|
805
|
-
await new Promise((resolve) => originalSetTimeout(resolve, 5));
|
|
806
|
-
expect(FakeWebSocket.instances).toHaveLength(instanceCount);
|
|
807
|
-
});
|
|
808
|
-
});
|
|
809
|
-
|
|
810
|
-
describe("FetchClient websocket generation", () => {
|
|
811
|
-
test("registers message and pubsub handlers from serialized endpoints", async () => {
|
|
812
|
-
setFakeWebSocket();
|
|
813
|
-
const client = new FetchClient("https://api.example", {}, { service: serviceSignal });
|
|
814
|
-
client.connect();
|
|
815
|
-
const ws = FakeWebSocket.instances[0];
|
|
816
|
-
ws.open();
|
|
817
|
-
const listened: unknown[] = [];
|
|
818
|
-
const published: unknown[] = [];
|
|
819
|
-
|
|
820
|
-
await client.handler.sendThing("hello");
|
|
821
|
-
const cleanupMessage = client.handler.listenSendThing((data: unknown) => listened.push(data)) as () => void;
|
|
822
|
-
ws.receive({ type: "msg", key: "sendThing", data: "server-message" });
|
|
823
|
-
cleanupMessage();
|
|
824
|
-
ws.receive({ type: "msg", key: "sendThing", data: "after-cleanup" });
|
|
825
|
-
const cleanupPubsub = (await client.handler.subscribeRoomThing("room-1", (data: unknown) =>
|
|
826
|
-
published.push(data),
|
|
827
|
-
)) as () => void;
|
|
828
|
-
ws.receive({ type: "pub", roomId: "roomThing-room-1", data: { title: "Published" } });
|
|
829
|
-
cleanupPubsub();
|
|
830
|
-
|
|
831
|
-
expect(JSON.parse(ws.sent[0] ?? "{}")).toEqual({ key: "sendThing", data: ["hello"] });
|
|
832
|
-
expect(listened).toEqual(["server-message"]);
|
|
833
|
-
expect(JSON.parse(ws.sent[1] ?? "{}")).toEqual({ key: "roomThing", data: ["room-1"], subscribe: true });
|
|
834
|
-
expect(published[0]).toBeInstanceOf(FetchTestLight);
|
|
835
|
-
expect((published[0] as InstanceType<typeof FetchTestLight>).title).toBe("Published");
|
|
836
|
-
expect(JSON.parse(ws.sent[2] ?? "{}")).toEqual({ key: "roomThing", data: ["room-1"], subscribe: false });
|
|
837
|
-
});
|
|
838
|
-
});
|