@revealui/core 0.0.1-pre.4 → 0.2.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 (619) hide show
  1. package/LICENSE +22 -202
  2. package/README.md +29 -180
  3. package/dist/api/compression.d.ts +83 -0
  4. package/dist/api/compression.d.ts.map +1 -0
  5. package/dist/api/compression.js +233 -0
  6. package/dist/api/payload-optimization.d.ts +138 -0
  7. package/dist/api/payload-optimization.d.ts.map +1 -0
  8. package/dist/api/payload-optimization.js +320 -0
  9. package/dist/api/rate-limit.d.ts +113 -0
  10. package/dist/api/rate-limit.d.ts.map +1 -0
  11. package/dist/api/rate-limit.js +301 -0
  12. package/dist/api/response-cache.d.ts +125 -0
  13. package/dist/api/response-cache.d.ts.map +1 -0
  14. package/dist/api/response-cache.js +335 -0
  15. package/dist/api/rest.d.ts +54 -0
  16. package/dist/api/rest.d.ts.map +1 -0
  17. package/dist/api/rest.js +464 -0
  18. package/dist/auth/access.d.ts +25 -0
  19. package/dist/auth/access.d.ts.map +1 -0
  20. package/dist/auth/access.js +20 -0
  21. package/dist/auth/index.d.ts +2 -0
  22. package/dist/auth/index.d.ts.map +1 -0
  23. package/dist/auth/index.js +2 -0
  24. package/dist/cache/query-cache.d.ts +98 -0
  25. package/dist/cache/query-cache.d.ts.map +1 -0
  26. package/dist/cache/query-cache.js +260 -0
  27. package/dist/caching/app-cache.d.ts +237 -0
  28. package/dist/caching/app-cache.d.ts.map +1 -0
  29. package/dist/caching/app-cache.js +430 -0
  30. package/dist/caching/cdn-config.d.ts +155 -0
  31. package/dist/caching/cdn-config.d.ts.map +1 -0
  32. package/dist/caching/cdn-config.js +425 -0
  33. package/dist/caching/edge-cache.d.ts +177 -0
  34. package/dist/caching/edge-cache.d.ts.map +1 -0
  35. package/dist/caching/edge-cache.js +381 -0
  36. package/dist/caching/service-worker.d.ts +165 -0
  37. package/dist/caching/service-worker.d.ts.map +1 -0
  38. package/dist/caching/service-worker.js +437 -0
  39. package/dist/client/admin/RichText.d.ts +12 -0
  40. package/dist/client/admin/RichText.d.ts.map +1 -0
  41. package/dist/client/admin/RichText.js +5 -0
  42. package/dist/client/admin/components/AdminDashboard.d.ts +7 -0
  43. package/dist/client/admin/components/AdminDashboard.d.ts.map +1 -0
  44. package/dist/client/admin/components/AdminDashboard.js +318 -0
  45. package/dist/client/admin/components/CollectionList.d.ts +16 -0
  46. package/dist/client/admin/components/CollectionList.d.ts.map +1 -0
  47. package/dist/client/admin/components/CollectionList.js +67 -0
  48. package/dist/client/admin/components/DocumentForm.d.ts +11 -0
  49. package/dist/client/admin/components/DocumentForm.d.ts.map +1 -0
  50. package/dist/client/admin/components/DocumentForm.js +99 -0
  51. package/dist/client/admin/components/GlobalForm.d.ts +11 -0
  52. package/dist/client/admin/components/GlobalForm.d.ts.map +1 -0
  53. package/dist/client/admin/components/GlobalForm.js +74 -0
  54. package/dist/client/admin/i18n/en.d.ts +25 -0
  55. package/dist/client/admin/i18n/en.d.ts.map +1 -0
  56. package/dist/client/admin/i18n/en.js +25 -0
  57. package/dist/client/admin/index.d.ts +10 -0
  58. package/dist/client/admin/index.d.ts.map +1 -0
  59. package/dist/client/admin/index.js +10 -0
  60. package/dist/client/admin/layout.d.ts +10 -0
  61. package/dist/client/admin/layout.d.ts.map +1 -0
  62. package/dist/client/admin/layout.js +6 -0
  63. package/dist/client/admin/page.d.ts +38 -0
  64. package/dist/client/admin/page.d.ts.map +1 -0
  65. package/dist/client/admin/page.js +15 -0
  66. package/dist/client/admin/utils/apiClient.d.ts +110 -0
  67. package/dist/client/admin/utils/apiClient.d.ts.map +1 -0
  68. package/dist/client/admin/utils/apiClient.js +220 -0
  69. package/dist/client/admin/utils/auth.d.ts +27 -0
  70. package/dist/client/admin/utils/auth.d.ts.map +1 -0
  71. package/dist/client/admin/utils/auth.js +58 -0
  72. package/dist/client/admin/utils/index.d.ts +6 -0
  73. package/dist/client/admin/utils/index.d.ts.map +1 -0
  74. package/dist/client/admin/utils/index.js +5 -0
  75. package/dist/client/admin/utils/serializeConfig.d.ts +7 -0
  76. package/dist/client/admin/utils/serializeConfig.d.ts.map +1 -0
  77. package/dist/client/admin/utils/serializeConfig.js +35 -0
  78. package/dist/client/hooks.d.ts +18 -0
  79. package/dist/client/hooks.d.ts.map +1 -0
  80. package/dist/client/hooks.js +29 -0
  81. package/dist/client/http/client.d.ts +15 -0
  82. package/dist/client/http/client.d.ts.map +1 -0
  83. package/dist/client/http/client.js +49 -0
  84. package/dist/client/http/fetchBanner.d.ts +18 -0
  85. package/dist/client/http/fetchBanner.d.ts.map +1 -0
  86. package/dist/client/http/fetchBanner.js +44 -0
  87. package/dist/client/http/fetchCard.d.ts +18 -0
  88. package/dist/client/http/fetchCard.d.ts.map +1 -0
  89. package/dist/client/http/fetchCard.js +46 -0
  90. package/dist/client/http/fetchEvents.d.ts +18 -0
  91. package/dist/client/http/fetchEvents.d.ts.map +1 -0
  92. package/dist/client/http/fetchEvents.js +44 -0
  93. package/dist/client/http/fetchHero.d.ts +17 -0
  94. package/dist/client/http/fetchHero.d.ts.map +1 -0
  95. package/dist/client/http/fetchHero.js +55 -0
  96. package/dist/client/http/fetchMainInfos.d.ts +17 -0
  97. package/dist/client/http/fetchMainInfos.d.ts.map +1 -0
  98. package/dist/client/http/fetchMainInfos.js +44 -0
  99. package/dist/client/http/fetchVideos.d.ts +13 -0
  100. package/dist/client/http/fetchVideos.d.ts.map +1 -0
  101. package/dist/client/http/fetchVideos.js +36 -0
  102. package/dist/client/http/index.d.ts +19 -0
  103. package/dist/client/http/index.d.ts.map +1 -0
  104. package/dist/client/http/index.js +11 -0
  105. package/dist/client/index.d.ts +12 -0
  106. package/dist/client/index.d.ts.map +1 -0
  107. package/dist/client/index.js +15 -0
  108. package/dist/client/richtext/RichTextEditor.d.ts +48 -0
  109. package/dist/client/richtext/RichTextEditor.d.ts.map +1 -0
  110. package/dist/client/richtext/RichTextEditor.js +360 -0
  111. package/dist/client/richtext/components/ImageNodeComponent.d.ts +9 -0
  112. package/dist/client/richtext/components/ImageNodeComponent.d.ts.map +1 -0
  113. package/dist/client/richtext/components/ImageNodeComponent.js +99 -0
  114. package/dist/client/richtext/components/ImageUploadButton.d.ts +11 -0
  115. package/dist/client/richtext/components/ImageUploadButton.d.ts.map +1 -0
  116. package/dist/client/richtext/components/ImageUploadButton.js +103 -0
  117. package/dist/client/richtext/index.d.ts +92 -0
  118. package/dist/client/richtext/index.d.ts.map +1 -0
  119. package/dist/client/richtext/index.js +74 -0
  120. package/dist/client/richtext/nodes/DecoratorBlockNode.d.ts +20 -0
  121. package/dist/client/richtext/nodes/DecoratorBlockNode.d.ts.map +1 -0
  122. package/dist/client/richtext/nodes/DecoratorBlockNode.js +29 -0
  123. package/dist/client/richtext/nodes/ImageNode.d.ts +51 -0
  124. package/dist/client/richtext/nodes/ImageNode.d.ts.map +1 -0
  125. package/dist/client/richtext/nodes/ImageNode.js +95 -0
  126. package/dist/client/richtext/plugins/CollaborationPlugin.d.ts +13 -0
  127. package/dist/client/richtext/plugins/CollaborationPlugin.d.ts.map +1 -0
  128. package/dist/client/richtext/plugins/CollaborationPlugin.js +8 -0
  129. package/dist/client/richtext/plugins/CursorsOverlayPlugin.d.ts +4 -0
  130. package/dist/client/richtext/plugins/CursorsOverlayPlugin.d.ts.map +1 -0
  131. package/dist/client/richtext/plugins/CursorsOverlayPlugin.js +50 -0
  132. package/dist/client/richtext/plugins/FloatingToolbarPlugin.d.ts +7 -0
  133. package/dist/client/richtext/plugins/FloatingToolbarPlugin.d.ts.map +1 -0
  134. package/dist/client/richtext/plugins/FloatingToolbarPlugin.js +248 -0
  135. package/dist/client/richtext/plugins/ImagePlugin.d.ts +3 -0
  136. package/dist/client/richtext/plugins/ImagePlugin.d.ts.map +1 -0
  137. package/dist/client/richtext/plugins/ImagePlugin.js +73 -0
  138. package/dist/client/richtext/plugins/PastePlugin.d.ts +2 -0
  139. package/dist/client/richtext/plugins/PastePlugin.d.ts.map +1 -0
  140. package/dist/client/richtext/plugins/PastePlugin.js +36 -0
  141. package/dist/client/richtext/plugins/ToolbarPlugin.d.ts +8 -0
  142. package/dist/client/richtext/plugins/ToolbarPlugin.d.ts.map +1 -0
  143. package/dist/client/richtext/plugins/ToolbarPlugin.js +204 -0
  144. package/dist/client/ui/index.d.ts +111 -0
  145. package/dist/client/ui/index.d.ts.map +1 -0
  146. package/dist/client/ui/index.js +130 -0
  147. package/dist/collections/CollectionOperations.d.ts +27 -0
  148. package/dist/collections/CollectionOperations.d.ts.map +1 -0
  149. package/dist/collections/CollectionOperations.js +34 -0
  150. package/dist/collections/hooks.d.ts +11 -0
  151. package/dist/collections/hooks.d.ts.map +1 -0
  152. package/dist/collections/hooks.js +35 -0
  153. package/dist/collections/index.d.ts +2 -0
  154. package/dist/collections/index.d.ts.map +1 -0
  155. package/dist/collections/index.js +1 -0
  156. package/dist/collections/operations/create.d.ts +10 -0
  157. package/dist/collections/operations/create.d.ts.map +1 -0
  158. package/dist/collections/operations/create.js +101 -0
  159. package/dist/collections/operations/delete.d.ts +10 -0
  160. package/dist/collections/operations/delete.d.ts.map +1 -0
  161. package/dist/collections/operations/delete.js +16 -0
  162. package/dist/collections/operations/fieldHooks.d.ts +21 -0
  163. package/dist/collections/operations/fieldHooks.d.ts.map +1 -0
  164. package/dist/collections/operations/fieldHooks.js +51 -0
  165. package/dist/collections/operations/find.d.ts +10 -0
  166. package/dist/collections/operations/find.d.ts.map +1 -0
  167. package/dist/collections/operations/find.js +124 -0
  168. package/dist/collections/operations/findById.d.ts +15 -0
  169. package/dist/collections/operations/findById.d.ts.map +1 -0
  170. package/dist/collections/operations/findById.js +59 -0
  171. package/dist/collections/operations/update.d.ts +10 -0
  172. package/dist/collections/operations/update.d.ts.map +1 -0
  173. package/dist/collections/operations/update.js +134 -0
  174. package/dist/config/index.d.ts +9 -0
  175. package/dist/config/index.d.ts.map +1 -0
  176. package/dist/config/index.js +61 -0
  177. package/dist/config/runtime.d.ts +22 -0
  178. package/dist/config/runtime.d.ts.map +1 -0
  179. package/dist/config/runtime.js +32 -0
  180. package/dist/config/utils.d.ts +12 -0
  181. package/dist/config/utils.d.ts.map +1 -0
  182. package/dist/config/utils.js +20 -0
  183. package/dist/database/index.d.ts +1 -0
  184. package/dist/database/index.d.ts.map +1 -0
  185. package/dist/database/index.js +6 -0
  186. package/dist/database/ssl-config.d.ts +9 -0
  187. package/dist/database/ssl-config.d.ts.map +1 -0
  188. package/dist/database/ssl-config.js +7 -0
  189. package/dist/database/type-adapter.d.ts +113 -0
  190. package/dist/database/type-adapter.d.ts.map +1 -0
  191. package/dist/database/type-adapter.js +97 -0
  192. package/dist/database/universal-postgres.d.ts +45 -0
  193. package/dist/database/universal-postgres.d.ts.map +1 -0
  194. package/dist/database/universal-postgres.js +526 -0
  195. package/dist/dataloader.d.ts +26 -0
  196. package/dist/dataloader.d.ts.map +1 -0
  197. package/dist/dataloader.js +162 -0
  198. package/dist/error-handling/circuit-breaker.d.ts +262 -0
  199. package/dist/error-handling/circuit-breaker.d.ts.map +1 -0
  200. package/dist/error-handling/circuit-breaker.js +542 -0
  201. package/dist/error-handling/error-boundary.d.ts +94 -0
  202. package/dist/error-handling/error-boundary.d.ts.map +1 -0
  203. package/dist/error-handling/error-boundary.js +285 -0
  204. package/dist/error-handling/error-reporter.d.ts +213 -0
  205. package/dist/error-handling/error-reporter.d.ts.map +1 -0
  206. package/dist/error-handling/error-reporter.js +506 -0
  207. package/dist/error-handling/fallback-components.d.ts +131 -0
  208. package/dist/error-handling/fallback-components.d.ts.map +1 -0
  209. package/dist/error-handling/fallback-components.js +371 -0
  210. package/dist/error-handling/index.d.ts +16 -0
  211. package/dist/error-handling/index.d.ts.map +1 -0
  212. package/dist/error-handling/index.js +15 -0
  213. package/dist/error-handling/retry.d.ts +194 -0
  214. package/dist/error-handling/retry.d.ts.map +1 -0
  215. package/dist/error-handling/retry.js +450 -0
  216. package/dist/errors/index.d.ts +23 -0
  217. package/dist/errors/index.d.ts.map +1 -0
  218. package/dist/errors/index.js +40 -0
  219. package/dist/factories/builders.d.ts +50 -0
  220. package/dist/factories/builders.d.ts.map +1 -0
  221. package/dist/factories/builders.js +77 -0
  222. package/dist/factories/index.d.ts +2 -0
  223. package/dist/factories/index.d.ts.map +1 -0
  224. package/dist/factories/index.js +1 -0
  225. package/dist/features.d.ts +82 -0
  226. package/dist/features.d.ts.map +1 -0
  227. package/dist/features.js +89 -0
  228. package/dist/fieldTraversal.d.ts +26 -0
  229. package/dist/fieldTraversal.d.ts.map +1 -0
  230. package/dist/fieldTraversal.js +132 -0
  231. package/dist/fields/config/types.d.ts +48 -0
  232. package/dist/fields/config/types.d.ts.map +1 -0
  233. package/dist/fields/config/types.js +20 -0
  234. package/dist/fields/getDefaultValue.d.ts +16 -0
  235. package/dist/fields/getDefaultValue.d.ts.map +1 -0
  236. package/dist/fields/getDefaultValue.js +20 -0
  237. package/dist/fields/getFieldPaths.d.ts +25 -0
  238. package/dist/fields/getFieldPaths.d.ts.map +1 -0
  239. package/dist/fields/getFieldPaths.js +23 -0
  240. package/dist/fields/hooks/afterRead/index.d.ts +36 -0
  241. package/dist/fields/hooks/afterRead/index.d.ts.map +1 -0
  242. package/dist/fields/hooks/afterRead/index.js +70 -0
  243. package/dist/fields/hooks/afterRead/promise.d.ts +46 -0
  244. package/dist/fields/hooks/afterRead/promise.d.ts.map +1 -0
  245. package/dist/fields/hooks/afterRead/promise.js +178 -0
  246. package/dist/fields/hooks/afterRead/traverseFields.d.ts +44 -0
  247. package/dist/fields/hooks/afterRead/traverseFields.d.ts.map +1 -0
  248. package/dist/fields/hooks/afterRead/traverseFields.js +37 -0
  249. package/dist/generated/agents/index.d.ts +8 -0
  250. package/dist/generated/agents/index.d.ts.map +1 -0
  251. package/dist/generated/agents/index.js +7 -0
  252. package/dist/generated/components/index.d.ts +8 -0
  253. package/dist/generated/components/index.d.ts.map +1 -0
  254. package/dist/generated/components/index.js +7 -0
  255. package/dist/generated/functions/index.d.ts +8 -0
  256. package/dist/generated/functions/index.d.ts.map +1 -0
  257. package/dist/generated/functions/index.js +7 -0
  258. package/dist/generated/hooks/index.d.ts +8 -0
  259. package/dist/generated/hooks/index.d.ts.map +1 -0
  260. package/dist/generated/hooks/index.js +7 -0
  261. package/dist/generated/index.d.ts +10 -0
  262. package/dist/generated/index.d.ts.map +1 -0
  263. package/dist/generated/index.js +9 -0
  264. package/dist/generated/plans/index.d.ts +8 -0
  265. package/dist/generated/plans/index.d.ts.map +1 -0
  266. package/dist/generated/plans/index.js +7 -0
  267. package/dist/generated/prompts/index.d.ts +8 -0
  268. package/dist/generated/prompts/index.d.ts.map +1 -0
  269. package/dist/generated/prompts/index.js +7 -0
  270. package/dist/generated/tools/index.d.ts +8 -0
  271. package/dist/generated/tools/index.d.ts.map +1 -0
  272. package/dist/generated/tools/index.js +7 -0
  273. package/dist/generated/types/cms.d.ts +1766 -0
  274. package/dist/generated/types/cms.d.ts.map +1 -0
  275. package/dist/generated/types/cms.js +12 -0
  276. package/dist/generated/types/index.d.ts +19 -0
  277. package/dist/generated/types/index.d.ts.map +1 -0
  278. package/dist/generated/types/index.js +28 -0
  279. package/dist/generated/types/neon.d.ts +11 -0
  280. package/dist/generated/types/neon.d.ts.map +1 -0
  281. package/dist/generated/types/neon.js +11 -0
  282. package/dist/generated/types/supabase.d.ts +193 -0
  283. package/dist/generated/types/supabase.d.ts.map +1 -0
  284. package/dist/generated/types/supabase.js +5 -0
  285. package/dist/globals/GlobalOperations.d.ts +24 -0
  286. package/dist/globals/GlobalOperations.d.ts.map +1 -0
  287. package/dist/globals/GlobalOperations.js +149 -0
  288. package/dist/globals/index.d.ts +2 -0
  289. package/dist/globals/index.d.ts.map +1 -0
  290. package/dist/globals/index.js +1 -0
  291. package/dist/index.d.ts +64 -1
  292. package/dist/index.d.ts.map +1 -0
  293. package/dist/index.js +128 -33
  294. package/dist/instance/RevealUIInstance.d.ts +6 -0
  295. package/dist/instance/RevealUIInstance.d.ts.map +1 -0
  296. package/dist/instance/RevealUIInstance.js +312 -0
  297. package/dist/instance/index.d.ts +3 -0
  298. package/dist/instance/index.d.ts.map +1 -0
  299. package/dist/instance/index.js +2 -0
  300. package/dist/instance/logger.d.ts +31 -0
  301. package/dist/instance/logger.d.ts.map +1 -0
  302. package/dist/instance/logger.js +42 -0
  303. package/dist/instance/methods/create.d.ts +10 -0
  304. package/dist/instance/methods/create.d.ts.map +1 -0
  305. package/dist/instance/methods/create.js +38 -0
  306. package/dist/instance/methods/delete.d.ts +10 -0
  307. package/dist/instance/methods/delete.d.ts.map +1 -0
  308. package/dist/instance/methods/delete.js +24 -0
  309. package/dist/instance/methods/find.d.ts +10 -0
  310. package/dist/instance/methods/find.d.ts.map +1 -0
  311. package/dist/instance/methods/find.js +23 -0
  312. package/dist/instance/methods/findById.d.ts +13 -0
  313. package/dist/instance/methods/findById.d.ts.map +1 -0
  314. package/dist/instance/methods/findById.js +23 -0
  315. package/dist/instance/methods/hooks.d.ts +14 -0
  316. package/dist/instance/methods/hooks.d.ts.map +1 -0
  317. package/dist/instance/methods/hooks.js +32 -0
  318. package/dist/instance/methods/update.d.ts +10 -0
  319. package/dist/instance/methods/update.d.ts.map +1 -0
  320. package/dist/instance/methods/update.js +42 -0
  321. package/dist/license.d.ts +73 -0
  322. package/dist/license.d.ts.map +1 -0
  323. package/dist/license.js +157 -0
  324. package/dist/monitoring/alerts.d.ts +118 -0
  325. package/dist/monitoring/alerts.d.ts.map +1 -0
  326. package/dist/monitoring/alerts.js +324 -0
  327. package/dist/monitoring/cleanup-manager.d.ts +71 -0
  328. package/dist/monitoring/cleanup-manager.d.ts.map +1 -0
  329. package/dist/monitoring/cleanup-manager.js +226 -0
  330. package/dist/monitoring/health-monitor.d.ts +22 -0
  331. package/dist/monitoring/health-monitor.d.ts.map +1 -0
  332. package/dist/monitoring/health-monitor.js +142 -0
  333. package/dist/monitoring/index.d.ts +14 -0
  334. package/dist/monitoring/index.d.ts.map +1 -0
  335. package/dist/monitoring/index.js +17 -0
  336. package/dist/monitoring/process-registry.d.ts +97 -0
  337. package/dist/monitoring/process-registry.d.ts.map +1 -0
  338. package/dist/monitoring/process-registry.js +222 -0
  339. package/dist/monitoring/query-monitor.d.ts +153 -0
  340. package/dist/monitoring/query-monitor.d.ts.map +1 -0
  341. package/dist/monitoring/query-monitor.js +209 -0
  342. package/dist/monitoring/types.d.ts +231 -0
  343. package/dist/monitoring/types.d.ts.map +1 -0
  344. package/dist/monitoring/types.js +42 -0
  345. package/dist/monitoring/zombie-detector.d.ts +81 -0
  346. package/dist/monitoring/zombie-detector.d.ts.map +1 -0
  347. package/dist/monitoring/zombie-detector.js +231 -0
  348. package/dist/nextjs/index.d.ts +4 -0
  349. package/dist/nextjs/index.d.ts.map +1 -0
  350. package/dist/nextjs/index.js +3 -0
  351. package/dist/nextjs/utilities.d.ts +5 -0
  352. package/dist/nextjs/utilities.d.ts.map +1 -0
  353. package/dist/nextjs/utilities.js +16 -0
  354. package/dist/nextjs/withRevealUI.d.ts +20 -0
  355. package/dist/nextjs/withRevealUI.d.ts.map +1 -0
  356. package/dist/nextjs/withRevealUI.js +181 -0
  357. package/dist/observability/alerts.d.ts +138 -0
  358. package/dist/observability/alerts.d.ts.map +1 -0
  359. package/dist/observability/alerts.js +390 -0
  360. package/dist/observability/health-check.d.ts +95 -0
  361. package/dist/observability/health-check.d.ts.map +1 -0
  362. package/dist/observability/health-check.js +345 -0
  363. package/dist/observability/index.d.ts +12 -0
  364. package/dist/observability/index.d.ts.map +1 -0
  365. package/dist/observability/index.js +11 -0
  366. package/dist/observability/logger.d.ts +47 -0
  367. package/dist/observability/logger.d.ts.map +1 -0
  368. package/dist/observability/logger.js +140 -0
  369. package/dist/observability/metrics.d.ts +205 -0
  370. package/dist/observability/metrics.d.ts.map +1 -0
  371. package/dist/observability/metrics.js +429 -0
  372. package/dist/observability/tracing.d.ts +149 -0
  373. package/dist/observability/tracing.d.ts.map +1 -0
  374. package/dist/observability/tracing.js +381 -0
  375. package/dist/optimization/asset-optimizer.d.ts +202 -0
  376. package/dist/optimization/asset-optimizer.d.ts.map +1 -0
  377. package/dist/optimization/asset-optimizer.js +312 -0
  378. package/dist/optimization/build-optimizer.d.ts +202 -0
  379. package/dist/optimization/build-optimizer.d.ts.map +1 -0
  380. package/dist/optimization/build-optimizer.js +271 -0
  381. package/dist/optimization/bundle-analyzer.d.ts +98 -0
  382. package/dist/optimization/bundle-analyzer.d.ts.map +1 -0
  383. package/dist/optimization/bundle-analyzer.js +322 -0
  384. package/dist/optimization/code-splitting.d.ts +144 -0
  385. package/dist/optimization/code-splitting.d.ts.map +1 -0
  386. package/dist/optimization/code-splitting.js +290 -0
  387. package/dist/plugin/index.d.ts +12 -0
  388. package/dist/plugin/index.d.ts.map +1 -0
  389. package/dist/plugin/index.js +4 -0
  390. package/dist/plugins/form-builder.d.ts +115 -0
  391. package/dist/plugins/form-builder.d.ts.map +1 -0
  392. package/dist/plugins/form-builder.js +239 -0
  393. package/dist/plugins/index.d.ts +5 -0
  394. package/dist/plugins/index.d.ts.map +1 -0
  395. package/dist/plugins/index.js +4 -0
  396. package/dist/plugins/nested-docs.d.ts +8 -0
  397. package/dist/plugins/nested-docs.d.ts.map +1 -0
  398. package/dist/plugins/nested-docs.js +67 -0
  399. package/dist/plugins/redirects.d.ts +17 -0
  400. package/dist/plugins/redirects.d.ts.map +1 -0
  401. package/dist/plugins/redirects.js +62 -0
  402. package/dist/queries/index.d.ts +2 -0
  403. package/dist/queries/index.d.ts.map +1 -0
  404. package/dist/queries/index.js +1 -0
  405. package/dist/queries/queryBuilder.d.ts +47 -0
  406. package/dist/queries/queryBuilder.d.ts.map +1 -0
  407. package/dist/queries/queryBuilder.js +252 -0
  408. package/dist/relationships/analyzer.d.ts +39 -0
  409. package/dist/relationships/analyzer.d.ts.map +1 -0
  410. package/dist/relationships/analyzer.js +127 -0
  411. package/dist/relationships/index.d.ts +3 -0
  412. package/dist/relationships/index.d.ts.map +1 -0
  413. package/dist/relationships/index.js +2 -0
  414. package/dist/relationships/populate-helpers.d.ts +104 -0
  415. package/dist/relationships/populate-helpers.d.ts.map +1 -0
  416. package/dist/relationships/populate-helpers.js +187 -0
  417. package/dist/relationships/population.d.ts +42 -0
  418. package/dist/relationships/population.d.ts.map +1 -0
  419. package/dist/relationships/population.js +188 -0
  420. package/dist/revealui.d.ts +46 -0
  421. package/dist/revealui.d.ts.map +1 -0
  422. package/dist/revealui.js +92 -0
  423. package/dist/richtext/exports/client/rcc.d.ts +37 -0
  424. package/dist/richtext/exports/client/rcc.d.ts.map +1 -0
  425. package/dist/richtext/exports/client/rcc.js +182 -0
  426. package/dist/richtext/exports/server/rsc.d.ts +117 -0
  427. package/dist/richtext/exports/server/rsc.d.ts.map +1 -0
  428. package/dist/richtext/exports/server/rsc.js +288 -0
  429. package/dist/richtext/index.d.ts +161 -0
  430. package/dist/richtext/index.d.ts.map +1 -0
  431. package/dist/richtext/index.js +243 -0
  432. package/dist/richtext/lexical.d.ts +23 -0
  433. package/dist/richtext/lexical.d.ts.map +1 -0
  434. package/dist/richtext/lexical.js +35 -0
  435. package/dist/security/audit.d.ts +188 -0
  436. package/dist/security/audit.d.ts.map +1 -0
  437. package/dist/security/audit.js +431 -0
  438. package/dist/security/auth.d.ts +241 -0
  439. package/dist/security/auth.d.ts.map +1 -0
  440. package/dist/security/auth.js +474 -0
  441. package/dist/security/authorization.d.ts +235 -0
  442. package/dist/security/authorization.d.ts.map +1 -0
  443. package/dist/security/authorization.js +434 -0
  444. package/dist/security/encryption.d.ts +214 -0
  445. package/dist/security/encryption.d.ts.map +1 -0
  446. package/dist/security/encryption.js +506 -0
  447. package/dist/security/gdpr.d.ts +300 -0
  448. package/dist/security/gdpr.d.ts.map +1 -0
  449. package/dist/security/gdpr.js +470 -0
  450. package/dist/security/headers.d.ts +182 -0
  451. package/dist/security/headers.d.ts.map +1 -0
  452. package/dist/security/headers.js +402 -0
  453. package/dist/security/index.d.ts +19 -0
  454. package/dist/security/index.d.ts.map +1 -0
  455. package/dist/security/index.js +18 -0
  456. package/dist/server/index.d.ts +21 -0
  457. package/dist/server/index.d.ts.map +1 -0
  458. package/dist/server/index.js +28 -0
  459. package/dist/server/renderPage.d.ts +69 -0
  460. package/dist/server/renderPage.d.ts.map +1 -0
  461. package/dist/server/renderPage.js +109 -0
  462. package/dist/storage/index.d.ts +1 -0
  463. package/dist/storage/index.d.ts.map +1 -0
  464. package/dist/storage/index.js +4 -0
  465. package/dist/storage/vercel-blob.d.ts +17 -0
  466. package/dist/storage/vercel-blob.d.ts.map +1 -0
  467. package/dist/storage/vercel-blob.js +83 -0
  468. package/dist/translations/index.d.ts +17 -0
  469. package/dist/translations/index.d.ts.map +1 -0
  470. package/dist/translations/index.js +1 -0
  471. package/dist/types/access.d.ts +67 -0
  472. package/dist/types/access.d.ts.map +1 -0
  473. package/dist/types/access.js +8 -0
  474. package/dist/types/api.d.ts +57 -0
  475. package/dist/types/api.d.ts.map +1 -0
  476. package/dist/types/api.js +8 -0
  477. package/dist/types/cms.d.ts +8 -0
  478. package/dist/types/cms.d.ts.map +1 -0
  479. package/dist/types/cms.js +6 -0
  480. package/dist/types/config.d.ts +152 -0
  481. package/dist/types/config.d.ts.map +1 -0
  482. package/dist/types/config.js +9 -0
  483. package/dist/types/core.d.ts +11 -0
  484. package/dist/types/core.d.ts.map +1 -0
  485. package/dist/types/core.js +9 -0
  486. package/dist/types/extensions.d.ts +116 -0
  487. package/dist/types/extensions.d.ts.map +1 -0
  488. package/dist/types/extensions.js +8 -0
  489. package/dist/types/frontend.d.ts +53 -0
  490. package/dist/types/frontend.d.ts.map +1 -0
  491. package/dist/types/frontend.js +7 -0
  492. package/dist/types/generated.d.ts +14 -0
  493. package/dist/types/generated.d.ts.map +1 -0
  494. package/dist/types/generated.js +11 -0
  495. package/dist/types/hooks.d.ts +53 -0
  496. package/dist/types/hooks.d.ts.map +1 -0
  497. package/dist/types/hooks.js +8 -0
  498. package/dist/types/index.d.ts +49 -0
  499. package/dist/types/index.d.ts.map +1 -0
  500. package/dist/types/index.js +61 -0
  501. package/dist/types/interfaces/app.d.ts +50 -0
  502. package/dist/types/interfaces/app.d.ts.map +1 -0
  503. package/dist/types/interfaces/app.js +5 -0
  504. package/dist/types/jobs.d.ts +112 -0
  505. package/dist/types/jobs.d.ts.map +1 -0
  506. package/dist/types/jobs.js +7 -0
  507. package/dist/types/legacy.d.ts +147 -0
  508. package/dist/types/legacy.d.ts.map +1 -0
  509. package/dist/types/legacy.js +8 -0
  510. package/dist/types/plugins.d.ts +17 -0
  511. package/dist/types/plugins.d.ts.map +1 -0
  512. package/dist/types/plugins.js +8 -0
  513. package/dist/types/query.d.ts +99 -0
  514. package/dist/types/query.d.ts.map +1 -0
  515. package/dist/types/query.js +24 -0
  516. package/dist/types/request.d.ts +40 -0
  517. package/dist/types/request.d.ts.map +1 -0
  518. package/dist/types/request.js +8 -0
  519. package/dist/types/richtext.d.ts +23 -0
  520. package/dist/types/richtext.d.ts.map +1 -0
  521. package/dist/types/richtext.js +8 -0
  522. package/dist/types/runtime.d.ts +216 -0
  523. package/dist/types/runtime.d.ts.map +1 -0
  524. package/dist/types/runtime.js +9 -0
  525. package/dist/types/schema.d.ts +9 -0
  526. package/dist/types/schema.d.ts.map +1 -0
  527. package/dist/types/schema.js +7 -0
  528. package/dist/types/user.d.ts +48 -0
  529. package/dist/types/user.d.ts.map +1 -0
  530. package/dist/types/user.js +8 -0
  531. package/dist/utils/access-conversion.d.ts +17 -0
  532. package/dist/utils/access-conversion.d.ts.map +1 -0
  533. package/dist/utils/access-conversion.js +96 -0
  534. package/dist/utils/api-wrapper.d.ts +63 -0
  535. package/dist/utils/api-wrapper.d.ts.map +1 -0
  536. package/dist/utils/api-wrapper.js +151 -0
  537. package/dist/utils/block-conversion.d.ts +21 -0
  538. package/dist/utils/block-conversion.d.ts.map +1 -0
  539. package/dist/utils/block-conversion.js +109 -0
  540. package/dist/utils/cache.d.ts +86 -0
  541. package/dist/utils/cache.d.ts.map +1 -0
  542. package/dist/utils/cache.js +154 -0
  543. package/dist/utils/deep-clone.d.ts +25 -0
  544. package/dist/utils/deep-clone.d.ts.map +1 -0
  545. package/dist/utils/deep-clone.js +115 -0
  546. package/dist/utils/error-responses.d.ts +57 -0
  547. package/dist/utils/error-responses.d.ts.map +1 -0
  548. package/dist/utils/error-responses.js +96 -0
  549. package/dist/utils/errors.d.ts +97 -0
  550. package/dist/utils/errors.d.ts.map +1 -0
  551. package/dist/utils/errors.js +397 -0
  552. package/dist/utils/field-conversion.d.ts +40 -0
  553. package/dist/utils/field-conversion.d.ts.map +1 -0
  554. package/dist/utils/field-conversion.js +275 -0
  555. package/dist/utils/flattenResult.d.ts +7 -0
  556. package/dist/utils/flattenResult.d.ts.map +1 -0
  557. package/dist/utils/flattenResult.js +23 -0
  558. package/dist/utils/getBlockSelect.d.ts +12 -0
  559. package/dist/utils/getBlockSelect.d.ts.map +1 -0
  560. package/dist/utils/getBlockSelect.js +12 -0
  561. package/dist/utils/getSelectMode.d.ts +8 -0
  562. package/dist/utils/getSelectMode.d.ts.map +1 -0
  563. package/dist/utils/getSelectMode.js +21 -0
  564. package/dist/utils/isValidID.d.ts +5 -0
  565. package/dist/utils/isValidID.d.ts.map +1 -0
  566. package/dist/utils/isValidID.js +13 -0
  567. package/dist/utils/json-parsing.d.ts +48 -0
  568. package/dist/utils/json-parsing.d.ts.map +1 -0
  569. package/dist/utils/json-parsing.js +130 -0
  570. package/dist/utils/jwt-validation.d.ts +14 -0
  571. package/dist/utils/jwt-validation.d.ts.map +1 -0
  572. package/dist/utils/jwt-validation.js +36 -0
  573. package/dist/utils/logger-client.d.ts +32 -0
  574. package/dist/utils/logger-client.d.ts.map +1 -0
  575. package/dist/utils/logger-client.js +55 -0
  576. package/dist/utils/logger-server.d.ts +32 -0
  577. package/dist/utils/logger-server.d.ts.map +1 -0
  578. package/dist/utils/logger-server.js +68 -0
  579. package/dist/utils/logger.d.ts +14 -0
  580. package/dist/utils/logger.d.ts.map +1 -0
  581. package/dist/utils/logger.js +12 -0
  582. package/dist/utils/request-context.d.ts +143 -0
  583. package/dist/utils/request-context.d.ts.map +1 -0
  584. package/dist/utils/request-context.js +168 -0
  585. package/dist/utils/request-headers.d.ts +15 -0
  586. package/dist/utils/request-headers.d.ts.map +1 -0
  587. package/dist/utils/request-headers.js +31 -0
  588. package/dist/utils/stripUnselectedFields.d.ts +10 -0
  589. package/dist/utils/stripUnselectedFields.d.ts.map +1 -0
  590. package/dist/utils/stripUnselectedFields.js +20 -0
  591. package/dist/utils/type-guards.d.ts +33 -0
  592. package/dist/utils/type-guards.d.ts.map +1 -0
  593. package/dist/utils/type-guards.js +63 -0
  594. package/dist/utils/user.d.ts +14 -0
  595. package/dist/utils/user.d.ts.map +1 -0
  596. package/dist/utils/user.js +15 -0
  597. package/package.json +250 -724
  598. package/LICENSE_SUMMARY.md +0 -55
  599. package/NOTICE +0 -34
  600. package/dist/exports/RenderErrorPage.js +0 -3
  601. package/dist/exports/__internal.js +0 -3
  602. package/dist/exports/abort.js +0 -3
  603. package/dist/exports/bin-entry.js +0 -5
  604. package/dist/exports/client.js +0 -3
  605. package/dist/exports/config.js +0 -1
  606. package/dist/exports/helpers.js +0 -1
  607. package/dist/exports/index.js +0 -33
  608. package/dist/exports/plugin.js +0 -3
  609. package/dist/exports/prerender.js +0 -3
  610. package/dist/exports/router.js +0 -3
  611. package/dist/exports/routing.js +0 -3
  612. package/dist/exports/server.js +0 -3
  613. package/dist/exports/setup.js +0 -3
  614. package/dist/exports/types.js +0 -1
  615. package/dist/integration/styles.css +0 -141
  616. package/dist/shared/RenderErrorPage.d.ts +0 -3
  617. package/dist/shared/RenderErrorPage.js +0 -3
  618. package/dist/shared/abort.js +0 -3
  619. package/dist/shared/route/routing.js +0 -3
