pg-interleave 0.3.2 → 0.4.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.d.ts CHANGED
@@ -4,6 +4,7 @@ export interface InterceptOptions {
4
4
  clientPid?: number;
5
5
  sessionTag?: string;
6
6
  onQueryMatch: string | RegExp;
7
+ withParams?: Array<string | number | boolean | null>;
7
8
  action?: "PAUSE_BEFORE_QUERY" | "PAUSE_AFTER_RESPONSE" | "pause_before_query" | "pause_after_response";
8
9
  times?: number;
9
10
  }
package/dist/index.js CHANGED
@@ -93,16 +93,24 @@ class PgInterleaveClient {
93
93
  const action = options.action
94
94
  ? options.action.toLowerCase()
95
95
  : "pause_before_query";
96
+ const serializedParams = options.withParams !== undefined
97
+ ? options.withParams.map((p) => (p === null || p === undefined ? null : String(p)))
98
+ : undefined;
99
+ const body = {
100
+ query_pattern: pattern,
101
+ action,
102
+ times: options.times ?? 1,
103
+ };
104
+ if (pid !== undefined)
105
+ body.target_pid = pid;
106
+ if (options.sessionTag !== undefined)
107
+ body.session_tag = options.sessionTag;
108
+ if (serializedParams !== undefined)
109
+ body.with_params = serializedParams;
96
110
  const res = await fetch(`${this.controlUrl}/intercept`, {
97
111
  method: "POST",
98
112
  headers: { "Content-Type": "application/json" },
99
- body: JSON.stringify({
100
- target_pid: pid ?? null,
101
- session_tag: options.sessionTag ?? null,
102
- query_pattern: pattern,
103
- action,
104
- times: options.times ?? 1,
105
- }),
113
+ body: JSON.stringify(body),
106
114
  });
107
115
  if (!res.ok) {
108
116
  const errBody = await res.text();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pg-interleave",
3
- "version": "0.3.2",
3
+ "version": "0.4.0",
4
4
  "description": "Deterministic PostgreSQL wire-protocol proxy client for concurrency and chaos testing",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",