openadminjs 0.1.14 → 0.1.16

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "openadminjs",
3
- "version": "0.1.14",
3
+ "version": "0.1.16",
4
4
  "type": "module",
5
5
  "bin": {
6
6
  "openadminjs": "dist/index.js"
@@ -1,4 +1,17 @@
1
- import { Body, Controller, Delete, Get, Param, Patch, Post, Put, Query, Res, UseGuards } from "@nestjs/common";
1
+ import {
2
+ Body,
3
+ Controller,
4
+ Delete,
5
+ Get,
6
+ Inject,
7
+ Param,
8
+ Patch,
9
+ Post,
10
+ Put,
11
+ Query,
12
+ Res,
13
+ UseGuards
14
+ } from "@nestjs/common";
2
15
  import { AuthGuard } from "../common/auth.guard";
3
16
  import { RequireAuthRealm } from "../common/auth-realm.decorator";
4
17
  import { CurrentUser } from "../common/current-user.decorator";
@@ -11,7 +24,7 @@ type UserContext = { id: string; email?: string; permissions: string[] };
11
24
  @RequireAuthRealm("admin")
12
25
  @Controller("admin/ai")
13
26
  export class AdminAiController {
14
- constructor(private readonly ai: AdminAiService) {}
27
+ constructor(@Inject(AdminAiService) private readonly ai: AdminAiService) {}
15
28
 
16
29
  @Get("config")
17
30
  config() {
@@ -1,4 +1,4 @@
1
- import { BadRequestException, ForbiddenException, Injectable } from "@nestjs/common";
1
+ import { BadRequestException, ForbiddenException, Inject, Injectable } from "@nestjs/common";
2
2
  import type { Prisma } from "@prisma/client";
3
3
  import { PrismaService } from "../common/prisma.service";
4
4
  import { pluginRuntime } from "../plugins/plugin-runtime";
@@ -79,8 +79,8 @@ const DEFAULT_SYSTEM_PROMPT = [
79
79
  @Injectable()
80
80
  export class AdminAiService {
81
81
  constructor(
82
- private readonly prisma: PrismaService,
83
- private readonly resourcesService: AdminResourceService
82
+ @Inject(PrismaService) private readonly prisma: PrismaService,
83
+ @Inject(AdminResourceService) private readonly resourcesService: AdminResourceService
84
84
  ) {}
85
85
 
86
86
  async getConfig() {
@@ -1,4 +1,4 @@
1
- import { Injectable } from "@nestjs/common";
1
+ import { Inject, Injectable } from "@nestjs/common";
2
2
  import { PrismaService } from "../common/prisma.service";
3
3
 
4
4
  type Period = "7d" | "30d" | "90d";
@@ -6,7 +6,7 @@ type UserContext = { id: string; permissions: string[] };
6
6
 
7
7
  @Injectable()
8
8
  export class AdminAnalyticsService {
9
- constructor(private readonly prisma: PrismaService) {}
9
+ constructor(@Inject(PrismaService) private readonly prisma: PrismaService) {}
10
10
 
11
11
  async overview(user: UserContext, period: Period = "30d") {
12
12
  const days = period === "7d" ? 7 : period === "90d" ? 90 : 30;
@@ -1,4 +1,4 @@
1
- import { Body, Controller, Delete, Get, Param, Patch, Post, UseGuards } from "@nestjs/common";
1
+ import { Body, Controller, Delete, Get, Inject, Param, Patch, Post, UseGuards } from "@nestjs/common";
2
2
  import { AuthGuard } from "../common/auth.guard";
3
3
  import { RequireAuthRealm } from "../common/auth-realm.decorator";
4
4
  import { AddPluginDto, PatchPluginDto } from "./dto/plugins.dto";
@@ -8,7 +8,7 @@ import { AdminPluginsService } from "./admin-plugins.service";
8
8
  @RequireAuthRealm("admin")
9
9
  @Controller("admin/plugins")
10
10
  export class AdminPluginsController {
11
- constructor(private readonly plugins: AdminPluginsService) {}
11
+ constructor(@Inject(AdminPluginsService) private readonly plugins: AdminPluginsService) {}
12
12
 
13
13
  @Get()
14
14
  list() {
@@ -1,4 +1,4 @@
1
- import { BadRequestException, ForbiddenException, Injectable, NotFoundException } from "@nestjs/common";
1
+ import { BadRequestException, ForbiddenException, Inject, Injectable, NotFoundException } from "@nestjs/common";
2
2
  import { Prisma } from "@prisma/client";
3
3
  import type { ResourceConfig, ResourceField } from "@openadminjs/core";
4
4
  import {
@@ -33,7 +33,7 @@ type PrismaDelegate = {
33
33
 
34
34
  @Injectable()
35
35
  export class AdminResourceService {
36
- constructor(private readonly prisma: PrismaService) {}
36
+ constructor(@Inject(PrismaService) private readonly prisma: PrismaService) {}
37
37
 
38
38
  listResources(user: UserContext, locale?: string) {
39
39
  return resources
@@ -13,8 +13,8 @@ type UserContext = { id: string; email?: string; permissions: string[] };
13
13
  @Controller("admin/resources")
14
14
  export class AdminController {
15
15
  constructor(
16
- private readonly resources: AdminResourceService,
17
- private readonly analytics: AdminAnalyticsService,
16
+ @Inject(AdminResourceService) private readonly resources: AdminResourceService,
17
+ @Inject(AdminAnalyticsService) private readonly analytics: AdminAnalyticsService,
18
18
  @Optional() @Inject(PaymentService) private readonly payments?: PaymentService
19
19
  ) {}
20
20
 
@@ -26,6 +26,6 @@ import { AuthService } from "./auth.service";
26
26
  ],
27
27
  controllers: [AuthController],
28
28
  providers: [AuthService, PrismaService, AuthGuard],
29
- exports: [AuthService, AuthGuard]
29
+ exports: [AuthService, AuthGuard, JwtModule]
30
30
  })
31
31
  export class AuthModule {}
@@ -11,7 +11,7 @@ export class AuthService {
11
11
  constructor(
12
12
  @Inject(PrismaService) private readonly prisma: PrismaService,
13
13
  @Inject(JwtService) private readonly jwt: JwtService,
14
- @Optional() private readonly mail?: MailService
14
+ @Optional() @Inject(MailService) private readonly mail?: MailService
15
15
  ) {}
16
16
 
17
17
  async login(
@@ -1,4 +1,11 @@
1
- import { CanActivate, ExecutionContext, ForbiddenException, Injectable, UnauthorizedException } from "@nestjs/common";
1
+ import {
2
+ CanActivate,
3
+ ExecutionContext,
4
+ ForbiddenException,
5
+ Inject,
6
+ Injectable,
7
+ UnauthorizedException
8
+ } from "@nestjs/common";
2
9
  import { ConfigService } from "@nestjs/config";
3
10
  import { Reflector } from "@nestjs/core";
4
11
  import { JwtService } from "@nestjs/jwt";
@@ -18,10 +25,10 @@ export type RequestUser = {
18
25
  @Injectable()
19
26
  export class AuthGuard implements CanActivate {
20
27
  constructor(
21
- private readonly jwt: JwtService,
22
- private readonly prisma: PrismaService,
23
- private readonly reflector: Reflector,
24
- private readonly config: ConfigService
28
+ @Inject(JwtService) private readonly jwt: JwtService,
29
+ @Inject(PrismaService) private readonly prisma: PrismaService,
30
+ @Inject(Reflector) private readonly reflector: Reflector,
31
+ @Inject(ConfigService) private readonly config: ConfigService
25
32
  ) {}
26
33
 
27
34
  async canActivate(context: ExecutionContext): Promise<boolean> {
@@ -1,4 +1,4 @@
1
- import { CanActivate, ExecutionContext, ForbiddenException, Injectable } from "@nestjs/common";
1
+ import { CanActivate, ExecutionContext, ForbiddenException, Inject, Injectable } from "@nestjs/common";
2
2
  import { Reflector } from "@nestjs/core";
3
3
  import { REQUIRE_PERMISSION, REQUIRE_ROLE } from "./permission.decorator";
4
4
  import { CaslAbilityFactory } from "./casl-ability.factory";
@@ -6,8 +6,8 @@ import { CaslAbilityFactory } from "./casl-ability.factory";
6
6
  @Injectable()
7
7
  export class PermissionsGuard implements CanActivate {
8
8
  constructor(
9
- private readonly reflector: Reflector,
10
- private readonly abilityFactory: CaslAbilityFactory
9
+ @Inject(Reflector) private readonly reflector: Reflector,
10
+ @Inject(CaslAbilityFactory) private readonly abilityFactory: CaslAbilityFactory
11
11
  ) {}
12
12
 
13
13
  canActivate(context: ExecutionContext): boolean {
@@ -1,4 +1,4 @@
1
- import { Injectable, Logger } from "@nestjs/common";
1
+ import { Inject, Injectable, Logger } from "@nestjs/common";
2
2
  import { ConfigService } from "@nestjs/config";
3
3
  import {
4
4
  createMailDriver,
@@ -21,7 +21,7 @@ export class MailService {
21
21
  private readonly appName: string;
22
22
  private readonly appUrl: string;
23
23
 
24
- constructor(private readonly config: ConfigService) {
24
+ constructor(@Inject(ConfigService) private readonly config: ConfigService) {
25
25
  const host = this.config.get<string>("SMTP_HOST");
26
26
  this.appName = this.config.get<string>("APP_NAME") ?? "OpenAdminJS";
27
27
  this.appUrl = this.config.get<string>("APP_URL") ?? "http://localhost:3000";
@@ -1,4 +1,4 @@
1
- import { Controller, Get, Post, UseGuards } from "@nestjs/common";
1
+ import { Controller, Get, Inject, Post, UseGuards } from "@nestjs/common";
2
2
  import { AuthGuard } from "../common/auth.guard";
3
3
  import { RequireAuthRealm } from "../common/auth-realm.decorator";
4
4
  import { PermissionsGuard } from "../common/permissions.guard";
@@ -12,7 +12,7 @@ type UserContext = { id: string };
12
12
  @UseGuards(AuthGuard, PermissionsGuard)
13
13
  @RequireAuthRealm("admin")
14
14
  export class QueueController {
15
- constructor(private readonly queue: QueueService) {}
15
+ constructor(@Inject(QueueService) private readonly queue: QueueService) {}
16
16
 
17
17
  @Get("stats")
18
18
  @RequirePermission("jobs.read")
@@ -1,5 +1,5 @@
1
1
  import { Processor, WorkerHost } from "@nestjs/bullmq";
2
- import { Logger } from "@nestjs/common";
2
+ import { Inject, Logger } from "@nestjs/common";
3
3
  import type { Job } from "bullmq";
4
4
  import { PrismaService } from "../common/prisma.service";
5
5
 
@@ -7,7 +7,7 @@ import { PrismaService } from "../common/prisma.service";
7
7
  export class QueueProcessor extends WorkerHost {
8
8
  private readonly logger = new Logger(QueueProcessor.name);
9
9
 
10
- constructor(private readonly prisma: PrismaService) {
10
+ constructor(@Inject(PrismaService) private readonly prisma: PrismaService) {
11
11
  super();
12
12
  }
13
13
 
@@ -1,4 +1,4 @@
1
- import { Injectable, ServiceUnavailableException } from "@nestjs/common";
1
+ import { Inject, Injectable, ServiceUnavailableException } from "@nestjs/common";
2
2
  import { InjectQueue } from "@nestjs/bullmq";
3
3
  import { Queue } from "bullmq";
4
4
  import { PrismaService } from "../common/prisma.service";
@@ -7,7 +7,7 @@ import { PrismaService } from "../common/prisma.service";
7
7
  export class QueueService {
8
8
  constructor(
9
9
  @InjectQueue("default") private readonly queue: Queue,
10
- private readonly prisma: PrismaService
10
+ @Inject(PrismaService) private readonly prisma: PrismaService
11
11
  ) {}
12
12
 
13
13
  async getStats() {
@@ -3,6 +3,7 @@ import {
3
3
  Controller,
4
4
  Get,
5
5
  Headers,
6
+ Inject,
6
7
  Param,
7
8
  Post,
8
9
  Query,
@@ -20,7 +21,7 @@ type RequestLike = { user?: UserContext; rawBody?: Buffer };
20
21
 
21
22
  @Controller("store")
22
23
  export class PaymentController {
23
- constructor(private readonly paymentService: PaymentService) {}
24
+ constructor(@Inject(PaymentService) private readonly paymentService: PaymentService) {}
24
25
 
25
26
  // ──────────────────────────────────────────────
26
27
  // Public endpoints — no JWT required
@@ -1,4 +1,4 @@
1
- import { Injectable, Logger } from "@nestjs/common";
1
+ import { Inject, Injectable, Logger } from "@nestjs/common";
2
2
  import { ConfigService } from "@nestjs/config";
3
3
  import {
4
4
  createPaymentProvider,
@@ -19,7 +19,7 @@ export class PaymentProviderService {
19
19
  private readonly provider: PaymentProvider;
20
20
  private readonly logger = new Logger(PaymentProviderService.name);
21
21
 
22
- constructor(private readonly config: ConfigService) {
22
+ constructor(@Inject(ConfigService) private readonly config: ConfigService) {
23
23
  const providerName = (this.config.get<string>("PAYMENT_PROVIDER") ?? "mock") as ProviderName;
24
24
  this.provider = createPaymentProvider(providerName, {
25
25
  stripeSecretKey: this.config.get<string>("STRIPE_SECRET_KEY"),
@@ -1,4 +1,4 @@
1
- import { BadRequestException, Injectable, NotFoundException } from "@nestjs/common";
1
+ import { BadRequestException, Inject, Injectable, NotFoundException } from "@nestjs/common";
2
2
  import { PrismaService } from "../../common/prisma.service";
3
3
  import { PaymentProviderService } from "./payment.provider";
4
4
 
@@ -29,8 +29,8 @@ export type OrderStatusResponse = {
29
29
  @Injectable()
30
30
  export class PaymentService {
31
31
  constructor(
32
- private readonly prisma: PrismaService,
33
- private readonly paymentProvider: PaymentProviderService
32
+ @Inject(PrismaService) private readonly prisma: PrismaService,
33
+ @Inject(PaymentProviderService) private readonly paymentProvider: PaymentProviderService
34
34
  ) {}
35
35
 
36
36
  /** Create a new order and return a checkout URL. */