@encore.dev/sdk 2.0.0-beta.8 → 2.0.0-beta.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.
Files changed (186) hide show
  1. package/README.md +54 -0
  2. package/app_meta.test.ts +25 -5
  3. package/app_meta.ts +43 -12
  4. package/config/config.test.ts +8 -12
  5. package/config/config.ts +16 -12
  6. package/config/secrets.ts +19 -10
  7. package/config/value.ts +13 -17
  8. package/cron/mod.test.ts +52 -0
  9. package/cron/mod.ts +9 -2
  10. package/dist/app_meta.d.ts +37 -12
  11. package/dist/app_meta.d.ts.map +1 -1
  12. package/dist/app_meta.js +1 -0
  13. package/dist/app_meta.js.map +1 -1
  14. package/dist/config/config.d.ts +16 -12
  15. package/dist/config/config.d.ts.map +1 -1
  16. package/dist/config/config.js +5 -2
  17. package/dist/config/config.js.map +1 -1
  18. package/dist/config/secrets.d.ts +19 -10
  19. package/dist/config/secrets.d.ts.map +1 -1
  20. package/dist/config/secrets.js +19 -10
  21. package/dist/config/secrets.js.map +1 -1
  22. package/dist/config/value.d.ts +7 -5
  23. package/dist/config/value.d.ts.map +1 -1
  24. package/dist/config/value.js +10 -7
  25. package/dist/config/value.js.map +1 -1
  26. package/dist/cron/mod.d.ts +5 -1
  27. package/dist/cron/mod.d.ts.map +1 -1
  28. package/dist/cron/mod.js +8 -1
  29. package/dist/cron/mod.js.map +1 -1
  30. package/dist/frontends/mod.d.ts +39 -0
  31. package/dist/frontends/mod.d.ts.map +1 -0
  32. package/dist/frontends/mod.js +47 -0
  33. package/dist/frontends/mod.js.map +1 -0
  34. package/dist/gateway/mod.d.ts +3 -2
  35. package/dist/gateway/mod.d.ts.map +1 -1
  36. package/dist/gateway/mod.js +3 -2
  37. package/dist/gateway/mod.js.map +1 -1
  38. package/dist/gateways/mod.d.ts +42 -0
  39. package/dist/gateways/mod.d.ts.map +1 -0
  40. package/dist/gateways/mod.js +55 -0
  41. package/dist/gateways/mod.js.map +1 -0
  42. package/dist/internal/fetch.d.ts +4 -0
  43. package/dist/internal/fetch.d.ts.map +1 -1
  44. package/dist/internal/fetch.js +12 -1
  45. package/dist/internal/fetch.js.map +1 -1
  46. package/dist/internal/otel/http.d.ts +11 -0
  47. package/dist/internal/otel/http.d.ts.map +1 -0
  48. package/dist/internal/otel/http.js +64 -0
  49. package/dist/internal/otel/http.js.map +1 -0
  50. package/dist/internal/otel/index.d.ts +1 -1
  51. package/dist/internal/otel/index.d.ts.map +1 -1
  52. package/dist/internal/otel/index.js +1 -1
  53. package/dist/internal/otel/index.js.map +1 -1
  54. package/dist/internal/otel/provider.d.ts +3 -0
  55. package/dist/internal/otel/provider.d.ts.map +1 -1
  56. package/dist/internal/otel/provider.js +3 -0
  57. package/dist/internal/otel/provider.js.map +1 -1
  58. package/dist/internal/otel/span.d.ts +11 -1
  59. package/dist/internal/otel/span.d.ts.map +1 -1
  60. package/dist/internal/otel/span.js +25 -2
  61. package/dist/internal/otel/span.js.map +1 -1
  62. package/dist/internal/reqfields.d.ts +26 -6
  63. package/dist/internal/reqfields.d.ts.map +1 -1
  64. package/dist/internal/reqfields.js +44 -7
  65. package/dist/internal/reqfields.js.map +1 -1
  66. package/dist/internal/runtime/napi/napi.cjs +36 -4
  67. package/dist/internal/runtime/napi/napi.d.cts +99 -4
  68. package/dist/internal/testing/carry.d.ts +49 -0
  69. package/dist/internal/testing/carry.d.ts.map +1 -0
  70. package/dist/internal/testing/carry.js +77 -0
  71. package/dist/internal/testing/carry.js.map +1 -0
  72. package/dist/internal/testing/scope.d.ts +34 -6
  73. package/dist/internal/testing/scope.d.ts.map +1 -1
  74. package/dist/internal/testing/scope.js +103 -5
  75. package/dist/internal/testing/scope.js.map +1 -1
  76. package/dist/internal/testing/steps.d.ts +55 -0
  77. package/dist/internal/testing/steps.d.ts.map +1 -0
  78. package/dist/internal/testing/steps.js +295 -0
  79. package/dist/internal/testing/steps.js.map +1 -0
  80. package/dist/internal/testing/telemetry.d.ts +305 -0
  81. package/dist/internal/testing/telemetry.d.ts.map +1 -0
  82. package/dist/internal/testing/telemetry.js +188 -0
  83. package/dist/internal/testing/telemetry.js.map +1 -0
  84. package/dist/mod.d.ts +1 -1
  85. package/dist/mod.d.ts.map +1 -1
  86. package/dist/mod.js.map +1 -1
  87. package/dist/pubsub/mod.d.ts +1 -1
  88. package/dist/pubsub/mod.d.ts.map +1 -1
  89. package/dist/pubsub/subscription.d.ts +6 -5
  90. package/dist/pubsub/subscription.d.ts.map +1 -1
  91. package/dist/pubsub/subscription.js.map +1 -1
  92. package/dist/pubsub/topic.d.ts +14 -8
  93. package/dist/pubsub/topic.d.ts.map +1 -1
  94. package/dist/pubsub/topic.js +36 -22
  95. package/dist/pubsub/topic.js.map +1 -1
  96. package/dist/reqctx/mod.d.ts +1 -18
  97. package/dist/reqctx/mod.d.ts.map +1 -1
  98. package/dist/reqctx/mod.js +1 -17
  99. package/dist/reqctx/mod.js.map +1 -1
  100. package/dist/services/index.d.ts +2 -1
  101. package/dist/services/index.d.ts.map +1 -1
  102. package/dist/services/index.js +2 -1
  103. package/dist/services/index.js.map +1 -1
  104. package/dist/storage/objects/bucket.d.ts +2 -1
  105. package/dist/storage/objects/bucket.d.ts.map +1 -1
  106. package/dist/storage/objects/bucket.js +2 -1
  107. package/dist/storage/objects/bucket.js.map +1 -1
  108. package/dist/storage/postgres/database.d.ts +5 -1
  109. package/dist/storage/postgres/database.d.ts.map +1 -1
  110. package/dist/storage/postgres/database.js +7 -3
  111. package/dist/storage/postgres/database.js.map +1 -1
  112. package/dist/storage/redis/commands.d.ts +5 -5
  113. package/dist/storage/redis/commands.d.ts.map +1 -1
  114. package/dist/storage/redis/commands.js +5 -5
  115. package/dist/storage/redis/commands.js.map +1 -1
  116. package/dist/testing/mod.d.ts +28 -5
  117. package/dist/testing/mod.d.ts.map +1 -1
  118. package/dist/testing/mod.js +52 -8
  119. package/dist/testing/mod.js.map +1 -1
  120. package/dist/testing/playwright.d.ts +93 -0
  121. package/dist/testing/playwright.d.ts.map +1 -0
  122. package/dist/testing/playwright.js +164 -0
  123. package/dist/testing/playwright.js.map +1 -0
  124. package/dist/testing/puppeteer.d.ts +36 -0
  125. package/dist/testing/puppeteer.d.ts.map +1 -0
  126. package/dist/testing/puppeteer.js +70 -0
  127. package/dist/testing/puppeteer.js.map +1 -0
  128. package/dist/testing/system.d.ts +181 -0
  129. package/dist/testing/system.d.ts.map +1 -0
  130. package/dist/testing/system.js +255 -0
  131. package/dist/testing/system.js.map +1 -0
  132. package/dist/tracing/http.d.ts +11 -0
  133. package/dist/tracing/http.d.ts.map +1 -0
  134. package/dist/tracing/http.js +34 -0
  135. package/dist/tracing/http.js.map +1 -0
  136. package/dist/tracing/mod.d.ts +1 -0
  137. package/dist/tracing/mod.d.ts.map +1 -1
  138. package/dist/tracing/mod.js +1 -0
  139. package/dist/tracing/mod.js.map +1 -1
  140. package/dist/tracing/node.d.ts +10 -0
  141. package/dist/tracing/node.d.ts.map +1 -0
  142. package/dist/tracing/node.js +142 -0
  143. package/dist/tracing/node.js.map +1 -0
  144. package/dist/tsconfig.build.tsbuildinfo +1 -1
  145. package/frontends/mod.test.ts +51 -0
  146. package/frontends/mod.ts +50 -0
  147. package/gateway/mod.ts +3 -2
  148. package/gateways/mod.ts +60 -0
  149. package/internal/fetch.ts +12 -1
  150. package/internal/otel/http.ts +91 -0
  151. package/internal/otel/index.ts +1 -1
  152. package/internal/otel/provider.ts +3 -0
  153. package/internal/otel/span.ts +25 -2
  154. package/internal/reqfields.ts +43 -10
  155. package/internal/runtime/napi/napi.cjs +36 -4
  156. package/internal/runtime/napi/napi.d.cts +99 -4
  157. package/internal/testing/carry.test.ts +242 -0
  158. package/internal/testing/carry.ts +101 -0
  159. package/internal/testing/scope.ts +106 -7
  160. package/internal/testing/steps.test.ts +152 -0
  161. package/internal/testing/steps.ts +342 -0
  162. package/internal/testing/telemetry.test.ts +210 -0
  163. package/internal/testing/telemetry.ts +466 -0
  164. package/mod.ts +1 -0
  165. package/package.json +26 -1
  166. package/pubsub/mod.ts +6 -1
  167. package/pubsub/pubsub.test.ts +1 -0
  168. package/pubsub/subscription.ts +6 -5
  169. package/pubsub/topic.ts +45 -21
  170. package/reqctx/mod.ts +1 -18
  171. package/reqctx/reqctx.test.ts +23 -0
  172. package/scripts/postprocess-docs.test.ts +11 -1
  173. package/services/index.ts +2 -1
  174. package/storage/objects/bucket.ts +2 -1
  175. package/storage/postgres/database.ts +7 -3
  176. package/storage/redis/commands.ts +5 -5
  177. package/testing/mod.ts +63 -7
  178. package/testing/playwright.ts +247 -0
  179. package/testing/puppeteer.ts +101 -0
  180. package/testing/system.test.ts +108 -0
  181. package/testing/system.ts +373 -0
  182. package/tracing/http.ts +49 -0
  183. package/tracing/mod.ts +1 -0
  184. package/tracing/native.test.ts +101 -4
  185. package/tracing/node.ts +176 -0
  186. package/tracing/tracing.test.ts +660 -24
