kuwan-expresspack-core 0.1.8 → 0.1.10

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/env.d.ts ADDED
@@ -0,0 +1,26 @@
1
+ import { z } from 'zod';
2
+
3
+ declare function parseEnv<T extends z.ZodType>(schema: T, env: Record<string, string | undefined>): z.infer<T> | undefined;
4
+ /**
5
+ * Load env with types and validation from a Zod schema
6
+ *
7
+ * @param appRoot
8
+ * @param zodSchema
9
+ * @param env
10
+ */
11
+ declare function create<T extends z.ZodType>(appRoot: string | URL, zodSchema: T, env?: Record<string, string | undefined>): z.infer<T>;
12
+ /**
13
+ * Helper type to infer the environment variable types from a Zod schema
14
+ *
15
+ * @example
16
+ * ```
17
+ * export type Env = InferEnv<typeof envSchema>;
18
+ * ```
19
+ */
20
+ type InferEnv<T extends z.ZodType> = z.infer<T>;
21
+ declare const _default: {
22
+ create: typeof create;
23
+ parseEnv: typeof parseEnv;
24
+ };
25
+
26
+ export { type InferEnv, create, _default as default, parseEnv };
package/dist/env.mjs ADDED
@@ -0,0 +1,5 @@
1
+ import { z } from 'zod';
2
+
3
+ function t(n,r){let e=n.safeParse(r);return e.success||(console.error("\u274C Invalid environment variables:"),console.error(z.prettifyError(e.error))),e?.data}function s(n,r,e){return t(r,e||process.env)||{}}var a={create:s,parseEnv:t};
4
+
5
+ export { s as create, a as default, t as parseEnv };
@@ -0,0 +1,24 @@
1
+ import { RootOperationNode, LogEvent } from 'kysely';
2
+
3
+ type KyselyLoggerParams = {
4
+ sql: string;
5
+ params: readonly unknown[];
6
+ duration: number;
7
+ queryNode?: RootOperationNode;
8
+ error?: unknown;
9
+ };
10
+ type KyselyLoggerOptions = {
11
+ logger: (data: KyselyLoggerParams) => void;
12
+ merge: boolean;
13
+ logQueryNode: boolean;
14
+ };
15
+ /**
16
+ * Obtained from:
17
+ * https://github.com/subframe7536/kysely-sqlite-tools/blob/master/packages/sqlite-utils/src/logger.ts
18
+ *
19
+ * The goal was to log the SQL and parameters of the query executed by Kysely instead
20
+ * of having the SQL logs with the question marks.
21
+ */
22
+ declare function createKyselyLogger(options: KyselyLoggerOptions): (event: LogEvent) => void;
23
+
24
+ export { type KyselyLoggerOptions, type KyselyLoggerParams, createKyselyLogger };
@@ -0,0 +1,3 @@
1
+ function L(g){let{logger:l,merge:y,logQueryNode:i}=g;return t=>{let{level:p,queryDurationMillis:u,query:{parameters:n,sql:c,query:d}}=t,a="__Q__",f=p==="error"?t.error:void 0,r=c.replace(/\r?\n/g," ").replace(/\s+/g," ");y&&n.forEach(o=>{let e=o;o instanceof Date&&(e=o.toLocaleString()),typeof e=="string"&&(e=`'${e}'`.replace(/\?/g,a)),r=r.replace(/\?/,e);});let s={sql:r.replace(new RegExp(a,"g"),"?"),params:n,duration:u,error:f};i&&(s.queryNode=d),l(s);}}
2
+
3
+ export { L as createKyselyLogger };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "kuwan-expresspack-core",
3
- "version": "0.1.8",
3
+ "version": "0.1.10",
4
4
  "description": "",
5
5
  "type": "module",
6
6
  "main": "./dist/index.mjs",
@@ -68,6 +68,10 @@
68
68
  "./utils/dynamic-import": {
69
69
  "types": "./dist/utils/dynamic-import.d.ts",
70
70
  "import": "./dist/utils/dynamic-import.mjs"
71
+ },
72
+ "./thrid-party/kysely-logger": {
73
+ "types": "./dist/third-party/kysely-logger.d.ts",
74
+ "import": "./dist/third-party/kysely-logger.mjs"
71
75
  }
72
76
  },
73
77
  "dependencies": {
@@ -103,7 +107,8 @@
103
107
  "@types/express": "^5.0.3",
104
108
  "eslint": "^9.37.0",
105
109
  "express": "^5.1.0",
106
- "typescript": "^5.9.3"
110
+ "typescript": "^5.9.3",
111
+ "kysely": "^0.28.8"
107
112
  },
108
113
  "sideEffects": false,
109
114
  "scripts": {