@bleedingdev/modern-js-bff-effect 3.9.0-ultramodern.2 → 3.9.0-ultramodern.21

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 (142) hide show
  1. package/README.md +20 -4
  2. package/dist/cjs/assembly.js +50 -0
  3. package/dist/cjs/{effect-client/guards.js → data-platform/batch/options.js} +13 -9
  4. package/dist/cjs/data-platform/batch/queue.js +48 -83
  5. package/dist/cjs/data-platform/trace.js +2 -2
  6. package/dist/cjs/effect/context.js +28 -4
  7. package/dist/cjs/effect/edge-dispatcher.js +12 -12
  8. package/dist/cjs/effect/edge.js +36 -3
  9. package/dist/cjs/effect/endpoint-contracts.js +3 -4
  10. package/dist/cjs/effect/entry-shape.js +40 -12
  11. package/dist/cjs/effect/generated-entry.js +57 -0
  12. package/dist/cjs/effect/handler/batch-handler.js +7 -7
  13. package/dist/cjs/effect/handler/batch.js +8 -10
  14. package/dist/cjs/effect/handler/definition.js +1 -21
  15. package/dist/cjs/effect/index.js +8 -8
  16. package/dist/cjs/effect/module.js +8 -4
  17. package/dist/cjs/effect/operation-context.js +10 -14
  18. package/dist/cjs/effect/rpcSerialization.js +0 -2
  19. package/dist/cjs/effect-client/cross-project.js +89 -0
  20. package/dist/cjs/effect-client/index.js +5 -3
  21. package/dist/cjs/microvertical-api.js +120 -0
  22. package/dist/esm/assembly.mjs +12 -0
  23. package/dist/esm/data-platform/batch/options.mjs +10 -0
  24. package/dist/esm/data-platform/batch/queue.mjs +48 -83
  25. package/dist/esm/data-platform/trace.mjs +1 -1
  26. package/dist/esm/effect/context.mjs +21 -6
  27. package/dist/esm/effect/edge-dispatcher.mjs +6 -6
  28. package/dist/esm/effect/edge.mjs +3 -0
  29. package/dist/esm/effect/endpoint-contracts.mjs +2 -3
  30. package/dist/esm/effect/entry-shape-registry.mjs +2 -2
  31. package/dist/esm/effect/entry-shape.mjs +29 -6
  32. package/dist/esm/effect/generated-entry.mjs +19 -0
  33. package/dist/esm/effect/handler/batch-handler.mjs +8 -8
  34. package/dist/esm/effect/handler/batch.mjs +9 -8
  35. package/dist/esm/effect/handler/definition.mjs +1 -21
  36. package/dist/esm/effect/index.mjs +1 -1
  37. package/dist/esm/effect/module.mjs +8 -4
  38. package/dist/esm/effect/operation-context.mjs +3 -4
  39. package/dist/esm/effect/rpcSerialization.mjs +0 -2
  40. package/dist/esm/effect-client/cross-project.mjs +51 -0
  41. package/dist/esm/effect-client/index.mjs +4 -2
  42. package/dist/esm/microvertical-api.mjs +67 -0
  43. package/dist/esm-node/assembly.mjs +13 -0
  44. package/dist/esm-node/data-platform/batch/options.mjs +11 -0
  45. package/dist/esm-node/data-platform/batch/queue.mjs +48 -83
  46. package/dist/esm-node/data-platform/trace.mjs +1 -1
  47. package/dist/esm-node/effect/context.mjs +21 -6
  48. package/dist/esm-node/effect/edge-dispatcher.mjs +6 -6
  49. package/dist/esm-node/effect/edge.mjs +3 -0
  50. package/dist/esm-node/effect/endpoint-contracts.mjs +2 -3
  51. package/dist/esm-node/effect/entry-shape.mjs +29 -6
  52. package/dist/esm-node/effect/generated-entry.mjs +20 -0
  53. package/dist/esm-node/effect/handler/batch-handler.mjs +8 -8
  54. package/dist/esm-node/effect/handler/batch.mjs +9 -8
  55. package/dist/esm-node/effect/handler/definition.mjs +1 -21
  56. package/dist/esm-node/effect/index.mjs +1 -1
  57. package/dist/esm-node/effect/module.mjs +8 -4
  58. package/dist/esm-node/effect/operation-context.mjs +3 -4
  59. package/dist/esm-node/effect/rpcSerialization.mjs +0 -2
  60. package/dist/esm-node/effect-client/cross-project.mjs +52 -0
  61. package/dist/esm-node/effect-client/index.mjs +4 -2
  62. package/dist/esm-node/microvertical-api.mjs +68 -0
  63. package/dist/types/assembly.d.ts +10 -0
  64. package/dist/types/data-platform/batch/options.d.ts +7 -0
  65. package/dist/types/data-platform/batch/queue.d.ts +0 -1
  66. package/dist/types/effect/context.d.ts +15 -2
  67. package/dist/types/effect/edge-dispatcher.d.ts +3 -3
  68. package/dist/types/effect/edge.d.ts +3 -0
  69. package/dist/types/effect/endpoint-contracts.d.ts +2 -20
  70. package/dist/types/effect/entry-shape.d.ts +16 -2
  71. package/dist/types/effect/generated-entry.d.ts +7 -0
  72. package/dist/types/effect/handler/batch.d.ts +7 -2
  73. package/dist/types/effect/handler/types.d.ts +2 -17
  74. package/dist/types/effect/handler.d.ts +1 -1
  75. package/dist/types/effect/module.d.ts +2 -1
  76. package/dist/types/effect/operation-context.d.ts +1 -2
  77. package/dist/types/effect-client/cross-project.d.ts +10 -0
  78. package/dist/types/effect-client/index.d.ts +7 -4
  79. package/dist/types/microvertical-api.d.ts +65 -0
  80. package/package.json +47 -42
  81. package/src/assembly.ts +43 -0
  82. package/src/data-platform/batch/options.ts +20 -0
  83. package/src/data-platform/batch/queue.ts +63 -92
  84. package/src/data-platform/trace.ts +1 -1
  85. package/src/effect/context.ts +64 -12
  86. package/src/effect/edge-dispatcher.ts +14 -11
  87. package/src/effect/edge.ts +6 -0
  88. package/src/effect/endpoint-contracts.ts +3 -24
  89. package/src/effect/entry-shape.ts +105 -10
  90. package/src/effect/generated-entry.ts +36 -0
  91. package/src/effect/handler/batch-handler.ts +27 -28
  92. package/src/effect/handler/batch.ts +9 -13
  93. package/src/effect/handler/definition.ts +0 -45
  94. package/src/effect/handler/http.ts +2 -2
  95. package/src/effect/handler/types.ts +3 -32
  96. package/src/effect/handler.ts +0 -1
  97. package/src/effect/index.ts +1 -1
  98. package/src/effect/module.ts +11 -4
  99. package/src/effect/operation-context.ts +2 -6
  100. package/src/effect/rpcSerialization.ts +0 -2
  101. package/src/effect-client/cross-project.ts +104 -0
  102. package/src/effect-client/index.ts +17 -7
  103. package/src/microvertical-api.ts +102 -0
  104. package/dist/cjs/effect/edge-context.js +0 -61
  105. package/dist/cjs/effect-client/batch.js +0 -73
  106. package/dist/cjs/effect-client/envelope.js +0 -145
  107. package/dist/cjs/effect-client/request-context.js +0 -64
  108. package/dist/cjs/effect-client/request.js +0 -66
  109. package/dist/cjs/effect-client/runtime.js +0 -100
  110. package/dist/cjs/effect-client/types.js +0 -18
  111. package/dist/esm/effect/edge-context.mjs +0 -14
  112. package/dist/esm/effect-client/batch.mjs +0 -35
  113. package/dist/esm/effect-client/envelope.mjs +0 -104
  114. package/dist/esm/effect-client/guards.mjs +0 -3
  115. package/dist/esm/effect-client/request-context.mjs +0 -23
  116. package/dist/esm/effect-client/request.mjs +0 -28
  117. package/dist/esm/effect-client/runtime.mjs +0 -62
  118. package/dist/esm/effect-client/types.mjs +0 -0
  119. package/dist/esm-node/effect/edge-context.mjs +0 -15
  120. package/dist/esm-node/effect-client/batch.mjs +0 -36
  121. package/dist/esm-node/effect-client/envelope.mjs +0 -105
  122. package/dist/esm-node/effect-client/guards.mjs +0 -4
  123. package/dist/esm-node/effect-client/request-context.mjs +0 -24
  124. package/dist/esm-node/effect-client/request.mjs +0 -29
  125. package/dist/esm-node/effect-client/runtime.mjs +0 -63
  126. package/dist/esm-node/effect-client/types.mjs +0 -1
  127. package/dist/types/effect/edge-context.d.ts +0 -5
  128. package/dist/types/effect-client/batch.d.ts +0 -2
  129. package/dist/types/effect-client/envelope.d.ts +0 -15
  130. package/dist/types/effect-client/guards.d.ts +0 -2
  131. package/dist/types/effect-client/request-context.d.ts +0 -3
  132. package/dist/types/effect-client/request.d.ts +0 -1
  133. package/dist/types/effect-client/runtime.d.ts +0 -5
  134. package/dist/types/effect-client/types.d.ts +0 -68
  135. package/src/effect/edge-context.ts +0 -51
  136. package/src/effect-client/batch.ts +0 -50
  137. package/src/effect-client/envelope.ts +0 -238
  138. package/src/effect-client/guards.ts +0 -6
  139. package/src/effect-client/request-context.ts +0 -54
  140. package/src/effect-client/request.ts +0 -51
  141. package/src/effect-client/runtime.ts +0 -122
  142. package/src/effect-client/types.ts +0 -84
