@technicity/data-service-generator 0.23.0-next.7 → 0.23.0-next.9

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.
@@ -9,6 +9,9 @@ type IGenerateInput = {
9
9
  host?: string;
10
10
  port?: number;
11
11
  server?: string;
12
+ clientOpts?: {
13
+ [k: string]: any;
14
+ };
12
15
  outdir: string;
13
16
  tables?: Array<string>;
14
17
  excludeTables?: Array<string>;
@@ -234,7 +234,8 @@ function init(input) {
234
234
  password,
235
235
  host: host ?? "localhost",
236
236
  port: port ?? 3306,
237
- database
237
+ database,
238
+ ...input.clientOpts
238
239
  };
239
240
  const mysql = new MySQL_1.MySQL(connectionOpts);
240
241
  ctx.query = mysql.query.bind(mysql);
@@ -246,7 +247,8 @@ function init(input) {
246
247
  port: port ?? 5432,
247
248
  user,
248
249
  password,
249
- database
250
+ database,
251
+ ...input.clientOpts
250
252
  };
251
253
  const pool = new pg_1.Pool(connectionOpts);
252
254
  ctx.query = (q, values) => pool.query(q, values ?? []).then((r) => r.rows);
@@ -637,6 +639,7 @@ function getMethodSourceOnHandlerPostOne(x) {
637
639
  return `on${(0, capitalizeFirstLetter_1.capitalizeFirstLetter)(x.methodName)}(handler:
638
640
  (sdk: InstanceType<typeof SDK>, input: { data: ${x.typeDataName} },
639
641
  output: Partial<${getTypeReturnName(x.table)}>,
642
+ before: null,
640
643
  context: TContext,
641
644
  ) => Promise<void>
642
645
  ): void {
@@ -751,6 +754,7 @@ function getMethodSourceOnHandlerDeleteOne(x, findOnes) {
751
754
  .map((findOne) => `{ ${findOne.name}: ${findOne.type}${findOne.nullable ? " | null" : ""} }`)
752
755
  .join(" | ")}, },
753
756
  output: void,
757
+ before: ${getTypeReturnName(x.table)} | null,
754
758
  context: TContext,
755
759
  ) => Promise<void>
756
760
  ): void {
@@ -70,7 +70,9 @@ async function resolve(input, dbCall, formatQuery, beginTransaction, dialect, mi
70
70
  const shouldRunOnHandler = typeof onHandler === "function" &&
71
71
  asyncLocalStorage != null &&
72
72
  asyncLocalStorage?.getStore()?.isInOnHandler !== true;
73
- const beforeValue = shouldRunOnHandler && input.passBeforeValueToAfterCallback
73
+ const beforeValue = shouldRunOnHandler &&
74
+ input.passBeforeValueToAfterCallback &&
75
+ input.action !== "create"
74
76
  ? await _resolve({
75
77
  ...paramsChanged,
76
78
  action: paramsChanged.action === "updateMany" ||
@@ -103,7 +105,9 @@ async function resolve(input, dbCall, formatQuery, beginTransaction, dialect, mi
103
105
  const shouldRunOnHandler = typeof onHandler === "function" &&
104
106
  asyncLocalStorage != null &&
105
107
  asyncLocalStorage?.getStore()?.isInOnHandler !== true;
106
- const beforeValue = shouldRunOnHandler && input.passBeforeValueToAfterCallback
108
+ const beforeValue = shouldRunOnHandler &&
109
+ input.passBeforeValueToAfterCallback &&
110
+ input.action !== "create"
107
111
  ? await _resolve({
108
112
  ...input,
109
113
  action: input.action === "updateMany" || input.action === "deleteMany"
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@technicity/data-service-generator",
3
- "version": "0.23.0-next.7",
3
+ "version": "0.23.0-next.9",
4
4
  "main": "./dist/index.js",
5
5
  "files": [
6
6
  "dist"