openadminjs 0.1.4 → 0.1.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (404) hide show
  1. package/README.md +16 -113
  2. package/dist/create-project.d.ts +34 -0
  3. package/dist/create-project.js +245 -0
  4. package/dist/index.d.ts +2 -0
  5. package/dist/index.js +138 -0
  6. package/dist/index.test.d.ts +1 -0
  7. package/dist/index.test.js +7 -0
  8. package/dist/resource-slug.d.ts +2 -0
  9. package/dist/resource-slug.js +4 -0
  10. package/dist/resource-slug.test.d.ts +1 -0
  11. package/dist/resource-slug.test.js +9 -0
  12. package/package.json +35 -24
  13. package/.env.example +0 -9
  14. package/.github/FUNDING.yml +0 -3
  15. package/.github/ISSUE_TEMPLATE/bug_report.yml +0 -10
  16. package/.github/ISSUE_TEMPLATE/feature_request.yml +0 -10
  17. package/.github/PULL_REQUEST_TEMPLATE.md +0 -9
  18. package/.github/dependabot.yml +0 -10
  19. package/.github/workflows/ci.yml +0 -26
  20. package/CHANGELOG.md +0 -5
  21. package/CODE_OF_CONDUCT.md +0 -3
  22. package/CONTRIBUTING.md +0 -11
  23. package/LICENSE +0 -21
  24. package/ROADMAP.md +0 -7
  25. package/SECURITY.md +0 -11
  26. package/apps/admin/app/api/auth/login/route.ts +0 -51
  27. package/apps/admin/app/api/auth/logout/route.ts +0 -11
  28. package/apps/admin/app/api/auth/refresh/route.ts +0 -46
  29. package/apps/admin/app/api-tokens/page.tsx +0 -253
  30. package/apps/admin/app/audit-logs/page.tsx +0 -5
  31. package/apps/admin/app/dashboard/page.tsx +0 -392
  32. package/apps/admin/app/files/page.tsx +0 -5
  33. package/apps/admin/app/globals.css +0 -206
  34. package/apps/admin/app/jobs/page.tsx +0 -19
  35. package/apps/admin/app/layout.tsx +0 -57
  36. package/apps/admin/app/login/page.test.tsx +0 -18
  37. package/apps/admin/app/login/page.tsx +0 -161
  38. package/apps/admin/app/login/safe-next-param.ts +0 -4
  39. package/apps/admin/app/notifications/page.tsx +0 -146
  40. package/apps/admin/app/page.tsx +0 -5
  41. package/apps/admin/app/plugins/page.tsx +0 -407
  42. package/apps/admin/app/profile/page.tsx +0 -116
  43. package/apps/admin/app/resources/[resource]/[id]/edit/page.tsx +0 -45
  44. package/apps/admin/app/resources/[resource]/[id]/page.tsx +0 -449
  45. package/apps/admin/app/resources/[resource]/create/page.tsx +0 -34
  46. package/apps/admin/app/resources/[resource]/page.tsx +0 -100
  47. package/apps/admin/app/settings/page.tsx +0 -233
  48. package/apps/admin/components/ai-assistant-widget.tsx +0 -684
  49. package/apps/admin/components/app-shell.tsx +0 -305
  50. package/apps/admin/components/auth-guard.test.tsx +0 -55
  51. package/apps/admin/components/auth-guard.tsx +0 -39
  52. package/apps/admin/components/jobs-panel.tsx +0 -103
  53. package/apps/admin/components/logo.tsx +0 -30
  54. package/apps/admin/components/resource-form.tsx +0 -349
  55. package/apps/admin/components/resource-table.tsx +0 -277
  56. package/apps/admin/lib/ai-events.ts +0 -23
  57. package/apps/admin/lib/api.test.ts +0 -118
  58. package/apps/admin/lib/api.ts +0 -135
  59. package/apps/admin/lib/auth-flow.e2e.test.ts +0 -79
  60. package/apps/admin/lib/brand.ts +0 -14
  61. package/apps/admin/lib/locale.ts +0 -49
  62. package/apps/admin/lib/tokens.ts +0 -93
  63. package/apps/admin/middleware.ts +0 -58
  64. package/apps/admin/next-env.d.ts +0 -6
  65. package/apps/admin/next.config.mjs +0 -7
  66. package/apps/admin/package.json +0 -44
  67. package/apps/admin/postcss.config.mjs +0 -6
  68. package/apps/admin/public/brand/apple-touch-icon.png +0 -0
  69. package/apps/admin/public/brand/favicon.svg +0 -1
  70. package/apps/admin/public/brand/og-image.png +0 -0
  71. package/apps/admin/public/brand/openadminjs-icon-new.png +0 -0
  72. package/apps/admin/public/brand/openadminjs-logo-monochrome.png +0 -0
  73. package/apps/admin/public/brand/openadminjs-logo-new.png +0 -0
  74. package/apps/admin/tailwind.config.ts +0 -37
  75. package/apps/admin/tsconfig.json +0 -23
  76. package/apps/admin/vitest.config.ts +0 -7
  77. package/apps/api/package.json +0 -56
  78. package/apps/api/plugins.manifest.example.json +0 -34
  79. package/apps/api/plugins.manifest.json +0 -4
  80. package/apps/api/src/access/catalog.ts +0 -112
  81. package/apps/api/src/access/derive-permissions.test.ts +0 -26
  82. package/apps/api/src/access/derive-permissions.ts +0 -36
  83. package/apps/api/src/access/public-catalog.ts +0 -28
  84. package/apps/api/src/admin/admin-ai.controller.ts +0 -125
  85. package/apps/api/src/admin/admin-ai.events.ts +0 -23
  86. package/apps/api/src/admin/admin-ai.service.ts +0 -1271
  87. package/apps/api/src/admin/admin-analytics.service.ts +0 -164
  88. package/apps/api/src/admin/admin-plugins.controller.ts +0 -32
  89. package/apps/api/src/admin/admin-plugins.service.ts +0 -267
  90. package/apps/api/src/admin/admin-resource.service.test.ts +0 -118
  91. package/apps/api/src/admin/admin-resource.service.ts +0 -375
  92. package/apps/api/src/admin/admin.controller.ts +0 -72
  93. package/apps/api/src/admin/admin.module.ts +0 -30
  94. package/apps/api/src/admin/dto/plugins.dto.ts +0 -55
  95. package/apps/api/src/admin/validate-resource-payload.test.ts +0 -44
  96. package/apps/api/src/admin/validate-resource-payload.ts +0 -103
  97. package/apps/api/src/app.module.ts +0 -45
  98. package/apps/api/src/auth/auth.controller.ts +0 -70
  99. package/apps/api/src/auth/auth.dto.ts +0 -49
  100. package/apps/api/src/auth/auth.module.ts +0 -30
  101. package/apps/api/src/auth/auth.service.test.ts +0 -75
  102. package/apps/api/src/auth/auth.service.ts +0 -231
  103. package/apps/api/src/common/auth-realm.decorator.ts +0 -6
  104. package/apps/api/src/common/auth.guard.test.ts +0 -61
  105. package/apps/api/src/common/auth.guard.ts +0 -78
  106. package/apps/api/src/common/casl-ability.factory.test.ts +0 -33
  107. package/apps/api/src/common/casl-ability.factory.ts +0 -41
  108. package/apps/api/src/common/current-user.decorator.ts +0 -6
  109. package/apps/api/src/common/permission.decorator.ts +0 -7
  110. package/apps/api/src/common/permissions.guard.ts +0 -31
  111. package/apps/api/src/common/prisma.service.ts +0 -13
  112. package/apps/api/src/health/health.controller.ts +0 -25
  113. package/apps/api/src/mail/mail.module.ts +0 -9
  114. package/apps/api/src/mail/mail.service.ts +0 -115
  115. package/apps/api/src/main.ts +0 -37
  116. package/apps/api/src/plugins/bootstrap.ts +0 -4
  117. package/apps/api/src/plugins/bundled/admin-widget.plugin.ts +0 -25
  118. package/apps/api/src/plugins/bundled/hello.plugin.ts +0 -19
  119. package/apps/api/src/plugins/bundled/image-optimizer.plugin.ts +0 -22
  120. package/apps/api/src/plugins/bundled/registry.ts +0 -13
  121. package/apps/api/src/plugins/bundled/seo.plugin.ts +0 -25
  122. package/apps/api/src/plugins/manifest-path.ts +0 -35
  123. package/apps/api/src/plugins/manifest.schema.test.ts +0 -36
  124. package/apps/api/src/plugins/manifest.schema.ts +0 -58
  125. package/apps/api/src/plugins/plugin-api.interceptor.ts +0 -47
  126. package/apps/api/src/plugins/plugin-loader.ts +0 -134
  127. package/apps/api/src/plugins/plugin-runtime.test.ts +0 -24
  128. package/apps/api/src/plugins/plugin-runtime.ts +0 -85
  129. package/apps/api/src/queue/queue.controller.ts +0 -28
  130. package/apps/api/src/queue/queue.module.ts +0 -23
  131. package/apps/api/src/queue/queue.processor.ts +0 -47
  132. package/apps/api/src/queue/queue.service.ts +0 -50
  133. package/apps/api/src/resources/categories.resource.ts +0 -21
  134. package/apps/api/src/resources/commerce.resource.ts +0 -157
  135. package/apps/api/src/resources/operations.resource.ts +0 -111
  136. package/apps/api/src/resources/posts.resource.ts +0 -88
  137. package/apps/api/src/resources/registry.ts +0 -27
  138. package/apps/api/src/resources/resource-hooks.install.ts +0 -18
  139. package/apps/api/src/resources/resource-hooks.registry.test.ts +0 -72
  140. package/apps/api/src/resources/resource-hooks.registry.ts +0 -66
  141. package/apps/api/src/resources/resource-hooks.runner.ts +0 -93
  142. package/apps/api/src/resources/system.resource.ts +0 -51
  143. package/apps/api/src/resources/users.resource.ts +0 -19
  144. package/apps/api/src/store/payment/payment.controller.ts +0 -98
  145. package/apps/api/src/store/payment/payment.module.ts +0 -14
  146. package/apps/api/src/store/payment/payment.provider.ts +0 -38
  147. package/apps/api/src/store/payment/payment.service.ts +0 -235
  148. package/apps/api/src/store/store.controller.ts +0 -26
  149. package/apps/api/src/store/store.module.ts +0 -12
  150. package/apps/api/src/test-setup.ts +0 -1
  151. package/apps/api/tsconfig.json +0 -11
  152. package/apps/api/vitest.config.ts +0 -21
  153. package/apps/web/README.md +0 -12
  154. package/apps/web/app/globals.css +0 -12
  155. package/apps/web/app/layout.tsx +0 -18
  156. package/apps/web/app/page.tsx +0 -27
  157. package/apps/web/app/posts/[slug]/page.tsx +0 -38
  158. package/apps/web/app/posts/page.tsx +0 -20
  159. package/apps/web/app/robots.txt/route.ts +0 -9
  160. package/apps/web/app/sitemap.xml/route.ts +0 -20
  161. package/apps/web/components/public-fields.tsx +0 -22
  162. package/apps/web/lib/openadmin-client.ts +0 -82
  163. package/apps/web/lib/seo.test.ts +0 -41
  164. package/apps/web/lib/seo.ts +0 -53
  165. package/apps/web/next-env.d.ts +0 -6
  166. package/apps/web/next.config.mjs +0 -5
  167. package/apps/web/package.json +0 -30
  168. package/apps/web/postcss.config.mjs +0 -6
  169. package/apps/web/public/brand/apple-touch-icon.png +0 -0
  170. package/apps/web/public/brand/favicon.svg +0 -1
  171. package/apps/web/public/brand/og-image.png +0 -0
  172. package/apps/web/public/brand/openadminjs-icon-new.png +0 -0
  173. package/apps/web/public/brand/openadminjs-logo-monochrome.png +0 -0
  174. package/apps/web/public/brand/openadminjs-logo-new.png +0 -0
  175. package/apps/web/tailwind.config.ts +0 -21
  176. package/apps/web/test/next-stub.ts +0 -7
  177. package/apps/web/tsconfig.json +0 -23
  178. package/apps/web/vitest.config.ts +0 -19
  179. package/docs/content/security.md +0 -7
  180. package/eslint.config.mjs +0 -11
  181. package/examples/README.md +0 -80
  182. package/examples/basic-admin/README.md +0 -24
  183. package/examples/basic-admin/package.json +0 -17
  184. package/examples/basic-admin/prisma/models.fragment.prisma +0 -12
  185. package/examples/basic-admin/src/index.test.ts +0 -8
  186. package/examples/basic-admin/src/index.ts +0 -5
  187. package/examples/basic-admin/src/resources/lead.resource.ts +0 -30
  188. package/examples/basic-admin/tsconfig.json +0 -7
  189. package/examples/basic-admin/vitest.config.ts +0 -16
  190. package/examples/blog-admin/README.md +0 -18
  191. package/examples/blog-admin/package.json +0 -17
  192. package/examples/blog-admin/prisma/models.fragment.prisma +0 -30
  193. package/examples/blog-admin/src/index.test.ts +0 -8
  194. package/examples/blog-admin/src/index.ts +0 -5
  195. package/examples/blog-admin/src/resources/authors.resource.ts +0 -21
  196. package/examples/blog-admin/src/resources/tags.resource.ts +0 -20
  197. package/examples/blog-admin/tsconfig.json +0 -7
  198. package/examples/blog-admin/vitest.config.ts +0 -16
  199. package/examples/crm-admin/README.md +0 -17
  200. package/examples/crm-admin/package.json +0 -17
  201. package/examples/crm-admin/prisma/models.fragment.prisma +0 -50
  202. package/examples/crm-admin/src/index.test.ts +0 -9
  203. package/examples/crm-admin/src/index.ts +0 -7
  204. package/examples/crm-admin/src/resources/activities.resource.ts +0 -29
  205. package/examples/crm-admin/src/resources/companies.resource.ts +0 -21
  206. package/examples/crm-admin/src/resources/contacts.resource.ts +0 -24
  207. package/examples/crm-admin/src/resources/deals.resource.ts +0 -30
  208. package/examples/crm-admin/tsconfig.json +0 -7
  209. package/examples/crm-admin/vitest.config.ts +0 -16
  210. package/examples/ecommerce-admin/README.md +0 -17
  211. package/examples/ecommerce-admin/package.json +0 -17
  212. package/examples/ecommerce-admin/prisma/models.fragment.prisma +0 -43
  213. package/examples/ecommerce-admin/src/index.test.ts +0 -8
  214. package/examples/ecommerce-admin/src/index.ts +0 -7
  215. package/examples/ecommerce-admin/src/resources/customers.resource.ts +0 -21
  216. package/examples/ecommerce-admin/src/resources/order-items.resource.ts +0 -22
  217. package/examples/ecommerce-admin/src/resources/orders.resource.ts +0 -27
  218. package/examples/ecommerce-admin/src/resources/products.resource.ts +0 -23
  219. package/examples/ecommerce-admin/tsconfig.json +0 -7
  220. package/examples/ecommerce-admin/vitest.config.ts +0 -16
  221. package/examples/marketplace-admin/README.md +0 -17
  222. package/examples/marketplace-admin/package.json +0 -17
  223. package/examples/marketplace-admin/prisma/models.fragment.prisma +0 -32
  224. package/examples/marketplace-admin/src/index.test.ts +0 -8
  225. package/examples/marketplace-admin/src/index.ts +0 -6
  226. package/examples/marketplace-admin/src/resources/listings.resource.ts +0 -29
  227. package/examples/marketplace-admin/src/resources/payouts.resource.ts +0 -28
  228. package/examples/marketplace-admin/src/resources/sellers.resource.ts +0 -28
  229. package/examples/marketplace-admin/tsconfig.json +0 -7
  230. package/examples/marketplace-admin/vitest.config.ts +0 -16
  231. package/examples/support-admin/README.md +0 -18
  232. package/examples/support-admin/package.json +0 -17
  233. package/examples/support-admin/prisma/models.fragment.prisma +0 -20
  234. package/examples/support-admin/src/index.test.ts +0 -8
  235. package/examples/support-admin/src/index.ts +0 -5
  236. package/examples/support-admin/src/resources/ticket-messages.resource.ts +0 -22
  237. package/examples/support-admin/src/resources/tickets.resource.ts +0 -35
  238. package/examples/support-admin/tsconfig.json +0 -7
  239. package/examples/support-admin/vitest.config.ts +0 -16
  240. package/packages/auth/package.json +0 -17
  241. package/packages/auth/src/index.test.ts +0 -10
  242. package/packages/auth/src/index.ts +0 -17
  243. package/packages/auth/tsconfig.json +0 -8
  244. package/packages/brand/apps/admin/public/brand/apple-touch-icon.png +0 -0
  245. package/packages/brand/apps/admin/public/brand/favicon.svg +0 -1
  246. package/packages/brand/apps/admin/public/brand/og-image.png +0 -0
  247. package/packages/brand/apps/admin/public/brand/openadminjs-icon-new.png +0 -0
  248. package/packages/brand/apps/admin/public/brand/openadminjs-logo-monochrome.png +0 -0
  249. package/packages/brand/apps/admin/public/brand/openadminjs-logo-new.png +0 -0
  250. package/packages/brand/apps/web/public/brand/apple-touch-icon.png +0 -0
  251. package/packages/brand/apps/web/public/brand/favicon.svg +0 -1
  252. package/packages/brand/apps/web/public/brand/og-image.png +0 -0
  253. package/packages/brand/apps/web/public/brand/openadminjs-icon-new.png +0 -0
  254. package/packages/brand/apps/web/public/brand/openadminjs-logo-monochrome.png +0 -0
  255. package/packages/brand/apps/web/public/brand/openadminjs-logo-new.png +0 -0
  256. package/packages/brand/package.json +0 -19
  257. package/packages/brand/site/assets/brand/favicon.svg +0 -1
  258. package/packages/brand/site/assets/brand/og-image.svg +0 -1
  259. package/packages/brand/site/assets/brand/openadminjs-icon.svg +0 -1
  260. package/packages/brand/site/assets/brand/openadminjs-logo-dark.svg +0 -1
  261. package/packages/brand/site/assets/brand/openadminjs-logo-horizontal.svg +0 -1
  262. package/packages/brand/site/assets/brand/openadminjs-logo-monochrome.svg +0 -1
  263. package/packages/brand/site/assets/brand/openadminjs-logo.svg +0 -1
  264. package/packages/brand/src/generate-assets.mjs +0 -182
  265. package/packages/brand/src/index.test.ts +0 -9
  266. package/packages/brand/src/index.ts +0 -7
  267. package/packages/brand/tsconfig.json +0 -7
  268. package/packages/cli/package.json +0 -44
  269. package/packages/cli/src/create-project.ts +0 -316
  270. package/packages/cli/src/index.test.ts +0 -8
  271. package/packages/cli/src/index.ts +0 -149
  272. package/packages/cli/src/resource-slug.test.ts +0 -10
  273. package/packages/cli/src/resource-slug.ts +0 -4
  274. package/packages/cli/template/.env.example +0 -6
  275. package/packages/cli/template/README.md +0 -13
  276. package/packages/cli/template/apps/web/README.md +0 -12
  277. package/packages/cli/template/apps/web/app/globals.css +0 -12
  278. package/packages/cli/template/apps/web/app/layout.tsx +0 -18
  279. package/packages/cli/template/apps/web/app/page.tsx +0 -27
  280. package/packages/cli/template/apps/web/app/posts/[slug]/page.tsx +0 -38
  281. package/packages/cli/template/apps/web/app/posts/page.tsx +0 -20
  282. package/packages/cli/template/apps/web/app/robots.txt/route.ts +0 -9
  283. package/packages/cli/template/apps/web/app/sitemap.xml/route.ts +0 -20
  284. package/packages/cli/template/apps/web/components/public-fields.tsx +0 -22
  285. package/packages/cli/template/apps/web/lib/openadmin-client.ts +0 -71
  286. package/packages/cli/template/apps/web/lib/seo.ts +0 -42
  287. package/packages/cli/template/apps/web/next-env.d.ts +0 -2
  288. package/packages/cli/template/apps/web/next.config.mjs +0 -5
  289. package/packages/cli/template/apps/web/package.json +0 -29
  290. package/packages/cli/template/apps/web/postcss.config.mjs +0 -6
  291. package/packages/cli/template/apps/web/public/brand/apple-touch-icon.png +0 -0
  292. package/packages/cli/template/apps/web/public/brand/favicon.svg +0 -1
  293. package/packages/cli/template/apps/web/public/brand/og-image.png +0 -0
  294. package/packages/cli/template/apps/web/public/brand/openadminjs-icon-new.png +0 -0
  295. package/packages/cli/template/apps/web/public/brand/openadminjs-logo-monochrome.png +0 -0
  296. package/packages/cli/template/apps/web/public/brand/openadminjs-logo-new.png +0 -0
  297. package/packages/cli/template/apps/web/tailwind.config.ts +0 -21
  298. package/packages/cli/template/apps/web/tsconfig.json +0 -23
  299. package/packages/cli/template/package.json +0 -19
  300. package/packages/cli/template/pnpm-workspace.yaml +0 -3
  301. package/packages/cli/tsconfig.json +0 -10
  302. package/packages/core/package.json +0 -20
  303. package/packages/core/src/index.js +0 -1
  304. package/packages/core/src/index.test.ts +0 -27
  305. package/packages/core/src/index.ts +0 -61
  306. package/packages/core/tsconfig.json +0 -8
  307. package/packages/create-openadminjs/package.json +0 -25
  308. package/packages/create-openadminjs/src/index.ts +0 -122
  309. package/packages/create-openadminjs/src/package-name.test.ts +0 -13
  310. package/packages/create-openadminjs/src/package-name.ts +0 -8
  311. package/packages/create-openadminjs/src/render-files.test.ts +0 -26
  312. package/packages/create-openadminjs/src/render-files.ts +0 -21
  313. package/packages/create-openadminjs/template/.env.example +0 -7
  314. package/packages/create-openadminjs/template/README.md +0 -13
  315. package/packages/create-openadminjs/template/apps/web/README.md +0 -12
  316. package/packages/create-openadminjs/template/apps/web/app/globals.css +0 -12
  317. package/packages/create-openadminjs/template/apps/web/app/layout.tsx +0 -18
  318. package/packages/create-openadminjs/template/apps/web/app/page.tsx +0 -27
  319. package/packages/create-openadminjs/template/apps/web/app/posts/[slug]/page.tsx +0 -38
  320. package/packages/create-openadminjs/template/apps/web/app/posts/page.tsx +0 -20
  321. package/packages/create-openadminjs/template/apps/web/app/robots.txt/route.ts +0 -9
  322. package/packages/create-openadminjs/template/apps/web/app/sitemap.xml/route.ts +0 -20
  323. package/packages/create-openadminjs/template/apps/web/components/public-fields.tsx +0 -22
  324. package/packages/create-openadminjs/template/apps/web/lib/openadmin-client.ts +0 -71
  325. package/packages/create-openadminjs/template/apps/web/lib/seo.ts +0 -42
  326. package/packages/create-openadminjs/template/apps/web/next-env.d.ts +0 -2
  327. package/packages/create-openadminjs/template/apps/web/next.config.mjs +0 -5
  328. package/packages/create-openadminjs/template/apps/web/package.json +0 -29
  329. package/packages/create-openadminjs/template/apps/web/postcss.config.mjs +0 -6
  330. package/packages/create-openadminjs/template/apps/web/public/brand/apple-touch-icon.png +0 -0
  331. package/packages/create-openadminjs/template/apps/web/public/brand/favicon.svg +0 -1
  332. package/packages/create-openadminjs/template/apps/web/public/brand/og-image.png +0 -0
  333. package/packages/create-openadminjs/template/apps/web/public/brand/openadminjs-icon-new.png +0 -0
  334. package/packages/create-openadminjs/template/apps/web/public/brand/openadminjs-logo-monochrome.png +0 -0
  335. package/packages/create-openadminjs/template/apps/web/public/brand/openadminjs-logo-new.png +0 -0
  336. package/packages/create-openadminjs/template/apps/web/tailwind.config.ts +0 -21
  337. package/packages/create-openadminjs/template/apps/web/tsconfig.json +0 -23
  338. package/packages/create-openadminjs/template/package.json +0 -19
  339. package/packages/create-openadminjs/template/pnpm-workspace.yaml +0 -3
  340. package/packages/create-openadminjs/tsconfig.json +0 -10
  341. package/packages/mail/package.json +0 -18
  342. package/packages/mail/src/index.test.ts +0 -23
  343. package/packages/mail/src/index.ts +0 -246
  344. package/packages/mail/tsconfig.json +0 -5
  345. package/packages/notifications/package.json +0 -16
  346. package/packages/notifications/src/index.test.ts +0 -9
  347. package/packages/notifications/src/index.ts +0 -5
  348. package/packages/notifications/tsconfig.json +0 -5
  349. package/packages/payments/package.json +0 -15
  350. package/packages/payments/src/index.ts +0 -256
  351. package/packages/payments/tsconfig.json +0 -9
  352. package/packages/permissions/package.json +0 -17
  353. package/packages/permissions/src/blueprints.js +0 -57
  354. package/packages/permissions/src/blueprints.test.ts +0 -62
  355. package/packages/permissions/src/blueprints.ts +0 -89
  356. package/packages/permissions/src/index.js +0 -11
  357. package/packages/permissions/src/index.test.ts +0 -34
  358. package/packages/permissions/src/index.ts +0 -22
  359. package/packages/permissions/tsconfig.json +0 -8
  360. package/packages/plugin-sdk/package.json +0 -26
  361. package/packages/plugin-sdk/src/hooks.ts +0 -135
  362. package/packages/plugin-sdk/src/index.ts +0 -42
  363. package/packages/plugin-sdk/src/sdk.test.ts +0 -13
  364. package/packages/plugin-sdk/tsconfig.json +0 -8
  365. package/packages/plugin-sdk/vitest.config.ts +0 -5
  366. package/packages/queue/package.json +0 -16
  367. package/packages/queue/src/index.test.ts +0 -12
  368. package/packages/queue/src/index.ts +0 -6
  369. package/packages/queue/tsconfig.json +0 -5
  370. package/packages/resource/package.json +0 -17
  371. package/packages/resource/src/index.js +0 -177
  372. package/packages/resource/src/index.test.ts +0 -151
  373. package/packages/resource/src/index.ts +0 -344
  374. package/packages/resource/tsconfig.json +0 -8
  375. package/packages/storage/package.json +0 -16
  376. package/packages/storage/src/index.test.ts +0 -10
  377. package/packages/storage/src/index.ts +0 -23
  378. package/packages/storage/tsconfig.json +0 -5
  379. package/pnpm-workspace.yaml +0 -4
  380. package/prisma/migrations/20260505151751_baseline_init_all_tables/migration.sql +0 -371
  381. package/prisma/migrations/migration_lock.toml +0 -3
  382. package/prisma/schema.prisma +0 -291
  383. package/prisma/seed.ts +0 -210
  384. package/scripts/check-static-site.mjs +0 -17
  385. package/scripts/e2e-smoke.mjs +0 -17
  386. package/scripts/make-executable.mjs +0 -4
  387. package/site/.nojekyll +0 -0
  388. package/site/assets/brand/apple-touch-icon.png +0 -0
  389. package/site/assets/brand/favicon.svg +0 -1
  390. package/site/assets/brand/og-image.png +0 -0
  391. package/site/assets/brand/openadminjs-icon-new.png +0 -0
  392. package/site/assets/brand/openadminjs-logo-monochrome.png +0 -0
  393. package/site/assets/brand/openadminjs-logo-new.png +0 -0
  394. package/site/assets/css/styles.css +0 -1521
  395. package/site/assets/js/main.js +0 -193
  396. package/site/assets/partners/arcbyte.svg +0 -11
  397. package/site/assets/partners/gridstack.svg +0 -8
  398. package/site/assets/partners/nebula.svg +0 -12
  399. package/site/assets/partners/orbitlab.svg +0 -7
  400. package/site/assets/partners/pulseforge.svg +0 -11
  401. package/site/assets/partners/vertex.svg +0 -6
  402. package/site/docs.html +0 -1459
  403. package/site/index.html +0 -357
  404. package/tsconfig.base.json +0 -23