@@ -1,9 +1,8 @@
1
1
  import "node:module";
2
- import { createOperationContractHash } from "@modern-js/bff-core";
2
+ import { createOperationContractHash } from "@modern-js/server-runtime-extensions/bff-policy/node";
3
3
  import { classifyEffectBffEntryModule, isValidatorAwareHandlerFactory } from "./entry-shape.mjs";
4
4
  function resolveEffectEndpointName(endpoint) {
5
5
  if ('string' == typeof endpoint.identifier && endpoint.identifier) return endpoint.identifier;
6
- if ('string' == typeof endpoint.name && endpoint.name) return endpoint.name;
7
6
  return '';
8
7
  }
9
8
  function ensureLeadingSlash(pathname) {
@@ -61,7 +60,7 @@ async function extractHttpApiFromModule(mod, isHttpApi) {
61
60
  isValidatorAwareHandlerFactory: isValidatorAwareHandlerFactory,
62
61
  isHttpApi
63
62
  });
64
- return !facts?.legacyShape && facts?.api !== void 0 && facts.hasRuntimeLayer && (void 0 === facts.createHandler || facts.createHandlerValidatorAware) ? facts.api : null;
63
+ return !facts?.unsupportedShape && facts?.api !== void 0 && facts.hasRuntimeLayer && (void 0 === facts.createHandler || facts.createHandlerValidatorAware) ? facts.api : null;
65
64
  }
