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.
Files changed (530) hide show
  1. package/README.ko.md +5 -5
  2. package/README.md +5 -5
  3. package/client/router.ts +10 -3
  4. package/constant/serialize.ts +1 -1
  5. package/document/documentSchema.ts +9 -1
  6. package/index.ts +187 -0
  7. package/package.json +6 -50
  8. package/server/akanApp.ts +49 -30
  9. package/server/akanAppHeaders.ts +30 -0
  10. package/server/di/predefinedAdaptor.ts +1 -1
  11. package/server/processMetricsCollector.ts +79 -1
  12. package/server/resolver/database.resolver.ts +82 -31
  13. package/server/resolver/signal.resolver.ts +67 -28
  14. package/service/ipcTypes.ts +5 -0
  15. package/service/predefinedAdaptor/database.adaptor.ts +95 -27
  16. package/service/predefinedAdaptor/solidSqlite.ts +7 -7
  17. package/service/predefinedAdaptor/storage.adaptor.ts +35 -9
  18. package/signal/index.ts +1 -0
  19. package/signal/middleware.ts +5 -1
  20. package/signal/signalContext.ts +85 -31
  21. package/signal/trace.ts +279 -0
  22. package/types/dictionary/base.dictionary.d.ts +1 -1
  23. package/types/dictionary/dictionary.d.ts +8 -8
  24. package/types/document/documentSchema.d.ts +33 -0
  25. package/types/document/index.d.ts +1 -1
  26. package/types/document/schema.d.ts +1 -1
  27. package/types/document/types.d.ts +1 -1
  28. package/types/{devkit/akanConfig/types.d.ts → index.d.ts} +45 -54
  29. package/types/server/akanAppHeaders.d.ts +1 -0
  30. package/types/server/di/predefinedAdaptor.d.ts +1 -1
  31. package/types/server/processMetricsCollector.d.ts +2 -0
  32. package/types/service/ipcTypes.d.ts +5 -0
  33. package/types/service/predefinedAdaptor/database.adaptor.d.ts +26 -32
  34. package/types/service/predefinedAdaptor/solidSqlite.d.ts +3 -3
  35. package/types/service/predefinedAdaptor/storage.adaptor.d.ts +8 -2
  36. package/types/signal/index.d.ts +1 -0
  37. package/types/signal/signalContext.d.ts +4 -1
  38. package/types/signal/trace.d.ts +97 -0
  39. package/types/store/baseSt.d.ts +2 -2
  40. package/types/ui/Signal/style.d.ts +15 -0
  41. package/ui/Link/SsrLink.tsx +2 -2
  42. package/ui/Signal/Arg.tsx +22 -15
  43. package/ui/Signal/Doc.tsx +28 -21
  44. package/ui/Signal/Listener.tsx +15 -39
  45. package/ui/Signal/Message.tsx +32 -50
  46. package/ui/Signal/Object.tsx +16 -13
  47. package/ui/Signal/PubSub.tsx +29 -47
  48. package/ui/Signal/Response.tsx +7 -17
  49. package/ui/Signal/RestApi.tsx +41 -57
  50. package/ui/Signal/WebSocket.tsx +1 -1
  51. package/ui/Signal/style.ts +36 -0
  52. package/webkit/useCodepush.tsx +1 -1
  53. package/webkit/useCsrValues.ts +147 -37
  54. package/cli/application/application.command.ts +0 -221
  55. package/cli/application/application.interface.tsx +0 -225
  56. package/cli/application/application.runner.ts +0 -357
  57. package/cli/application/application.script.ts +0 -244
  58. package/cli/build.ts +0 -26
  59. package/cli/cloud/cloud.command.ts +0 -48
  60. package/cli/cloud/cloud.runner.ts +0 -157
  61. package/cli/cloud/cloud.script.ts +0 -40
  62. package/cli/guideline/guideline.command.ts +0 -31
  63. package/cli/guideline/guideline.prompt.ts +0 -212
  64. package/cli/guideline/guideline.runner.ts +0 -53
  65. package/cli/guideline/guideline.script.ts +0 -33
  66. package/cli/guidelines/___library/sharedUiStructureDescription.en.md +0 -767
  67. package/cli/guidelines/___library/utilUiStructureDescription.en.md +0 -395
  68. package/cli/guidelines/___lint/lintRuleDescription.en.md +0 -64
  69. package/cli/guidelines/___module/moduleStructureDescription.en.md +0 -80
  70. package/cli/guidelines/componentRule/componentRule.generate.json +0 -131
  71. package/cli/guidelines/componentRule/componentRule.instruction.md +0 -637
  72. package/cli/guidelines/cssRule/cssRule.generate.json +0 -93
  73. package/cli/guidelines/cssRule/cssRule.instruction.md +0 -435
  74. package/cli/guidelines/databaseModule/databaseModule.generate.json +0 -51
  75. package/cli/guidelines/databaseModule/databaseModule.instruction.md +0 -612
  76. package/cli/guidelines/docPageRule/docPageRule.generate.json +0 -72
  77. package/cli/guidelines/docPageRule/docPageRule.instruction.md +0 -389
  78. package/cli/guidelines/enumConstant/enumConstant.generate.json +0 -24
  79. package/cli/guidelines/enumConstant/enumConstant.instruction.md +0 -232
  80. package/cli/guidelines/framework/framework.generate.json +0 -119
  81. package/cli/guidelines/framework/framework.instruction.md +0 -1110
  82. package/cli/guidelines/howToUseStore/howToUseStore.generate.json +0 -0
  83. package/cli/guidelines/modelConstant/modelConstant.generate.json +0 -128
  84. package/cli/guidelines/modelConstant/modelConstant.instruction.md +0 -506
  85. package/cli/guidelines/modelDictionary/modelDictionary.generate.json +0 -108
  86. package/cli/guidelines/modelDictionary/modelDictionary.instruction.md +0 -547
  87. package/cli/guidelines/modelDocument/modelDocument.generate.json +0 -129
  88. package/cli/guidelines/modelDocument/modelDocument.instruction.md +0 -509
  89. package/cli/guidelines/modelService/modelService.generate.json +0 -135
  90. package/cli/guidelines/modelService/modelService.instruction.md +0 -708
  91. package/cli/guidelines/modelSignal/modelSignal.generate.json +0 -201
  92. package/cli/guidelines/modelSignal/modelSignal.instruction.md +0 -552
  93. package/cli/guidelines/modelStore/modelStore.generate.json +0 -130
  94. package/cli/guidelines/modelStore/modelStore.instruction.md +0 -585
  95. package/cli/guidelines/modelTemplate/modelTemplate.generate.json +0 -104
  96. package/cli/guidelines/modelTemplate/modelTemplate.instruction.md +0 -604
  97. package/cli/guidelines/modelUnit/modelUnit.generate.json +0 -92
  98. package/cli/guidelines/modelUnit/modelUnit.instruction.md +0 -541
  99. package/cli/guidelines/modelUtil/modelUtil.generate.json +0 -93
  100. package/cli/guidelines/modelUtil/modelUtil.instruction.md +0 -752
  101. package/cli/guidelines/modelView/modelView.generate.json +0 -80
  102. package/cli/guidelines/modelView/modelView.instruction.md +0 -1005
  103. package/cli/guidelines/modelZone/modelZone.generate.json +0 -126
  104. package/cli/guidelines/modelZone/modelZone.instruction.md +0 -528
  105. package/cli/guidelines/scalarConstant/scalarConstant.generate.json +0 -106
  106. package/cli/guidelines/scalarConstant/scalarConstant.instruction.md +0 -442
  107. package/cli/guidelines/scalarDictionary/scalarDictionary.generate.json +0 -83
  108. package/cli/guidelines/scalarDictionary/scalarDictionary.instruction.md +0 -273
  109. package/cli/guidelines/scalarModule/scalarModule.generate.json +0 -35
  110. package/cli/guidelines/scalarModule/scalarModule.instruction.md +0 -81
  111. package/cli/guidelines/sharedUiUsage/sharedUiUsage.generate.json +0 -108
  112. package/cli/guidelines/sharedUiUsage/sharedUiUsage.instruction.md +0 -310
  113. package/cli/guidelines/utilUiUsage/utilUiUsage.generate.json +0 -140
  114. package/cli/guidelines/utilUiUsage/utilUiUsage.instruction.md +0 -339
  115. package/cli/index.js +0 -184404
  116. package/cli/index.ts +0 -24
  117. package/cli/library/library.command.ts +0 -28
  118. package/cli/library/library.runner.ts +0 -66
  119. package/cli/library/library.script.ts +0 -39
  120. package/cli/module/module.command.ts +0 -35
  121. package/cli/module/module.prompt.ts +0 -18
  122. package/cli/module/module.request.ts +0 -319
  123. package/cli/module/module.runner.ts +0 -76
  124. package/cli/module/module.script.ts +0 -161
  125. package/cli/npmRegistry.ts +0 -13
  126. package/cli/openBrowser.ts +0 -15
  127. package/cli/package/package.command.ts +0 -32
  128. package/cli/package/package.runner.ts +0 -94
  129. package/cli/package/package.script.ts +0 -35
  130. package/cli/page/page.command.ts +0 -14
  131. package/cli/page/page.runner.ts +0 -14
  132. package/cli/page/page.script.ts +0 -12
  133. package/cli/pluralizeName.ts +0 -5
  134. package/cli/scalar/scalar.command.ts +0 -21
  135. package/cli/scalar/scalar.prompt.ts +0 -131
  136. package/cli/scalar/scalar.runner.ts +0 -38
  137. package/cli/scalar/scalar.script.ts +0 -16
  138. package/cli/semver.ts +0 -18
  139. package/cli/templates/__scalar/__model__/__model__.constant.ts +0 -15
  140. package/cli/templates/__scalar/__model__/__model__.dictionary.ts +0 -19
  141. package/cli/templates/__scalar/__model__/__model__.document.ts +0 -15
  142. package/cli/templates/app/akan.config.ts +0 -14
  143. package/cli/templates/app/env/env.client.debug.ts.template +0 -7
  144. package/cli/templates/app/env/env.client.develop.ts.template +0 -7
  145. package/cli/templates/app/env/env.client.local.ts.template +0 -7
  146. package/cli/templates/app/env/env.client.main.ts.template +0 -7
  147. package/cli/templates/app/env/env.client.testing.ts.template +0 -7
  148. package/cli/templates/app/env/env.client.ts +0 -21
  149. package/cli/templates/app/env/env.client.type.ts +0 -16
  150. package/cli/templates/app/env/env.server.debug.ts.template +0 -7
  151. package/cli/templates/app/env/env.server.develop.ts.template +0 -7
  152. package/cli/templates/app/env/env.server.local.ts.template +0 -7
  153. package/cli/templates/app/env/env.server.main.ts.template +0 -7
  154. package/cli/templates/app/env/env.server.testing.ts.template +0 -6
  155. package/cli/templates/app/env/env.server.ts +0 -20
  156. package/cli/templates/app/lib/___appName__/__appName__.dictionary.ts +0 -17
  157. package/cli/templates/app/lib/___appName__/__appName__.service.ts +0 -13
  158. package/cli/templates/app/lib/___appName__/__appName__.signal.ts +0 -17
  159. package/cli/templates/app/lib/___appName__/__appName__.store.ts +0 -15
  160. package/cli/templates/app/lib/option.ts +0 -17
  161. package/cli/templates/app/main.ts +0 -16
  162. package/cli/templates/app/package.json.template +0 -5
  163. package/cli/templates/app/page/_index.tsx +0 -296
  164. package/cli/templates/app/page/_layout.tsx +0 -31
  165. package/cli/templates/app/page/styles.css.template +0 -53
  166. package/cli/templates/app/public/favicon.ico +0 -0
  167. package/cli/templates/app/public/logo.png +0 -0
  168. package/cli/templates/app/tsconfig.json.template +0 -21
  169. package/cli/templates/client.ts +0 -46
  170. package/cli/templates/crudPages/[__model__Id]/edit/page.tsx +0 -47
  171. package/cli/templates/crudPages/[__model__Id]/page.tsx +0 -52
  172. package/cli/templates/crudPages/new/page.tsx +0 -42
  173. package/cli/templates/crudPages/page.tsx +0 -43
  174. package/cli/templates/crudSinglePage/page.tsx +0 -37
  175. package/cli/templates/env/_env.server.type.ts +0 -16
  176. package/cli/templates/facetIndex/index.ts +0 -32
  177. package/cli/templates/index.ts +0 -10
  178. package/cli/templates/lib/__lib/lib.constant.ts +0 -38
  179. package/cli/templates/lib/__lib/lib.dictionary.ts +0 -33
  180. package/cli/templates/lib/__lib/lib.document.ts +0 -35
  181. package/cli/templates/lib/__lib/lib.service.ts +0 -33
  182. package/cli/templates/lib/__lib/lib.signal.ts +0 -34
  183. package/cli/templates/lib/__lib/lib.store.ts +0 -33
  184. package/cli/templates/lib/cnst.ts +0 -29
  185. package/cli/templates/lib/db.ts +0 -32
  186. package/cli/templates/lib/dict.ts +0 -49
  187. package/cli/templates/lib/sig.ts +0 -60
  188. package/cli/templates/lib/srv.ts +0 -34
  189. package/cli/templates/lib/st.ts +0 -31
  190. package/cli/templates/lib/useClient.ts +0 -19
  191. package/cli/templates/lib/useServer.ts +0 -7
  192. package/cli/templates/libRoot/.gitignore.template +0 -16
  193. package/cli/templates/libRoot/akan.config.ts +0 -12
  194. package/cli/templates/libRoot/base/baseLogic.ts +0 -10
  195. package/cli/templates/libRoot/base/index.ts +0 -8
  196. package/cli/templates/libRoot/common/commonLogic.ts +0 -10
  197. package/cli/templates/libRoot/common/index.ts +0 -8
  198. package/cli/templates/libRoot/env/env.server.example.ts.template +0 -6
  199. package/cli/templates/libRoot/env/env.server.testing.ts.template +0 -6
  200. package/cli/templates/libRoot/lib/___libName__/__libName__.dictionary.ts +0 -15
  201. package/cli/templates/libRoot/lib/___libName__/__libName__.service.ts +0 -11
  202. package/cli/templates/libRoot/lib/___libName__/__libName__.store.ts +0 -13
  203. package/cli/templates/libRoot/lib/option.ts +0 -17
  204. package/cli/templates/libRoot/package.json.template +0 -5
  205. package/cli/templates/libRoot/srvkit/backendLogic.ts +0 -10
  206. package/cli/templates/libRoot/srvkit/index.ts +0 -8
  207. package/cli/templates/libRoot/tsconfig.json.template +0 -11
  208. package/cli/templates/libRoot/ui/index.ts +0 -7
  209. package/cli/templates/libRoot/webkit/frontendLogic.ts +0 -10
  210. package/cli/templates/libRoot/webkit/index.ts +0 -8
  211. package/cli/templates/localDev/docker-compose.yaml.template +0 -37
  212. package/cli/templates/module/__Model__.Template.tsx +0 -36
  213. package/cli/templates/module/__Model__.Unit.tsx +0 -26
  214. package/cli/templates/module/__Model__.Util.tsx +0 -30
  215. package/cli/templates/module/__Model__.View.tsx +0 -29
  216. package/cli/templates/module/__Model__.Zone.tsx +0 -43
  217. package/cli/templates/module/__model__.constant.ts +0 -24
  218. package/cli/templates/module/__model__.dictionary.ts +0 -30
  219. package/cli/templates/module/__model__.document.ts +0 -23
  220. package/cli/templates/module/__model__.service.ts +0 -16
  221. package/cli/templates/module/__model__.signal.ts +0 -27
  222. package/cli/templates/module/__model__.store.ts +0 -19
  223. package/cli/templates/moduleRoot/index.tsx +0 -31
  224. package/cli/templates/pkgRoot/tsconfig.json.template +0 -10
  225. package/cli/templates/server.ts +0 -45
  226. package/cli/templates/workspaceRoot/.env.template +0 -14
  227. package/cli/templates/workspaceRoot/.gitignore.template +0 -120
  228. package/cli/templates/workspaceRoot/.vscode/settings.json.template +0 -23
  229. package/cli/templates/workspaceRoot/biome.json.template +0 -191
  230. package/cli/templates/workspaceRoot/bunfig.toml +0 -4
  231. package/cli/templates/workspaceRoot/package.json.template +0 -7
  232. package/cli/templates/workspaceRoot/tsconfig.json.template +0 -29
  233. package/cli/testHelpers.ts +0 -171
  234. package/cli/workspace/workspace.command.ts +0 -55
  235. package/cli/workspace/workspace.runner.ts +0 -79
  236. package/cli/workspace/workspace.script.ts +0 -74
  237. package/devkit/aiEditor.ts +0 -299
  238. package/devkit/akanApp/akanApp.host.ts +0 -393
  239. package/devkit/akanApp/index.ts +0 -1
  240. package/devkit/akanConfig/akanConfig.ts +0 -360
  241. package/devkit/akanConfig/index.ts +0 -2
  242. package/devkit/akanConfig/types.ts +0 -187
  243. package/devkit/applicationBuildReporter.ts +0 -69
  244. package/devkit/applicationBuildRunner.ts +0 -302
  245. package/devkit/applicationReleasePackager.ts +0 -205
  246. package/devkit/artifact/implicitRootLayout.ts +0 -155
  247. package/devkit/artifact/index.ts +0 -1
  248. package/devkit/artifact/routeSeedIndex.ts +0 -128
  249. package/devkit/auth.ts +0 -41
  250. package/devkit/builder.ts +0 -164
  251. package/devkit/capacitor.base.config.ts +0 -74
  252. package/devkit/capacitorApp.ts +0 -389
  253. package/devkit/commandDecorators/argMeta.ts +0 -102
  254. package/devkit/commandDecorators/command.ts +0 -340
  255. package/devkit/commandDecorators/commandBuilder.ts +0 -224
  256. package/devkit/commandDecorators/commandMeta.ts +0 -6
  257. package/devkit/commandDecorators/dependencyBuilder.ts +0 -100
  258. package/devkit/commandDecorators/helpFormatter.ts +0 -220
  259. package/devkit/commandDecorators/index.ts +0 -8
  260. package/devkit/commandDecorators/targetMeta.ts +0 -31
  261. package/devkit/commandDecorators/types.ts +0 -10
  262. package/devkit/constants.ts +0 -25
  263. package/devkit/createTunnel.ts +0 -36
  264. package/devkit/dependencyScanner.ts +0 -339
  265. package/devkit/executors.ts +0 -1362
  266. package/devkit/extractDeps.ts +0 -85
  267. package/devkit/fileEditor.ts +0 -106
  268. package/devkit/fileSys.ts +0 -39
  269. package/devkit/frontendBuild/allRoutesBuilder.ts +0 -103
  270. package/devkit/frontendBuild/clientBuildTypes.ts +0 -114
  271. package/devkit/frontendBuild/clientEntriesBundler.ts +0 -300
  272. package/devkit/frontendBuild/clientEntryDiscovery.ts +0 -196
  273. package/devkit/frontendBuild/csrArtifactBuilder.ts +0 -237
  274. package/devkit/frontendBuild/cssCompiler.ts +0 -285
  275. package/devkit/frontendBuild/cssImportResolver.ts +0 -116
  276. package/devkit/frontendBuild/fontOptimizer.ts +0 -427
  277. package/devkit/frontendBuild/hmrChangeClassifier.ts +0 -28
  278. package/devkit/frontendBuild/hmrWatcher.ts +0 -101
  279. package/devkit/frontendBuild/index.ts +0 -18
  280. package/devkit/frontendBuild/pagesBundleBuilder.ts +0 -137
  281. package/devkit/frontendBuild/pagesEntrySourceGenerator.ts +0 -37
  282. package/devkit/frontendBuild/precompressArtifacts.ts +0 -59
  283. package/devkit/frontendBuild/routeClientBuilder.ts +0 -290
  284. package/devkit/frontendBuild/routesManifestArtifactSerializer.ts +0 -62
  285. package/devkit/frontendBuild/ssrBaseArtifactBuilder.ts +0 -139
  286. package/devkit/frontendBuild/vendorSpecifiers.ts +0 -16
  287. package/devkit/frontendBuild/watchRootResolver.ts +0 -28
  288. package/devkit/getCredentials.ts +0 -19
  289. package/devkit/getDirname.ts +0 -3
  290. package/devkit/getModelFileData.ts +0 -59
  291. package/devkit/getRelatedCnsts.ts +0 -300
  292. package/devkit/guideline.ts +0 -19
  293. package/devkit/incrementalBuilder/incrementalBuilder.host.ts +0 -152
  294. package/devkit/incrementalBuilder/incrementalBuilder.proc.ts +0 -331
  295. package/devkit/incrementalBuilder/index.ts +0 -1
  296. package/devkit/index.ts +0 -36
  297. package/devkit/lint/no-deep-internal-import.grit +0 -25
  298. package/devkit/lint/no-import-client-functions.grit +0 -32
  299. package/devkit/lint/no-import-external-library.grit +0 -21
  300. package/devkit/lint/no-js-private-class-method.grit +0 -42
  301. package/devkit/lint/no-use-client-in-server.grit +0 -7
  302. package/devkit/lint/non-scalar-props-restricted.grit +0 -13
  303. package/devkit/linter.ts +0 -248
  304. package/devkit/mobile/index.ts +0 -1
  305. package/devkit/mobile/mobileTarget.ts +0 -87
  306. package/devkit/prompter.ts +0 -71
  307. package/devkit/scanInfo.ts +0 -605
  308. package/devkit/selectModel.ts +0 -11
  309. package/devkit/spinner.ts +0 -54
  310. package/devkit/src/capacitorApp.ts +0 -277
  311. package/devkit/sshTunnel.ts +0 -151
  312. package/devkit/streamAi.ts +0 -45
  313. package/devkit/transforms/barrelAnalyzer.ts +0 -249
  314. package/devkit/transforms/barrelImportsPlugin.ts +0 -457
  315. package/devkit/transforms/externalizeFrameworkPlugin.ts +0 -159
  316. package/devkit/transforms/index.ts +0 -5
  317. package/devkit/transforms/rscUseClientTransform.ts +0 -52
  318. package/devkit/transforms/useClientBundlePlugin.ts +0 -47
  319. package/devkit/typeChecker.ts +0 -260
  320. package/devkit/types.ts +0 -44
  321. package/devkit/ui/MultiScrollList.tsx +0 -228
  322. package/devkit/ui/ScrollList.tsx +0 -106
  323. package/devkit/ui/index.ts +0 -2
  324. package/devkit/uploadRelease.ts +0 -95
  325. package/devkit/useStdoutDimensions.ts +0 -20
  326. package/types/cli/application/application.command.d.ts +0 -7
  327. package/types/cli/application/application.interface.d.ts +0 -40
  328. package/types/cli/application/application.runner.d.ts +0 -66
  329. package/types/cli/application/application.script.d.ts +0 -72
  330. package/types/cli/build.d.ts +0 -1
  331. package/types/cli/cloud/cloud.command.d.ts +0 -7
  332. package/types/cli/cloud/cloud.runner.d.ts +0 -13
  333. package/types/cli/cloud/cloud.script.d.ts +0 -23
  334. package/types/cli/guideline/guideline.command.d.ts +0 -7
  335. package/types/cli/guideline/guideline.prompt.d.ts +0 -29
  336. package/types/cli/guideline/guideline.runner.d.ts +0 -21
  337. package/types/cli/guideline/guideline.script.d.ts +0 -16
  338. package/types/cli/index.d.ts +0 -2
  339. package/types/cli/library/library.command.d.ts +0 -7
  340. package/types/cli/library/library.runner.d.ts +0 -11
  341. package/types/cli/library/library.script.d.ts +0 -13
  342. package/types/cli/module/module.command.d.ts +0 -7
  343. package/types/cli/module/module.prompt.d.ts +0 -13
  344. package/types/cli/module/module.request.d.ts +0 -63
  345. package/types/cli/module/module.runner.d.ts +0 -55
  346. package/types/cli/module/module.script.d.ts +0 -22
  347. package/types/cli/npmRegistry.d.ts +0 -1
  348. package/types/cli/openBrowser.d.ts +0 -1
  349. package/types/cli/package/package.command.d.ts +0 -7
  350. package/types/cli/package/package.runner.d.ts +0 -13
  351. package/types/cli/package/package.script.d.ts +0 -18
  352. package/types/cli/page/page.command.d.ts +0 -7
  353. package/types/cli/page/page.runner.d.ts +0 -10
  354. package/types/cli/page/page.script.d.ts +0 -13
  355. package/types/cli/pluralizeName.d.ts +0 -1
  356. package/types/cli/scalar/scalar.command.d.ts +0 -7
  357. package/types/cli/scalar/scalar.prompt.d.ts +0 -23
  358. package/types/cli/scalar/scalar.runner.d.ts +0 -16
  359. package/types/cli/scalar/scalar.script.d.ts +0 -11
  360. package/types/cli/semver.d.ts +0 -1
  361. package/types/cli/templates/__scalar/__model__/__model__.constant.d.ts +0 -7
  362. package/types/cli/templates/__scalar/__model__/__model__.dictionary.d.ts +0 -7
  363. package/types/cli/templates/__scalar/__model__/__model__.document.d.ts +0 -7
  364. package/types/cli/templates/app/akan.config.d.ts +0 -6
  365. package/types/cli/templates/app/env/env.client.d.ts +0 -6
  366. package/types/cli/templates/app/env/env.client.type.d.ts +0 -6
  367. package/types/cli/templates/app/env/env.server.d.ts +0 -6
  368. package/types/cli/templates/app/lib/___appName__/__appName__.dictionary.d.ts +0 -7
  369. package/types/cli/templates/app/lib/___appName__/__appName__.service.d.ts +0 -7
  370. package/types/cli/templates/app/lib/___appName__/__appName__.signal.d.ts +0 -7
  371. package/types/cli/templates/app/lib/___appName__/__appName__.store.d.ts +0 -7
  372. package/types/cli/templates/app/lib/option.d.ts +0 -6
  373. package/types/cli/templates/app/main.d.ts +0 -6
  374. package/types/cli/templates/app/page/_index.d.ts +0 -9
  375. package/types/cli/templates/app/page/_layout.d.ts +0 -11
  376. package/types/cli/templates/client.d.ts +0 -4
  377. package/types/cli/templates/crudPages/[__model__Id]/edit/page.d.ts +0 -11
  378. package/types/cli/templates/crudPages/[__model__Id]/page.d.ts +0 -11
  379. package/types/cli/templates/crudPages/new/page.d.ts +0 -11
  380. package/types/cli/templates/crudPages/page.d.ts +0 -11
  381. package/types/cli/templates/crudSinglePage/page.d.ts +0 -11
  382. package/types/cli/templates/env/_env.server.type.d.ts +0 -7
  383. package/types/cli/templates/facetIndex/index.d.ts +0 -13
  384. package/types/cli/templates/facetIndex.d.ts +0 -1
  385. package/types/cli/templates/index.d.ts +0 -6
  386. package/types/cli/templates/lib/__lib/lib.constant.d.ts +0 -4
  387. package/types/cli/templates/lib/__lib/lib.dictionary.d.ts +0 -4
  388. package/types/cli/templates/lib/__lib/lib.document.d.ts +0 -4
  389. package/types/cli/templates/lib/__lib/lib.service.d.ts +0 -4
  390. package/types/cli/templates/lib/__lib/lib.signal.d.ts +0 -4
  391. package/types/cli/templates/lib/__lib/lib.store.d.ts +0 -4
  392. package/types/cli/templates/lib/cnst.d.ts +0 -4
  393. package/types/cli/templates/lib/db.d.ts +0 -4
  394. package/types/cli/templates/lib/dict.d.ts +0 -4
  395. package/types/cli/templates/lib/sig.d.ts +0 -4
  396. package/types/cli/templates/lib/srv.d.ts +0 -4
  397. package/types/cli/templates/lib/st.d.ts +0 -4
  398. package/types/cli/templates/lib/useClient.d.ts +0 -4
  399. package/types/cli/templates/lib/useServer.d.ts +0 -4
  400. package/types/cli/templates/libRoot/akan.config.d.ts +0 -5
  401. package/types/cli/templates/libRoot/base/baseLogic.d.ts +0 -5
  402. package/types/cli/templates/libRoot/base/index.d.ts +0 -5
  403. package/types/cli/templates/libRoot/base.d.ts +0 -1
  404. package/types/cli/templates/libRoot/common/commonLogic.d.ts +0 -5
  405. package/types/cli/templates/libRoot/common/index.d.ts +0 -5
  406. package/types/cli/templates/libRoot/common.d.ts +0 -1
  407. package/types/cli/templates/libRoot/lib/___libName__/__libName__.dictionary.d.ts +0 -6
  408. package/types/cli/templates/libRoot/lib/___libName__/__libName__.service.d.ts +0 -6
  409. package/types/cli/templates/libRoot/lib/___libName__/__libName__.store.d.ts +0 -6
  410. package/types/cli/templates/libRoot/lib/option.d.ts +0 -6
  411. package/types/cli/templates/libRoot/srvkit/backendLogic.d.ts +0 -5
  412. package/types/cli/templates/libRoot/srvkit/index.d.ts +0 -5
  413. package/types/cli/templates/libRoot/srvkit.d.ts +0 -1
  414. package/types/cli/templates/libRoot/ui/index.d.ts +0 -5
  415. package/types/cli/templates/libRoot/ui.d.ts +0 -1
  416. package/types/cli/templates/libRoot/webkit/frontendLogic.d.ts +0 -5
  417. package/types/cli/templates/libRoot/webkit/index.d.ts +0 -5
  418. package/types/cli/templates/libRoot/webkit.d.ts +0 -1
  419. package/types/cli/templates/module/__Model__.Template.d.ts +0 -11
  420. package/types/cli/templates/module/__Model__.Unit.d.ts +0 -11
  421. package/types/cli/templates/module/__Model__.Util.d.ts +0 -11
  422. package/types/cli/templates/module/__Model__.View.d.ts +0 -11
  423. package/types/cli/templates/module/__Model__.Zone.d.ts +0 -11
  424. package/types/cli/templates/module/__model__.constant.d.ts +0 -8
  425. package/types/cli/templates/module/__model__.dictionary.d.ts +0 -8
  426. package/types/cli/templates/module/__model__.document.d.ts +0 -8
  427. package/types/cli/templates/module/__model__.service.d.ts +0 -8
  428. package/types/cli/templates/module/__model__.signal.d.ts +0 -9
  429. package/types/cli/templates/module/__model__.store.d.ts +0 -8
  430. package/types/cli/templates/moduleRoot/index.d.ts +0 -11
  431. package/types/cli/templates/moduleRoot.d.ts +0 -1
  432. package/types/cli/templates/server.d.ts +0 -4
  433. package/types/cli/templates.d.ts +0 -1
  434. package/types/cli/testHelpers.d.ts +0 -64
  435. package/types/cli/workspace/workspace.command.d.ts +0 -7
  436. package/types/cli/workspace/workspace.runner.d.ts +0 -14
  437. package/types/cli/workspace/workspace.script.d.ts +0 -29
  438. package/types/cli.d.ts +0 -1
  439. package/types/devkit/aiEditor.d.ts +0 -50
  440. package/types/devkit/akanApp/akanApp.host.d.ts +0 -16
  441. package/types/devkit/akanApp/index.d.ts +0 -1
  442. package/types/devkit/akanApp.d.ts +0 -1
  443. package/types/devkit/akanConfig/akanConfig.d.ts +0 -36
  444. package/types/devkit/akanConfig/index.d.ts +0 -2
  445. package/types/devkit/akanConfig.d.ts +0 -1
  446. package/types/devkit/applicationBuildReporter.d.ts +0 -25
  447. package/types/devkit/applicationBuildRunner.d.ts +0 -29
  448. package/types/devkit/applicationReleasePackager.d.ts +0 -17
  449. package/types/devkit/artifact/implicitRootLayout.d.ts +0 -17
  450. package/types/devkit/artifact/index.d.ts +0 -1
  451. package/types/devkit/artifact/routeSeedIndex.d.ts +0 -38
  452. package/types/devkit/artifact.d.ts +0 -1
  453. package/types/devkit/auth.d.ts +0 -9
  454. package/types/devkit/builder.d.ts +0 -18
  455. package/types/devkit/capacitor.base.config.d.ts +0 -3
  456. package/types/devkit/capacitorApp.d.ts +0 -49
  457. package/types/devkit/commandDecorators/argMeta.d.ts +0 -68
  458. package/types/devkit/commandDecorators/command.d.ts +0 -2
  459. package/types/devkit/commandDecorators/commandBuilder.d.ts +0 -60
  460. package/types/devkit/commandDecorators/commandMeta.d.ts +0 -2
  461. package/types/devkit/commandDecorators/dependencyBuilder.d.ts +0 -22
  462. package/types/devkit/commandDecorators/helpFormatter.d.ts +0 -3
  463. package/types/devkit/commandDecorators/index.d.ts +0 -8
  464. package/types/devkit/commandDecorators/targetMeta.d.ts +0 -21
  465. package/types/devkit/commandDecorators/types.d.ts +0 -8
  466. package/types/devkit/commandDecorators.d.ts +0 -1
  467. package/types/devkit/constants.d.ts +0 -25
  468. package/types/devkit/createTunnel.d.ts +0 -8
  469. package/types/devkit/dependencyScanner.d.ts +0 -33
  470. package/types/devkit/executors.d.ts +0 -320
  471. package/types/devkit/extractDeps.d.ts +0 -7
  472. package/types/devkit/fileEditor.d.ts +0 -16
  473. package/types/devkit/fileSys.d.ts +0 -12
  474. package/types/devkit/frontendBuild/allRoutesBuilder.d.ts +0 -18
  475. package/types/devkit/frontendBuild/clientBuildTypes.d.ts +0 -107
  476. package/types/devkit/frontendBuild/clientEntriesBundler.d.ts +0 -12
  477. package/types/devkit/frontendBuild/clientEntryDiscovery.d.ts +0 -19
  478. package/types/devkit/frontendBuild/csrArtifactBuilder.d.ts +0 -16
  479. package/types/devkit/frontendBuild/cssCompiler.d.ts +0 -25
  480. package/types/devkit/frontendBuild/cssImportResolver.d.ts +0 -9
  481. package/types/devkit/frontendBuild/fontOptimizer.d.ts +0 -14
  482. package/types/devkit/frontendBuild/hmrChangeClassifier.d.ts +0 -5
  483. package/types/devkit/frontendBuild/hmrWatcher.d.ts +0 -21
  484. package/types/devkit/frontendBuild/index.d.ts +0 -18
  485. package/types/devkit/frontendBuild/pagesBundleBuilder.d.ts +0 -28
  486. package/types/devkit/frontendBuild/pagesEntrySourceGenerator.d.ts +0 -9
  487. package/types/devkit/frontendBuild/precompressArtifacts.d.ts +0 -7
  488. package/types/devkit/frontendBuild/routeClientBuilder.d.ts +0 -50
  489. package/types/devkit/frontendBuild/routesManifestArtifactSerializer.d.ts +0 -12
  490. package/types/devkit/frontendBuild/ssrBaseArtifactBuilder.d.ts +0 -16
  491. package/types/devkit/frontendBuild/vendorSpecifiers.d.ts +0 -2
  492. package/types/devkit/frontendBuild/watchRootResolver.d.ts +0 -6
  493. package/types/devkit/frontendBuild.d.ts +0 -1
  494. package/types/devkit/getCredentials.d.ts +0 -12
  495. package/types/devkit/getDirname.d.ts +0 -1
  496. package/types/devkit/getModelFileData.d.ts +0 -16
  497. package/types/devkit/getRelatedCnsts.d.ts +0 -53
  498. package/types/devkit/guideline.d.ts +0 -19
  499. package/types/devkit/incrementalBuilder/incrementalBuilder.host.d.ts +0 -30
  500. package/types/devkit/incrementalBuilder/incrementalBuilder.proc.d.ts +0 -1
  501. package/types/devkit/incrementalBuilder/index.d.ts +0 -1
  502. package/types/devkit/incrementalBuilder.d.ts +0 -1
  503. package/types/devkit/index.d.ts +0 -36
  504. package/types/devkit/linter.d.ts +0 -108
  505. package/types/devkit/mobile/index.d.ts +0 -1
  506. package/types/devkit/mobile/mobileTarget.d.ts +0 -14
  507. package/types/devkit/mobile.d.ts +0 -1
  508. package/types/devkit/prompter.d.ts +0 -15
  509. package/types/devkit/scanInfo.d.ts +0 -82
  510. package/types/devkit/selectModel.d.ts +0 -1
  511. package/types/devkit/spinner.d.ts +0 -20
  512. package/types/devkit/src/capacitorApp.d.ts +0 -39
  513. package/types/devkit/sshTunnel.d.ts +0 -14
  514. package/types/devkit/streamAi.d.ts +0 -6
  515. package/types/devkit/transforms/barrelAnalyzer.d.ts +0 -27
  516. package/types/devkit/transforms/barrelImportsPlugin.d.ts +0 -26
  517. package/types/devkit/transforms/externalizeFrameworkPlugin.d.ts +0 -49
  518. package/types/devkit/transforms/index.d.ts +0 -5
  519. package/types/devkit/transforms/rscUseClientTransform.d.ts +0 -10
  520. package/types/devkit/transforms/useClientBundlePlugin.d.ts +0 -19
  521. package/types/devkit/transforms.d.ts +0 -1
  522. package/types/devkit/typeChecker.d.ts +0 -62
  523. package/types/devkit/types.d.ts +0 -43
  524. package/types/devkit/ui/MultiScrollList.d.ts +0 -13
  525. package/types/devkit/ui/ScrollList.d.ts +0 -7
  526. package/types/devkit/ui/index.d.ts +0 -2
  527. package/types/devkit/ui.d.ts +0 -1
  528. package/types/devkit/uploadRelease.d.ts +0 -10
  529. package/types/devkit/useStdoutDimensions.d.ts +0 -1
  530. 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,4 @@
