callman-core 1.40.0 → 1.41.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.
Files changed (66) hide show
  1. package/dist/host/db/dbPool.d.ts +94 -0
  2. package/dist/host/db/dbPool.d.ts.map +1 -0
  3. package/dist/host/db/dbPool.js +258 -0
  4. package/dist/host/db/dbPool.js.map +1 -0
  5. package/dist/host/db/dbTimings.d.ts +13 -0
  6. package/dist/host/db/dbTimings.d.ts.map +1 -0
  7. package/dist/host/db/dbTimings.js +9 -0
  8. package/dist/host/db/dbTimings.js.map +1 -0
  9. package/dist/host/db/mongoAdapter.d.ts +2 -0
  10. package/dist/host/db/mongoAdapter.d.ts.map +1 -1
  11. package/dist/host/db/mongoAdapter.js +44 -3
  12. package/dist/host/db/mongoAdapter.js.map +1 -1
  13. package/dist/host/db/mssqlAdapter.d.ts +2 -0
  14. package/dist/host/db/mssqlAdapter.d.ts.map +1 -1
  15. package/dist/host/db/mssqlAdapter.js +75 -4
  16. package/dist/host/db/mssqlAdapter.js.map +1 -1
  17. package/dist/host/db/mysqlAdapter.d.ts +2 -0
  18. package/dist/host/db/mysqlAdapter.d.ts.map +1 -1
  19. package/dist/host/db/mysqlAdapter.js +83 -2
  20. package/dist/host/db/mysqlAdapter.js.map +1 -1
  21. package/dist/host/db/oracleAdapter.d.ts +2 -0
  22. package/dist/host/db/oracleAdapter.d.ts.map +1 -1
  23. package/dist/host/db/oracleAdapter.js +90 -0
  24. package/dist/host/db/oracleAdapter.js.map +1 -1
  25. package/dist/host/db/postgresAdapter.d.ts +2 -0
  26. package/dist/host/db/postgresAdapter.d.ts.map +1 -1
  27. package/dist/host/db/postgresAdapter.js +58 -1
  28. package/dist/host/db/postgresAdapter.js.map +1 -1
  29. package/dist/host/db/queryExecutor.d.ts +2 -0
  30. package/dist/host/db/queryExecutor.d.ts.map +1 -1
  31. package/dist/host/db/queryExecutor.js.map +1 -1
  32. package/dist/host/index.d.ts +2 -0
  33. package/dist/host/index.d.ts.map +1 -1
  34. package/dist/host/index.js +1 -0
  35. package/dist/host/index.js.map +1 -1
  36. package/dist/request/executeRequest.d.ts.map +1 -1
  37. package/dist/request/executeRequest.js +3 -1
  38. package/dist/request/executeRequest.js.map +1 -1
  39. package/dist/request/httpTimings.d.ts +10 -0
  40. package/dist/request/httpTimings.d.ts.map +1 -0
  41. package/dist/request/httpTimings.js +131 -0
  42. package/dist/request/httpTimings.js.map +1 -0
  43. package/dist/types/index.d.ts +22 -0
  44. package/dist/types/index.d.ts.map +1 -1
  45. package/dist-cjs/host/db/dbPool.js +272 -0
  46. package/dist-cjs/host/db/dbPool.js.map +1 -0
  47. package/dist-cjs/host/db/dbTimings.js +14 -0
  48. package/dist-cjs/host/db/dbTimings.js.map +1 -0
  49. package/dist-cjs/host/db/mongoAdapter.js +44 -3
  50. package/dist-cjs/host/db/mongoAdapter.js.map +1 -1
  51. package/dist-cjs/host/db/mssqlAdapter.js +75 -4
  52. package/dist-cjs/host/db/mssqlAdapter.js.map +1 -1
  53. package/dist-cjs/host/db/mysqlAdapter.js +83 -2
  54. package/dist-cjs/host/db/mysqlAdapter.js.map +1 -1
  55. package/dist-cjs/host/db/oracleAdapter.js +90 -0
  56. package/dist-cjs/host/db/oracleAdapter.js.map +1 -1
  57. package/dist-cjs/host/db/postgresAdapter.js +58 -1
  58. package/dist-cjs/host/db/postgresAdapter.js.map +1 -1
  59. package/dist-cjs/host/db/queryExecutor.js.map +1 -1
  60. package/dist-cjs/host/index.js +10 -2
  61. package/dist-cjs/host/index.js.map +1 -1
  62. package/dist-cjs/request/executeRequest.js +3 -1
  63. package/dist-cjs/request/executeRequest.js.map +1 -1
  64. package/dist-cjs/request/httpTimings.js +168 -0
  65. package/dist-cjs/request/httpTimings.js.map +1 -0
  66. package/package.json +1 -1
