@fluojs/runtime 2.0.1 → 3.0.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 (127) hide show
  1. package/README.ko.md +278 -20
  2. package/README.md +278 -20
  3. package/dist/adapters/internal-request-response-factory.d.ts +1 -1
  4. package/dist/adapters/internal-request-response-factory.d.ts.map +1 -1
  5. package/dist/adapters/internal-request-response-factory.js +1 -1
  6. package/dist/adapters/request-response-factory.d.ts +20 -1
  7. package/dist/adapters/request-response-factory.d.ts.map +1 -1
  8. package/dist/adapters/request-response-factory.js +75 -22
  9. package/dist/bootstrap.d.ts +3 -9
  10. package/dist/bootstrap.d.ts.map +1 -1
  11. package/dist/bootstrap.js +179 -75
  12. package/dist/devtools/contracts.d.ts +3 -135
  13. package/dist/devtools/contracts.d.ts.map +1 -1
  14. package/dist/devtools/index.d.ts +2 -3
  15. package/dist/devtools/index.d.ts.map +1 -1
  16. package/dist/devtools/index.js +1 -2
  17. package/dist/devtools/snapshot.d.ts +1 -1
  18. package/dist/devtools/snapshot.d.ts.map +1 -1
  19. package/dist/devtools/snapshot.js +18 -17
  20. package/dist/devtools/studio-request-observer.d.ts +14 -0
  21. package/dist/devtools/studio-request-observer.d.ts.map +1 -0
  22. package/dist/devtools/studio-request-observer.js +112 -0
  23. package/dist/devtools/studio-runtime-config.d.ts +25 -0
  24. package/dist/devtools/studio-runtime-config.d.ts.map +1 -0
  25. package/dist/devtools/studio-runtime-config.js +59 -0
  26. package/dist/devtools/studio-runtime.d.ts +12 -18
  27. package/dist/devtools/studio-runtime.d.ts.map +1 -1
  28. package/dist/devtools/studio-runtime.js +25 -169
  29. package/dist/errors.d.ts +26 -0
  30. package/dist/errors.d.ts.map +1 -1
  31. package/dist/errors.js +38 -0
  32. package/dist/health/health.d.ts +6 -2
  33. package/dist/health/health.d.ts.map +1 -1
  34. package/dist/health/health.js +3 -2
  35. package/dist/http-adapter-shared.d.ts +1 -1
  36. package/dist/http-adapter-shared.d.ts.map +1 -1
  37. package/dist/http-adapter-shared.js +1 -1
  38. package/dist/index.d.ts +6 -3
  39. package/dist/index.d.ts.map +1 -1
  40. package/dist/index.js +4 -1
  41. package/dist/internal/route-inspection-metadata.d.ts +30 -0
  42. package/dist/internal/route-inspection-metadata.d.ts.map +1 -0
  43. package/dist/internal/route-inspection-metadata.js +68 -0
  44. package/dist/internal.d.ts +6 -1
  45. package/dist/internal.d.ts.map +1 -1
  46. package/dist/internal.js +4 -1
  47. package/dist/module-definition.d.ts +10 -0
  48. package/dist/module-definition.d.ts.map +1 -0
  49. package/dist/module-definition.js +12 -0
  50. package/dist/module-graph.d.ts +41 -0
  51. package/dist/module-graph.d.ts.map +1 -1
  52. package/dist/module-graph.js +108 -13
  53. package/dist/multipart.d.ts +67 -3
  54. package/dist/multipart.d.ts.map +1 -1
  55. package/dist/multipart.js +665 -103
  56. package/dist/platform-component-registry.d.ts +9 -0
  57. package/dist/platform-component-registry.d.ts.map +1 -0
  58. package/dist/platform-component-registry.js +70 -0
  59. package/dist/platform-diagnostic-retention.d.ts +13 -0
  60. package/dist/platform-diagnostic-retention.d.ts.map +1 -0
  61. package/dist/platform-diagnostic-retention.js +43 -0
  62. package/dist/platform-shell-probe-reports.d.ts +8 -0
  63. package/dist/platform-shell-probe-reports.d.ts.map +1 -0
  64. package/dist/platform-shell-probe-reports.js +95 -0
  65. package/dist/platform-shell-probes.d.ts +16 -0
  66. package/dist/platform-shell-probes.d.ts.map +1 -0
  67. package/dist/platform-shell-probes.js +141 -0
  68. package/dist/platform-shell.d.ts +7 -13
  69. package/dist/platform-shell.d.ts.map +1 -1
  70. package/dist/platform-shell.js +58 -310
  71. package/dist/retryable-shutdown.d.ts +7 -0
  72. package/dist/retryable-shutdown.d.ts.map +1 -0
  73. package/dist/retryable-shutdown.js +20 -0
  74. package/dist/route-inspection.d.ts +56 -0
  75. package/dist/route-inspection.d.ts.map +1 -0
  76. package/dist/route-inspection.js +80 -0
  77. package/dist/tokens.d.ts +6 -4
  78. package/dist/tokens.d.ts.map +1 -1
  79. package/dist/tokens.js +5 -0
  80. package/dist/types.d.ts +53 -8
  81. package/dist/types.d.ts.map +1 -1
  82. package/dist/web.d.ts +22 -3
  83. package/dist/web.d.ts.map +1 -1
  84. package/dist/web.js +80 -34
  85. package/package.json +13 -26
  86. package/dist/internal-node.d.ts +0 -2
  87. package/dist/internal-node.d.ts.map +0 -1
  88. package/dist/internal-node.js +0 -1
  89. package/dist/logging/json-logger.d.ts +0 -8
  90. package/dist/logging/json-logger.d.ts.map +0 -1
  91. package/dist/logging/json-logger.js +0 -45
  92. package/dist/logging/logger.d.ts +0 -37
  93. package/dist/logging/logger.d.ts.map +0 -1
  94. package/dist/logging/logger.js +0 -103
  95. package/dist/node/internal-node-compression.d.ts +0 -22
  96. package/dist/node/internal-node-compression.d.ts.map +0 -1
  97. package/dist/node/internal-node-compression.js +0 -84
  98. package/dist/node/internal-node-request.d.ts +0 -162
  99. package/dist/node/internal-node-request.d.ts.map +0 -1
  100. package/dist/node/internal-node-request.js +0 -478
  101. package/dist/node/internal-node-response.d.ts +0 -28
  102. package/dist/node/internal-node-response.d.ts.map +0 -1
  103. package/dist/node/internal-node-response.js +0 -205
  104. package/dist/node/internal-node-shutdown.d.ts +0 -34
  105. package/dist/node/internal-node-shutdown.d.ts.map +0 -1
  106. package/dist/node/internal-node-shutdown.js +0 -83
  107. package/dist/node/internal-node.d.ts +0 -111
  108. package/dist/node/internal-node.d.ts.map +0 -1
  109. package/dist/node/internal-node.js +0 -283
  110. package/dist/node/node-compression.d.ts +0 -2
  111. package/dist/node/node-compression.d.ts.map +0 -1
  112. package/dist/node/node-compression.js +0 -1
  113. package/dist/node/node-request.d.ts +0 -2
  114. package/dist/node/node-request.d.ts.map +0 -1
  115. package/dist/node/node-request.js +0 -1
  116. package/dist/node/node-response.d.ts +0 -2
  117. package/dist/node/node-response.d.ts.map +0 -1
  118. package/dist/node/node-response.js +0 -1
  119. package/dist/node/node-shutdown.d.ts +0 -2
  120. package/dist/node/node-shutdown.d.ts.map +0 -1
  121. package/dist/node/node-shutdown.js +0 -1
  122. package/dist/node/node.d.ts +0 -2
  123. package/dist/node/node.d.ts.map +0 -1
  124. package/dist/node/node.js +0 -1
  125. package/dist/node.d.ts +0 -5
  126. package/dist/node.d.ts.map +0 -1
  127. package/dist/node.js +0 -3