1
- import type { DatabaseMode } from "akanjs/base";
1
+ import type { DatabaseMode } from "akanjs";
2
2
  import {
3
3
  type AdaptorCls,
4
4
  BlobStorage,
@@ -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
- if (process.env.AKAN_MEMORY_GC_ON_REPORT === "1") Bun.gc(true);
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) => await Promise.all(ids.map((id) => this.__store.findOne({ id }))),
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
- return await Promise.all(
85
- keys.map(async (key) => {
86
- const query =
87
- loaderInfo.type === "query"
88
- ? key
89
- : {
90
- [loaderInfo.field as string]:
91
- loaderInfo.type === "arrayField" ? documentQueryHelper.has(key) : key,
92
- };
93
- return await this.__store.findOne(documentQueryHelper.all(loaderInfo.defaultQuery, query));
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>, _projection?: any) => store.pickOne(query),
157
- pickById: (id: string | undefined, _projection?: any) => {
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.pickById(id);
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 { type BaseEnv, type Cls, ENDPOINT_META, getEnv, ID, INTERNAL_META, Int, SLICE_META } from "akanjs/base";
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, { skip, limit, sort })) as any;
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
- GET: async (req) =>
256
- await SignalContext.try(endpoint, endpointInfo, key, async () => {
257
- const context = await new SignalContext(key, req, {
258
- endpointInfo,
259
- adaptor: endpoint,
260
- registry,
261
- env,
262
- live,
263
- middleware,
264
- }).init();
265
- return await context.exec();
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: async (req) =>
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
  }
@@ -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 =