@@ -0,0 +1,168 @@
1
+ "use strict";
2
+ // Per-request HTTP phase timings for `executeRequest` (Node hosts only).
3
+ //
4
+ // axios hides the ClientRequest/socket, so the phases are observed from the
5
+ // outside: Node's `http.client.request.*` diagnostics channels announce every
6
+ // ClientRequest, and an AsyncLocalStorage store opened around the axios call
7
+ // tells the subscriber which `executeRequest` call (if any) a request belongs
8
+ // to — concurrent calls never mix. Redirect hops are summed, like k6.
9
+ //
10
+ // Node builtins are imported LAZILY: this module is reachable from the
11
+ // renderer bundle through the barrel (see executeRequest.ts), and the browser
12
+ // never gets past `isNodeRuntime()`.
13
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
14
+ if (k2 === undefined) k2 = k;
15
+ var desc = Object.getOwnPropertyDescriptor(m, k);
16
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
17
+ desc = { enumerable: true, get: function() { return m[k]; } };
18
+ }
19
+ Object.defineProperty(o, k2, desc);
20
+ }) : (function(o, m, k, k2) {
21
+ if (k2 === undefined) k2 = k;
22
+ o[k2] = m[k];
23
+ }));
24
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
25
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
26
+ }) : function(o, v) {
27
+ o["default"] = v;
28
+ });
29
+ var __importStar = (this && this.__importStar) || (function () {
30
+ var ownKeys = function(o) {
31
+ ownKeys = Object.getOwnPropertyNames || function (o) {
32
+ var ar = [];
33
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
34
+ return ar;
35
+ };
36
+ return ownKeys(o);
37
+ };
38
+ return function (mod) {
39
+ if (mod && mod.__esModule) return mod;
40
+ var result = {};
41
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
42
+ __setModuleDefault(result, mod);
43
+ return result;
44
+ };
45
+ })();
46
+ Object.defineProperty(exports, "__esModule", { value: true });
47
+ exports.withHttpTimings = void 0;
48
+ let storePromise = null;
49
+ const isNodeRuntime = () => typeof process !== "undefined" &&
50
+ typeof process.versions?.node === "string" &&
51
+ typeof globalThis.window === "undefined";
52
+ const now = () => performance.now();
53
+ const round = (value) => Math.max(0, Math.round(value * 100) / 100);
54
+ const init = async () => {
55
+ if (!isNodeRuntime())
56
+ return null;
57
+ try {
58
+ const [{ AsyncLocalStorage }, diagnostics] = await Promise.all([
59
+ Promise.resolve().then(() => __importStar(require("node:async_hooks"))),
60
+ Promise.resolve().then(() => __importStar(require("node:diagnostics_channel"))),
61
+ ]);
62
+ const als = new AsyncLocalStorage();
63
+ const createdAt = new WeakMap();
64
+ diagnostics.subscribe("http.client.request.created", (message) => {
65
+ const { request } = message;
66
+ if (als.getStore())
67
+ createdAt.set(request, now());
68
+ });
69
+ diagnostics.subscribe("http.client.request.start", (message) => {
70
+ const collector = als.getStore();
71
+ if (!collector)
72
+ return;
73
+ const request = message.request;
74
+ const startedAt = createdAt.get(request) ?? now();
75
+ collector.hops += 1;
76
+ const watchSocket = (socket) => {
77
+ const assignedAt = now();
78
+ collector.blocked += assignedAt - startedAt;
79
+ let mark = assignedAt;
80
+ if (!socket.connecting) {
81
+ collector.reusedConnection = true;
82
+ return;
83
+ }
84
+ socket.once("lookup", () => {
85
+ const at = now();
86
+ collector.dns += at - mark;
87
+ mark = at;
88
+ });
89
+ socket.once("connect", () => {
90
+ const at = now();
91
+ collector.connect += at - mark;
92
+ mark = at;
93
+ });
94
+ socket.once("secureConnect", () => {
95
+ const at = now();
96
+ collector.tls += at - mark;
97
+ mark = at;
98
+ });
99
+ };
100
+ if (request.socket)
101
+ watchSocket(request.socket);
102
+ else
103
+ request.once("socket", watchSocket);
104
+ let sentAt = null;
105
+ request.once("finish", () => {
106
+ sentAt = now();
107
+ collector.send += sentAt - startedAt;
108
+ });
109
+ request.once("response", (response) => {
110
+ const firstByteAt = now();
111
+ collector.wait += firstByteAt - (sentAt ?? firstByteAt);
112
+ response.once("end", () => {
113
+ collector.receive += now() - firstByteAt;
114
+ });
115
+ });
116
+ });
117
+ return als;
118
+ }
119
+ catch {
120
+ return null;
121
+ }
122
+ };
123
+ const getStore = () => {
124
+ storePromise ??= init();
125
+ return storePromise;
126
+ };
127
+ /**
128
+ * Run `fn` (the axios call) and collect its HTTP phases. On non-Node hosts,
129
+ * or when the hooks are unavailable, `timings` is null and `fn` runs as is.
130
+ */
131
+ const withHttpTimings = async (fn) => {
132
+ const store = await getStore();
133
+ if (!store)
134
+ return { value: await fn(), timings: null };
135
+ const collector = {
136
+ blocked: 0,
137
+ dns: 0,
138
+ connect: 0,
139
+ tls: 0,
140
+ send: 0,
141
+ wait: 0,
142
+ receive: 0,
143
+ hops: 0,
144
+ reusedConnection: false,
145
+ };
146
+ const value = await store.run(collector, fn);
147
+ if (collector.hops === 0)
148
+ return { value, timings: null };
149
+ // `send` above is measured from request start (it includes connection
150
+ // setup); keep only the time spent writing the request.
151
+ const setup = collector.blocked + collector.dns + collector.connect + collector.tls;
152
+ return {
153
+ value,
154
+ timings: {
155
+ blocked: round(collector.blocked),
156
+ dns: round(collector.dns),
157
+ connect: round(collector.connect),
158
+ tls: round(collector.tls),
159
+ send: round(collector.send - setup),
160
+ wait: round(collector.wait),
161
+ receive: round(collector.receive),
162
+ redirects: Math.max(0, collector.hops - 1),
163
+ reusedConnection: collector.reusedConnection,
164
+ },
165
+ };
166
+ };
167
+ exports.withHttpTimings = withHttpTimings;
168
+ //# sourceMappingURL=httpTimings.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"httpTimings.js","sourceRoot":"","sources":["../../src/request/httpTimings.ts"],"names":[],"mappings":";AAAA,yEAAyE;AACzE,EAAE;AACF,4EAA4E;AAC5E,8EAA8E;AAC9E,6EAA6E;AAC7E,8EAA8E;AAC9E,sEAAsE;AACtE,EAAE;AACF,uEAAuE;AACvE,8EAA8E;AAC9E,qCAAqC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAkBrC,IAAI,YAAY,GAAiC,IAAI,CAAC;AAEtD,MAAM,aAAa,GAAG,GAAY,EAAE,CAClC,OAAO,OAAO,KAAK,WAAW;IA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K,GAAG,MAAM,KAAK,CAAC,GAAG,CAAC,SAAS,EAAE,EAAE,CAAC,CAAC;IAC7C,IAAI,SAAS,CAAC,IAAI,KAAK,CAAC;QAAE,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;IAC1D,sEAAsE;IACtE,wDAAwD;IACxD,MAAM,KAAK,GAAG,SAAS,CAAC,OAAO,GAAG,SAAS,CAAC,GAAG,GAAG,SAAS,CAAC,OAAO,GAAG,SAAS,CAAC,GAAG,CAAC;IACpF,OAAO;QACL,KAAK;QACL,OAAO,EAAE;YACP,OAAO,EAAE,KAAK,CAAC,SAAS,CAAC,OAAO,CAAC;YACjC,GAAG,EAAE,KAAK,CAAC,SAAS,CAAC,GAAG,CAAC;YACzB,OAAO,EAAE,KAAK,CAAC,SAAS,CAAC,OAAO,CAAC;YACjC,GAAG,EAAE,KAAK,CAAC,SAAS,CAAC,GAAG,CAAC;YACzB,IAAI,EAAE,KAAK,CAAC,SAAS,CAAC,IAAI,GAAG,KAAK,CAAC;YACnC,IAAI,EAAE,KAAK,CAAC,SAAS,CAAC,IAAI,CAAC;YAC3B,OAAO,EAAE,KAAK,CAAC,SAAS,CAAC,OAAO,CAAC;YACjC,SAAS,EAAE,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,SAAS,CAAC,IAAI,GAAG,CAAC,CAAC;YAC1C,gBAAgB,EAAE,SAAS,CAAC,gBAAgB;SAC7C;KACF,CAAC;AACJ,CAAC,CAAC;AAnCW,QAAA,eAAe,mBAmC1B"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "callman-core",
3
- "version": "1.40.0",
3
+ "version": "1.41.0",
4
4
  "main": "dist-cjs/index.js",
5
5
  "module": "dist/index.js",
6
6
  "types": "dist/index.d.ts",