ks-labs / adonis5-audit

A functional audit library for Adonisjs V5 🔖 - embend into your base model and audit everthing
https://www.npmjs.com/package/adonis5-audit
MIT License
7 stars 1 forks source link

Cannot find module '../src/audit/createAudit' #3

Closed cadecannon closed 1 year ago

cadecannon commented 1 year ago

After stepping through the install instructions, I was trying to log a custom event when a user OAuth's in via Ally. Unfortunately, I get an error that '../src/audit/createAudit' cannot be found. Looking in the code quickly, it looks like maybe this should be /src/Functional/createAudit, but that simple change did not result in a fix.

import { auditCustom } from '@ioc:Adonis/Addons/AuditHelpers'
import { CustomAuditEvents } from 'App/Types/Audit'

... // OAuth Login logic here

await auth.use('web').login(user)

await auditCustom({
  ctx: request,
  event: CustomAuditEvents.OAUTH_LOGIN,
  auditableId: user.id,
  auditable: 'user',
})
vinicioslc commented 1 year ago

Hi sorry for the mismatch documentation try something like this below and write here if works properly import { auditCustom } from '@ioc:Adonis/Addons/AuditMixin'

on my project its working

    await auditCustom({
      event: CustomAuditEvents.manifestEvent,
      data: { custom: 'data' },
      auditable: 'VehicleType',
      auditable_id: vehicleType.id,
      ctx: ctx,
    })
cadecannon commented 1 year ago

Does not appear to work for me. I'm now getting the following error:

(0 , AuditMixin_1.auditCustom) is not a function

I am running 5.9.0 of adonis/core and 3.1.1 of adonis5-audit.

When I import this:

import { Audit, auditCustom } from '@ioc:Adonis/Addons/AuditMixin'

Audit exists but auditCustom does not.

vinicioslc commented 1 year ago

Your tsconfig.json have the following typo notations inside import and include keys?

{
  "extends": "./node_modules/adonis-preset-ts/tsconfig",
  "exclude": [
    "node_modules",
    "build"
  ],
  "compilerOptions": {
    "strict": false,
    "forceConsistentCasingInFileNames": true,
    "experimentalDecorators": true,
    "resolveJsonModule": true,
    "outDir": "build",
    "alwaysStrict": true,
    "rootDir": "./",
    "target": "ESNext",
    "sourceMap": true,
    "paths": {
      "App/*": [
        "./app/*"
      ],
      "Config/*": [
        "./config/*"
      ],
      "Contracts/*": [
        "./contracts/*"
      ],
      "Services/*": [
        "./Services/*"
      ],
      "Database/*": [
        "./database/*"
      ]
    },
    "types": [
      "@adonisjs/core",
      "@adonisjs/repl",
      "@adonisjs/auth",
      "@adonisjs/lucid",
      "@adonisjs/shield",
      "@adonisjs/bouncer",
      "adonis5-audit",
    ]
  },
  "include": [
    "adonis5-audit"
  ]
}

If has it and stays in the problem, please create an empty repo, with the same problem for me to reproduce this behavior.

in my project its working nice with adonisjs/core@5.8.4 and adonis5-audit@3.1.1

vinicioslc commented 1 year ago

It would be great if you create a repository to reproduce this problem and make sure it's not some configuration in your environment, so if it's a missing configuration, let us know so we can improve the documentation and add the missing steps. @cadecannon

vinicioslc commented 1 year ago

This issued will be closed due the lack of innactivity