@@ -0,0 +1,233 @@
1
+ /**
2
+ * API Response Compression Middleware
3
+ *
4
+ * Implements gzip and brotli compression for API responses
5
+ */
6
+ import { NextResponse } from 'next/server';
7
+ import { logger } from '../observability/logger.js';
8
+ const DEFAULT_OPTIONS = {
9
+ threshold: 1024, // 1KB minimum
10
+ level: 6, // Balanced compression
11
+ preferBrotli: true,
12
+ excludeTypes: [
13
+ 'image/png',
14
+ 'image/jpeg',
15
+ 'image/gif',
16
+ 'image/webp',
17
+ 'video/mp4',
18
+ 'application/zip',
19
+ 'application/gzip',
20
+ 'application/pdf',
21
+ ],
22
+ };
23
+ /**
24
+ * Check if response should be compressed
25
+ */
26
+ function shouldCompress(response, options) {
27
+ const contentType = response.headers.get('content-type') || '';
28
+ const contentLength = parseInt(response.headers.get('content-length') || '0', 10);
29
+ // Check if already compressed
30
+ if (response.headers.get('content-encoding')) {
31
+ return false;
32
+ }
33
+ // Check content type exclusions
34
+ if (options.excludeTypes?.some((type) => contentType.includes(type))) {
35
+ return false;
36
+ }
37
+ // Check size threshold
38
+ if (contentLength > 0 && contentLength < (options.threshold || 0)) {
39
+ return false;
40
+ }
41
+ return true;
42
+ }
43
+ /**
44
+ * Get best compression encoding from Accept-Encoding header
45
+ */
46
+ function getBestEncoding(request, preferBrotli) {
47
+ const acceptEncoding = request.headers.get('accept-encoding') || '';
48
+ const supportsBrotli = acceptEncoding.includes('br');
49
+ const supportsGzip = acceptEncoding.includes('gzip');
50
+ if (preferBrotli && supportsBrotli) {
51
+ return 'br';
52
+ }
53
+ if (supportsGzip) {
54
+ return 'gzip';
55
+ }
56
+ if (supportsBrotli) {
57
+ return 'br';
58
+ }
59
+ return null;
60
+ }
61
+ /**
62
+ * Compress response body
63
+ */
64
+ async function compressBody(body, encoding, _level) {
65
+ const textEncoder = new TextEncoder();
66
+ const data = typeof body === 'string' ? textEncoder.encode(body) : body;
67
+ if (encoding === 'gzip') {
68
+ // Use CompressionStream API (available in modern environments)
69
+ const stream = new Response(data).body?.pipeThrough(new CompressionStream('gzip'));
70
+ const compressed = await new Response(stream).arrayBuffer();
71
+ return new Uint8Array(compressed);
72
+ }
73
+ if (encoding === 'br') {
74
+ // Brotli compression
75
+ // Note: CompressionStream('deflate-raw') is available, but not 'br' in all environments
76
+ // Fallback to gzip if brotli not available
77
+ try {
78
+ const stream = new Response(data).body?.pipeThrough(new CompressionStream('deflate'));
79
+ const compressed = await new Response(stream).arrayBuffer();
80
+ return new Uint8Array(compressed);
81
+ }
82
+ catch {
83
+ // Fallback to gzip
84
+ const stream = new Response(data).body?.pipeThrough(new CompressionStream('gzip'));
85
+ const compressed = await new Response(stream).arrayBuffer();
86
+ return new Uint8Array(compressed);
87
+ }
88
+ }
89
+ return data;
90
+ }
91
+ /**
92
+ * Compress API response
93
+ */
94
+ export async function compressResponse(request, response, options = {}) {
95
+ const opts = { ...DEFAULT_OPTIONS, ...options };
96
+ // Check if should compress
97
+ if (!shouldCompress(response, opts)) {
98
+ return response;
99
+ }
100
+ // Get best encoding
101
+ const encoding = getBestEncoding(request, opts.preferBrotli ?? true);
102
+ if (!encoding) {
103
+ return response;
104
+ }
105
+ try {
106
+ // Get response body
107
+ const body = await response.text();
108
+ // Compress body
109
+ const compressed = await compressBody(body, encoding, opts.level || 6);
110
+ // Create new response with compressed body
111
+ const newResponse = new NextResponse(compressed, {
112
+ status: response.status,
113
+ statusText: response.statusText,
114
+ headers: response.headers,
115
+ });
116
+ // Set compression headers
117
+ newResponse.headers.set('content-encoding', encoding);
118
+ newResponse.headers.set('content-length', compressed.length.toString());
119
+ newResponse.headers.delete('content-length'); // Let runtime set it
120
+ newResponse.headers.set('vary', 'Accept-Encoding');
121
+ return newResponse;
122
+ }
123
+ catch (error) {
124
+ logger.error('Compression error', error instanceof Error ? error : new Error(String(error)));
125
+ return response;
126
+ }
127
+ }
128
+ /**
129
+ * Create compression middleware
130
+ */
131
+ export function createCompressionMiddleware(options = {}) {
132
+ return async (request, next) => {
133
+ const response = await next();
134
+ return compressResponse(request, response, options);
135
+ };
136
+ }
137
+ /**
138
+ * Calculate compression ratio
139
+ */
140
+ export function getCompressionRatio(originalSize, compressedSize) {
141
+ return ((originalSize - compressedSize) / originalSize) * 100;
142
+ }
143
+ export function getCompressionStats(originalBody, compressedBody, encoding) {
144
+ const originalSize = typeof originalBody === 'string' ? new Blob([originalBody]).size : originalBody.length;
145
+ const compressedSize = compressedBody.length;
146
+ const compressionRatio = getCompressionRatio(originalSize, compressedSize);
147
+ const savings = originalSize - compressedSize;
148
+ return {
149
+ originalSize,
150
+ compressedSize,
151
+ compressionRatio,
152
+ encoding,
153
+ savings,
154
+ };
155
+ }
156
+ /**
157
+ * Preset compression configurations
158
+ */
159
+ export const COMPRESSION_PRESETS = {
160
+ // Fast compression, lower ratio
161
+ fast: {
162
+ threshold: 512,
163
+ level: 3,
164
+ preferBrotli: false,
165
+ },
166
+ // Balanced compression
167
+ balanced: {
168
+ threshold: 1024,
169
+ level: 6,
170
+ preferBrotli: true,
171
+ },
172
+ // Maximum compression, slower
173
+ max: {
174
+ threshold: 512,
175
+ level: 9,
176
+ preferBrotli: true,
177
+ },
178
+ // For static assets
179
+ static: {
180
+ threshold: 1024,
181
+ level: 9,
182
+ preferBrotli: true,
183
+ },
184
+ // For API responses
185
+ api: {
186
+ threshold: 512,
187
+ level: 6,
188
+ preferBrotli: true,
189
+ excludeTypes: [
190
+ 'image/png',
191
+ 'image/jpeg',
192
+ 'image/gif',
193
+ 'image/webp',
194
+ 'video/mp4',
195
+ 'application/zip',
196
+ 'application/gzip',
197
+ 'application/pdf',
198
+ ],
199
+ },
200
+ };
201
+ /**
202
+ * Compress JSON response
203
+ */
204
+ export async function compressJSON(data, encoding = 'gzip', level = 6) {
205
+ const json = JSON.stringify(data);
206
+ return compressBody(json, encoding, level);
207
+ }
208
+ /**
209
+ * Decompress response
210
+ */
211
+ export async function decompressBody(body, encoding) {
212
+ if (encoding === 'gzip') {
213
+ const stream = new Response(body).body?.pipeThrough(new DecompressionStream('gzip'));
214
+ const decompressed = await new Response(stream).arrayBuffer();
215
+ return new Uint8Array(decompressed);
216
+ }
217
+ if (encoding === 'br' || encoding === 'deflate') {
218
+ const stream = new Response(body).body?.pipeThrough(new DecompressionStream('deflate'));
219
+ const decompressed = await new Response(stream).arrayBuffer();
220
+ return new Uint8Array(decompressed);
221
+ }
222
+ return body;
223
+ }
224
+ /**
225
+ * Check if compression is supported
226
+ */
227
+ export function isCompressionSupported(request) {
228
+ const acceptEncoding = request.headers.get('accept-encoding') || '';
229
+ return {
230
+ gzip: acceptEncoding.includes('gzip'),
231
+ brotli: acceptEncoding.includes('br'),
232
+ };
233
+ }
@@ -0,0 +1,138 @@
1
+ /**
2
+ * API Payload Optimization
3
+ *
4
+ * Reduces payload size through field selection, pagination, and data transformation
5
+ */
6
+ interface PaginationOptions {
7
+ page?: number;
8
+ limit?: number;
9
+ cursor?: string;
10
+ defaultLimit?: number;
11
+ maxLimit?: number;
12
+ }
13
+ interface PaginatedResponse<T> {
14
+ data: T[];
15
+ pagination: {
16
+ page?: number;
17
+ limit: number;
18
+ total?: number;
19
+ hasMore: boolean;
20
+ nextCursor?: string | null;
21
+ prevCursor?: string | null;
22
+ };
23
+ }
24
+ interface FieldSelectionOptions {
25
+ include?: string[];
26
+ exclude?: string[];
27
+ defaultFields?: string[];
28
+ }
29
+ /**
30
+ * Paginate array of items
31
+ */
32
+ export declare function paginateArray<T>(items: T[], options?: PaginationOptions): PaginatedResponse<T>;
33
+ /**
34
+ * Create cursor for cursor-based pagination
35
+ */
36
+ export declare function createCursor(item: Record<string, unknown>, field?: string): string;
37
+ /**
38
+ * Parse cursor
39
+ */
40
+ export declare function parseCursor(cursor: string): {
41
+ field: string;
42
+ value: unknown;
43
+ } | null;
44
+ /**
45
+ * Select fields from object
46
+ */
47
+ export declare function selectFields<T extends Record<string, unknown>>(obj: T, options: FieldSelectionOptions): Partial<T>;
48
+ /**
49
+ * Select fields from array of objects
50
+ */
51
+ export declare function selectFieldsFromArray<T extends Record<string, unknown>>(items: T[], options: FieldSelectionOptions): Partial<T>[];
52
+ /**
53
+ * Remove null and undefined values
54
+ */
55
+ export declare function removeEmpty<T extends Record<string, unknown>>(obj: T): Partial<T>;
56
+ /**
57
+ * Flatten nested object
58
+ */
59
+ export declare function flattenObject(obj: Record<string, unknown>, prefix?: string): Record<string, unknown>;
60
+ /**
61
+ * Minimize JSON response size
62
+ */
63
+ export declare function minimizeJSON(data: unknown): string;
64
+ /**
65
+ * Format JSON response (for development)
66
+ */
67
+ export declare function formatJSON(data: unknown): string;
68
+ /**
69
+ * Remove sensitive fields
70
+ */
71
+ export declare function sanitizeResponse<T extends Record<string, unknown>>(obj: T, sensitiveFields?: string[]): Partial<T>;
72
+ /**
73
+ * Transform timestamps to ISO strings
74
+ */
75
+ export declare function transformDates<T extends Record<string, unknown>>(obj: T): T;
76
+ /**
77
+ * Calculate payload size in bytes
78
+ */
79
+ export declare function getPayloadSize(data: unknown): number;
80
+ /**
81
+ * Get payload size in human-readable format
82
+ */
83
+ export declare function formatPayloadSize(bytes: number): string;
84
+ /**
85
+ * Optimize payload by removing unnecessary data
86
+ */
87
+ export interface OptimizationResult<T> {
88
+ data: T;
89
+ originalSize: number;
90
+ optimizedSize: number;
91
+ savings: number;
92
+ savingsPercent: number;
93
+ }
94
+ export declare function optimizePayload<T>(data: T, options?: FieldSelectionOptions & {
95
+ removeEmpty?: boolean;
96
+ transformDates?: boolean;
97
+ sanitize?: boolean;
98
+ }): OptimizationResult<T>;
99
+ /**
100
+ * Create API response with optimized payload
101
+ */
102
+ export declare function createOptimizedResponse<T>(data: T, options?: {
103
+ pagination?: PaginationOptions;
104
+ fields?: FieldSelectionOptions;
105
+ optimize?: boolean;
106
+ compress?: boolean;
107
+ }): {
108
+ data: unknown;
109
+ meta?: {
110
+ pagination?: PaginatedResponse<T>['pagination'];
111
+ size?: {
112
+ original: string;
113
+ optimized: string;
114
+ savings: string;
115
+ };
116
+ };
117
+ };
118
+ /**
119
+ * Parse field selection from query params
120
+ */
121
+ export declare function parseFieldsFromQuery(query: string): FieldSelectionOptions;
122
+ /**
123
+ * Parse pagination from query params
124
+ */
125
+ export declare function parsePaginationFromQuery(query: string): PaginationOptions;
126
+ /**
127
+ * Batch responses to reduce round trips
128
+ */
129
+ export declare function batchResponses<T>(responses: Array<{
130
+ key: string;
131
+ data: T;
132
+ }>): Record<string, T>;
133
+ /**
134
+ * Create partial response (for large objects)
135
+ */
136
+ export declare function createPartialResponse<T extends Record<string, unknown>>(obj: T, maxDepth?: number, currentDepth?: number): Partial<T> | string;
137
+ export {};
138
+ //# sourceMappingURL=payload-optimization.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"payload-optimization.d.ts","sourceRoot":"","sources":["../../src/api/payload-optimization.ts"],"names":[],"mappings":"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"}
@@ -0,0 +1,320 @@
1
+ /**
2
+ * API Payload Optimization
3
+ *
4
+ * Reduces payload size through field selection, pagination, and data transformation
5
+ */
6
+ /**
7
+ * Paginate array of items
8
+ */
9
+ export function paginateArray(items, options = {}) {
10
+ const { page = 1, limit = options.defaultLimit || 20, maxLimit = 100 } = options;
11
+ // Enforce max limit
12
+ const effectiveLimit = Math.min(limit, maxLimit);
13
+ // Calculate offset
14
+ const offset = (page - 1) * effectiveLimit;
15
+ // Slice data
16
+ const data = items.slice(offset, offset + effectiveLimit);
17
+ return {
18
+ data,
19
+ pagination: {
20
+ page,
21
+ limit: effectiveLimit,
22
+ total: items.length,
23
+ hasMore: offset + effectiveLimit < items.length,
24
+ },
25
+ };
26
+ }
27
+ /**
28
+ * Create cursor for cursor-based pagination
29
+ */
30
+ export function createCursor(item, field = 'id') {
31
+ const value = item[field];
32
+ return Buffer.from(JSON.stringify({ field, value })).toString('base64');
33
+ }
34
+ /**
35
+ * Parse cursor
36
+ */
37
+ export function parseCursor(cursor) {
38
+ try {
39
+ const decoded = Buffer.from(cursor, 'base64').toString('utf-8');
40
+ return JSON.parse(decoded);
41
+ }
42
+ catch {
43
+ return null;
44
+ }
45
+ }
46
+ /**
47
+ * Select fields from object
48
+ */
49
+ export function selectFields(obj, options) {
50
+ const { include, exclude, defaultFields } = options;
51
+ // If include is specified, only include those fields
52
+ if (include && include.length > 0) {
53
+ const result = {};
54
+ for (const field of include) {
55
+ if (field in obj) {
56
+ result[field] = obj[field];
57
+ }
58
+ }
59
+ return result;
60
+ }
61
+ // If exclude is specified, exclude those fields
62
+ if (exclude && exclude.length > 0) {
63
+ const result = { ...obj };
64
+ for (const field of exclude) {
65
+ delete result[field];
66
+ }
67
+ return result;
68
+ }
69
+ // Use default fields
70
+ if (defaultFields && defaultFields.length > 0) {
71
+ const result = {};
72
+ for (const field of defaultFields) {
73
+ if (field in obj) {
74
+ result[field] = obj[field];
75
+ }
76
+ }
77
+ return result;
78
+ }
79
+ // Return all fields
80
+ return obj;
81
+ }
82
+ /**
83
+ * Select fields from array of objects
84
+ */
85
+ export function selectFieldsFromArray(items, options) {
86
+ return items.map((item) => selectFields(item, options));
87
+ }
88
+ /**
89
+ * Remove null and undefined values
90
+ */
91
+ export function removeEmpty(obj) {
92
+ const result = {};
93
+ for (const [key, value] of Object.entries(obj)) {
94
+ if (value !== null && value !== undefined) {
95
+ result[key] = value;
96
+ }
97
+ }
98
+ return result;
99
+ }
100
+ /**
101
+ * Flatten nested object
102
+ */
103
+ export function flattenObject(obj, prefix = '') {
104
+ const result = {};
105
+ for (const [key, value] of Object.entries(obj)) {
106
+ const newKey = prefix ? `${prefix}.${key}` : key;
107
+ if (value !== null && typeof value === 'object' && !Array.isArray(value)) {
108
+ Object.assign(result, flattenObject(value, newKey));
109
+ }
110
+ else {
111
+ result[newKey] = value;
112
+ }
113
+ }
114
+ return result;
115
+ }
116
+ /**
117
+ * Minimize JSON response size
118
+ */
119
+ export function minimizeJSON(data) {
120
+ return JSON.stringify(data, null, 0);
121
+ }
122
+ /**
123
+ * Format JSON response (for development)
124
+ */
125
+ export function formatJSON(data) {
126
+ return JSON.stringify(data, null, 2);
127
+ }
128
+ /**
129
+ * Remove sensitive fields
130
+ */
131
+ export function sanitizeResponse(obj, sensitiveFields = ['password', 'secret', 'token', 'apiKey']) {
132
+ return selectFields(obj, { exclude: sensitiveFields });
133
+ }
134
+ /**
135
+ * Transform timestamps to ISO strings
136
+ */
137
+ export function transformDates(obj) {
138
+ const result = {};
139
+ for (const [key, value] of Object.entries(obj)) {
140
+ if (value instanceof Date) {
141
+ result[key] = value.toISOString();
142
+ }
143
+ else if (value !== null && typeof value === 'object' && !Array.isArray(value)) {
144
+ result[key] = transformDates(value);
145
+ }
146
+ else if (Array.isArray(value)) {
147
+ result[key] = value.map((item) => typeof item === 'object' && item !== null
148
+ ? transformDates(item)
149
+ : item);
150
+ }
151
+ else {
152
+ result[key] = value;
153
+ }
154
+ }
155
+ return result;
156
+ }
157
+ /**
158
+ * Calculate payload size in bytes
159
+ */
160
+ export function getPayloadSize(data) {
161
+ const json = JSON.stringify(data);
162
+ return new Blob([json]).size;
163
+ }
164
+ /**
165
+ * Get payload size in human-readable format
166
+ */
167
+ export function formatPayloadSize(bytes) {
168
+ if (bytes < 1024)
169
+ return `${bytes} B`;
170
+ if (bytes < 1024 * 1024)
171
+ return `${(bytes / 1024).toFixed(2)} KB`;
172
+ return `${(bytes / (1024 * 1024)).toFixed(2)} MB`;
173
+ }
174
+ export function optimizePayload(data, options = {}) {
175
+ const originalSize = getPayloadSize(data);
176
+ let optimized = data;
177
+ // Select fields
178
+ if (Array.isArray(data)) {
179
+ optimized = selectFieldsFromArray(data, options);
180
+ }
181
+ else if (typeof data === 'object' && data !== null) {
182
+ optimized = selectFields(data, options);
183
+ }
184
+ // Remove empty values
185
+ if (options.removeEmpty) {
186
+ if (Array.isArray(optimized)) {
187
+ optimized = optimized.map((item) => removeEmpty(item));
188
+ }
189
+ else if (optimized !== null && typeof optimized === 'object') {
190
+ optimized = removeEmpty(optimized);
191
+ }
192
+ }
193
+ // Transform dates
194
+ if (options.transformDates) {
195
+ if (Array.isArray(optimized)) {
196
+ optimized = optimized.map((item) => transformDates(item));
197
+ }
198
+ else if (optimized !== null && typeof optimized === 'object') {
199
+ optimized = transformDates(optimized);
200
+ }
201
+ }
202
+ // Sanitize
203
+ if (options.sanitize) {
204
+ if (Array.isArray(optimized)) {
205
+ optimized = optimized.map((item) => sanitizeResponse(item));
206
+ }
207
+ else if (optimized !== null && typeof optimized === 'object') {
208
+ optimized = sanitizeResponse(optimized);
209
+ }
210
+ }
211
+ const optimizedSize = getPayloadSize(optimized);
212
+ const savings = originalSize - optimizedSize;
213
+ const savingsPercent = (savings / originalSize) * 100;
214
+ return {
215
+ data: optimized,
216
+ originalSize,
217
+ optimizedSize,
218
+ savings,
219
+ savingsPercent,
220
+ };
221
+ }
222
+ /**
223
+ * Create API response with optimized payload
224
+ */
225
+ export function createOptimizedResponse(data, options = {}) {
226
+ let result = data;
227
+ // Paginate if array
228
+ if (Array.isArray(data) && options.pagination) {
229
+ const paginated = paginateArray(data, options.pagination);
230
+ result = {
231
+ data: paginated.data,
232
+ meta: {
233
+ pagination: paginated.pagination,
234
+ },
235
+ };
236
+ }
237
+ // Optimize payload
238
+ if (options.optimize) {
239
+ const optimized = optimizePayload(result, options.fields || {});
240
+ const resultWithMeta = result;
241
+ return {
242
+ data: optimized.data,
243
+ meta: {
244
+ ...(resultWithMeta.meta && typeof resultWithMeta.meta === 'object'
245
+ ? resultWithMeta.meta
246
+ : {}),
247
+ size: {
248
+ original: formatPayloadSize(optimized.originalSize),
249
+ optimized: formatPayloadSize(optimized.optimizedSize),
250
+ savings: `${optimized.savingsPercent.toFixed(1)}%`,
251
+ },
252
+ },
253
+ };
254
+ }
255
+ return { data: result };
256
+ }
257
+ /**
258
+ * Parse field selection from query params
259
+ */
260
+ export function parseFieldsFromQuery(query) {
261
+ const params = new URLSearchParams(query);
262
+ const include = params.get('fields')?.split(',').filter(Boolean);
263
+ const exclude = params.get('exclude')?.split(',').filter(Boolean);
264
+ return {
265
+ include,
266
+ exclude,
267
+ };
268
+ }
269
+ /**
270
+ * Parse pagination from query params
271
+ */
272
+ export function parsePaginationFromQuery(query) {
273
+ const params = new URLSearchParams(query);
274
+ const page = parseInt(params.get('page') || '1', 10);
275
+ const limit = parseInt(params.get('limit') || '20', 10);
276
+ const cursor = params.get('cursor') || undefined;
277
+ return {
278
+ page,
279
+ limit,
280
+ cursor,
281
+ };
282
+ }
283
+ /**
284
+ * Batch responses to reduce round trips
285
+ */
286
+ export function batchResponses(responses) {
287
+ const result = {};
288
+ for (const { key, data } of responses) {
289
+ result[key] = data;
290
+ }
291
+ return result;
292
+ }
293
+ /**
294
+ * Create partial response (for large objects)
295
+ */
296
+ export function createPartialResponse(obj, maxDepth = 2, currentDepth = 0) {
297
+ if (currentDepth >= maxDepth) {
298
+ return '[truncated]';
299
+ }
300
+ const result = {};
301
+ for (const [key, value] of Object.entries(obj)) {
302
+ if (Array.isArray(value)) {
303
+ result[key] = value
304
+ .slice(0, 10)
305
+ .map((item) => typeof item === 'object' && item !== null
306
+ ? createPartialResponse(item, maxDepth, currentDepth + 1)
307
+ : item);
308
+ if (value.length > 10) {
309
+ result[`${key}_count`] = value.length;
310
+ }
311
+ }
312
+ else if (value !== null && typeof value === 'object') {
313
+ result[key] = createPartialResponse(value, maxDepth, currentDepth + 1);
314
+ }
315
+ else {
316
+ result[key] = value;
317
+ }
318
+ }
319
+ return result;
320
+ }