@nocobase/app-server 0.11.1-alpha.5 → 2.0.0-beta.2

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 (579) hide show
  1. package/README.md +295 -0
  2. package/dist/application/index.d.ts +128 -0
  3. package/dist/application/index.d.ts.map +1 -0
  4. package/dist/application/index.js +386 -0
  5. package/dist/application/index.js.map +1 -0
  6. package/dist/caching/config.d.ts +2 -0
  7. package/dist/caching/config.d.ts.map +1 -0
  8. package/dist/caching/config.js +2 -0
  9. package/dist/caching/config.js.map +1 -0
  10. package/dist/caching/index.d.ts +5 -0
  11. package/dist/caching/index.d.ts.map +1 -0
  12. package/dist/caching/index.js +4 -0
  13. package/dist/caching/index.js.map +1 -0
  14. package/dist/caching/provider.d.ts +8 -0
  15. package/dist/caching/provider.d.ts.map +1 -0
  16. package/dist/caching/provider.js +14 -0
  17. package/dist/caching/provider.js.map +1 -0
  18. package/dist/caching/token.d.ts +4 -0
  19. package/dist/caching/token.d.ts.map +1 -0
  20. package/dist/caching/token.js +3 -0
  21. package/dist/caching/token.js.map +1 -0
  22. package/dist/config/app-config-types.d.ts +44 -0
  23. package/dist/config/app-config-types.d.ts.map +1 -0
  24. package/dist/config/app-config-types.js +2 -0
  25. package/dist/config/app-config-types.js.map +1 -0
  26. package/dist/config/app-config.d.ts +60 -0
  27. package/dist/config/app-config.d.ts.map +1 -0
  28. package/dist/config/app-config.js +247 -0
  29. package/dist/config/app-config.js.map +1 -0
  30. package/dist/config/context.d.ts +3 -0
  31. package/dist/config/context.d.ts.map +1 -0
  32. package/dist/config/context.js +7 -0
  33. package/dist/config/context.js.map +1 -0
  34. package/dist/config/define-app-config.d.ts +71 -0
  35. package/dist/config/define-app-config.d.ts.map +1 -0
  36. package/dist/config/define-app-config.js +48 -0
  37. package/dist/config/define-app-config.js.map +1 -0
  38. package/dist/config/index.d.ts +13 -0
  39. package/dist/config/index.d.ts.map +1 -0
  40. package/dist/config/index.js +11 -0
  41. package/dist/config/index.js.map +1 -0
  42. package/dist/config/not-configured.d.ts +23 -0
  43. package/dist/config/not-configured.d.ts.map +1 -0
  44. package/dist/config/not-configured.js +31 -0
  45. package/dist/config/not-configured.js.map +1 -0
  46. package/dist/config/paths.d.ts +27 -0
  47. package/dist/config/paths.d.ts.map +1 -0
  48. package/dist/config/paths.js +27 -0
  49. package/dist/config/paths.js.map +1 -0
  50. package/dist/config/placeholder-secret.d.ts +19 -0
  51. package/dist/config/placeholder-secret.d.ts.map +1 -0
  52. package/dist/config/placeholder-secret.js +26 -0
  53. package/dist/config/placeholder-secret.js.map +1 -0
  54. package/dist/config/runtime-environment.d.ts +11 -0
  55. package/dist/config/runtime-environment.d.ts.map +1 -0
  56. package/dist/config/runtime-environment.js +20 -0
  57. package/dist/config/runtime-environment.js.map +1 -0
  58. package/dist/config/types.d.ts +12 -0
  59. package/dist/config/types.d.ts.map +1 -0
  60. package/dist/config/types.js +2 -0
  61. package/dist/config/types.js.map +1 -0
  62. package/dist/config/validation.d.ts +36 -0
  63. package/dist/config/validation.d.ts.map +1 -0
  64. package/dist/config/validation.js +186 -0
  65. package/dist/config/validation.js.map +1 -0
  66. package/dist/config/variables.d.ts +57 -0
  67. package/dist/config/variables.d.ts.map +1 -0
  68. package/dist/config/variables.js +89 -0
  69. package/dist/config/variables.js.map +1 -0
  70. package/dist/database/collections-artifact.d.ts +99 -0
  71. package/dist/database/collections-artifact.d.ts.map +1 -0
  72. package/dist/database/collections-artifact.js +397 -0
  73. package/dist/database/collections-artifact.js.map +1 -0
  74. package/dist/database/collections-directory.d.ts +36 -0
  75. package/dist/database/collections-directory.d.ts.map +1 -0
  76. package/dist/database/collections-directory.js +115 -0
  77. package/dist/database/collections-directory.js.map +1 -0
  78. package/dist/database/collections-doctor.d.ts +43 -0
  79. package/dist/database/collections-doctor.d.ts.map +1 -0
  80. package/dist/database/collections-doctor.js +88 -0
  81. package/dist/database/collections-doctor.js.map +1 -0
  82. package/dist/database/connection-check.d.ts +25 -0
  83. package/dist/database/connection-check.d.ts.map +1 -0
  84. package/dist/database/connection-check.js +65 -0
  85. package/dist/database/connection-check.js.map +1 -0
  86. package/dist/database/connection-selection.d.ts +16 -0
  87. package/dist/database/connection-selection.d.ts.map +1 -0
  88. package/dist/database/connection-selection.js +30 -0
  89. package/dist/database/connection-selection.js.map +1 -0
  90. package/dist/database/define-app-database-config.d.ts +49 -0
  91. package/dist/database/define-app-database-config.d.ts.map +1 -0
  92. package/dist/database/define-app-database-config.js +73 -0
  93. package/dist/database/define-app-database-config.js.map +1 -0
  94. package/dist/database/environment.d.ts +11 -0
  95. package/dist/database/environment.d.ts.map +1 -0
  96. package/dist/database/environment.js +49 -0
  97. package/dist/database/environment.js.map +1 -0
  98. package/dist/database/index.d.ts +17 -0
  99. package/dist/database/index.d.ts.map +1 -0
  100. package/dist/database/index.js +16 -0
  101. package/dist/database/index.js.map +1 -0
  102. package/dist/database/manager.d.ts +16 -0
  103. package/dist/database/manager.d.ts.map +1 -0
  104. package/dist/database/manager.js +83 -0
  105. package/dist/database/manager.js.map +1 -0
  106. package/dist/database/migrator.d.ts +88 -0
  107. package/dist/database/migrator.d.ts.map +1 -0
  108. package/dist/database/migrator.js +143 -0
  109. package/dist/database/migrator.js.map +1 -0
  110. package/dist/database/ownership.d.ts +6 -0
  111. package/dist/database/ownership.d.ts.map +1 -0
  112. package/dist/database/ownership.js +50 -0
  113. package/dist/database/ownership.js.map +1 -0
  114. package/dist/database/plan.d.ts +36 -0
  115. package/dist/database/plan.d.ts.map +1 -0
  116. package/dist/database/plan.js +136 -0
  117. package/dist/database/plan.js.map +1 -0
  118. package/dist/database/provider.d.ts +43 -0
  119. package/dist/database/provider.d.ts.map +1 -0
  120. package/dist/database/provider.js +171 -0
  121. package/dist/database/provider.js.map +1 -0
  122. package/dist/database/resolve-config.d.ts +42 -0
  123. package/dist/database/resolve-config.d.ts.map +1 -0
  124. package/dist/database/resolve-config.js +118 -0
  125. package/dist/database/resolve-config.js.map +1 -0
  126. package/dist/database/seeder.d.ts +50 -0
  127. package/dist/database/seeder.d.ts.map +1 -0
  128. package/dist/database/seeder.js +117 -0
  129. package/dist/database/seeder.js.map +1 -0
  130. package/dist/database/storage.d.ts +10 -0
  131. package/dist/database/storage.d.ts.map +1 -0
  132. package/dist/database/storage.js +37 -0
  133. package/dist/database/storage.js.map +1 -0
  134. package/dist/database/task-config.d.ts +7 -0
  135. package/dist/database/task-config.d.ts.map +1 -0
  136. package/dist/database/task-config.js +19 -0
  137. package/dist/database/task-config.js.map +1 -0
  138. package/dist/database/task-container.d.ts +3 -0
  139. package/dist/database/task-container.d.ts.map +1 -0
  140. package/dist/database/task-container.js +34 -0
  141. package/dist/database/task-container.js.map +1 -0
  142. package/dist/database/tasks.d.ts +104 -0
  143. package/dist/database/tasks.d.ts.map +1 -0
  144. package/dist/database/tasks.js +350 -0
  145. package/dist/database/tasks.js.map +1 -0
  146. package/dist/database/types.d.ts +92 -0
  147. package/dist/database/types.d.ts.map +1 -0
  148. package/dist/database/types.js +2 -0
  149. package/dist/database/types.js.map +1 -0
  150. package/dist/drive/config.d.ts +2 -0
  151. package/dist/drive/config.d.ts.map +1 -0
  152. package/dist/drive/config.js +2 -0
  153. package/dist/drive/config.js.map +1 -0
  154. package/dist/drive/index.d.ts +5 -0
  155. package/dist/drive/index.d.ts.map +1 -0
  156. package/dist/drive/index.js +4 -0
  157. package/dist/drive/index.js.map +1 -0
  158. package/dist/drive/provider.d.ts +9 -0
  159. package/dist/drive/provider.d.ts.map +1 -0
  160. package/dist/drive/provider.js +22 -0
  161. package/dist/drive/provider.js.map +1 -0
  162. package/dist/drive/token.d.ts +4 -0
  163. package/dist/drive/token.d.ts.map +1 -0
  164. package/dist/drive/token.js +3 -0
  165. package/dist/drive/token.js.map +1 -0
  166. package/dist/i18n/index.d.ts +37 -0
  167. package/dist/i18n/index.d.ts.map +1 -0
  168. package/dist/i18n/index.js +44 -0
  169. package/dist/i18n/index.js.map +1 -0
  170. package/dist/id-generator/config.d.ts +2 -0
  171. package/dist/id-generator/config.d.ts.map +1 -0
  172. package/dist/id-generator/config.js +2 -0
  173. package/dist/id-generator/config.js.map +1 -0
  174. package/dist/id-generator/index.d.ts +5 -0
  175. package/dist/id-generator/index.d.ts.map +1 -0
  176. package/dist/id-generator/index.js +4 -0
  177. package/dist/id-generator/index.js.map +1 -0
  178. package/dist/id-generator/provider.d.ts +7 -0
  179. package/dist/id-generator/provider.d.ts.map +1 -0
  180. package/dist/id-generator/provider.js +11 -0
  181. package/dist/id-generator/provider.js.map +1 -0
  182. package/dist/id-generator/token.d.ts +4 -0
  183. package/dist/id-generator/token.d.ts.map +1 -0
  184. package/dist/id-generator/token.js +3 -0
  185. package/dist/id-generator/token.js.map +1 -0
  186. package/dist/index.d.ts +20 -0
  187. package/dist/index.d.ts.map +1 -0
  188. package/dist/index.js +20 -0
  189. package/dist/index.js.map +1 -0
  190. package/dist/jobs/config.d.ts +2 -0
  191. package/dist/jobs/config.d.ts.map +1 -0
  192. package/dist/jobs/config.js +2 -0
  193. package/dist/jobs/config.js.map +1 -0
  194. package/dist/jobs/index.d.ts +4 -0
  195. package/dist/jobs/index.d.ts.map +1 -0
  196. package/dist/jobs/index.js +4 -0
  197. package/dist/jobs/index.js.map +1 -0
  198. package/dist/jobs/provider.d.ts +23 -0
  199. package/dist/jobs/provider.d.ts.map +1 -0
  200. package/dist/jobs/provider.js +55 -0
  201. package/dist/jobs/provider.js.map +1 -0
  202. package/dist/jobs/token.d.ts +8 -0
  203. package/dist/jobs/token.d.ts.map +1 -0
  204. package/dist/jobs/token.js +7 -0
  205. package/dist/jobs/token.js.map +1 -0
  206. package/dist/logging/config.d.ts +16 -0
  207. package/dist/logging/config.d.ts.map +1 -0
  208. package/dist/logging/config.js +26 -0
  209. package/dist/logging/config.js.map +1 -0
  210. package/dist/logging/index.d.ts +5 -0
  211. package/dist/logging/index.d.ts.map +1 -0
  212. package/dist/logging/index.js +5 -0
  213. package/dist/logging/index.js.map +1 -0
  214. package/dist/logging/middleware.d.ts +13 -0
  215. package/dist/logging/middleware.d.ts.map +1 -0
  216. package/dist/logging/middleware.js +128 -0
  217. package/dist/logging/middleware.js.map +1 -0
  218. package/dist/logging/provider.d.ts +9 -0
  219. package/dist/logging/provider.d.ts.map +1 -0
  220. package/dist/logging/provider.js +95 -0
  221. package/dist/logging/provider.js.map +1 -0
  222. package/dist/logging/token.d.ts +4 -0
  223. package/dist/logging/token.d.ts.map +1 -0
  224. package/dist/logging/token.js +3 -0
  225. package/dist/logging/token.js.map +1 -0
  226. package/dist/node/config.d.ts +6 -0
  227. package/dist/node/config.d.ts.map +1 -0
  228. package/dist/node/config.js +2 -0
  229. package/dist/node/config.js.map +1 -0
  230. package/dist/node/index.d.ts +6 -0
  231. package/dist/node/index.d.ts.map +1 -0
  232. package/dist/node/index.js +6 -0
  233. package/dist/node/index.js.map +1 -0
  234. package/dist/node/not-configured-message.d.ts +10 -0
  235. package/dist/node/not-configured-message.d.ts.map +1 -0
  236. package/dist/node/not-configured-message.js +24 -0
  237. package/dist/node/not-configured-message.js.map +1 -0
  238. package/dist/node/proxy.d.ts +25 -0
  239. package/dist/node/proxy.d.ts.map +1 -0
  240. package/dist/node/proxy.js +229 -0
  241. package/dist/node/proxy.js.map +1 -0
  242. package/dist/node/runtime.d.ts +45 -0
  243. package/dist/node/runtime.d.ts.map +1 -0
  244. package/dist/node/runtime.js +176 -0
  245. package/dist/node/runtime.js.map +1 -0
  246. package/dist/node/scope.d.ts +55 -0
  247. package/dist/node/scope.d.ts.map +1 -0
  248. package/dist/node/scope.js +115 -0
  249. package/dist/node/scope.js.map +1 -0
  250. package/dist/node/server.d.ts +80 -0
  251. package/dist/node/server.d.ts.map +1 -0
  252. package/dist/node/server.js +283 -0
  253. package/dist/node/server.js.map +1 -0
  254. package/dist/plugins/define.d.ts +4 -0
  255. package/dist/plugins/define.d.ts.map +1 -0
  256. package/dist/plugins/define.js +45 -0
  257. package/dist/plugins/define.js.map +1 -0
  258. package/dist/plugins/index.d.ts +27 -0
  259. package/dist/plugins/index.d.ts.map +1 -0
  260. package/dist/plugins/index.js +4 -0
  261. package/dist/plugins/index.js.map +1 -0
  262. package/dist/plugins/inspect.d.ts +79 -0
  263. package/dist/plugins/inspect.d.ts.map +1 -0
  264. package/dist/plugins/inspect.js +142 -0
  265. package/dist/plugins/inspect.js.map +1 -0
  266. package/dist/plugins/resolve.d.ts +14 -0
  267. package/dist/plugins/resolve.d.ts.map +1 -0
  268. package/dist/plugins/resolve.js +101 -0
  269. package/dist/plugins/resolve.js.map +1 -0
  270. package/dist/plugins/types.d.ts +91 -0
  271. package/dist/plugins/types.d.ts.map +1 -0
  272. package/dist/plugins/types.js +2 -0
  273. package/dist/plugins/types.js.map +1 -0
  274. package/dist/proxy/http-proxy.d.ts +8 -0
  275. package/dist/proxy/http-proxy.d.ts.map +1 -0
  276. package/dist/proxy/http-proxy.js +59 -0
  277. package/dist/proxy/http-proxy.js.map +1 -0
  278. package/dist/proxy/index.d.ts +3 -0
  279. package/dist/proxy/index.d.ts.map +1 -0
  280. package/dist/proxy/index.js +3 -0
  281. package/dist/proxy/index.js.map +1 -0
  282. package/dist/proxy/origin.d.ts +12 -0
  283. package/dist/proxy/origin.d.ts.map +1 -0
  284. package/dist/proxy/origin.js +61 -0
  285. package/dist/proxy/origin.js.map +1 -0
  286. package/dist/queue/config.d.ts +4 -0
  287. package/dist/queue/config.d.ts.map +1 -0
  288. package/dist/queue/config.js +2 -0
  289. package/dist/queue/config.js.map +1 -0
  290. package/dist/queue/index.d.ts +4 -0
  291. package/dist/queue/index.d.ts.map +1 -0
  292. package/dist/queue/index.js +4 -0
  293. package/dist/queue/index.js.map +1 -0
  294. package/dist/queue/provider.d.ts +24 -0
  295. package/dist/queue/provider.d.ts.map +1 -0
  296. package/dist/queue/provider.js +57 -0
  297. package/dist/queue/provider.js.map +1 -0
  298. package/dist/queue/token.d.ts +9 -0
  299. package/dist/queue/token.d.ts.map +1 -0
  300. package/dist/queue/token.js +8 -0
  301. package/dist/queue/token.js.map +1 -0
  302. package/dist/realtime/index.d.ts +6 -0
  303. package/dist/realtime/index.d.ts.map +1 -0
  304. package/dist/realtime/index.js +6 -0
  305. package/dist/realtime/index.js.map +1 -0
  306. package/dist/realtime/provider.d.ts +10 -0
  307. package/dist/realtime/provider.d.ts.map +1 -0
  308. package/dist/realtime/provider.js +19 -0
  309. package/dist/realtime/provider.js.map +1 -0
  310. package/dist/realtime/service.d.ts +9 -0
  311. package/dist/realtime/service.d.ts.map +1 -0
  312. package/dist/realtime/service.js +347 -0
  313. package/dist/realtime/service.js.map +1 -0
  314. package/dist/realtime/types.d.ts +74 -0
  315. package/dist/realtime/types.d.ts.map +1 -0
  316. package/dist/realtime/types.js +4 -0
  317. package/dist/realtime/types.js.map +1 -0
  318. package/dist/realtime/websocket.d.ts +7 -0
  319. package/dist/realtime/websocket.d.ts.map +1 -0
  320. package/dist/realtime/websocket.js +57 -0
  321. package/dist/realtime/websocket.js.map +1 -0
  322. package/dist/router/api-error.d.ts +171 -0
  323. package/dist/router/api-error.d.ts.map +1 -0
  324. package/dist/router/api-error.js +291 -0
  325. package/dist/router/api-error.js.map +1 -0
  326. package/dist/router/api-limits.d.ts +80 -0
  327. package/dist/router/api-limits.d.ts.map +1 -0
  328. package/dist/router/api-limits.js +281 -0
  329. package/dist/router/api-limits.js.map +1 -0
  330. package/dist/router/cli/derive.d.ts +32 -0
  331. package/dist/router/cli/derive.d.ts.map +1 -0
  332. package/dist/router/cli/derive.js +548 -0
  333. package/dist/router/cli/derive.js.map +1 -0
  334. package/dist/router/cli/index.d.ts +6 -0
  335. package/dist/router/cli/index.d.ts.map +1 -0
  336. package/dist/router/cli/index.js +6 -0
  337. package/dist/router/cli/index.js.map +1 -0
  338. package/dist/router/cli/reference.d.ts +9 -0
  339. package/dist/router/cli/reference.d.ts.map +1 -0
  340. package/dist/router/cli/reference.js +64 -0
  341. package/dist/router/cli/reference.js.map +1 -0
  342. package/dist/router/cli/routes.d.ts +9 -0
  343. package/dist/router/cli/routes.d.ts.map +1 -0
  344. package/dist/router/cli/routes.js +228 -0
  345. package/dist/router/cli/routes.js.map +1 -0
  346. package/dist/router/cli/service.d.ts +50 -0
  347. package/dist/router/cli/service.d.ts.map +1 -0
  348. package/dist/router/cli/service.js +104 -0
  349. package/dist/router/cli/service.js.map +1 -0
  350. package/dist/router/cli/types.d.ts +278 -0
  351. package/dist/router/cli/types.d.ts.map +1 -0
  352. package/dist/router/cli/types.js +18 -0
  353. package/dist/router/cli/types.js.map +1 -0
  354. package/dist/router/duplicate-routes.d.ts +25 -0
  355. package/dist/router/duplicate-routes.d.ts.map +1 -0
  356. package/dist/router/duplicate-routes.js +51 -0
  357. package/dist/router/duplicate-routes.js.map +1 -0
  358. package/dist/router/health.d.ts +7 -0
  359. package/dist/router/health.d.ts.map +1 -0
  360. package/dist/router/health.js +48 -0
  361. package/dist/router/health.js.map +1 -0
  362. package/dist/router/index.d.ts +26 -0
  363. package/dist/router/index.d.ts.map +1 -0
  364. package/dist/router/index.js +29 -0
  365. package/dist/router/index.js.map +1 -0
  366. package/dist/router/openapi/components.d.ts +24 -0
  367. package/dist/router/openapi/components.d.ts.map +1 -0
  368. package/dist/router/openapi/components.js +128 -0
  369. package/dist/router/openapi/components.js.map +1 -0
  370. package/dist/router/openapi/declared.d.ts +19 -0
  371. package/dist/router/openapi/declared.d.ts.map +1 -0
  372. package/dist/router/openapi/declared.js +46 -0
  373. package/dist/router/openapi/declared.js.map +1 -0
  374. package/dist/router/openapi/describe.d.ts +82 -0
  375. package/dist/router/openapi/describe.d.ts.map +1 -0
  376. package/dist/router/openapi/describe.js +207 -0
  377. package/dist/router/openapi/describe.js.map +1 -0
  378. package/dist/router/openapi/docs-routes.d.ts +10 -0
  379. package/dist/router/openapi/docs-routes.d.ts.map +1 -0
  380. package/dist/router/openapi/docs-routes.js +157 -0
  381. package/dist/router/openapi/docs-routes.js.map +1 -0
  382. package/dist/router/openapi/document.d.ts +151 -0
  383. package/dist/router/openapi/document.d.ts.map +1 -0
  384. package/dist/router/openapi/document.js +471 -0
  385. package/dist/router/openapi/document.js.map +1 -0
  386. package/dist/router/openapi/index.d.ts +7 -0
  387. package/dist/router/openapi/index.d.ts.map +1 -0
  388. package/dist/router/openapi/index.js +7 -0
  389. package/dist/router/openapi/index.js.map +1 -0
  390. package/dist/router/openapi/repository-document.d.ts +30 -0
  391. package/dist/router/openapi/repository-document.d.ts.map +1 -0
  392. package/dist/router/openapi/repository-document.js +812 -0
  393. package/dist/router/openapi/repository-document.js.map +1 -0
  394. package/dist/router/openapi/schema.d.ts +30 -0
  395. package/dist/router/openapi/schema.d.ts.map +1 -0
  396. package/dist/router/openapi/schema.js +301 -0
  397. package/dist/router/openapi/schema.js.map +1 -0
  398. package/dist/router/openapi/service.d.ts +101 -0
  399. package/dist/router/openapi/service.d.ts.map +1 -0
  400. package/dist/router/openapi/service.js +162 -0
  401. package/dist/router/openapi/service.js.map +1 -0
  402. package/dist/router/repository-constraints.d.ts +15 -0
  403. package/dist/router/repository-constraints.d.ts.map +1 -0
  404. package/dist/router/repository-constraints.js +14 -0
  405. package/dist/router/repository-constraints.js.map +1 -0
  406. package/dist/router/repository-routes.d.ts +90 -0
  407. package/dist/router/repository-routes.d.ts.map +1 -0
  408. package/dist/router/repository-routes.js +452 -0
  409. package/dist/router/repository-routes.js.map +1 -0
  410. package/dist/router/routes.d.ts +24 -0
  411. package/dist/router/routes.d.ts.map +1 -0
  412. package/dist/router/routes.js +19 -0
  413. package/dist/router/routes.js.map +1 -0
  414. package/dist/runtime/application.d.ts +8 -0
  415. package/dist/runtime/application.d.ts.map +1 -0
  416. package/dist/runtime/application.js +22 -0
  417. package/dist/runtime/application.js.map +1 -0
  418. package/dist/runtime/definition.d.ts +50 -0
  419. package/dist/runtime/definition.d.ts.map +1 -0
  420. package/dist/runtime/definition.js +82 -0
  421. package/dist/runtime/definition.js.map +1 -0
  422. package/dist/runtime/index.d.ts +8 -0
  423. package/dist/runtime/index.d.ts.map +1 -0
  424. package/dist/runtime/index.js +7 -0
  425. package/dist/runtime/index.js.map +1 -0
  426. package/dist/runtime/lifecycle.d.ts +29 -0
  427. package/dist/runtime/lifecycle.d.ts.map +1 -0
  428. package/dist/runtime/lifecycle.js +104 -0
  429. package/dist/runtime/lifecycle.js.map +1 -0
  430. package/dist/runtime/mount.d.ts +4 -0
  431. package/dist/runtime/mount.d.ts.map +1 -0
  432. package/dist/runtime/mount.js +47 -0
  433. package/dist/runtime/mount.js.map +1 -0
  434. package/dist/runtime/scope.d.ts +29 -0
  435. package/dist/runtime/scope.d.ts.map +1 -0
  436. package/dist/runtime/scope.js +48 -0
  437. package/dist/runtime/scope.js.map +1 -0
  438. package/dist/runtime/types.d.ts +55 -0
  439. package/dist/runtime/types.d.ts.map +1 -0
  440. package/dist/runtime/types.js +2 -0
  441. package/dist/runtime/types.js.map +1 -0
  442. package/dist/sample-data/index.d.ts +3 -0
  443. package/dist/sample-data/index.d.ts.map +1 -0
  444. package/dist/sample-data/index.js +3 -0
  445. package/dist/sample-data/index.js.map +1 -0
  446. package/dist/sample-data/registry.d.ts +4 -0
  447. package/dist/sample-data/registry.d.ts.map +1 -0
  448. package/dist/sample-data/registry.js +74 -0
  449. package/dist/sample-data/registry.js.map +1 -0
  450. package/dist/sample-data/token.d.ts +64 -0
  451. package/dist/sample-data/token.d.ts.map +1 -0
  452. package/dist/sample-data/token.js +7 -0
  453. package/dist/sample-data/token.js.map +1 -0
  454. package/dist/secrets/config.d.ts +15 -0
  455. package/dist/secrets/config.d.ts.map +1 -0
  456. package/dist/secrets/config.js +43 -0
  457. package/dist/secrets/config.js.map +1 -0
  458. package/dist/secrets/index.d.ts +6 -0
  459. package/dist/secrets/index.d.ts.map +1 -0
  460. package/dist/secrets/index.js +6 -0
  461. package/dist/secrets/index.js.map +1 -0
  462. package/dist/secrets/provider.d.ts +7 -0
  463. package/dist/secrets/provider.d.ts.map +1 -0
  464. package/dist/secrets/provider.js +10 -0
  465. package/dist/secrets/provider.js.map +1 -0
  466. package/dist/secrets/service.d.ts +64 -0
  467. package/dist/secrets/service.d.ts.map +1 -0
  468. package/dist/secrets/service.js +47 -0
  469. package/dist/secrets/service.js.map +1 -0
  470. package/dist/secrets/table-store.d.ts +34 -0
  471. package/dist/secrets/table-store.d.ts.map +1 -0
  472. package/dist/secrets/table-store.js +118 -0
  473. package/dist/secrets/table-store.js.map +1 -0
  474. package/dist/secrets/token.d.ts +4 -0
  475. package/dist/secrets/token.d.ts.map +1 -0
  476. package/dist/secrets/token.js +3 -0
  477. package/dist/secrets/token.js.map +1 -0
  478. package/dist/session/config.d.ts +10 -0
  479. package/dist/session/config.d.ts.map +1 -0
  480. package/dist/session/config.js +2 -0
  481. package/dist/session/config.js.map +1 -0
  482. package/dist/session/index.d.ts +4 -0
  483. package/dist/session/index.d.ts.map +1 -0
  484. package/dist/session/index.js +4 -0
  485. package/dist/session/index.js.map +1 -0
  486. package/dist/session/provider.d.ts +26 -0
  487. package/dist/session/provider.d.ts.map +1 -0
  488. package/dist/session/provider.js +69 -0
  489. package/dist/session/provider.js.map +1 -0
  490. package/dist/session/token.d.ts +4 -0
  491. package/dist/session/token.d.ts.map +1 -0
  492. package/dist/session/token.js +3 -0
  493. package/dist/session/token.js.map +1 -0
  494. package/dist/spa/config.d.ts +5 -0
  495. package/dist/spa/config.d.ts.map +1 -0
  496. package/dist/spa/config.js +2 -0
  497. package/dist/spa/config.js.map +1 -0
  498. package/dist/spa/content-types.d.ts +2 -0
  499. package/dist/spa/content-types.d.ts.map +1 -0
  500. package/dist/spa/content-types.js +25 -0
  501. package/dist/spa/content-types.js.map +1 -0
  502. package/dist/spa/index.d.ts +9 -0
  503. package/dist/spa/index.d.ts.map +1 -0
  504. package/dist/spa/index.js +9 -0
  505. package/dist/spa/index.js.map +1 -0
  506. package/dist/spa/provider.d.ts +13 -0
  507. package/dist/spa/provider.d.ts.map +1 -0
  508. package/dist/spa/provider.js +90 -0
  509. package/dist/spa/provider.js.map +1 -0
  510. package/dist/spa/routes.d.ts +4 -0
  511. package/dist/spa/routes.d.ts.map +1 -0
  512. package/dist/spa/routes.js +96 -0
  513. package/dist/spa/routes.js.map +1 -0
  514. package/dist/spa/runtime-html.d.ts +14 -0
  515. package/dist/spa/runtime-html.d.ts.map +1 -0
  516. package/dist/spa/runtime-html.js +85 -0
  517. package/dist/spa/runtime-html.js.map +1 -0
  518. package/dist/spa/serve-index.d.ts +9 -0
  519. package/dist/spa/serve-index.d.ts.map +1 -0
  520. package/dist/spa/serve-index.js +12 -0
  521. package/dist/spa/serve-index.js.map +1 -0
  522. package/dist/spa/static-assets.d.ts +7 -0
  523. package/dist/spa/static-assets.d.ts.map +1 -0
  524. package/dist/spa/static-assets.js +90 -0
  525. package/dist/spa/static-assets.js.map +1 -0
  526. package/dist/spa/types.d.ts +23 -0
  527. package/dist/spa/types.d.ts.map +1 -0
  528. package/dist/spa/types.js +2 -0
  529. package/dist/spa/types.js.map +1 -0
  530. package/dist/support/index.d.ts +4 -0
  531. package/dist/support/index.d.ts.map +1 -0
  532. package/dist/support/index.js +4 -0
  533. package/dist/support/index.js.map +1 -0
  534. package/dist/support/paths.d.ts +10 -0
  535. package/dist/support/paths.d.ts.map +1 -0
  536. package/dist/support/paths.js +25 -0
  537. package/dist/support/paths.js.map +1 -0
  538. package/dist/support/redirects.d.ts +3 -0
  539. package/dist/support/redirects.d.ts.map +1 -0
  540. package/dist/support/redirects.js +48 -0
  541. package/dist/support/redirects.js.map +1 -0
  542. package/dist/support/requests.d.ts +2 -0
  543. package/dist/support/requests.d.ts.map +1 -0
  544. package/dist/support/requests.js +13 -0
  545. package/dist/support/requests.js.map +1 -0
  546. package/dist/swagger-ui/LICENSE +202 -0
  547. package/dist/swagger-ui/NOTICE +2 -0
  548. package/dist/swagger-ui/favicon-16x16.png +0 -0
  549. package/dist/swagger-ui/favicon-32x32.png +0 -0
  550. package/dist/swagger-ui/swagger-ui-bundle.js +2 -0
  551. package/dist/swagger-ui/swagger-ui-bundle.js.LICENSE.txt +129 -0
  552. package/dist/swagger-ui/swagger-ui.css +3 -0
  553. package/dist/websocket.d.ts +61 -0
  554. package/dist/websocket.d.ts.map +1 -0
  555. package/dist/websocket.js +371 -0
  556. package/dist/websocket.js.map +1 -0
  557. package/package.json +193 -12
  558. package/LICENSE +0 -661
  559. package/lib/config/cache.d.ts +0 -2
  560. package/lib/config/cache.js +0 -16
  561. package/lib/config/database.d.ts +0 -3
  562. package/lib/config/database.js +0 -25
  563. package/lib/config/index.d.ts +0 -10
  564. package/lib/config/index.js +0 -20
  565. package/lib/config/logger.d.ts +0 -3
  566. package/lib/config/logger.js +0 -11
  567. package/lib/config/plugins.d.ts +0 -3
  568. package/lib/config/plugins.js +0 -8
  569. package/lib/config/resourcer.d.ts +0 -4
  570. package/lib/config/resourcer.js +0 -10
  571. package/lib/index.d.ts +0 -3
  572. package/lib/index.js +0 -21
  573. package/src/config/cache.ts +0 -5
  574. package/src/config/database.ts +0 -21
  575. package/src/config/index.ts +0 -13
  576. package/src/config/logger.ts +0 -6
  577. package/src/config/plugins.ts +0 -3
  578. package/src/config/resourcer.ts +0 -3
  579. package/src/index.ts +0 -10
