@compforge/harness-toolbox 0.4.4 → 0.4.7
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 +10 -0
- package/dist/{chunk-2171tajs.js → chunk-1ts7pswj.js} +4 -3
- package/dist/chunk-835fssgz.js +37 -0
- package/dist/{chunk-mn6dwsvh.js → chunk-9shz0bw1.js} +3 -1
- package/dist/{chunk-0s27bgga.js → chunk-ae84rzq5.js} +1 -1
- package/dist/{chunk-age65q4n.js → chunk-db4an9td.js} +1 -1
- package/dist/{chunk-ftkrjqkc.js → chunk-dpcge1xt.js} +1 -1
- package/dist/{chunk-grpygk6f.js → chunk-dx6yvj81.js} +2 -2
- package/dist/{chunk-sqbew04a.js → chunk-f3vq900j.js} +2 -2
- package/dist/{chunk-yp6tcw22.js → chunk-f98qrpx1.js} +38 -78
- package/dist/{chunk-wv4jwhvj.js → chunk-fqrknvr8.js} +2 -2
- package/dist/chunk-gm4swndx.js +106 -0
- package/dist/{chunk-c2n8zvyn.js → chunk-m391jmpw.js} +8 -8
- package/dist/chunk-m4d29vfd.js +236 -0
- package/dist/{chunk-631vce5z.js → chunk-nftzckdy.js} +57 -7
- package/dist/{chunk-shsabpc1.js → chunk-r3rnsvwv.js} +1 -1
- package/dist/{chunk-20kv4wc3.js → chunk-rkt41za2.js} +7 -1
- package/dist/{chunk-hmah9t8e.js → chunk-rq5fc007.js} +1 -1
- package/dist/{chunk-h73h2b7y.js → chunk-t4hrnaj0.js} +44 -39
- package/dist/{chunk-kkts16w9.js → chunk-ww11q58v.js} +1 -1
- package/dist/{chunk-4ms037k2.js → chunk-x0yhfg29.js} +2 -2
- package/dist/{chunk-j46x7j7c.js → chunk-xgnz10sr.js} +5 -3
- package/dist/{chunk-5zgz1z41.js → chunk-z15gwjvg.js} +1 -1
- package/dist/connection/acquire.d.ts +34 -0
- package/dist/connection/acquire.js +9 -0
- package/dist/datasource.js +1 -1
- package/dist/errors.d.ts +4 -0
- package/dist/errors.js +3 -1
- package/dist/file/client.js +2 -2
- package/dist/file/index.js +4 -4
- package/dist/file/local.js +3 -3
- package/dist/file/pod.js +3 -3
- package/dist/kubernetes/client.js +11 -11
- package/dist/kubernetes/compute-quantity.js +2 -2
- package/dist/kubernetes/compute.js +2 -2
- package/dist/kubernetes/environment.js +11 -11
- package/dist/kubernetes/exec-transport.js +2 -2
- package/dist/kubernetes/executor.js +2 -2
- package/dist/kubernetes/pod-log-datasource.js +1 -1
- package/dist/kubernetes/pod-log.js +1 -1
- package/dist/kubernetes/port-forward.d.ts +5 -0
- package/dist/kubernetes/port-forward.js +3 -3
- package/dist/kubernetes/resource-transport.js +3 -3
- package/dist/kubernetes/resources.js +2 -2
- package/dist/kubernetes/service-port-forward.d.ts +2 -0
- package/dist/kubernetes/service-port-forward.js +5 -5
- package/dist/kubernetes/service.d.ts +1 -1
- package/dist/kubernetes/service.js +1 -1
- package/dist/kubernetes/workload.js +2 -2
- package/dist/mysql/client.d.ts +5 -2
- package/dist/mysql/client.js +9 -8
- package/dist/mysql/connection.d.ts +3 -0
- package/dist/mysql/connection.js +4 -2
- package/dist/mysql/index.js +10 -9
- package/dist/mysql/readonly.js +2 -2
- package/dist/opensearch/client.d.ts +14 -3
- package/dist/opensearch/client.js +9 -6
- package/dist/opensearch/index.js +9 -6
- package/dist/process/index.d.ts +1 -1
- package/dist/process/index.js +1 -1
- package/dist/redis/client.js +7 -6
- package/dist/redis/index.js +11 -10
- package/dist/s3/datasource.js +5 -5
- package/dist/s3/index.js +5 -5
- package/dist/transport/index.js +4 -4
- package/dist/transport/pod-relay.js +4 -4
- package/package.json +1 -4
- package/dist/chunk-136egyff.js +0 -11
- package/dist/chunk-8mb6natq.js +0 -178
package/dist/s3/index.js
CHANGED
|
@@ -2,17 +2,17 @@ import {
|
|
|
2
2
|
S3DataSource
|
|
3
3
|
} from "../chunk-35cjec9z.js";
|
|
4
4
|
import"../chunk-z5pm2emz.js";
|
|
5
|
-
import"../chunk-
|
|
5
|
+
import"../chunk-rkt41za2.js";
|
|
6
6
|
import {
|
|
7
7
|
S3Client
|
|
8
8
|
} from "../chunk-zp1s833x.js";
|
|
9
9
|
import"../chunk-v3hxvnrc.js";
|
|
10
10
|
import"../chunk-x4ntb898.js";
|
|
11
11
|
import"../chunk-h8fwx0k7.js";
|
|
12
|
-
import"../chunk-
|
|
13
|
-
import"../chunk-
|
|
14
|
-
import"../chunk-
|
|
15
|
-
import"../chunk-
|
|
12
|
+
import"../chunk-fqrknvr8.js";
|
|
13
|
+
import"../chunk-nftzckdy.js";
|
|
14
|
+
import"../chunk-rq5fc007.js";
|
|
15
|
+
import"../chunk-9shz0bw1.js";
|
|
16
16
|
import"../chunk-ssj93brx.js";
|
|
17
17
|
export {
|
|
18
18
|
S3DataSource,
|
package/dist/transport/index.js
CHANGED
|
@@ -6,10 +6,10 @@ import {
|
|
|
6
6
|
} from "../chunk-h8fwx0k7.js";
|
|
7
7
|
import {
|
|
8
8
|
PodRelayTransport
|
|
9
|
-
} from "../chunk-
|
|
10
|
-
import"../chunk-
|
|
11
|
-
import"../chunk-
|
|
12
|
-
import"../chunk-
|
|
9
|
+
} from "../chunk-fqrknvr8.js";
|
|
10
|
+
import"../chunk-nftzckdy.js";
|
|
11
|
+
import"../chunk-rq5fc007.js";
|
|
12
|
+
import"../chunk-9shz0bw1.js";
|
|
13
13
|
import"../chunk-ssj93brx.js";
|
|
14
14
|
export {
|
|
15
15
|
isConnectionNetworkError,
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import {
|
|
2
2
|
PodRelayTransport
|
|
3
|
-
} from "../chunk-
|
|
4
|
-
import"../chunk-
|
|
5
|
-
import"../chunk-
|
|
6
|
-
import"../chunk-
|
|
3
|
+
} from "../chunk-fqrknvr8.js";
|
|
4
|
+
import"../chunk-nftzckdy.js";
|
|
5
|
+
import"../chunk-rq5fc007.js";
|
|
6
|
+
import"../chunk-9shz0bw1.js";
|
|
7
7
|
import"../chunk-ssj93brx.js";
|
|
8
8
|
export {
|
|
9
9
|
PodRelayTransport
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@compforge/harness-toolbox",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.7",
|
|
4
4
|
"description": "Shared infrastructure clients, transports and bounded data capture",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"scripts": {
|
|
@@ -116,9 +116,6 @@
|
|
|
116
116
|
"@types/node": "^22",
|
|
117
117
|
"@types/ws": "^8.18.1"
|
|
118
118
|
},
|
|
119
|
-
"overrides": {
|
|
120
|
-
"@compforge/harness-common": "file:../common"
|
|
121
|
-
},
|
|
122
119
|
"publishConfig": {
|
|
123
120
|
"access": "public"
|
|
124
121
|
},
|
package/dist/chunk-136egyff.js
DELETED
package/dist/chunk-8mb6natq.js
DELETED
|
@@ -1,178 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
ToolboxError
|
|
3
|
-
} from "./chunk-20kv4wc3.js";
|
|
4
|
-
import {
|
|
5
|
-
isConnectionNetworkError
|
|
6
|
-
} from "./chunk-h8fwx0k7.js";
|
|
7
|
-
|
|
8
|
-
// src/opensearch/client.ts
|
|
9
|
-
import { Client, Connection, errors } from "@opensearch-project/opensearch";
|
|
10
|
-
function isOpenSearchReadApi(search) {
|
|
11
|
-
return typeof search.request === "function";
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
class OpenSearchConnection extends Connection {
|
|
15
|
-
buildRequestObject(params) {
|
|
16
|
-
return { ...super.buildRequestObject(params), servername: this.ssl?.servername };
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
|
-
function createClient(options) {
|
|
20
|
-
return new Client({
|
|
21
|
-
node: options.node,
|
|
22
|
-
Connection: OpenSearchConnection,
|
|
23
|
-
auth: options.auth.username && options.auth.password ? { username: options.auth.username, password: options.auth.password } : undefined,
|
|
24
|
-
ssl: { rejectUnauthorized: false, servername: options.servername },
|
|
25
|
-
requestTimeout: options.requestTimeoutMs ?? 60000,
|
|
26
|
-
maxRetries: 0,
|
|
27
|
-
agent: { keepAlive: !process.versions.bun }
|
|
28
|
-
});
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
class OpenSearchEngine {
|
|
32
|
-
client;
|
|
33
|
-
constructor(options, client) {
|
|
34
|
-
this.client = client ?? createClient(options);
|
|
35
|
-
}
|
|
36
|
-
async count(index, query) {
|
|
37
|
-
const response = await this.client.count({ index, body: { query } });
|
|
38
|
-
return Number(response.body.count ?? 0);
|
|
39
|
-
}
|
|
40
|
-
async search(index, body) {
|
|
41
|
-
const response = await this.client.search({ index, body });
|
|
42
|
-
return response.body;
|
|
43
|
-
}
|
|
44
|
-
async request(path, query) {
|
|
45
|
-
if (!this.client.transport)
|
|
46
|
-
throw new Error("OpenSearch client 不支持通用只读请求");
|
|
47
|
-
const response = await this.client.transport.request({
|
|
48
|
-
method: "GET",
|
|
49
|
-
path,
|
|
50
|
-
querystring: query
|
|
51
|
-
});
|
|
52
|
-
return response.body;
|
|
53
|
-
}
|
|
54
|
-
async ping(signal, timeoutMs) {
|
|
55
|
-
signal?.throwIfAborted();
|
|
56
|
-
const request = this.client.ping({}, timeoutMs === undefined ? undefined : { requestTimeout: timeoutMs });
|
|
57
|
-
const abort = () => {
|
|
58
|
-
request.abort?.();
|
|
59
|
-
};
|
|
60
|
-
signal?.addEventListener("abort", abort, { once: true });
|
|
61
|
-
try {
|
|
62
|
-
return await request;
|
|
63
|
-
} finally {
|
|
64
|
-
signal?.removeEventListener("abort", abort);
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
close() {
|
|
68
|
-
return this.client.close();
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
class OpenSearchClient {
|
|
73
|
-
source;
|
|
74
|
-
lifecycle;
|
|
75
|
-
#controller = new AbortController;
|
|
76
|
-
signal;
|
|
77
|
-
#initialization;
|
|
78
|
-
#disposal;
|
|
79
|
-
#engine;
|
|
80
|
-
#operations = new Set;
|
|
81
|
-
constructor(source, lifecycle = {}) {
|
|
82
|
-
this.source = source;
|
|
83
|
-
this.lifecycle = lifecycle;
|
|
84
|
-
this.signal = lifecycle.signal ? AbortSignal.any([lifecycle.signal, this.#controller.signal]) : this.#controller.signal;
|
|
85
|
-
}
|
|
86
|
-
initialize() {
|
|
87
|
-
this.signal.throwIfAborted();
|
|
88
|
-
return this.#initialization ??= (async () => {
|
|
89
|
-
const target = await this.source.resolve();
|
|
90
|
-
this.signal.throwIfAborted();
|
|
91
|
-
const original = new URL(target.node);
|
|
92
|
-
let reason;
|
|
93
|
-
for (const [index, transport] of this.source.transports.entries()) {
|
|
94
|
-
this.signal.throwIfAborted();
|
|
95
|
-
if (transport.kind !== "tcp")
|
|
96
|
-
throw new Error("OpenSearch requires a TCP transport");
|
|
97
|
-
let engine;
|
|
98
|
-
try {
|
|
99
|
-
const endpoint = await transport.connect({
|
|
100
|
-
host: original.hostname,
|
|
101
|
-
port: Number(original.port || (original.protocol === "https:" ? 443 : 80)),
|
|
102
|
-
servername: target.servername ?? original.hostname
|
|
103
|
-
});
|
|
104
|
-
this.signal.throwIfAborted();
|
|
105
|
-
const url = new URL(original);
|
|
106
|
-
url.hostname = endpoint.host;
|
|
107
|
-
url.port = String(endpoint.port);
|
|
108
|
-
engine = new OpenSearchEngine({ ...target, node: url.toString(), servername: endpoint.servername ?? target.servername ?? original.hostname });
|
|
109
|
-
await engine.ping(this.signal, target.connectTimeoutMs ?? target.requestTimeoutMs ?? 1e4);
|
|
110
|
-
this.signal.throwIfAborted();
|
|
111
|
-
this.lifecycle.onRoute?.({ transport: transport.name, reason });
|
|
112
|
-
this.#engine = engine;
|
|
113
|
-
return;
|
|
114
|
-
} catch (error) {
|
|
115
|
-
await engine?.close();
|
|
116
|
-
this.signal.throwIfAborted();
|
|
117
|
-
const network = isConnectionNetworkError(error);
|
|
118
|
-
if (!network && !(error instanceof errors.ConnectionError) && !(error instanceof errors.TimeoutError))
|
|
119
|
-
throw error;
|
|
120
|
-
reason = network ? String(error.code) : error.name;
|
|
121
|
-
if (index === this.source.transports.length - 1) {
|
|
122
|
-
throw new ToolboxError(`OpenSearch connect failed (${reason})`, { kind: "connection_failed", code: reason, cause: error });
|
|
123
|
-
}
|
|
124
|
-
}
|
|
125
|
-
}
|
|
126
|
-
throw new Error("OpenSearch DataSource has no transport");
|
|
127
|
-
})();
|
|
128
|
-
}
|
|
129
|
-
#ready() {
|
|
130
|
-
this.signal.throwIfAborted();
|
|
131
|
-
if (!this.#engine)
|
|
132
|
-
throw new Error("OpenSearch client is not initialized");
|
|
133
|
-
return this.#engine;
|
|
134
|
-
}
|
|
135
|
-
#run(operation) {
|
|
136
|
-
const engine = this.#ready();
|
|
137
|
-
const pending = operation(engine);
|
|
138
|
-
this.#operations.add(pending);
|
|
139
|
-
pending.then(() => this.#operations.delete(pending), () => this.#operations.delete(pending));
|
|
140
|
-
return pending;
|
|
141
|
-
}
|
|
142
|
-
count(index, query) {
|
|
143
|
-
return this.#run((engine) => engine.count(index, query));
|
|
144
|
-
}
|
|
145
|
-
search(index, body) {
|
|
146
|
-
return this.#run((engine) => engine.search(index, body));
|
|
147
|
-
}
|
|
148
|
-
request(path, query) {
|
|
149
|
-
return this.#run((engine) => engine.request(path, query));
|
|
150
|
-
}
|
|
151
|
-
ping() {
|
|
152
|
-
return this.#run((engine) => engine.ping());
|
|
153
|
-
}
|
|
154
|
-
close() {
|
|
155
|
-
return this.dispose();
|
|
156
|
-
}
|
|
157
|
-
dispose() {
|
|
158
|
-
return this.#disposal ??= (async () => {
|
|
159
|
-
this.#controller.abort(new Error("OpenSearch client disposed"));
|
|
160
|
-
await this.#initialization?.catch(() => {});
|
|
161
|
-
await Promise.allSettled(this.#operations);
|
|
162
|
-
await this.#engine?.close();
|
|
163
|
-
})();
|
|
164
|
-
}
|
|
165
|
-
}
|
|
166
|
-
async function openOpenSearch(source, lifecycle = {}) {
|
|
167
|
-
const client = new OpenSearchClient(source, lifecycle);
|
|
168
|
-
try {
|
|
169
|
-
await client.initialize();
|
|
170
|
-
} catch (error) {
|
|
171
|
-
await client.dispose();
|
|
172
|
-
throw error;
|
|
173
|
-
}
|
|
174
|
-
lifecycle.onDispose?.(() => client.dispose());
|
|
175
|
-
return client;
|
|
176
|
-
}
|
|
177
|
-
|
|
178
|
-
export { isOpenSearchReadApi, OpenSearchEngine, OpenSearchClient, openOpenSearch };
|