akanjs 2.0.6 → 2.1.0-rc.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.ko.md +5 -5
- package/README.md +5 -5
- package/client/router.ts +10 -3
- package/constant/serialize.ts +1 -1
- package/document/documentSchema.ts +9 -1
- package/index.ts +187 -0
- package/package.json +6 -50
- package/server/akanApp.ts +49 -30
- package/server/akanAppHeaders.ts +30 -0
- package/server/di/predefinedAdaptor.ts +1 -1
- package/server/processMetricsCollector.ts +79 -1
- package/server/resolver/database.resolver.ts +82 -31
- package/server/resolver/signal.resolver.ts +67 -28
- package/service/ipcTypes.ts +5 -0
- package/service/predefinedAdaptor/database.adaptor.ts +95 -27
- package/service/predefinedAdaptor/solidSqlite.ts +7 -7
- package/service/predefinedAdaptor/storage.adaptor.ts +35 -9
- package/signal/index.ts +1 -0
- package/signal/middleware.ts +5 -1
- package/signal/signalContext.ts +85 -31
- package/signal/trace.ts +279 -0
- package/types/dictionary/base.dictionary.d.ts +1 -1
- package/types/dictionary/dictionary.d.ts +8 -8
- package/types/document/documentSchema.d.ts +33 -0
- package/types/document/index.d.ts +1 -1
- package/types/document/schema.d.ts +1 -1
- package/types/document/types.d.ts +1 -1
- package/types/{devkit/akanConfig/types.d.ts → index.d.ts} +45 -54
- package/types/server/akanAppHeaders.d.ts +1 -0
- package/types/server/di/predefinedAdaptor.d.ts +1 -1
- package/types/server/processMetricsCollector.d.ts +2 -0
- package/types/service/ipcTypes.d.ts +5 -0
- package/types/service/predefinedAdaptor/database.adaptor.d.ts +26 -32
- package/types/service/predefinedAdaptor/solidSqlite.d.ts +3 -3
- package/types/service/predefinedAdaptor/storage.adaptor.d.ts +8 -2
- package/types/signal/index.d.ts +1 -0
- package/types/signal/signalContext.d.ts +4 -1
- package/types/signal/trace.d.ts +97 -0
- package/types/store/baseSt.d.ts +2 -2
- package/types/ui/Signal/style.d.ts +15 -0
- package/ui/Link/SsrLink.tsx +2 -2
- package/ui/Signal/Arg.tsx +22 -15
- package/ui/Signal/Doc.tsx +28 -21
- package/ui/Signal/Listener.tsx +15 -39
- package/ui/Signal/Message.tsx +32 -50
- package/ui/Signal/Object.tsx +16 -13
- package/ui/Signal/PubSub.tsx +29 -47
- package/ui/Signal/Response.tsx +7 -17
- package/ui/Signal/RestApi.tsx +41 -57
- package/ui/Signal/WebSocket.tsx +1 -1
- package/ui/Signal/style.ts +36 -0
- package/webkit/useCodepush.tsx +1 -1
- package/webkit/useCsrValues.ts +147 -37
- package/cli/application/application.command.ts +0 -221
- package/cli/application/application.interface.tsx +0 -225
- package/cli/application/application.runner.ts +0 -357
- package/cli/application/application.script.ts +0 -244
- package/cli/build.ts +0 -26
- package/cli/cloud/cloud.command.ts +0 -48
- package/cli/cloud/cloud.runner.ts +0 -157
- package/cli/cloud/cloud.script.ts +0 -40
- package/cli/guideline/guideline.command.ts +0 -31
- package/cli/guideline/guideline.prompt.ts +0 -212
- package/cli/guideline/guideline.runner.ts +0 -53
- package/cli/guideline/guideline.script.ts +0 -33
- package/cli/guidelines/___library/sharedUiStructureDescription.en.md +0 -767
- package/cli/guidelines/___library/utilUiStructureDescription.en.md +0 -395
- package/cli/guidelines/___lint/lintRuleDescription.en.md +0 -64
- package/cli/guidelines/___module/moduleStructureDescription.en.md +0 -80
- package/cli/guidelines/componentRule/componentRule.generate.json +0 -131
- package/cli/guidelines/componentRule/componentRule.instruction.md +0 -637
- package/cli/guidelines/cssRule/cssRule.generate.json +0 -93
- package/cli/guidelines/cssRule/cssRule.instruction.md +0 -435
- package/cli/guidelines/databaseModule/databaseModule.generate.json +0 -51
- package/cli/guidelines/databaseModule/databaseModule.instruction.md +0 -612
- package/cli/guidelines/docPageRule/docPageRule.generate.json +0 -72
- package/cli/guidelines/docPageRule/docPageRule.instruction.md +0 -389
- package/cli/guidelines/enumConstant/enumConstant.generate.json +0 -24
- package/cli/guidelines/enumConstant/enumConstant.instruction.md +0 -232
- package/cli/guidelines/framework/framework.generate.json +0 -119
- package/cli/guidelines/framework/framework.instruction.md +0 -1110
- package/cli/guidelines/howToUseStore/howToUseStore.generate.json +0 -0
- package/cli/guidelines/modelConstant/modelConstant.generate.json +0 -128
- package/cli/guidelines/modelConstant/modelConstant.instruction.md +0 -506
- package/cli/guidelines/modelDictionary/modelDictionary.generate.json +0 -108
- package/cli/guidelines/modelDictionary/modelDictionary.instruction.md +0 -547
- package/cli/guidelines/modelDocument/modelDocument.generate.json +0 -129
- package/cli/guidelines/modelDocument/modelDocument.instruction.md +0 -509
- package/cli/guidelines/modelService/modelService.generate.json +0 -135
- package/cli/guidelines/modelService/modelService.instruction.md +0 -708
- package/cli/guidelines/modelSignal/modelSignal.generate.json +0 -201
- package/cli/guidelines/modelSignal/modelSignal.instruction.md +0 -552
- package/cli/guidelines/modelStore/modelStore.generate.json +0 -130
- package/cli/guidelines/modelStore/modelStore.instruction.md +0 -585
- package/cli/guidelines/modelTemplate/modelTemplate.generate.json +0 -104
- package/cli/guidelines/modelTemplate/modelTemplate.instruction.md +0 -604
- package/cli/guidelines/modelUnit/modelUnit.generate.json +0 -92
- package/cli/guidelines/modelUnit/modelUnit.instruction.md +0 -541
- package/cli/guidelines/modelUtil/modelUtil.generate.json +0 -93
- package/cli/guidelines/modelUtil/modelUtil.instruction.md +0 -752
- package/cli/guidelines/modelView/modelView.generate.json +0 -80
- package/cli/guidelines/modelView/modelView.instruction.md +0 -1005
- package/cli/guidelines/modelZone/modelZone.generate.json +0 -126
- package/cli/guidelines/modelZone/modelZone.instruction.md +0 -528
- package/cli/guidelines/scalarConstant/scalarConstant.generate.json +0 -106
- package/cli/guidelines/scalarConstant/scalarConstant.instruction.md +0 -442
- package/cli/guidelines/scalarDictionary/scalarDictionary.generate.json +0 -83
- package/cli/guidelines/scalarDictionary/scalarDictionary.instruction.md +0 -273
- package/cli/guidelines/scalarModule/scalarModule.generate.json +0 -35
- package/cli/guidelines/scalarModule/scalarModule.instruction.md +0 -81
- package/cli/guidelines/sharedUiUsage/sharedUiUsage.generate.json +0 -108
- package/cli/guidelines/sharedUiUsage/sharedUiUsage.instruction.md +0 -310
- package/cli/guidelines/utilUiUsage/utilUiUsage.generate.json +0 -140
- package/cli/guidelines/utilUiUsage/utilUiUsage.instruction.md +0 -339
- package/cli/index.js +0 -184404
- package/cli/index.ts +0 -24
- package/cli/library/library.command.ts +0 -28
- package/cli/library/library.runner.ts +0 -66
- package/cli/library/library.script.ts +0 -39
- package/cli/module/module.command.ts +0 -35
- package/cli/module/module.prompt.ts +0 -18
- package/cli/module/module.request.ts +0 -319
- package/cli/module/module.runner.ts +0 -76
- package/cli/module/module.script.ts +0 -161
- package/cli/npmRegistry.ts +0 -13
- package/cli/openBrowser.ts +0 -15
- package/cli/package/package.command.ts +0 -32
- package/cli/package/package.runner.ts +0 -94
- package/cli/package/package.script.ts +0 -35
- package/cli/page/page.command.ts +0 -14
- package/cli/page/page.runner.ts +0 -14
- package/cli/page/page.script.ts +0 -12
- package/cli/pluralizeName.ts +0 -5
- package/cli/scalar/scalar.command.ts +0 -21
- package/cli/scalar/scalar.prompt.ts +0 -131
- package/cli/scalar/scalar.runner.ts +0 -38
- package/cli/scalar/scalar.script.ts +0 -16
- package/cli/semver.ts +0 -18
- package/cli/templates/__scalar/__model__/__model__.constant.ts +0 -15
- package/cli/templates/__scalar/__model__/__model__.dictionary.ts +0 -19
- package/cli/templates/__scalar/__model__/__model__.document.ts +0 -15
- package/cli/templates/app/akan.config.ts +0 -14
- package/cli/templates/app/env/env.client.debug.ts.template +0 -7
- package/cli/templates/app/env/env.client.develop.ts.template +0 -7
- package/cli/templates/app/env/env.client.local.ts.template +0 -7
- package/cli/templates/app/env/env.client.main.ts.template +0 -7
- package/cli/templates/app/env/env.client.testing.ts.template +0 -7
- package/cli/templates/app/env/env.client.ts +0 -21
- package/cli/templates/app/env/env.client.type.ts +0 -16
- package/cli/templates/app/env/env.server.debug.ts.template +0 -7
- package/cli/templates/app/env/env.server.develop.ts.template +0 -7
- package/cli/templates/app/env/env.server.local.ts.template +0 -7
- package/cli/templates/app/env/env.server.main.ts.template +0 -7
- package/cli/templates/app/env/env.server.testing.ts.template +0 -6
- package/cli/templates/app/env/env.server.ts +0 -20
- package/cli/templates/app/lib/___appName__/__appName__.dictionary.ts +0 -17
- package/cli/templates/app/lib/___appName__/__appName__.service.ts +0 -13
- package/cli/templates/app/lib/___appName__/__appName__.signal.ts +0 -17
- package/cli/templates/app/lib/___appName__/__appName__.store.ts +0 -15
- package/cli/templates/app/lib/option.ts +0 -17
- package/cli/templates/app/main.ts +0 -16
- package/cli/templates/app/package.json.template +0 -5
- package/cli/templates/app/page/_index.tsx +0 -296
- package/cli/templates/app/page/_layout.tsx +0 -31
- package/cli/templates/app/page/styles.css.template +0 -53
- package/cli/templates/app/public/favicon.ico +0 -0
- package/cli/templates/app/public/logo.png +0 -0
- package/cli/templates/app/tsconfig.json.template +0 -21
- package/cli/templates/client.ts +0 -46
- package/cli/templates/crudPages/[__model__Id]/edit/page.tsx +0 -47
- package/cli/templates/crudPages/[__model__Id]/page.tsx +0 -52
- package/cli/templates/crudPages/new/page.tsx +0 -42
- package/cli/templates/crudPages/page.tsx +0 -43
- package/cli/templates/crudSinglePage/page.tsx +0 -37
- package/cli/templates/env/_env.server.type.ts +0 -16
- package/cli/templates/facetIndex/index.ts +0 -32
- package/cli/templates/index.ts +0 -10
- package/cli/templates/lib/__lib/lib.constant.ts +0 -38
- package/cli/templates/lib/__lib/lib.dictionary.ts +0 -33
- package/cli/templates/lib/__lib/lib.document.ts +0 -35
- package/cli/templates/lib/__lib/lib.service.ts +0 -33
- package/cli/templates/lib/__lib/lib.signal.ts +0 -34
- package/cli/templates/lib/__lib/lib.store.ts +0 -33
- package/cli/templates/lib/cnst.ts +0 -29
- package/cli/templates/lib/db.ts +0 -32
- package/cli/templates/lib/dict.ts +0 -49
- package/cli/templates/lib/sig.ts +0 -60
- package/cli/templates/lib/srv.ts +0 -34
- package/cli/templates/lib/st.ts +0 -31
- package/cli/templates/lib/useClient.ts +0 -19
- package/cli/templates/lib/useServer.ts +0 -7
- package/cli/templates/libRoot/.gitignore.template +0 -16
- package/cli/templates/libRoot/akan.config.ts +0 -12
- package/cli/templates/libRoot/base/baseLogic.ts +0 -10
- package/cli/templates/libRoot/base/index.ts +0 -8
- package/cli/templates/libRoot/common/commonLogic.ts +0 -10
- package/cli/templates/libRoot/common/index.ts +0 -8
- package/cli/templates/libRoot/env/env.server.example.ts.template +0 -6
- package/cli/templates/libRoot/env/env.server.testing.ts.template +0 -6
- package/cli/templates/libRoot/lib/___libName__/__libName__.dictionary.ts +0 -15
- package/cli/templates/libRoot/lib/___libName__/__libName__.service.ts +0 -11
- package/cli/templates/libRoot/lib/___libName__/__libName__.store.ts +0 -13
- package/cli/templates/libRoot/lib/option.ts +0 -17
- package/cli/templates/libRoot/package.json.template +0 -5
- package/cli/templates/libRoot/srvkit/backendLogic.ts +0 -10
- package/cli/templates/libRoot/srvkit/index.ts +0 -8
- package/cli/templates/libRoot/tsconfig.json.template +0 -11
- package/cli/templates/libRoot/ui/index.ts +0 -7
- package/cli/templates/libRoot/webkit/frontendLogic.ts +0 -10
- package/cli/templates/libRoot/webkit/index.ts +0 -8
- package/cli/templates/localDev/docker-compose.yaml.template +0 -37
- package/cli/templates/module/__Model__.Template.tsx +0 -36
- package/cli/templates/module/__Model__.Unit.tsx +0 -26
- package/cli/templates/module/__Model__.Util.tsx +0 -30
- package/cli/templates/module/__Model__.View.tsx +0 -29
- package/cli/templates/module/__Model__.Zone.tsx +0 -43
- package/cli/templates/module/__model__.constant.ts +0 -24
- package/cli/templates/module/__model__.dictionary.ts +0 -30
- package/cli/templates/module/__model__.document.ts +0 -23
- package/cli/templates/module/__model__.service.ts +0 -16
- package/cli/templates/module/__model__.signal.ts +0 -27
- package/cli/templates/module/__model__.store.ts +0 -19
- package/cli/templates/moduleRoot/index.tsx +0 -31
- package/cli/templates/pkgRoot/tsconfig.json.template +0 -10
- package/cli/templates/server.ts +0 -45
- package/cli/templates/workspaceRoot/.env.template +0 -14
- package/cli/templates/workspaceRoot/.gitignore.template +0 -120
- package/cli/templates/workspaceRoot/.vscode/settings.json.template +0 -23
- package/cli/templates/workspaceRoot/biome.json.template +0 -191
- package/cli/templates/workspaceRoot/bunfig.toml +0 -4
- package/cli/templates/workspaceRoot/package.json.template +0 -7
- package/cli/templates/workspaceRoot/tsconfig.json.template +0 -29
- package/cli/testHelpers.ts +0 -171
- package/cli/workspace/workspace.command.ts +0 -55
- package/cli/workspace/workspace.runner.ts +0 -79
- package/cli/workspace/workspace.script.ts +0 -74
- package/devkit/aiEditor.ts +0 -299
- package/devkit/akanApp/akanApp.host.ts +0 -393
- package/devkit/akanApp/index.ts +0 -1
- package/devkit/akanConfig/akanConfig.ts +0 -360
- package/devkit/akanConfig/index.ts +0 -2
- package/devkit/akanConfig/types.ts +0 -187
- package/devkit/applicationBuildReporter.ts +0 -69
- package/devkit/applicationBuildRunner.ts +0 -302
- package/devkit/applicationReleasePackager.ts +0 -205
- package/devkit/artifact/implicitRootLayout.ts +0 -155
- package/devkit/artifact/index.ts +0 -1
- package/devkit/artifact/routeSeedIndex.ts +0 -128
- package/devkit/auth.ts +0 -41
- package/devkit/builder.ts +0 -164
- package/devkit/capacitor.base.config.ts +0 -74
- package/devkit/capacitorApp.ts +0 -389
- package/devkit/commandDecorators/argMeta.ts +0 -102
- package/devkit/commandDecorators/command.ts +0 -340
- package/devkit/commandDecorators/commandBuilder.ts +0 -224
- package/devkit/commandDecorators/commandMeta.ts +0 -6
- package/devkit/commandDecorators/dependencyBuilder.ts +0 -100
- package/devkit/commandDecorators/helpFormatter.ts +0 -220
- package/devkit/commandDecorators/index.ts +0 -8
- package/devkit/commandDecorators/targetMeta.ts +0 -31
- package/devkit/commandDecorators/types.ts +0 -10
- package/devkit/constants.ts +0 -25
- package/devkit/createTunnel.ts +0 -36
- package/devkit/dependencyScanner.ts +0 -339
- package/devkit/executors.ts +0 -1362
- package/devkit/extractDeps.ts +0 -85
- package/devkit/fileEditor.ts +0 -106
- package/devkit/fileSys.ts +0 -39
- package/devkit/frontendBuild/allRoutesBuilder.ts +0 -103
- package/devkit/frontendBuild/clientBuildTypes.ts +0 -114
- package/devkit/frontendBuild/clientEntriesBundler.ts +0 -300
- package/devkit/frontendBuild/clientEntryDiscovery.ts +0 -196
- package/devkit/frontendBuild/csrArtifactBuilder.ts +0 -237
- package/devkit/frontendBuild/cssCompiler.ts +0 -285
- package/devkit/frontendBuild/cssImportResolver.ts +0 -116
- package/devkit/frontendBuild/fontOptimizer.ts +0 -427
- package/devkit/frontendBuild/hmrChangeClassifier.ts +0 -28
- package/devkit/frontendBuild/hmrWatcher.ts +0 -101
- package/devkit/frontendBuild/index.ts +0 -18
- package/devkit/frontendBuild/pagesBundleBuilder.ts +0 -137
- package/devkit/frontendBuild/pagesEntrySourceGenerator.ts +0 -37
- package/devkit/frontendBuild/precompressArtifacts.ts +0 -59
- package/devkit/frontendBuild/routeClientBuilder.ts +0 -290
- package/devkit/frontendBuild/routesManifestArtifactSerializer.ts +0 -62
- package/devkit/frontendBuild/ssrBaseArtifactBuilder.ts +0 -139
- package/devkit/frontendBuild/vendorSpecifiers.ts +0 -16
- package/devkit/frontendBuild/watchRootResolver.ts +0 -28
- package/devkit/getCredentials.ts +0 -19
- package/devkit/getDirname.ts +0 -3
- package/devkit/getModelFileData.ts +0 -59
- package/devkit/getRelatedCnsts.ts +0 -300
- package/devkit/guideline.ts +0 -19
- package/devkit/incrementalBuilder/incrementalBuilder.host.ts +0 -152
- package/devkit/incrementalBuilder/incrementalBuilder.proc.ts +0 -331
- package/devkit/incrementalBuilder/index.ts +0 -1
- package/devkit/index.ts +0 -36
- package/devkit/lint/no-deep-internal-import.grit +0 -25
- package/devkit/lint/no-import-client-functions.grit +0 -32
- package/devkit/lint/no-import-external-library.grit +0 -21
- package/devkit/lint/no-js-private-class-method.grit +0 -42
- package/devkit/lint/no-use-client-in-server.grit +0 -7
- package/devkit/lint/non-scalar-props-restricted.grit +0 -13
- package/devkit/linter.ts +0 -248
- package/devkit/mobile/index.ts +0 -1
- package/devkit/mobile/mobileTarget.ts +0 -87
- package/devkit/prompter.ts +0 -71
- package/devkit/scanInfo.ts +0 -605
- package/devkit/selectModel.ts +0 -11
- package/devkit/spinner.ts +0 -54
- package/devkit/src/capacitorApp.ts +0 -277
- package/devkit/sshTunnel.ts +0 -151
- package/devkit/streamAi.ts +0 -45
- package/devkit/transforms/barrelAnalyzer.ts +0 -249
- package/devkit/transforms/barrelImportsPlugin.ts +0 -457
- package/devkit/transforms/externalizeFrameworkPlugin.ts +0 -159
- package/devkit/transforms/index.ts +0 -5
- package/devkit/transforms/rscUseClientTransform.ts +0 -52
- package/devkit/transforms/useClientBundlePlugin.ts +0 -47
- package/devkit/typeChecker.ts +0 -260
- package/devkit/types.ts +0 -44
- package/devkit/ui/MultiScrollList.tsx +0 -228
- package/devkit/ui/ScrollList.tsx +0 -106
- package/devkit/ui/index.ts +0 -2
- package/devkit/uploadRelease.ts +0 -95
- package/devkit/useStdoutDimensions.ts +0 -20
- package/types/cli/application/application.command.d.ts +0 -7
- package/types/cli/application/application.interface.d.ts +0 -40
- package/types/cli/application/application.runner.d.ts +0 -66
- package/types/cli/application/application.script.d.ts +0 -72
- package/types/cli/build.d.ts +0 -1
- package/types/cli/cloud/cloud.command.d.ts +0 -7
- package/types/cli/cloud/cloud.runner.d.ts +0 -13
- package/types/cli/cloud/cloud.script.d.ts +0 -23
- package/types/cli/guideline/guideline.command.d.ts +0 -7
- package/types/cli/guideline/guideline.prompt.d.ts +0 -29
- package/types/cli/guideline/guideline.runner.d.ts +0 -21
- package/types/cli/guideline/guideline.script.d.ts +0 -16
- package/types/cli/index.d.ts +0 -2
- package/types/cli/library/library.command.d.ts +0 -7
- package/types/cli/library/library.runner.d.ts +0 -11
- package/types/cli/library/library.script.d.ts +0 -13
- package/types/cli/module/module.command.d.ts +0 -7
- package/types/cli/module/module.prompt.d.ts +0 -13
- package/types/cli/module/module.request.d.ts +0 -63
- package/types/cli/module/module.runner.d.ts +0 -55
- package/types/cli/module/module.script.d.ts +0 -22
- package/types/cli/npmRegistry.d.ts +0 -1
- package/types/cli/openBrowser.d.ts +0 -1
- package/types/cli/package/package.command.d.ts +0 -7
- package/types/cli/package/package.runner.d.ts +0 -13
- package/types/cli/package/package.script.d.ts +0 -18
- package/types/cli/page/page.command.d.ts +0 -7
- package/types/cli/page/page.runner.d.ts +0 -10
- package/types/cli/page/page.script.d.ts +0 -13
- package/types/cli/pluralizeName.d.ts +0 -1
- package/types/cli/scalar/scalar.command.d.ts +0 -7
- package/types/cli/scalar/scalar.prompt.d.ts +0 -23
- package/types/cli/scalar/scalar.runner.d.ts +0 -16
- package/types/cli/scalar/scalar.script.d.ts +0 -11
- package/types/cli/semver.d.ts +0 -1
- package/types/cli/templates/__scalar/__model__/__model__.constant.d.ts +0 -7
- package/types/cli/templates/__scalar/__model__/__model__.dictionary.d.ts +0 -7
- package/types/cli/templates/__scalar/__model__/__model__.document.d.ts +0 -7
- package/types/cli/templates/app/akan.config.d.ts +0 -6
- package/types/cli/templates/app/env/env.client.d.ts +0 -6
- package/types/cli/templates/app/env/env.client.type.d.ts +0 -6
- package/types/cli/templates/app/env/env.server.d.ts +0 -6
- package/types/cli/templates/app/lib/___appName__/__appName__.dictionary.d.ts +0 -7
- package/types/cli/templates/app/lib/___appName__/__appName__.service.d.ts +0 -7
- package/types/cli/templates/app/lib/___appName__/__appName__.signal.d.ts +0 -7
- package/types/cli/templates/app/lib/___appName__/__appName__.store.d.ts +0 -7
- package/types/cli/templates/app/lib/option.d.ts +0 -6
- package/types/cli/templates/app/main.d.ts +0 -6
- package/types/cli/templates/app/page/_index.d.ts +0 -9
- package/types/cli/templates/app/page/_layout.d.ts +0 -11
- package/types/cli/templates/client.d.ts +0 -4
- package/types/cli/templates/crudPages/[__model__Id]/edit/page.d.ts +0 -11
- package/types/cli/templates/crudPages/[__model__Id]/page.d.ts +0 -11
- package/types/cli/templates/crudPages/new/page.d.ts +0 -11
- package/types/cli/templates/crudPages/page.d.ts +0 -11
- package/types/cli/templates/crudSinglePage/page.d.ts +0 -11
- package/types/cli/templates/env/_env.server.type.d.ts +0 -7
- package/types/cli/templates/facetIndex/index.d.ts +0 -13
- package/types/cli/templates/facetIndex.d.ts +0 -1
- package/types/cli/templates/index.d.ts +0 -6
- package/types/cli/templates/lib/__lib/lib.constant.d.ts +0 -4
- package/types/cli/templates/lib/__lib/lib.dictionary.d.ts +0 -4
- package/types/cli/templates/lib/__lib/lib.document.d.ts +0 -4
- package/types/cli/templates/lib/__lib/lib.service.d.ts +0 -4
- package/types/cli/templates/lib/__lib/lib.signal.d.ts +0 -4
- package/types/cli/templates/lib/__lib/lib.store.d.ts +0 -4
- package/types/cli/templates/lib/cnst.d.ts +0 -4
- package/types/cli/templates/lib/db.d.ts +0 -4
- package/types/cli/templates/lib/dict.d.ts +0 -4
- package/types/cli/templates/lib/sig.d.ts +0 -4
- package/types/cli/templates/lib/srv.d.ts +0 -4
- package/types/cli/templates/lib/st.d.ts +0 -4
- package/types/cli/templates/lib/useClient.d.ts +0 -4
- package/types/cli/templates/lib/useServer.d.ts +0 -4
- package/types/cli/templates/libRoot/akan.config.d.ts +0 -5
- package/types/cli/templates/libRoot/base/baseLogic.d.ts +0 -5
- package/types/cli/templates/libRoot/base/index.d.ts +0 -5
- package/types/cli/templates/libRoot/base.d.ts +0 -1
- package/types/cli/templates/libRoot/common/commonLogic.d.ts +0 -5
- package/types/cli/templates/libRoot/common/index.d.ts +0 -5
- package/types/cli/templates/libRoot/common.d.ts +0 -1
- package/types/cli/templates/libRoot/lib/___libName__/__libName__.dictionary.d.ts +0 -6
- package/types/cli/templates/libRoot/lib/___libName__/__libName__.service.d.ts +0 -6
- package/types/cli/templates/libRoot/lib/___libName__/__libName__.store.d.ts +0 -6
- package/types/cli/templates/libRoot/lib/option.d.ts +0 -6
- package/types/cli/templates/libRoot/srvkit/backendLogic.d.ts +0 -5
- package/types/cli/templates/libRoot/srvkit/index.d.ts +0 -5
- package/types/cli/templates/libRoot/srvkit.d.ts +0 -1
- package/types/cli/templates/libRoot/ui/index.d.ts +0 -5
- package/types/cli/templates/libRoot/ui.d.ts +0 -1
- package/types/cli/templates/libRoot/webkit/frontendLogic.d.ts +0 -5
- package/types/cli/templates/libRoot/webkit/index.d.ts +0 -5
- package/types/cli/templates/libRoot/webkit.d.ts +0 -1
- package/types/cli/templates/module/__Model__.Template.d.ts +0 -11
- package/types/cli/templates/module/__Model__.Unit.d.ts +0 -11
- package/types/cli/templates/module/__Model__.Util.d.ts +0 -11
- package/types/cli/templates/module/__Model__.View.d.ts +0 -11
- package/types/cli/templates/module/__Model__.Zone.d.ts +0 -11
- package/types/cli/templates/module/__model__.constant.d.ts +0 -8
- package/types/cli/templates/module/__model__.dictionary.d.ts +0 -8
- package/types/cli/templates/module/__model__.document.d.ts +0 -8
- package/types/cli/templates/module/__model__.service.d.ts +0 -8
- package/types/cli/templates/module/__model__.signal.d.ts +0 -9
- package/types/cli/templates/module/__model__.store.d.ts +0 -8
- package/types/cli/templates/moduleRoot/index.d.ts +0 -11
- package/types/cli/templates/moduleRoot.d.ts +0 -1
- package/types/cli/templates/server.d.ts +0 -4
- package/types/cli/templates.d.ts +0 -1
- package/types/cli/testHelpers.d.ts +0 -64
- package/types/cli/workspace/workspace.command.d.ts +0 -7
- package/types/cli/workspace/workspace.runner.d.ts +0 -14
- package/types/cli/workspace/workspace.script.d.ts +0 -29
- package/types/cli.d.ts +0 -1
- package/types/devkit/aiEditor.d.ts +0 -50
- package/types/devkit/akanApp/akanApp.host.d.ts +0 -16
- package/types/devkit/akanApp/index.d.ts +0 -1
- package/types/devkit/akanApp.d.ts +0 -1
- package/types/devkit/akanConfig/akanConfig.d.ts +0 -36
- package/types/devkit/akanConfig/index.d.ts +0 -2
- package/types/devkit/akanConfig.d.ts +0 -1
- package/types/devkit/applicationBuildReporter.d.ts +0 -25
- package/types/devkit/applicationBuildRunner.d.ts +0 -29
- package/types/devkit/applicationReleasePackager.d.ts +0 -17
- package/types/devkit/artifact/implicitRootLayout.d.ts +0 -17
- package/types/devkit/artifact/index.d.ts +0 -1
- package/types/devkit/artifact/routeSeedIndex.d.ts +0 -38
- package/types/devkit/artifact.d.ts +0 -1
- package/types/devkit/auth.d.ts +0 -9
- package/types/devkit/builder.d.ts +0 -18
- package/types/devkit/capacitor.base.config.d.ts +0 -3
- package/types/devkit/capacitorApp.d.ts +0 -49
- package/types/devkit/commandDecorators/argMeta.d.ts +0 -68
- package/types/devkit/commandDecorators/command.d.ts +0 -2
- package/types/devkit/commandDecorators/commandBuilder.d.ts +0 -60
- package/types/devkit/commandDecorators/commandMeta.d.ts +0 -2
- package/types/devkit/commandDecorators/dependencyBuilder.d.ts +0 -22
- package/types/devkit/commandDecorators/helpFormatter.d.ts +0 -3
- package/types/devkit/commandDecorators/index.d.ts +0 -8
- package/types/devkit/commandDecorators/targetMeta.d.ts +0 -21
- package/types/devkit/commandDecorators/types.d.ts +0 -8
- package/types/devkit/commandDecorators.d.ts +0 -1
- package/types/devkit/constants.d.ts +0 -25
- package/types/devkit/createTunnel.d.ts +0 -8
- package/types/devkit/dependencyScanner.d.ts +0 -33
- package/types/devkit/executors.d.ts +0 -320
- package/types/devkit/extractDeps.d.ts +0 -7
- package/types/devkit/fileEditor.d.ts +0 -16
- package/types/devkit/fileSys.d.ts +0 -12
- package/types/devkit/frontendBuild/allRoutesBuilder.d.ts +0 -18
- package/types/devkit/frontendBuild/clientBuildTypes.d.ts +0 -107
- package/types/devkit/frontendBuild/clientEntriesBundler.d.ts +0 -12
- package/types/devkit/frontendBuild/clientEntryDiscovery.d.ts +0 -19
- package/types/devkit/frontendBuild/csrArtifactBuilder.d.ts +0 -16
- package/types/devkit/frontendBuild/cssCompiler.d.ts +0 -25
- package/types/devkit/frontendBuild/cssImportResolver.d.ts +0 -9
- package/types/devkit/frontendBuild/fontOptimizer.d.ts +0 -14
- package/types/devkit/frontendBuild/hmrChangeClassifier.d.ts +0 -5
- package/types/devkit/frontendBuild/hmrWatcher.d.ts +0 -21
- package/types/devkit/frontendBuild/index.d.ts +0 -18
- package/types/devkit/frontendBuild/pagesBundleBuilder.d.ts +0 -28
- package/types/devkit/frontendBuild/pagesEntrySourceGenerator.d.ts +0 -9
- package/types/devkit/frontendBuild/precompressArtifacts.d.ts +0 -7
- package/types/devkit/frontendBuild/routeClientBuilder.d.ts +0 -50
- package/types/devkit/frontendBuild/routesManifestArtifactSerializer.d.ts +0 -12
- package/types/devkit/frontendBuild/ssrBaseArtifactBuilder.d.ts +0 -16
- package/types/devkit/frontendBuild/vendorSpecifiers.d.ts +0 -2
- package/types/devkit/frontendBuild/watchRootResolver.d.ts +0 -6
- package/types/devkit/frontendBuild.d.ts +0 -1
- package/types/devkit/getCredentials.d.ts +0 -12
- package/types/devkit/getDirname.d.ts +0 -1
- package/types/devkit/getModelFileData.d.ts +0 -16
- package/types/devkit/getRelatedCnsts.d.ts +0 -53
- package/types/devkit/guideline.d.ts +0 -19
- package/types/devkit/incrementalBuilder/incrementalBuilder.host.d.ts +0 -30
- package/types/devkit/incrementalBuilder/incrementalBuilder.proc.d.ts +0 -1
- package/types/devkit/incrementalBuilder/index.d.ts +0 -1
- package/types/devkit/incrementalBuilder.d.ts +0 -1
- package/types/devkit/index.d.ts +0 -36
- package/types/devkit/linter.d.ts +0 -108
- package/types/devkit/mobile/index.d.ts +0 -1
- package/types/devkit/mobile/mobileTarget.d.ts +0 -14
- package/types/devkit/mobile.d.ts +0 -1
- package/types/devkit/prompter.d.ts +0 -15
- package/types/devkit/scanInfo.d.ts +0 -82
- package/types/devkit/selectModel.d.ts +0 -1
- package/types/devkit/spinner.d.ts +0 -20
- package/types/devkit/src/capacitorApp.d.ts +0 -39
- package/types/devkit/sshTunnel.d.ts +0 -14
- package/types/devkit/streamAi.d.ts +0 -6
- package/types/devkit/transforms/barrelAnalyzer.d.ts +0 -27
- package/types/devkit/transforms/barrelImportsPlugin.d.ts +0 -26
- package/types/devkit/transforms/externalizeFrameworkPlugin.d.ts +0 -49
- package/types/devkit/transforms/index.d.ts +0 -5
- package/types/devkit/transforms/rscUseClientTransform.d.ts +0 -10
- package/types/devkit/transforms/useClientBundlePlugin.d.ts +0 -19
- package/types/devkit/transforms.d.ts +0 -1
- package/types/devkit/typeChecker.d.ts +0 -62
- package/types/devkit/types.d.ts +0 -43
- package/types/devkit/ui/MultiScrollList.d.ts +0 -13
- package/types/devkit/ui/ScrollList.d.ts +0 -7
- package/types/devkit/ui/index.d.ts +0 -2
- package/types/devkit/ui.d.ts +0 -1
- package/types/devkit/uploadRelease.d.ts +0 -10
- package/types/devkit/useStdoutDimensions.d.ts +0 -1
- package/types/devkit.d.ts +0 -1
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
const HOP_BY_HOP_HEADERS = new Set([
|
|
2
|
+
"connection",
|
|
3
|
+
"keep-alive",
|
|
4
|
+
"proxy-authenticate",
|
|
5
|
+
"proxy-authorization",
|
|
6
|
+
"te",
|
|
7
|
+
"trailer",
|
|
8
|
+
"transfer-encoding",
|
|
9
|
+
"upgrade",
|
|
10
|
+
]);
|
|
11
|
+
|
|
12
|
+
export function makeAkanChildProxyHeaders(req: Request, childIdx: number): Headers {
|
|
13
|
+
const headers = new Headers(req.headers);
|
|
14
|
+
for (const key of HOP_BY_HOP_HEADERS) headers.delete(key);
|
|
15
|
+
const forwardedFor = headers.get("x-forwarded-for");
|
|
16
|
+
const clientAddress = headers.get("x-real-ip") ?? "127.0.0.1";
|
|
17
|
+
const host = headers.get("host");
|
|
18
|
+
headers.set("x-forwarded-for", forwardedFor ? `${forwardedFor}, ${clientAddress}` : clientAddress);
|
|
19
|
+
headers.set("x-forwarded-host", headers.get("x-forwarded-host") ?? host ?? new URL(req.url).host);
|
|
20
|
+
headers.set(
|
|
21
|
+
"x-forwarded-proto",
|
|
22
|
+
headers.get("x-forwarded-proto") ?? (req.url.startsWith("https:") ? "https" : "http"),
|
|
23
|
+
);
|
|
24
|
+
headers.set("x-akan-child-idx", String(childIdx));
|
|
25
|
+
if (!headers.has("x-request-id") && process.env.AKAN_BENCH_SKIP_REQUEST_ID !== "1") {
|
|
26
|
+
headers.set("x-request-id", crypto.randomUUID());
|
|
27
|
+
}
|
|
28
|
+
headers.set("host", "akan-child");
|
|
29
|
+
return headers;
|
|
30
|
+
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { AkanMetricsReport } from "akanjs/service";
|
|
2
|
+
import { getTraceSnapshot, isTraceEnabled } from "akanjs/signal";
|
|
2
3
|
|
|
3
4
|
type BunJscHeapStats = {
|
|
4
5
|
heapSize?: number;
|
|
@@ -8,19 +9,83 @@ type BunJscHeapStats = {
|
|
|
8
9
|
protectedObjectCount?: number;
|
|
9
10
|
};
|
|
10
11
|
|
|
12
|
+
/**
|
|
13
|
+
* Samples event-loop scheduling delay by measuring how late a fixed-interval timer
|
|
14
|
+
* actually fires. The sample window is summarized and reset on each metrics report,
|
|
15
|
+
* so values reflect recent load rather than process lifetime.
|
|
16
|
+
*/
|
|
17
|
+
class EventLoopLagMonitor {
|
|
18
|
+
static readonly #maxSamples = 600;
|
|
19
|
+
#timer: ReturnType<typeof setInterval> | null = null;
|
|
20
|
+
#intervalMs = 500;
|
|
21
|
+
#lastTickAt = 0;
|
|
22
|
+
#samples: number[] = [];
|
|
23
|
+
#maxMs = 0;
|
|
24
|
+
|
|
25
|
+
start(intervalMs = 500): void {
|
|
26
|
+
if (this.#timer) return;
|
|
27
|
+
this.#intervalMs = intervalMs;
|
|
28
|
+
this.#lastTickAt = performance.now();
|
|
29
|
+
this.#timer = setInterval(() => {
|
|
30
|
+
const now = performance.now();
|
|
31
|
+
const lag = Math.max(0, now - this.#lastTickAt - this.#intervalMs);
|
|
32
|
+
this.#lastTickAt = now;
|
|
33
|
+
this.#maxMs = Math.max(this.#maxMs, lag);
|
|
34
|
+
if (this.#samples.length < EventLoopLagMonitor.#maxSamples) this.#samples.push(lag);
|
|
35
|
+
else this.#samples[Math.floor(Math.random() * EventLoopLagMonitor.#maxSamples)] = lag;
|
|
36
|
+
}, intervalMs);
|
|
37
|
+
|
|
38
|
+
(this.#timer as { unref?: () => void }).unref?.();
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
/** Summarize the current window and reset it. */
|
|
42
|
+
snapshotAndReset(): { meanMs: number; p99Ms: number; maxMs: number } | null {
|
|
43
|
+
if (this.#samples.length === 0) return null;
|
|
44
|
+
const sorted = [...this.#samples].sort((a, b) => a - b);
|
|
45
|
+
const sum = sorted.reduce((acc, v) => acc + v, 0);
|
|
46
|
+
const p99Index = Math.min(sorted.length - 1, Math.floor(0.99 * sorted.length));
|
|
47
|
+
const result = {
|
|
48
|
+
meanMs: round(sum / sorted.length),
|
|
49
|
+
p99Ms: round(sorted[p99Index] ?? 0),
|
|
50
|
+
maxMs: round(this.#maxMs),
|
|
51
|
+
};
|
|
52
|
+
this.#samples = [];
|
|
53
|
+
this.#maxMs = 0;
|
|
54
|
+
return result;
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
const round = (value: number, digits = 3): number => {
|
|
59
|
+
const factor = 10 ** digits;
|
|
60
|
+
return Math.round(value * factor) / factor;
|
|
61
|
+
};
|
|
62
|
+
|
|
11
63
|
export class ProcessMetricsCollector {
|
|
12
64
|
static readonly #defaultMemoryLogIntervalMs = 60_000;
|
|
65
|
+
static readonly #lagMonitor = new EventLoopLagMonitor();
|
|
13
66
|
|
|
14
67
|
static parseMemoryLogIntervalMs(value = process.env.AKAN_MEMORY_LOG_INTERVAL_MS) {
|
|
15
68
|
const parsed = Number.parseInt(value ?? "", 10);
|
|
16
69
|
return Number.isFinite(parsed) && parsed > 0 ? parsed : ProcessMetricsCollector.#defaultMemoryLogIntervalMs;
|
|
17
70
|
}
|
|
18
71
|
|
|
72
|
+
/** Begin sampling event-loop lag. Idempotent; safe to call from each server role. */
|
|
73
|
+
static startEventLoopLagMonitor(intervalMs = 500): void {
|
|
74
|
+
ProcessMetricsCollector.#lagMonitor.start(intervalMs);
|
|
75
|
+
}
|
|
76
|
+
|
|
19
77
|
static async collect(extra: AkanMetricsReport = {}): Promise<AkanMetricsReport> {
|
|
20
|
-
|
|
78
|
+
ProcessMetricsCollector.#lagMonitor.start();
|
|
79
|
+
let gcDurationMs: number | undefined;
|
|
80
|
+
if (process.env.AKAN_MEMORY_GC_ON_REPORT === "1") {
|
|
81
|
+
const gcStart = performance.now();
|
|
82
|
+
Bun.gc(true);
|
|
83
|
+
gcDurationMs = round(performance.now() - gcStart);
|
|
84
|
+
}
|
|
21
85
|
const memory = process.memoryUsage();
|
|
22
86
|
const resourceUsage = process.resourceUsage?.();
|
|
23
87
|
const jsc = await ProcessMetricsCollector.#collectJscHeapStats();
|
|
88
|
+
const lag = ProcessMetricsCollector.#lagMonitor.snapshotAndReset();
|
|
24
89
|
return {
|
|
25
90
|
pid: process.pid,
|
|
26
91
|
reportedAt: Date.now(),
|
|
@@ -45,6 +110,15 @@ export class ProcessMetricsCollector {
|
|
|
45
110
|
jscProtectedObjectCount: jsc.protectedObjectCount,
|
|
46
111
|
}
|
|
47
112
|
: {}),
|
|
113
|
+
...(lag
|
|
114
|
+
? {
|
|
115
|
+
eventLoopLagMeanMs: lag.meanMs,
|
|
116
|
+
eventLoopLagP99Ms: lag.p99Ms,
|
|
117
|
+
eventLoopLagMaxMs: lag.maxMs,
|
|
118
|
+
}
|
|
119
|
+
: {}),
|
|
120
|
+
...(gcDurationMs !== undefined ? { gcDurationMs } : {}),
|
|
121
|
+
...(isTraceEnabled() ? { trace: getTraceSnapshot() } : {}),
|
|
48
122
|
...extra,
|
|
49
123
|
};
|
|
50
124
|
}
|
|
@@ -64,6 +138,10 @@ export class ProcessMetricsCollector {
|
|
|
64
138
|
...(metrics.jscHeapSizeBytes !== undefined
|
|
65
139
|
? [`jscHeap=${ProcessMetricsCollector.formatBytes(metrics.jscHeapSizeBytes)}`]
|
|
66
140
|
: []),
|
|
141
|
+
...(metrics.eventLoopLagMeanMs !== undefined
|
|
142
|
+
? [`elLag=${metrics.eventLoopLagMeanMs}/${metrics.eventLoopLagP99Ms ?? 0}/${metrics.eventLoopLagMaxMs ?? 0}ms`]
|
|
143
|
+
: []),
|
|
144
|
+
...(metrics.gcDurationMs !== undefined ? [`gc=${metrics.gcDurationMs}ms`] : []),
|
|
67
145
|
].join(" ");
|
|
68
146
|
}
|
|
69
147
|
|
|
@@ -27,6 +27,22 @@ import {
|
|
|
27
27
|
DatabaseAdaptorRole,
|
|
28
28
|
type DocumentStore,
|
|
29
29
|
} from "akanjs/service";
|
|
30
|
+
import { getCurrentTrace, traceDataLoaderBatch } from "akanjs/signal";
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* Times a store query and records it against the active request trace (no-op when
|
|
34
|
+
* tracing is disabled). Used to surface "queries per request" and DB latency share.
|
|
35
|
+
*/
|
|
36
|
+
const timedQuery = async <T>(fn: () => Promise<T>): Promise<T> => {
|
|
37
|
+
const trace = getCurrentTrace();
|
|
38
|
+
if (!trace) return await fn();
|
|
39
|
+
const start = performance.now();
|
|
40
|
+
try {
|
|
41
|
+
return await fn();
|
|
42
|
+
} finally {
|
|
43
|
+
trace.countDbQuery(performance.now() - start);
|
|
44
|
+
}
|
|
45
|
+
};
|
|
30
46
|
|
|
31
47
|
export class DatabaseResolver {
|
|
32
48
|
static resolveDatabase(constant: ConstantModel, database: DatabaseModel): AdaptorCls<DatabaseInstance> {
|
|
@@ -55,6 +71,18 @@ export class DatabaseResolver {
|
|
|
55
71
|
const schema = new DocumentSchema();
|
|
56
72
|
database.model._onSchema(schema as any);
|
|
57
73
|
database.model._libsOnSchema(schema as any);
|
|
74
|
+
const filterMeta = getFilterMeta(database.filter);
|
|
75
|
+
const indexedSortFieldKeys = new Set<string>();
|
|
76
|
+
for (const sort of Object.values(filterMeta.sort)) {
|
|
77
|
+
if (!sort || typeof sort !== "object") continue;
|
|
78
|
+
const sortFields = Object.entries(sort as Record<string, 1 | -1>);
|
|
79
|
+
if (!sortFields.length) continue;
|
|
80
|
+
const fields = Object.fromEntries([["removedAt", 1] as const, ...sortFields]);
|
|
81
|
+
const key = Object.keys(fields).join(",");
|
|
82
|
+
if (indexedSortFieldKeys.has(key)) continue;
|
|
83
|
+
indexedSortFieldKeys.add(key);
|
|
84
|
+
schema.index(fields);
|
|
85
|
+
}
|
|
58
86
|
|
|
59
87
|
class DatabaseModelInstance extends adapt(`${modelName}Model`, ({ plug }) => ({
|
|
60
88
|
__database: plug(DatabaseAdaptorRole, (database) => database),
|
|
@@ -71,7 +99,12 @@ export class DatabaseResolver {
|
|
|
71
99
|
await this.__store.ensure();
|
|
72
100
|
this.__model = this.#createModelFacade() as unknown as Mdl<any, any>;
|
|
73
101
|
this.__loader = new DataLoader<string, any>(
|
|
74
|
-
async (ids) =>
|
|
102
|
+
async (ids) => {
|
|
103
|
+
traceDataLoaderBatch(ids.length);
|
|
104
|
+
const docs = await timedQuery(() => this.__store.find({ id: documentQueryHelper.oneOf([...ids]) }));
|
|
105
|
+
const byId = new Map(docs.map((doc) => [String(doc.id), doc]));
|
|
106
|
+
return ids.map((id) => byId.get(String(id)) ?? null);
|
|
107
|
+
},
|
|
75
108
|
{ name: `${modelName}Loader`, cache: false },
|
|
76
109
|
);
|
|
77
110
|
Object.assign(this, {
|
|
@@ -81,18 +114,35 @@ export class DatabaseResolver {
|
|
|
81
114
|
Object.entries(getLoaderInfos(database.model)).forEach(([key, loaderInfo]) => {
|
|
82
115
|
Object.assign(this, {
|
|
83
116
|
[key]: new DataLoader<any, any>(async (keys) => {
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
117
|
+
traceDataLoaderBatch(keys.length);
|
|
118
|
+
if (loaderInfo.type === "query") {
|
|
119
|
+
const fields = loaderInfo.field as string[];
|
|
120
|
+
const query = { kind: "any", queries: keys } as QueryOf<unknown>;
|
|
121
|
+
const docs = await timedQuery(() =>
|
|
122
|
+
this.__store.find(documentQueryHelper.all(loaderInfo.defaultQuery, query)),
|
|
123
|
+
);
|
|
124
|
+
const byKey = new Map(docs.map((doc) => [fields.map((field) => String(doc[field])).join(""), doc]));
|
|
125
|
+
return keys.map(
|
|
126
|
+
(queryKey) => byKey.get(fields.map((field) => String(queryKey[field])).join("")) ?? null,
|
|
127
|
+
);
|
|
128
|
+
}
|
|
129
|
+
const field = loaderInfo.field as string;
|
|
130
|
+
const query = {
|
|
131
|
+
[field]: documentQueryHelper.oneOf([...keys]),
|
|
132
|
+
};
|
|
133
|
+
const docs = await timedQuery(() =>
|
|
134
|
+
this.__store.find(documentQueryHelper.all(loaderInfo.defaultQuery, query)),
|
|
95
135
|
);
|
|
136
|
+
if (loaderInfo.type === "arrayField") {
|
|
137
|
+
const byKey = new Map<string, unknown>();
|
|
138
|
+
for (const doc of docs) {
|
|
139
|
+
const values = Array.isArray(doc[field]) ? doc[field] : [];
|
|
140
|
+
for (const value of values) if (!byKey.has(String(value))) byKey.set(String(value), doc);
|
|
141
|
+
}
|
|
142
|
+
return keys.map((key) => byKey.get(String(key)) ?? null);
|
|
143
|
+
}
|
|
144
|
+
const byKey = new Map(docs.map((doc) => [String(doc[field]), doc]));
|
|
145
|
+
return keys.map((key) => byKey.get(String(key)) ?? null);
|
|
96
146
|
}),
|
|
97
147
|
});
|
|
98
148
|
});
|
|
@@ -105,7 +155,7 @@ export class DatabaseResolver {
|
|
|
105
155
|
}
|
|
106
156
|
const createFindManyChain = (
|
|
107
157
|
query: QueryOf<any>,
|
|
108
|
-
options: { sort?: any; skip?: number; limit?: number } = {},
|
|
158
|
+
options: { sort?: any; skip?: number; limit?: number; select?: any } = {},
|
|
109
159
|
) => {
|
|
110
160
|
const chain: any = {
|
|
111
161
|
sort(sort: any) {
|
|
@@ -117,8 +167,8 @@ export class DatabaseResolver {
|
|
|
117
167
|
limit(limit: number) {
|
|
118
168
|
return createFindManyChain(query, { ...options, limit });
|
|
119
169
|
},
|
|
120
|
-
select() {
|
|
121
|
-
return createFindManyChain(query, options);
|
|
170
|
+
select(select?: any) {
|
|
171
|
+
return createFindManyChain(query, { ...options, select });
|
|
122
172
|
},
|
|
123
173
|
|
|
124
174
|
then(resolve: (value: any[]) => void, reject: (reason: unknown) => void) {
|
|
@@ -130,7 +180,7 @@ export class DatabaseResolver {
|
|
|
130
180
|
};
|
|
131
181
|
return chain;
|
|
132
182
|
};
|
|
133
|
-
const createFindOneChain = (query: QueryOf<any>, options: { sort?: any; skip?: number } = {}) => {
|
|
183
|
+
const createFindOneChain = (query: QueryOf<any>, options: { sort?: any; skip?: number; select?: any } = {}) => {
|
|
134
184
|
const chain: any = {
|
|
135
185
|
sort(sort: any) {
|
|
136
186
|
return createFindOneChain(query, { ...options, sort });
|
|
@@ -138,8 +188,8 @@ export class DatabaseResolver {
|
|
|
138
188
|
skip(skip: number) {
|
|
139
189
|
return createFindOneChain(query, { ...options, skip });
|
|
140
190
|
},
|
|
141
|
-
select() {
|
|
142
|
-
return createFindOneChain(query, options);
|
|
191
|
+
select(select?: any) {
|
|
192
|
+
return createFindOneChain(query, { ...options, select });
|
|
143
193
|
},
|
|
144
194
|
|
|
145
195
|
then(resolve: (value: any | null) => void, reject: (reason: unknown) => void) {
|
|
@@ -153,10 +203,13 @@ export class DatabaseResolver {
|
|
|
153
203
|
};
|
|
154
204
|
return Object.assign(Model, {
|
|
155
205
|
refName: modelName,
|
|
156
|
-
pickOne: (query: QueryOf<any>,
|
|
157
|
-
pickById: (id: string | undefined,
|
|
206
|
+
pickOne: (query: QueryOf<any>, projection?: any) => store.pickOne(query, { select: projection }),
|
|
207
|
+
pickById: (id: string | undefined, projection?: any) => {
|
|
158
208
|
if (!id) throw new Error("No Document ID");
|
|
159
|
-
return store.
|
|
209
|
+
return store.findOne({ id }, { select: projection }).then((doc) => {
|
|
210
|
+
if (!doc) throw new Error(`No Document (${modelName}): ${id}`);
|
|
211
|
+
return doc;
|
|
212
|
+
});
|
|
160
213
|
},
|
|
161
214
|
exists: async (query: QueryOf<any>) => await store.exists(query),
|
|
162
215
|
sample: (query: QueryOf<any>, size = 1) => store.find(query, { sample: size, limit: size }),
|
|
@@ -184,20 +237,20 @@ export class DatabaseResolver {
|
|
|
184
237
|
}
|
|
185
238
|
|
|
186
239
|
async __list(query?: QueryOf<any>, queryOption?: ListQueryOption): Promise<any[]> {
|
|
187
|
-
const { find, sort, skip, limit, sample } = getListQuery(query, queryOption);
|
|
188
|
-
return await this.__store.find(find, { sort, skip, limit, sample });
|
|
240
|
+
const { find, sort, skip, limit, sample, select } = getListQuery(query, queryOption);
|
|
241
|
+
return await timedQuery(() => this.__store.find(find, { sort, skip, limit, sample, select }));
|
|
189
242
|
}
|
|
190
243
|
async __listIds(query?: QueryOf<any>, queryOption?: ListQueryOption): Promise<string[]> {
|
|
191
244
|
const { find, sort, skip, limit, sample } = getListQuery(query, queryOption);
|
|
192
|
-
return await this.__store.findIds(find, { sort, skip, limit, sample });
|
|
245
|
+
return await timedQuery(() => this.__store.findIds(find, { sort, skip, limit, sample }));
|
|
193
246
|
}
|
|
194
247
|
async __find(query?: QueryOf<any>, queryOption?: FindQueryOption): Promise<any | null> {
|
|
195
248
|
const { find, sort, skip, sample } = getFindQuery(query, queryOption);
|
|
196
|
-
return await this.__store.findOne(find, { sort, skip, sample });
|
|
249
|
+
return await timedQuery(() => this.__store.findOne(find, { sort, skip, sample }));
|
|
197
250
|
}
|
|
198
251
|
async __findId(query?: QueryOf<any>, queryOption?: FindQueryOption): Promise<string | null> {
|
|
199
252
|
const { find, sort, skip, sample } = getFindQuery(query, queryOption);
|
|
200
|
-
return await this.__store.findId(find, { sort, skip, sample });
|
|
253
|
+
return await timedQuery(() => this.__store.findId(find, { sort, skip, sample }));
|
|
201
254
|
}
|
|
202
255
|
async __pick(query?: QueryOf<any>, queryOption?: FindQueryOption): Promise<any> {
|
|
203
256
|
const { find, sort, skip, sample } = getFindQuery(query, queryOption);
|
|
@@ -213,7 +266,7 @@ export class DatabaseResolver {
|
|
|
213
266
|
return await this.__store.exists(query);
|
|
214
267
|
}
|
|
215
268
|
async __count(query?: QueryOf<any>): Promise<number> {
|
|
216
|
-
return await this.__store.count(query);
|
|
269
|
+
return await timedQuery(() => this.__store.count(query));
|
|
217
270
|
}
|
|
218
271
|
async __insight(query?: QueryOf<any>): Promise<any> {
|
|
219
272
|
return await this.__store.insight(query);
|
|
@@ -254,13 +307,13 @@ export class DatabaseResolver {
|
|
|
254
307
|
return await this.__store.clone(data);
|
|
255
308
|
}
|
|
256
309
|
async __create(data: DataInputOf<any, any>) {
|
|
257
|
-
return await this.__store.create(data);
|
|
310
|
+
return await timedQuery(() => this.__store.create(data));
|
|
258
311
|
}
|
|
259
312
|
async [`create${className}`](data: DataInputOf<any, any>) {
|
|
260
313
|
return this.__create(data);
|
|
261
314
|
}
|
|
262
315
|
async __update(id: string, data: DataInputOf<any, any>) {
|
|
263
|
-
return await this.__store.update(id, data);
|
|
316
|
+
return await timedQuery(() => this.__store.update(id, data));
|
|
264
317
|
}
|
|
265
318
|
async [`update${className}`](id: string, data: DataInputOf<any, any>) {
|
|
266
319
|
return this.__update(id, data);
|
|
@@ -289,8 +342,6 @@ export class DatabaseResolver {
|
|
|
289
342
|
const queryOption = hasQueryOption ? lastArg : {};
|
|
290
343
|
return { query, queryOption };
|
|
291
344
|
};
|
|
292
|
-
const filterMeta = getFilterMeta(database.filter);
|
|
293
|
-
|
|
294
345
|
Object.entries(filterMeta.query).forEach(([queryKey, filterInfo]) => {
|
|
295
346
|
const queryFn = filterInfo.queryFn;
|
|
296
347
|
if (!queryFn) throw new Error(`No query function for key: ${queryKey}`);
|
|
@@ -1,4 +1,15 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {
|
|
2
|
+
type BaseEnv,
|
|
3
|
+
type Cls,
|
|
4
|
+
ENDPOINT_META,
|
|
5
|
+
FIELD_META,
|
|
6
|
+
getEnv,
|
|
7
|
+
ID,
|
|
8
|
+
INTERNAL_META,
|
|
9
|
+
Int,
|
|
10
|
+
PrimitiveRegistry,
|
|
11
|
+
SLICE_META,
|
|
12
|
+
} from "akanjs/base";
|
|
2
13
|
import { capitalize, Logger } from "akanjs/common";
|
|
3
14
|
import { serialize } from "akanjs/constant";
|
|
4
15
|
import { documentQueryHelper } from "akanjs/document";
|
|
@@ -169,7 +180,12 @@ export class SignalResolver {
|
|
|
169
180
|
const sort = requestArgs[argLength + 2] ?? "latest";
|
|
170
181
|
const internalArgs = requestArgs.slice(argLength + 3);
|
|
171
182
|
const query = await sliceInfo.execFn?.apply(this, [...args, ...internalArgs, documentQueryHelper]);
|
|
172
|
-
return (await this[serviceName].__list(query, {
|
|
183
|
+
return (await this[serviceName].__list(query, {
|
|
184
|
+
skip,
|
|
185
|
+
limit,
|
|
186
|
+
sort,
|
|
187
|
+
select: SignalResolver.#selectForConstant(sliceInfo.light),
|
|
188
|
+
})) as any;
|
|
173
189
|
});
|
|
174
190
|
|
|
175
191
|
const insightKey = `${refName}Insight${capitalizedKey}`;
|
|
@@ -249,37 +265,37 @@ export class SignalResolver {
|
|
|
249
265
|
if (endpointInfo.signalOption.globalPrefix !== undefined) {
|
|
250
266
|
routeOptions[path] = { globalPrefix: endpointInfo.signalOption.globalPrefix };
|
|
251
267
|
}
|
|
268
|
+
const normalHttpHandler = async (req: Bun.BunRequest) =>
|
|
269
|
+
await SignalContext.try(endpoint, endpointInfo, key, async () => {
|
|
270
|
+
const context = await new SignalContext(key, req, {
|
|
271
|
+
endpointInfo,
|
|
272
|
+
adaptor: endpoint,
|
|
273
|
+
registry,
|
|
274
|
+
env,
|
|
275
|
+
live,
|
|
276
|
+
middleware,
|
|
277
|
+
}).init();
|
|
278
|
+
return await context.exec();
|
|
279
|
+
});
|
|
252
280
|
switch (endpointInfo.type) {
|
|
253
281
|
case "query":
|
|
254
|
-
routes[path] =
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
endpointInfo,
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
}
|
|
267
|
-
};
|
|
282
|
+
routes[path] = SignalResolver.#canUsePrimitiveQueryFastPath(endpointInfo, middleware)
|
|
283
|
+
? {
|
|
284
|
+
GET: async (req) => {
|
|
285
|
+
if (SignalResolver.#hasAuthCredential(req)) return await normalHttpHandler(req);
|
|
286
|
+
return await SignalContext.try(endpoint, endpointInfo, key, async () => {
|
|
287
|
+
const result = await endpointInfo.execFn?.call(endpoint);
|
|
288
|
+
return result instanceof Response ? result : Response.json(result);
|
|
289
|
+
});
|
|
290
|
+
},
|
|
291
|
+
}
|
|
292
|
+
: {
|
|
293
|
+
GET: normalHttpHandler,
|
|
294
|
+
};
|
|
268
295
|
break;
|
|
269
296
|
case "mutation":
|
|
270
297
|
routes[path] = {
|
|
271
|
-
POST:
|
|
272
|
-
await SignalContext.try(endpoint, endpointInfo, key, async () => {
|
|
273
|
-
const context = await new SignalContext(key, req, {
|
|
274
|
-
endpointInfo,
|
|
275
|
-
adaptor: endpoint,
|
|
276
|
-
registry,
|
|
277
|
-
env,
|
|
278
|
-
live,
|
|
279
|
-
middleware,
|
|
280
|
-
}).init();
|
|
281
|
-
return await context.exec();
|
|
282
|
-
}),
|
|
298
|
+
POST: normalHttpHandler,
|
|
283
299
|
};
|
|
284
300
|
break;
|
|
285
301
|
case "pubsub":
|
|
@@ -349,6 +365,29 @@ export class SignalResolver {
|
|
|
349
365
|
return trimmed ? `/${trimmed}` : "";
|
|
350
366
|
}
|
|
351
367
|
|
|
368
|
+
static #selectForConstant(constant: Cls): Record<string, true> | undefined {
|
|
369
|
+
const fields = (constant as { [FIELD_META]?: Record<string, unknown> })[FIELD_META];
|
|
370
|
+
if (!fields) return undefined;
|
|
371
|
+
return Object.fromEntries(Object.keys(fields).map((field) => [field, true]));
|
|
372
|
+
}
|
|
373
|
+
|
|
374
|
+
static #canUsePrimitiveQueryFastPath(endpointInfo: EndpointInfo, middleware: Map<string, MiddlewareCls>) {
|
|
375
|
+
return (
|
|
376
|
+
process.env.AKAN_TRACE !== "1" &&
|
|
377
|
+
endpointInfo.args.length === 0 &&
|
|
378
|
+
endpointInfo.internalArgs.length === 0 &&
|
|
379
|
+
(endpointInfo.signalOption.guards?.length ?? 0) === 0 &&
|
|
380
|
+
(endpointInfo.signalOption.middlewares?.length ?? 0) === 0 &&
|
|
381
|
+
[...middleware.values()].every((MiddlewareCls) => MiddlewareCls.refName === "AccountMiddleware") &&
|
|
382
|
+
endpointInfo.returns.arrDepth === 0 &&
|
|
383
|
+
PrimitiveRegistry.has(endpointInfo.returns.returnRef as Cls)
|
|
384
|
+
);
|
|
385
|
+
}
|
|
386
|
+
|
|
387
|
+
static #hasAuthCredential(req: Request) {
|
|
388
|
+
return Boolean(req.headers.get("authorization") || req.headers.get("cookie")?.includes("jwt="));
|
|
389
|
+
}
|
|
390
|
+
|
|
352
391
|
static async handleWsOpen(ws: Bun.ServerWebSocket<any>, registry: InjectRegistry) {
|
|
353
392
|
await SignalResolver.#getWebsocket(registry).registerSocket(ws);
|
|
354
393
|
}
|
package/service/ipcTypes.ts
CHANGED
|
@@ -94,6 +94,11 @@ export interface AkanMetricsReport {
|
|
|
94
94
|
httpHtmlCacheHits?: number;
|
|
95
95
|
httpHtmlCacheMisses?: number;
|
|
96
96
|
httpHtmlCacheBypass?: number;
|
|
97
|
+
eventLoopLagMeanMs?: number;
|
|
98
|
+
eventLoopLagP99Ms?: number;
|
|
99
|
+
eventLoopLagMaxMs?: number;
|
|
100
|
+
gcDurationMs?: number;
|
|
101
|
+
trace?: unknown;
|
|
97
102
|
}
|
|
98
103
|
|
|
99
104
|
export type AkanIpcMessage =
|