@@ -0,0 +1,812 @@
1
+ import { filterOperatorsForFieldType, isManagedField, isSortableFieldType, supportsFilterShorthand, writableFields, } from '@nocobase/db';
2
+ import { describeRoute } from 'hono-openapi';
3
+ import { convertApiSchema } from './schema.js';
4
+ /** The operation extension a data endpoint's declaration carries until the document generator expands it. */
5
+ const repositoryExtension = 'x-nocobase-repository';
6
+ const ref = (name) => ({
7
+ $ref: `#/components/schemas/${name}`,
8
+ });
9
+ function pascal(value) {
10
+ return value.charAt(0).toUpperCase() + value.slice(1);
11
+ }
12
+ const actionSummaries = {
13
+ findMany: 'List records',
14
+ findOne: 'Get one record',
15
+ count: 'Count records',
16
+ aggregate: 'Aggregate records',
17
+ groupBy: 'Group and aggregate records',
18
+ exists: 'Check whether a record exists',
19
+ createOne: 'Create a record',
20
+ updateOne: 'Update one record',
21
+ deleteOne: 'Delete one record',
22
+ };
23
+ /** The declaration a data endpoint registers, so it is documented without a hand-written `describeRoute()`. */
24
+ export function describeRepositoryEndpoint(descriptor) {
25
+ const spec = {
26
+ tags: [pascal(descriptor.exposure)],
27
+ summary: `${actionSummaries[descriptor.action]} of ${descriptor.exposure}`,
28
+ operationId: `${descriptor.exposure}${pascal(descriptor.action)}`,
29
+ [repositoryExtension]: descriptor,
30
+ };
31
+ return describeRoute(spec);
32
+ }
33
+ /** The scalar types whose filter operators the shared `RepositoryFilter` description lists. */
34
+ const describedFieldTypes = [
35
+ 'string',
36
+ 'char',
37
+ 'uuid',
38
+ 'text',
39
+ 'enum',
40
+ 'increments',
41
+ 'integer',
42
+ 'bigInt',
43
+ 'decimal',
44
+ 'float',
45
+ 'double',
46
+ 'date',
47
+ 'datetime',
48
+ 'datetimeTz',
49
+ 'time',
50
+ 'boolean',
51
+ 'json',
52
+ ];
53
+ function operatorTable() {
54
+ const rows = new Map();
55
+ for (const type of describedFieldTypes) {
56
+ const operators = filterOperatorsForFieldType(type);
57
+ if (!operators)
58
+ continue;
59
+ const key = operators.map((operator) => `\`${operator}\``).join(' ');
60
+ rows.set(key, [...(rows.get(key) ?? []), type]);
61
+ }
62
+ return [
63
+ '| Field types | Operators |',
64
+ '| --- | --- |',
65
+ ...[...rows].map(([operators, types]) => `| ${types.join(', ')} | ${operators} |`),
66
+ ].join('\n');
67
+ }
68
+ const shorthandTypes = () => describedFieldTypes
69
+ .filter((type) => supportsFilterShorthand(type))
70
+ .join(', ');
71
+ function filterDescription() {
72
+ return [
73
+ 'A Repository filter. It takes one of two forms.',
74
+ '',
75
+ `**Shorthand**: \`{ "status": "active", "ownerId": "1" }\` matches records whose fields equal the given values, all conditions combined with AND. Only root scalar fields of these types may appear: ${shorthandTypes()}. \`null\` matches a database NULL. Operator objects such as \`{ "budget": { "$gte": 100 } }\` are not part of the syntax; use the AST.`,
76
+ '',
77
+ '**AST**: `{ "kind": "filter", "version": 1, "root": { "kind": "group", "logic": "and", "items": [...] } }`. `root` is a group; a group combines `items` with `logic` `and` or `or` and may nest. An item is a group, a condition `{ "kind": "condition", "path": ["status"], "operator": "$eq", "value": "active" }`, or a relation condition. `path` names logical fields; a path may pass through to-one relations, such as `["owner", "name"]`.',
78
+ '',
79
+ 'Operators by field type, as the Repository validates them:',
80
+ '',
81
+ operatorTable(),
82
+ '',
83
+ 'Empty values and dates: `$empty` on a string, uuid or text field matches NULL or an empty string, on any other scalar only NULL; `$eq` with `null` matches NULL and `$ne` with `null` matches anything not NULL; `$ne` and `$notIncludes` follow SQL NULL semantics and do not match NULL rows. Date values are `YYYY-MM-DD` for `date`, zone-free ISO date-times for `datetime` and ISO date-times with an offset or `Z` for `datetimeTz`. `$dateOn` and `$dateNotOn` apply to `date` only; `$dateBetween` takes `[start, end]` and is the half-open interval `[start, end)`; `$dateNotBefore` is `>=` and `$dateNotAfter` is `<=`. A string condition may set `"mode": "insensitive"` for case-insensitive matching.',
84
+ '',
85
+ 'Relation conditions: `{ "kind": "relation", "path": ["tasks"], "quantifier": "some", "filter": { "kind": "group", ... } }`. `some` matches when at least one related record matches the nested group, `none` when none does (also when there are none); `exists` / `notEmpty` and `notExists` / `empty` test whether related records exist and take no nested filter. A to-many relation is only reachable through a quantifier.',
86
+ '',
87
+ 'JSON conditions: a condition on a `json` field adds `"jsonPath": ["profile", "country"]` (string keys and array indexes) and uses the `$json*` operators: `$jsonEq` / `$jsonNe` compare a JSON value structurally, `$jsonHas`, `$jsonHasSome` and `$jsonHasEvery` test array members, `$jsonEmpty` / `$jsonNotEmpty` test for an empty array, and `$jsonDbNull`, `$jsonNull` and `$jsonAnyNull` distinguish a database NULL from a JSON null.',
88
+ '',
89
+ 'A value may be a context variable, `{ "kind": "variable", "path": "$actor.id" }`, where the server supplies a context.',
90
+ ].join('\n');
91
+ }
92
+ /** The shared Repository components every document with a data endpoint carries. */
93
+ function sharedRepositorySchemas() {
94
+ return {
95
+ RepositoryFilterVariable: {
96
+ type: 'object',
97
+ description: 'A value the server fills in from the request context.',
98
+ required: ['kind', 'path'],
99
+ properties: {
100
+ kind: { const: 'variable' },
101
+ path: { type: 'string', examples: ['$actor.id'] },
102
+ },
103
+ additionalProperties: false,
104
+ },
105
+ RepositoryFilterCondition: {
106
+ type: 'object',
107
+ description: 'A condition on a field, possibly reached through to-one relations.',
108
+ required: ['kind', 'path', 'operator'],
109
+ properties: {
110
+ kind: { const: 'condition' },
111
+ path: { type: 'array', items: { type: 'string' }, minItems: 1 },
112
+ operator: { type: 'string', pattern: '^\\$[a-zA-Z]+$' },
113
+ value: {},
114
+ mode: { type: 'string', enum: ['default', 'insensitive'] },
115
+ jsonPath: {
116
+ type: 'array',
117
+ items: {
118
+ anyOf: [{ type: 'string' }, { type: 'integer', minimum: 0 }],
119
+ },
120
+ },
121
+ },
122
+ additionalProperties: false,
123
+ },
124
+ RepositoryFilterRelation: {
125
+ type: 'object',
126
+ description: 'A condition on related records. Only `some` and `none` take a nested `filter`.',
127
+ required: ['kind', 'path', 'quantifier'],
128
+ properties: {
129
+ kind: { const: 'relation' },
130
+ path: { type: 'array', items: { type: 'string' }, minItems: 1 },
131
+ quantifier: {
132
+ type: 'string',
133
+ enum: ['exists', 'notExists', 'some', 'none', 'empty', 'notEmpty'],
134
+ },
135
+ filter: ref('RepositoryFilterGroup'),
136
+ },
137
+ additionalProperties: false,
138
+ },
139
+ RepositoryFilterGroup: {
140
+ type: 'object',
141
+ required: ['kind', 'logic', 'items'],
142
+ properties: {
143
+ kind: { const: 'group' },
144
+ logic: { type: 'string', enum: ['and', 'or'] },
145
+ items: {
146
+ type: 'array',
147
+ items: {
148
+ anyOf: [
149
+ ref('RepositoryFilterGroup'),
150
+ ref('RepositoryFilterCondition'),
151
+ ref('RepositoryFilterRelation'),
152
+ ],
153
+ },
154
+ },
155
+ },
156
+ additionalProperties: false,
157
+ },
158
+ RepositoryFilter: {
159
+ description: filterDescription(),
160
+ anyOf: [
161
+ {
162
+ type: 'object',
163
+ title: 'Shorthand',
164
+ additionalProperties: {
165
+ anyOf: [
166
+ { type: 'string' },
167
+ { type: 'number' },
168
+ { type: 'boolean' },
169
+ { type: 'null' },
170
+ ],
171
+ },
172
+ minProperties: 1,
173
+ },
174
+ {
175
+ type: 'object',
176
+ title: 'AST',
177
+ required: ['kind', 'version', 'root'],
178
+ properties: {
179
+ kind: { const: 'filter' },
180
+ version: { const: 1 },
181
+ collection: { type: 'string' },
182
+ root: ref('RepositoryFilterGroup'),
183
+ },
184
+ additionalProperties: false,
185
+ },
186
+ ],
187
+ },
188
+ RepositorySelect: {
189
+ type: 'object',
190
+ description: 'Which fields and relations to return, as a Select AST: `{ "kind": "select", "version": 1, "root": { "kind": "selection", "fields": ["id", "name"], "includes": [{ "kind": "include", "relation": "owner", "select": { "kind": "selection", "fields": ["id"] } }] } }`. Without `select` the server returns every field the exposure may read and no relations. An include may carry its own `filter`, `sort`, `limit`, `cursor`, `direction` and `distinct` on to-many relations, and `combine` returns records and aggregates of one relation together. Asking for a field the exposure may not read is refused, not silently dropped.',
191
+ required: ['kind', 'version', 'root'],
192
+ properties: {
193
+ kind: { const: 'select' },
194
+ version: { const: 1 },
195
+ collection: { type: 'string' },
196
+ root: { type: 'object', additionalProperties: true },
197
+ },
198
+ },
199
+ RepositorySort: {
200
+ type: 'object',
201
+ description: 'The order of results, as a Sort AST: `{ "kind": "sort", "version": 1, "items": [{ "kind": "field", "path": ["status"], "direction": "asc" }, { "kind": "field", "path": ["name"], "direction": "desc", "nulls": "last" }] }`. Earlier items take precedence; the primary key is appended as a tie-breaker. A field path may pass through to-one relations; a to-many relation is sorted by an aggregate, `{ "kind": "aggregate", "relation": ["tasks"], "aggregate": "count", "direction": "desc" }` (`count`, `sum`, `avg`, `min`, `max`). Sorting a field twice is refused.',
202
+ required: ['kind', 'version', 'items'],
203
+ properties: {
204
+ kind: { const: 'sort' },
205
+ version: { const: 1 },
206
+ collection: { type: 'string' },
207
+ items: {
208
+ type: 'array',
209
+ items: { type: 'object', additionalProperties: true },
210
+ },
211
+ },
212
+ },
213
+ RepositoryRelationMutation: {
214
+ type: 'object',
215
+ description: 'A nested write on a relation, such as `{ "connect": ... }`, `{ "create": ... }`, `{ "set": ... }` or `{ "disconnect": ... }`. Which operations and fields are accepted is decided by the exposure\'s Policy.',
216
+ additionalProperties: true,
217
+ },
218
+ RepositoryCreatedTarget: {
219
+ type: 'object',
220
+ description: 'A related record a nested write created.',
221
+ additionalProperties: true,
222
+ },
223
+ };
224
+ }
225
+ function nullable(schema, field) {
226
+ if (field.nullable === false || field.primaryKey)
227
+ return schema;
228
+ if (typeof schema.type === 'string')
229
+ return { ...schema, type: [schema.type, 'null'] };
230
+ if (schema.enum) {
231
+ const members = schema.enum;
232
+ return { ...schema, enum: [...members, null] };
233
+ }
234
+ return schema;
235
+ }
236
+ /** The JSON shape a scalar field's value takes over HTTP, before nullability. */
237
+ export function fieldValueSchema(field) {
238
+ const describe = (schema) => {
239
+ const text = [field.title, field.description].filter(Boolean).join(': ');
240
+ return text ? { ...schema, description: text } : schema;
241
+ };
242
+ switch (field.type) {
243
+ case 'string':
244
+ case 'char':
245
+ case 'text':
246
+ return describe({
247
+ type: 'string',
248
+ ...(field.length ? { maxLength: field.length } : {}),
249
+ });
250
+ case 'uuid':
251
+ return describe({ type: 'string', format: 'uuid' });
252
+ case 'enum':
253
+ return describe({ type: 'string', enum: [...(field.values ?? [])] });
254
+ case 'increments':
255
+ case 'integer':
256
+ return describe({ type: 'integer' });
257
+ case 'bigInt':
258
+ return describe({
259
+ type: 'string',
260
+ pattern: '^-?\\d+$',
261
+ description: 'A 64-bit integer as a decimal string, so it keeps its precision in JavaScript.',
262
+ });
263
+ case 'decimal':
264
+ return describe({
265
+ type: 'string',
266
+ pattern: '^-?\\d+(\\.\\d+)?$',
267
+ description: 'A decimal number as a string, so it keeps its precision.',
268
+ });
269
+ case 'float':
270
+ case 'double':
271
+ return describe({ type: 'number' });
272
+ case 'boolean':
273
+ return describe({ type: 'boolean' });
274
+ case 'date':
275
+ return describe({ type: 'string', format: 'date' });
276
+ case 'datetime':
277
+ return describe({
278
+ type: 'string',
279
+ description: 'A date and time without a time zone, such as `2026-10-04T08:00:00.000`.',
280
+ });
281
+ case 'datetimeTz':
282
+ return describe({ type: 'string', format: 'date-time' });
283
+ case 'time':
284
+ return describe({ type: 'string', examples: ['08:30:00'] });
285
+ case 'json':
286
+ return describe({
287
+ description: 'Any JSON value; the Collection does not constrain its structure.',
288
+ });
289
+ default:
290
+ return describe({
291
+ description: `A value of the \`${field.type}\` field type.`,
292
+ });
293
+ }
294
+ }
295
+ function isRelation(field) {
296
+ return 'target' in field && typeof field.target === 'string';
297
+ }
298
+ function scalarFields(collection) {
299
+ return (collection.fields ?? []).filter((field) => !isRelation(field));
300
+ }
301
+ function relationFields(collection) {
302
+ return (collection.fields ?? []).filter(isRelation);
303
+ }
304
+ function readSelection(collection, policy) {
305
+ const all = {
306
+ fields: new Set(scalarFields(collection).map((field) => field.name)),
307
+ relations: new Set(relationFields(collection).map((field) => field.name)),
308
+ };
309
+ if (policy === undefined || policy.read === true)
310
+ return all;
311
+ if (policy.read === false)
312
+ return undefined;
313
+ return {
314
+ fields: new Set(policy.read.fields.filter((name) => all.fields.has(name))),
315
+ relations: new Set(Object.keys(policy.read.relations).filter((name) => all.relations.has(name))),
316
+ };
317
+ }
318
+ function writeSelection(collection, node, principalDependent) {
319
+ const writable = new Set(writableFields(collection));
320
+ const relations = new Set(relationFields(collection).map((field) => field.name));
321
+ if (principalDependent || node === true)
322
+ return { fields: writable, relations };
323
+ if (node === false || node === undefined)
324
+ return undefined;
325
+ return {
326
+ fields: new Set(node.fields.filter((name) => writable.has(name))),
327
+ relations: new Set(Object.keys(node.relations).filter((name) => relations.has(name))),
328
+ };
329
+ }
330
+ const principalNote = " The exposure builds its Policy from the caller, so this lists every field of the Collection; the caller's permissions restrict which of them a request may use.";
331
+ /**
332
+ * The exposure's computed fields as read-only record properties, converted under the document's conventions, with the
333
+ * components their schemas refer to added to `schemas`. A name the Collection also has is left to the Collection: the
334
+ * routes refuse such a declaration when they are created, so this only happens when the Collection gained the field
335
+ * afterwards.
336
+ */
337
+ async function computedFieldProperties(descriptor, collection, schemas) {
338
+ const taken = new Set((collection?.fields ?? []).map((field) => field.name));
339
+ const properties = {};
340
+ for (const [name, schema] of Object.entries(descriptor.computedFields)) {
341
+ if (taken.has(name))
342
+ continue;
343
+ let converted;
344
+ if (typeof schema === 'object' && '~standard' in schema) {
345
+ const result = await convertApiSchema(schema, 'output');
346
+ converted = result.schema;
347
+ for (const [key, component] of Object.entries(result.components?.schemas ?? {}))
348
+ schemas[key] ??= component;
349
+ }
350
+ else {
351
+ converted = schema;
352
+ }
353
+ properties[name] = { ...converted, readOnly: true };
354
+ }
355
+ return properties;
356
+ }
357
+ function computedNote(names) {
358
+ if (names.length === 0)
359
+ return '';
360
+ return ` ${names.map((name) => `\`${name}\``).join(', ')} ${names.length > 1 ? 'are' : 'is'} added by the server to the records it returns rather than stored: never written, selected, filtered or sorted on.`;
361
+ }
362
+ async function buildExposureSchemas(descriptor, collection, schemas) {
363
+ const prefix = pascal(descriptor.exposure);
364
+ const principalDependent = descriptor.policy === undefined;
365
+ const note = principalDependent ? principalNote : '';
366
+ const computed = await computedFieldProperties(descriptor, collection, schemas);
367
+ const computedText = computedNote(Object.keys(computed));
368
+ if (!collection) {
369
+ const missing = `The Collection \`${descriptor.collection}\` could not be read when this document was generated, so its fields are not listed.`;
370
+ schemas[`${prefix}Record`] = {
371
+ type: 'object',
372
+ description: `${missing}${computedText}`,
373
+ ...(Object.keys(computed).length > 0 ? { properties: computed } : {}),
374
+ additionalProperties: true,
375
+ };
376
+ return {
377
+ record: ref(`${prefix}Record`),
378
+ createValues: {
379
+ type: 'object',
380
+ description: missing,
381
+ additionalProperties: true,
382
+ },
383
+ updateValues: {
384
+ type: 'object',
385
+ description: missing,
386
+ additionalProperties: true,
387
+ },
388
+ filter: ref('RepositoryFilter'),
389
+ sortableFields: [],
390
+ };
391
+ }
392
+ const byName = new Map((collection.fields ?? []).map((field) => [field.name, field]));
393
+ const readable = readSelection(collection, descriptor.policy) ?? {
394
+ fields: new Set(),
395
+ relations: new Set(),
396
+ };
397
+ const recordProperties = {};
398
+ for (const name of readable.fields) {
399
+ const field = byName.get(name);
400
+ const schema = nullable(fieldValueSchema(field), field);
401
+ recordProperties[name] = isManagedField(collection, field)
402
+ ? { ...schema, readOnly: true }
403
+ : schema;
404
+ }
405
+ for (const name of readable.relations) {
406
+ const relation = byName.get(name);
407
+ const toMany = relation.type === 'hasMany' || relation.type === 'belongsToMany';
408
+ const target = {
409
+ type: 'object',
410
+ additionalProperties: true,
411
+ description: `A related \`${relation.target}\` record.`,
412
+ };
413
+ recordProperties[name] = {
414
+ ...(toMany
415
+ ? { type: 'array', items: target }
416
+ : { anyOf: [target, { type: 'null' }] }),
417
+ description: `The \`${relation.type}\` relation to \`${relation.target}\`. Returned only when \`select\` includes it.`,
418
+ };
419
+ }
420
+ Object.assign(recordProperties, computed);
421
+ schemas[`${prefix}Record`] = {
422
+ type: 'object',
423
+ description: `A \`${collection.name ?? descriptor.collection}\` record as \`${descriptor.exposure}\` returns it. Without \`select\` every listed scalar field is returned.${computedText}${note}`,
424
+ properties: recordProperties,
425
+ };
426
+ const values = (kind) => {
427
+ const selection = writeSelection(collection, principalDependent ? undefined : descriptor.policy[kind], principalDependent);
428
+ const name = `${prefix}${pascal(kind)}Values`;
429
+ if (!selection) {
430
+ schemas[name] = {
431
+ type: 'object',
432
+ description: `The exposure's Policy refuses every ${kind}.`,
433
+ maxProperties: 0,
434
+ };
435
+ return ref(name);
436
+ }
437
+ const properties = {};
438
+ for (const fieldName of selection.fields) {
439
+ const field = byName.get(fieldName);
440
+ properties[fieldName] = nullable(fieldValueSchema(field), field);
441
+ }
442
+ for (const relationName of selection.relations) {
443
+ properties[relationName] = ref('RepositoryRelationMutation');
444
+ }
445
+ const required = kind === 'create'
446
+ ? [...selection.fields].filter((fieldName) => {
447
+ const field = byName.get(fieldName);
448
+ return ((field.nullable === false || field.primaryKey === true) &&
449
+ field.defaultValue === undefined &&
450
+ !(descriptor.policy &&
451
+ descriptor.policy.create !== true &&
452
+ descriptor.policy.create !== false &&
453
+ Object.hasOwn(descriptor.policy.create.defaults, fieldName)));
454
+ })
455
+ : [];
456
+ schemas[name] = {
457
+ type: 'object',
458
+ description: `The fields a ${kind} may write. Fields the database or the Repository assigns, such as an auto-increment key or the optimistic-lock version, are never written.${note}`,
459
+ properties,
460
+ ...(required.length > 0 ? { required } : {}),
461
+ additionalProperties: false,
462
+ };
463
+ return ref(name);
464
+ };
465
+ const filterable = scalarFields(collection).filter((field) => readable.fields.has(field.name));
466
+ const shorthandProperties = {};
467
+ const conditions = [];
468
+ for (const field of filterable) {
469
+ const value = fieldValueSchema(field);
470
+ if (supportsFilterShorthand(field.type)) {
471
+ shorthandProperties[field.name] = { anyOf: [value, { type: 'null' }] };
472
+ }
473
+ const operators = filterOperatorsForFieldType(field.type);
474
+ if (!operators)
475
+ continue;
476
+ conditions.push({
477
+ type: 'object',
478
+ title: field.name,
479
+ description: `A condition on \`${field.name}\` (\`${field.type}\`).`,
480
+ required: ['kind', 'path', 'operator'],
481
+ properties: {
482
+ kind: { const: 'condition' },
483
+ path: {
484
+ type: 'array',
485
+ items: { const: field.name },
486
+ minItems: 1,
487
+ maxItems: 1,
488
+ },
489
+ operator: { type: 'string', enum: [...operators] },
490
+ value: {
491
+ anyOf: [
492
+ value,
493
+ { type: 'array', items: value },
494
+ { type: 'null' },
495
+ ref('RepositoryFilterVariable'),
496
+ ],
497
+ },
498
+ ...(field.type === 'json'
499
+ ? {
500
+ jsonPath: {
501
+ type: 'array',
502
+ items: {
503
+ anyOf: [{ type: 'string' }, { type: 'integer', minimum: 0 }],
504
+ },
505
+ },
506
+ }
507
+ : {}),
508
+ ...(['string', 'char', 'uuid', 'text'].includes(field.type)
509
+ ? { mode: { type: 'string', enum: ['default', 'insensitive'] } }
510
+ : {}),
511
+ },
512
+ additionalProperties: false,
513
+ });
514
+ }
515
+ schemas[`${prefix}FilterCondition`] = {
516
+ description: `A condition on a field of \`${descriptor.exposure}\`, on a field reached through to-one relations (\`RepositoryFilterCondition\`), or on related records (\`RepositoryFilterRelation\`).`,
517
+ anyOf: [
518
+ ...conditions,
519
+ ref('RepositoryFilterCondition'),
520
+ ref('RepositoryFilterRelation'),
521
+ ],
522
+ };
523
+ schemas[`${prefix}FilterGroup`] = {
524
+ type: 'object',
525
+ required: ['kind', 'logic', 'items'],
526
+ properties: {
527
+ kind: { const: 'group' },
528
+ logic: { type: 'string', enum: ['and', 'or'] },
529
+ items: {
530
+ type: 'array',
531
+ items: {
532
+ anyOf: [ref(`${prefix}FilterGroup`), ref(`${prefix}FilterCondition`)],
533
+ },
534
+ },
535
+ },
536
+ additionalProperties: false,
537
+ };
538
+ schemas[`${prefix}Filter`] = {
539
+ description: `A filter on \`${descriptor.exposure}\`: the shorthand over its fields, or a Filter AST. The grammar, the operators of each field type and the relation and JSON conditions are described in \`RepositoryFilter\`.${note}`,
540
+ anyOf: [
541
+ {
542
+ type: 'object',
543
+ title: 'Shorthand',
544
+ properties: shorthandProperties,
545
+ additionalProperties: false,
546
+ minProperties: 1,
547
+ },
548
+ {
549
+ type: 'object',
550
+ title: 'AST',
551
+ required: ['kind', 'version', 'root'],
552
+ properties: {
553
+ kind: { const: 'filter' },
554
+ version: { const: 1 },
555
+ collection: { const: collection.name ?? descriptor.collection },
556
+ root: ref(`${prefix}FilterGroup`),
557
+ },
558
+ additionalProperties: false,
559
+ },
560
+ ],
561
+ };
562
+ return {
563
+ record: ref(`${prefix}Record`),
564
+ createValues: values('create'),
565
+ updateValues: values('update'),
566
+ filter: ref(`${prefix}Filter`),
567
+ sortableFields: filterable
568
+ .filter((field) => isSortableFieldType(field.type))
569
+ .map((field) => field.name),
570
+ };
571
+ }
572
+ function data(schema) {
573
+ return { type: 'object', required: ['data'], properties: { data: schema } };
574
+ }
575
+ function jsonContent(schema) {
576
+ return { 'application/json': { schema } };
577
+ }
578
+ const errorRef = (name) => ({
579
+ $ref: `#/components/responses/${name}`,
580
+ });
581
+ function buildOperation(descriptor, exposure, base) {
582
+ const properties = {};
583
+ const required = [];
584
+ const action = descriptor.action;
585
+ const sortDescription = exposure.sortableFields.length
586
+ ? ` Sortable fields: ${exposure.sortableFields.map((name) => `\`${name}\``).join(', ')}.`
587
+ : '';
588
+ const option = {
589
+ filter: () => exposure.filter,
590
+ select: () => ref('RepositorySelect'),
591
+ sort: () => ({
592
+ allOf: [ref('RepositorySort')],
593
+ description: `The order of results.${sortDescription}`,
594
+ }),
595
+ distinct: () => ({
596
+ description: 'Fields whose combination keeps one representative row each, such as `["status"]`.',
597
+ }),
598
+ limit: () => ({
599
+ type: 'integer',
600
+ minimum: 0,
601
+ maximum: descriptor.maxLimit,
602
+ default: descriptor.maxLimit,
603
+ description: `How many records to return, at most ${descriptor.maxLimit}.`,
604
+ }),
605
+ offset: () => ({
606
+ type: 'integer',
607
+ minimum: 0,
608
+ description: 'How many records to skip. Exclusive with `cursor`.',
609
+ }),
610
+ cursor: () => ({
611
+ type: 'object',
612
+ additionalProperties: true,
613
+ description: 'The sort values of the record to continue after, one per sort field including the appended primary key, such as `{ "id": "42" }`. Requires an explicit `sort` on non-nullable fields; exclusive with `offset`.',
614
+ }),
615
+ direction: () => ({
616
+ type: 'string',
617
+ enum: ['forward', 'backward'],
618
+ description: 'Which side of `cursor` to read. `backward` still returns records in `sort` order.',
619
+ }),
620
+ values: () => (action === 'createOne'
621
+ ? exposure.createValues
622
+ : exposure.updateValues) ?? {
623
+ type: 'object',
624
+ },
625
+ ifVersion: () => ({
626
+ anyOf: [{ type: 'string' }, { type: 'integer' }],
627
+ description: 'Apply only if the record still has this optimistic-lock version; otherwise the request fails with 409 `VERSION_CONFLICT`.',
628
+ }),
629
+ aggregate: () => ({
630
+ type: 'object',
631
+ additionalProperties: true,
632
+ description: 'Named aggregates, such as `{ "total": { "sum": "amount" }, "orders": { "count": true } }`.',
633
+ }),
634
+ by: () => ({
635
+ type: 'array',
636
+ items: { type: 'string' },
637
+ minItems: 1,
638
+ description: 'The fields to group by.',
639
+ }),
640
+ having: () => ({
641
+ type: 'object',
642
+ additionalProperties: true,
643
+ description: 'A filter on the aggregates of each group.',
644
+ }),
645
+ };
646
+ const accepted = {
647
+ findMany: [
648
+ 'filter',
649
+ 'select',
650
+ 'sort',
651
+ 'distinct',
652
+ 'limit',
653
+ 'offset',
654
+ 'cursor',
655
+ 'direction',
656
+ ],
657
+ findOne: ['filter', 'select', 'sort'],
658
+ count: ['filter'],
659
+ aggregate: ['filter', 'aggregate'],
660
+ groupBy: ['by', 'filter', 'aggregate', 'having', 'sort'],
661
+ exists: ['filter'],
662
+ createOne: ['values', 'select'],
663
+ updateOne: ['filter', 'values', 'select', 'ifVersion'],
664
+ deleteOne: ['filter', 'select', 'ifVersion'],
665
+ };
666
+ for (const name of accepted[action])
667
+ properties[name] = option[name]();
668
+ if (['findOne', 'updateOne', 'deleteOne'].includes(action))
669
+ required.push('filter');
670
+ if (['createOne', 'updateOne'].includes(action))
671
+ required.push('values');
672
+ if (action === 'aggregate' || action === 'groupBy')
673
+ required.push('aggregate');
674
+ if (action === 'groupBy')
675
+ required.push('by');
676
+ const mutation = (record) => ({
677
+ type: 'object',
678
+ required: ['record', 'createdTargets'],
679
+ properties: {
680
+ record,
681
+ createdTargets: { type: 'array', items: ref('RepositoryCreatedTarget') },
682
+ version: { anyOf: [{ type: 'string' }, { type: 'integer' }] },
683
+ },
684
+ });
685
+ const results = {
686
+ findMany: { type: 'array', items: exposure.record },
687
+ findOne: { anyOf: [exposure.record, { type: 'null' }] },
688
+ count: { type: 'integer', minimum: 0 },
689
+ exists: { type: 'boolean' },
690
+ aggregate: {
691
+ type: 'object',
692
+ additionalProperties: true,
693
+ description: 'One value per named aggregate. Integers beyond the safe range are strings.',
694
+ },
695
+ groupBy: {
696
+ type: 'array',
697
+ items: { type: 'object', additionalProperties: true },
698
+ description: 'One row per group: the `by` fields and the named aggregates. Integers beyond the safe range are strings.',
699
+ },
700
+ createOne: mutation(exposure.record),
701
+ updateOne: mutation(exposure.record),
702
+ deleteOne: {
703
+ type: 'object',
704
+ required: ['deleted'],
705
+ properties: {
706
+ deleted: { const: true },
707
+ record: {
708
+ allOf: [exposure.record],
709
+ description: 'The deleted record, when `select` asks for it.',
710
+ },
711
+ },
712
+ },
713
+ };
714
+ const success = {
715
+ description: action === 'findMany'
716
+ ? 'The records. With `Accept: application/x-ndjson` the records stream instead, one JSON frame per line: `{"type":"record","data":{...}}` for each record, then `{"type":"end"}`, or `{"type":"error","error":{...}}` if the read fails after the stream has started. Errors detected before the first frame answer with the standard error body.'
717
+ : 'Success.',
718
+ content: {
719
+ ...jsonContent(data(results[action])),
720
+ ...(action === 'findMany'
721
+ ? {
722
+ 'application/x-ndjson': {
723
+ schema: {
724
+ type: 'object',
725
+ required: ['type'],
726
+ properties: {
727
+ type: { type: 'string', enum: ['record', 'end', 'error'] },
728
+ data: exposure.record,
729
+ error: ref('ApiErrorPayload'),
730
+ },
731
+ },
732
+ },
733
+ }
734
+ : {}),
735
+ },
736
+ };
737
+ return {
738
+ ...base,
739
+ description: `\`${descriptor.exposure}\` exposes the \`${descriptor.collection}\` Collection. The body accepts only the options listed; any other option is refused with 400 \`UNSUPPORTED_REPOSITORY_OPTION\`.`,
740
+ requestBody: {
741
+ required: true,
742
+ content: {
743
+ 'application/json': {
744
+ schema: {
745
+ type: 'object',
746
+ properties,
747
+ ...(required.length > 0 ? { required } : {}),
748
+ additionalProperties: false,
749
+ },
750
+ },
751
+ },
752
+ },
753
+ responses: {
754
+ '200': success,
755
+ '400': errorRef('BadRequest'),
756
+ '403': errorRef('PermissionDenied'),
757
+ ...(['findOne', 'updateOne', 'deleteOne'].includes(action)
758
+ ? { '404': errorRef('NotFound') }
759
+ : {}),
760
+ ...(action === 'updateOne' || action === 'deleteOne'
761
+ ? { '409': errorRef('Conflict') }
762
+ : {}),
763
+ '413': errorRef('PayloadTooLarge'),
764
+ '415': errorRef('UnsupportedMediaType'),
765
+ '500': errorRef('InternalError'),
766
+ },
767
+ };
768
+ }
769
+ const methods = ['get', 'put', 'post', 'delete', 'patch'];
770
+ /**
771
+ * Replace each data endpoint's placeholder declaration in `document` with its operation: per-field record, `values`
772
+ * and filter schemas read from the Collection, and the shared Repository components.
773
+ */
774
+ export async function expandRepositoryOperations(document) {
775
+ const pending = [];
776
+ for (const item of Object.values(document.paths ?? {})) {
777
+ if (!item)
778
+ continue;
779
+ for (const method of methods) {
780
+ const operation = item[method];
781
+ const descriptor = operation?.[repositoryExtension];
782
+ if (!operation || !descriptor)
783
+ continue;
784
+ pending.push({
785
+ operation,
786
+ descriptor,
787
+ assign: (built) => {
788
+ item[method] = built;
789
+ },
790
+ });
791
+ }
792
+ }
793
+ if (pending.length === 0)
794
+ return;
795
+ const components = (document.components ??= {});
796
+ const schemas = (components.schemas ??= {});
797
+ Object.assign(schemas, sharedRepositorySchemas());
798
+ const exposures = new Map();
799
+ for (const { operation, descriptor, assign } of pending) {
800
+ let exposure = exposures.get(descriptor.exposure);
801
+ if (!exposure) {
802
+ exposure = descriptor
803
+ .loadCollection()
804
+ .catch(() => undefined)
805
+ .then((collection) => buildExposureSchemas(descriptor, collection, schemas));
806
+ exposures.set(descriptor.exposure, exposure);
807
+ }
808
+ const { [repositoryExtension]: _descriptor, ...base } = operation;
809
+ assign(buildOperation(descriptor, await exposure, base));
810
+ }
811
+ }
812
+ //# sourceMappingURL=repository-document.js.map