@@ -1,478 +0,0 @@
1
- import { Readable } from 'node:stream';
2
- import { URL } from 'node:url';
3
- import { BadRequestException, PayloadTooLargeException } from '@fluojs/http';
4
- import { parseMultipart } from '../multipart.js';
5
-
6
- /**
7
- * Options for creating a deferred framework request shell from a Node-backed adapter.
8
- */
9
-
10
- /**
11
- * HTTP payload-size error that closes the underlying Node request stream after the response commits.
12
- */
13
- export class NodeRequestPayloadTooLargeException extends PayloadTooLargeException {
14
- constructor(request) {
15
- super('Request body exceeds the size limit.');
16
- this.request = request;
17
- }
18
- prepareResponse(response) {
19
- response.setHeader('Connection', 'close');
20
- const destroyRequest = () => {
21
- if (!this.request.destroyed) {
22
- this.request.destroy();
23
- }
24
- };
25
- response.once('finish', destroyRequest);
26
- response.once('close', destroyRequest);
27
- this.request.pause();
28
- }
29
- }
30
-
31
- /**
32
- * Creates a framework request from a raw Node incoming message.
33
- *
34
- * @param request - Raw Node request carrying headers, URL, and body stream.
35
- * @param signal - Abort signal tied to the response lifecycle.
36
- * @param multipartOptions - Multipart parser options applied to multipart requests.
37
- * @param maxBodySize - Maximum allowed non-multipart body size in bytes.
38
- * @param preserveRawBody - Whether to retain the raw request body bytes.
39
- * @returns The normalized framework request used by the dispatcher.
40
- */
41
- export async function createFrameworkRequest(request, signal, multipartOptions, maxBodySize = 1 * 1024 * 1024, preserveRawBody = false) {
42
- const frameworkRequest = createDeferredFrameworkRequest(request, signal, multipartOptions, maxBodySize, preserveRawBody);
43
- await materializeFrameworkRequestBody(frameworkRequest);
44
- return frameworkRequest;
45
- }
46
-
47
- /**
48
- * Creates the cheap Node framework request shell before consuming the body stream.
49
- *
50
- * @param request - Raw Node request carrying headers, URL, and body stream.
51
- * @param signal - Abort signal tied to the response lifecycle.
52
- * @param multipartOptions - Multipart parser options applied when materializing multipart requests.
53
- * @param maxBodySize - Maximum allowed non-multipart body size in bytes.
54
- * @param preserveRawBody - Whether materialization should retain raw request body bytes.
55
- * @returns The framework request shell with metadata snapshotted and body materialization deferred.
56
- */
57
- export function createDeferredFrameworkRequest(request, signal, multipartOptions, maxBodySize = 1 * 1024 * 1024, preserveRawBody = false) {
58
- const rawUrl = request.url ?? '/';
59
- const urlParts = splitRawRequestUrl(rawUrl);
60
- const headers = cloneRequestHeaders(request.headers);
61
- const contentType = normalizePrimaryContentType(headers['content-type']);
62
- const isMultipart = contentType === 'multipart/form-data';
63
- let frameworkRequest;
64
- const materializeBody = createMemoizedAsyncValue(async () => {
65
- if (isMultipart) {
66
- const result = await parseMultipart({
67
- body: Readable.toWeb(request),
68
- headers,
69
- method: request.method,
70
- url: resolveAbsoluteRequestUrl(rawUrl)
71
- }, {
72
- ...multipartOptions,
73
- maxTotalSize: multipartOptions?.maxTotalSize ?? maxBodySize
74
- });
75
- frameworkRequest.body = result.fields;
76
- frameworkRequest.files = result.files.map(file => ({
77
- ...file,
78
- buffer: Buffer.from(file.buffer)
79
- }));
80
- return;
81
- }
82
- if (!hasNodeRequestBody(request)) {
83
- frameworkRequest.body = undefined;
84
- return;
85
- }
86
- const bodyResult = await readRequestBody(request, headers['content-type'], maxBodySize, preserveRawBody);
87
- frameworkRequest.body = bodyResult.body;
88
- if (bodyResult.rawBody) {
89
- frameworkRequest.rawBody = bodyResult.rawBody;
90
- }
91
- });
92
- frameworkRequest = createDeferredFrameworkRequestShell({
93
- cookieHeader: cloneHeaderValue(headers.cookie),
94
- headers,
95
- materializeBody,
96
- method: request.method,
97
- path: urlParts.path,
98
- queryFactory: () => parseQueryParamsFromSearch(urlParts.search),
99
- raw: request,
100
- requestId: resolvePrimaryRequestIdFromHeaders(headers),
101
- signal,
102
- url: urlParts.path + urlParts.search
103
- });
104
- return frameworkRequest;
105
- }
106
-
107
- /**
108
- * Creates a framework request shell from already-snapshotted Node adapter metadata.
109
- *
110
- * @param options - Raw request, metadata factories, and deferred body materialization hooks.
111
- * @returns A framework request with lazy headers, cookies, query values, and optional body materialization.
112
- */
113
- export function createDeferredFrameworkRequestShell({
114
- cookieHeader,
115
- headers,
116
- headersFactory,
117
- materializeBody,
118
- method,
119
- path,
120
- query,
121
- queryFactory,
122
- raw,
123
- requestId,
124
- signal,
125
- url
126
- }) {
127
- const hasQuerySnapshot = query !== undefined;
128
- const hasLazySignal = typeof signal === 'function';
129
- const resolveHeaders = headersFactory ? createMemoizedValue(headersFactory) : () => headers ?? {};
130
- const resolveCookies = createMemoizedValue(() => parseCookieHeader(cookieHeader ?? resolveHeaders().cookie));
131
- const resolveQuery = hasQuerySnapshot ? undefined : createMemoizedValue(() => queryFactory?.() ?? {});
132
- const frameworkRequest = {
133
- get cookies() {
134
- return resolveCookies();
135
- },
136
- get headers() {
137
- return resolveHeaders();
138
- },
139
- method: method ?? 'GET',
140
- params: {},
141
- path,
142
- requestId,
143
- raw,
144
- url
145
- };
146
- if (hasLazySignal) {
147
- Object.defineProperty(frameworkRequest, 'signal', {
148
- configurable: true,
149
- enumerable: true,
150
- get() {
151
- return signal();
152
- }
153
- });
154
- } else {
155
- frameworkRequest.signal = signal;
156
- }
157
- if (hasQuerySnapshot) {
158
- frameworkRequest.query = query;
159
- } else {
160
- Object.defineProperty(frameworkRequest, 'query', {
161
- configurable: true,
162
- enumerable: true,
163
- get() {
164
- return resolveQuery();
165
- }
166
- });
167
- }
168
- if (materializeBody) {
169
- frameworkRequest.materializeBody = materializeBody;
170
- }
171
- return frameworkRequest;
172
- }
173
- function hasNodeRequestBody(request) {
174
- const contentLength = request.headers['content-length'];
175
- const transferEncoding = request.headers['transfer-encoding'];
176
- const primaryContentLength = Array.isArray(contentLength) ? contentLength[0] : contentLength;
177
- if (transferEncoding !== undefined) {
178
- return true;
179
- }
180
- if (primaryContentLength === undefined) {
181
- return true;
182
- }
183
- const parsedContentLength = Number(primaryContentLength);
184
- return !Number.isFinite(parsedContentLength) || parsedContentLength !== 0;
185
- }
186
-
187
- /**
188
- * Materializes a deferred Node framework request body exactly once.
189
- *
190
- * @param request - Framework request returned by {@link createDeferredFrameworkRequest}.
191
- * @returns A promise that settles after body, rawBody, and files fields are populated when applicable.
192
- */
193
- export async function materializeFrameworkRequestBody(request) {
194
- await request.materializeBody?.();
195
- delete request.materializeBody;
196
- }
197
-
198
- /**
199
- * Creates a synchronous memoized value resolver.
200
- *
201
- * @param factory - Function that computes the value on first access.
202
- * @returns A stable resolver that returns the cached value after the first call.
203
- */
204
- export function createMemoizedValue(factory) {
205
- let initialized = false;
206
- let value;
207
- return () => {
208
- if (!initialized) {
209
- value = factory();
210
- initialized = true;
211
- }
212
- return value;
213
- };
214
- }
215
-
216
- /**
217
- * Creates an async memoized side-effect resolver.
218
- *
219
- * @param factory - Async function to run at most once.
220
- * @returns A resolver that returns the same in-flight or completed promise for every call.
221
- */
222
- export function createMemoizedAsyncValue(factory) {
223
- let promise;
224
- return () => {
225
- promise ??= factory();
226
- return promise;
227
- };
228
- }
229
-
230
- /**
231
- * Creates an abort signal that fires when the Node response closes unexpectedly.
232
- *
233
- * @param response - Raw Node server response associated with the request.
234
- * @returns An abort signal for downstream request cancellation handling.
235
- */
236
- export function createRequestSignal(response) {
237
- const controller = new AbortController();
238
- const abort = reason => {
239
- if (!controller.signal.aborted) {
240
- controller.abort(new Error(reason));
241
- }
242
- };
243
- response.once('close', () => {
244
- if (!response.writableEnded) {
245
- abort('Response closed before response commit.');
246
- }
247
- });
248
- return controller.signal;
249
- }
250
-
251
- /**
252
- * Resolves the request identifier from the preferred inbound headers.
253
- *
254
- * @param headers - Raw Node request headers.
255
- * @returns The request identifier when present.
256
- */
257
- export function resolveRequestIdFromHeaders(headers) {
258
- const requestId = headers['x-request-id'] ?? headers['x-correlation-id'];
259
- return Array.isArray(requestId) ? requestId[0] : requestId;
260
- }
261
- function resolvePrimaryRequestIdFromHeaders(headers) {
262
- return resolveRequestIdFromHeaders(headers);
263
- }
264
-
265
- /**
266
- * Parses a raw URL search string into the framework query shape.
267
- *
268
- * @param search - Raw search string, with or without a leading question mark.
269
- * @returns Query values where repeated keys become string arrays.
270
- */
271
- export function parseQueryParamsFromSearch(search) {
272
- return parseQueryParams(new URLSearchParams(search));
273
- }
274
- function parseQueryParams(searchParams) {
275
- const query = {};
276
- for (const [key, value] of searchParams.entries()) {
277
- const current = query[key];
278
- if (current === undefined) {
279
- query[key] = value;
280
- continue;
281
- }
282
- if (Array.isArray(current)) {
283
- current.push(value);
284
- continue;
285
- }
286
- query[key] = [current, value];
287
- }
288
- return query;
289
- }
290
-
291
- /**
292
- * Snapshots host-parsed query values when they already match framework semantics.
293
- *
294
- * @param query - Host query object exposed by a Node-backed adapter.
295
- * @returns A cloned query record when all values are strings or string arrays; otherwise `undefined` for raw URL fallback.
296
- */
297
- export function snapshotSimpleQueryRecord(query) {
298
- if (typeof query !== 'object' || query === null) {
299
- return undefined;
300
- }
301
- const snapshot = {};
302
- for (const [key, value] of Object.entries(query)) {
303
- if (typeof value === 'string') {
304
- snapshot[key] = value;
305
- continue;
306
- }
307
- if (Array.isArray(value) && value.every(item => typeof item === 'string')) {
308
- snapshot[key] = [...value];
309
- continue;
310
- }
311
- return undefined;
312
- }
313
- return snapshot;
314
- }
315
-
316
- /**
317
- * Clones Node request headers into the framework header record shape.
318
- *
319
- * @param headers - Raw Node incoming headers.
320
- * @returns A shallow header snapshot with array values cloned.
321
- */
322
- export function cloneRequestHeaders(headers) {
323
- const clonedEntries = Object.entries(headers).map(([name, value]) => [name, cloneHeaderValue(value)]);
324
- return Object.fromEntries(clonedEntries);
325
- }
326
-
327
- /**
328
- * Clones a single Node header value when it is array-backed.
329
- *
330
- * @param value - Header value to snapshot.
331
- * @returns The original scalar value or a cloned array value.
332
- */
333
- export function cloneHeaderValue(value) {
334
- return Array.isArray(value) ? [...value] : value;
335
- }
336
-
337
- /**
338
- * Reads the primary value from a Node header value.
339
- *
340
- * @param headerValue - Header value that may contain multiple entries.
341
- * @returns The first header value when present.
342
- */
343
- export function readPrimaryHeaderValue(headerValue) {
344
- if (Array.isArray(headerValue)) {
345
- return headerValue[0];
346
- }
347
- return headerValue;
348
- }
349
-
350
- /**
351
- * Normalizes a Node content-type header to its primary media type.
352
- *
353
- * @param headerValue - Raw content-type header value.
354
- * @returns Lowercase primary media type without parameters, or `undefined` when absent.
355
- */
356
- export function normalizePrimaryContentType(headerValue) {
357
- const primaryHeaderValue = readPrimaryHeaderValue(headerValue);
358
- if (typeof primaryHeaderValue !== 'string') {
359
- return undefined;
360
- }
361
- const [mediaType] = primaryHeaderValue.split(';', 1);
362
- const normalizedMediaType = mediaType?.trim().toLowerCase();
363
- return normalizedMediaType && normalizedMediaType.length > 0 ? normalizedMediaType : undefined;
364
- }
365
- function decodeCookieValue(raw) {
366
- try {
367
- return decodeURIComponent(raw);
368
- } catch {
369
- return raw;
370
- }
371
- }
372
-
373
- /**
374
- * Parses a Node cookie header into framework cookie values.
375
- *
376
- * @param cookieHeader - Raw cookie header value or values.
377
- * @returns Cookie name/value pairs with percent-decoded values when possible.
378
- */
379
- export function parseCookieHeader(cookieHeader) {
380
- const normalizedCookieHeader = Array.isArray(cookieHeader) ? cookieHeader.join('; ') : cookieHeader;
381
- if (!normalizedCookieHeader) {
382
- return {};
383
- }
384
- return Object.fromEntries(normalizedCookieHeader.split(';').map(pair => pair.trim()).filter(Boolean).map(pair => {
385
- const index = pair.indexOf('=');
386
- if (index === -1) {
387
- return [pair.trim(), ''];
388
- }
389
- return [pair.slice(0, index).trim(), decodeCookieValue(pair.slice(index + 1).trim())];
390
- }));
391
- }
392
- async function readRequestBody(request, contentType, maxBodySize = 1 * 1024 * 1024, preserveRawBody = false) {
393
- const chunks = [];
394
- let totalSize = 0;
395
- for await (const chunk of request) {
396
- const buf = typeof chunk === 'string' ? Buffer.from(chunk) : chunk;
397
- totalSize += buf.byteLength;
398
- if (totalSize > maxBodySize) {
399
- throw new NodeRequestPayloadTooLargeException(request);
400
- }
401
- chunks.push(buf);
402
- }
403
- if (chunks.length === 0) {
404
- return {
405
- body: undefined
406
- };
407
- }
408
- const rawBody = Buffer.concat(chunks);
409
- const bodyText = rawBody.toString('utf8');
410
- if (bodyText.length === 0) {
411
- return {
412
- body: undefined,
413
- rawBody: preserveRawBody ? rawBody : undefined
414
- };
415
- }
416
- const primaryContentType = normalizePrimaryContentType(contentType);
417
- if (primaryContentType === 'application/json') {
418
- try {
419
- return {
420
- body: JSON.parse(bodyText),
421
- rawBody: preserveRawBody ? rawBody : undefined
422
- };
423
- } catch {
424
- throw new BadRequestException('Request body contains invalid JSON.');
425
- }
426
- }
427
- return {
428
- body: bodyText,
429
- rawBody: preserveRawBody ? rawBody : undefined
430
- };
431
- }
432
-
433
- /**
434
- * Splits a raw Node request URL into path and search components.
435
- *
436
- * @param rawUrl - Raw request URL, absolute URL, or undefined value from Node.
437
- * @returns The pathname and search string used by framework request matching and query parsing.
438
- */
439
- export function splitRawRequestUrl(rawUrl) {
440
- const resolvedRawUrl = rawUrl ?? '/';
441
- if (resolvedRawUrl.startsWith('http://') || resolvedRawUrl.startsWith('https://')) {
442
- const url = new URL(resolvedRawUrl);
443
- return {
444
- path: url.pathname,
445
- search: url.search
446
- };
447
- }
448
- const queryStart = resolvedRawUrl.indexOf('?');
449
- const hashStart = resolvedRawUrl.indexOf('#');
450
- const pathEndCandidates = [queryStart, hashStart].filter(index => index >= 0);
451
- const pathEnd = pathEndCandidates.length > 0 ? Math.min(...pathEndCandidates) : resolvedRawUrl.length;
452
- const path = resolvedRawUrl.slice(0, pathEnd) || '/';
453
- if (queryStart === -1) {
454
- return {
455
- path,
456
- search: ''
457
- };
458
- }
459
- const searchEnd = hashStart >= 0 && hashStart > queryStart ? hashStart : resolvedRawUrl.length;
460
- return {
461
- path,
462
- search: resolvedRawUrl.slice(queryStart, searchEnd)
463
- };
464
- }
465
-
466
- /**
467
- * Resolves a raw Node request URL into an absolute URL string.
468
- *
469
- * @param rawUrl - Raw request URL, absolute URL, or undefined value from Node.
470
- * @returns An absolute URL suitable for Web-standard parsers.
471
- */
472
- export function resolveAbsoluteRequestUrl(rawUrl) {
473
- const resolvedRawUrl = rawUrl ?? '/';
474
- if (resolvedRawUrl.startsWith('http://') || resolvedRawUrl.startsWith('https://')) {
475
- return resolvedRawUrl;
476
- }
477
- return new URL(resolvedRawUrl, 'http://localhost').toString();
478
- }
@@ -1,28 +0,0 @@
1
- import type { ServerResponse } from 'node:http';
2
- import { type FrameworkResponseCompression, type FrameworkResponse } from '@fluojs/http';
3
- /**
4
- * Defines the mutable framework response type.
5
- */
6
- export type MutableFrameworkResponse = FrameworkResponse & {
7
- statusSet?: boolean;
8
- };
9
- type FrameworkResponseCompressionFactory = () => FrameworkResponseCompression | undefined;
10
- /**
11
- * Create framework response.
12
- *
13
- * @param response The response.
14
- * @param compression The compression.
15
- * @returns The create framework response result.
16
- */
17
- export declare function createFrameworkResponse(response: ServerResponse, compression?: FrameworkResponseCompression | FrameworkResponseCompressionFactory): MutableFrameworkResponse;
18
- /**
19
- * Write node adapter error response.
20
- *
21
- * @param error The error.
22
- * @param response The response.
23
- * @param requestId The request id.
24
- * @returns The write node adapter error response result.
25
- */
26
- export declare function writeNodeAdapterErrorResponse(error: unknown, response: FrameworkResponse, requestId?: string): Promise<void>;
27
- export {};
28
- //# sourceMappingURL=internal-node-response.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"internal-node-response.d.ts","sourceRoot":"","sources":["../../src/node/internal-node-response.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;AAEhD,OAAO,EAIL,KAAK,4BAA4B,EACjC,KAAK,iBAAiB,EAEvB,MAAM,cAAc,CAAC;AAEtB;;GAEG;AACH,MAAM,MAAM,wBAAwB,GAAG,iBAAiB,GAAG;IAAE,SAAS,CAAC,EAAE,OAAO,CAAA;CAAE,CAAC;AAEnF,KAAK,mCAAmC,GAAG,MAAM,4BAA4B,GAAG,SAAS,CAAC;AA6C1F;;;;;;GAMG;AACH,wBAAgB,uBAAuB,CACrC,QAAQ,EAAE,cAAc,EACxB,WAAW,CAAC,EAAE,4BAA4B,GAAG,mCAAmC,GAC/E,wBAAwB,CAqH1B;AAED;;;;;;;GAOG;AACH,wBAAsB,6BAA6B,CACjD,KAAK,EAAE,OAAO,EACd,QAAQ,EAAE,iBAAiB,EAC3B,SAAS,CAAC,EAAE,MAAM,GACjB,OAAO,CAAC,IAAI,CAAC,CAIf"}