@bleedingdev/modern-js-bff-effect 3.9.0-ultramodern.9 → 3.9.3-ultramodern.2
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/cjs/assembly.js +2 -2
- package/dist/cjs/data-platform/batch/options.js +48 -0
- package/dist/cjs/data-platform/batch/queue.js +48 -83
- package/dist/cjs/effect/context.js +28 -4
- package/dist/cjs/effect/edge-dispatcher.js +19 -19
- package/dist/cjs/effect/edge.js +26 -6
- package/dist/cjs/effect/entry-shape.js +38 -10
- package/dist/cjs/effect/handler/batch-handler.js +2 -3
- package/dist/cjs/effect/handler/batch.js +0 -9
- package/dist/cjs/effect/handler/http.js +1 -1
- package/dist/cjs/effect/handler/openapi.js +3 -3
- package/dist/cjs/effect/handler/rpc.js +2 -2
- package/dist/cjs/effect/handler.js +26 -26
- package/dist/cjs/effect/index.js +8 -8
- package/dist/cjs/effect/module.js +6 -2
- package/dist/cjs/effect/operation-context.js +3 -7
- package/dist/cjs/effect/rpcSerialization.js +1 -3
- package/dist/cjs/effect-client/cross-project.js +8 -11
- package/dist/cjs/effect-client/index.js +10 -10
- package/dist/cjs/microvertical-api.js +1 -1
- package/dist/esm/assembly.mjs +1 -1
- package/dist/esm/data-platform/batch/options.mjs +10 -0
- package/dist/esm/data-platform/batch/queue.mjs +48 -83
- package/dist/esm/effect/context.mjs +21 -6
- package/dist/esm/effect/edge-dispatcher.mjs +5 -5
- package/dist/esm/effect/edge.mjs +2 -0
- package/dist/esm/effect/entry-shape-registry.mjs +2 -2
- package/dist/esm/effect/entry-shape.mjs +27 -4
- package/dist/esm/effect/handler/batch-handler.mjs +3 -4
- package/dist/esm/effect/handler/batch.mjs +1 -7
- package/dist/esm/effect/handler/http.mjs +1 -1
- package/dist/esm/effect/handler/openapi.mjs +2 -2
- package/dist/esm/effect/handler/rpc.mjs +2 -2
- package/dist/esm/effect/handler.mjs +6 -6
- package/dist/esm/effect/index.mjs +1 -1
- package/dist/esm/effect/module.mjs +5 -1
- package/dist/esm/effect/operation-context.mjs +2 -3
- package/dist/esm/effect/rpcSerialization.mjs +1 -3
- package/dist/esm/effect-client/cross-project.mjs +8 -11
- package/dist/esm/effect-client/index.mjs +5 -5
- package/dist/esm/microvertical-api.mjs +1 -1
- package/dist/esm-node/assembly.mjs +1 -1
- package/dist/esm-node/data-platform/batch/options.mjs +11 -0
- package/dist/esm-node/data-platform/batch/queue.mjs +48 -83
- package/dist/esm-node/effect/context.mjs +21 -6
- package/dist/esm-node/effect/edge-dispatcher.mjs +5 -5
- package/dist/esm-node/effect/edge.mjs +2 -0
- package/dist/esm-node/effect/entry-shape.mjs +27 -4
- package/dist/esm-node/effect/handler/batch-handler.mjs +3 -4
- package/dist/esm-node/effect/handler/batch.mjs +1 -7
- package/dist/esm-node/effect/handler/http.mjs +1 -1
- package/dist/esm-node/effect/handler/openapi.mjs +2 -2
- package/dist/esm-node/effect/handler/rpc.mjs +2 -2
- package/dist/esm-node/effect/handler.mjs +6 -6
- package/dist/esm-node/effect/index.mjs +1 -1
- package/dist/esm-node/effect/module.mjs +5 -1
- package/dist/esm-node/effect/operation-context.mjs +2 -3
- package/dist/esm-node/effect/rpcSerialization.mjs +1 -3
- package/dist/esm-node/effect-client/cross-project.mjs +8 -11
- package/dist/esm-node/effect-client/index.mjs +5 -5
- package/dist/esm-node/microvertical-api.mjs +1 -1
- package/dist/types/assembly.d.ts +2 -2
- package/dist/types/data-platform/batch/options.d.ts +7 -0
- package/dist/types/data-platform/batch/queue.d.ts +0 -1
- package/dist/types/effect/context.d.ts +14 -1
- package/dist/types/effect/edge-dispatcher.d.ts +4 -4
- package/dist/types/effect/edge.d.ts +2 -0
- package/dist/types/effect/entry-shape.d.ts +14 -0
- package/dist/types/effect/handler/batch.d.ts +0 -1
- package/dist/types/effect/handler/definition.d.ts +2 -2
- package/dist/types/effect/handler/http.d.ts +2 -2
- package/dist/types/effect/handler/openapi.d.ts +2 -2
- package/dist/types/effect/handler/rpc.d.ts +1 -1
- package/dist/types/effect/handler/types.d.ts +5 -5
- package/dist/types/effect/handler.d.ts +5 -5
- package/dist/types/effect/module.d.ts +2 -1
- package/dist/types/effect/operation-context.d.ts +0 -1
- package/dist/types/effect/rpcSerialization.d.ts +1 -1
- package/dist/types/effect-client/cross-project.d.ts +2 -2
- package/dist/types/effect-client/index.d.ts +6 -6
- package/dist/types/microvertical-api.d.ts +4 -4
- package/package.json +39 -45
- package/src/assembly.ts +3 -2
- package/src/data-platform/batch/options.ts +20 -0
- package/src/data-platform/batch/queue.ts +61 -89
- package/src/effect/context.ts +64 -12
- package/src/effect/edge-dispatcher.ts +13 -12
- package/src/effect/edge.ts +5 -0
- package/src/effect/entry-shape.ts +97 -7
- package/src/effect/handler/batch-handler.ts +6 -12
- package/src/effect/handler/batch.ts +0 -12
- package/src/effect/handler/definition.ts +2 -3
- package/src/effect/handler/http.ts +4 -3
- package/src/effect/handler/openapi.ts +2 -2
- package/src/effect/handler/rpc.ts +3 -2
- package/src/effect/handler/types.ts +6 -12
- package/src/effect/handler.ts +5 -5
- package/src/effect/index.ts +1 -1
- package/src/effect/module.ts +8 -1
- package/src/effect/operation-context.ts +1 -5
- package/src/effect/rpcSerialization.ts +1 -3
- package/src/effect-client/cross-project.ts +11 -16
- package/src/effect-client/index.ts +11 -15
- package/src/microvertical-api.ts +1 -1
- package/dist/cjs/effect/edge-context.js +0 -61
- package/dist/esm/effect/edge-context.mjs +0 -14
- package/dist/esm-node/effect/edge-context.mjs +0 -15
- package/dist/types/effect/edge-context.d.ts +0 -5
- package/src/effect/edge-context.ts +0 -51
package/dist/cjs/assembly.js
CHANGED
|
@@ -30,11 +30,11 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
30
30
|
__webpack_require__.d(__webpack_exports__, {
|
|
31
31
|
assembleEffectBffRuntime: ()=>assembleEffectBffRuntime
|
|
32
32
|
});
|
|
33
|
+
const http_api_namespaceObject = require("effect/http-api");
|
|
33
34
|
const Layer_namespaceObject = require("effect/Layer");
|
|
34
|
-
const httpapi_namespaceObject = require("effect/unstable/httpapi");
|
|
35
35
|
const definition_js_namespaceObject = require("./effect/handler/definition.js");
|
|
36
36
|
const assembleEffectBffRuntime = ({ api, handlers, transport })=>{
|
|
37
|
-
const apiLayer =
|
|
37
|
+
const apiLayer = http_api_namespaceObject.HttpApiBuilder.layer(api).pipe(Layer_namespaceObject.provide(handlers));
|
|
38
38
|
const layer = void 0 === transport ? apiLayer : apiLayer.pipe(Layer_namespaceObject.merge(transport));
|
|
39
39
|
return (0, definition_js_namespaceObject.defineEffectBff)({
|
|
40
40
|
api,
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __webpack_require__ = {};
|
|
3
|
+
(()=>{
|
|
4
|
+
__webpack_require__.d = (exports1, getters, values)=>{
|
|
5
|
+
var define = (defs, kind)=>{
|
|
6
|
+
for(var key in defs)if (__webpack_require__.o(defs, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
[kind]: defs[key]
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
define(getters, "get");
|
|
12
|
+
define(values, "value");
|
|
13
|
+
};
|
|
14
|
+
})();
|
|
15
|
+
(()=>{
|
|
16
|
+
__webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
|
|
17
|
+
})();
|
|
18
|
+
(()=>{
|
|
19
|
+
__webpack_require__.r = (exports1)=>{
|
|
20
|
+
if ("u" > typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
|
|
21
|
+
value: 'Module'
|
|
22
|
+
});
|
|
23
|
+
Object.defineProperty(exports1, '__esModule', {
|
|
24
|
+
value: true
|
|
25
|
+
});
|
|
26
|
+
};
|
|
27
|
+
})();
|
|
28
|
+
var __webpack_exports__ = {};
|
|
29
|
+
__webpack_require__.r(__webpack_exports__);
|
|
30
|
+
function normalizeBatchLimits(options = {}) {
|
|
31
|
+
return {
|
|
32
|
+
maxBatchSize: Math.max(1, options.maxBatchSize ?? 16),
|
|
33
|
+
maxBatchBytes: Math.max(1024, options.maxBatchBytes ?? 65536),
|
|
34
|
+
allowedMethods: new Set((void 0 !== options.allowedMethods && options.allowedMethods.length > 0 ? options.allowedMethods : [
|
|
35
|
+
'GET'
|
|
36
|
+
]).map((method)=>method.toUpperCase()))
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
__webpack_require__.d(__webpack_exports__, {
|
|
40
|
+
normalizeBatchLimits: ()=>normalizeBatchLimits
|
|
41
|
+
});
|
|
42
|
+
exports.normalizeBatchLimits = __webpack_exports__.normalizeBatchLimits;
|
|
43
|
+
for(var __rspack_i in __webpack_exports__)if (-1 === [
|
|
44
|
+
"normalizeBatchLimits"
|
|
45
|
+
].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
|
|
46
|
+
Object.defineProperty(exports, '__esModule', {
|
|
47
|
+
value: true
|
|
48
|
+
});
|
|
@@ -33,6 +33,7 @@ __webpack_require__.d(__webpack_exports__, {
|
|
|
33
33
|
});
|
|
34
34
|
const external_codec_js_namespaceObject = require("../codec.js");
|
|
35
35
|
const external_types_js_namespaceObject = require("../types.js");
|
|
36
|
+
const external_options_js_namespaceObject = require("./options.js");
|
|
36
37
|
const external_protocol_js_namespaceObject = require("./protocol.js");
|
|
37
38
|
const external_request_js_namespaceObject = require("./request.js");
|
|
38
39
|
const external_response_js_namespaceObject = require("./response.js");
|
|
@@ -111,7 +112,6 @@ class BatchBucketRegistry {
|
|
|
111
112
|
if (existing) return existing;
|
|
112
113
|
const next = {
|
|
113
114
|
items: [],
|
|
114
|
-
bytes: 0,
|
|
115
115
|
batchId: (0, external_request_js_namespaceObject.createBatchId)(),
|
|
116
116
|
sentAt: Date.now(),
|
|
117
117
|
timer: null,
|
|
@@ -130,12 +130,8 @@ class BatchBucketRegistry {
|
|
|
130
130
|
}
|
|
131
131
|
function createBatchTransportQueue({ options, baseFetch, bucketRegistry }) {
|
|
132
132
|
const flushIntervalMs = Math.max(0, options.flushIntervalMs ?? 8);
|
|
133
|
-
const maxBatchSize =
|
|
134
|
-
const maxBatchBytes = Math.max(1024, options.maxBatchBytes ?? 65536);
|
|
133
|
+
const { maxBatchSize, maxBatchBytes, allowedMethods } = (0, external_options_js_namespaceObject.normalizeBatchLimits)(options);
|
|
135
134
|
const requestTimeoutMs = options.requestTimeoutMs;
|
|
136
|
-
const allowedMethods = new Set((options.allowedMethods && options.allowedMethods.length > 0 ? options.allowedMethods : [
|
|
137
|
-
'GET'
|
|
138
|
-
]).map((method)=>method.toUpperCase()));
|
|
139
135
|
const onEvent = options.onEvent;
|
|
140
136
|
const buckets = bucketRegistry ?? new BatchBucketRegistry();
|
|
141
137
|
const pendingByKey = new Map();
|
|
@@ -168,7 +164,6 @@ function createBatchTransportQueue({ options, baseFetch, bucketRegistry }) {
|
|
|
168
164
|
const index = bucket.items.indexOf(request);
|
|
169
165
|
if (-1 === index) return;
|
|
170
166
|
bucket.items.splice(index, 1);
|
|
171
|
-
bucket.bytes = measurePayload(bucket, bucket.items);
|
|
172
167
|
if (0 === bucket.items.length && bucket.timer) {
|
|
173
168
|
clearTimeout(bucket.timer);
|
|
174
169
|
bucket.timer = null;
|
|
@@ -210,7 +205,11 @@ function createBatchTransportQueue({ options, baseFetch, bucketRegistry }) {
|
|
|
210
205
|
if (!SAFE_REPLAY_METHODS.has(request.item.method)) throw new Error(`Batch result is unknown for ${request.item.method}; automatic replay is disabled (${reason}).`);
|
|
211
206
|
return runSingle(request);
|
|
212
207
|
};
|
|
213
|
-
const
|
|
208
|
+
const finishFlush = (bucketKey, bucket)=>{
|
|
209
|
+
bucket.flushing = false;
|
|
210
|
+
if (bucket.items.length > 0 && !bucket.timer) flushBucket(bucketKey);
|
|
211
|
+
buckets.releaseIfIdle(bucketKey, bucket);
|
|
212
|
+
};
|
|
214
213
|
const flushBucket = async (bucketKey)=>{
|
|
215
214
|
const bucket = buckets.get(bucketKey);
|
|
216
215
|
if (!bucket || bucket.flushing) return;
|
|
@@ -227,7 +226,6 @@ function createBatchTransportQueue({ options, baseFetch, bucketRegistry }) {
|
|
|
227
226
|
sentAt: bucket.sentAt
|
|
228
227
|
};
|
|
229
228
|
bucket.items = [];
|
|
230
|
-
bucket.bytes = 0;
|
|
231
229
|
rotatePayloadIdentity(bucket);
|
|
232
230
|
const firstItem = items[0];
|
|
233
231
|
if (!firstItem) {
|
|
@@ -243,14 +241,25 @@ function createBatchTransportQueue({ options, baseFetch, bucketRegistry }) {
|
|
|
243
241
|
size: items.length,
|
|
244
242
|
reason: disabledEndpoints.has(endpoint) ? 'batch-disabled' : void 0
|
|
245
243
|
});
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
244
|
+
try {
|
|
245
|
+
await settleRequests(items, runSingle);
|
|
246
|
+
} finally{
|
|
247
|
+
finishFlush(bucketKey, bucket);
|
|
248
|
+
}
|
|
250
249
|
return;
|
|
251
250
|
}
|
|
252
251
|
const payload = createPayload(payloadIdentity, items);
|
|
253
252
|
const batchId = payload.batchId;
|
|
253
|
+
const settleAmbiguousBatchRequests = (reason)=>{
|
|
254
|
+
(0, external_telemetry_js_namespaceObject.emitDataBatchTransportEvent)(onEvent, {
|
|
255
|
+
type: 'fallback',
|
|
256
|
+
endpoint,
|
|
257
|
+
batchId,
|
|
258
|
+
size: items.length,
|
|
259
|
+
reason
|
|
260
|
+
});
|
|
261
|
+
return settleRequests(items, (request)=>runAfterAmbiguousBatch(request, reason));
|
|
262
|
+
};
|
|
254
263
|
(0, external_telemetry_js_namespaceObject.emitDataBatchTransportEvent)(onEvent, {
|
|
255
264
|
type: 'flush',
|
|
256
265
|
endpoint,
|
|
@@ -301,42 +310,13 @@ function createBatchTransportQueue({ options, baseFetch, bucketRegistry }) {
|
|
|
301
310
|
batchId,
|
|
302
311
|
reason: `batch-endpoint-unavailable-${String(response.status)}`
|
|
303
312
|
});
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
endpoint,
|
|
307
|
-
batchId,
|
|
308
|
-
size: items.length,
|
|
309
|
-
reason: `batch-response-${String(response.status)}`
|
|
310
|
-
});
|
|
311
|
-
await settleAmbiguousBatchRequests(items, `batch-response-${String(response.status)}`);
|
|
312
|
-
bucket.flushing = false;
|
|
313
|
+
await settleRequests(items, (request)=>runAfterAmbiguousBatch(request, `batch-response-${String(response.status)}`));
|
|
314
|
+
} else await settleAmbiguousBatchRequests(`batch-response-${String(response.status)}`);
|
|
313
315
|
return;
|
|
314
316
|
}
|
|
315
317
|
const result = await runWithSignal(controller.signal, async ()=>response.json());
|
|
316
|
-
if (!(0, external_response_js_namespaceObject.isBatchResponsePayload)(result))
|
|
317
|
-
|
|
318
|
-
type: 'fallback',
|
|
319
|
-
endpoint,
|
|
320
|
-
batchId,
|
|
321
|
-
size: items.length,
|
|
322
|
-
reason: 'invalid-batch-response'
|
|
323
|
-
});
|
|
324
|
-
await settleAmbiguousBatchRequests(items, 'invalid-batch-response');
|
|
325
|
-
bucket.flushing = false;
|
|
326
|
-
return;
|
|
327
|
-
}
|
|
328
|
-
if (result.batchId !== batchId) {
|
|
329
|
-
(0, external_telemetry_js_namespaceObject.emitDataBatchTransportEvent)(onEvent, {
|
|
330
|
-
type: 'fallback',
|
|
331
|
-
endpoint,
|
|
332
|
-
batchId,
|
|
333
|
-
size: items.length,
|
|
334
|
-
reason: 'mismatched-batch-id'
|
|
335
|
-
});
|
|
336
|
-
await settleAmbiguousBatchRequests(items, 'mismatched-batch-id');
|
|
337
|
-
bucket.flushing = false;
|
|
338
|
-
return;
|
|
339
|
-
}
|
|
318
|
+
if (!(0, external_response_js_namespaceObject.isBatchResponsePayload)(result)) return void await settleAmbiguousBatchRequests('invalid-batch-response');
|
|
319
|
+
if (result.batchId !== batchId) return void await settleAmbiguousBatchRequests('mismatched-batch-id');
|
|
340
320
|
const itemMap = new Map();
|
|
341
321
|
for (const item of result.items)itemMap.set(item.id, item);
|
|
342
322
|
await settleRequests(items, async (request)=>{
|
|
@@ -360,19 +340,10 @@ function createBatchTransportQueue({ options, baseFetch, bucketRegistry }) {
|
|
|
360
340
|
});
|
|
361
341
|
return;
|
|
362
342
|
}
|
|
363
|
-
(
|
|
364
|
-
type: 'fallback',
|
|
365
|
-
endpoint,
|
|
366
|
-
batchId,
|
|
367
|
-
size: items.length,
|
|
368
|
-
reason: 'batch-transport-error'
|
|
369
|
-
});
|
|
370
|
-
await settleAmbiguousBatchRequests(items, 'batch-transport-error');
|
|
343
|
+
await settleAmbiguousBatchRequests('batch-transport-error');
|
|
371
344
|
} finally{
|
|
372
345
|
for (const item of items)item.abortBatchIfUnused = void 0;
|
|
373
|
-
bucket
|
|
374
|
-
if (bucket.items.length > 0 && !bucket.timer) flushBucket(bucketKey);
|
|
375
|
-
buckets.releaseIfIdle(bucketKey, bucket);
|
|
346
|
+
finishFlush(bucketKey, bucket);
|
|
376
347
|
}
|
|
377
348
|
};
|
|
378
349
|
const pendingReadPromises = new Map();
|
|
@@ -396,7 +367,20 @@ function createBatchTransportQueue({ options, baseFetch, bucketRegistry }) {
|
|
|
396
367
|
const sourceSignal = initDefinesSignal ? initSignal ?? void 0 : sourceRequest?.signal;
|
|
397
368
|
const requestUrl = (0, external_url_js_namespaceObject.toAbsoluteUrl)(input);
|
|
398
369
|
const endpoint = (0, external_url_js_namespaceObject.normalizeBatchEndpoint)(requestUrl, options.endpoint).toString();
|
|
370
|
+
const itemHeaders = {
|
|
371
|
+
...headers
|
|
372
|
+
};
|
|
373
|
+
delete itemHeaders.authorization;
|
|
374
|
+
delete itemHeaders.cookie;
|
|
399
375
|
return {
|
|
376
|
+
itemHeaders,
|
|
377
|
+
itemPath: `${requestUrl.pathname}${requestUrl.search}`,
|
|
378
|
+
bucketKey: (0, external_codec_js_namespaceObject.stableStringify)({
|
|
379
|
+
endpoint,
|
|
380
|
+
authorization: headers.authorization ?? null,
|
|
381
|
+
cookie: headers.cookie ?? null,
|
|
382
|
+
credentials
|
|
383
|
+
}),
|
|
400
384
|
requestUrl,
|
|
401
385
|
endpoint,
|
|
402
386
|
method,
|
|
@@ -429,22 +413,11 @@ function createBatchTransportQueue({ options, baseFetch, bucketRegistry }) {
|
|
|
429
413
|
batchEndpoint: request.endpoint,
|
|
430
414
|
requestUrl: request.requestUrl
|
|
431
415
|
})) return;
|
|
432
|
-
const itemHeaders = {
|
|
433
|
-
...request.headers
|
|
434
|
-
};
|
|
435
|
-
delete itemHeaders.authorization;
|
|
436
|
-
delete itemHeaders.cookie;
|
|
437
|
-
const bucketKey = (0, external_codec_js_namespaceObject.stableStringify)({
|
|
438
|
-
endpoint: request.endpoint,
|
|
439
|
-
authorization: request.headers.authorization ?? null,
|
|
440
|
-
cookie: request.headers.cookie ?? null,
|
|
441
|
-
credentials: request.credentials
|
|
442
|
-
});
|
|
443
416
|
return (0, external_codec_js_namespaceObject.stableStringify)({
|
|
444
|
-
bucketKey,
|
|
445
|
-
path:
|
|
417
|
+
bucketKey: request.bucketKey,
|
|
418
|
+
path: request.itemPath,
|
|
446
419
|
method: request.method,
|
|
447
|
-
headers: itemHeaders,
|
|
420
|
+
headers: request.itemHeaders,
|
|
448
421
|
body: null
|
|
449
422
|
});
|
|
450
423
|
};
|
|
@@ -462,26 +435,19 @@ function createBatchTransportQueue({ options, baseFetch, bucketRegistry }) {
|
|
|
462
435
|
const itemId = `${Date.now().toString(36)}_${nextItemId.toString(36)}_${Math.random().toString(16).slice(2, 8)}`;
|
|
463
436
|
nextItemId += 1;
|
|
464
437
|
const itemHeaders = {
|
|
465
|
-
...request.
|
|
438
|
+
...request.itemHeaders
|
|
466
439
|
};
|
|
467
|
-
delete itemHeaders.authorization;
|
|
468
|
-
delete itemHeaders.cookie;
|
|
469
440
|
if (preparedBody.body && preparedBody.inferredContentType && !itemHeaders['content-type']) itemHeaders['content-type'] = preparedBody.inferredContentType;
|
|
470
441
|
const item = {
|
|
471
442
|
id: itemId,
|
|
472
|
-
path:
|
|
443
|
+
path: request.itemPath,
|
|
473
444
|
method: request.method,
|
|
474
445
|
headers: itemHeaders,
|
|
475
446
|
...preparedBody.body ? {
|
|
476
447
|
body: preparedBody.body
|
|
477
448
|
} : {}
|
|
478
449
|
};
|
|
479
|
-
const bucketKey =
|
|
480
|
-
endpoint: request.endpoint,
|
|
481
|
-
authorization: request.headers.authorization ?? null,
|
|
482
|
-
cookie: request.headers.cookie ?? null,
|
|
483
|
-
credentials: request.credentials
|
|
484
|
-
});
|
|
450
|
+
const { bucketKey } = request;
|
|
485
451
|
const key = (0, external_codec_js_namespaceObject.stableStringify)({
|
|
486
452
|
bucketKey,
|
|
487
453
|
path: item.path,
|
|
@@ -575,13 +541,12 @@ function createBatchTransportQueue({ options, baseFetch, bucketRegistry }) {
|
|
|
575
541
|
}
|
|
576
542
|
}
|
|
577
543
|
bucket.items.push(queued);
|
|
578
|
-
bucket.bytes = measurePayload(bucket, bucket.items);
|
|
579
544
|
(0, external_telemetry_js_namespaceObject.emitDataBatchTransportEvent)(onEvent, {
|
|
580
545
|
type: 'enqueue',
|
|
581
546
|
endpoint: request.endpoint,
|
|
582
547
|
size: bucket.items.length
|
|
583
548
|
});
|
|
584
|
-
if (bucket.items.length >= maxBatchSize || bucket.
|
|
549
|
+
if (bucket.items.length >= maxBatchSize || measurePayload(bucket, bucket.items) >= maxBatchBytes) {
|
|
585
550
|
flushBucket(bucketKey);
|
|
586
551
|
return queued.promise;
|
|
587
552
|
}
|
|
@@ -28,28 +28,52 @@ var __webpack_require__ = {};
|
|
|
28
28
|
var __webpack_exports__ = {};
|
|
29
29
|
__webpack_require__.r(__webpack_exports__);
|
|
30
30
|
__webpack_require__.d(__webpack_exports__, {
|
|
31
|
+
EFFECT_BFF_CONTEXT_STORAGE_SHARE: ()=>EFFECT_BFF_CONTEXT_STORAGE_SHARE,
|
|
32
|
+
adoptEffectContextStorage: ()=>adoptEffectContextStorage,
|
|
31
33
|
createEffectOperationContext: ()=>external_operation_context_js_namespaceObject.createEffectOperationContext,
|
|
34
|
+
getEffectContextStorage: ()=>getEffectContextStorage,
|
|
32
35
|
runWithEffectContext: ()=>runWithEffectContext,
|
|
33
36
|
useEffectContext: ()=>useEffectContext,
|
|
34
37
|
useOperationContext: ()=>useOperationContext
|
|
35
38
|
});
|
|
36
|
-
const external_node_async_hooks_namespaceObject = require("node:async_hooks");
|
|
37
39
|
const external_operation_context_js_namespaceObject = require("./operation-context.js");
|
|
38
40
|
const globalStore = globalThis;
|
|
39
|
-
const
|
|
40
|
-
const
|
|
41
|
+
const asyncHooks = globalStore.process?.getBuiltinModule?.('node:async_hooks');
|
|
42
|
+
const AsyncLocalStorage = asyncHooks?.AsyncLocalStorage;
|
|
43
|
+
if ('function' != typeof AsyncLocalStorage) throw new Error('[BFF][Effect] The edge runtime must provide AsyncLocalStorage. Enable Node.js compatibility or the nodejs_als compatibility flag.');
|
|
44
|
+
const EFFECT_BFF_CONTEXT_STORAGE_SHARE = '@modern-js/bff-effect/context-storage';
|
|
45
|
+
let effectContextStorage = new AsyncLocalStorage();
|
|
46
|
+
let effectContextStorageUsed = false;
|
|
47
|
+
const usedEffectContextStorage = ()=>{
|
|
48
|
+
effectContextStorageUsed = true;
|
|
49
|
+
return effectContextStorage;
|
|
50
|
+
};
|
|
51
|
+
const runWithEffectContext = (context, cb)=>usedEffectContextStorage().run(context, cb);
|
|
41
52
|
const useEffectContext = ()=>{
|
|
42
|
-
const context =
|
|
53
|
+
const context = usedEffectContextStorage().getStore();
|
|
43
54
|
if (!context) throw new Error("Can't call useEffectContext out of Effect runtime scope");
|
|
44
55
|
return context;
|
|
45
56
|
};
|
|
57
|
+
const getEffectContextStorage = ()=>effectContextStorage;
|
|
58
|
+
function adoptEffectContextStorage(storage) {
|
|
59
|
+
const candidate = storage;
|
|
60
|
+
if ('function' != typeof candidate?.run || 'function' != typeof candidate.getStore) throw new Error(`[BFF][Effect] Share ${EFFECT_BFF_CONTEXT_STORAGE_SHARE} must provide an AsyncLocalStorage.`);
|
|
61
|
+
if (effectContextStorageUsed && candidate !== effectContextStorage) throw new Error('[BFF][Effect] A backend federation container received the host request storage after an Effect API already used its own. Evaluate exposes only after container init().');
|
|
62
|
+
effectContextStorage = candidate;
|
|
63
|
+
}
|
|
46
64
|
const useOperationContext = ()=>useEffectContext().operationContext;
|
|
65
|
+
exports.EFFECT_BFF_CONTEXT_STORAGE_SHARE = __webpack_exports__.EFFECT_BFF_CONTEXT_STORAGE_SHARE;
|
|
66
|
+
exports.adoptEffectContextStorage = __webpack_exports__.adoptEffectContextStorage;
|
|
47
67
|
exports.createEffectOperationContext = __webpack_exports__.createEffectOperationContext;
|
|
68
|
+
exports.getEffectContextStorage = __webpack_exports__.getEffectContextStorage;
|
|
48
69
|
exports.runWithEffectContext = __webpack_exports__.runWithEffectContext;
|
|
49
70
|
exports.useEffectContext = __webpack_exports__.useEffectContext;
|
|
50
71
|
exports.useOperationContext = __webpack_exports__.useOperationContext;
|
|
51
72
|
for(var __rspack_i in __webpack_exports__)if (-1 === [
|
|
73
|
+
"EFFECT_BFF_CONTEXT_STORAGE_SHARE",
|
|
74
|
+
"adoptEffectContextStorage",
|
|
52
75
|
"createEffectOperationContext",
|
|
76
|
+
"getEffectContextStorage",
|
|
53
77
|
"runWithEffectContext",
|
|
54
78
|
"useEffectContext",
|
|
55
79
|
"useOperationContext"
|
|
@@ -35,16 +35,16 @@ __webpack_require__.d(__webpack_exports__, {
|
|
|
35
35
|
FetchHttpClient: ()=>http_namespaceObject.FetchHttpClient,
|
|
36
36
|
FindMyWay: ()=>http_namespaceObject.FindMyWay,
|
|
37
37
|
Headers: ()=>http_namespaceObject.Headers,
|
|
38
|
-
HttpApi: ()=>
|
|
39
|
-
HttpApiBuilder: ()=>
|
|
40
|
-
HttpApiClient: ()=>
|
|
41
|
-
HttpApiEndpoint: ()=>
|
|
42
|
-
HttpApiError: ()=>
|
|
43
|
-
HttpApiGroup: ()=>
|
|
44
|
-
HttpApiMiddleware: ()=>
|
|
45
|
-
HttpApiSchema: ()=>
|
|
46
|
-
HttpApiSecurity: ()=>
|
|
47
|
-
HttpApiTest: ()=>
|
|
38
|
+
HttpApi: ()=>http_api_namespaceObject.HttpApi,
|
|
39
|
+
HttpApiBuilder: ()=>http_api_namespaceObject.HttpApiBuilder,
|
|
40
|
+
HttpApiClient: ()=>http_api_namespaceObject.HttpApiClient,
|
|
41
|
+
HttpApiEndpoint: ()=>http_api_namespaceObject.HttpApiEndpoint,
|
|
42
|
+
HttpApiError: ()=>http_api_namespaceObject.HttpApiError,
|
|
43
|
+
HttpApiGroup: ()=>http_api_namespaceObject.HttpApiGroup,
|
|
44
|
+
HttpApiMiddleware: ()=>http_api_namespaceObject.HttpApiMiddleware,
|
|
45
|
+
HttpApiSchema: ()=>http_api_namespaceObject.HttpApiSchema,
|
|
46
|
+
HttpApiSecurity: ()=>http_api_namespaceObject.HttpApiSecurity,
|
|
47
|
+
HttpApiTest: ()=>http_api_namespaceObject.HttpApiTest,
|
|
48
48
|
HttpBody: ()=>http_namespaceObject.HttpBody,
|
|
49
49
|
HttpClient: ()=>http_namespaceObject.HttpClient,
|
|
50
50
|
HttpClientError: ()=>http_namespaceObject.HttpClientError,
|
|
@@ -67,7 +67,7 @@ __webpack_require__.d(__webpack_exports__, {
|
|
|
67
67
|
Layer: ()=>Layer_namespaceObject,
|
|
68
68
|
Multipart: ()=>http_namespaceObject.Multipart,
|
|
69
69
|
MultipartParser: ()=>http_namespaceObject.MultipartParser,
|
|
70
|
-
OpenApi: ()=>
|
|
70
|
+
OpenApi: ()=>http_api_namespaceObject.OpenApi,
|
|
71
71
|
Option: ()=>Option_namespaceObject,
|
|
72
72
|
Rpc: ()=>rpc_namespaceObject.Rpc,
|
|
73
73
|
RpcClient: ()=>rpc_namespaceObject.RpcClient,
|
|
@@ -93,23 +93,23 @@ __webpack_require__.d(__webpack_exports__, {
|
|
|
93
93
|
defineEffectBff: ()=>external_handler_js_namespaceObject.defineEffectBff,
|
|
94
94
|
defineEffectRpcBff: ()=>external_handler_js_namespaceObject.defineEffectRpcBff,
|
|
95
95
|
dispatchEffectBffRequest: ()=>dispatchEffectBffRequest,
|
|
96
|
-
runWithEffectContext: ()=>
|
|
97
|
-
useEffectContext: ()=>
|
|
98
|
-
useOperationContext: ()=>
|
|
96
|
+
runWithEffectContext: ()=>context_namespaceObject.runWithEffectContext,
|
|
97
|
+
useEffectContext: ()=>context_namespaceObject.useEffectContext,
|
|
98
|
+
useOperationContext: ()=>context_namespaceObject.useOperationContext
|
|
99
99
|
});
|
|
100
|
+
const context_namespaceObject = require("@modern-js/bff-effect/context");
|
|
100
101
|
const bff_policy_namespaceObject = require("@modern-js/server-runtime-extensions/bff-policy");
|
|
101
102
|
const Effect_namespaceObject = require("effect/Effect");
|
|
102
103
|
const external_headers_js_namespaceObject = require("../headers.js");
|
|
103
104
|
const external_dispatch_js_namespaceObject = require("./dispatch.js");
|
|
104
|
-
const external_edge_context_js_namespaceObject = require("./edge-context.js");
|
|
105
105
|
const external_module_js_namespaceObject = require("./module.js");
|
|
106
106
|
const Config_namespaceObject = require("effect/Config");
|
|
107
|
+
const http_namespaceObject = require("effect/http");
|
|
108
|
+
const http_api_namespaceObject = require("effect/http-api");
|
|
107
109
|
const Layer_namespaceObject = require("effect/Layer");
|
|
108
110
|
const Option_namespaceObject = require("effect/Option");
|
|
111
|
+
const rpc_namespaceObject = require("effect/rpc");
|
|
109
112
|
const Schema_namespaceObject = require("effect/Schema");
|
|
110
|
-
const http_namespaceObject = require("effect/unstable/http");
|
|
111
|
-
const httpapi_namespaceObject = require("effect/unstable/httpapi");
|
|
112
|
-
const rpc_namespaceObject = require("effect/unstable/rpc");
|
|
113
113
|
const external_handler_js_namespaceObject = require("./handler.js");
|
|
114
114
|
const external_operation_context_js_namespaceObject = require("./operation-context.js");
|
|
115
115
|
const NORMALIZED_POLICY_BOOLEAN_FIELDS = [
|
|
@@ -136,7 +136,7 @@ function restoreEffectBffMountPath(request, prefix) {
|
|
|
136
136
|
async function dispatchEffectBffRequest(handler, request, options = {}) {
|
|
137
137
|
return (0, external_dispatch_js_namespaceObject.dispatchEffectBffRequestWithContext)(handler, request, {
|
|
138
138
|
...options,
|
|
139
|
-
runWithEffectContext:
|
|
139
|
+
runWithEffectContext: context_namespaceObject.runWithEffectContext
|
|
140
140
|
});
|
|
141
141
|
}
|
|
142
142
|
async function createEffectBffEdgeDispatcher(options) {
|
package/dist/cjs/effect/edge.js
CHANGED
|
@@ -3,8 +3,14 @@ var __webpack_modules__ = {
|
|
|
3
3
|
"./edge-dispatcher" (module) {
|
|
4
4
|
module.exports = require("./edge-dispatcher.js");
|
|
5
5
|
},
|
|
6
|
+
"./entry-shape" (module) {
|
|
7
|
+
module.exports = require("./entry-shape.js");
|
|
8
|
+
},
|
|
6
9
|
"./generated-entry" (module) {
|
|
7
10
|
module.exports = require("./generated-entry.js");
|
|
11
|
+
},
|
|
12
|
+
"@modern-js/bff-effect/context" (module) {
|
|
13
|
+
module.exports = require("@modern-js/bff-effect/context");
|
|
8
14
|
}
|
|
9
15
|
};
|
|
10
16
|
var __webpack_module_cache__ = {};
|
|
@@ -54,20 +60,34 @@ function __webpack_require__(moduleId) {
|
|
|
54
60
|
var __webpack_exports__ = {};
|
|
55
61
|
(()=>{
|
|
56
62
|
__webpack_require__.r(__webpack_exports__);
|
|
57
|
-
var
|
|
63
|
+
var _modern_js_bff_effect_context__rspack_import_0 = __webpack_require__("@modern-js/bff-effect/context");
|
|
64
|
+
var _edge_dispatcher__rspack_import_1 = __webpack_require__("./edge-dispatcher");
|
|
58
65
|
var __rspack_reexport = {};
|
|
59
|
-
for(const __rspack_import_key in
|
|
66
|
+
for(const __rspack_import_key in _edge_dispatcher__rspack_import_1)if ([
|
|
67
|
+
"EFFECT_BFF_CONTEXT_STORAGE_SHARE",
|
|
68
|
+
"default",
|
|
69
|
+
"EFFECT_BFF_HANDLER_FACTORY_REGISTRY_SHARE",
|
|
60
70
|
"createEffectBffEdgeDispatcherFactory",
|
|
61
|
-
"
|
|
62
|
-
].indexOf(__rspack_import_key) < 0) __rspack_reexport[__rspack_import_key] = ()=>
|
|
71
|
+
"adoptEffectBffShareScope"
|
|
72
|
+
].indexOf(__rspack_import_key) < 0) __rspack_reexport[__rspack_import_key] = ()=>_edge_dispatcher__rspack_import_1[__rspack_import_key];
|
|
63
73
|
__webpack_require__.d(__webpack_exports__, __rspack_reexport);
|
|
64
|
-
var
|
|
74
|
+
var _entry_shape__rspack_import_2 = __webpack_require__("./entry-shape");
|
|
75
|
+
var _generated_entry__rspack_import_3 = __webpack_require__("./generated-entry");
|
|
65
76
|
__webpack_require__.d(__webpack_exports__, {
|
|
66
|
-
|
|
77
|
+
EFFECT_BFF_CONTEXT_STORAGE_SHARE: ()=>_modern_js_bff_effect_context__rspack_import_0.EFFECT_BFF_CONTEXT_STORAGE_SHARE,
|
|
78
|
+
EFFECT_BFF_HANDLER_FACTORY_REGISTRY_SHARE: ()=>_entry_shape__rspack_import_2.EFFECT_BFF_HANDLER_FACTORY_REGISTRY_SHARE,
|
|
79
|
+
adoptEffectBffShareScope: ()=>_entry_shape__rspack_import_2.adoptEffectBffShareScope,
|
|
80
|
+
createEffectBffEdgeDispatcherFactory: ()=>_generated_entry__rspack_import_3.createEffectBffEdgeDispatcherFactory
|
|
67
81
|
});
|
|
68
82
|
})();
|
|
83
|
+
exports.EFFECT_BFF_CONTEXT_STORAGE_SHARE = __webpack_exports__.EFFECT_BFF_CONTEXT_STORAGE_SHARE;
|
|
84
|
+
exports.EFFECT_BFF_HANDLER_FACTORY_REGISTRY_SHARE = __webpack_exports__.EFFECT_BFF_HANDLER_FACTORY_REGISTRY_SHARE;
|
|
85
|
+
exports.adoptEffectBffShareScope = __webpack_exports__.adoptEffectBffShareScope;
|
|
69
86
|
exports.createEffectBffEdgeDispatcherFactory = __webpack_exports__.createEffectBffEdgeDispatcherFactory;
|
|
70
87
|
for(var __rspack_i in __webpack_exports__)if (-1 === [
|
|
88
|
+
"EFFECT_BFF_CONTEXT_STORAGE_SHARE",
|
|
89
|
+
"EFFECT_BFF_HANDLER_FACTORY_REGISTRY_SHARE",
|
|
90
|
+
"adoptEffectBffShareScope",
|
|
71
91
|
"createEffectBffEdgeDispatcherFactory"
|
|
72
92
|
].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
|
|
73
93
|
Object.defineProperty(exports, '__esModule', {
|
|
@@ -30,6 +30,16 @@ var __webpack_require__ = {};
|
|
|
30
30
|
})();
|
|
31
31
|
var __webpack_exports__ = {};
|
|
32
32
|
__webpack_require__.r(__webpack_exports__);
|
|
33
|
+
__webpack_require__.d(__webpack_exports__, {
|
|
34
|
+
EFFECT_BFF_HANDLER_FACTORY_REGISTRY_SHARE: ()=>EFFECT_BFF_HANDLER_FACTORY_REGISTRY_SHARE,
|
|
35
|
+
adoptEffectBffShareScope: ()=>adoptEffectBffShareScope,
|
|
36
|
+
classifyEffectBffEntryModule: ()=>classifyEffectBffEntryModule,
|
|
37
|
+
isValidatorAwareHandlerFactory: ()=>isValidatorAwareHandlerFactory,
|
|
38
|
+
registerValidatorAwareHandlerFactory: ()=>registerValidatorAwareHandlerFactory,
|
|
39
|
+
strictEffectApproachMessage: ()=>strictEffectApproachMessage
|
|
40
|
+
});
|
|
41
|
+
const context_namespaceObject = require("@modern-js/bff-effect/context");
|
|
42
|
+
const EFFECT_BFF_HANDLER_FACTORY_REGISTRY_SHARE = '@modern-js/bff-effect/handler-factory-registry';
|
|
33
43
|
function createLocalValidatorAwareHandlerFactoryRegistry() {
|
|
34
44
|
const factories = new WeakSet();
|
|
35
45
|
return {
|
|
@@ -53,12 +63,33 @@ function loadNodeValidatorAwareHandlerFactoryRegistry() {
|
|
|
53
63
|
throw error;
|
|
54
64
|
}
|
|
55
65
|
}
|
|
56
|
-
|
|
66
|
+
let validatorAwareHandlerFactoryRegistry;
|
|
67
|
+
function handlerFactoryRegistry() {
|
|
68
|
+
validatorAwareHandlerFactoryRegistry ??= loadNodeValidatorAwareHandlerFactoryRegistry();
|
|
69
|
+
return validatorAwareHandlerFactoryRegistry;
|
|
70
|
+
}
|
|
71
|
+
const adoptShared = (shareScope, name, adopt)=>{
|
|
72
|
+
const versions = 'object' == typeof shareScope && null !== shareScope ? shareScope[name] : void 0;
|
|
73
|
+
const shared = void 0 === versions ? void 0 : Object.values(versions)[0];
|
|
74
|
+
if ('function' != typeof shared?.get) return Promise.resolve();
|
|
75
|
+
return Promise.resolve(shared.get()).then((factory)=>adopt('function' == typeof factory ? factory() : void 0));
|
|
76
|
+
};
|
|
77
|
+
function adoptEffectBffShareScope(shareScope) {
|
|
78
|
+
return Promise.all([
|
|
79
|
+
adoptShared(shareScope, EFFECT_BFF_HANDLER_FACTORY_REGISTRY_SHARE, (registry)=>adoptHandlerFactoryRegistry(registry)),
|
|
80
|
+
adoptShared(shareScope, context_namespaceObject.EFFECT_BFF_CONTEXT_STORAGE_SHARE, context_namespaceObject.adoptEffectContextStorage)
|
|
81
|
+
]).then(()=>void 0);
|
|
82
|
+
}
|
|
83
|
+
function adoptHandlerFactoryRegistry(registry) {
|
|
84
|
+
if ('function' != typeof registry?.register || 'function' != typeof registry.is) throw new Error(`[BFF][Effect] Share ${EFFECT_BFF_HANDLER_FACTORY_REGISTRY_SHARE} must provide a handler factory registry.`);
|
|
85
|
+
if (void 0 !== validatorAwareHandlerFactoryRegistry && validatorAwareHandlerFactoryRegistry !== registry) throw new Error('[BFF][Effect] A backend federation container received the host handler factory registry after an Effect API already used its own. Evaluate exposes only after container init().');
|
|
86
|
+
validatorAwareHandlerFactoryRegistry = registry;
|
|
87
|
+
}
|
|
57
88
|
function registerValidatorAwareHandlerFactory(factory) {
|
|
58
|
-
return
|
|
89
|
+
return handlerFactoryRegistry().register(factory);
|
|
59
90
|
}
|
|
60
91
|
function isValidatorAwareHandlerFactory(factory) {
|
|
61
|
-
return
|
|
92
|
+
return handlerFactoryRegistry().is(factory);
|
|
62
93
|
}
|
|
63
94
|
const strictEffectApproachMessage = '[BFF][Effect] strictEffectApproach is enforced: Effect API entries export defineEffectBff(...) or { api, layer } HttpApi module. Raw handler exports, default request handlers, unbranded custom createHandler factories not valid Effect API entries.';
|
|
64
95
|
function isEffectEntryRecord(value) {
|
|
@@ -91,18 +122,15 @@ function createEntryShapeFacts(module, predicates, unsupportedShape) {
|
|
|
91
122
|
hasRuntimeLayer
|
|
92
123
|
};
|
|
93
124
|
}
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
isValidatorAwareHandlerFactory: ()=>isValidatorAwareHandlerFactory,
|
|
97
|
-
registerValidatorAwareHandlerFactory: ()=>registerValidatorAwareHandlerFactory
|
|
98
|
-
}, {
|
|
99
|
-
strictEffectApproachMessage: strictEffectApproachMessage
|
|
100
|
-
});
|
|
125
|
+
exports.EFFECT_BFF_HANDLER_FACTORY_REGISTRY_SHARE = __webpack_exports__.EFFECT_BFF_HANDLER_FACTORY_REGISTRY_SHARE;
|
|
126
|
+
exports.adoptEffectBffShareScope = __webpack_exports__.adoptEffectBffShareScope;
|
|
101
127
|
exports.classifyEffectBffEntryModule = __webpack_exports__.classifyEffectBffEntryModule;
|
|
102
128
|
exports.isValidatorAwareHandlerFactory = __webpack_exports__.isValidatorAwareHandlerFactory;
|
|
103
129
|
exports.registerValidatorAwareHandlerFactory = __webpack_exports__.registerValidatorAwareHandlerFactory;
|
|
104
130
|
exports.strictEffectApproachMessage = __webpack_exports__.strictEffectApproachMessage;
|
|
105
131
|
for(var __rspack_i in __webpack_exports__)if (-1 === [
|
|
132
|
+
"EFFECT_BFF_HANDLER_FACTORY_REGISTRY_SHARE",
|
|
133
|
+
"adoptEffectBffShareScope",
|
|
106
134
|
"classifyEffectBffEntryModule",
|
|
107
135
|
"isValidatorAwareHandlerFactory",
|
|
108
136
|
"registerValidatorAwareHandlerFactory",
|
|
@@ -32,6 +32,7 @@ __webpack_require__.d(__webpack_exports__, {
|
|
|
32
32
|
});
|
|
33
33
|
const Effect_namespaceObject = require("effect/Effect");
|
|
34
34
|
const index_js_namespaceObject = require("../../data-platform/index.js");
|
|
35
|
+
const options_js_namespaceObject = require("../../data-platform/batch/options.js");
|
|
35
36
|
const protocol_js_namespaceObject = require("../../data-platform/batch/protocol.js");
|
|
36
37
|
const external_batch_js_namespaceObject = require("./batch.js");
|
|
37
38
|
const external_routing_js_namespaceObject = require("./routing.js");
|
|
@@ -123,11 +124,9 @@ function createDataPlatformBatchRequestHandler(options) {
|
|
|
123
124
|
const dataPlatformBatchOptions = options.dataPlatform?.batch;
|
|
124
125
|
const batchEnabled = dataPlatformBatchOptions?.enabled !== false;
|
|
125
126
|
const batchPath = (0, external_batch_js_namespaceObject.normalizeBatchPath)(dataPlatformBatchOptions?.endpoint);
|
|
126
|
-
const batchMaxSize =
|
|
127
|
-
const batchMaxBytes = Math.max(1024, dataPlatformBatchOptions?.maxBatchBytes ?? 65536);
|
|
127
|
+
const { maxBatchSize: batchMaxSize, maxBatchBytes: batchMaxBytes, allowedMethods: batchAllowedMethods } = (0, options_js_namespaceObject.normalizeBatchLimits)(dataPlatformBatchOptions);
|
|
128
128
|
const batchConcurrency = Math.max(1, dataPlatformBatchOptions?.maxConcurrency ?? 4);
|
|
129
129
|
const batchItemTimeoutMs = Math.max(0, dataPlatformBatchOptions?.requestTimeoutMs ?? 10000);
|
|
130
|
-
const batchAllowedMethods = (0, external_batch_js_namespaceObject.normalizeBatchAllowedMethods)(dataPlatformBatchOptions?.allowedMethods);
|
|
131
130
|
const envelopeHeader = options.dataPlatform?.envelopeHeader || index_js_namespaceObject.DEFAULT_DATA_ENVELOPE_HEADER;
|
|
132
131
|
const normalizedEnvelopeHeader = envelopeHeader.toLowerCase();
|
|
133
132
|
const handle = async (request, context)=>{
|
|
@@ -32,7 +32,6 @@ __webpack_require__.d(__webpack_exports__, {
|
|
|
32
32
|
createBatchValidationResponse: ()=>createBatchValidationResponse,
|
|
33
33
|
isBatchRequestPayload: ()=>isBatchRequestPayload,
|
|
34
34
|
mapWithConcurrency: ()=>mapWithConcurrency,
|
|
35
|
-
normalizeBatchAllowedMethods: ()=>normalizeBatchAllowedMethods,
|
|
36
35
|
normalizeBatchPath: ()=>normalizeBatchPath,
|
|
37
36
|
prepareJsonRequestBody: ()=>prepareJsonRequestBody,
|
|
38
37
|
promiseWithTimeout: ()=>promiseWithTimeout,
|
|
@@ -48,12 +47,6 @@ function normalizeBatchPath(pathname) {
|
|
|
48
47
|
if (!pathname.startsWith('/')) return `/${pathname}`;
|
|
49
48
|
return pathname;
|
|
50
49
|
}
|
|
51
|
-
function normalizeBatchAllowedMethods(allowedMethods) {
|
|
52
|
-
const source = Array.isArray(allowedMethods) && allowedMethods.length > 0 ? allowedMethods : [
|
|
53
|
-
'GET'
|
|
54
|
-
];
|
|
55
|
-
return new Set(source.map((method)=>method.toUpperCase()));
|
|
56
|
-
}
|
|
57
50
|
function isBatchRequestPayload(value) {
|
|
58
51
|
return (0, index_js_namespaceObject.isPlainObject)(value) && 2 === value.protocolVersion && 'string' == typeof value.batchId && 'number' == typeof value.sentAt && Array.isArray(value.items);
|
|
59
52
|
}
|
|
@@ -154,7 +147,6 @@ exports.BatchItemTimeoutError = __webpack_exports__.BatchItemTimeoutError;
|
|
|
154
147
|
exports.createBatchValidationResponse = __webpack_exports__.createBatchValidationResponse;
|
|
155
148
|
exports.isBatchRequestPayload = __webpack_exports__.isBatchRequestPayload;
|
|
156
149
|
exports.mapWithConcurrency = __webpack_exports__.mapWithConcurrency;
|
|
157
|
-
exports.normalizeBatchAllowedMethods = __webpack_exports__.normalizeBatchAllowedMethods;
|
|
158
150
|
exports.normalizeBatchPath = __webpack_exports__.normalizeBatchPath;
|
|
159
151
|
exports.prepareJsonRequestBody = __webpack_exports__.prepareJsonRequestBody;
|
|
160
152
|
exports.promiseWithTimeout = __webpack_exports__.promiseWithTimeout;
|
|
@@ -165,7 +157,6 @@ for(var __rspack_i in __webpack_exports__)if (-1 === [
|
|
|
165
157
|
"createBatchValidationResponse",
|
|
166
158
|
"isBatchRequestPayload",
|
|
167
159
|
"mapWithConcurrency",
|
|
168
|
-
"normalizeBatchAllowedMethods",
|
|
169
160
|
"normalizeBatchPath",
|
|
170
161
|
"prepareJsonRequestBody",
|
|
171
162
|
"promiseWithTimeout",
|
|
@@ -30,8 +30,8 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
30
30
|
__webpack_require__.d(__webpack_exports__, {
|
|
31
31
|
createHttpApiHandler: ()=>createHttpApiHandler
|
|
32
32
|
});
|
|
33
|
+
const http_namespaceObject = require("effect/http");
|
|
33
34
|
const Layer_namespaceObject = require("effect/Layer");
|
|
34
|
-
const http_namespaceObject = require("effect/unstable/http");
|
|
35
35
|
const external_batch_js_namespaceObject = require("./batch.js");
|
|
36
36
|
const external_batch_handler_js_namespaceObject = require("./batch-handler.js");
|
|
37
37
|
const external_envelope_js_namespaceObject = require("./envelope.js");
|