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,316 +0,0 @@
|
|
|
1
|
-
import { existsSync, readdirSync } from "node:fs";
|
|
2
|
-
import { dirname, resolve } from "node:path";
|
|
3
|
-
import { spawnSync } from "node:child_process";
|
|
4
|
-
import { fileURLToPath } from "node:url";
|
|
5
|
-
import { cancel, confirm, intro, isCancel, outro, select, text } from "@clack/prompts";
|
|
6
|
-
import fsExtra from "fs-extra";
|
|
7
|
-
import pc from "picocolors";
|
|
8
|
-
|
|
9
|
-
const __dirname = dirname(fileURLToPath(import.meta.url));
|
|
10
|
-
const { copySync, ensureDirSync, readFileSync, writeFileSync } = fsExtra;
|
|
11
|
-
|
|
12
|
-
export type PackageManager = "pnpm" | "npm" | "yarn";
|
|
13
|
-
export type DatabaseDriver = "postgresql" | "mysql" | "sqlite";
|
|
14
|
-
|
|
15
|
-
export type CreateProjectOptions = {
|
|
16
|
-
projectName?: string;
|
|
17
|
-
cwd?: string;
|
|
18
|
-
packageManager?: PackageManager;
|
|
19
|
-
database?: DatabaseDriver;
|
|
20
|
-
superadminEmail?: string;
|
|
21
|
-
superadminPassword?: string;
|
|
22
|
-
databaseUrl?: string;
|
|
23
|
-
redisUrl?: string;
|
|
24
|
-
jwtSecret?: string;
|
|
25
|
-
jwtRefreshSecret?: string;
|
|
26
|
-
adminOrigin?: string;
|
|
27
|
-
apiPort?: string;
|
|
28
|
-
git?: boolean;
|
|
29
|
-
install?: boolean;
|
|
30
|
-
templateDir?: string;
|
|
31
|
-
};
|
|
32
|
-
|
|
33
|
-
export type CreateProjectResult = {
|
|
34
|
-
appName: string;
|
|
35
|
-
packageName: string;
|
|
36
|
-
targetDir: string;
|
|
37
|
-
packageManager: PackageManager;
|
|
38
|
-
database: DatabaseDriver;
|
|
39
|
-
superadminEmail: string;
|
|
40
|
-
git: boolean;
|
|
41
|
-
install: boolean;
|
|
42
|
-
};
|
|
43
|
-
|
|
44
|
-
const placeholderPattern =
|
|
45
|
-
/__APP_NAME__|__PACKAGE_NAME__|__DATABASE_URL__|__DATABASE_PROVIDER__|__REDIS_URL__|__JWT_SECRET__|__JWT_REFRESH_SECRET__|__ADMIN_ORIGIN__|__API_PORT__/g;
|
|
46
|
-
|
|
47
|
-
export function toPackageName(input: string): string {
|
|
48
|
-
return input
|
|
49
|
-
.trim()
|
|
50
|
-
.toLowerCase()
|
|
51
|
-
.replace(/[^a-z0-9-]+/g, "-")
|
|
52
|
-
.replace(/^-|-$/g, "");
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
export function defaultTemplateDir(): string {
|
|
56
|
-
return resolve(__dirname, "../template");
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
function databaseUrl(packageName: string, database: DatabaseDriver): string {
|
|
60
|
-
if (database === "postgresql") {
|
|
61
|
-
return `postgresql://openadminjs:openadminjs@localhost:5432/${packageName}?schema=public`;
|
|
62
|
-
}
|
|
63
|
-
if (database === "mysql") {
|
|
64
|
-
return `mysql://openadminjs:openadminjs@localhost:3306/${packageName}`;
|
|
65
|
-
}
|
|
66
|
-
return "file:./prisma/dev.db";
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
function renderFile(file: string, replacements: Record<string, string>): void {
|
|
70
|
-
const content = readFileSync(file, "utf8");
|
|
71
|
-
writeFileSync(file, content.replace(placeholderPattern, (key) => replacements[key] ?? key));
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
function renderTemplateFiles(targetDir: string, replacements: Record<string, string>): void {
|
|
75
|
-
const stack = [targetDir];
|
|
76
|
-
while (stack.length) {
|
|
77
|
-
const current = stack.pop();
|
|
78
|
-
if (!current) continue;
|
|
79
|
-
for (const entry of readdirSync(current, { withFileTypes: true })) {
|
|
80
|
-
const path = resolve(current, entry.name);
|
|
81
|
-
if (entry.isDirectory()) {
|
|
82
|
-
stack.push(path);
|
|
83
|
-
} else if (entry.isFile()) {
|
|
84
|
-
renderFile(path, replacements);
|
|
85
|
-
}
|
|
86
|
-
}
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
export function createProject(options: Required<CreateProjectOptions>): CreateProjectResult {
|
|
91
|
-
const appName = options.projectName;
|
|
92
|
-
const packageName = toPackageName(appName);
|
|
93
|
-
if (!packageName) throw new Error("Project name must contain at least one letter or number.");
|
|
94
|
-
|
|
95
|
-
const targetDir = resolve(options.cwd, appName);
|
|
96
|
-
if (existsSync(targetDir)) throw new Error(`${targetDir} already exists.`);
|
|
97
|
-
|
|
98
|
-
ensureDirSync(targetDir);
|
|
99
|
-
copySync(options.templateDir, targetDir, {
|
|
100
|
-
overwrite: false,
|
|
101
|
-
errorOnExist: true,
|
|
102
|
-
filter: (source) => !source.includes("node_modules") && !source.includes(".next") && !source.includes("dist")
|
|
103
|
-
});
|
|
104
|
-
renderTemplateFiles(targetDir, {
|
|
105
|
-
__APP_NAME__: appName,
|
|
106
|
-
__PACKAGE_NAME__: packageName,
|
|
107
|
-
__DATABASE_PROVIDER__: options.database,
|
|
108
|
-
__DATABASE_URL__: options.databaseUrl,
|
|
109
|
-
__REDIS_URL__: options.redisUrl,
|
|
110
|
-
__JWT_SECRET__: options.jwtSecret,
|
|
111
|
-
__JWT_REFRESH_SECRET__: options.jwtRefreshSecret,
|
|
112
|
-
__ADMIN_ORIGIN__: options.adminOrigin,
|
|
113
|
-
__API_PORT__: options.apiPort
|
|
114
|
-
});
|
|
115
|
-
|
|
116
|
-
if (options.git) {
|
|
117
|
-
spawnSync("git", ["init"], { cwd: targetDir, stdio: "ignore" });
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
if (options.install) {
|
|
121
|
-
const installArgs = options.packageManager === "yarn" ? [] : ["install"];
|
|
122
|
-
spawnSync(options.packageManager, installArgs, { cwd: targetDir, stdio: "inherit" });
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
return {
|
|
126
|
-
appName,
|
|
127
|
-
packageName,
|
|
128
|
-
targetDir,
|
|
129
|
-
packageManager: options.packageManager,
|
|
130
|
-
database: options.database,
|
|
131
|
-
superadminEmail: options.superadminEmail,
|
|
132
|
-
git: options.git,
|
|
133
|
-
install: options.install
|
|
134
|
-
};
|
|
135
|
-
}
|
|
136
|
-
|
|
137
|
-
export function printNextSteps(result: CreateProjectResult): void {
|
|
138
|
-
const pm = result.packageManager;
|
|
139
|
-
const installStep = result.install ? "" : `\n ${pm} install`;
|
|
140
|
-
outro(
|
|
141
|
-
`${pc.green("Project created.")}\n\nNext steps:\n cd ${result.appName}${installStep}\n docker compose up -d\n ${pm} db:migrate\n ${pm} db:seed\n ${pm} dev\n\nAdmin: http://localhost:3000\nAPI: http://localhost:4000\nDocs: http://localhost:4000/api/docs\n\nSuperadmin: ${result.superadminEmail} / <your password>`
|
|
142
|
-
);
|
|
143
|
-
}
|
|
144
|
-
|
|
145
|
-
export async function createProjectInteractive(options: CreateProjectOptions = {}): Promise<CreateProjectResult | undefined> {
|
|
146
|
-
intro(pc.green("Create OpenAdminJS"));
|
|
147
|
-
|
|
148
|
-
const projectName =
|
|
149
|
-
options.projectName ??
|
|
150
|
-
(await text({
|
|
151
|
-
message: "Project name",
|
|
152
|
-
defaultValue: "my-app",
|
|
153
|
-
placeholder: "my-app"
|
|
154
|
-
}));
|
|
155
|
-
if (isCancel(projectName)) {
|
|
156
|
-
cancel("Cancelled");
|
|
157
|
-
return undefined;
|
|
158
|
-
}
|
|
159
|
-
|
|
160
|
-
const packageManager =
|
|
161
|
-
options.packageManager ??
|
|
162
|
-
(await select<PackageManager>({
|
|
163
|
-
message: "Package manager",
|
|
164
|
-
options: [
|
|
165
|
-
{ value: "pnpm", label: "pnpm" },
|
|
166
|
-
{ value: "npm", label: "npm" },
|
|
167
|
-
{ value: "yarn", label: "yarn" }
|
|
168
|
-
],
|
|
169
|
-
initialValue: "pnpm"
|
|
170
|
-
}));
|
|
171
|
-
if (isCancel(packageManager)) {
|
|
172
|
-
cancel("Cancelled");
|
|
173
|
-
return undefined;
|
|
174
|
-
}
|
|
175
|
-
|
|
176
|
-
const database =
|
|
177
|
-
options.database ??
|
|
178
|
-
(await select<DatabaseDriver>({
|
|
179
|
-
message: "Database",
|
|
180
|
-
options: [
|
|
181
|
-
{ value: "postgresql", label: "PostgreSQL" },
|
|
182
|
-
{ value: "mysql", label: "MySQL" },
|
|
183
|
-
{ value: "sqlite", label: "SQLite" }
|
|
184
|
-
],
|
|
185
|
-
initialValue: "postgresql"
|
|
186
|
-
}));
|
|
187
|
-
if (isCancel(database)) {
|
|
188
|
-
cancel("Cancelled");
|
|
189
|
-
return undefined;
|
|
190
|
-
}
|
|
191
|
-
|
|
192
|
-
const superadminEmail =
|
|
193
|
-
options.superadminEmail ??
|
|
194
|
-
(await text({
|
|
195
|
-
message: "Superadmin email",
|
|
196
|
-
defaultValue: "admin@localhost.dev",
|
|
197
|
-
placeholder: "admin@localhost.dev",
|
|
198
|
-
validate(value) {
|
|
199
|
-
return /^\S+@\S+\.\S+$/.test(value) ? undefined : "Enter a valid email address.";
|
|
200
|
-
}
|
|
201
|
-
}));
|
|
202
|
-
if (isCancel(superadminEmail)) {
|
|
203
|
-
cancel("Cancelled");
|
|
204
|
-
return undefined;
|
|
205
|
-
}
|
|
206
|
-
|
|
207
|
-
const superadminPassword =
|
|
208
|
-
options.superadminPassword ??
|
|
209
|
-
(await text({
|
|
210
|
-
message: "Superadmin password",
|
|
211
|
-
placeholder: "At least 8 characters",
|
|
212
|
-
validate(value) {
|
|
213
|
-
return value.length >= 8 ? undefined : "Password must be at least 8 characters.";
|
|
214
|
-
}
|
|
215
|
-
}));
|
|
216
|
-
if (isCancel(superadminPassword)) {
|
|
217
|
-
cancel("Cancelled");
|
|
218
|
-
return undefined;
|
|
219
|
-
}
|
|
220
|
-
|
|
221
|
-
const selectedDatabaseUrl =
|
|
222
|
-
options.databaseUrl ??
|
|
223
|
-
(await text({
|
|
224
|
-
message: "Database URL",
|
|
225
|
-
defaultValue: databaseUrl(toPackageName(String(projectName)), database)
|
|
226
|
-
}));
|
|
227
|
-
if (isCancel(selectedDatabaseUrl)) {
|
|
228
|
-
cancel("Cancelled");
|
|
229
|
-
return undefined;
|
|
230
|
-
}
|
|
231
|
-
|
|
232
|
-
const redisUrl =
|
|
233
|
-
options.redisUrl ??
|
|
234
|
-
(await text({
|
|
235
|
-
message: "Redis URL (optional for queues)",
|
|
236
|
-
defaultValue: "redis://localhost:6379"
|
|
237
|
-
}));
|
|
238
|
-
if (isCancel(redisUrl)) {
|
|
239
|
-
cancel("Cancelled");
|
|
240
|
-
return undefined;
|
|
241
|
-
}
|
|
242
|
-
|
|
243
|
-
const jwtSecret =
|
|
244
|
-
options.jwtSecret ??
|
|
245
|
-
(await text({
|
|
246
|
-
message: "JWT secret",
|
|
247
|
-
defaultValue: "change-me-to-a-long-random-secret",
|
|
248
|
-
placeholder: "at least 32 chars recommended"
|
|
249
|
-
}));
|
|
250
|
-
if (isCancel(jwtSecret)) {
|
|
251
|
-
cancel("Cancelled");
|
|
252
|
-
return undefined;
|
|
253
|
-
}
|
|
254
|
-
|
|
255
|
-
const jwtRefreshSecret =
|
|
256
|
-
options.jwtRefreshSecret ??
|
|
257
|
-
(await text({
|
|
258
|
-
message: "JWT refresh secret",
|
|
259
|
-
defaultValue: "change-me-too",
|
|
260
|
-
placeholder: "at least 32 chars recommended"
|
|
261
|
-
}));
|
|
262
|
-
if (isCancel(jwtRefreshSecret)) {
|
|
263
|
-
cancel("Cancelled");
|
|
264
|
-
return undefined;
|
|
265
|
-
}
|
|
266
|
-
|
|
267
|
-
const adminOrigin =
|
|
268
|
-
options.adminOrigin ??
|
|
269
|
-
(await text({
|
|
270
|
-
message: "Admin origin",
|
|
271
|
-
defaultValue: "http://localhost:3000"
|
|
272
|
-
}));
|
|
273
|
-
if (isCancel(adminOrigin)) {
|
|
274
|
-
cancel("Cancelled");
|
|
275
|
-
return undefined;
|
|
276
|
-
}
|
|
277
|
-
|
|
278
|
-
const apiPort =
|
|
279
|
-
options.apiPort ??
|
|
280
|
-
(await text({
|
|
281
|
-
message: "API port",
|
|
282
|
-
defaultValue: "4000"
|
|
283
|
-
}));
|
|
284
|
-
if (isCancel(apiPort)) {
|
|
285
|
-
cancel("Cancelled");
|
|
286
|
-
return undefined;
|
|
287
|
-
}
|
|
288
|
-
|
|
289
|
-
const git = options.git ?? (await confirm({ message: "Initialize git?", initialValue: true }));
|
|
290
|
-
if (isCancel(git)) {
|
|
291
|
-
cancel("Cancelled");
|
|
292
|
-
return undefined;
|
|
293
|
-
}
|
|
294
|
-
|
|
295
|
-
const install = options.install ?? true;
|
|
296
|
-
|
|
297
|
-
const result = createProject({
|
|
298
|
-
projectName: String(projectName),
|
|
299
|
-
cwd: options.cwd ?? process.cwd(),
|
|
300
|
-
packageManager,
|
|
301
|
-
database,
|
|
302
|
-
superadminEmail: String(superadminEmail),
|
|
303
|
-
superadminPassword: String(superadminPassword),
|
|
304
|
-
databaseUrl: String(selectedDatabaseUrl),
|
|
305
|
-
redisUrl: String(redisUrl),
|
|
306
|
-
jwtSecret: String(jwtSecret),
|
|
307
|
-
jwtRefreshSecret: String(jwtRefreshSecret),
|
|
308
|
-
adminOrigin: String(adminOrigin),
|
|
309
|
-
apiPort: String(apiPort),
|
|
310
|
-
git,
|
|
311
|
-
install,
|
|
312
|
-
templateDir: options.templateDir ?? defaultTemplateDir()
|
|
313
|
-
});
|
|
314
|
-
printNextSteps(result);
|
|
315
|
-
return result;
|
|
316
|
-
}
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import { describe, expect, it } from "vitest";
|
|
2
|
-
import { modelNameToResourceSlug } from "./resource-slug.js";
|
|
3
|
-
|
|
4
|
-
describe("openadminjs cli", () => {
|
|
5
|
-
it("exposes resource slug helper used by generate resource", () => {
|
|
6
|
-
expect(modelNameToResourceSlug("OrderItem")).toBe("order-item");
|
|
7
|
-
});
|
|
8
|
-
});
|
|
@@ -1,149 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
import { existsSync, mkdirSync, readFileSync, writeFileSync } from "node:fs";
|
|
3
|
-
import { join } from "node:path";
|
|
4
|
-
import { cac } from "cac";
|
|
5
|
-
import pc from "picocolors";
|
|
6
|
-
import { createProjectInteractive } from "./create-project.js";
|
|
7
|
-
import { modelNameToResourceSlug } from "./resource-slug.js";
|
|
8
|
-
|
|
9
|
-
const cli = cac("openadminjs");
|
|
10
|
-
|
|
11
|
-
function runScript(name: string): void {
|
|
12
|
-
const scripts: Record<string, string> = {
|
|
13
|
-
dev: "pnpm --parallel --filter @openadminjs/api --filter @openadminjs/admin dev",
|
|
14
|
-
build: "pnpm -r build",
|
|
15
|
-
start: "pnpm --parallel --filter @openadminjs/api --filter @openadminjs/admin start"
|
|
16
|
-
};
|
|
17
|
-
console.log(pc.cyan(`Run: ${scripts[name]}`));
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
function doctor(): void {
|
|
21
|
-
const required = ["package.json", "pnpm-workspace.yaml", ".env.example", "prisma/schema.prisma"];
|
|
22
|
-
const missing = required.filter((file) => !existsSync(join(process.cwd(), file)));
|
|
23
|
-
if (missing.length) {
|
|
24
|
-
console.error(pc.red("OpenAdminJS doctor found missing files:"));
|
|
25
|
-
for (const file of missing) console.error(` - ${file}`);
|
|
26
|
-
process.exitCode = 1;
|
|
27
|
-
return;
|
|
28
|
-
}
|
|
29
|
-
console.log(pc.green("OpenAdminJS doctor passed."));
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
function securityCheck(): void {
|
|
33
|
-
const envExample = existsSync(".env.example") ? readFileSync(".env.example", "utf8") : "";
|
|
34
|
-
const findings: string[] = [];
|
|
35
|
-
if (!envExample.includes("JWT_SECRET")) findings.push("JWT_SECRET is missing from .env.example");
|
|
36
|
-
if (envExample.includes("DATABASE_URL=postgresql://") && !envExample.includes("localhost")) {
|
|
37
|
-
findings.push("DATABASE_URL example should not point to production");
|
|
38
|
-
}
|
|
39
|
-
if (existsSync("apps/admin/app")) {
|
|
40
|
-
const login = existsSync("apps/admin/app/login/page.tsx");
|
|
41
|
-
if (!login) findings.push("Admin login route is missing");
|
|
42
|
-
}
|
|
43
|
-
if (findings.length) {
|
|
44
|
-
console.error(pc.red("Security check failed:"));
|
|
45
|
-
for (const finding of findings) console.error(` - ${finding}`);
|
|
46
|
-
process.exitCode = 1;
|
|
47
|
-
return;
|
|
48
|
-
}
|
|
49
|
-
console.log(pc.green("Security check passed."));
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
function generateResource(modelName: string, options: { force?: boolean }): void {
|
|
53
|
-
const name = modelNameToResourceSlug(modelName);
|
|
54
|
-
const targetDir = join(process.cwd(), "apps/api/src/resources");
|
|
55
|
-
const target = join(targetDir, `${name}.resource.ts`);
|
|
56
|
-
if (existsSync(target) && !options.force) {
|
|
57
|
-
console.error(pc.red(`${target} already exists. Use --force to overwrite.`));
|
|
58
|
-
process.exitCode = 1;
|
|
59
|
-
return;
|
|
60
|
-
}
|
|
61
|
-
mkdirSync(targetDir, { recursive: true });
|
|
62
|
-
const plural = `${name}s`;
|
|
63
|
-
writeFileSync(
|
|
64
|
-
target,
|
|
65
|
-
`import { defineResource } from '@openadminjs/core';\n\nexport default defineResource({\n name: '${plural}',\n label: '${modelName}s',\n model: '${modelName}',\n titleField: 'id',\n icon: 'Database',\n permissions: {\n read: '${plural}.read',\n create: '${plural}.create',\n update: '${plural}.update',\n delete: '${plural}.delete',\n },\n fields: {\n id: { type: 'id', label: 'ID', create: false, edit: false },\n },\n});\n`
|
|
66
|
-
);
|
|
67
|
-
console.log(pc.green(`Created ${target}`));
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
function generatePlugin(pluginId: string, options: { force?: boolean }): void {
|
|
71
|
-
const safeId = pluginId.trim().toLowerCase().replace(/[^a-z0-9.-]+/g, "-");
|
|
72
|
-
const slug = safeId.replace(/\./g, "-");
|
|
73
|
-
const targetDir = join(process.cwd(), "apps/api/src/plugins/custom");
|
|
74
|
-
const target = join(targetDir, `${slug}.plugin.ts`);
|
|
75
|
-
if (existsSync(target) && !options.force) {
|
|
76
|
-
console.error(pc.red(`${target} already exists. Use --force to overwrite.`));
|
|
77
|
-
process.exitCode = 1;
|
|
78
|
-
return;
|
|
79
|
-
}
|
|
80
|
-
mkdirSync(targetDir, { recursive: true });
|
|
81
|
-
writeFileSync(
|
|
82
|
-
target,
|
|
83
|
-
`import type { OpenAdminPlugin } from "@openadminjs/plugin-sdk";\n\nexport const ${slug.replace(/-([a-z])/g, (_, c) => c.toUpperCase())}Plugin: OpenAdminPlugin = {\n id: "${safeId}",\n version: "0.1.0",\n register({ registerSurface }) {\n registerSurface({\n seo: {\n metadata({ resourceName, record }) {\n if (resourceName !== "posts") return {};\n return { title: record.title ?? "Untitled" };\n }\n }\n });\n }\n};\n`
|
|
84
|
-
);
|
|
85
|
-
console.log(pc.green(`Created ${target}`));
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
cli.command("dev", "Start API and admin apps").action(() => runScript("dev"));
|
|
89
|
-
cli.command("create [projectName]", "Create a new OpenAdminJS project").action(async (projectName?: string) => {
|
|
90
|
-
try {
|
|
91
|
-
await createProjectInteractive({ projectName });
|
|
92
|
-
} catch (error) {
|
|
93
|
-
console.error(pc.red(error instanceof Error ? error.message : "Failed to create project."));
|
|
94
|
-
process.exitCode = 1;
|
|
95
|
-
}
|
|
96
|
-
});
|
|
97
|
-
cli.command("build", "Build all workspaces").action(() => runScript("build"));
|
|
98
|
-
cli.command("start", "Start production apps").action(() => runScript("start"));
|
|
99
|
-
cli
|
|
100
|
-
.command("db <action>", "Run database helper commands")
|
|
101
|
-
.action((action?: string) => {
|
|
102
|
-
switch (action) {
|
|
103
|
-
case "migrate":
|
|
104
|
-
console.log("Run: pnpm --filter @openadminjs/api prisma migrate dev");
|
|
105
|
-
return;
|
|
106
|
-
case "seed":
|
|
107
|
-
console.log("Run: pnpm --filter @openadminjs/api prisma db seed");
|
|
108
|
-
return;
|
|
109
|
-
case "studio":
|
|
110
|
-
console.log("Run: pnpm --filter @openadminjs/api prisma studio");
|
|
111
|
-
return;
|
|
112
|
-
default:
|
|
113
|
-
console.error(pc.red("Unknown db action. Use: migrate, seed, studio."));
|
|
114
|
-
process.exitCode = 1;
|
|
115
|
-
}
|
|
116
|
-
});
|
|
117
|
-
|
|
118
|
-
function runGenerateCommand(kind: string | undefined, name: string | undefined, options: { force?: boolean }): void {
|
|
119
|
-
if (!kind || !name) {
|
|
120
|
-
console.error(pc.red("Usage: openadminjs generate <resource|plugin> <name> [--force]"));
|
|
121
|
-
process.exitCode = 1;
|
|
122
|
-
return;
|
|
123
|
-
}
|
|
124
|
-
if (kind === "resource") {
|
|
125
|
-
generateResource(name, options);
|
|
126
|
-
return;
|
|
127
|
-
}
|
|
128
|
-
if (kind === "plugin") {
|
|
129
|
-
generatePlugin(name, options);
|
|
130
|
-
return;
|
|
131
|
-
}
|
|
132
|
-
console.error(pc.red(`Unknown generate kind: ${kind}. Use resource or plugin.`));
|
|
133
|
-
process.exitCode = 1;
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
cli
|
|
137
|
-
.command("generate <kind> <name>", "Generate resource or plugin starter")
|
|
138
|
-
.option("--force", "Overwrite existing file")
|
|
139
|
-
.action(runGenerateCommand);
|
|
140
|
-
|
|
141
|
-
cli
|
|
142
|
-
.command("make <kind> <name>", "Alias for generate")
|
|
143
|
-
.option("--force", "Overwrite existing file")
|
|
144
|
-
.action(runGenerateCommand);
|
|
145
|
-
cli.command("doctor", "Check generated project health").action(doctor);
|
|
146
|
-
cli.command("security", "Run security checklist").action(securityCheck);
|
|
147
|
-
cli.command("security check", "Run security checklist").action(securityCheck);
|
|
148
|
-
cli.help();
|
|
149
|
-
cli.parse();
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { describe, expect, it } from "vitest";
|
|
2
|
-
import { modelNameToResourceSlug } from "./resource-slug.js";
|
|
3
|
-
|
|
4
|
-
describe("modelNameToResourceSlug", () => {
|
|
5
|
-
it("converts PascalCase to kebab-case", () => {
|
|
6
|
-
expect(modelNameToResourceSlug("Post")).toBe("post");
|
|
7
|
-
expect(modelNameToResourceSlug("OrderItem")).toBe("order-item");
|
|
8
|
-
expect(modelNameToResourceSlug("BlogCategory")).toBe("blog-category");
|
|
9
|
-
});
|
|
10
|
-
});
|
|
@@ -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`.
|
|
@@ -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
|
-
}
|
|
@@ -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
|
-
}
|