66
65
  function createEffectEndpointContractHash(endpoint, requestId) {
67
66
  return createOperationContractHash(createEffectOperationContractSource(endpoint), requestId);
@@ -1,4 +1,6 @@
1
1
  import "node:module";
2
+ import { EFFECT_BFF_CONTEXT_STORAGE_SHARE, adoptEffectContextStorage } from "@modern-js/bff-effect/context";
3
+ const EFFECT_BFF_HANDLER_FACTORY_REGISTRY_SHARE = '@modern-js/bff-effect/handler-factory-registry';
2
4
  function createLocalValidatorAwareHandlerFactoryRegistry() {
3
5
  const factories = new WeakSet();
4
6
  return {
@@ -22,12 +24,33 @@ function loadNodeValidatorAwareHandlerFactoryRegistry() {
22
24
  throw error;
23
25
  }
24
26
  }
25
- const validatorAwareHandlerFactoryRegistry = loadNodeValidatorAwareHandlerFactoryRegistry();
27
+ let validatorAwareHandlerFactoryRegistry;
28
+ function handlerFactoryRegistry() {
29
+ validatorAwareHandlerFactoryRegistry ??= loadNodeValidatorAwareHandlerFactoryRegistry();
30
+ return validatorAwareHandlerFactoryRegistry;
31
+ }
32
+ const adoptShared = (shareScope, name, adopt)=>{
33
+ const versions = 'object' == typeof shareScope && null !== shareScope ? shareScope[name] : void 0;
34
+ const shared = void 0 === versions ? void 0 : Object.values(versions)[0];
35
+ if ('function' != typeof shared?.get) return Promise.resolve();
36
+ return Promise.resolve(shared.get()).then((factory)=>adopt('function' == typeof factory ? factory() : void 0));
37
+ };
38
+ function adoptEffectBffShareScope(shareScope) {
39
+ return Promise.all([
40
+ adoptShared(shareScope, EFFECT_BFF_HANDLER_FACTORY_REGISTRY_SHARE, (registry)=>adoptHandlerFactoryRegistry(registry)),
41
+ adoptShared(shareScope, EFFECT_BFF_CONTEXT_STORAGE_SHARE, adoptEffectContextStorage)
42
+ ]).then(()=>void 0);
43
+ }
44
+ function adoptHandlerFactoryRegistry(registry) {
45
+ 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.`);
46
+ 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().');
47
+ validatorAwareHandlerFactoryRegistry = registry;
48
+ }
26
49
  function registerValidatorAwareHandlerFactory(factory) {
27
- return validatorAwareHandlerFactoryRegistry.register(factory);
50
+ return handlerFactoryRegistry().register(factory);
28
51
  }
29
52
  function isValidatorAwareHandlerFactory(factory) {
30
- return validatorAwareHandlerFactoryRegistry.is(factory);
53
+ return handlerFactoryRegistry().is(factory);
31
54
  }
32
55
  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.';
33
56
  function isEffectEntryRecord(value) {
@@ -46,13 +69,13 @@ function classifyEffectBffEntryModule(value, predicates) {
46
69
  if (predicates.isRequestHandler(module.handler)) return createEntryShapeFacts(module, predicates, '`handler` export');
47
70
  return createEntryShapeFacts(module, predicates);
48
71
  }
49
- function createEntryShapeFacts(module, predicates, legacyShape) {
72
+ function createEntryShapeFacts(module, predicates, unsupportedShape) {
50
73
  const createHandler = 'function' == typeof module.createHandler ? module.createHandler : void 0;
51
74
  const api = predicates.isHttpApi(module.api) ? module.api : void 0;
52
75
  const hasRuntimeLayer = void 0 !== module.layer;
53
76
  return {
54
77
  module,
55
- legacyShape,
78
+ unsupportedShape,
56
79
  createHandler,
57
80
  createHandlerValidatorAware: void 0 !== createHandler && predicates.isValidatorAwareHandlerFactory(createHandler),
58
81
  api,
@@ -60,4 +83,4 @@ function createEntryShapeFacts(module, predicates, legacyShape) {
60
83
  hasRuntimeLayer
61
84
  };
62
85
  }
63
- export { classifyEffectBffEntryModule, isValidatorAwareHandlerFactory, registerValidatorAwareHandlerFactory, strictEffectApproachMessage };
86
+ export { EFFECT_BFF_HANDLER_FACTORY_REGISTRY_SHARE, adoptEffectBffShareScope, classifyEffectBffEntryModule, isValidatorAwareHandlerFactory, registerValidatorAwareHandlerFactory, strictEffectApproachMessage };
@@ -0,0 +1,20 @@
1
+ import "node:module";
2
+ import { createEffectBffEdgeDispatcher } from "./edge-dispatcher.mjs";
3
+ function createEffectBffEdgeDispatcherFactory(module, generatedOperationContracts) {
4
+ return (options)=>{
5
+ const policy = options?.crossProjectPolicy;
6
+ const crossProjectPolicy = null == policy || null === policy.expectedOperationContracts || 'object' != typeof policy.expectedOperationContracts || Array.isArray(policy.expectedOperationContracts) ? policy : {
7
+ ...policy,
8
+ expectedOperationContracts: {
9
+ ...policy.expectedOperationContracts,
10
+ ...generatedOperationContracts
11
+ }
12
+ };
13
+ return createEffectBffEdgeDispatcher({
14
+ ...options,
15
+ crossProjectPolicy,
16
+ module
17
+ });
18
+ };
19
+ }
20
+ export { createEffectBffEdgeDispatcherFactory };
@@ -1,8 +1,10 @@
1
1
  import "node:module";
2
2
  import { DEFAULT_DATA_BATCH_HEADER, DEFAULT_DATA_ENVELOPE_HEADER, decodeRequestEnvelopeHeader, isPlainObject, normalizeMethod } from "../../data-platform/index.mjs";
3
+ import { normalizeBatchLimits } from "../../data-platform/batch/options.mjs";
3
4
  import { decodeBatchBody, isBatchBody, toBatchResponseItem } from "../../data-platform/batch/protocol.mjs";
4
- import { BatchItemTimeoutError, createBatchValidationResponse, isBatchRequestPayload, mapWithConcurrency, normalizeBatchAllowedMethods, normalizeBatchPath, promiseWithTimeout, toBatchItemError } from "./batch.mjs";
5
+ import { BatchItemTimeoutError, createBatchValidationResponse, isBatchRequestPayload, mapWithConcurrency, normalizeBatchPath, promiseWithTimeout, toBatchItemError } from "./batch.mjs";
5
6
  import { getMountedPrefixFromContext, removeMountedPrefixFromBatchPath } from "./routing.mjs";
7
+ import * as __rspack_external_effect_Effect_41060786 from "effect/Effect";
6
8
  const HOP_BY_HOP_BATCH_ITEM_HEADERS = new Set([
7
9
  'connection',
8
10
  'keep-alive',
@@ -91,11 +93,9 @@ function createDataPlatformBatchRequestHandler(options) {
91
93
  const dataPlatformBatchOptions = options.dataPlatform?.batch;
92
94
  const batchEnabled = dataPlatformBatchOptions?.enabled !== false;
93
95
  const batchPath = normalizeBatchPath(dataPlatformBatchOptions?.endpoint);
94
- const batchMaxSize = Math.max(1, dataPlatformBatchOptions?.maxBatchSize ?? 16);
95
- const batchMaxBytes = Math.max(1024, dataPlatformBatchOptions?.maxBatchBytes ?? 65536);
96
+ const { maxBatchSize: batchMaxSize, maxBatchBytes: batchMaxBytes, allowedMethods: batchAllowedMethods } = normalizeBatchLimits(dataPlatformBatchOptions);
96
97
  const batchConcurrency = Math.max(1, dataPlatformBatchOptions?.maxConcurrency ?? 4);
97
98
  const batchItemTimeoutMs = Math.max(0, dataPlatformBatchOptions?.requestTimeoutMs ?? 10000);
98
- const batchAllowedMethods = normalizeBatchAllowedMethods(dataPlatformBatchOptions?.allowedMethods);
99
99
  const envelopeHeader = options.dataPlatform?.envelopeHeader || DEFAULT_DATA_ENVELOPE_HEADER;
100
100
  const normalizedEnvelopeHeader = envelopeHeader.toLowerCase();
101
101
  const handle = async (request, context)=>{
@@ -185,25 +185,25 @@ function createDataPlatformBatchRequestHandler(options) {
185
185
  return toBatchResponseItem(itemId, itemResponse, 'HEAD' === itemMethod);
186
186
  } catch (error) {
187
187
  if (error instanceof BatchItemTimeoutError) {
188
- console.error({
188
+ __rspack_external_effect_Effect_41060786.runSync(__rspack_external_effect_Effect_41060786.logError({
189
189
  event: 'bff.batch.item.timeout',
190
190
  batchId: payload.batchId,
191
191
  itemId,
192
192
  method: itemMethod,
193
193
  path: itemPathname,
194
194
  errorName: error.name
195
- });
195
+ }));
196
196
  return toBatchItemError(itemId, 504, 'Batch item request timed out');
197
197
  }
198
198
  if (error instanceof Response) return toBatchResponseItem(itemId, error, 'HEAD' === itemMethod);
199
- console.error({
199
+ __rspack_external_effect_Effect_41060786.runSync(__rspack_external_effect_Effect_41060786.logError({
200
200
  event: 'bff.batch.item.failure',
201
201
  batchId: payload.batchId,
202
202
  itemId,
203
203
  method: itemMethod,
204
204
  path: itemPathname,
205
205
  errorName: error instanceof Error ? error.name : 'UnknownError'
206
- });
206
+ }));
207
207
  return toBatchItemError(itemId, 500, 'Internal Server Error');
208
208
  } finally{
209
209
  request.signal.removeEventListener('abort', abortFromBatchRequest);
@@ -1,17 +1,12 @@
1
1
  import "node:module";
2
2
  import { DEFAULT_DATA_BATCH_ENDPOINT, isPlainObject, normalizeMethod } from "../../data-platform/index.mjs";
3
3
  import { encodeBatchText } from "../../data-platform/batch/protocol.mjs";
4
+ import * as __rspack_external_effect_Data_2b3f4efb from "effect/Data";
4
5
  function normalizeBatchPath(pathname) {
5
6
  if (!pathname || '/' === pathname) return DEFAULT_DATA_BATCH_ENDPOINT;
6
7
  if (!pathname.startsWith('/')) return `/${pathname}`;
7
8
  return pathname;
8
9
  }
9
- function normalizeBatchAllowedMethods(allowedMethods) {
10
- const source = Array.isArray(allowedMethods) && allowedMethods.length > 0 ? allowedMethods : [
11
- 'GET'
12
- ];
13
- return new Set(source.map((method)=>method.toUpperCase()));
14
- }
15
10
  function isBatchRequestPayload(value) {
16
11
  return isPlainObject(value) && 2 === value.protocolVersion && 'string' == typeof value.batchId && 'number' == typeof value.sentAt && Array.isArray(value.items);
17
12
  }
@@ -65,7 +60,13 @@ function toBatchItemError(id, status, message) {
65
60
  }))
66
61
  };
67
62
  }
68
- class BatchItemTimeoutError extends Error {
63
+ class BatchItemTimeoutError extends __rspack_external_effect_Data_2b3f4efb.TaggedError('BatchItemTimeoutError') {
64
+ constructor(message){
65
+ super({
66
+ message
67
+ });
68
+ this.name = 'Error';
69
+ }
69
70
  }
70
71
  function promiseWithTimeout(effect, timeoutMs, onTimeout) {
71
72
  if (timeoutMs <= 0) return effect;
@@ -103,4 +104,4 @@ async function mapWithConcurrency(items, concurrency, mapper) {
103
104
  return output;
104
105
  }
105
106
  export { toHeaderRecord } from "../../headers.mjs";
106
- export { BatchItemTimeoutError, createBatchValidationResponse, isBatchRequestPayload, mapWithConcurrency, normalizeBatchAllowedMethods, normalizeBatchPath, prepareJsonRequestBody, promiseWithTimeout, toBatchItemError };
107
+ export { BatchItemTimeoutError, createBatchValidationResponse, isBatchRequestPayload, mapWithConcurrency, normalizeBatchPath, prepareJsonRequestBody, promiseWithTimeout, toBatchItemError };
@@ -21,30 +21,10 @@ function defineEffectBff(definition) {
21
21
  validateRequest: options?.validateRequest
22
22
  });
23
23
  });
24
- const client = createLoaderMaterializedClientPlaceholder();
25
24
  return {
26
25
  ...definition,
27
- createHandler,
28
- client
29
- };
30
- }
31
- const LOADER_CLIENT_IGNORED_KEYS = new Set([
32
- 'then',
33
- 'catch',
34
- 'finally',
35
- 'toJSON',
36
- '$$typeof'
37
- ]);
38
- function createLoaderMaterializedClientPlaceholder() {
39
- const explain = (property)=>{
40
- throw new Error(`[BFF][Effect] client.${String(property)} is not available here: the typed client only exists when the API entry is imported through the "@api/index" transformed path (the BFF loader replaces it with generated client code). On the server, use HttpApiClient or call the Effect layer directly.`);
26
+ createHandler
41
27
  };
42
- return new Proxy(Object.create(null), {
43
- get (_target, property) {
44
- if ('symbol' == typeof property || LOADER_CLIENT_IGNORED_KEYS.has(property)) return;
45
- return explain(property);
46
- }
47
- });
48
28
  }
49
29
  function defineEffectRpcBff(definition) {
50
30
  const createHandler = (options)=>createRpcApiHandler({
@@ -2,7 +2,7 @@ import "node:module";
2
2
  import * as __rspack_external__effect_opentelemetry_66324c75 from "@effect/opentelemetry";
3
3
  export * from "./endpoint-contracts.mjs";
4
4
  export * from "./handler.mjs";
5
- export { createEffectOperationContext, runWithEffectContext, useEffectContext, useOperationContext } from "./context.mjs";
5
+ export { createEffectOperationContext, runWithEffectContext, useEffectContext, useOperationContext } from "@modern-js/bff-effect/context";
6
6
  export { createEffectBffEdgeHandler, createEffectBffTestHandler, dispatchEffectBffRequest } from "./edge.mjs";
7
7
  export { resolveEffectBffModuleHandler } from "./module.mjs";
8
8
  export { __rspack_external__effect_opentelemetry_66324c75 as OpenTelemetry };
@@ -12,7 +12,7 @@ function shareDispose(dispose) {
12
12
  return disposePromise;
13
13
  };
14
14
  }
15
- function rejectLegacyEffectModuleShape(options, shape) {
15
+ function rejectUnsupportedEffectModuleShape(options, shape) {
16
16
  options.onWarning?.(`${strictEffectApproachMessage} Rejected ${shape}.`);
17
17
  return true;
18
18
  }
@@ -40,8 +40,12 @@ function classifyEffectBffRuntimeEntryShape(module) {
40
40
  }
41
41
  function resolveClassifiedEffectBffModuleHandler(facts, options = {}) {
42
42
  if (!facts) return null;
43
- if (facts.legacyShape) {
44
- if (rejectLegacyEffectModuleShape(options, facts.legacyShape)) return null;
43
+ if (facts.unsupportedShape) {
44
+ if (rejectUnsupportedEffectModuleShape(options, facts.unsupportedShape)) return null;
45
+ }
46
+ if (void 0 !== facts.module.rpc && !facts.createHandlerValidatorAware) {
47
+ rejectUnsupportedEffectModuleShape(options, 'unbranded RPC runtime');
48
+ return null;
45
49
  }
46
50
  if ('function' == typeof facts.createHandler) {
47
51
  if (facts.createHandlerValidatorAware) {
@@ -54,7 +58,7 @@ function resolveClassifiedEffectBffModuleHandler(facts, options = {}) {
54
58
  return createLoadedHandler(webHandler);
55
59
  }
56
60
  if (void 0 === facts.api || !facts.hasRuntimeLayer) {
57
- rejectLegacyEffectModuleShape(options, 'unbranded `createHandler` export');
61
+ rejectUnsupportedEffectModuleShape(options, 'unbranded `createHandler` export');
58
62
  return null;
59
63
  }
60
64
  options.onWarning?.(`${strictEffectApproachMessage} Ignored unbranded \`createHandler\` export and rebuilt the handler from its { api, layer } exports.`);
@@ -1,6 +1,5 @@
1
1
  import "node:module";
2
- import { BFF_LOCALE_HEADER, BFF_OPERATION_CONTEXT_DETAIL_HEADER, BFF_OPERATION_CONTEXT_HEADER, BFF_TRACEPARENT_HEADER, parseTraceparent } from "@modern-js/create-request";
3
- const kEffectContextStorage = Symbol.for('modernjs.plugin-bff.effectContextStorage');
2
+ import { BFF_LOCALE_HEADER, BFF_OPERATION_CONTEXT_DETAIL_HEADER, BFF_OPERATION_CONTEXT_HEADER, BFF_TRACEPARENT_HEADER, parseTraceparent } from "@modern-js/runtime-extensions/request-context";
4
3
  const readHeader = (headers, header)=>{
5
4
  const value = headers.get(header);
6
5
  return value && value.length > 0 ? value : void 0;
@@ -55,7 +54,7 @@ const createEffectOperationContext = ({ request, path, method })=>{
55
54
  } : {},
56
55
  routePath: servicePath,
57
56
  method: (method || request.method || 'GET').toUpperCase(),
58
- source: 'effect-adapter',
57
+ source: 'effect-server',
59
58
  ...path && path !== servicePath ? {
60
59
  attributes: {
61
60
  mountedPath: path
@@ -73,4 +72,4 @@ const createEffectOperationContext = ({ request, path, method })=>{
73
72
  } : {}
74
73
  };
75
74
  };
76
- export { createEffectOperationContext, kEffectContextStorage };
75
+ export { createEffectOperationContext };
@@ -8,8 +8,6 @@ function getRpcSerializationLayer(serialization) {
8
8
  return RpcSerialization.layerJsonRpc();
9
9
  case 'ndJsonRpc':
10
10
  return RpcSerialization.layerNdJsonRpc();
11
- case 'msgPack':
12
- return RpcSerialization.layerMsgPack;
13
11
  default:
14
12
  return RpcSerialization.layerJsonRpc();
15
13
  }
@@ -0,0 +1,52 @@
1
+ import "node:module";
2
+ import { BFF_ENVELOPE_HEADER, BFF_OPERATION_CONTEXT_DETAIL_HEADER, BFF_OPERATION_CONTEXT_HEADER, digestOperationContract, resolveCrossProjectRequestObservation } from "@modern-js/server-runtime-extensions/bff-policy";
3
+ import { HttpClient, HttpClientRequest } from "effect/unstable/http";
4
+ import { HttpApi } from "effect/unstable/httpapi";
5
+ import * as __rspack_external_effect_Effect_41060786 from "effect/Effect";
6
+ import * as __rspack_external_effect_Schema_6065f72d from "effect/Schema";
7
+ const encodeJson = __rspack_external_effect_Schema_6065f72d.encodeSync(__rspack_external_effect_Schema_6065f72d.fromJsonString(__rspack_external_effect_Schema_6065f72d.Unknown));
8
+ function withCrossProjectPolicy(api, options, client) {
9
+ const contracts = {};
10
+ const prefix = options.prefix.replace(/\/$/, '');
11
+ HttpApi.reflect(api, {
12
+ onGroup: ()=>{},
13
+ onEndpoint: ({ endpoint })=>{
14
+ const routePath = `${prefix}${'/' === endpoint.path ? '' : endpoint.path}` || '/';
15
+ const name = endpoint.identifier;
16
+ contracts[`${endpoint.method}:${routePath}`] = {
17
+ operationId: `${options.requestId}:${name}`,
18
+ name,
19
+ method: endpoint.method,
20
+ routePath
21
+ };
22
+ }
23
+ });
24
+ return client.pipe(HttpClient.mapRequestEffect((request)=>{
25
+ const observed = resolveCrossProjectRequestObservation({
26
+ method: request.method,
27
+ pathname: new URL(request.url, 'http://effect.invalid').pathname
28
+ }, {
29
+ expectedOperationContracts: contracts
30
+ });
31
+ const contract = observed && contracts[`${observed.method}:${observed.routePath}`];
32
+ if (void 0 === contract) return __rspack_external_effect_Effect_41060786.die(new Error('[BFF][Effect] Request has no matching shared operation contract.'));
33
+ return __rspack_external_effect_Effect_41060786.gen(function*() {
34
+ const schemaHash = yield* __rspack_external_effect_Effect_41060786.promise(()=>digestOperationContract({
35
+ httpMethod: contract.method,
36
+ name: contract.name,
37
+ routePath: contract.routePath
38
+ }, options.requestId));
39
+ return request.pipe(HttpClientRequest.setHeader(BFF_ENVELOPE_HEADER, encodeJson({
40
+ requestId: options.requestId
41
+ })), HttpClientRequest.setHeader(BFF_OPERATION_CONTEXT_HEADER, contract.operationId), HttpClientRequest.setHeader(BFF_OPERATION_CONTEXT_DETAIL_HEADER, encodeJson({
42
+ requestId: options.requestId,
43
+ operationId: contract.operationId,
44
+ method: contract.method,
45
+ routePath: contract.routePath,
46
+ schemaHash,
47
+ operationVersion: options.operationVersion
48
+ })));
49
+ });
50
+ }));
51
+ }
52
+ export { withCrossProjectPolicy };
@@ -1,11 +1,12 @@
1
1
  import "node:module";
2
- import { createRequestContextHeaders } from "@modern-js/create-request";
2
+ import { createRequestContextHeaders } from "@modern-js/runtime-extensions/request-context";
3
3
  import * as __rspack_external_effect_Effect_41060786 from "effect/Effect";
4
4
  import * as __rspack_external_effect_Layer_69c46453 from "effect/Layer";
5
5
  import { FetchHttpClient, HttpClient, HttpClientRequest } from "effect/unstable/http";
6
6
  import { HttpApi, HttpApiClient, HttpApiEndpoint, HttpApiGroup, HttpApiSchema } from "effect/unstable/httpapi";
7
7
  import { Rpc, RpcClient, RpcGroup, RpcSchema, RpcSerialization } from "effect/unstable/rpc";
8
8
  import { getRpcSerializationLayer } from "../effect/rpcSerialization.mjs";
9
+ import { withCrossProjectPolicy } from "./cross-project.mjs";
9
10
  import * as __rspack_external_effect_Schema_6065f72d from "effect/Schema";
10
11
  import * as __rspack_external_effect_unstable_http_HttpClientError_4b9eaee6 from "effect/unstable/http/HttpClientError";
11
12
  import * as __rspack_external_effect_Data_2b3f4efb from "effect/Data";
@@ -47,7 +48,8 @@ function makeEffectHttpApiClient(api, options) {
47
48
  for (const [header, value] of Object.entries(requestContextHeaders))if (void 0 === nextRequest.headers[header.toLowerCase()]) nextRequest = HttpClientRequest.setHeader(nextRequest, header, value);
48
49
  return nextRequest;
49
50
  }));
50
- return 'function' == typeof options?.transformClient ? options.transformClient(contextClient) : contextClient;
51
+ const policyClient = options?.crossProject !== void 0 ? withCrossProjectPolicy(api, options.crossProject, contextClient) : contextClient;
52
+ return 'function' == typeof options?.transformClient ? options.transformClient(policyClient) : policyClient;
51
53
  };
