@serhii.mazur/directus-gu-logs 1.0.1 → 1.0.3

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 CHANGED
@@ -37,7 +37,7 @@ This recipient will be used to send internal notifications when errors occur.
37
37
  ## 📦 Installation
38
38
 
39
39
  ```bash
40
- npm install @serhii.mazur/directus-gu-logs
40
+ npm i @serhii.mazur/directus-gu-logs
41
41
  ```
42
42
 
43
43
  ## 🧩 Usage
@@ -45,9 +45,9 @@ npm install @serhii.mazur/directus-gu-logs
45
45
  ```ts
46
46
  import { Logs } from "@serhii.mazur/directus-gu-logs";
47
47
 
48
- const logs = new Logs(context, "logs", "my-extension");
48
+ const logs = new Logs(context, "my-extension", "logs");
49
49
 
50
50
  await logs.printLogs("myFunction", "message");
51
- await logs.createActivity("create", "collection", "id", "comment");
51
+ await logs.createActivity("create", "collection", "id");
52
52
  await logs.createNotification("An error occurred");
53
53
  ```
package/dist/index.d.ts CHANGED
@@ -2,12 +2,12 @@ import { ApiExtensionContext } from "@directus/extensions";
2
2
  import type { PrimaryKey } from "@directus/types";
3
3
  export declare class Logs {
4
4
  protected context: ApiExtensionContext;
5
- protected collectionName: string;
6
5
  protected extension: string;
7
- constructor(context: ApiExtensionContext, collectionName?: string, extension?: string);
6
+ protected collectionName: string;
7
+ constructor(context: ApiExtensionContext, extension?: string, collectionName?: string);
8
8
  private getSchema;
9
9
  private createOne;
10
10
  printLogs(functionName: string, error: string): Promise<void>;
11
- createActivity(action: "create" | "update" | "delete" | undefined, collection: string, id: PrimaryKey, comment?: string): Promise<void>;
11
+ createActivity(action: string, collection: string, id: PrimaryKey): Promise<void>;
12
12
  createNotification(message?: string): Promise<void>;
13
13
  }
package/dist/index.js CHANGED
@@ -1,8 +1,8 @@
1
1
  export class Logs {
2
- constructor(context, collectionName = "logs", extension = "unknown") {
2
+ constructor(context, extension = "unknown", collectionName = "logs") {
3
3
  this.context = context;
4
- this.collectionName = collectionName;
5
4
  this.extension = extension;
5
+ this.collectionName = collectionName;
6
6
  }
7
7
  async getSchema() {
8
8
  return await this.context.getSchema();
@@ -31,7 +31,7 @@ export class Logs {
31
31
  console.error("❌ Failed to save logs:", error);
32
32
  }
33
33
  }
34
- async createActivity(action = "create", collection, id, comment = "") {
34
+ async createActivity(action, collection, id) {
35
35
  try {
36
36
  const schema = await this.getSchema();
37
37
  const services = this.context.services;
@@ -43,7 +43,6 @@ export class Logs {
43
43
  });
44
44
  await activityService.createOne({
45
45
  action,
46
- comment,
47
46
  user: accountability?.user ?? null,
48
47
  collection,
49
48
  ip: accountability?.ip ?? null,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@serhii.mazur/directus-gu-logs",
3
- "version": "1.0.1",
3
+ "version": "1.0.3",
4
4
  "description": "Helper class Logs for using in Directus extensions",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
package/src/index.ts CHANGED
@@ -11,13 +11,13 @@ interface LogEntry {
11
11
 
12
12
  export class Logs {
13
13
  protected context: ApiExtensionContext;
14
- protected collectionName: string;
15
14
  protected extension: string;
15
+ protected collectionName: string;
16
16
 
17
- constructor(context: ApiExtensionContext, collectionName = "logs", extension = "unknown") {
17
+ constructor(context: ApiExtensionContext, extension = "unknown", collectionName = "logs") {
18
18
  this.context = context;
19
- this.collectionName = collectionName;
20
19
  this.extension = extension;
20
+ this.collectionName = collectionName;
21
21
  }
22
22
 
23
23
  private async getSchema() {
@@ -52,12 +52,7 @@ export class Logs {
52
52
  }
53
53
  }
54
54
 
55
- async createActivity(
56
- action: "create" | "update" | "delete" = "create",
57
- collection: string,
58
- id: PrimaryKey,
59
- comment: string = ""
60
- ) {
55
+ async createActivity(action: string, collection: string, id: PrimaryKey) {
61
56
  try {
62
57
  const schema = await this.getSchema();
63
58
  const services = this.context.services;
@@ -71,7 +66,6 @@ export class Logs {
71
66
 
72
67
  await activityService.createOne({
73
68
  action,
74
- comment,
75
69
  user: accountability?.user ?? null,
76
70
  collection,
77
71
  ip: accountability?.ip ?? null,