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.
- package/README.md +16 -113
- package/dist/create-project.d.ts +34 -0
- package/dist/create-project.js +245 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +138 -0
- package/dist/index.test.d.ts +1 -0
- package/dist/index.test.js +7 -0
- package/dist/resource-slug.d.ts +2 -0
- package/dist/resource-slug.js +4 -0
- package/dist/resource-slug.test.d.ts +1 -0
- package/dist/resource-slug.test.js +9 -0
- package/package.json +35 -24
- package/.env.example +0 -9
- package/.github/FUNDING.yml +0 -3
- package/.github/ISSUE_TEMPLATE/bug_report.yml +0 -10
- package/.github/ISSUE_TEMPLATE/feature_request.yml +0 -10
- package/.github/PULL_REQUEST_TEMPLATE.md +0 -9
- package/.github/dependabot.yml +0 -10
- package/.github/workflows/ci.yml +0 -26
- package/CHANGELOG.md +0 -5
- package/CODE_OF_CONDUCT.md +0 -3
- package/CONTRIBUTING.md +0 -11
- package/LICENSE +0 -21
- package/ROADMAP.md +0 -7
- package/SECURITY.md +0 -11
- package/apps/admin/app/api/auth/login/route.ts +0 -51
- package/apps/admin/app/api/auth/logout/route.ts +0 -11
- package/apps/admin/app/api/auth/refresh/route.ts +0 -46
- package/apps/admin/app/api-tokens/page.tsx +0 -253
- package/apps/admin/app/audit-logs/page.tsx +0 -5
- package/apps/admin/app/dashboard/page.tsx +0 -392
- package/apps/admin/app/files/page.tsx +0 -5
- package/apps/admin/app/globals.css +0 -206
- package/apps/admin/app/jobs/page.tsx +0 -19
- package/apps/admin/app/layout.tsx +0 -57
- package/apps/admin/app/login/page.test.tsx +0 -18
- package/apps/admin/app/login/page.tsx +0 -161
- package/apps/admin/app/login/safe-next-param.ts +0 -4
- package/apps/admin/app/notifications/page.tsx +0 -146
- package/apps/admin/app/page.tsx +0 -5
- package/apps/admin/app/plugins/page.tsx +0 -407
- package/apps/admin/app/profile/page.tsx +0 -116
- package/apps/admin/app/resources/[resource]/[id]/edit/page.tsx +0 -45
- package/apps/admin/app/resources/[resource]/[id]/page.tsx +0 -449
- package/apps/admin/app/resources/[resource]/create/page.tsx +0 -34
- package/apps/admin/app/resources/[resource]/page.tsx +0 -100
- package/apps/admin/app/settings/page.tsx +0 -233
- package/apps/admin/components/ai-assistant-widget.tsx +0 -684
- package/apps/admin/components/app-shell.tsx +0 -305
- package/apps/admin/components/auth-guard.test.tsx +0 -55
- package/apps/admin/components/auth-guard.tsx +0 -39
- package/apps/admin/components/jobs-panel.tsx +0 -103
- package/apps/admin/components/logo.tsx +0 -30
- package/apps/admin/components/resource-form.tsx +0 -349
- package/apps/admin/components/resource-table.tsx +0 -277
- package/apps/admin/lib/ai-events.ts +0 -23
- package/apps/admin/lib/api.test.ts +0 -118
- package/apps/admin/lib/api.ts +0 -135
- package/apps/admin/lib/auth-flow.e2e.test.ts +0 -79
- package/apps/admin/lib/brand.ts +0 -14
- package/apps/admin/lib/locale.ts +0 -49
- package/apps/admin/lib/tokens.ts +0 -93
- package/apps/admin/middleware.ts +0 -58
- package/apps/admin/next-env.d.ts +0 -6
- package/apps/admin/next.config.mjs +0 -7
- package/apps/admin/package.json +0 -44
- package/apps/admin/postcss.config.mjs +0 -6
- package/apps/admin/public/brand/apple-touch-icon.png +0 -0
- package/apps/admin/public/brand/favicon.svg +0 -1
- package/apps/admin/public/brand/og-image.png +0 -0
- package/apps/admin/public/brand/openadminjs-icon-new.png +0 -0
- package/apps/admin/public/brand/openadminjs-logo-monochrome.png +0 -0
- package/apps/admin/public/brand/openadminjs-logo-new.png +0 -0
- package/apps/admin/tailwind.config.ts +0 -37
- package/apps/admin/tsconfig.json +0 -23
- package/apps/admin/vitest.config.ts +0 -7
- package/apps/api/package.json +0 -56
- package/apps/api/plugins.manifest.example.json +0 -34
- package/apps/api/plugins.manifest.json +0 -4
- package/apps/api/src/access/catalog.ts +0 -112
- package/apps/api/src/access/derive-permissions.test.ts +0 -26
- package/apps/api/src/access/derive-permissions.ts +0 -36
- package/apps/api/src/access/public-catalog.ts +0 -28
- package/apps/api/src/admin/admin-ai.controller.ts +0 -125
- package/apps/api/src/admin/admin-ai.events.ts +0 -23
- package/apps/api/src/admin/admin-ai.service.ts +0 -1271
- package/apps/api/src/admin/admin-analytics.service.ts +0 -164
- package/apps/api/src/admin/admin-plugins.controller.ts +0 -32
- package/apps/api/src/admin/admin-plugins.service.ts +0 -267
- package/apps/api/src/admin/admin-resource.service.test.ts +0 -118
- package/apps/api/src/admin/admin-resource.service.ts +0 -375
- package/apps/api/src/admin/admin.controller.ts +0 -72
- package/apps/api/src/admin/admin.module.ts +0 -30
- package/apps/api/src/admin/dto/plugins.dto.ts +0 -55
- package/apps/api/src/admin/validate-resource-payload.test.ts +0 -44
- package/apps/api/src/admin/validate-resource-payload.ts +0 -103
- package/apps/api/src/app.module.ts +0 -45
- package/apps/api/src/auth/auth.controller.ts +0 -70
- package/apps/api/src/auth/auth.dto.ts +0 -49
- package/apps/api/src/auth/auth.module.ts +0 -30
- package/apps/api/src/auth/auth.service.test.ts +0 -75
- package/apps/api/src/auth/auth.service.ts +0 -231
- package/apps/api/src/common/auth-realm.decorator.ts +0 -6
- package/apps/api/src/common/auth.guard.test.ts +0 -61
- package/apps/api/src/common/auth.guard.ts +0 -78
- package/apps/api/src/common/casl-ability.factory.test.ts +0 -33
- package/apps/api/src/common/casl-ability.factory.ts +0 -41
- package/apps/api/src/common/current-user.decorator.ts +0 -6
- package/apps/api/src/common/permission.decorator.ts +0 -7
- package/apps/api/src/common/permissions.guard.ts +0 -31
- package/apps/api/src/common/prisma.service.ts +0 -13
- package/apps/api/src/health/health.controller.ts +0 -25
- package/apps/api/src/mail/mail.module.ts +0 -9
- package/apps/api/src/mail/mail.service.ts +0 -115
- package/apps/api/src/main.ts +0 -37
- package/apps/api/src/plugins/bootstrap.ts +0 -4
- package/apps/api/src/plugins/bundled/admin-widget.plugin.ts +0 -25
- package/apps/api/src/plugins/bundled/hello.plugin.ts +0 -19
- package/apps/api/src/plugins/bundled/image-optimizer.plugin.ts +0 -22
- package/apps/api/src/plugins/bundled/registry.ts +0 -13
- package/apps/api/src/plugins/bundled/seo.plugin.ts +0 -25
- package/apps/api/src/plugins/manifest-path.ts +0 -35
- package/apps/api/src/plugins/manifest.schema.test.ts +0 -36
- package/apps/api/src/plugins/manifest.schema.ts +0 -58
- package/apps/api/src/plugins/plugin-api.interceptor.ts +0 -47
- package/apps/api/src/plugins/plugin-loader.ts +0 -134
- package/apps/api/src/plugins/plugin-runtime.test.ts +0 -24
- package/apps/api/src/plugins/plugin-runtime.ts +0 -85
- package/apps/api/src/queue/queue.controller.ts +0 -28
- package/apps/api/src/queue/queue.module.ts +0 -23
- package/apps/api/src/queue/queue.processor.ts +0 -47
- package/apps/api/src/queue/queue.service.ts +0 -50
- package/apps/api/src/resources/categories.resource.ts +0 -21
- package/apps/api/src/resources/commerce.resource.ts +0 -157
- package/apps/api/src/resources/operations.resource.ts +0 -111
- package/apps/api/src/resources/posts.resource.ts +0 -88
- package/apps/api/src/resources/registry.ts +0 -27
- package/apps/api/src/resources/resource-hooks.install.ts +0 -18
- package/apps/api/src/resources/resource-hooks.registry.test.ts +0 -72
- package/apps/api/src/resources/resource-hooks.registry.ts +0 -66
- package/apps/api/src/resources/resource-hooks.runner.ts +0 -93
- package/apps/api/src/resources/system.resource.ts +0 -51
- package/apps/api/src/resources/users.resource.ts +0 -19
- package/apps/api/src/store/payment/payment.controller.ts +0 -98
- package/apps/api/src/store/payment/payment.module.ts +0 -14
- package/apps/api/src/store/payment/payment.provider.ts +0 -38
- package/apps/api/src/store/payment/payment.service.ts +0 -235
- package/apps/api/src/store/store.controller.ts +0 -26
- package/apps/api/src/store/store.module.ts +0 -12
- package/apps/api/src/test-setup.ts +0 -1
- package/apps/api/tsconfig.json +0 -11
- package/apps/api/vitest.config.ts +0 -21
- package/apps/web/README.md +0 -12
- package/apps/web/app/globals.css +0 -12
- package/apps/web/app/layout.tsx +0 -18
- package/apps/web/app/page.tsx +0 -27
- package/apps/web/app/posts/[slug]/page.tsx +0 -38
- package/apps/web/app/posts/page.tsx +0 -20
- package/apps/web/app/robots.txt/route.ts +0 -9
- package/apps/web/app/sitemap.xml/route.ts +0 -20
- package/apps/web/components/public-fields.tsx +0 -22
- package/apps/web/lib/openadmin-client.ts +0 -82
- package/apps/web/lib/seo.test.ts +0 -41
- package/apps/web/lib/seo.ts +0 -53
- package/apps/web/next-env.d.ts +0 -6
- package/apps/web/next.config.mjs +0 -5
- package/apps/web/package.json +0 -30
- package/apps/web/postcss.config.mjs +0 -6
- package/apps/web/public/brand/apple-touch-icon.png +0 -0
- package/apps/web/public/brand/favicon.svg +0 -1
- package/apps/web/public/brand/og-image.png +0 -0
- package/apps/web/public/brand/openadminjs-icon-new.png +0 -0
- package/apps/web/public/brand/openadminjs-logo-monochrome.png +0 -0
- package/apps/web/public/brand/openadminjs-logo-new.png +0 -0
- package/apps/web/tailwind.config.ts +0 -21
- package/apps/web/test/next-stub.ts +0 -7
- package/apps/web/tsconfig.json +0 -23
- package/apps/web/vitest.config.ts +0 -19
- package/docs/content/security.md +0 -7
- package/eslint.config.mjs +0 -11
- package/examples/README.md +0 -80
- package/examples/basic-admin/README.md +0 -24
- package/examples/basic-admin/package.json +0 -17
- package/examples/basic-admin/prisma/models.fragment.prisma +0 -12
- package/examples/basic-admin/src/index.test.ts +0 -8
- package/examples/basic-admin/src/index.ts +0 -5
- package/examples/basic-admin/src/resources/lead.resource.ts +0 -30
- package/examples/basic-admin/tsconfig.json +0 -7
- package/examples/basic-admin/vitest.config.ts +0 -16
- package/examples/blog-admin/README.md +0 -18
- package/examples/blog-admin/package.json +0 -17
- package/examples/blog-admin/prisma/models.fragment.prisma +0 -30
- package/examples/blog-admin/src/index.test.ts +0 -8
- package/examples/blog-admin/src/index.ts +0 -5
- package/examples/blog-admin/src/resources/authors.resource.ts +0 -21
- package/examples/blog-admin/src/resources/tags.resource.ts +0 -20
- package/examples/blog-admin/tsconfig.json +0 -7
- package/examples/blog-admin/vitest.config.ts +0 -16
- package/examples/crm-admin/README.md +0 -17
- package/examples/crm-admin/package.json +0 -17
- package/examples/crm-admin/prisma/models.fragment.prisma +0 -50
- package/examples/crm-admin/src/index.test.ts +0 -9
- package/examples/crm-admin/src/index.ts +0 -7
- package/examples/crm-admin/src/resources/activities.resource.ts +0 -29
- package/examples/crm-admin/src/resources/companies.resource.ts +0 -21
- package/examples/crm-admin/src/resources/contacts.resource.ts +0 -24
- package/examples/crm-admin/src/resources/deals.resource.ts +0 -30
- package/examples/crm-admin/tsconfig.json +0 -7
- package/examples/crm-admin/vitest.config.ts +0 -16
- package/examples/ecommerce-admin/README.md +0 -17
- package/examples/ecommerce-admin/package.json +0 -17
- package/examples/ecommerce-admin/prisma/models.fragment.prisma +0 -43
- package/examples/ecommerce-admin/src/index.test.ts +0 -8
- package/examples/ecommerce-admin/src/index.ts +0 -7
- package/examples/ecommerce-admin/src/resources/customers.resource.ts +0 -21
- package/examples/ecommerce-admin/src/resources/order-items.resource.ts +0 -22
- package/examples/ecommerce-admin/src/resources/orders.resource.ts +0 -27
- package/examples/ecommerce-admin/src/resources/products.resource.ts +0 -23
- package/examples/ecommerce-admin/tsconfig.json +0 -7
- package/examples/ecommerce-admin/vitest.config.ts +0 -16
- package/examples/marketplace-admin/README.md +0 -17
- package/examples/marketplace-admin/package.json +0 -17
- package/examples/marketplace-admin/prisma/models.fragment.prisma +0 -32
- package/examples/marketplace-admin/src/index.test.ts +0 -8
- package/examples/marketplace-admin/src/index.ts +0 -6
- package/examples/marketplace-admin/src/resources/listings.resource.ts +0 -29
- package/examples/marketplace-admin/src/resources/payouts.resource.ts +0 -28
- package/examples/marketplace-admin/src/resources/sellers.resource.ts +0 -28
- package/examples/marketplace-admin/tsconfig.json +0 -7
- package/examples/marketplace-admin/vitest.config.ts +0 -16
- package/examples/support-admin/README.md +0 -18
- package/examples/support-admin/package.json +0 -17
- package/examples/support-admin/prisma/models.fragment.prisma +0 -20
- package/examples/support-admin/src/index.test.ts +0 -8
- package/examples/support-admin/src/index.ts +0 -5
- package/examples/support-admin/src/resources/ticket-messages.resource.ts +0 -22
- package/examples/support-admin/src/resources/tickets.resource.ts +0 -35
- package/examples/support-admin/tsconfig.json +0 -7
- package/examples/support-admin/vitest.config.ts +0 -16
- package/packages/auth/package.json +0 -17
- package/packages/auth/src/index.test.ts +0 -10
- package/packages/auth/src/index.ts +0 -17
- package/packages/auth/tsconfig.json +0 -8
- package/packages/brand/apps/admin/public/brand/apple-touch-icon.png +0 -0
- package/packages/brand/apps/admin/public/brand/favicon.svg +0 -1
- package/packages/brand/apps/admin/public/brand/og-image.png +0 -0
- package/packages/brand/apps/admin/public/brand/openadminjs-icon-new.png +0 -0
- package/packages/brand/apps/admin/public/brand/openadminjs-logo-monochrome.png +0 -0
- package/packages/brand/apps/admin/public/brand/openadminjs-logo-new.png +0 -0
- package/packages/brand/apps/web/public/brand/apple-touch-icon.png +0 -0
- package/packages/brand/apps/web/public/brand/favicon.svg +0 -1
- package/packages/brand/apps/web/public/brand/og-image.png +0 -0
- package/packages/brand/apps/web/public/brand/openadminjs-icon-new.png +0 -0
- package/packages/brand/apps/web/public/brand/openadminjs-logo-monochrome.png +0 -0
- package/packages/brand/apps/web/public/brand/openadminjs-logo-new.png +0 -0
- package/packages/brand/package.json +0 -19
- package/packages/brand/site/assets/brand/favicon.svg +0 -1
- package/packages/brand/site/assets/brand/og-image.svg +0 -1
- package/packages/brand/site/assets/brand/openadminjs-icon.svg +0 -1
- package/packages/brand/site/assets/brand/openadminjs-logo-dark.svg +0 -1
- package/packages/brand/site/assets/brand/openadminjs-logo-horizontal.svg +0 -1
- package/packages/brand/site/assets/brand/openadminjs-logo-monochrome.svg +0 -1
- package/packages/brand/site/assets/brand/openadminjs-logo.svg +0 -1
- package/packages/brand/src/generate-assets.mjs +0 -182
- package/packages/brand/src/index.test.ts +0 -9
- package/packages/brand/src/index.ts +0 -7
- package/packages/brand/tsconfig.json +0 -7
- package/packages/cli/package.json +0 -44
- package/packages/cli/src/create-project.ts +0 -316
- package/packages/cli/src/index.test.ts +0 -8
- package/packages/cli/src/index.ts +0 -149
- package/packages/cli/src/resource-slug.test.ts +0 -10
- package/packages/cli/src/resource-slug.ts +0 -4
- package/packages/cli/template/.env.example +0 -6
- package/packages/cli/template/README.md +0 -13
- package/packages/cli/template/apps/web/README.md +0 -12
- package/packages/cli/template/apps/web/app/globals.css +0 -12
- package/packages/cli/template/apps/web/app/layout.tsx +0 -18
- package/packages/cli/template/apps/web/app/page.tsx +0 -27
- package/packages/cli/template/apps/web/app/posts/[slug]/page.tsx +0 -38
- package/packages/cli/template/apps/web/app/posts/page.tsx +0 -20
- package/packages/cli/template/apps/web/app/robots.txt/route.ts +0 -9
- package/packages/cli/template/apps/web/app/sitemap.xml/route.ts +0 -20
- package/packages/cli/template/apps/web/components/public-fields.tsx +0 -22
- package/packages/cli/template/apps/web/lib/openadmin-client.ts +0 -71
- package/packages/cli/template/apps/web/lib/seo.ts +0 -42
- package/packages/cli/template/apps/web/next-env.d.ts +0 -2
- package/packages/cli/template/apps/web/next.config.mjs +0 -5
- package/packages/cli/template/apps/web/package.json +0 -29
- package/packages/cli/template/apps/web/postcss.config.mjs +0 -6
- package/packages/cli/template/apps/web/public/brand/apple-touch-icon.png +0 -0
- package/packages/cli/template/apps/web/public/brand/favicon.svg +0 -1
- package/packages/cli/template/apps/web/public/brand/og-image.png +0 -0
- package/packages/cli/template/apps/web/public/brand/openadminjs-icon-new.png +0 -0
- package/packages/cli/template/apps/web/public/brand/openadminjs-logo-monochrome.png +0 -0
- package/packages/cli/template/apps/web/public/brand/openadminjs-logo-new.png +0 -0
- package/packages/cli/template/apps/web/tailwind.config.ts +0 -21
- package/packages/cli/template/apps/web/tsconfig.json +0 -23
- package/packages/cli/template/package.json +0 -19
- package/packages/cli/template/pnpm-workspace.yaml +0 -3
- package/packages/cli/tsconfig.json +0 -10
- package/packages/core/package.json +0 -20
- package/packages/core/src/index.js +0 -1
- package/packages/core/src/index.test.ts +0 -27
- package/packages/core/src/index.ts +0 -61
- package/packages/core/tsconfig.json +0 -8
- package/packages/create-openadminjs/package.json +0 -25
- package/packages/create-openadminjs/src/index.ts +0 -122
- package/packages/create-openadminjs/src/package-name.test.ts +0 -13
- package/packages/create-openadminjs/src/package-name.ts +0 -8
- package/packages/create-openadminjs/src/render-files.test.ts +0 -26
- package/packages/create-openadminjs/src/render-files.ts +0 -21
- package/packages/create-openadminjs/template/.env.example +0 -7
- package/packages/create-openadminjs/template/README.md +0 -13
- package/packages/create-openadminjs/template/apps/web/README.md +0 -12
- package/packages/create-openadminjs/template/apps/web/app/globals.css +0 -12
- package/packages/create-openadminjs/template/apps/web/app/layout.tsx +0 -18
- package/packages/create-openadminjs/template/apps/web/app/page.tsx +0 -27
- package/packages/create-openadminjs/template/apps/web/app/posts/[slug]/page.tsx +0 -38
- package/packages/create-openadminjs/template/apps/web/app/posts/page.tsx +0 -20
- package/packages/create-openadminjs/template/apps/web/app/robots.txt/route.ts +0 -9
- package/packages/create-openadminjs/template/apps/web/app/sitemap.xml/route.ts +0 -20
- package/packages/create-openadminjs/template/apps/web/components/public-fields.tsx +0 -22
- package/packages/create-openadminjs/template/apps/web/lib/openadmin-client.ts +0 -71
- package/packages/create-openadminjs/template/apps/web/lib/seo.ts +0 -42
- package/packages/create-openadminjs/template/apps/web/next-env.d.ts +0 -2
- package/packages/create-openadminjs/template/apps/web/next.config.mjs +0 -5
- package/packages/create-openadminjs/template/apps/web/package.json +0 -29
- package/packages/create-openadminjs/template/apps/web/postcss.config.mjs +0 -6
- package/packages/create-openadminjs/template/apps/web/public/brand/apple-touch-icon.png +0 -0
- package/packages/create-openadminjs/template/apps/web/public/brand/favicon.svg +0 -1
- package/packages/create-openadminjs/template/apps/web/public/brand/og-image.png +0 -0
- package/packages/create-openadminjs/template/apps/web/public/brand/openadminjs-icon-new.png +0 -0
- package/packages/create-openadminjs/template/apps/web/public/brand/openadminjs-logo-monochrome.png +0 -0
- package/packages/create-openadminjs/template/apps/web/public/brand/openadminjs-logo-new.png +0 -0
- package/packages/create-openadminjs/template/apps/web/tailwind.config.ts +0 -21
- package/packages/create-openadminjs/template/apps/web/tsconfig.json +0 -23
- package/packages/create-openadminjs/template/package.json +0 -19
- package/packages/create-openadminjs/template/pnpm-workspace.yaml +0 -3
- package/packages/create-openadminjs/tsconfig.json +0 -10
- package/packages/mail/package.json +0 -18
- package/packages/mail/src/index.test.ts +0 -23
- package/packages/mail/src/index.ts +0 -246
- package/packages/mail/tsconfig.json +0 -5
- package/packages/notifications/package.json +0 -16
- package/packages/notifications/src/index.test.ts +0 -9
- package/packages/notifications/src/index.ts +0 -5
- package/packages/notifications/tsconfig.json +0 -5
- package/packages/payments/package.json +0 -15
- package/packages/payments/src/index.ts +0 -256
- package/packages/payments/tsconfig.json +0 -9
- package/packages/permissions/package.json +0 -17
- package/packages/permissions/src/blueprints.js +0 -57
- package/packages/permissions/src/blueprints.test.ts +0 -62
- package/packages/permissions/src/blueprints.ts +0 -89
- package/packages/permissions/src/index.js +0 -11
- package/packages/permissions/src/index.test.ts +0 -34
- package/packages/permissions/src/index.ts +0 -22
- package/packages/permissions/tsconfig.json +0 -8
- package/packages/plugin-sdk/package.json +0 -26
- package/packages/plugin-sdk/src/hooks.ts +0 -135
- package/packages/plugin-sdk/src/index.ts +0 -42
- package/packages/plugin-sdk/src/sdk.test.ts +0 -13
- package/packages/plugin-sdk/tsconfig.json +0 -8
- package/packages/plugin-sdk/vitest.config.ts +0 -5
- package/packages/queue/package.json +0 -16
- package/packages/queue/src/index.test.ts +0 -12
- package/packages/queue/src/index.ts +0 -6
- package/packages/queue/tsconfig.json +0 -5
- package/packages/resource/package.json +0 -17
- package/packages/resource/src/index.js +0 -177
- package/packages/resource/src/index.test.ts +0 -151
- package/packages/resource/src/index.ts +0 -344
- package/packages/resource/tsconfig.json +0 -8
- package/packages/storage/package.json +0 -16
- package/packages/storage/src/index.test.ts +0 -10
- package/packages/storage/src/index.ts +0 -23
- package/packages/storage/tsconfig.json +0 -5
- package/pnpm-workspace.yaml +0 -4
- package/prisma/migrations/20260505151751_baseline_init_all_tables/migration.sql +0 -371
- package/prisma/migrations/migration_lock.toml +0 -3
- package/prisma/schema.prisma +0 -291
- package/prisma/seed.ts +0 -210
- package/scripts/check-static-site.mjs +0 -17
- package/scripts/e2e-smoke.mjs +0 -17
- package/scripts/make-executable.mjs +0 -4
- package/site/.nojekyll +0 -0
- package/site/assets/brand/apple-touch-icon.png +0 -0
- package/site/assets/brand/favicon.svg +0 -1
- package/site/assets/brand/og-image.png +0 -0
- package/site/assets/brand/openadminjs-icon-new.png +0 -0
- package/site/assets/brand/openadminjs-logo-monochrome.png +0 -0
- package/site/assets/brand/openadminjs-logo-new.png +0 -0
- package/site/assets/css/styles.css +0 -1521
- package/site/assets/js/main.js +0 -193
- package/site/assets/partners/arcbyte.svg +0 -11
- package/site/assets/partners/gridstack.svg +0 -8
- package/site/assets/partners/nebula.svg +0 -12
- package/site/assets/partners/orbitlab.svg +0 -7
- package/site/assets/partners/pulseforge.svg +0 -11
- package/site/assets/partners/vertex.svg +0 -6
- package/site/docs.html +0 -1459
- package/site/index.html +0 -357
- package/tsconfig.base.json +0 -23
|
@@ -1,235 +0,0 @@
|
|
|
1
|
-
import { BadRequestException, Injectable, NotFoundException } from "@nestjs/common";
|
|
2
|
-
import { PrismaService } from "../../common/prisma.service";
|
|
3
|
-
import { PaymentProviderService } from "./payment.provider";
|
|
4
|
-
|
|
5
|
-
export type CreateOrderInput = {
|
|
6
|
-
items: Array<{
|
|
7
|
-
productId?: string;
|
|
8
|
-
name: string;
|
|
9
|
-
price: number;
|
|
10
|
-
quantity: number;
|
|
11
|
-
}>;
|
|
12
|
-
currency?: string;
|
|
13
|
-
email?: string;
|
|
14
|
-
userId?: string;
|
|
15
|
-
notes?: string;
|
|
16
|
-
successUrl: string;
|
|
17
|
-
cancelUrl: string;
|
|
18
|
-
};
|
|
19
|
-
|
|
20
|
-
export type OrderStatusResponse = {
|
|
21
|
-
id: string;
|
|
22
|
-
status: string;
|
|
23
|
-
total: number;
|
|
24
|
-
currency: string;
|
|
25
|
-
items: Array<{ name: string; price: number; quantity: number }>;
|
|
26
|
-
createdAt: Date;
|
|
27
|
-
};
|
|
28
|
-
|
|
29
|
-
@Injectable()
|
|
30
|
-
export class PaymentService {
|
|
31
|
-
constructor(
|
|
32
|
-
private readonly prisma: PrismaService,
|
|
33
|
-
private readonly paymentProvider: PaymentProviderService
|
|
34
|
-
) {}
|
|
35
|
-
|
|
36
|
-
/** Create a new order and return a checkout URL. */
|
|
37
|
-
async createCheckout(input: CreateOrderInput) {
|
|
38
|
-
const { items, currency = "USD", email, userId, notes, successUrl, cancelUrl } = input;
|
|
39
|
-
|
|
40
|
-
if (!items.length) throw new BadRequestException({ message: "Order must contain at least one item", code: "EMPTY_ORDER" });
|
|
41
|
-
|
|
42
|
-
const total = items.reduce((sum, item) => sum + item.price * item.quantity, 0);
|
|
43
|
-
|
|
44
|
-
const order = await this.prisma.$transaction(async (tx) => {
|
|
45
|
-
const created = await tx.order.create({
|
|
46
|
-
data: {
|
|
47
|
-
userId: userId ?? null,
|
|
48
|
-
email: email ?? null,
|
|
49
|
-
currency,
|
|
50
|
-
total,
|
|
51
|
-
notes: notes ?? null,
|
|
52
|
-
status: "pending"
|
|
53
|
-
}
|
|
54
|
-
});
|
|
55
|
-
|
|
56
|
-
await tx.orderItem.createMany({
|
|
57
|
-
data: items.map((item) => ({
|
|
58
|
-
orderId: created.id,
|
|
59
|
-
productId: item.productId ?? null,
|
|
60
|
-
name: item.name,
|
|
61
|
-
price: item.price,
|
|
62
|
-
quantity: item.quantity
|
|
63
|
-
}))
|
|
64
|
-
});
|
|
65
|
-
|
|
66
|
-
return created;
|
|
67
|
-
});
|
|
68
|
-
|
|
69
|
-
const provider = this.paymentProvider.get();
|
|
70
|
-
const checkout = await provider.createCheckout({
|
|
71
|
-
orderId: order.id,
|
|
72
|
-
lineItems: items.map((item) => ({
|
|
73
|
-
name: item.name,
|
|
74
|
-
unitAmount: item.price,
|
|
75
|
-
quantity: item.quantity
|
|
76
|
-
})),
|
|
77
|
-
currency,
|
|
78
|
-
successUrl,
|
|
79
|
-
cancelUrl,
|
|
80
|
-
customerEmail: email
|
|
81
|
-
});
|
|
82
|
-
|
|
83
|
-
// Log the initial transaction attempt
|
|
84
|
-
await this.prisma.transaction.create({
|
|
85
|
-
data: {
|
|
86
|
-
orderId: order.id,
|
|
87
|
-
provider: this.paymentProvider.name,
|
|
88
|
-
providerTxId: checkout.providerSessionId,
|
|
89
|
-
status: "pending",
|
|
90
|
-
amount: total,
|
|
91
|
-
currency,
|
|
92
|
-
metadata: { sessionId: checkout.providerSessionId }
|
|
93
|
-
}
|
|
94
|
-
});
|
|
95
|
-
|
|
96
|
-
return { orderId: order.id, checkoutUrl: checkout.checkoutUrl };
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
/** Process an inbound webhook event from the payment provider. */
|
|
100
|
-
async handleWebhook(provider: string, rawBody: Buffer, signature: string) {
|
|
101
|
-
const logEntry = await this.prisma.webhookLog.create({
|
|
102
|
-
data: { provider, eventType: "unknown", payload: {}, status: "pending" }
|
|
103
|
-
});
|
|
104
|
-
|
|
105
|
-
try {
|
|
106
|
-
const event = await this.paymentProvider.get().verifyWebhook(rawBody, signature);
|
|
107
|
-
|
|
108
|
-
await this.prisma.webhookLog.update({
|
|
109
|
-
where: { id: logEntry.id },
|
|
110
|
-
data: { eventType: event.type, payload: event.raw as object, status: "processed" }
|
|
111
|
-
});
|
|
112
|
-
|
|
113
|
-
if (event.orderId) {
|
|
114
|
-
await this.applyWebhookEvent(event.orderId, event.type, event.providerEventId, event.amount, event.currency);
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
return { received: true, type: event.type };
|
|
118
|
-
} catch (error) {
|
|
119
|
-
await this.prisma.webhookLog.update({
|
|
120
|
-
where: { id: logEntry.id },
|
|
121
|
-
data: { status: "failed", error: error instanceof Error ? error.message : "unknown" }
|
|
122
|
-
});
|
|
123
|
-
throw error;
|
|
124
|
-
}
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
private async applyWebhookEvent(
|
|
128
|
-
orderId: string,
|
|
129
|
-
type: string,
|
|
130
|
-
providerEventId: string,
|
|
131
|
-
amount?: number,
|
|
132
|
-
currency?: string
|
|
133
|
-
) {
|
|
134
|
-
const statusMap: Record<string, string> = {
|
|
135
|
-
"payment.succeeded": "paid",
|
|
136
|
-
"payment.failed": "failed",
|
|
137
|
-
"payment.refunded": "refunded",
|
|
138
|
-
"checkout.expired": "cancelled"
|
|
139
|
-
};
|
|
140
|
-
|
|
141
|
-
const newStatus = statusMap[type];
|
|
142
|
-
if (!newStatus) return;
|
|
143
|
-
|
|
144
|
-
await this.prisma.$transaction(async (tx) => {
|
|
145
|
-
await tx.order.update({ where: { id: orderId }, data: { status: newStatus } });
|
|
146
|
-
await tx.transaction.updateMany({
|
|
147
|
-
where: { orderId, providerTxId: providerEventId },
|
|
148
|
-
data: {
|
|
149
|
-
status: newStatus === "paid" ? "succeeded" : newStatus === "refunded" ? "refunded" : "failed",
|
|
150
|
-
...(amount ? { amount } : {}),
|
|
151
|
-
...(currency ? { currency } : {})
|
|
152
|
-
}
|
|
153
|
-
});
|
|
154
|
-
});
|
|
155
|
-
}
|
|
156
|
-
|
|
157
|
-
/** Get order status (public — by orderId only, no auth needed). */
|
|
158
|
-
async getOrderStatus(orderId: string): Promise<OrderStatusResponse> {
|
|
159
|
-
const order = await this.prisma.order.findUnique({
|
|
160
|
-
where: { id: orderId },
|
|
161
|
-
include: { items: true }
|
|
162
|
-
});
|
|
163
|
-
if (!order) throw new NotFoundException({ message: "Order not found", code: "ORDER_NOT_FOUND" });
|
|
164
|
-
|
|
165
|
-
return {
|
|
166
|
-
id: order.id,
|
|
167
|
-
status: order.status,
|
|
168
|
-
total: order.total,
|
|
169
|
-
currency: order.currency,
|
|
170
|
-
items: order.items.map((item) => ({ name: item.name, price: item.price, quantity: item.quantity })),
|
|
171
|
-
createdAt: order.createdAt
|
|
172
|
-
};
|
|
173
|
-
}
|
|
174
|
-
|
|
175
|
-
/** List orders for the authenticated user. */
|
|
176
|
-
async getUserOrders(userId: string, page = 1, limit = 20) {
|
|
177
|
-
const [data, total] = await Promise.all([
|
|
178
|
-
this.prisma.order.findMany({
|
|
179
|
-
where: { userId },
|
|
180
|
-
include: { items: true },
|
|
181
|
-
orderBy: { createdAt: "desc" },
|
|
182
|
-
skip: (page - 1) * limit,
|
|
183
|
-
take: limit
|
|
184
|
-
}),
|
|
185
|
-
this.prisma.order.count({ where: { userId } })
|
|
186
|
-
]);
|
|
187
|
-
return { data, meta: { page, limit, total, pages: Math.ceil(total / limit) || 1 } };
|
|
188
|
-
}
|
|
189
|
-
|
|
190
|
-
/** Refund an order (admin only). */
|
|
191
|
-
async refundOrder(orderId: string) {
|
|
192
|
-
const order = await this.prisma.order.findUnique({
|
|
193
|
-
where: { id: orderId },
|
|
194
|
-
include: { transactions: true }
|
|
195
|
-
});
|
|
196
|
-
if (!order) throw new NotFoundException({ message: "Order not found", code: "ORDER_NOT_FOUND" });
|
|
197
|
-
if (order.status !== "paid") {
|
|
198
|
-
throw new BadRequestException({ message: `Cannot refund order with status "${order.status}"`, code: "INVALID_ORDER_STATUS" });
|
|
199
|
-
}
|
|
200
|
-
|
|
201
|
-
const successTx = order.transactions.find((tx) => tx.status === "succeeded");
|
|
202
|
-
if (!successTx?.providerTxId) {
|
|
203
|
-
throw new BadRequestException({ message: "No successful transaction found for this order", code: "NO_TRANSACTION" });
|
|
204
|
-
}
|
|
205
|
-
|
|
206
|
-
const refund = await this.paymentProvider.get().refund({
|
|
207
|
-
providerTransactionId: successTx.providerTxId,
|
|
208
|
-
amount: order.total
|
|
209
|
-
});
|
|
210
|
-
|
|
211
|
-
await this.prisma.$transaction(async (tx) => {
|
|
212
|
-
await tx.order.update({ where: { id: orderId }, data: { status: "refunded" } });
|
|
213
|
-
await tx.transaction.create({
|
|
214
|
-
data: {
|
|
215
|
-
orderId,
|
|
216
|
-
provider: this.paymentProvider.name,
|
|
217
|
-
providerTxId: refund.providerRefundId,
|
|
218
|
-
status: "refunded",
|
|
219
|
-
amount: refund.amount,
|
|
220
|
-
currency: order.currency
|
|
221
|
-
}
|
|
222
|
-
});
|
|
223
|
-
});
|
|
224
|
-
|
|
225
|
-
return { ok: true, refundId: refund.providerRefundId };
|
|
226
|
-
}
|
|
227
|
-
|
|
228
|
-
/** List products. */
|
|
229
|
-
async listProducts(onlyActive = true) {
|
|
230
|
-
return this.prisma.product.findMany({
|
|
231
|
-
where: onlyActive ? { active: true } : undefined,
|
|
232
|
-
orderBy: { createdAt: "desc" }
|
|
233
|
-
});
|
|
234
|
-
}
|
|
235
|
-
}
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import { Controller, Get, UseGuards } from "@nestjs/common";
|
|
2
|
-
import { AuthGuard } from "../common/auth.guard";
|
|
3
|
-
import { RequireAuthRealm } from "../common/auth-realm.decorator";
|
|
4
|
-
import { CurrentUser } from "../common/current-user.decorator";
|
|
5
|
-
import type { RequestUser } from "../common/auth.guard";
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
* Example storefront-scoped routes (`Role.realm === "public"`).
|
|
9
|
-
* Add cart/checkout/etc. here or in a dedicated app — checks are the same: JWT realm + permission slugs.
|
|
10
|
-
*/
|
|
11
|
-
@Controller("store")
|
|
12
|
-
@UseGuards(AuthGuard)
|
|
13
|
-
@RequireAuthRealm("public")
|
|
14
|
-
export class StoreController {
|
|
15
|
-
@Get("session")
|
|
16
|
-
session(@CurrentUser() user: RequestUser) {
|
|
17
|
-
return {
|
|
18
|
-
realm: user.realm,
|
|
19
|
-
id: user.id,
|
|
20
|
-
email: user.email,
|
|
21
|
-
name: user.name,
|
|
22
|
-
roles: user.roles,
|
|
23
|
-
permissions: user.permissions
|
|
24
|
-
};
|
|
25
|
-
}
|
|
26
|
-
}
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { Module } from "@nestjs/common";
|
|
2
|
-
import { AuthModule } from "../auth/auth.module";
|
|
3
|
-
import { PrismaService } from "../common/prisma.service";
|
|
4
|
-
import { StoreController } from "./store.controller";
|
|
5
|
-
import { PaymentModule } from "./payment/payment.module";
|
|
6
|
-
|
|
7
|
-
@Module({
|
|
8
|
-
imports: [AuthModule, PaymentModule],
|
|
9
|
-
controllers: [StoreController],
|
|
10
|
-
providers: [PrismaService]
|
|
11
|
-
})
|
|
12
|
-
export class StoreModule {}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import "reflect-metadata";
|
package/apps/api/tsconfig.json
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import { dirname, resolve } from "node:path";
|
|
2
|
-
import { fileURLToPath } from "node:url";
|
|
3
|
-
import { defineConfig } from "vitest/config";
|
|
4
|
-
|
|
5
|
-
const __dirname = dirname(fileURLToPath(import.meta.url));
|
|
6
|
-
const repoRoot = resolve(__dirname, "../..");
|
|
7
|
-
|
|
8
|
-
export default defineConfig({
|
|
9
|
-
test: {
|
|
10
|
-
environment: "node",
|
|
11
|
-
setupFiles: [resolve(__dirname, "src/test-setup.ts")]
|
|
12
|
-
},
|
|
13
|
-
resolve: {
|
|
14
|
-
alias: {
|
|
15
|
-
"@openadminjs/core": resolve(repoRoot, "packages/core/src/index.ts"),
|
|
16
|
-
"@openadminjs/resource": resolve(repoRoot, "packages/resource/src/index.ts"),
|
|
17
|
-
"@openadminjs/permissions": resolve(repoRoot, "packages/permissions/src/index.ts"),
|
|
18
|
-
"@openadminjs/plugin-sdk": resolve(repoRoot, "packages/plugin-sdk/src/index.ts")
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
});
|
package/apps/web/README.md
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
# OpenAdminJS Web Layer
|
|
2
|
-
|
|
3
|
-
This folder is part of the generated application, not the library marketing site.
|
|
4
|
-
|
|
5
|
-
Use it for:
|
|
6
|
-
|
|
7
|
-
- public frontend pages powered by OpenAdminJS API/resource metadata;
|
|
8
|
-
- custom pages for entities created in the admin;
|
|
9
|
-
- SEO metadata, canonical URLs, robots and sitemap generation;
|
|
10
|
-
- field-level public rendering where you choose which resource fields appear on each page.
|
|
11
|
-
|
|
12
|
-
The marketing landing/docs site for GitHub Pages lives in `/site`.
|
package/apps/web/app/globals.css
DELETED
package/apps/web/app/layout.tsx
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import type { Metadata } from "next";
|
|
2
|
-
import "./globals.css";
|
|
3
|
-
|
|
4
|
-
export const metadata: Metadata = {
|
|
5
|
-
title: {
|
|
6
|
-
default: "OpenAdminJS Web",
|
|
7
|
-
template: "%s | OpenAdminJS Web"
|
|
8
|
-
},
|
|
9
|
-
description: "Public frontend layer powered by OpenAdminJS resources."
|
|
10
|
-
};
|
|
11
|
-
|
|
12
|
-
export default function RootLayout({ children }: { children: React.ReactNode }) {
|
|
13
|
-
return (
|
|
14
|
-
<html lang="en">
|
|
15
|
-
<body>{children}</body>
|
|
16
|
-
</html>
|
|
17
|
-
);
|
|
18
|
-
}
|
package/apps/web/app/page.tsx
DELETED
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import Link from "next/link";
|
|
2
|
-
import { listPublicRecords } from "../lib/openadmin-client";
|
|
3
|
-
|
|
4
|
-
export default async function HomePage() {
|
|
5
|
-
const posts = await listPublicRecords("posts");
|
|
6
|
-
|
|
7
|
-
return (
|
|
8
|
-
<main className="mx-auto max-w-5xl px-4 py-12">
|
|
9
|
-
<section className="max-w-3xl">
|
|
10
|
-
<p className="text-sm font-semibold uppercase text-emerald-700">OpenAdminJS Web Layer</p>
|
|
11
|
-
<h1 className="mt-3 text-4xl font-semibold tracking-normal">Public frontend powered by resources</h1>
|
|
12
|
-
<p className="mt-4 text-lg leading-8 text-slate-600">
|
|
13
|
-
This side is part of generated applications. Use it to build public pages, SEO landing pages, catalogs, blogs or custom frontend flows on top of the same API and resource metadata.
|
|
14
|
-
</p>
|
|
15
|
-
</section>
|
|
16
|
-
|
|
17
|
-
<section className="mt-10 grid gap-4">
|
|
18
|
-
{posts.map((post) => (
|
|
19
|
-
<Link key={post.id} href={`/posts/${post.slug}`} className="rounded-md border border-slate-200 bg-white p-5 hover:border-emerald-300">
|
|
20
|
-
<h2 className="font-semibold">{String(post.title)}</h2>
|
|
21
|
-
<p className="mt-2 text-sm leading-6 text-slate-600">{String(post.excerpt)}</p>
|
|
22
|
-
</Link>
|
|
23
|
-
))}
|
|
24
|
-
</section>
|
|
25
|
-
</main>
|
|
26
|
-
);
|
|
27
|
-
}
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
import { notFound } from "next/navigation";
|
|
2
|
-
import type { Metadata } from "next";
|
|
3
|
-
import { PublicFields } from "../../../components/public-fields";
|
|
4
|
-
import { getPublicRecord, getPublicResource, listPublicRecords } from "../../../lib/openadmin-client";
|
|
5
|
-
import { metadataForRecord } from "../../../lib/seo";
|
|
6
|
-
|
|
7
|
-
export async function generateStaticParams() {
|
|
8
|
-
const posts = await listPublicRecords("posts");
|
|
9
|
-
return posts.map((post) => ({ slug: String(post.slug ?? post.id) }));
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
export async function generateMetadata({ params }: { params: Promise<{ slug: string }> }): Promise<Metadata> {
|
|
13
|
-
const { slug } = await params;
|
|
14
|
-
const resource = getPublicResource("posts");
|
|
15
|
-
const post = await getPublicRecord("posts", slug);
|
|
16
|
-
if (!post) return {};
|
|
17
|
-
return metadataForRecord(resource, post);
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
export default async function PostPage({ params }: { params: Promise<{ slug: string }> }) {
|
|
21
|
-
const { slug } = await params;
|
|
22
|
-
const resource = getPublicResource("posts");
|
|
23
|
-
const post = await getPublicRecord("posts", slug);
|
|
24
|
-
if (!post) notFound();
|
|
25
|
-
|
|
26
|
-
return (
|
|
27
|
-
<main className="mx-auto max-w-3xl px-4 py-12">
|
|
28
|
-
<article>
|
|
29
|
-
<p className="text-sm font-semibold uppercase text-emerald-700">{resource.label}</p>
|
|
30
|
-
<h1 className="mt-3 text-4xl font-semibold tracking-normal">{String(post.title)}</h1>
|
|
31
|
-
<p className="mt-4 text-lg leading-8 text-slate-600">{String(post.excerpt)}</p>
|
|
32
|
-
<div className="mt-10">
|
|
33
|
-
<PublicFields resource={resource} record={post} />
|
|
34
|
-
</div>
|
|
35
|
-
</article>
|
|
36
|
-
</main>
|
|
37
|
-
);
|
|
38
|
-
}
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import Link from "next/link";
|
|
2
|
-
import { listPublicRecords } from "../../lib/openadmin-client";
|
|
3
|
-
|
|
4
|
-
export default async function PostsPage() {
|
|
5
|
-
const posts = await listPublicRecords("posts");
|
|
6
|
-
|
|
7
|
-
return (
|
|
8
|
-
<main className="mx-auto max-w-4xl px-4 py-12">
|
|
9
|
-
<h1 className="text-3xl font-semibold tracking-normal">Posts</h1>
|
|
10
|
-
<div className="mt-8 grid gap-4">
|
|
11
|
-
{posts.map((post) => (
|
|
12
|
-
<Link key={post.id} href={`/posts/${post.slug}`} className="rounded-md border border-slate-200 bg-white p-5">
|
|
13
|
-
<h2 className="font-semibold">{String(post.title)}</h2>
|
|
14
|
-
<p className="mt-2 text-sm text-slate-600">{String(post.excerpt)}</p>
|
|
15
|
-
</Link>
|
|
16
|
-
))}
|
|
17
|
-
</div>
|
|
18
|
-
</main>
|
|
19
|
-
);
|
|
20
|
-
}
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import { listPublicRecords } from "../../lib/openadmin-client";
|
|
2
|
-
import { absoluteUrl, sitemapXml } from "../../lib/seo";
|
|
3
|
-
|
|
4
|
-
export async function GET() {
|
|
5
|
-
const posts = await listPublicRecords("posts");
|
|
6
|
-
const urls = [
|
|
7
|
-
{ loc: absoluteUrl("/") },
|
|
8
|
-
{ loc: absoluteUrl("/posts") },
|
|
9
|
-
...posts.map((post) => ({
|
|
10
|
-
loc: absoluteUrl(`/posts/${post.slug ?? post.id}`),
|
|
11
|
-
lastmod: post.updatedAt
|
|
12
|
-
}))
|
|
13
|
-
];
|
|
14
|
-
|
|
15
|
-
return new Response(sitemapXml(urls), {
|
|
16
|
-
headers: {
|
|
17
|
-
"content-type": "application/xml"
|
|
18
|
-
}
|
|
19
|
-
});
|
|
20
|
-
}
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import type { PublicRecord, PublicResourceConfig } from "../lib/openadmin-client";
|
|
2
|
-
|
|
3
|
-
export function PublicFields({ resource, record }: { resource: PublicResourceConfig; record: PublicRecord }) {
|
|
4
|
-
const fields = Object.entries(resource.fields).filter(([, field]) => field.public);
|
|
5
|
-
|
|
6
|
-
return (
|
|
7
|
-
<dl className="grid gap-4">
|
|
8
|
-
{fields.map(([name, field]) => (
|
|
9
|
-
<div key={name} className="rounded-md border border-slate-200 bg-white p-4">
|
|
10
|
-
<dt className="text-sm font-medium text-slate-500">{field.label ?? name}</dt>
|
|
11
|
-
<dd className="mt-2 text-slate-950">{formatValue(record[name], field.type)}</dd>
|
|
12
|
-
</div>
|
|
13
|
-
))}
|
|
14
|
-
</dl>
|
|
15
|
-
);
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
function formatValue(value: unknown, type: string): string {
|
|
19
|
-
if (value == null) return "";
|
|
20
|
-
if (type === "datetime" || type === "date") return new Date(String(value)).toLocaleDateString();
|
|
21
|
-
return String(value);
|
|
22
|
-
}
|
|
@@ -1,82 +0,0 @@
|
|
|
1
|
-
import type { ResourceSeoConfig } from "@openadminjs/core";
|
|
2
|
-
|
|
3
|
-
export type PublicFieldConfig = {
|
|
4
|
-
type: string;
|
|
5
|
-
label?: string;
|
|
6
|
-
public?: boolean;
|
|
7
|
-
seo?: "title" | "description" | "image" | "slug" | "canonical";
|
|
8
|
-
};
|
|
9
|
-
|
|
10
|
-
export type PublicResourceConfig = {
|
|
11
|
-
name: string;
|
|
12
|
-
label: string;
|
|
13
|
-
basePath: string;
|
|
14
|
-
titleField: string;
|
|
15
|
-
descriptionField?: string;
|
|
16
|
-
slugField: string;
|
|
17
|
-
/** Aligns with `defineResource` SEO block for hreflang, OG image, custom paths */
|
|
18
|
-
seo?: ResourceSeoConfig;
|
|
19
|
-
fields: Record<string, PublicFieldConfig>;
|
|
20
|
-
};
|
|
21
|
-
|
|
22
|
-
export type PublicRecord = Record<string, unknown> & {
|
|
23
|
-
id: string;
|
|
24
|
-
slug?: string;
|
|
25
|
-
title?: string;
|
|
26
|
-
description?: string;
|
|
27
|
-
updatedAt?: string;
|
|
28
|
-
};
|
|
29
|
-
|
|
30
|
-
export const publicResources: PublicResourceConfig[] = [
|
|
31
|
-
{
|
|
32
|
-
name: "posts",
|
|
33
|
-
label: "Posts",
|
|
34
|
-
basePath: "/posts",
|
|
35
|
-
titleField: "title",
|
|
36
|
-
descriptionField: "excerpt",
|
|
37
|
-
slugField: "slug",
|
|
38
|
-
seo: {
|
|
39
|
-
public: true,
|
|
40
|
-
slugField: "slug",
|
|
41
|
-
pathPattern: "/posts/:slug",
|
|
42
|
-
titleField: "title",
|
|
43
|
-
descriptionField: "excerpt"
|
|
44
|
-
},
|
|
45
|
-
fields: {
|
|
46
|
-
title: { type: "text", label: "Title", public: true, seo: "title" },
|
|
47
|
-
slug: { type: "slug", label: "Slug", public: false, seo: "slug" },
|
|
48
|
-
excerpt: { type: "textarea", label: "Excerpt", public: true, seo: "description" },
|
|
49
|
-
content: { type: "richtext", label: "Content", public: true },
|
|
50
|
-
status: { type: "badge", label: "Status", public: false },
|
|
51
|
-
updatedAt: { type: "datetime", label: "Updated", public: true }
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
];
|
|
55
|
-
|
|
56
|
-
const demoPosts: PublicRecord[] = [
|
|
57
|
-
{
|
|
58
|
-
id: "welcome",
|
|
59
|
-
slug: "welcome-to-openadminjs",
|
|
60
|
-
title: "Welcome to OpenAdminJS",
|
|
61
|
-
excerpt: "Public resource pages can be generated from the same metadata as admin resources.",
|
|
62
|
-
content:
|
|
63
|
-
"OpenAdminJS keeps API, admin and public web concerns connected through resource metadata while still letting you write custom frontend pages.",
|
|
64
|
-
updatedAt: new Date("2026-04-29T00:00:00.000Z").toISOString()
|
|
65
|
-
}
|
|
66
|
-
];
|
|
67
|
-
|
|
68
|
-
export function getPublicResource(name: string): PublicResourceConfig {
|
|
69
|
-
const resource = publicResources.find((item) => item.name === name);
|
|
70
|
-
if (!resource) throw new Error(`Unknown public resource: ${name}`);
|
|
71
|
-
return resource;
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
export async function listPublicRecords(resourceName: string): Promise<PublicRecord[]> {
|
|
75
|
-
if (resourceName === "posts") return demoPosts;
|
|
76
|
-
return [];
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
export async function getPublicRecord(resourceName: string, slug: string): Promise<PublicRecord | undefined> {
|
|
80
|
-
const records = await listPublicRecords(resourceName);
|
|
81
|
-
return records.find((record) => record.slug === slug || record.id === slug);
|
|
82
|
-
}
|
package/apps/web/lib/seo.test.ts
DELETED
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
import { afterEach, describe, expect, it, vi } from "vitest";
|
|
2
|
-
|
|
3
|
-
describe("seo helpers", () => {
|
|
4
|
-
afterEach(() => {
|
|
5
|
-
vi.unstubAllEnvs();
|
|
6
|
-
vi.resetModules();
|
|
7
|
-
});
|
|
8
|
-
|
|
9
|
-
it("builds absolute URLs from NEXT_PUBLIC_SITE_URL", async () => {
|
|
10
|
-
vi.stubEnv("NEXT_PUBLIC_SITE_URL", "https://example.com");
|
|
11
|
-
const { absoluteUrl } = await import("./seo");
|
|
12
|
-
expect(absoluteUrl("/posts/hello")).toBe("https://example.com/posts/hello");
|
|
13
|
-
});
|
|
14
|
-
|
|
15
|
-
it("metadataForRecord fills canonical and OpenGraph", async () => {
|
|
16
|
-
vi.stubEnv("NEXT_PUBLIC_SITE_URL", "https://example.com");
|
|
17
|
-
const { metadataForRecord } = await import("./seo");
|
|
18
|
-
const meta = metadataForRecord(
|
|
19
|
-
{
|
|
20
|
-
name: "posts",
|
|
21
|
-
label: "Posts",
|
|
22
|
-
basePath: "/posts",
|
|
23
|
-
titleField: "title",
|
|
24
|
-
slugField: "slug",
|
|
25
|
-
fields: {}
|
|
26
|
-
},
|
|
27
|
-
{ id: "1", title: "Hi", slug: "hi", description: "d" }
|
|
28
|
-
);
|
|
29
|
-
expect(meta.title).toBe("Hi");
|
|
30
|
-
expect(meta.alternates?.canonical).toBe("https://example.com/posts/hi");
|
|
31
|
-
expect(meta.openGraph?.url).toBe("https://example.com/posts/hi");
|
|
32
|
-
});
|
|
33
|
-
|
|
34
|
-
it("sitemapXml renders url entries", async () => {
|
|
35
|
-
const { sitemapXml } = await import("./seo");
|
|
36
|
-
const xml = sitemapXml([{ loc: "https://example.com/a", lastmod: "2024-01-01" }]);
|
|
37
|
-
expect(xml).toContain("<loc>https://example.com/a</loc>");
|
|
38
|
-
expect(xml).toContain("<lastmod>2024-01-01</lastmod>");
|
|
39
|
-
expect(xml).toContain("<urlset");
|
|
40
|
-
});
|
|
41
|
-
});
|
package/apps/web/lib/seo.ts
DELETED
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
import { buildSeoPagePayload } from "@openadminjs/core";
|
|
2
|
-
import type { Metadata } from "next";
|
|
3
|
-
import type { PublicRecord, PublicResourceConfig } from "./openadmin-client";
|
|
4
|
-
|
|
5
|
-
const siteUrl = process.env.NEXT_PUBLIC_SITE_URL ?? "http://localhost:3001";
|
|
6
|
-
|
|
7
|
-
export function absoluteUrl(path: string): string {
|
|
8
|
-
return new URL(path, siteUrl).toString();
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
export function metadataForRecord(resource: PublicResourceConfig, record: PublicRecord): Metadata {
|
|
12
|
-
const payload = buildSeoPagePayload({
|
|
13
|
-
siteUrl,
|
|
14
|
-
basePath: resource.basePath,
|
|
15
|
-
seo: resource.seo,
|
|
16
|
-
record: record as Record<string, unknown>,
|
|
17
|
-
resourceLabel: resource.label
|
|
18
|
-
});
|
|
19
|
-
|
|
20
|
-
const ogImages = payload.openGraph.images?.map((img) => img.url).filter(Boolean);
|
|
21
|
-
|
|
22
|
-
return {
|
|
23
|
-
title: payload.title,
|
|
24
|
-
description: payload.description,
|
|
25
|
-
alternates: {
|
|
26
|
-
canonical: payload.canonicalUrl,
|
|
27
|
-
...(payload.alternates?.languages ? { languages: payload.alternates.languages } : {})
|
|
28
|
-
},
|
|
29
|
-
openGraph: {
|
|
30
|
-
title: payload.openGraph.title,
|
|
31
|
-
description: payload.openGraph.description,
|
|
32
|
-
url: payload.openGraph.url,
|
|
33
|
-
type: payload.openGraph.type as "article",
|
|
34
|
-
...(ogImages?.length ? { images: ogImages } : {})
|
|
35
|
-
},
|
|
36
|
-
twitter: {
|
|
37
|
-
card: "summary_large_image",
|
|
38
|
-
title: payload.title,
|
|
39
|
-
description: payload.description,
|
|
40
|
-
...(ogImages?.[0] ? { images: [ogImages[0]] } : {})
|
|
41
|
-
}
|
|
42
|
-
};
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
export function sitemapXml(urls: Array<{ loc: string; lastmod?: string }>): string {
|
|
46
|
-
const items = urls
|
|
47
|
-
.map((url) => {
|
|
48
|
-
const lastmod = url.lastmod ? `<lastmod>${url.lastmod}</lastmod>` : "";
|
|
49
|
-
return `<url><loc>${url.loc}</loc>${lastmod}</url>`;
|
|
50
|
-
})
|
|
51
|
-
.join("");
|
|
52
|
-
return `<?xml version="1.0" encoding="UTF-8"?><urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">${items}</urlset>`;
|
|
53
|
-
}
|