@bleedingdev/modern-js-bff-effect 3.9.0-ultramodern.3 → 3.9.0-ultramodern.5

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 (60) hide show
  1. package/dist/cjs/assembly.js +50 -0
  2. package/dist/cjs/data-platform/trace.js +2 -2
  3. package/dist/cjs/effect/edge-dispatcher.js +7 -7
  4. package/dist/cjs/effect/edge.js +15 -2
  5. package/dist/cjs/effect/endpoint-contracts.js +2 -2
  6. package/dist/cjs/effect/generated-entry.js +57 -0
  7. package/dist/cjs/effect/handler/batch-handler.js +5 -4
  8. package/dist/cjs/effect/handler/batch.js +8 -1
  9. package/dist/cjs/effect/operation-context.js +7 -7
  10. package/dist/cjs/effect-client/index.js +2 -2
  11. package/dist/cjs/microvertical-api.js +120 -0
  12. package/dist/esm/assembly.mjs +12 -0
  13. package/dist/esm/data-platform/trace.mjs +1 -1
  14. package/dist/esm/effect/edge-dispatcher.mjs +5 -5
  15. package/dist/esm/effect/edge.mjs +1 -0
  16. package/dist/esm/effect/endpoint-contracts.mjs +1 -1
  17. package/dist/esm/effect/generated-entry.mjs +19 -0
  18. package/dist/esm/effect/handler/batch-handler.mjs +5 -4
  19. package/dist/esm/effect/handler/batch.mjs +8 -1
  20. package/dist/esm/effect/operation-context.mjs +1 -1
  21. package/dist/esm/effect-client/index.mjs +1 -1
  22. package/dist/esm/microvertical-api.mjs +67 -0
  23. package/dist/esm-node/assembly.mjs +13 -0
  24. package/dist/esm-node/data-platform/trace.mjs +1 -1
  25. package/dist/esm-node/effect/edge-dispatcher.mjs +5 -5
  26. package/dist/esm-node/effect/edge.mjs +1 -0
  27. package/dist/esm-node/effect/endpoint-contracts.mjs +1 -1
  28. package/dist/esm-node/effect/generated-entry.mjs +20 -0
  29. package/dist/esm-node/effect/handler/batch-handler.mjs +5 -4
  30. package/dist/esm-node/effect/handler/batch.mjs +8 -1
  31. package/dist/esm-node/effect/operation-context.mjs +1 -1
  32. package/dist/esm-node/effect-client/index.mjs +1 -1
  33. package/dist/esm-node/microvertical-api.mjs +68 -0
  34. package/dist/types/assembly.d.ts +10 -0
  35. package/dist/types/effect/context.d.ts +1 -1
  36. package/dist/types/effect/edge-context.d.ts +1 -1
  37. package/dist/types/effect/edge-dispatcher.d.ts +1 -1
  38. package/dist/types/effect/edge.d.ts +1 -0
  39. package/dist/types/effect/endpoint-contracts.d.ts +1 -1
  40. package/dist/types/effect/generated-entry.d.ts +7 -0
  41. package/dist/types/effect/handler/batch.d.ts +7 -1
  42. package/dist/types/effect/operation-context.d.ts +1 -1
  43. package/dist/types/effect-client/index.d.ts +1 -1
  44. package/dist/types/effect-client/types.d.ts +1 -1
  45. package/dist/types/microvertical-api.d.ts +65 -0
  46. package/package.json +30 -4
  47. package/src/assembly.ts +43 -0
  48. package/src/data-platform/batch/queue.ts +2 -3
  49. package/src/data-platform/trace.ts +1 -1
  50. package/src/effect/edge-dispatcher.ts +7 -4
  51. package/src/effect/edge.ts +1 -0
  52. package/src/effect/endpoint-contracts.ts +1 -1
  53. package/src/effect/entry-shape.ts +4 -1
  54. package/src/effect/generated-entry.ts +36 -0
  55. package/src/effect/handler/batch-handler.ts +21 -16
  56. package/src/effect/handler/batch.ts +9 -1
  57. package/src/effect/operation-context.ts +1 -1
  58. package/src/effect-client/index.ts +1 -1
  59. package/src/effect-client/types.ts +1 -1
  60. package/src/microvertical-api.ts +102 -0