@@ -1,134 +0,0 @@
1
- import { existsSync, readFileSync } from "node:fs";
2
- import { createRequire } from "node:module";
3
- import type { OpenAdminPlugin, OpenAdminPluginModule, PluginRegistrationContext, PluginSurfaceRegistry } from "@openadminjs/plugin-sdk";
4
- import { Logger } from "@nestjs/common";
5
- import { registerResourceHooks, unregisterResourceHooksBySource } from "../resources/resource-hooks.registry";
6
- import { bundledOpenAdminPlugins } from "./bundled/registry";
7
- import { getManifestCandidateStrings, toAbsoluteManifestPath } from "./manifest-path";
8
- import { pluginManifestSchema, type PluginManifestEntry } from "./manifest.schema";
9
- import { pluginRuntime } from "./plugin-runtime";
10
-
11
- const log = new Logger("OpenAdminPlugins");
12
-
13
- const require = createRequire(import.meta.url);
14
-
15
- function readManifest(): unknown | undefined {
16
- for (const candidate of getManifestCandidateStrings()) {
17
- const path = toAbsoluteManifestPath(candidate);
18
- if (existsSync(path)) {
19
- log.log(`Loading plugin manifest: ${path}`);
20
- return JSON.parse(readFileSync(path, "utf8")) as unknown;
21
- }
22
- }
23
- return undefined;
24
- }
25
-
26
- /** Clears the main module entry so the next `require` re-reads from disk (e.g. after `pnpm add`). */
27
- export function invalidateNpmPluginMainModule(packageSpec: string): void {
28
- try {
29
- const resolved = require.resolve(packageSpec);
30
- delete require.cache[resolved];
31
- } catch {
32
- /* not resolved yet — fine */
33
- }
34
- }
35
-
36
- function resolveNpmPlugin(entry: PluginManifestEntry): OpenAdminPlugin {
37
- const spec = entry.package!;
38
- if (process.env.NODE_ENV === "production" && (spec.includes("..") || spec.startsWith(".") || spec.startsWith("/"))) {
39
- throw new Error(`Refusing to load plugin package path in production: ${entry.id}`);
40
- }
41
- const mod = require(spec) as OpenAdminPluginModule;
42
- const plugin = mod.openAdminPlugin ?? mod.default;
43
- if (!plugin) {
44
- throw new Error(`Package "${spec}" has no openAdminPlugin or default export (${entry.id})`);
45
- }
46
- if (plugin.id !== entry.id) {
47
- log.warn(`Plugin manifest id "${entry.id}" differs from plugin.id "${plugin.id}" — manifest id is used as source label`);
48
- }
49
- return plugin;
50
- }
51
-
52
- function resolveBundledPlugin(entry: PluginManifestEntry): OpenAdminPlugin {
53
- const key = entry.bundled!;
54
- const plugin = bundledOpenAdminPlugins[key];
55
- if (!plugin) {
56
- throw new Error(`Unknown bundled plugin "${key}" for ${entry.id}. Known: ${Object.keys(bundledOpenAdminPlugins).join(", ")}`);
57
- }
58
- return plugin;
59
- }
60
-
61
- function createContext(entry: PluginManifestEntry): PluginRegistrationContext {
62
- const config = (entry.config ?? {}) as Record<string, unknown>;
63
- const capabilities = new Set(entry.capabilities ?? []);
64
- const ensureCap = (name: string) => {
65
- if ((entry.trustMode ?? "trusted") === "trusted" && capabilities.size === 0) return;
66
- if (!capabilities.has(name as never)) {
67
- throw new Error(`Plugin "${entry.id}" attempted to use capability "${name}" but it is not declared in manifest.`);
68
- }
69
- };
70
- const registerSurface = (surface: PluginSurfaceRegistry) => {
71
- if (surface.resource) {
72
- ensureCap("resource.hooks");
73
- throw new Error('Use registerResourceHooks(resourceName, hooks) for resource lifecycle hooks.');
74
- }
75
- if (surface.api) {
76
- if (surface.api.routes?.length) ensureCap("api.routes");
77
- else ensureCap("api.hooks");
78
- }
79
- if (surface.media) ensureCap("media.pipeline");
80
- if (surface.seo) ensureCap("seo.extend");
81
- if (surface.jobs?.length) ensureCap("jobs.run");
82
- if (surface.adminUi?.length) ensureCap("admin.ui.extend");
83
- pluginRuntime.register(entry.id, surface);
84
- };
85
- return {
86
- pluginId: entry.id,
87
- config,
88
- trustMode: entry.trustMode ?? "trusted",
89
- capabilities: [...capabilities],
90
- registerResourceHooks: (resourceName, hooks, options) =>
91
- registerResourceHooks(resourceName, hooks, { ...options, source: entry.id }),
92
- registerSurface
93
- };
94
- }
95
-
96
- /** Register hooks for one manifest entry (same as bootstrap). Throws on failure. */
97
- export async function applyManifestPluginEntry(entry: PluginManifestEntry): Promise<void> {
98
- if (entry.enabled === false) return;
99
- const plugin: OpenAdminPlugin = entry.bundled ? resolveBundledPlugin(entry) : resolveNpmPlugin(entry);
100
- const ctx = createContext(entry);
101
- await plugin.register(ctx as PluginRegistrationContext);
102
- if (plugin.onStart) await plugin.onStart(ctx as PluginRegistrationContext);
103
- log.log(`Loaded plugin ${entry.id} (${entry.bundled ? `bundled:${entry.bundled}` : `package:${entry.package}`})`);
104
- }
105
-
106
- /** Drop all hook registrations attributed to this plugin id (before re-apply or disable). */
107
- export function removeManifestPluginHooks(pluginId: string): void {
108
- unregisterResourceHooksBySource(pluginId);
109
- pluginRuntime.removeBySource(pluginId);
110
- log.log(`Removed runtime hooks for plugin ${pluginId}`);
111
- }
112
-
113
- export async function loadPluginsFromManifest(): Promise<void> {
114
- const raw = readManifest();
115
- if (!raw) {
116
- log.log("No plugins.manifest.json found — skipping plugins");
117
- return;
118
- }
119
- const parsed = pluginManifestSchema.safeParse(raw);
120
- if (!parsed.success) {
121
- log.error(`Invalid plugins.manifest.json: ${parsed.error.message}`);
122
- return;
123
- }
124
- const manifest = parsed.data;
125
- for (const entry of manifest.plugins) {
126
- if (entry.enabled === false) continue;
127
- try {
128
- await applyManifestPluginEntry(entry);
129
- } catch (e) {
130
- log.error(`Failed to load plugin ${entry.id}: ${(e as Error).message}`);
131
- if (process.env.NODE_ENV === "production") throw e;
132
- }
133
- }
134
- }
@@ -1,24 +0,0 @@
1
- import { describe, expect, it } from "vitest";
2
- import { pluginRuntime } from "./plugin-runtime";
3
-
4
- describe("pluginRuntime", () => {
5
- it("registers and removes surfaces by source", () => {
6
- pluginRuntime.register(
7
- "test.plugin",
8
- {
9
- seo: {
10
- metadata: () => ({ title: "x" })
11
- },
12
- jobs: [{ name: "test-job", handler: () => "ok" }]
13
- },
14
- "posts"
15
- );
16
- expect(pluginRuntime.getSeoHooks().length).toBeGreaterThan(0);
17
- expect(pluginRuntime.getJobs().some((job) => job.name === "test-job")).toBe(true);
18
-
19
- pluginRuntime.removeBySource("test.plugin");
20
-
21
- expect(pluginRuntime.getSeoHooks().length).toBe(0);
22
- expect(pluginRuntime.getJobs().some((job) => job.name === "test-job")).toBe(false);
23
- });
24
- });
@@ -1,85 +0,0 @@
1
- import type {
2
- AdminUiExtension,
3
- ApiHooks,
4
- JobHandler,
5
- MediaHooks,
6
- PluginSurfaceRegistry,
7
- ResourceLifecycleHooks,
8
- SeoHooks
9
- } from "@openadminjs/plugin-sdk";
10
-
11
- type SurfaceEntry<T> = {
12
- source: string;
13
- value: T;
14
- };
15
-
16
- class PluginRuntimeBus {
17
- private readonly resourceHooks = new Map<string, SurfaceEntry<ResourceLifecycleHooks>[]>();
18
- private readonly apiHooks: SurfaceEntry<ApiHooks>[] = [];
19
- private readonly mediaHooks: SurfaceEntry<MediaHooks>[] = [];
20
- private readonly seoHooks: SurfaceEntry<SeoHooks>[] = [];
21
- private readonly jobs: SurfaceEntry<JobHandler>[] = [];
22
- private readonly adminUi: SurfaceEntry<AdminUiExtension>[] = [];
23
-
24
- register(source: string, surface: PluginSurfaceRegistry, resourceName?: string): void {
25
- if (surface.resource && resourceName) {
26
- const chain = this.resourceHooks.get(resourceName) ?? [];
27
- chain.push({ source, value: surface.resource });
28
- this.resourceHooks.set(resourceName, chain);
29
- }
30
- if (surface.api) this.apiHooks.push({ source, value: surface.api });
31
- if (surface.media) this.mediaHooks.push({ source, value: surface.media });
32
- if (surface.seo) this.seoHooks.push({ source, value: surface.seo });
33
- if (surface.jobs) {
34
- for (const handler of surface.jobs) this.jobs.push({ source, value: handler });
35
- }
36
- if (surface.adminUi) {
37
- for (const extension of surface.adminUi) this.adminUi.push({ source, value: extension });
38
- }
39
- }
40
-
41
- removeBySource(source: string): void {
42
- for (const [name, entries] of this.resourceHooks.entries()) {
43
- const filtered = entries.filter((entry) => entry.source !== source);
44
- if (filtered.length === 0) this.resourceHooks.delete(name);
45
- else this.resourceHooks.set(name, filtered);
46
- }
47
- this.removeInPlace(this.apiHooks, source);
48
- this.removeInPlace(this.mediaHooks, source);
49
- this.removeInPlace(this.seoHooks, source);
50
- this.removeInPlace(this.jobs, source);
51
- this.removeInPlace(this.adminUi, source);
52
- }
53
-
54
- getResourceHookChain(resourceName: string): ResourceLifecycleHooks[] {
55
- return (this.resourceHooks.get(resourceName) ?? []).map((entry) => entry.value);
56
- }
57
-
58
- getApiHooks(): ApiHooks[] {
59
- return this.apiHooks.map((item) => item.value);
60
- }
61
-
62
- getMediaHooks(): MediaHooks[] {
63
- return this.mediaHooks.map((item) => item.value);
64
- }
65
-
66
- getSeoHooks(): SeoHooks[] {
67
- return this.seoHooks.map((item) => item.value);
68
- }
69
-
70
- getJobs(): JobHandler[] {
71
- return this.jobs.map((item) => item.value);
72
- }
73
-
74
- getAdminUiExtensions(): AdminUiExtension[] {
75
- return this.adminUi.map((item) => item.value);
76
- }
77
-
78
- private removeInPlace<T>(list: SurfaceEntry<T>[], source: string): void {
79
- for (let i = list.length - 1; i >= 0; i -= 1) {
80
- if (list[i]?.source === source) list.splice(i, 1);
81
- }
82
- }
83
- }
84
-
85
- export const pluginRuntime = new PluginRuntimeBus();
@@ -1,28 +0,0 @@
1
- import { Controller, Get, Post, UseGuards } from "@nestjs/common";
2
- import { AuthGuard } from "../common/auth.guard";
3
- import { RequireAuthRealm } from "../common/auth-realm.decorator";
4
- import { PermissionsGuard } from "../common/permissions.guard";
5
- import { RequirePermission } from "../common/permission.decorator";
6
- import { CurrentUser } from "../common/current-user.decorator";
7
- import { QueueService } from "./queue.service";
8
-
9
- type UserContext = { id: string };
10
-
11
- @Controller("jobs")
12
- @UseGuards(AuthGuard, PermissionsGuard)
13
- @RequireAuthRealm("admin")
14
- export class QueueController {
15
- constructor(private readonly queue: QueueService) {}
16
-
17
- @Get("stats")
18
- @RequirePermission("jobs.read")
19
- stats() {
20
- return this.queue.getStats();
21
- }
22
-
23
- @Post("dispatch")
24
- @RequirePermission("jobs.dispatch")
25
- dispatch(@CurrentUser() user: UserContext) {
26
- return this.queue.dispatch(user.id);
27
- }
28
- }
@@ -1,23 +0,0 @@
1
- import { Module } from "@nestjs/common";
2
- import { JwtModule } from "@nestjs/jwt";
3
- import { BullModule } from "@nestjs/bullmq";
4
- import { PrismaService } from "../common/prisma.service";
5
- import { AuthGuard } from "../common/auth.guard";
6
- import { PermissionsGuard } from "../common/permissions.guard";
7
- import { CaslAbilityFactory } from "../common/casl-ability.factory";
8
- import { QueueController } from "./queue.controller";
9
- import { QueueService } from "./queue.service";
10
- import { QueueProcessor } from "./queue.processor";
11
-
12
- @Module({
13
- imports: [
14
- JwtModule.register({}),
15
- BullModule.forRoot({
16
- connection: { url: process.env.REDIS_URL ?? "redis://127.0.0.1:6379" }
17
- }),
18
- BullModule.registerQueue({ name: "default" })
19
- ],
20
- controllers: [QueueController],
21
- providers: [QueueService, QueueProcessor, PrismaService, AuthGuard, PermissionsGuard, CaslAbilityFactory]
22
- })
23
- export class QueueModule {}
@@ -1,47 +0,0 @@
1
- import { Processor, WorkerHost } from "@nestjs/bullmq";
2
- import { Logger } from "@nestjs/common";
3
- import type { Job } from "bullmq";
4
- import { PrismaService } from "../common/prisma.service";
5
-
6
- @Processor("default")
7
- export class QueueProcessor extends WorkerHost {
8
- private readonly logger = new Logger(QueueProcessor.name);
9
-
10
- constructor(private readonly prisma: PrismaService) {
11
- super();
12
- }
13
-
14
- async process(job: Job<{ initiatedBy?: string; at?: string }>) {
15
- await this.prisma.jobLog.create({
16
- data: {
17
- name: job.name,
18
- status: "processing",
19
- payload: { queueJobId: job.id, ...job.data }
20
- }
21
- });
22
-
23
- try {
24
- await new Promise((resolve) => setTimeout(resolve, 200));
25
- await this.prisma.jobLog.create({
26
- data: {
27
- name: job.name,
28
- status: "completed",
29
- payload: { queueJobId: job.id, ...job.data }
30
- }
31
- });
32
- return { ok: true };
33
- } catch (error) {
34
- const message = error instanceof Error ? error.message : "Unknown queue error";
35
- await this.prisma.jobLog.create({
36
- data: {
37
- name: job.name,
38
- status: "failed",
39
- error: message,
40
- payload: { queueJobId: job.id, ...job.data }
41
- }
42
- });
43
- this.logger.error(`Job ${job.id} failed`, error instanceof Error ? error.stack : undefined);
44
- throw error;
45
- }
46
- }
47
- }
@@ -1,50 +0,0 @@
1
- import { Injectable, ServiceUnavailableException } from "@nestjs/common";
2
- import { InjectQueue } from "@nestjs/bullmq";
3
- import { Queue } from "bullmq";
4
- import { PrismaService } from "../common/prisma.service";
5
-
6
- @Injectable()
7
- export class QueueService {
8
- constructor(
9
- @InjectQueue("default") private readonly queue: Queue,
10
- private readonly prisma: PrismaService
11
- ) {}
12
-
13
- async getStats() {
14
- const [counts, recent] = await Promise.all([
15
- this.queue.getJobCounts("active", "waiting", "completed", "failed", "delayed"),
16
- this.prisma.jobLog.findMany({ orderBy: { createdAt: "desc" }, take: 10 })
17
- ]);
18
-
19
- return { counts, recent };
20
- }
21
-
22
- async dispatch(userId: string) {
23
- this.ensureRedisConfigured();
24
- const payload = { initiatedBy: userId, at: new Date().toISOString() };
25
- const job = await this.queue.add("maintenance.sync", payload, {
26
- removeOnComplete: 100,
27
- attempts: 3,
28
- backoff: { type: "exponential", delay: 1000 }
29
- });
30
-
31
- await this.prisma.jobLog.create({
32
- data: {
33
- name: "maintenance.sync",
34
- status: "queued",
35
- payload: { ...payload, queueJobId: job.id }
36
- }
37
- });
38
-
39
- return { id: job.id, name: job.name };
40
- }
41
-
42
- private ensureRedisConfigured() {
43
- if (!process.env.REDIS_URL) {
44
- throw new ServiceUnavailableException({
45
- message: "Redis is not configured. Set REDIS_URL to enable queues.",
46
- code: "REDIS_NOT_CONFIGURED"
47
- });
48
- }
49
- }
50
- }
@@ -1,21 +0,0 @@
1
- import { defineResource } from "@openadminjs/core";
2
-
3
- export default defineResource({
4
- name: "categories",
5
- label: "Categories",
6
- model: "category",
7
- titleField: "name",
8
- icon: "Folder",
9
- permissions: {
10
- read: "categories.read",
11
- create: "categories.create",
12
- update: "categories.update",
13
- delete: "categories.delete"
14
- },
15
- fields: {
16
- id: { type: "id", label: "ID", create: false, edit: false, list: false },
17
- name: { type: "text", label: "Name", required: true, searchable: true, sortable: true },
18
- slug: { type: "slug", label: "Slug", from: "name", searchable: true },
19
- createdAt: { type: "datetime", label: "Created at", create: false, edit: false, sortable: true }
20
- }
21
- });
@@ -1,157 +0,0 @@
1
- import type { PrismaClient } from "@prisma/client";
2
- import { defineResource } from "@openadminjs/core";
3
-
4
- export const productsResource = defineResource({
5
- name: "products",
6
- label: { en: "Products", ru: "Товары" },
7
- model: "product",
8
- titleField: "name",
9
- icon: "ShoppingBag",
10
- i18n: { defaultLocale: "en", locales: ["en", "ru"] },
11
- permissions: {
12
- read: "products.read",
13
- create: "products.create",
14
- update: "products.update",
15
- delete: "products.delete"
16
- },
17
- fields: {
18
- id: { type: "id", label: "ID", create: false, edit: false, list: false },
19
- name: { type: "text", label: { en: "Name", ru: "Название" }, required: true, searchable: true, maxLength: 200 },
20
- slug: { type: "slug", label: "Slug", required: true, maxLength: 200 },
21
- description: { type: "textarea", label: { en: "Description", ru: "Описание" }, list: false },
22
- price: {
23
- type: "number",
24
- label: { en: "Price (cents)", ru: "Цена (копейки)" },
25
- required: true,
26
- min: 0,
27
- filterable: true,
28
- sortable: true
29
- },
30
- currency: {
31
- type: "select",
32
- label: "Currency",
33
- options: ["USD", "EUR", "GBP", "RUB", "UAH"],
34
- required: true
35
- },
36
- active: { type: "boolean", label: { en: "Active", ru: "Активен" }, filterable: true, sortable: true },
37
- imageUrl: { type: "url", label: { en: "Image URL", ru: "URL изображения" }, list: false },
38
- metadata: { type: "json", label: "Metadata", list: false },
39
- createdAt: { type: "datetime", label: { en: "Created", ru: "Создан" }, create: false, edit: false, sortable: true }
40
- }
41
- });
42
-
43
- export const ordersResource = defineResource({
44
- name: "orders",
45
- label: { en: "Orders", ru: "Заказы" },
46
- model: "order",
47
- titleField: "id",
48
- icon: "Receipt",
49
- i18n: { defaultLocale: "en", locales: ["en", "ru"] },
50
- permissions: {
51
- read: "orders.read",
52
- update: "orders.update",
53
- refund: "orders.refund"
54
- },
55
- fields: {
56
- id: { type: "id", label: "ID", create: false, edit: false },
57
- email: { type: "email", label: { en: "Email", ru: "Email" }, searchable: true, edit: false },
58
- status: {
59
- type: "badge",
60
- label: { en: "Status", ru: "Статус" },
61
- options: ["pending", "paid", "failed", "refunded", "cancelled"],
62
- filterable: true,
63
- sortable: true
64
- },
65
- total: { type: "number", label: { en: "Total (cents)", ru: "Итог (копейки)" }, edit: false, sortable: true, filterable: true },
66
- currency: { type: "text", label: "Currency", edit: false },
67
- notes: { type: "textarea", label: { en: "Notes", ru: "Заметки" }, list: false },
68
- createdAt: { type: "datetime", label: { en: "Created", ru: "Создан" }, create: false, edit: false, sortable: true }
69
- },
70
- actions: {
71
- refund: {
72
- label: { en: "Refund", ru: "Возврат" },
73
- variant: "destructive",
74
- confirm: true,
75
- permission: "orders.refund",
76
- async handler(ctx) {
77
- const db = ctx.prisma as PrismaClient;
78
- const order = await db.order.findUnique({
79
- where: { id: ctx.id },
80
- include: { transactions: true }
81
- });
82
- if (!order || order.status !== "paid") {
83
- throw new Error("Order is not paid or not found");
84
- }
85
- return db.order.update({ where: { id: ctx.id }, data: { status: "refunded" } });
86
- }
87
- },
88
- cancel: {
89
- label: { en: "Cancel", ru: "Отменить" },
90
- variant: "destructive",
91
- confirm: true,
92
- permission: "orders.update",
93
- async handler(ctx) {
94
- const db = ctx.prisma as PrismaClient;
95
- return db.order.update({
96
- where: { id: ctx.id },
97
- data: { status: "cancelled" }
98
- });
99
- }
100
- }
101
- }
102
- });
103
-
104
- export const transactionsResource = defineResource({
105
- name: "transactions",
106
- label: { en: "Transactions", ru: "Транзакции" },
107
- model: "transaction",
108
- titleField: "id",
109
- icon: "CreditCard",
110
- i18n: { defaultLocale: "en", locales: ["en", "ru"] },
111
- permissions: {
112
- read: "transactions.read"
113
- },
114
- fields: {
115
- id: { type: "id", label: "ID", create: false, edit: false },
116
- provider: { type: "badge", label: { en: "Provider", ru: "Провайдер" }, create: false, edit: false, filterable: true },
117
- providerTxId: { type: "text", label: { en: "Provider TX ID", ru: "ID транзакции" }, create: false, edit: false },
118
- status: {
119
- type: "badge",
120
- label: { en: "Status", ru: "Статус" },
121
- options: ["pending", "succeeded", "failed", "refunded"],
122
- create: false,
123
- edit: false,
124
- filterable: true,
125
- sortable: true
126
- },
127
- amount: { type: "number", label: { en: "Amount (cents)", ru: "Сумма (копейки)" }, create: false, edit: false, sortable: true },
128
- currency: { type: "text", label: "Currency", create: false, edit: false },
129
- createdAt: { type: "datetime", label: { en: "Created", ru: "Создан" }, create: false, edit: false, sortable: true }
130
- }
131
- });
132
-
133
- export const webhookLogsResource = defineResource({
134
- name: "webhook-logs",
135
- label: { en: "Webhook Logs", ru: "Вебхук Логи" },
136
- model: "webhookLog",
137
- titleField: "eventType",
138
- icon: "Webhook",
139
- permissions: {
140
- read: "webhook-logs.read"
141
- },
142
- fields: {
143
- id: { type: "id", label: "ID", create: false, edit: false, list: false },
144
- provider: { type: "badge", label: "Provider", create: false, edit: false, filterable: true },
145
- eventType: { type: "text", label: { en: "Event Type", ru: "Тип события" }, create: false, edit: false, searchable: true },
146
- status: {
147
- type: "badge",
148
- label: "Status",
149
- options: ["pending", "processed", "failed"],
150
- create: false,
151
- edit: false,
152
- filterable: true
153
- },
154
- error: { type: "textarea", label: "Error", create: false, edit: false, list: false },
155
- createdAt: { type: "datetime", label: { en: "Received", ru: "Получен" }, create: false, edit: false, sortable: true }
156
- }
157
- });
@@ -1,111 +0,0 @@
1
- import type { PrismaClient } from "@prisma/client";
2
- import { defineResource } from "@openadminjs/core";
3
-
4
- export const apiTokensResource = defineResource({
5
- name: "api-tokens",
6
- label: { en: "API tokens", ru: "API-токены" },
7
- model: "apiToken",
8
- titleField: "name",
9
- icon: "KeyRound",
10
- i18n: { defaultLocale: "en", locales: ["en", "ru"] },
11
- permissions: {
12
- read: "api-tokens.read",
13
- create: "api-tokens.create",
14
- delete: "api-tokens.delete",
15
- revoke: "api-tokens.revoke"
16
- },
17
- fields: {
18
- id: { type: "id", label: "ID", create: false, edit: false, list: false },
19
- name: { type: "text", label: { en: "Name", ru: "Имя" }, searchable: true },
20
- scopes: { type: "json", label: "Scopes", create: true, edit: false },
21
- tokenHash: { type: "hidden", label: "Token hash" },
22
- revokedAt: { type: "datetime", label: { en: "Revoked at", ru: "Отозван" }, create: false, edit: false },
23
- createdAt: { type: "datetime", label: { en: "Created", ru: "Создан" }, create: false, edit: false, sortable: true }
24
- },
25
- actions: {
26
- revoke: {
27
- label: { en: "Revoke", ru: "Отозвать" },
28
- variant: "destructive",
29
- confirm: true,
30
- permission: "api-tokens.revoke",
31
- async handler(ctx) {
32
- const db = ctx.prisma as PrismaClient;
33
- return db.apiToken.update({
34
- where: { id: ctx.id },
35
- data: { revokedAt: new Date() }
36
- });
37
- }
38
- }
39
- }
40
- });
41
-
42
- export const notificationsResource = defineResource({
43
- name: "notifications",
44
- label: { en: "Notifications", ru: "Уведомления" },
45
- model: "notification",
46
- titleField: "title",
47
- icon: "Bell",
48
- i18n: { defaultLocale: "en", locales: ["en", "ru"] },
49
- listScope: {
50
- type: "userOwns",
51
- field: "userId",
52
- bypassPermissions: ["notifications.read.all", "*"]
53
- },
54
- permissions: {
55
- read: "notifications.read",
56
- create: "notifications.create",
57
- update: "notifications.update",
58
- delete: "notifications.delete",
59
- markRead: "notifications.update"
60
- },
61
- fields: {
62
- id: { type: "id", label: "ID", create: false, edit: false, list: false },
63
- title: { type: "text", label: { en: "Title", ru: "Заголовок" }, searchable: true },
64
- body: { type: "textarea", label: { en: "Body", ru: "Текст" }, list: false },
65
- readAt: { type: "datetime", label: { en: "Read at", ru: "Прочитано" }, create: false, edit: false },
66
- createdAt: { type: "datetime", label: { en: "Created", ru: "Создано" }, create: false, edit: false, sortable: true }
67
- },
68
- actions: {
69
- "mark-read": {
70
- label: { en: "Mark read", ru: "Прочитано" },
71
- variant: "primary",
72
- permission: "notifications.update",
73
- async handler(ctx) {
74
- const db = ctx.prisma as PrismaClient;
75
- return db.notification.update({
76
- where: { id: ctx.id },
77
- data: { readAt: new Date() }
78
- });
79
- }
80
- },
81
- "mark-unread": {
82
- label: { en: "Mark unread", ru: "Не прочитано" },
83
- variant: "default",
84
- permission: "notifications.update",
85
- async handler(ctx) {
86
- const db = ctx.prisma as PrismaClient;
87
- return db.notification.update({
88
- where: { id: ctx.id },
89
- data: { readAt: null }
90
- });
91
- }
92
- }
93
- }
94
- });
95
-
96
- export const jobLogsResource = defineResource({
97
- name: "job-logs",
98
- label: "Job Logs",
99
- model: "jobLog",
100
- titleField: "name",
101
- icon: "Gauge",
102
- permissions: { read: "jobs.read" },
103
- fields: {
104
- id: { type: "id", label: "ID", create: false, edit: false, list: false },
105
- name: { type: "text", label: "Job", searchable: true },
106
- status: { type: "badge", label: "Status", filterable: true },
107
- payload: { type: "json", label: "Payload", list: false },
108
- error: { type: "textarea", label: "Error", list: false },
109
- createdAt: { type: "datetime", label: "Created", create: false, edit: false, sortable: true }
110
- }
111
- });