52
54
  return HttpApiClient.make(api, {
53
55
  baseUrl: options?.baseUrl,
@@ -0,0 +1,68 @@
1
+ import "node:module";
2
+ import { Schema } from "effect";
3
+ const MicroVerticalAppIdSchema = Schema.String.pipe(Schema.brand('MicroVerticalAppId'), Schema.decodeTo(Schema.String));
4
+ const MicroVerticalUnitIdSchema = Schema.String.pipe(Schema.brand('MicroVerticalUnitId'), Schema.decodeTo(Schema.String));
5
+ const MicroVerticalOperationIdSchema = Schema.String.pipe(Schema.brand('MicroVerticalOperationId'), Schema.decodeTo(Schema.String));
6
+ const MicroVerticalTraceIdSchema = Schema.String.pipe(Schema.brand('MicroVerticalTraceId'), Schema.decodeTo(Schema.String));
7
+ const MicroVerticalBuildMarkerSchema = Schema.Struct({
8
+ appId: MicroVerticalAppIdSchema,
9
+ build: Schema.String,
10
+ buildMarker: Schema.String,
11
+ deployProfile: Schema.String,
12
+ packageName: Schema.String,
13
+ sourceRevision: Schema.String,
14
+ surface: Schema.String,
15
+ unitId: MicroVerticalUnitIdSchema,
16
+ version: Schema.String
17
+ });
18
+ const MicroVerticalReadinessSchema = Schema.Struct({
19
+ checks: Schema.Struct({
20
+ api: Schema.Literal('ready'),
21
+ moduleFederation: Schema.Literal('ready'),
22
+ ssr: Schema.Literal('ready'),
23
+ translations: Schema.Literal('ready')
24
+ }),
25
+ marker: MicroVerticalBuildMarkerSchema,
26
+ status: Schema.Literal('ready'),
27
+ versionSkew: Schema.Literal('none')
28
+ });
29
+ const MicroVerticalOperationSourceSchema = Schema.Literals([
30
+ 'client',
31
+ 'server',
32
+ 'generated-client',
33
+ 'effect-server',
34
+ 'data-platform',
35
+ 'unknown'
36
+ ]);
37
+ const MicroVerticalOperationContextSchema = Schema.Struct({
38
+ method: Schema.String,
39
+ operationId: MicroVerticalOperationIdSchema,
40
+ routePath: Schema.String,
41
+ source: MicroVerticalOperationSourceSchema,
42
+ traceId: Schema.optionalKey(MicroVerticalTraceIdSchema)
43
+ });
44
+ const createMicroVerticalOperationContext = (input)=>{
45
+ const context = {
46
+ method: input.method,
47
+ operationId: input.operationId,
48
+ routePath: input.routePath,
49
+ source: 'generated-client'
50
+ };
51
+ return void 0 === input.traceId ? context : {
52
+ ...context,
53
+ traceId: input.traceId
54
+ };
55
+ };
56
+ const microVerticalOperationAttributes = (operationContext)=>{
57
+ const attributes = {
58
+ 'modernjs.operation.id': operationContext.operationId,
59
+ 'modernjs.operation.method': operationContext.method,
60
+ 'modernjs.operation.route': operationContext.routePath,
61
+ 'modernjs.operation.source': operationContext.source
62
+ };
63
+ return void 0 === operationContext.traceId ? attributes : {
64
+ ...attributes,
65
+ 'modernjs.trace.id': operationContext.traceId
66
+ };
67
+ };
68
+ export { MicroVerticalBuildMarkerSchema, MicroVerticalOperationContextSchema, MicroVerticalOperationSourceSchema, MicroVerticalReadinessSchema, createMicroVerticalOperationContext, microVerticalOperationAttributes };
@@ -0,0 +1,10 @@
1
+ /** Server-only assembly for the invariant tail of a strict Effect BFF runtime factory. */
2
+ import * as Layer from 'effect/Layer';
3
+ import type { HttpApi, HttpApiGroup } from 'effect/unstable/httpapi';
4
+ import type { EffectRuntimeRequirements } from './effect/handler/types.js';
5
+ export interface EffectBffRuntimeAssembly<ApiId extends string, Groups extends HttpApiGroup.Constraint, HandlerRequirements extends EffectRuntimeRequirements, TransportRequirements extends EffectRuntimeRequirements = never> {
6
+ readonly api: HttpApi.HttpApi<ApiId, Groups>;
7
+ readonly handlers: Layer.Layer<HttpApiGroup.ToService<ApiId, Groups>, never, HandlerRequirements>;
8
+ readonly transport?: Layer.Layer<never, never, TransportRequirements>;
9
+ }
10
+ export declare const assembleEffectBffRuntime: <ApiId extends string, Groups extends HttpApiGroup.Constraint, HandlerRequirements extends EffectRuntimeRequirements, TransportRequirements extends EffectRuntimeRequirements = never>({ api, handlers, transport, }: EffectBffRuntimeAssembly<ApiId, Groups, HandlerRequirements, TransportRequirements>) => import("./effect/index.js").EffectBffDefinition<HttpApi.HttpApi<ApiId, Groups>, Layer.Layer<never, never, HandlerRequirements | TransportRequirements | Exclude<import("effect/FileSystem").FileSystem, HttpApiGroup.ToService<ApiId, Groups>> | Exclude<import("effect/unstable/http/Etag").Generator, HttpApiGroup.ToService<ApiId, Groups>> | Exclude<import("effect/unstable/http/HttpPlatform").HttpPlatform, HttpApiGroup.ToService<ApiId, Groups>> | Exclude<import("effect/unstable/http/HttpRouter").HttpRouter, HttpApiGroup.ToService<ApiId, Groups>> | Exclude<import("effect/Path").Path, HttpApiGroup.ToService<ApiId, Groups>> | Exclude<HttpApiGroup.ToService<ApiId, Groups>, HttpApiGroup.ToService<ApiId, Groups>>>, import("effect/unstable/rpc/Rpc").Any> & import("./effect/index.js").EffectBffRuntime<HttpApi.HttpApi<ApiId, Groups>, Layer.Layer<never, never, HandlerRequirements | TransportRequirements | Exclude<import("effect/FileSystem").FileSystem, HttpApiGroup.ToService<ApiId, Groups>> | Exclude<import("effect/unstable/http/Etag").Generator, HttpApiGroup.ToService<ApiId, Groups>> | Exclude<import("effect/unstable/http/HttpPlatform").HttpPlatform, HttpApiGroup.ToService<ApiId, Groups>> | Exclude<import("effect/unstable/http/HttpRouter").HttpRouter, HttpApiGroup.ToService<ApiId, Groups>> | Exclude<import("effect/Path").Path, HttpApiGroup.ToService<ApiId, Groups>> | Exclude<HttpApiGroup.ToService<ApiId, Groups>, HttpApiGroup.ToService<ApiId, Groups>>>>;
@@ -0,0 +1,7 @@
1
+ import type { DataBatchTransportOptions } from '../types.js';
2
+ /** Wire limits and method eligibility are identical on both sides. */
3
+ export declare function normalizeBatchLimits(options?: Pick<DataBatchTransportOptions, 'maxBatchSize' | 'maxBatchBytes' | 'allowedMethods'>): {
4
+ maxBatchSize: number;
5
+ maxBatchBytes: number;
6
+ allowedMethods: Set<string>;
7
+ };
@@ -30,7 +30,6 @@ type QueuedBatchRequest = {
30
30
  };
31
31
  type BatchBucket = {
32
32
  items: QueuedBatchRequest[];
33
- bytes: number;
34
33
  batchId: string;
35
34
  sentAt: number;
36
35
  timer: ReturnType<typeof setTimeout> | null;
@@ -1,5 +1,18 @@
1
- import { type EffectContext } from './operation-context.js';
1
+ import type { EffectContext, EffectContextStorage } from './operation-context.js';
2
2
  export { type CreateEffectOperationContextOptions, createEffectOperationContext, type EffectContext, } from './operation-context.js';
3
+ /**
4
+ * Module Federation share through which a backend federation host hands its
5
+ * request storage to the containers it initializes.
6
+ */
7
+ export declare const EFFECT_BFF_CONTEXT_STORAGE_SHARE = "@modern-js/bff-effect/context-storage";
3
8
  export declare const runWithEffectContext: <T>(context: EffectContext, cb: () => T) => T;
4
9
  export declare const useEffectContext: () => EffectContext;
5
- export declare const useOperationContext: () => import("@modern-js/create-request").OperationContext;
10
+ /** @internal The storage a backend federation host shares with containers. */
11
+ export declare const getEffectContextStorage: () => EffectContextStorage;
12
+ /**
13
+ * @internal Called through `adoptEffectBffShareScope()` from a backend
14
+ * federation container's `init()`, so its endpoints read the context the
15
+ * host dispatcher enters.
16
+ */
17
+ export declare function adoptEffectContextStorage(storage: unknown): void;
18
+ export declare const useOperationContext: () => import("@modern-js/runtime-extensions/request-context").OperationContext;
@@ -1,8 +1,9 @@
1
- import { type NormalizedCrossProjectPolicy } from '@modern-js/bff-core/security/cross-project-policy';
1
+ import { type NormalizedCrossProjectPolicy } from '@modern-js/server-runtime-extensions/bff-policy';
2
2
  import { type DispatchEffectBffRequestOptions } from './dispatch.js';
3
3
  import type { EffectBffOpenApiConfig, EffectDataPlatformValidationOptions } from './handler.js';
4
4
  import { type EffectApiModule, type EffectBffRequestHandler } from './module.js';
5
5
  import type { EffectContext } from './operation-context.js';
6
+ export { runWithEffectContext, useEffectContext, useOperationContext, } from './context.js';
6
7
  export * as Config from 'effect/Config';
7
8
  export * as Effect from 'effect/Effect';
8
9
  export * as Layer from 'effect/Layer';
@@ -11,8 +12,7 @@ export * as Schema from 'effect/Schema';
11
12
  export { Cookies, Etag, FetchHttpClient, FindMyWay, Headers, HttpBody, HttpClient, HttpClientError, HttpClientRequest, HttpClientResponse, HttpEffect, HttpIncomingMessage, HttpMethod, HttpMiddleware, HttpPlatform, HttpRouter, HttpServer, HttpServerError, HttpServerRequest, HttpServerRespondable, HttpServerResponse, HttpStaticServer, HttpStatus, HttpTraceContext, Multipart, MultipartParser, Template, Url, UrlParams, } from 'effect/unstable/http';
12
13
  export { HttpApi, HttpApiBuilder, HttpApiClient, HttpApiEndpoint, HttpApiError, HttpApiGroup, HttpApiMiddleware, HttpApiSchema, HttpApiSecurity, HttpApiTest, OpenApi, } from 'effect/unstable/httpapi';
13
14
  export { Rpc, RpcClient, RpcClientError, RpcGroup, RpcMessage, RpcMiddleware, RpcSchema, RpcSerialization, RpcServer, RpcTest, RpcWorker, Utils, } from 'effect/unstable/rpc';
14
- export { runWithEffectContext, useEffectContext, useOperationContext, } from './edge-context.js';
15
- export type { EffectApiClientFromApi, EffectApiPromiseClientFromApi, EffectBffDefinition, EffectBffHandlerFactory, EffectBffOpenApiConfig, EffectBffRuntime, EffectDataPlatformBatchOptions, EffectDataPlatformSelectionValidationOptions, EffectDataPlatformValidationOptions, EffectRequestValidator, EffectRpcBffDefinition, EffectRpcBffHandlerFactory, EffectRpcBffHandlerOptions, EffectRpcRuntimeLayer, EffectRpcSerialization, EffectRuntimeLayer, EffectRuntimeRequirements, } from './handler.js';
15
+ export type { EffectApiClientFromApi, EffectBffDefinition, EffectBffHandlerFactory, EffectBffOpenApiConfig, EffectBffRuntime, EffectDataPlatformBatchOptions, EffectDataPlatformSelectionValidationOptions, EffectDataPlatformValidationOptions, EffectRequestValidator, EffectRpcBffDefinition, EffectRpcBffHandlerFactory, EffectRpcBffHandlerOptions, EffectRpcRuntimeLayer, EffectRpcSerialization, EffectRuntimeLayer, EffectRuntimeRequirements, } from './handler.js';
16
16
  export { createHttpApiHandler, defineEffectBff, defineEffectRpcBff, } from './handler.js';
17
17
  export { type CreateEffectOperationContextOptions, createEffectOperationContext, type EffectContext, } from './operation-context.js';
18
18
  export type EffectBffEdgeDispatchOptions = Omit<DispatchEffectBffRequestOptions, 'runWithEffectContext'>;
@@ -1 +1,4 @@
1
+ export { EFFECT_BFF_CONTEXT_STORAGE_SHARE } from './context.js';
1
2
  export * from './edge-dispatcher.js';
3
+ export { adoptEffectBffShareScope, EFFECT_BFF_HANDLER_FACTORY_REGISTRY_SHARE, } from './entry-shape.js';
4
+ export { createEffectBffEdgeDispatcherFactory } from './generated-entry.js';
@@ -1,17 +1,5 @@
1
- /**
2
- * Shared Effect HttpApi endpoint reflection used by BOTH sides of the
3
- * cross-project contract:
4
- *
5
- * - the `@modern-js/plugin-bff-extensions/client-generator` package stamps
6
- * each generated operation with a per-endpoint contract hash;
7
- * - the `@modern-js/plugin-bff-extensions/effect-adapter` package derives the
8
- * expected operation-contract map for the cross-project policy from the
9
- * same endpoints.
10
- *
11
- * Keeping route-path normalization and the endpoint -> contract mapping in
12
- * one module is what guarantees the two hashes agree.
13
- */
14
- import { type OperationContractSource } from '@modern-js/bff-core';
1
+ /** Shared endpoint normalization and identity hashing for server policy metadata. */
2
+ import { type OperationContractSource } from '@modern-js/server-runtime-extensions/bff-policy/node';
15
3
  export type EffectEndpointMeta = {
16
4
  apiId: string;
17
5
  groupName: string;
@@ -26,13 +14,7 @@ type HttpApiGroupLike = {
26
14
  identifier?: unknown;
27
15
  };
28
16
  type HttpApiEndpointLike = {
29
- /**
30
- * effect 4.0.0-beta.98 renamed the endpoint `name` property to `identifier`,
31
- * matching `HttpApiGroup`. `name` is kept as a fallback so reflection over an
32
- * older Effect build does not silently degrade to the class name.
33
- */
34
17
  identifier?: unknown;
35
- name?: unknown;
36
18
  method?: unknown;
37
19
  path?: unknown;
38
20
  };
@@ -1,14 +1,28 @@
1
+ import type { EffectRpcBffDefinition } from './handler/types.js';
2
+ /**
3
+ * Module Federation share through which a backend federation host hands its
4
+ * package-private handler factory registry to the containers it initializes.
5
+ */
6
+ export declare const EFFECT_BFF_HANDLER_FACTORY_REGISTRY_SHARE = "@modern-js/bff-effect/handler-factory-registry";
7
+ /**
8
+ * @internal Called by generated backend federation containers from `init()`,
9
+ * before any expose evaluates, so factories created by `defineEffectBff`
10
+ * register with the host's registry and endpoints read the host's request
11
+ * storage instead of bundle-local ones.
12
+ */
13
+ export declare function adoptEffectBffShareScope(shareScope: unknown): Promise<void>;
1
14
  type EffectBffEntryModule = {
2
15
  api?: unknown;
3
16
  layer?: unknown;
17
+ rpc?: EffectRpcBffDefinition;
4
18
  handler?: unknown;
5
19
  createHandler?: unknown;
6
20
  default?: unknown;
7
21
  };
8
- type LegacyEffectBffEntryShape = '`handler` export' | 'default request handler';
22
+ type UnsupportedEffectBffEntryShape = '`handler` export' | 'default request handler';
9
23
  export type EffectBffEntryShapeFacts = {
10
24
  module: EffectBffEntryModule;
11
- legacyShape?: LegacyEffectBffEntryShape;
25
+ unsupportedShape?: UnsupportedEffectBffEntryShape;
12
26
  createHandler?: unknown;
13
27
  createHandlerValidatorAware: boolean;
14
28
  api?: unknown;
@@ -0,0 +1,7 @@
1
+ import { type EffectBffEdgeHandlerOptions } from './edge-dispatcher.js';
2
+ type OperationContracts = NonNullable<EffectBffEdgeHandlerOptions['crossProjectPolicy']>['expectedOperationContracts'];
3
+ export declare function createEffectBffEdgeDispatcherFactory(module: EffectBffEdgeHandlerOptions['module'], generatedOperationContracts: OperationContracts): (options?: Omit<EffectBffEdgeHandlerOptions, 'module'>) => Promise<{
4
+ dispatch: (request: Request, dispatchOptions?: Omit<import("./edge-dispatcher.js").EffectBffEdgeDispatchOptions, 'prefix' | 'onError'>) => Promise<Response>;
5
+ dispose: () => Promise<void>;
6
+ }>;
7
+ export {};