@bleedingdev/modern-js-bff-effect 3.8.3-ultramodern.6 → 3.9.0-ultramodern.10
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/README.md +20 -4
- package/dist/cjs/{effect-client/guards.js → assembly.js} +15 -9
- package/dist/cjs/data-platform/trace.js +2 -2
- package/dist/cjs/effect/edge-dispatcher.js +7 -7
- package/dist/cjs/effect/edge.js +15 -2
- package/dist/cjs/effect/endpoint-contracts.js +3 -4
- package/dist/cjs/effect/entry-shape.js +2 -2
- package/dist/cjs/effect/generated-entry.js +57 -0
- package/dist/cjs/effect/handler/batch-handler.js +5 -4
- package/dist/cjs/effect/handler/batch.js +8 -1
- package/dist/cjs/effect/handler/definition.js +1 -21
- package/dist/cjs/effect/module.js +4 -4
- package/dist/cjs/effect/operation-context.js +7 -7
- package/dist/cjs/effect-client/cross-project.js +92 -0
- package/dist/cjs/effect-client/index.js +5 -3
- package/dist/cjs/microvertical-api.js +120 -0
- package/dist/esm/assembly.mjs +12 -0
- package/dist/esm/data-platform/trace.mjs +1 -1
- package/dist/esm/effect/edge-dispatcher.mjs +5 -5
- package/dist/esm/effect/edge.mjs +1 -0
- package/dist/esm/effect/endpoint-contracts.mjs +2 -3
- package/dist/esm/effect/entry-shape-registry.mjs +1 -1
- package/dist/esm/effect/entry-shape.mjs +2 -2
- package/dist/esm/effect/generated-entry.mjs +19 -0
- package/dist/esm/effect/handler/batch-handler.mjs +5 -4
- package/dist/esm/effect/handler/batch.mjs +8 -1
- package/dist/esm/effect/handler/definition.mjs +1 -21
- package/dist/esm/effect/module.mjs +4 -4
- package/dist/esm/effect/operation-context.mjs +1 -1
- package/dist/esm/effect-client/cross-project.mjs +54 -0
- package/dist/esm/effect-client/index.mjs +4 -2
- package/dist/esm/microvertical-api.mjs +67 -0
- package/dist/esm-node/assembly.mjs +13 -0
- package/dist/esm-node/data-platform/trace.mjs +1 -1
- package/dist/esm-node/effect/edge-dispatcher.mjs +5 -5
- package/dist/esm-node/effect/edge.mjs +1 -0
- package/dist/esm-node/effect/endpoint-contracts.mjs +2 -3
- package/dist/esm-node/effect/entry-shape-registry.mjs +1 -1
- package/dist/esm-node/effect/entry-shape.mjs +2 -2
- package/dist/esm-node/effect/generated-entry.mjs +20 -0
- package/dist/esm-node/effect/handler/batch-handler.mjs +5 -4
- package/dist/esm-node/effect/handler/batch.mjs +8 -1
- package/dist/esm-node/effect/handler/definition.mjs +1 -21
- package/dist/esm-node/effect/module.mjs +4 -4
- package/dist/esm-node/effect/operation-context.mjs +1 -1
- package/dist/esm-node/effect-client/cross-project.mjs +55 -0
- package/dist/esm-node/effect-client/index.mjs +4 -2
- package/dist/esm-node/microvertical-api.mjs +68 -0
- package/dist/types/assembly.d.ts +10 -0
- package/dist/types/data-platform/batch/protocol.d.ts +1 -1
- package/dist/types/data-platform/batch/queue.d.ts +1 -1
- package/dist/types/data-platform/batch/request.d.ts +1 -1
- package/dist/types/data-platform/batch/response.d.ts +1 -1
- package/dist/types/data-platform/batch/telemetry.d.ts +1 -1
- package/dist/types/data-platform/batch/url.d.ts +1 -1
- package/dist/types/data-platform/batch-transport.d.ts +3 -3
- package/dist/types/data-platform/codec.d.ts +1 -1
- package/dist/types/data-platform/index.d.ts +8 -8
- package/dist/types/data-platform/invalidation.d.ts +1 -1
- package/dist/types/data-platform/trace.d.ts +1 -1
- package/dist/types/data-platform/validation.d.ts +1 -1
- package/dist/types/effect/context.d.ts +3 -3
- package/dist/types/effect/dispatch.d.ts +2 -2
- package/dist/types/effect/edge-context.d.ts +3 -3
- package/dist/types/effect/edge-dispatcher.d.ts +9 -9
- package/dist/types/effect/edge.d.ts +2 -1
- package/dist/types/effect/endpoint-contracts.d.ts +2 -20
- package/dist/types/effect/entry-shape.d.ts +2 -2
- package/dist/types/effect/generated-entry.d.ts +7 -0
- package/dist/types/effect/handler/batch-handler.d.ts +1 -1
- package/dist/types/effect/handler/batch.d.ts +9 -3
- package/dist/types/effect/handler/definition.d.ts +1 -1
- package/dist/types/effect/handler/envelope.d.ts +1 -1
- package/dist/types/effect/handler/http.d.ts +1 -1
- package/dist/types/effect/handler/openapi.d.ts +1 -1
- package/dist/types/effect/handler/rpc.d.ts +1 -1
- package/dist/types/effect/handler/types.d.ts +2 -17
- package/dist/types/effect/handler.d.ts +3 -3
- package/dist/types/effect/index.d.ts +5 -5
- package/dist/types/effect/module.d.ts +2 -2
- package/dist/types/effect/operation-context.d.ts +1 -1
- package/dist/types/effect/rpcSerialization.d.ts +1 -1
- package/dist/types/effect-client/cross-project.d.ts +10 -0
- package/dist/types/effect-client/index.d.ts +4 -1
- package/dist/types/index.d.ts +3 -3
- package/dist/types/microvertical-api.d.ts +65 -0
- package/package.json +35 -22
- package/src/assembly.ts +43 -0
- package/src/data-platform/batch/queue.ts +2 -3
- package/src/data-platform/trace.ts +1 -1
- package/src/effect/edge-dispatcher.ts +7 -5
- package/src/effect/edge.ts +1 -0
- package/src/effect/endpoint-contracts.ts +3 -24
- package/src/effect/entry-shape.ts +10 -5
- package/src/effect/generated-entry.ts +36 -0
- package/src/effect/handler/batch-handler.ts +21 -16
- package/src/effect/handler/batch.ts +9 -1
- package/src/effect/handler/definition.ts +0 -44
- package/src/effect/handler/http.ts +2 -2
- package/src/effect/handler/types.ts +0 -27
- package/src/effect/handler.ts +0 -1
- package/src/effect/module.ts +4 -4
- package/src/effect/operation-context.ts +1 -1
- package/src/effect-client/cross-project.ts +109 -0
- package/src/effect-client/index.ts +13 -3
- package/src/microvertical-api.ts +102 -0
- package/dist/cjs/effect-client/batch.js +0 -73
- package/dist/cjs/effect-client/envelope.js +0 -145
- package/dist/cjs/effect-client/request-context.js +0 -64
- package/dist/cjs/effect-client/request.js +0 -66
- package/dist/cjs/effect-client/runtime.js +0 -100
- package/dist/cjs/effect-client/types.js +0 -18
- package/dist/esm/effect-client/batch.mjs +0 -35
- package/dist/esm/effect-client/envelope.mjs +0 -104
- package/dist/esm/effect-client/guards.mjs +0 -3
- package/dist/esm/effect-client/request-context.mjs +0 -23
- package/dist/esm/effect-client/request.mjs +0 -28
- package/dist/esm/effect-client/runtime.mjs +0 -62
- package/dist/esm/effect-client/types.mjs +0 -0
- package/dist/esm-node/effect-client/batch.mjs +0 -36
- package/dist/esm-node/effect-client/envelope.mjs +0 -105
- package/dist/esm-node/effect-client/guards.mjs +0 -4
- package/dist/esm-node/effect-client/request-context.mjs +0 -24
- package/dist/esm-node/effect-client/request.mjs +0 -29
- package/dist/esm-node/effect-client/runtime.mjs +0 -63
- package/dist/esm-node/effect-client/types.mjs +0 -1
- package/dist/types/effect-client/batch.d.ts +0 -2
- package/dist/types/effect-client/envelope.d.ts +0 -15
- package/dist/types/effect-client/guards.d.ts +0 -2
- package/dist/types/effect-client/request-context.d.ts +0 -3
- package/dist/types/effect-client/request.d.ts +0 -1
- package/dist/types/effect-client/runtime.d.ts +0 -5
- package/dist/types/effect-client/types.d.ts +0 -68
- package/src/effect-client/batch.ts +0 -50
- package/src/effect-client/envelope.ts +0 -238
- package/src/effect-client/guards.ts +0 -6
- package/src/effect-client/request-context.ts +0 -54
- package/src/effect-client/request.ts +0 -51
- package/src/effect-client/runtime.ts +0 -122
- package/src/effect-client/types.ts +0 -84
- /package/dist/esm/{rslib-runtime.mjs → rslib-runtime~1.mjs} +0 -0
- /package/dist/esm-node/{rslib-runtime.mjs → rslib-runtime~0.mjs} +0 -0
|
@@ -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
|
-
|
|
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
|
-
|
|
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
|
|
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;
|
|
@@ -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({
|
|
@@ -12,7 +12,7 @@ function shareDispose(dispose) {
|
|
|
12
12
|
return disposePromise;
|
|
13
13
|
};
|
|
14
14
|
}
|
|
15
|
-
function
|
|
15
|
+
function rejectUnsupportedEffectModuleShape(options, shape) {
|
|
16
16
|
options.onWarning?.(`${strictEffectApproachMessage} Rejected ${shape}.`);
|
|
17
17
|
return true;
|
|
18
18
|
}
|
|
@@ -40,8 +40,8 @@ function classifyEffectBffRuntimeEntryShape(module) {
|
|
|
40
40
|
}
|
|
41
41
|
function resolveClassifiedEffectBffModuleHandler(facts, options = {}) {
|
|
42
42
|
if (!facts) return null;
|
|
43
|
-
if (facts.
|
|
44
|
-
if (
|
|
43
|
+
if (facts.unsupportedShape) {
|
|
44
|
+
if (rejectUnsupportedEffectModuleShape(options, facts.unsupportedShape)) return null;
|
|
45
45
|
}
|
|
46
46
|
if ('function' == typeof facts.createHandler) {
|
|
47
47
|
if (facts.createHandlerValidatorAware) {
|
|
@@ -54,7 +54,7 @@ function resolveClassifiedEffectBffModuleHandler(facts, options = {}) {
|
|
|
54
54
|
return createLoadedHandler(webHandler);
|
|
55
55
|
}
|
|
56
56
|
if (void 0 === facts.api || !facts.hasRuntimeLayer) {
|
|
57
|
-
|
|
57
|
+
rejectUnsupportedEffectModuleShape(options, 'unbranded `createHandler` export');
|
|
58
58
|
return null;
|
|
59
59
|
}
|
|
60
60
|
options.onWarning?.(`${strictEffectApproachMessage} Ignored unbranded \`createHandler\` export and rebuilt the handler from its { api, layer } exports.`);
|
|
@@ -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/
|
|
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);
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import "node:module";
|
|
2
|
+
import { BFF_ENVELOPE_HEADER, BFF_OPERATION_CONTEXT_DETAIL_HEADER, BFF_OPERATION_CONTEXT_HEADER, 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 input = encodeJson({
|
|
35
|
+
httpMethod: contract.method,
|
|
36
|
+
name: contract.name,
|
|
37
|
+
requestId: options.requestId,
|
|
38
|
+
routePath: contract.routePath
|
|
39
|
+
});
|
|
40
|
+
const digest = yield* __rspack_external_effect_Effect_41060786.promise(()=>globalThis.crypto.subtle.digest('SHA-256', new TextEncoder().encode(input)));
|
|
41
|
+
const schemaHash = Array.from(new Uint8Array(digest), (value)=>value.toString(16).padStart(2, '0')).join('');
|
|
42
|
+
return request.pipe(HttpClientRequest.setHeader(BFF_ENVELOPE_HEADER, encodeJson({
|
|
43
|
+
requestId: options.requestId
|
|
44
|
+
})), HttpClientRequest.setHeader(BFF_OPERATION_CONTEXT_HEADER, contract.operationId), HttpClientRequest.setHeader(BFF_OPERATION_CONTEXT_DETAIL_HEADER, encodeJson({
|
|
45
|
+
requestId: options.requestId,
|
|
46
|
+
operationId: contract.operationId,
|
|
47
|
+
method: contract.method,
|
|
48
|
+
routePath: contract.routePath,
|
|
49
|
+
schemaHash,
|
|
50
|
+
operationVersion: options.operationVersion
|
|
51
|
+
})));
|
|
52
|
+
});
|
|
53
|
+
}));
|
|
54
|
+
}
|
|
55
|
+
export { withCrossProjectPolicy };
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import "node:module";
|
|
2
|
-
import { createRequestContextHeaders } from "@modern-js/
|
|
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
|
-
|
|
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-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>>>>;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { DataBatchBody, DataBatchHeader, DataBatchResponseItem } from '../types';
|
|
1
|
+
import type { DataBatchBody, DataBatchHeader, DataBatchResponseItem } from '../types.js';
|
|
2
2
|
export declare function encodeBatchBody(bytes: Uint8Array): DataBatchBody;
|
|
3
3
|
export declare function encodeBatchText(value: string): DataBatchBody;
|
|
4
4
|
export declare function decodeBatchBody(body: DataBatchBody): Uint8Array<ArrayBuffer>;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { DataBatchRequestItem, DataBatchTransportOptions, DataTransportRequestInfo } from '../types';
|
|
1
|
+
import type { DataBatchRequestItem, DataBatchTransportOptions, DataTransportRequestInfo } from '../types.js';
|
|
2
2
|
type DataBatchFetch = NonNullable<DataBatchTransportOptions['fetch']>;
|
|
3
3
|
type CreateBatchTransportQueueOptions = {
|
|
4
4
|
options: DataBatchTransportOptions;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { DataBatchBody } from '../types';
|
|
1
|
+
import type { DataBatchBody } from '../types.js';
|
|
2
2
|
export declare function toHeaderRecord(headers: HeadersInit | undefined): Record<string, string>;
|
|
3
3
|
export declare function measureTextBytes(value: string): number;
|
|
4
4
|
export declare function createBatchId(): string;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import type { DataBatchResponsePayload } from '../types';
|
|
1
|
+
import type { DataBatchResponsePayload } from '../types.js';
|
|
2
2
|
export declare function isBatchResponsePayload(value: unknown): value is DataBatchResponsePayload;
|
|
3
3
|
export declare function parseResponseLikeCreateRequest(response: Response): Promise<any>;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { DataBatchTransportEvent, DataBatchTransportTelemetryAttributes } from '../types';
|
|
1
|
+
import type { DataBatchTransportEvent, DataBatchTransportTelemetryAttributes } from '../types.js';
|
|
2
2
|
export declare const DATA_BATCH_TRANSPORT_OTEL_EVENT = "modernjs.data.batch";
|
|
3
3
|
export declare function createDataBatchTransportTelemetryAttributes(event: DataBatchTransportEvent): DataBatchTransportTelemetryAttributes;
|
|
4
4
|
export declare function emitDataBatchTransportEvent(onEvent: ((event: DataBatchTransportEvent) => void) | undefined, event: DataBatchTransportEvent): void;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { DataTransportRequestInfo } from '../types';
|
|
1
|
+
import type { DataTransportRequestInfo } from '../types.js';
|
|
2
2
|
export declare function resolveRuntimeOrigin(): string;
|
|
3
3
|
export declare function toAbsoluteUrl(input: DataTransportRequestInfo): URL;
|
|
4
4
|
export declare function normalizeBatchEndpoint(requestUrl: URL, endpoint: string | undefined): URL;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import type { DataBatchTransportOptions } from './types';
|
|
2
|
-
export { createDataBatchTransportTelemetryAttributes, DATA_BATCH_TRANSPORT_OTEL_EVENT, emitDataBatchTransportEvent, } from './batch/telemetry';
|
|
3
|
-
export declare function createDataBatchTransport(options?: DataBatchTransportOptions): (input: import("./types").DataTransportRequestInfo, init?: RequestInit) => Promise<any>;
|
|
1
|
+
import type { DataBatchTransportOptions } from './types.js';
|
|
2
|
+
export { createDataBatchTransportTelemetryAttributes, DATA_BATCH_TRANSPORT_OTEL_EVENT, emitDataBatchTransportEvent, } from './batch/telemetry.js';
|
|
3
|
+
export declare function createDataBatchTransport(options?: DataBatchTransportOptions): (input: import("./types.js").DataTransportRequestInfo, init?: RequestInit) => Promise<any>;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { CacheScope, DataRequestMode, OperationDescriptor, RequestEnvelope, SelectionPlan } from './types';
|
|
1
|
+
import type { CacheScope, DataRequestMode, OperationDescriptor, RequestEnvelope, SelectionPlan } from './types.js';
|
|
2
2
|
export declare function isPlainObject(value: unknown): value is Record<string, unknown>;
|
|
3
3
|
export declare function stableStringify(value: unknown): string;
|
|
4
4
|
export declare function encodeRequestEnvelopeHeader(envelope: RequestEnvelope): string;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
export { measureTextBytes, normalizeMethod } from './batch/request';
|
|
2
|
-
export { createDataBatchTransport, createDataBatchTransportTelemetryAttributes, DATA_BATCH_TRANSPORT_OTEL_EVENT, emitDataBatchTransportEvent, } from './batch-transport';
|
|
3
|
-
export { buildQueryKey, buildScopeKey, createOperationId, decodeRequestEnvelopeHeader, encodeRequestEnvelopeHeader, isPlainObject, normalizeOrigin, stableStringify, } from './codec';
|
|
4
|
-
export { createInvalidationEvent, shouldApplyInvalidation, } from './invalidation';
|
|
5
|
-
export { deriveChildTraceContext, formatTraceparentHeader, parseTraceparentHeader, } from './trace';
|
|
6
|
-
export type { CacheScope, DataBatchBody, DataBatchHeader, DataBatchRequestItem, DataBatchRequestPayload, DataBatchResponseItem, DataBatchResponsePayload, DataBatchTransportEvent, DataBatchTransportOptions, DataBatchTransportTelemetryAttributes, DataMutationMode, DataRequestMode, HydrationEnvelope, HydrationEnvelopeValidationOptions, InvalidationEvent, InvalidationSubscriber, OperationDescriptor, RequestEnvelope, RequestEnvelopeValidationOptions, SelectionPlan, SelectionPlanValidationOptions, SelectionPlanValidationResult, TraceContext, } from './types';
|
|
7
|
-
export { DEFAULT_DATA_BATCH_ENDPOINT, DEFAULT_DATA_BATCH_HEADER, DEFAULT_DATA_ENVELOPE_HEADER, } from './types';
|
|
8
|
-
export { createHydrationEnvelope, createRequestEnvelope, validateHydrationEnvelope, validateRequestEnvelope, validateSelectionPlan, } from './validation';
|
|
1
|
+
export { measureTextBytes, normalizeMethod } from './batch/request.js';
|
|
2
|
+
export { createDataBatchTransport, createDataBatchTransportTelemetryAttributes, DATA_BATCH_TRANSPORT_OTEL_EVENT, emitDataBatchTransportEvent, } from './batch-transport.js';
|
|
3
|
+
export { buildQueryKey, buildScopeKey, createOperationId, decodeRequestEnvelopeHeader, encodeRequestEnvelopeHeader, isPlainObject, normalizeOrigin, stableStringify, } from './codec.js';
|
|
4
|
+
export { createInvalidationEvent, shouldApplyInvalidation, } from './invalidation.js';
|
|
5
|
+
export { deriveChildTraceContext, formatTraceparentHeader, parseTraceparentHeader, } from './trace.js';
|
|
6
|
+
export type { CacheScope, DataBatchBody, DataBatchHeader, DataBatchRequestItem, DataBatchRequestPayload, DataBatchResponseItem, DataBatchResponsePayload, DataBatchTransportEvent, DataBatchTransportOptions, DataBatchTransportTelemetryAttributes, DataMutationMode, DataRequestMode, HydrationEnvelope, HydrationEnvelopeValidationOptions, InvalidationEvent, InvalidationSubscriber, OperationDescriptor, RequestEnvelope, RequestEnvelopeValidationOptions, SelectionPlan, SelectionPlanValidationOptions, SelectionPlanValidationResult, TraceContext, } from './types.js';
|
|
7
|
+
export { DEFAULT_DATA_BATCH_ENDPOINT, DEFAULT_DATA_BATCH_HEADER, DEFAULT_DATA_ENVELOPE_HEADER, } from './types.js';
|
|
8
|
+
export { createHydrationEnvelope, createRequestEnvelope, validateHydrationEnvelope, validateRequestEnvelope, validateSelectionPlan, } from './validation.js';
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { CacheScope, InvalidationEvent, InvalidationSubscriber, OperationDescriptor } from './types';
|
|
1
|
+
import type { CacheScope, InvalidationEvent, InvalidationSubscriber, OperationDescriptor } from './types.js';
|
|
2
2
|
export declare function createInvalidationEvent(input: {
|
|
3
3
|
sourceOperation: OperationDescriptor;
|
|
4
4
|
sourceScope: CacheScope;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { TraceContext } from './types';
|
|
1
|
+
import type { TraceContext } from './types.js';
|
|
2
2
|
export declare function parseTraceparentHeader(header: string): TraceContext | null;
|
|
3
3
|
export declare function formatTraceparentHeader(trace: TraceContext): string;
|
|
4
4
|
export declare function deriveChildTraceContext(parent: TraceContext, childSpanId: string): TraceContext;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { CacheScope, DataMutationMode, DataRequestMode, HydrationEnvelope, HydrationEnvelopeValidationOptions, OperationDescriptor, RequestEnvelope, RequestEnvelopeValidationOptions, SelectionPlan, SelectionPlanValidationOptions, SelectionPlanValidationResult, TraceContext } from './types';
|
|
1
|
+
import type { CacheScope, DataMutationMode, DataRequestMode, HydrationEnvelope, HydrationEnvelopeValidationOptions, OperationDescriptor, RequestEnvelope, RequestEnvelopeValidationOptions, SelectionPlan, SelectionPlanValidationOptions, SelectionPlanValidationResult, TraceContext } from './types.js';
|
|
2
2
|
export declare function validateSelectionPlan(plan: SelectionPlan, options?: SelectionPlanValidationOptions): SelectionPlanValidationResult;
|
|
3
3
|
export declare function createRequestEnvelope<Input>(input: {
|
|
4
4
|
operation: OperationDescriptor;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { type EffectContext } from './operation-context';
|
|
2
|
-
export { type CreateEffectOperationContextOptions, createEffectOperationContext, type EffectContext, } from './operation-context';
|
|
1
|
+
import { type EffectContext } from './operation-context.js';
|
|
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/
|
|
5
|
+
export declare const useOperationContext: () => import("@modern-js/runtime-extensions/request-context").OperationContext;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { EffectBffRequestHandler } from './module';
|
|
2
|
-
import { type EffectContext } from './operation-context';
|
|
1
|
+
import type { EffectBffRequestHandler } from './module.js';
|
|
2
|
+
import { type EffectContext } from './operation-context.js';
|
|
3
3
|
type EffectDispatchContextRunner = <T>(context: EffectContext, cb: () => T) => T;
|
|
4
4
|
export type DispatchEffectBffRequestOptions = {
|
|
5
5
|
prefix?: string;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { type EffectContext } from './operation-context';
|
|
2
|
-
export { type CreateEffectOperationContextOptions, createEffectOperationContext, type EffectContext, } from './operation-context';
|
|
1
|
+
import { type EffectContext } from './operation-context.js';
|
|
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/
|
|
5
|
+
export declare const useOperationContext: () => import("@modern-js/runtime-extensions/request-context").OperationContext;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { type NormalizedCrossProjectPolicy } from '@modern-js/
|
|
2
|
-
import { type DispatchEffectBffRequestOptions } from './dispatch';
|
|
3
|
-
import type { EffectBffOpenApiConfig, EffectDataPlatformValidationOptions } from './handler';
|
|
4
|
-
import { type EffectApiModule, type EffectBffRequestHandler } from './module';
|
|
5
|
-
import type { EffectContext } from './operation-context';
|
|
1
|
+
import { type NormalizedCrossProjectPolicy } from '@modern-js/server-runtime-extensions/bff-policy';
|
|
2
|
+
import { type DispatchEffectBffRequestOptions } from './dispatch.js';
|
|
3
|
+
import type { EffectBffOpenApiConfig, EffectDataPlatformValidationOptions } from './handler.js';
|
|
4
|
+
import { type EffectApiModule, type EffectBffRequestHandler } from './module.js';
|
|
5
|
+
import type { EffectContext } from './operation-context.js';
|
|
6
6
|
export * as Config from 'effect/Config';
|
|
7
7
|
export * as Effect from 'effect/Effect';
|
|
8
8
|
export * as Layer from 'effect/Layer';
|
|
@@ -11,10 +11,10 @@ export * as Schema from 'effect/Schema';
|
|
|
11
11
|
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
12
|
export { HttpApi, HttpApiBuilder, HttpApiClient, HttpApiEndpoint, HttpApiError, HttpApiGroup, HttpApiMiddleware, HttpApiSchema, HttpApiSecurity, HttpApiTest, OpenApi, } from 'effect/unstable/httpapi';
|
|
13
13
|
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';
|
|
15
|
-
export type { EffectApiClientFromApi,
|
|
16
|
-
export { createHttpApiHandler, defineEffectBff, defineEffectRpcBff, } from './handler';
|
|
17
|
-
export { type CreateEffectOperationContextOptions, createEffectOperationContext, type EffectContext, } from './operation-context';
|
|
14
|
+
export { runWithEffectContext, useEffectContext, useOperationContext, } from './edge-context.js';
|
|
15
|
+
export type { EffectApiClientFromApi, EffectBffDefinition, EffectBffHandlerFactory, EffectBffOpenApiConfig, EffectBffRuntime, EffectDataPlatformBatchOptions, EffectDataPlatformSelectionValidationOptions, EffectDataPlatformValidationOptions, EffectRequestValidator, EffectRpcBffDefinition, EffectRpcBffHandlerFactory, EffectRpcBffHandlerOptions, EffectRpcRuntimeLayer, EffectRpcSerialization, EffectRuntimeLayer, EffectRuntimeRequirements, } from './handler.js';
|
|
16
|
+
export { createHttpApiHandler, defineEffectBff, defineEffectRpcBff, } from './handler.js';
|
|
17
|
+
export { type CreateEffectOperationContextOptions, createEffectOperationContext, type EffectContext, } from './operation-context.js';
|
|
18
18
|
export type EffectBffEdgeDispatchOptions = Omit<DispatchEffectBffRequestOptions, 'runWithEffectContext'>;
|
|
19
19
|
export type EffectBffEdgeHandlerOptions = {
|
|
20
20
|
module: EffectApiModule;
|
|
@@ -1 +1,2 @@
|
|
|
1
|
-
export * from './edge-dispatcher';
|
|
1
|
+
export * from './edge-dispatcher.js';
|
|
2
|
+
export { createEffectBffEdgeDispatcherFactory } from './generated-entry.js';
|
|
@@ -1,17 +1,5 @@
|
|
|
1
|
-
/**
|
|
2
|
-
|
|
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
|
};
|
|
@@ -5,10 +5,10 @@ type EffectBffEntryModule = {
|
|
|
5
5
|
createHandler?: unknown;
|
|
6
6
|
default?: unknown;
|
|
7
7
|
};
|
|
8
|
-
type
|
|
8
|
+
type UnsupportedEffectBffEntryShape = '`handler` export' | 'default request handler';
|
|
9
9
|
export type EffectBffEntryShapeFacts = {
|
|
10
10
|
module: EffectBffEntryModule;
|
|
11
|
-
|
|
11
|
+
unsupportedShape?: UnsupportedEffectBffEntryShape;
|
|
12
12
|
createHandler?: unknown;
|
|
13
13
|
createHandlerValidatorAware: boolean;
|
|
14
14
|
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 {};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { EffectDataPlatformValidationOptions } from './types';
|
|
1
|
+
import type { EffectDataPlatformValidationOptions } from './types.js';
|
|
2
2
|
type DataPlatformBatchItemHandler<TContext> = (request: Request, context?: TContext) => Promise<unknown>;
|
|
3
3
|
export declare function createDataPlatformBatchRequestHandler<TContext>(options: {
|
|
4
4
|
dataPlatform?: EffectDataPlatformValidationOptions;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { type DataBatchRequestPayload, type DataBatchResponseItem } from '../../data-platform';
|
|
2
|
-
export { toHeaderRecord } from '../../headers';
|
|
1
|
+
import { type DataBatchRequestPayload, type DataBatchResponseItem } from '../../data-platform/index.js';
|
|
2
|
+
export { toHeaderRecord } from '../../headers.js';
|
|
3
3
|
export declare function normalizeBatchPath(pathname: string | undefined): `/${string}`;
|
|
4
4
|
export declare function normalizeBatchAllowedMethods(allowedMethods: string[] | undefined): Set<string>;
|
|
5
5
|
type ParsedBatchRequestPayload = Omit<DataBatchRequestPayload, 'items'> & {
|
|
@@ -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
|
-
|
|
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,6 +1,6 @@
|
|
|
1
1
|
import type { HttpApi } from 'effect/unstable/httpapi';
|
|
2
2
|
import type { Rpc } from 'effect/unstable/rpc';
|
|
3
|
-
import type { EffectBffDefinition, EffectBffRuntime, EffectRpcBffDefinition, EffectRpcBffHandlerFactory, EffectRpcRuntimeLayer, EffectRuntimeLayer } from './types';
|
|
3
|
+
import type { EffectBffDefinition, EffectBffRuntime, EffectRpcBffDefinition, EffectRpcBffHandlerFactory, EffectRpcRuntimeLayer, EffectRuntimeLayer } from './types.js';
|
|
4
4
|
export declare function defineEffectBff<TApi extends HttpApi.Constraint, TLayer extends EffectRuntimeLayer, TRpcs extends Rpc.Any = Rpc.Any>(definition: EffectBffDefinition<TApi, TLayer, TRpcs>): EffectBffDefinition<TApi, TLayer, TRpcs> & EffectBffRuntime<TApi, TLayer>;
|
|
5
5
|
export declare function defineEffectRpcBff<TRpcs extends Rpc.Any = Rpc.Any, TLayer extends EffectRpcRuntimeLayer<TRpcs> = EffectRpcRuntimeLayer<TRpcs>>(definition: EffectRpcBffDefinition<TRpcs, TLayer>): EffectRpcBffDefinition<TRpcs, TLayer> & {
|
|
6
6
|
createHandler: EffectRpcBffHandlerFactory<TRpcs>;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { EffectDataPlatformValidationOptions } from './types';
|
|
1
|
+
import type { EffectDataPlatformValidationOptions } from './types.js';
|
|
2
2
|
/**
|
|
3
3
|
* Validates the `x-modernjs-data-envelope` header (the data-platform
|
|
4
4
|
* transport/cache contract: protocol version, scope, selection plan).
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { HttpApi } from 'effect/unstable/httpapi';
|
|
2
2
|
import type { Rpc } from 'effect/unstable/rpc';
|
|
3
|
-
import type { EffectBffOpenApiConfig, EffectDataPlatformValidationOptions, EffectRequestInterceptor, EffectRequestValidator, EffectRpcBffDefinition, EffectRuntimeLayer } from './types';
|
|
3
|
+
import type { EffectBffOpenApiConfig, EffectDataPlatformValidationOptions, EffectRequestInterceptor, EffectRequestValidator, EffectRpcBffDefinition, EffectRuntimeLayer } from './types.js';
|
|
4
4
|
export declare function createHttpApiHandler<TApi extends HttpApi.Constraint = HttpApi.Top, TRpcs extends Rpc.Any = Rpc.Any>(options: {
|
|
5
5
|
api: TApi;
|
|
6
6
|
layer: EffectRuntimeLayer;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { HttpRouter } from 'effect/unstable/http';
|
|
2
2
|
import { type HttpApi } from 'effect/unstable/httpapi';
|
|
3
|
-
import type { EffectBffOpenApiConfig } from './types';
|
|
3
|
+
import type { EffectBffOpenApiConfig } from './types.js';
|
|
4
4
|
export declare function createOpenApiLayer(api: HttpApi.Constraint, openapi: EffectBffOpenApiConfig | undefined): import("effect/Layer").Layer<never, never, HttpRouter.HttpRouter> | null;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { type Rpc } from 'effect/unstable/rpc';
|
|
2
|
-
import type { EffectRpcBffDefinition } from './types';
|
|
2
|
+
import type { EffectRpcBffDefinition } from './types.js';
|
|
3
3
|
export declare function normalizeRpcPath(pathname: string | undefined): `/${string}`;
|
|
4
4
|
export declare function createRpcApiHandler<TRpcs extends Rpc.Any = Rpc.Any>(options: EffectRpcBffDefinition<TRpcs>): {
|
|
5
5
|
readonly handler: (request: globalThis.Request, context?: import("effect/Context").Context<never> | undefined) => Promise<Response>;
|