@@ -0,0 +1,295 @@
1
+ /**
2
+ * Says which statement of a test is running while it has its browser do
3
+ * something, for the adapters of `@encore.dev/sdk/testing`.
4
+ *
5
+ * A test's browser is reached through Encore, which reads what the test's
6
+ * tool has it do — a click, a key, a navigation — off the protocol. That
7
+ * says what was done, not which line of the test did it. So each call the
8
+ * test makes on its tool's objects is reported as a **step**, with the call
9
+ * as written and where it is, on the connection the tool's own commands go
10
+ * over: what the browser is told between a step's beginning and its end is
11
+ * that statement's doing.
12
+ *
13
+ * The tool's objects are wrapped ({@link wrap}), not changed: a call on a
14
+ * wrapper reports the step and makes the call on the object itself.
15
+ *
16
+ * @internal
17
+ */
18
+ /** Reports steps over a connection. */
19
+ export class Steps {
20
+ send;
21
+ /** Set once the connection has failed: nothing more is reported. */
22
+ gone = false;
23
+ constructor(send) {
24
+ this.send = send;
25
+ }
26
+ /** Runs `fn` as the step `name`, made at `at`. */
27
+ async run(name, at, fn) {
28
+ const step = this.begin(name, at);
29
+ try {
30
+ const result = await fn();
31
+ await this.end(step);
32
+ return result;
33
+ }
34
+ catch (err) {
35
+ await this.end(step, said(err));
36
+ throw err;
37
+ }
38
+ }
39
+ /**
40
+ * Says the step `name` begins, now: the word is on its way before this
41
+ * returns, ahead of whatever the caller has the browser do next. Resolves
42
+ * to the step's id, or `null` where nothing took it.
43
+ */
44
+ begin(name, at) {
45
+ if (this.gone)
46
+ return Promise.resolve(null);
47
+ let sent;
48
+ try {
49
+ sent = this.send('Encore.stepBegin', { name, ...(at ?? {}) });
50
+ }
51
+ catch {
52
+ this.gone = true;
53
+ return Promise.resolve(null);
54
+ }
55
+ return sent.then(answer => {
56
+ const id = answer?.id;
57
+ return typeof id === 'string' ? id : null;
58
+ }, () => {
59
+ // Not Encore's browser, or it has closed: the test goes on as it is.
60
+ this.gone = true;
61
+ return null;
62
+ });
63
+ }
64
+ /** Says the step `step` ended, with `error` if it failed. */
65
+ async end(step, error) {
66
+ await this.finish(step, error === undefined ? {} : { error });
67
+ }
68
+ /** Takes back the step `step`: what began was no statement of its own. */
69
+ async discard(step) {
70
+ await this.finish(step, { discard: true });
71
+ }
72
+ async finish(step, params) {
73
+ const id = await step;
74
+ if (id === null || this.gone)
75
+ return;
76
+ try {
77
+ await this.send('Encore.stepEnd', { id, ...params });
78
+ }
79
+ catch {
80
+ this.gone = true;
81
+ }
82
+ }
83
+ }
84
+ /** What an error says. */
85
+ function said(err) {
86
+ return err instanceof Error ? err.message : String(err);
87
+ }
88
+ /** The frames that are not the test's: this SDK's, the tools', Node's. */
89
+ const NOT_THE_TEST = /[\\/]node_modules[\\/]|[\\/]internal[\\/]testing[\\/]steps\.[cm]?[jt]s|[\\/]testing[\\/](puppeteer|playwright|system)\.[cm]?[jt]s|^node:|\(node:/;
90
+ /** Where the test called from: the first frame of the stack that is its own. */
91
+ export function caller() {
92
+ const holder = {};
93
+ const limit = Error.stackTraceLimit;
94
+ Error.stackTraceLimit = 30;
95
+ Error.captureStackTrace(holder, caller);
96
+ Error.stackTraceLimit = limit;
97
+ for (const frame of (holder.stack ?? '').split('\n').slice(1)) {
98
+ if (NOT_THE_TEST.test(frame))
99
+ continue;
100
+ const found = /\(?((?:file:\/\/)?(?:[A-Za-z]:)?[^():]+):(\d+):\d+\)?\s*$/.exec(frame);
101
+ if (found === null)
102
+ continue;
103
+ let file = found[1].trim();
104
+ if (file.startsWith('file://')) {
105
+ try {
106
+ file = decodeURIComponent(new URL(file).pathname);
107
+ }
108
+ catch {
109
+ // As it is written.
110
+ }
111
+ }
112
+ return { file, line: Number(found[2]) };
113
+ }
114
+ return null;
115
+ }
116
+ /** An argument of a call, as it would be written, in short. */
117
+ function written(arg) {
118
+ switch (typeof arg) {
119
+ case 'string':
120
+ return JSON.stringify(arg.length > 60 ? arg.slice(0, 59) + '…' : arg);
121
+ case 'function':
122
+ return 'fn';
123
+ case 'undefined':
124
+ return 'undefined';
125
+ case 'object': {
126
+ if (arg === null)
127
+ return 'null';
128
+ if (arg instanceof RegExp)
129
+ return String(arg);
130
+ const proto = Object.getPrototypeOf(arg);
131
+ if (proto !== Object.prototype && proto !== null && !Array.isArray(arg)) {
132
+ return proto.constructor?.name ?? 'object';
133
+ }
134
+ try {
135
+ const json = JSON.stringify(arg, (_key, value) => value instanceof RegExp ? String(value) : value);
136
+ return json.length > 60 ? json.slice(0, 59) + '…' : json;
137
+ }
138
+ catch {
139
+ return Array.isArray(arg) ? '[…]' : '{…}';
140
+ }
141
+ }
142
+ default:
143
+ return String(arg);
144
+ }
145
+ }
146
+ /** What a tool's objects are called in a step's name, by their class. */
147
+ const NAMES = [
148
+ [/Page$/, 'page'],
149
+ [/Frame$/, 'frame'],
150
+ [/Keyboard$/, 'keyboard'],
151
+ [/Mouse$/, 'mouse'],
152
+ [/Touchscreen$/, 'touchscreen'],
153
+ [/Context$/, 'context'],
154
+ ];
155
+ /** The objects whose calls are steps, by their class: what a test acts on. */
156
+ const WRAPPED = /(Page|Frame|FrameLocator|Locator|ElementHandle|JSHandle|Keyboard|Mouse|Touchscreen|BrowserContext|Browser)$/;
157
+ /** The calls that are no statement of a test's about its pages. */
158
+ const NOT_STEPS = new Set([
159
+ 'on',
160
+ 'once',
161
+ 'off',
162
+ 'addListener',
163
+ 'removeListener',
164
+ 'removeAllListeners',
165
+ 'emit',
166
+ 'then',
167
+ 'catch',
168
+ 'finally',
169
+ 'close',
170
+ 'disconnect',
171
+ 'dispose',
172
+ 'newPage',
173
+ 'newContext',
174
+ 'createBrowserContext',
175
+ 'createCDPSession',
176
+ 'newCDPSession',
177
+ 'newBrowserCDPSession',
178
+ 'pages',
179
+ 'contexts',
180
+ 'browserContexts',
181
+ 'target',
182
+ 'targets',
183
+ 'version',
184
+ 'userAgent',
185
+ 'toString',
186
+ 'toJSON',
187
+ 'constructor',
188
+ ]);
189
+ function className(value) {
190
+ return (Object.getPrototypeOf(value)
191
+ ?.constructor?.name ?? '');
192
+ }
193
+ function wrappable(value) {
194
+ return (typeof value === 'object' &&
195
+ value !== null &&
196
+ WRAPPED.test(className(value)));
197
+ }
198
+ /** The wrappers made, by what each wraps, so that one object has one. */
199
+ const wrappers = new WeakMap();
200
+ /** What each wrapper wraps. */
201
+ const wrapped = new WeakMap();
202
+ /** The tool's own object for `value`, if `value` is a wrapper of one. */
203
+ export function unwrap(value) {
204
+ if (typeof value === 'object' && value !== null) {
205
+ return wrapped.get(value) ?? value;
206
+ }
207
+ return value;
208
+ }
209
+ /**
210
+ * Wraps `target`, an object of a test's tool, so that each call made on it
211
+ * is reported to `steps`: `label` is what it is called in a step's name
212
+ * (`page`, or the call that gave it, as `page.locator("#pay")`).
213
+ */
214
+ export function wrap(target, label, steps) {
215
+ const existing = wrappers.get(target);
216
+ if (existing !== undefined)
217
+ return existing;
218
+ const proxy = new Proxy(target, {
219
+ get(obj, prop) {
220
+ // Read as the object itself: its getters and private fields are its own.
221
+ const value = Reflect.get(obj, prop, obj);
222
+ if (typeof prop === 'symbol') {
223
+ return typeof value === 'function' ? value.bind(obj) : value;
224
+ }
225
+ if (typeof value !== 'function') {
226
+ // What hangs off it: `page.keyboard`, `page.mouse`.
227
+ return wrappable(value)
228
+ ? wrap(value, `${label}.${prop}`, steps)
229
+ : value;
230
+ }
231
+ if (prop.startsWith('_') || NOT_STEPS.has(prop)) {
232
+ return (...args) => below(value.apply(obj, args.map(unwrap)), steps);
233
+ }
234
+ return (...args) => {
235
+ const real = args.map(unwrap);
236
+ const name = `${label}.${prop}(${args.map(written).join(', ')})`;
237
+ // Said before the call is made: what the call has the browser do
238
+ // follows it on the connection, and is the step's.
239
+ const step = steps.begin(name, caller());
240
+ let result;
241
+ try {
242
+ result = value.apply(obj, real);
243
+ }
244
+ catch (err) {
245
+ void steps.end(step, said(err));
246
+ throw err;
247
+ }
248
+ if (isThenable(result)) {
249
+ return Promise.resolve(result).then(async (done) => {
250
+ await steps.end(step);
251
+ return below(done, steps, name);
252
+ }, async (err) => {
253
+ await steps.end(step, said(err));
254
+ throw err;
255
+ });
256
+ }
257
+ // What a call gives at once is what to act on next, not an action.
258
+ void steps.discard(step);
259
+ return wrappable(result) ? wrap(result, name, steps) : result;
260
+ };
261
+ },
262
+ });
263
+ wrappers.set(target, proxy);
264
+ wrapped.set(proxy, target);
265
+ return proxy;
266
+ }
267
+ function isThenable(value) {
268
+ return (typeof value === 'object' &&
269
+ value !== null &&
270
+ typeof value.then === 'function' &&
271
+ // A locator is no promise, though some can be awaited.
272
+ !wrappable(value));
273
+ }
274
+ /** What a call that is no step gave, wrapped where a test acts on it. */
275
+ function below(value, steps, label) {
276
+ if (isThenable(value)) {
277
+ return Promise.resolve(value).then(inner => below(inner, steps, label));
278
+ }
279
+ if (Array.isArray(value)) {
280
+ return value.map((item) => below(item, steps, label));
281
+ }
282
+ if (wrappable(value))
283
+ return wrap(value, label ?? named(value), steps);
284
+ return value;
285
+ }
286
+ /** What an object of a tool's is called when nothing says how it was got. */
287
+ function named(value) {
288
+ const name = className(value);
289
+ for (const [pattern, label] of NAMES) {
290
+ if (pattern.test(name))
291
+ return label;
292
+ }
293
+ return name.charAt(0).toLowerCase() + name.slice(1);
294
+ }
295
+ //# sourceMappingURL=steps.js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C;AAED,6EAA6E;AAC7E,SAAS,KAAK,CAAC,KAAa;IAC1B,MAAM,IAAI,GAAG,SAAS,CAAC,KAAK,CAAC,CAAC;IAC9B,KAAK,MAAM,CAAC,OAAO,EAAE,KAAK,CAAC,IAAI,KAAK,EAAE,CAAC;QACrC,IAAI,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC;YAAE,OAAO,KAAK,CAAC;IACvC,CAAC;IACD,OAAO,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,WAAW,EAAE,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;AACtD,CAAC"}
@@ -0,0 +1,305 @@
1
+ /**
2
+ * What a test session recorded for one system test, as the core read it
3
+ * (`encore_sdk_core::system_test::telemetry`): the spans and the lines logged
4
+ * in them, each span said to be what it is of. The core hands it over as
5
+ * JSON, with the tree and the errors worked out; this gives it types.
6
+ *
7
+ * @internal
8
+ */
9
+ /** A span's kind. */
10
+ export type SpanKind = 'internal' | 'server' | 'client' | 'producer' | 'consumer';
11
+ /** A span's status. */
12
+ export type SpanStatus = 'unset' | 'ok' | 'error';
13
+ /** The test itself: the root of its trace. */
14
+ export interface TestWhat {
15
+ type: 'test';
16
+ name: string;
17
+ }
18
+ /**
19
+ * A request Encore handed a service, or took at a gateway: recorded by
20
+ * Encore where it hands the request over, whether or not the service records
21
+ * a span of its own.
22
+ */
23
+ export interface RequestWhat {
24
+ type: 'request';
25
+ /** The service it was handed to, or the gateway that took it. */
26
+ service: string;
27
+ method: string;
28
+ path: string;
29
+ /** The route it matched, when the service's API spec says. */
30
+ route?: string;
31
+ /** The endpoint it matched, by name, when known. */
32
+ endpoint?: string;
33
+ /** The response's status; 0 when none was sent. */
34
+ status: number;
35
+ /** Who made it: the service whose span it is under, `test` for the test
36
+ * itself, none when its parent is not among the spans. */
37
+ caller?: string;
38
+ /** How long it was held for its service to start, if it was, in
39
+ * nanoseconds. */
40
+ coldStartNanos?: number;
41
+ /** Whether a call between services carried its request's context
42
+ * (`propagated`), as Encore judged it, when it did. */
43
+ propagation?: string;
44
+ }
45
+ /** A query a service, or the test, ran on a database. */
46
+ export interface QueryWhat {
47
+ type: 'query';
48
+ database: string;
49
+ /** What it does to what (`INSERT charges`). */
50
+ summary: string;
51
+ statement: string;
52
+ }
53
+ /** A message published to a topic. */
54
+ export interface PublishWhat {
55
+ type: 'publish';
56
+ topic: string;
57
+ messageId: string;
58
+ }
59
+ /** A message delivered to a subscription: one attempt. */
60
+ export interface DeliveryWhat {
61
+ type: 'delivery';
62
+ topic: string;
63
+ subscription: string;
64
+ messageId: string;
65
+ /** Which delivery of the message it is: 1 the first. */
66
+ attempt: number;
67
+ /** Whether the handler handled it. */
68
+ handled: boolean;
69
+ }
70
+ /** Encore's own doing on a request's way: sending it on, or holding it
71
+ * while its service starts. Part of the request. */
72
+ export interface HopWhat {
73
+ type: 'hop';
74
+ }
75
+ /** Anything else: a span of the app's own, a cache command, a connect. */
76
+ export interface OtherWhat {
77
+ type: 'other';
78
+ }
79
+ /** What a span is of, with what a test asks of one. */
80
+ export type What = TestWhat | RequestWhat | QueryWhat | PublishWhat | DeliveryWhat | HopWhat | OtherWhat;
81
+ /** An event of a span. */
82
+ export interface SpanEvent {
83
+ name: string;
84
+ timeUnixNanos: bigint;
85
+ attributes: Record<string, unknown>;
86
+ }
87
+ /** A link to another span. */
88
+ export interface SpanLink {
89
+ traceId: string;
90
+ spanId: string;
91
+ }
92
+ /** One span. */
93
+ export interface Span<W extends What = What> {
94
+ traceId: string;
95
+ spanId: string;
96
+ /** None for the root of a trace. */
97
+ parentSpanId?: string;
98
+ name: string;
99
+ kind: SpanKind;
100
+ /** The service that recorded it: the app's name for the test's own
101
+ * spans. */
102
+ service: string;
103
+ /** The instrumentation scope that recorded it. */
104
+ scope: string;
105
+ startUnixNanos: bigint;
106
+ endUnixNanos: bigint;
107
+ status: SpanStatus;
108
+ /** Empty unless the status says. */
109
+ statusMessage: string;
110
+ attributes: Record<string, unknown>;
111
+ events: SpanEvent[];
112
+ /** The spans it is linked to: a delivery's, to the publish of its
113
+ * message. */
114
+ links: SpanLink[];
115
+ /** What the span is of. */
116
+ what: W;
117
+ }
118
+ /** A line a service logged, or something Encore captured of a request. */
119
+ export interface Log {
120
+ timeUnixNanos: bigint;
121
+ /** `error`, `warn`, `info`, `debug` or `trace`; empty when unknown. */
122
+ level: string;
123
+ body: string;
124
+ service: string;
125
+ /** Empty for a line logged outside any span. */
126
+ traceId: string;
127
+ spanId: string;
128
+ /** The name of the event it is, for one that is no line; empty for a
129
+ * line. */
130
+ eventName: string;
131
+ attributes: Record<string, unknown>;
132
+ }
133
+ /**
134
+ * Which spans of a kind to list: those whose {@link Span.what} has each
135
+ * value given. `{service: "orders", status: 200}` matches the requests the
136
+ * `orders` service answered with a 200.
137
+ */
138
+ export type Filter<W extends What> = Partial<Omit<W, 'type'>>;
139
+ /** What a test session recorded for one test. */
140
+ export declare class Telemetry {
141
+ /** The test's id. */
142
+ readonly testId: string;
143
+ /** Every span of every trace the test caused, by start: the test's own
144
+ * trace, and that of each delivery of a message published for it. */
145
+ readonly spans: readonly Span[];
146
+ /** The lines the services logged in those traces, and what Encore
147
+ * captured of their requests, by time. */
148
+ readonly logs: readonly Log[];
149
+ private readonly rendered;
150
+ private readonly shaped;
151
+ private readonly wrong;
152
+ private readonly lost;
153
+ /** @internal */
154
+ constructor(wire: Wire);
155
+ /**
156
+ * Reads the core's JSON (`Telemetry::to_json`). The times in it are
157
+ * nanoseconds since the Unix epoch, past what a JavaScript number holds
158
+ * exactly, so they are read as bigints.
159
+ *
160
+ * @internal
161
+ */
162
+ static parse(json: string): Telemetry;
163
+ /** The requests services were handed, and gateways took, in order. */
164
+ requests(filter?: Filter<RequestWhat>): Span<RequestWhat>[];
165
+ /** The queries run on the app's databases, in order. */
166
+ queries(filter?: Filter<QueryWhat>): Span<QueryWhat>[];
167
+ /** The messages published, in order. */
168
+ publishes(filter?: Filter<PublishWhat>): Span<PublishWhat>[];
169
+ /** The deliveries of messages to subscriptions, an attempt each, in
170
+ * order. */
171
+ deliveries(filter?: Filter<DeliveryWhat>): Span<DeliveryWhat>[];
172
+ private of;
173
+ /**
174
+ * What went wrong in what the test caused, a line each: requests answered
175
+ * with a server error, spans that failed, deliveries the handler did not
176
+ * handle, calls between services that lost their request's context, and
177
+ * lines logged as errors.
178
+ */
179
+ errors(): string[];
180
+ /**
181
+ * The calls between services that lost their request's context, and with
182
+ * it the test: those a service made for the test, then those only known
183
+ * to have been made while it ran, each kind of call once. A test that
184
+ * finds its own data without what it expected finds why here. The tree
185
+ * (`toString`) lists them under it.
186
+ */
187
+ lostContext(): LostContext[];
188
+ /**
189
+ * The tree without what differs between runs — ids, times, how long
190
+ * anything took, cold starts — for a snapshot of which services a flow
191
+ * touches, and in what order. Spans beside each other that overlap in
192
+ * time are listed by name, so concurrent calls give one shape.
193
+ */
194
+ shape(): string;
195
+ /**
196
+ * What the test caused, as a tree: each request and what the service did
197
+ * for it, then each delivery, with statuses and how long each took. What
198
+ * a failed test prints.
199
+ */
200
+ toString(): string;
201
+ }
202
+ /**
203
+ * What a failed system test prints of what its session recorded for it: the
204
+ * tree of what it caused in the app, under a line saying so. Empty for a
205
+ * test that caused nothing there.
206
+ */
207
+ export declare function causedBy(recorded: Telemetry): string;
208
+ /** The core's JSON: its `Serialize` derives, with a nanosecond time quoted
209
+ * by {@link Telemetry.parse}. */
210
+ interface Wire {
211
+ test_id?: string;
212
+ spans?: WireSpan[];
213
+ logs?: WireLog[];
214
+ rendered?: string;
215
+ shape?: string;
216
+ errors?: string[];
217
+ lost_context?: {
218
+ caller?: string;
219
+ service: string;
220
+ method: string;
221
+ path: string;
222
+ verdict: string;
223
+ of_test: boolean;
224
+ }[];
225
+ }
226
+ /**
227
+ * A call between services that did not carry its request's context, and so
228
+ * not the test: what the service called did for it, it did on the data the
229
+ * services share, not on the test's.
230
+ */
231
+ export interface LostContext {
232
+ /** The service that made the call, when it is known. */
233
+ readonly caller?: string;
234
+ /** The service called. */
235
+ readonly service: string;
236
+ readonly method: string;
237
+ readonly path: string;
238
+ /** How it was lost: `context_dropped` for a call in its request's trace
239
+ * without its Request Context, `detached` for one in a trace of its own,
240
+ * `untraced` for one with no trace. */
241
+ readonly verdict: string;
242
+ /** Whether the call is known to be the test's: one in its trace. Not one
243
+ * only known to have been made while it ran, which may be another
244
+ * test's running beside it. */
245
+ readonly ofTest: boolean;
246
+ }
247
+ interface WireSpan {
248
+ trace_id: string;
249
+ span_id: string;
250
+ parent_span_id?: string;
251
+ name: string;
252
+ kind: SpanKind;
253
+ service: string;
254
+ scope: string;
255
+ start_unix_nanos: string | number;
256
+ end_unix_nanos: string | number;
257
+ status: SpanStatus;
258
+ status_message?: string;
259
+ attributes?: Record<string, unknown>;
260
+ events?: {
261
+ name: string;
262
+ time_unix_nanos: string | number;
263
+ attributes?: Record<string, unknown>;
264
+ }[];
265
+ links?: {
266
+ trace_id: string;
267
+ span_id: string;
268
+ }[];
269
+ what: WireWhat;
270
+ }
271
+ type WireWhat = TestWhat | {
272
+ type: 'request';
273
+ service: string;
274
+ method: string;
275
+ path: string;
276
+ route?: string;
277
+ endpoint?: string;
278
+ status: number;
279
+ caller?: string;
280
+ cold_start_nanos?: number;
281
+ propagation?: string;
282
+ } | QueryWhat | {
283
+ type: 'publish';
284
+ topic: string;
285
+ message_id: string;
286
+ } | {
287
+ type: 'delivery';
288
+ topic: string;
289
+ subscription: string;
290
+ message_id: string;
291
+ attempt: number;
292
+ handled: boolean;
293
+ } | HopWhat | OtherWhat;
294
+ interface WireLog {
295
+ time_unix_nanos: string | number;
296
+ level: string;
297
+ body: string;
298
+ service: string;
299
+ trace_id?: string;
300
+ span_id?: string;
301
+ event_name?: string;
302
+ attributes?: Record<string, unknown>;
303
+ }
304
+ export {};
305
+ //# sourceMappingURL=telemetry.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"telemetry.d.ts","sourceRoot":"","sources":["../../../internal/testing/telemetry.ts"],"names":[],"mappings":"AAAA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