@@ -0,0 +1,67 @@
1
+ import { Schema } from "effect";
2
+ const MicroVerticalAppIdSchema = Schema.String.pipe(Schema.brand('MicroVerticalAppId'), Schema.decodeTo(Schema.String));
3
+ const MicroVerticalUnitIdSchema = Schema.String.pipe(Schema.brand('MicroVerticalUnitId'), Schema.decodeTo(Schema.String));
4
+ const MicroVerticalOperationIdSchema = Schema.String.pipe(Schema.brand('MicroVerticalOperationId'), Schema.decodeTo(Schema.String));
5
+ const MicroVerticalTraceIdSchema = Schema.String.pipe(Schema.brand('MicroVerticalTraceId'), Schema.decodeTo(Schema.String));
6
+ const MicroVerticalBuildMarkerSchema = Schema.Struct({
7
+ appId: MicroVerticalAppIdSchema,
8
+ build: Schema.String,
9
+ buildMarker: Schema.String,
10
+ deployProfile: Schema.String,
11
+ packageName: Schema.String,
12
+ sourceRevision: Schema.String,
13
+ surface: Schema.String,
14
+ unitId: MicroVerticalUnitIdSchema,
15
+ version: Schema.String
16
+ });
17
+ const MicroVerticalReadinessSchema = Schema.Struct({
18
+ checks: Schema.Struct({
19
+ api: Schema.Literal('ready'),
20
+ moduleFederation: Schema.Literal('ready'),
21
+ ssr: Schema.Literal('ready'),
22
+ translations: Schema.Literal('ready')
23
+ }),
24
+ marker: MicroVerticalBuildMarkerSchema,
25
+ status: Schema.Literal('ready'),
26
+ versionSkew: Schema.Literal('none')
27
+ });
28
+ const MicroVerticalOperationSourceSchema = Schema.Literals([
29
+ 'client',
30
+ 'server',
31
+ 'generated-client',
32
+ 'effect-adapter',
33
+ 'data-platform',
34
+ 'unknown'
35
+ ]);
36
+ const MicroVerticalOperationContextSchema = Schema.Struct({
37
+ method: Schema.String,
38
+ operationId: MicroVerticalOperationIdSchema,
39
+ routePath: Schema.String,
40
+ source: MicroVerticalOperationSourceSchema,
41
+ traceId: Schema.optionalKey(MicroVerticalTraceIdSchema)
42
+ });
43
+ const createMicroVerticalOperationContext = (input)=>{
44
+ const context = {
45
+ method: input.method,
46
+ operationId: input.operationId,
47
+ routePath: input.routePath,
48
+ source: 'generated-client'
49
+ };
50
+ return void 0 === input.traceId ? context : {
51
+ ...context,
52
+ traceId: input.traceId
53
+ };
54
+ };
55
+ const microVerticalOperationAttributes = (operationContext)=>{
56
+ const attributes = {
57
+ 'modernjs.operation.id': operationContext.operationId,
58
+ 'modernjs.operation.method': operationContext.method,
59
+ 'modernjs.operation.route': operationContext.routePath,
60
+ 'modernjs.operation.source': operationContext.source
61
+ };
62
+ return void 0 === operationContext.traceId ? attributes : {
63
+ ...attributes,
64
+ 'modernjs.trace.id': operationContext.traceId
65
+ };
66
+ };
67
+ export { MicroVerticalBuildMarkerSchema, MicroVerticalOperationContextSchema, MicroVerticalOperationSourceSchema, MicroVerticalReadinessSchema, createMicroVerticalOperationContext, microVerticalOperationAttributes };
@@ -0,0 +1,13 @@
1
+ import "node:module";
2
+ import { HttpApiBuilder } from "effect/unstable/httpapi";
3
+ import { defineEffectBff } from "./effect/handler/definition.mjs";
4
+ import * as __rspack_external_effect_Layer_69c46453 from "effect/Layer";
5
+ const assembleEffectBffRuntime = ({ api, handlers, transport })=>{
6
+ const apiLayer = HttpApiBuilder.layer(api).pipe(__rspack_external_effect_Layer_69c46453.provide(handlers));
7
+ const layer = void 0 === transport ? apiLayer : apiLayer.pipe(__rspack_external_effect_Layer_69c46453.merge(transport));
8
+ return defineEffectBff({
9
+ api,
10
+ layer
11
+ });
12
+ };
13
+ export { assembleEffectBffRuntime };
@@ -1,5 +1,5 @@
1
1
  import "node:module";
