@forinda/kickjs-prisma 1.5.0 → 1.7.0

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/dist/index.js CHANGED
@@ -1,100 +1,100 @@
1
- import { Logger as l, Scope as h } from "@forinda/kickjs-core";
2
- var d = /* @__PURE__ */ Symbol("PrismaClient"), c = l.for("PrismaAdapter"), f = class {
1
+ import { Logger as u, Scope as l } from "@forinda/kickjs-core";
2
+ var h = /* @__PURE__ */ Symbol("PrismaClient"), c = u.for("PrismaAdapter"), m = class {
3
3
  name = "PrismaAdapter";
4
4
  client;
5
- constructor(t) {
6
- this.options = t, this.client = t.client;
5
+ constructor(e) {
6
+ this.options = e, this.client = e.client;
7
7
  }
8
- beforeStart(t, i) {
9
- this.options.logging && (typeof this.client.$on == "function" ? this.client.$on("query", (e) => {
10
- c.debug(`Query: ${e.query}`), c.debug(`Params: ${e.params}`), c.debug(`Duration: ${e.duration}ms`);
11
- }) : typeof this.client.$extends == "function" && (this.client = this.client.$extends({ query: { $allOperations({ operation: e, model: o, args: r, query: s }) {
12
- const n = performance.now();
13
- return s(r).then((a) => {
14
- const u = Math.round(performance.now() - n);
15
- return c.debug(`${o}.${e} — ${u}ms`), a;
8
+ beforeStart({ container: e }) {
9
+ this.options.logging && (typeof this.client.$on == "function" ? this.client.$on("query", (r) => {
10
+ c.debug(`Query: ${r.query}`), c.debug(`Params: ${r.params}`), c.debug(`Duration: ${r.duration}ms`);
11
+ }) : typeof this.client.$extends == "function" && (this.client = this.client.$extends({ query: { $allOperations({ operation: r, model: t, args: o, query: i }) {
12
+ const s = performance.now();
13
+ return i(o).then((n) => {
14
+ const a = Math.round(performance.now() - s);
15
+ return c.debug(`${t}.${r} — ${a}ms`), n;
16
16
  });
17
- } } }))), i.registerFactory(d, () => this.client, h.SINGLETON), c.info("PrismaClient registered in DI container");
17
+ } } }))), e.registerFactory(h, () => this.client, l.SINGLETON), c.info("PrismaClient registered in DI container");
18
18
  }
19
19
  async shutdown() {
20
20
  typeof this.client.$disconnect == "function" && (await this.client.$disconnect(), c.info("PrismaClient disconnected"));
21
21
  }
22
- }, p = class {
22
+ }, f = class {
23
23
  name = "PrismaQueryAdapter";
24
- build(t, i = {}) {
25
- const e = {}, o = this.buildFilters(t.filters), r = this.buildSearch(t.search, i.searchColumns);
26
- if (o.length > 0 || r) {
24
+ build(e, r = {}) {
25
+ const t = {}, o = this.buildFilters(e.filters), i = this.buildSearch(e.search, r.searchColumns);
26
+ if (o.length > 0 || i) {
27
27
  const n = [];
28
- o.length > 0 && n.push(...o), r && n.push(r), e.where = n.length === 1 ? n[0] : { AND: n };
28
+ o.length > 0 && n.push(...o), i && n.push(i), t.where = n.length === 1 ? n[0] : { AND: n };
29
29
  }
30
- const s = this.buildSort(t.sort);
31
- return s.length > 0 && (e.orderBy = s), e.skip = t.pagination.offset, e.take = t.pagination.limit, e;
30
+ const s = this.buildSort(e.sort);
31
+ return s.length > 0 && (t.orderBy = s), t.skip = e.pagination.offset, t.take = e.pagination.limit, t;
32
32
  }
33
- buildFilters(t) {
34
- return t.map((i) => {
35
- const { field: e, operator: o, value: r } = i;
33
+ buildFilters(e) {
34
+ return e.map((r) => {
35
+ const { field: t, operator: o, value: i } = r;
36
36
  switch (o) {
37
37
  case "eq":
38
- return { [e]: { equals: this.coerce(r) } };
38
+ return { [t]: { equals: this.coerce(i) } };
39
39
  case "neq":
40
- return { [e]: { not: this.coerce(r) } };
40
+ return { [t]: { not: this.coerce(i) } };
41
41
  case "gt":
42
- return { [e]: { gt: this.coerce(r) } };
42
+ return { [t]: { gt: this.coerce(i) } };
43
43
  case "gte":
44
- return { [e]: { gte: this.coerce(r) } };
44
+ return { [t]: { gte: this.coerce(i) } };
45
45
  case "lt":
46
- return { [e]: { lt: this.coerce(r) } };
46
+ return { [t]: { lt: this.coerce(i) } };
47
47
  case "lte":
48
- return { [e]: { lte: this.coerce(r) } };
48
+ return { [t]: { lte: this.coerce(i) } };
49
49
  case "contains":
50
- return { [e]: {
51
- contains: r,
50
+ return { [t]: {
51
+ contains: i,
52
52
  mode: "insensitive"
53
53
  } };
54
54
  case "starts":
55
- return { [e]: {
56
- startsWith: r,
55
+ return { [t]: {
56
+ startsWith: i,
57
57
  mode: "insensitive"
58
58
  } };
59
59
  case "ends":
60
- return { [e]: {
61
- endsWith: r,
60
+ return { [t]: {
61
+ endsWith: i,
62
62
  mode: "insensitive"
63
63
  } };
64
64
  case "in": {
65
- const s = r.split(",").map((n) => this.coerce(n.trim()));
66
- return { [e]: { in: s } };
65
+ const s = i.split(",").map((n) => this.coerce(n.trim()));
66
+ return { [t]: { in: s } };
67
67
  }
68
68
  case "between": {
69
- const [s, n] = r.split(",").map((a) => this.coerce(a.trim()));
70
- return { [e]: {
69
+ const [s, n] = i.split(",").map((a) => this.coerce(a.trim()));
70
+ return { [t]: {
71
71
  gte: s,
72
72
  lte: n
73
73
  } };
74
74
  }
75
75
  default:
76
- return { [e]: { equals: this.coerce(r) } };
76
+ return { [t]: { equals: this.coerce(i) } };
77
77
  }
78
78
  });
79
79
  }
80
- buildSort(t) {
81
- return t.map((i) => ({ [i.field]: i.direction }));
80
+ buildSort(e) {
81
+ return e.map((r) => ({ [r.field]: r.direction }));
82
82
  }
83
- buildSearch(t, i) {
84
- return !t || !i || i.length === 0 ? null : { OR: i.map((e) => ({ [e]: {
85
- contains: t,
83
+ buildSearch(e, r) {
84
+ return !e || !r || r.length === 0 ? null : { OR: r.map((t) => ({ [t]: {
85
+ contains: e,
86
86
  mode: "insensitive"
87
87
  } })) };
88
88
  }
89
- coerce(t) {
90
- if (t === "true") return !0;
91
- if (t === "false") return !1;
92
- const i = Number(t);
93
- return !Number.isNaN(i) && t.trim() !== "" ? i : t;
89
+ coerce(e) {
90
+ if (e === "true") return !0;
91
+ if (e === "false") return !1;
92
+ const r = Number(e);
93
+ return !Number.isNaN(r) && e.trim() !== "" ? r : e;
94
94
  }
95
95
  };
96
96
  export {
97
- d as PRISMA_CLIENT,
98
- f as PrismaAdapter,
99
- p as PrismaQueryAdapter
97
+ h as PRISMA_CLIENT,
98
+ m as PrismaAdapter,
99
+ f as PrismaQueryAdapter
100
100
  };
@@ -1,4 +1,4 @@
1
- import { type AppAdapter, type Container } from '@forinda/kickjs-core';
1
+ import { type AppAdapter, type AdapterContext } from '@forinda/kickjs-core';
2
2
  import { type PrismaAdapterOptions } from './types';
3
3
  /**
4
4
  * Prisma adapter — registers a PrismaClient in the DI container and manages
@@ -38,7 +38,7 @@ export declare class PrismaAdapter implements AppAdapter {
38
38
  private client;
39
39
  constructor(options: PrismaAdapterOptions);
40
40
  /** Register the PrismaClient in the DI container */
41
- beforeStart(_app: any, container: Container): void;
41
+ beforeStart({ container }: AdapterContext): void;
42
42
  /** Disconnect the PrismaClient on shutdown */
43
43
  shutdown(): Promise<void>;
44
44
  }
@@ -1 +1 @@
1
- {"version":3,"file":"prisma.adapter.d.ts","sourceRoot":"","sources":["../src/prisma.adapter.ts"],"names":[],"mappings":"AAAA,OAAO,EAAU,KAAK,UAAU,EAAE,KAAK,SAAS,EAAS,MAAM,sBAAsB,CAAA;AACrF,OAAO,EAAiB,KAAK,oBAAoB,EAAE,MAAM,SAAS,CAAA;AAIlE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AACH,qBAAa,aAAc,YAAW,UAAU;IAIlC,OAAO,CAAC,OAAO;IAH3B,IAAI,SAAkB;IACtB,OAAO,CAAC,MAAM,CAAK;gBAEC,OAAO,EAAE,oBAAoB;IAIjD,oDAAoD;IACpD,WAAW,CAAC,IAAI,EAAE,GAAG,EAAE,SAAS,EAAE,SAAS,GAAG,IAAI;IAiClD,8CAA8C;IACxC,QAAQ,IAAI,OAAO,CAAC,IAAI,CAAC;CAMhC"}
1
+ {"version":3,"file":"prisma.adapter.d.ts","sourceRoot":"","sources":["../src/prisma.adapter.ts"],"names":[],"mappings":"AAAA,OAAO,EAAU,KAAK,UAAU,EAAE,KAAK,cAAc,EAAS,MAAM,sBAAsB,CAAA;AAC1F,OAAO,EAAiB,KAAK,oBAAoB,EAAE,MAAM,SAAS,CAAA;AAIlE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AACH,qBAAa,aAAc,YAAW,UAAU;IAIlC,OAAO,CAAC,OAAO;IAH3B,IAAI,SAAkB;IACtB,OAAO,CAAC,MAAM,CAAK;gBAEC,OAAO,EAAE,oBAAoB;IAIjD,oDAAoD;IACpD,WAAW,CAAC,EAAE,SAAS,EAAE,EAAE,cAAc,GAAG,IAAI;IAiChD,8CAA8C;IACxC,QAAQ,IAAI,OAAO,CAAC,IAAI,CAAC;CAMhC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@forinda/kickjs-prisma",
3
- "version": "1.5.0",
3
+ "version": "1.7.0",
4
4
  "description": "Prisma ORM adapter with DI integration, transaction support, and query building for KickJS",
5
5
  "keywords": [
6
6
  "kickjs",
@@ -53,8 +53,8 @@
53
53
  ],
54
54
  "dependencies": {
55
55
  "reflect-metadata": "^0.2.2",
56
- "@forinda/kickjs-core": "1.5.0",
57
- "@forinda/kickjs-http": "1.5.0"
56
+ "@forinda/kickjs-http": "1.7.0",
57
+ "@forinda/kickjs-core": "1.7.0"
58
58
  },
59
59
  "peerDependencies": {
60
60
  "@prisma/client": ">=5.0.0"
@@ -65,7 +65,7 @@
65
65
  }
66
66
  },
67
67
  "devDependencies": {
68
- "@types/node": "^24.5.2",
68
+ "@types/node": "^25.0.0",
69
69
  "typescript": "^5.9.2"
70
70
  },
71
71
  "publishConfig": {