2
- import { parseTraceparent } from "@modern-js/create-request";
2
+ import { parseTraceparent } from "@modern-js/runtime-extensions/request-context";
3
3
  function isAllZeroHex(value) {
4
4
  return /^0+$/.test(value);
5
5
  }
@@ -1,11 +1,11 @@
1
1
  import "node:module";
2
- import { evaluateCrossProjectPolicy, resolveCrossProjectRequestObservation } from "@modern-js/bff-core/security/cross-project-policy";
2
+ import { evaluateCrossProjectPolicy, resolveCrossProjectRequestObservation } from "@modern-js/server-runtime-extensions/bff-policy";
3
+ import * as __rspack_external_effect_Effect_41060786 from "effect/Effect";
3
4
  import { toHeaderRecord } from "../headers.mjs";
4
5
  import { dispatchEffectBffRequestWithContext } from "./dispatch.mjs";
5
6
  import { runWithEffectContext, useEffectContext, useOperationContext } from "./edge-context.mjs";
6
7
  import { resolveEffectBffModuleHandler } from "./module.mjs";
7
8
  import * as __rspack_external_effect_Config_76cfa59d from "effect/Config";
8
- import * as __rspack_external_effect_Effect_41060786 from "effect/Effect";
9
9
  import * as __rspack_external_effect_Layer_69c46453 from "effect/Layer";
10
10
  import * as __rspack_external_effect_Option_0498e63a from "effect/Option";
11
11
  import * as __rspack_external_effect_Schema_6065f72d from "effect/Schema";
@@ -91,9 +91,9 @@ async function createEffectBffEdgeDispatcher(options) {
91
91
  dispose: ()=>{
92
92
  disposePromise ??= (async ()=>{
93
93
  acceptingRequests = false;
94
- if (activeDispatches > 0) await new Promise((resolve)=>{
95
- resolveDrain = resolve;
96
- });
94
+ if (activeDispatches > 0) await __rspack_external_effect_Effect_41060786.runPromise(__rspack_external_effect_Effect_41060786.callback((resume)=>{
95
+ resolveDrain = ()=>resume(__rspack_external_effect_Effect_41060786["void"]);
96
+ }));
97
97
  await loaded.dispose?.();
98
98
  })();
99
99
  return disposePromise;
@@ -1,2 +1,3 @@
1
1
  import "node:module";
2
2
  export * from "./edge-dispatcher.mjs";
3
+ export { createEffectBffEdgeDispatcherFactory } from "./generated-entry.mjs";
@@ -1,5 +1,5 @@
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;
@@ -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 };
@@ -3,6 +3,7 @@ import { DEFAULT_DATA_BATCH_HEADER, DEFAULT_DATA_ENVELOPE_HEADER, decodeRequestE
3
3
  import { decodeBatchBody, isBatchBody, toBatchResponseItem } from "../../data-platform/batch/protocol.mjs";
4
4
  import { BatchItemTimeoutError, createBatchValidationResponse, isBatchRequestPayload, mapWithConcurrency, normalizeBatchAllowedMethods, normalizeBatchPath, promiseWithTimeout, toBatchItemError } from "./batch.mjs";
5
5
  import { getMountedPrefixFromContext, removeMountedPrefixFromBatchPath } from "./routing.mjs";
6
+ import * as __rspack_external_effect_Effect_41060786 from "effect/Effect";
6
7
  const HOP_BY_HOP_BATCH_ITEM_HEADERS = new Set([
7
8
  'connection',
8
9
  'keep-alive',
@@ -185,25 +186,25 @@ function createDataPlatformBatchRequestHandler(options) {
185
186
  return toBatchResponseItem(itemId, itemResponse, 'HEAD' === itemMethod);
186
187
  } catch (error) {
187
188
  if (error instanceof BatchItemTimeoutError) {
188
- console.error({
189
+ __rspack_external_effect_Effect_41060786.runSync(__rspack_external_effect_Effect_41060786.logError({
189
190
  event: 'bff.batch.item.timeout',
190
191
  batchId: payload.batchId,
191
192
  itemId,
192
193
  method: itemMethod,
193
194
  path: itemPathname,
194
195
  errorName: error.name
195
- });
196
+ }));
196
197
  return toBatchItemError(itemId, 504, 'Batch item request timed out');
197
198
  }
198
199
  if (error instanceof Response) return toBatchResponseItem(itemId, error, 'HEAD' === itemMethod);
199
- console.error({
200
+ __rspack_external_effect_Effect_41060786.runSync(__rspack_external_effect_Effect_41060786.logError({
200
201
  event: 'bff.batch.item.failure',
201
202
  batchId: payload.batchId,
202
203
  itemId,
203
204
  method: itemMethod,
204
205
  path: itemPathname,
205
206
  errorName: error instanceof Error ? error.name : 'UnknownError'
206
- });
207
+ }));
207
208
  return toBatchItemError(itemId, 500, 'Internal Server Error');
208
209
  } finally{
209
210
  request.signal.removeEventListener('abort', abortFromBatchRequest);
@@ -1,6 +1,7 @@
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}`;
@@ -65,7 +66,13 @@ function toBatchItemError(id, status, message) {
65
66
  }))
66
67
  };
67
68
  }
68
- class BatchItemTimeoutError extends Error {
69
+ class BatchItemTimeoutError extends __rspack_external_effect_Data_2b3f4efb.TaggedError('BatchItemTimeoutError') {
70
+ constructor(message){
71
+ super({
72
+ message
73
+ });
74
+ this.name = 'Error';
75
+ }
69
76
  }
70
77
  function promiseWithTimeout(effect, timeoutMs, onTimeout) {
71
78
  if (timeoutMs <= 0) return effect;
@@ -1,5 +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";
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";
3
3
  const kEffectContextStorage = Symbol.for('modernjs.plugin-bff.effectContextStorage');
4
4
  const readHeader = (headers, header)=>{
5
5
  const value = headers.get(header);
@@ -1,5 +1,5 @@
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";
@@ -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-adapter',
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>>>>;
@@ -2,4 +2,4 @@ import { type EffectContext } from './operation-context.js';
2
2
  export { type CreateEffectOperationContextOptions, createEffectOperationContext, type EffectContext, } from './operation-context.js';
3
3
  export declare const runWithEffectContext: <T>(context: EffectContext, cb: () => T) => T;
4
4
  export declare const useEffectContext: () => EffectContext;
5
- export declare const useOperationContext: () => import("@modern-js/create-request").OperationContext;
5
+ export declare const useOperationContext: () => import("@modern-js/runtime-extensions/request-context").OperationContext;
@@ -2,4 +2,4 @@ import { type EffectContext } from './operation-context.js';
2
2
  export { type CreateEffectOperationContextOptions, createEffectOperationContext, type EffectContext, } from './operation-context.js';
3
3
  export declare const runWithEffectContext: <T>(context: EffectContext, cb: () => T) => T;
4
4
  export declare const useEffectContext: () => EffectContext;
5
- export declare const useOperationContext: () => import("@modern-js/create-request").OperationContext;
5
+ export declare const useOperationContext: () => import("@modern-js/runtime-extensions/request-context").OperationContext;
@@ -1,4 +1,4 @@
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';
@@ -1 +1,2 @@
1
1
  export * from './edge-dispatcher.js';
2
+ export { createEffectBffEdgeDispatcherFactory } from './generated-entry.js';
@@ -11,7 +11,7 @@
11
11
  * Keeping route-path normalization and the endpoint -> contract mapping in
12
12
  * one module is what guarantees the two hashes agree.
13
13
  */
14
- import { type OperationContractSource } from '@modern-js/bff-core';
14
+ import { type OperationContractSource } from '@modern-js/server-runtime-extensions/bff-policy/node';
15
15
  export type EffectEndpointMeta = {
16
16
  apiId: string;
17
17
  groupName: string;
@@ -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 {};
@@ -9,7 +9,13 @@ export declare function isBatchRequestPayload(value: unknown): value is ParsedBa
9
9
  export declare function createBatchValidationResponse(message: string, status?: number): Response;
10
10
  export declare function prepareJsonRequestBody(request: Request): Promise<Request | Response>;
11
11
  export declare function toBatchItemError(id: string, status: number, message: string): DataBatchResponseItem;
12
- export declare class BatchItemTimeoutError extends Error {
12
+ declare const BatchItemTimeoutError_base: new <A extends Record<string, any> = {}>(args: import("effect/Types").VoidIfEmpty<{ readonly [P in keyof A as P extends "_tag" ? never : P]: A[P]; }>) => import("effect/Cause").YieldableError & {
13
+ readonly _tag: "BatchItemTimeoutError";
14
+ } & Readonly<A>;
15
+ export declare class BatchItemTimeoutError extends BatchItemTimeoutError_base<{
16
+ readonly message: string;
17
+ }> {
18
+ constructor(message: string);
13
19
  }
14
20
  export declare function promiseWithTimeout<T>(effect: Promise<T>, timeoutMs: number, onTimeout?: (error: BatchItemTimeoutError) => void): Promise<T>;
15
21
  export declare function mapWithConcurrency<TItem, TResult>(items: readonly TItem[], concurrency: number, mapper: (item: TItem, index: number) => Promise<TResult>): Promise<TResult[]>;
@@ -1,4 +1,4 @@
1
- import { type OperationContext } from '@modern-js/create-request';
1
+ import { type OperationContext } from '@modern-js/runtime-extensions/request-context';
2
2
  export type EffectContext = {
3
3
  request: Request;
4
4
  env: Record<string, unknown>;
@@ -1,4 +1,4 @@
1
- import { type RequestContextInput } from '@modern-js/create-request';
1
+ import { type RequestContextInput } from '@modern-js/runtime-extensions/request-context';
2
2
  import * as Effect from 'effect/Effect';
3
3
  import * as Layer from 'effect/Layer';
4
4
  import { HttpClient } from 'effect/unstable/http';
@@ -48,7 +48,7 @@ export type EffectRequestContextInput = Record<string, unknown>;
48
48
  export type EffectRequestContext = {
49
49
  headers: Record<string, string>;
50
50
  } & Record<string, unknown>;
51
- /** Structural slice of `@modern-js/create-request` the runtime relies on. */
51
+ /** Structural slice of `@modern-js/runtime-extensions/request-policy` the runtime relies on. */
52
52
  export type EffectRequestRuntime = {
53
53
  createRequest: (options: {
54
54
  path: string;
@@ -0,0 +1,65 @@
1
+ import { Schema } from 'effect';
2
+ export declare const MicroVerticalBuildMarkerSchema: Schema.Struct<{
3
+ readonly appId: Schema.compose<Schema.String, Schema.brand<Schema.String, "MicroVerticalAppId">>;
4
+ readonly build: Schema.String;
5
+ readonly buildMarker: Schema.String;
6
+ readonly deployProfile: Schema.String;
7
+ readonly packageName: Schema.String;
8
+ readonly sourceRevision: Schema.String;
9
+ readonly surface: Schema.String;
10
+ readonly unitId: Schema.compose<Schema.String, Schema.brand<Schema.String, "MicroVerticalUnitId">>;
11
+ readonly version: Schema.String;
12
+ }>;
13
+ export type MicroVerticalBuildMarker = typeof MicroVerticalBuildMarkerSchema.Type;
14
+ export declare const MicroVerticalReadinessSchema: Schema.Struct<{
15
+ readonly checks: Schema.Struct<{
16
+ readonly api: Schema.Literal<"ready">;
17
+ readonly moduleFederation: Schema.Literal<"ready">;
18
+ readonly ssr: Schema.Literal<"ready">;
19
+ readonly translations: Schema.Literal<"ready">;
20
+ }>;
21
+ readonly marker: Schema.Struct<{
22
+ readonly appId: Schema.compose<Schema.String, Schema.brand<Schema.String, "MicroVerticalAppId">>;
23
+ readonly build: Schema.String;
24
+ readonly buildMarker: Schema.String;
25
+ readonly deployProfile: Schema.String;
26
+ readonly packageName: Schema.String;
27
+ readonly sourceRevision: Schema.String;
28
+ readonly surface: Schema.String;
29
+ readonly unitId: Schema.compose<Schema.String, Schema.brand<Schema.String, "MicroVerticalUnitId">>;
30
+ readonly version: Schema.String;
31
+ }>;
32
+ readonly status: Schema.Literal<"ready">;
33
+ readonly versionSkew: Schema.Literal<"none">;
34
+ }>;
35
+ export type MicroVerticalReadiness = typeof MicroVerticalReadinessSchema.Type;
36
+ export declare const MicroVerticalOperationSourceSchema: Schema.Literals<readonly ["client", "server", "generated-client", "effect-adapter", "data-platform", "unknown"]>;
37
+ export type MicroVerticalOperationSource = typeof MicroVerticalOperationSourceSchema.Type;
38
+ export declare const MicroVerticalOperationContextSchema: Schema.Struct<{
39
+ readonly method: Schema.String;
40
+ readonly operationId: Schema.compose<Schema.String, Schema.brand<Schema.String, "MicroVerticalOperationId">>;
41
+ readonly routePath: Schema.String;
42
+ readonly source: Schema.Literals<readonly ["client", "server", "generated-client", "effect-adapter", "data-platform", "unknown"]>;
43
+ readonly traceId: Schema.optionalKey<Schema.compose<Schema.String, Schema.brand<Schema.String, "MicroVerticalTraceId">>>;
44
+ }>;
45
+ export type MicroVerticalOperationContext = typeof MicroVerticalOperationContextSchema.Type;
46
+ export declare const createMicroVerticalOperationContext: <const Method extends string, const OperationId extends string, const RoutePath extends string>(input: {
47
+ readonly method: Method;
48
+ readonly operationId: OperationId;
49
+ readonly routePath: RoutePath;
50
+ readonly traceId?: string;
51
+ }) => Readonly<typeof input & {
52
+ source: 'generated-client';
53
+ }>;
54
+ export declare const microVerticalOperationAttributes: (operationContext: MicroVerticalOperationContext) => {
55
+ 'modernjs.operation.id': string;
56
+ 'modernjs.operation.method': string;
57
+ 'modernjs.operation.route': string;
58
+ 'modernjs.operation.source': "client" | "data-platform" | "effect-adapter" | "generated-client" | "server" | "unknown";
59
+ } | {
60
+ 'modernjs.operation.id': string;
61
+ 'modernjs.operation.method': string;
62
+ 'modernjs.operation.route': string;
63
+ 'modernjs.operation.source': "client" | "data-platform" | "effect-adapter" | "generated-client" | "server" | "unknown";
64
+ 'modernjs.trace.id': string;
65
+ };
package/package.json CHANGED
@@ -18,7 +18,7 @@
18
18
  "modern.js",
19
19
  "ultramodern.js"
20
20
  ],
21
- "version": "3.9.0-ultramodern.3",
21
+ "version": "3.9.0-ultramodern.5",
22
22
  "files": [
23
23
  "dist",
24
24
  "src"
@@ -67,6 +67,15 @@
67
67
  "import": "./dist/esm/effect-client/index.mjs",
68
68
  "default": "./dist/esm/effect-client/index.mjs"
69
69
  },
70
+ "./microvertical-api": {
71
+ "types": "./dist/types/microvertical-api.d.ts",
72
+ "node": {
73
+ "import": "./dist/esm-node/microvertical-api.mjs",
74
+ "require": "./dist/cjs/microvertical-api.js"
75
+ },
76
+ "import": "./dist/esm/microvertical-api.mjs",
77
+ "default": "./dist/esm/microvertical-api.mjs"
78
+ },
70
79
  "./effect-client-runtime": {
71
80
  "types": "./dist/types/effect-client/runtime.d.ts",
72
81
  "node": {
@@ -84,6 +93,14 @@
84
93
  },
85
94
  "import": "./dist/esm/data-platform/index.mjs",
86
95
  "default": "./dist/esm/data-platform/index.mjs"
96
+ },
97
+ "./assembly": {
98
+ "types": "./dist/types/assembly.d.ts",
99
+ "node": {
100
+ "import": "./dist/esm-node/assembly.mjs",
101
+ "require": "./dist/cjs/assembly.js"
102
+ },
103
+ "default": "./dist/esm/assembly.mjs"
87
104
  }
88
105
  },
89
106
  "typesVersions": {
@@ -104,6 +121,10 @@
104
121
  "./dist/types/effect-client/index.d.ts",
105
122
  "./src/effect-client/index.ts"
106
123
  ],
124
+ "microvertical-api": [
125
+ "./dist/types/microvertical-api.d.ts",
126
+ "./src/microvertical-api.ts"
127
+ ],
107
128
  "effect-client-runtime": [
108
129
  "./dist/types/effect-client/runtime.d.ts",
109
130
  "./src/effect-client/runtime.ts"
@@ -111,6 +132,10 @@
111
132
  "data-platform": [
112
133
  "./dist/types/data-platform/index.d.ts",
113
134
  "./src/data-platform/index.ts"
135
+ ],
136
+ "assembly": [
137
+ "./dist/types/assembly.d.ts",
138
+ "./src/assembly.ts"
114
139
  ]
115
140
  }
116
141
  },
@@ -118,9 +143,10 @@
118
143
  "node": ">=26.7.0"
119
144
  },
120
145
  "dependencies": {
121
- "@modern-js/bff-core": "npm:@bleedingdev/modern-js-bff-core@3.9.0-ultramodern.3",
122
- "@modern-js/create-request": "npm:@bleedingdev/modern-js-create-request@3.9.0-ultramodern.3",
123
- "@modern-js/runtime-extensions": "npm:@bleedingdev/modern-js-runtime-extensions@3.9.0-ultramodern.3",
146
+ "@modern-js/bff-core": "npm:@bleedingdev/modern-js-bff-core@3.9.0-ultramodern.5",
147
+ "@modern-js/create-request": "npm:@bleedingdev/modern-js-create-request@3.9.0-ultramodern.5",
148
+ "@modern-js/runtime-extensions": "npm:@bleedingdev/modern-js-runtime-extensions@3.9.0-ultramodern.5",
149
+ "@modern-js/server-runtime-extensions": "npm:@bleedingdev/modern-js-server-runtime-extensions@3.9.0-ultramodern.5",
124
150
  "@opentelemetry/api": "1.9.1",
125
151
  "@opentelemetry/api-logs": "0.222.0",
126
152
  "@opentelemetry/resources": "2.11.0",
@@ -0,0 +1,43 @@
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 { HttpApiBuilder } from 'effect/unstable/httpapi';
5
+ import { defineEffectBff } from './effect/handler/definition';
6
+ import type { EffectRuntimeRequirements } from './effect/handler/types';
7
+
8
+ export interface EffectBffRuntimeAssembly<
9
+ ApiId extends string,
10
+ Groups extends HttpApiGroup.Constraint,
11
+ HandlerRequirements extends EffectRuntimeRequirements,
12
+ TransportRequirements extends EffectRuntimeRequirements = never,
13
+ > {
14
+ readonly api: HttpApi.HttpApi<ApiId, Groups>;
15
+ readonly handlers: Layer.Layer<
16
+ HttpApiGroup.ToService<ApiId, Groups>,
17
+ never,
18
+ HandlerRequirements
19
+ >;
20
+ readonly transport?: Layer.Layer<never, never, TransportRequirements>;
21
+ }
22
+
23
+ export const assembleEffectBffRuntime = <
24
+ ApiId extends string,
25
+ Groups extends HttpApiGroup.Constraint,
26
+ HandlerRequirements extends EffectRuntimeRequirements,
27
+ TransportRequirements extends EffectRuntimeRequirements = never,
28
+ >({
29
+ api,
30
+ handlers,
31
+ transport,
32
+ }: EffectBffRuntimeAssembly<
33
+ ApiId,
34
+ Groups,
35
+ HandlerRequirements,
36
+ TransportRequirements
37
+ >) => {
38
+ const apiLayer = HttpApiBuilder.layer(api).pipe(Layer.provide(handlers));
39
+ const layer =
40
+ transport === undefined ? apiLayer : apiLayer.pipe(Layer.merge(transport));
41
+
42
+ return defineEffectBff({ api, layer });
43
+ };
@@ -307,15 +307,14 @@ export function createBatchTransportQueue({
307
307
  abortBatchIfUnused?.();
308
308
  };
309
309
 
310
- const runSingle = (request: QueuedBatchRequest) => {
311
- return runWithSignal(request.lifetime.signal, async () => {
310
+ const runSingle = (request: QueuedBatchRequest) =>
311
+ runWithSignal(request.lifetime.signal, async () => {
312
312
  const response = await baseFetch(
313
313
  request.requestInput,
314
314
  request.requestInit,
315
315
  );
316
316
  return parseResponseLikeCreateRequest(response);
317
317
  });
318
- };
319
318
 
320
319
  const settleRequests = async (
321
320
  items: QueuedBatchRequest[],
@@ -1,5 +1,5 @@
1
1
  // @effect-diagnostics asyncFunction:off globalDate:off globalRandom:off globalTimers:off newPromise:off strictBooleanExpressions:off
2
- import { parseTraceparent } from '@modern-js/create-request';
2
+ import { parseTraceparent } from '@modern-js/runtime-extensions/request-context';
3
3
 
4
4
  import type { TraceContext } from './types';
5
5