@bleedingdev/modern-js-bff-effect 3.8.3-ultramodern.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +25 -0
- package/dist/cjs/data-platform/batch/protocol.js +130 -0
- package/dist/cjs/data-platform/batch/queue.js +623 -0
- package/dist/cjs/data-platform/batch/request.js +121 -0
- package/dist/cjs/data-platform/batch/response.js +65 -0
- package/dist/cjs/data-platform/batch/telemetry.js +71 -0
- package/dist/cjs/data-platform/batch/url.js +69 -0
- package/dist/cjs/data-platform/batch-transport.js +59 -0
- package/dist/cjs/data-platform/codec.js +155 -0
- package/dist/cjs/data-platform/index.js +124 -0
- package/dist/cjs/data-platform/invalidation.js +61 -0
- package/dist/cjs/data-platform/trace.js +73 -0
- package/dist/cjs/data-platform/types.js +48 -0
- package/dist/cjs/data-platform/validation.js +178 -0
- package/dist/cjs/effect/context.js +59 -0
- package/dist/cjs/effect/dispatch.js +101 -0
- package/dist/cjs/effect/edge-context.js +61 -0
- package/dist/cjs/effect/edge-dispatcher.js +354 -0
- package/dist/cjs/effect/edge.js +62 -0
- package/dist/cjs/effect/endpoint-contracts.js +121 -0
- package/dist/cjs/effect/entry-shape-registry.js +31 -0
- package/dist/cjs/effect/entry-shape.js +113 -0
- package/dist/cjs/effect/handler/batch-handler.js +270 -0
- package/dist/cjs/effect/handler/batch.js +170 -0
- package/dist/cjs/effect/handler/definition.js +99 -0
- package/dist/cjs/effect/handler/envelope.js +104 -0
- package/dist/cjs/effect/handler/http.js +107 -0
- package/dist/cjs/effect/handler/openapi.js +58 -0
- package/dist/cjs/effect/handler/routing.js +100 -0
- package/dist/cjs/effect/handler/rpc.js +63 -0
- package/dist/cjs/effect/handler/types.js +43 -0
- package/dist/cjs/effect/handler.js +173 -0
- package/dist/cjs/effect/index.js +137 -0
- package/dist/cjs/effect/module.js +118 -0
- package/dist/cjs/effect/operation-context.js +116 -0
- package/dist/cjs/effect/rpcSerialization.js +54 -0
- package/dist/cjs/effect-client/batch.js +73 -0
- package/dist/cjs/effect-client/envelope.js +145 -0
- package/dist/cjs/effect-client/guards.js +44 -0
- package/dist/cjs/effect-client/index.js +208 -0
- package/dist/cjs/effect-client/request-context.js +64 -0
- package/dist/cjs/effect-client/request.js +66 -0
- package/dist/cjs/effect-client/runtime.js +100 -0
- package/dist/cjs/effect-client/types.js +18 -0
- package/dist/cjs/headers.js +46 -0
- package/dist/cjs/index.js +83 -0
- package/dist/esm/data-platform/batch/protocol.mjs +71 -0
- package/dist/esm/data-platform/batch/queue.mjs +582 -0
- package/dist/esm/data-platform/batch/request.mjs +68 -0
- package/dist/esm/data-platform/batch/response.mjs +24 -0
- package/dist/esm/data-platform/batch/telemetry.mjs +27 -0
- package/dist/esm/data-platform/batch/url.mjs +25 -0
- package/dist/esm/data-platform/batch-transport.mjs +12 -0
- package/dist/esm/data-platform/codec.mjs +90 -0
- package/dist/esm/data-platform/index.mjs +7 -0
- package/dist/esm/data-platform/invalidation.mjs +20 -0
- package/dist/esm/data-platform/trace.mjs +29 -0
- package/dist/esm/data-platform/types.mjs +4 -0
- package/dist/esm/data-platform/validation.mjs +128 -0
- package/dist/esm/effect/context.mjs +12 -0
- package/dist/esm/effect/dispatch.mjs +63 -0
- package/dist/esm/effect/edge-context.mjs +14 -0
- package/dist/esm/effect/edge-dispatcher.mjs +115 -0
- package/dist/esm/effect/edge.mjs +1 -0
- package/dist/esm/effect/endpoint-contracts.mjs +68 -0
- package/dist/esm/effect/entry-shape-registry.mjs +17 -0
- package/dist/esm/effect/entry-shape.mjs +51 -0
- package/dist/esm/effect/handler/batch-handler.mjs +232 -0
- package/dist/esm/effect/handler/batch.mjs +105 -0
- package/dist/esm/effect/handler/definition.mjs +58 -0
- package/dist/esm/effect/handler/envelope.mjs +63 -0
- package/dist/esm/effect/handler/http.mjs +69 -0
- package/dist/esm/effect/handler/openapi.mjs +20 -0
- package/dist/esm/effect/handler/routing.mjs +50 -0
- package/dist/esm/effect/handler/rpc.mjs +22 -0
- package/dist/esm/effect/handler/types.mjs +5 -0
- package/dist/esm/effect/handler.mjs +13 -0
- package/dist/esm/effect/index.mjs +7 -0
- package/dist/esm/effect/module.mjs +80 -0
- package/dist/esm/effect/operation-context.mjs +75 -0
- package/dist/esm/effect/rpcSerialization.mjs +16 -0
- package/dist/esm/effect-client/batch.mjs +35 -0
- package/dist/esm/effect-client/envelope.mjs +104 -0
- package/dist/esm/effect-client/guards.mjs +3 -0
- package/dist/esm/effect-client/index.mjs +110 -0
- package/dist/esm/effect-client/request-context.mjs +23 -0
- package/dist/esm/effect-client/request.mjs +28 -0
- package/dist/esm/effect-client/runtime.mjs +62 -0
- package/dist/esm/effect-client/types.mjs +0 -0
- package/dist/esm/headers.mjs +8 -0
- package/dist/esm/index.mjs +4 -0
- package/dist/esm/rslib-runtime.mjs +18 -0
- package/dist/esm-node/data-platform/batch/protocol.mjs +72 -0
- package/dist/esm-node/data-platform/batch/queue.mjs +583 -0
- package/dist/esm-node/data-platform/batch/request.mjs +69 -0
- package/dist/esm-node/data-platform/batch/response.mjs +25 -0
- package/dist/esm-node/data-platform/batch/telemetry.mjs +28 -0
- package/dist/esm-node/data-platform/batch/url.mjs +26 -0
- package/dist/esm-node/data-platform/batch-transport.mjs +13 -0
- package/dist/esm-node/data-platform/codec.mjs +91 -0
- package/dist/esm-node/data-platform/index.mjs +8 -0
- package/dist/esm-node/data-platform/invalidation.mjs +21 -0
- package/dist/esm-node/data-platform/trace.mjs +30 -0
- package/dist/esm-node/data-platform/types.mjs +5 -0
- package/dist/esm-node/data-platform/validation.mjs +129 -0
- package/dist/esm-node/effect/context.mjs +13 -0
- package/dist/esm-node/effect/dispatch.mjs +64 -0
- package/dist/esm-node/effect/edge-context.mjs +15 -0
- package/dist/esm-node/effect/edge-dispatcher.mjs +116 -0
- package/dist/esm-node/effect/edge.mjs +2 -0
- package/dist/esm-node/effect/endpoint-contracts.mjs +69 -0
- package/dist/esm-node/effect/entry-shape-registry.mjs +18 -0
- package/dist/esm-node/effect/entry-shape.mjs +63 -0
- package/dist/esm-node/effect/handler/batch-handler.mjs +233 -0
- package/dist/esm-node/effect/handler/batch.mjs +106 -0
- package/dist/esm-node/effect/handler/definition.mjs +59 -0
- package/dist/esm-node/effect/handler/envelope.mjs +64 -0
- package/dist/esm-node/effect/handler/http.mjs +70 -0
- package/dist/esm-node/effect/handler/openapi.mjs +21 -0
- package/dist/esm-node/effect/handler/routing.mjs +51 -0
- package/dist/esm-node/effect/handler/rpc.mjs +23 -0
- package/dist/esm-node/effect/handler/types.mjs +6 -0
- package/dist/esm-node/effect/handler.mjs +14 -0
- package/dist/esm-node/effect/index.mjs +8 -0
- package/dist/esm-node/effect/module.mjs +81 -0
- package/dist/esm-node/effect/operation-context.mjs +76 -0
- package/dist/esm-node/effect/rpcSerialization.mjs +17 -0
- package/dist/esm-node/effect-client/batch.mjs +36 -0
- package/dist/esm-node/effect-client/envelope.mjs +105 -0
- package/dist/esm-node/effect-client/guards.mjs +4 -0
- package/dist/esm-node/effect-client/index.mjs +111 -0
- package/dist/esm-node/effect-client/request-context.mjs +24 -0
- package/dist/esm-node/effect-client/request.mjs +29 -0
- package/dist/esm-node/effect-client/runtime.mjs +63 -0
- package/dist/esm-node/effect-client/types.mjs +1 -0
- package/dist/esm-node/headers.mjs +9 -0
- package/dist/esm-node/index.mjs +5 -0
- package/dist/esm-node/rslib-runtime.mjs +19 -0
- package/dist/types/data-platform/batch/protocol.d.ts +9 -0
- package/dist/types/data-platform/batch/queue.d.ts +47 -0
- package/dist/types/data-platform/batch/request.d.ts +19 -0
- package/dist/types/data-platform/batch/response.d.ts +3 -0
- package/dist/types/data-platform/batch/telemetry.d.ts +4 -0
- package/dist/types/data-platform/batch/url.d.ts +4 -0
- package/dist/types/data-platform/batch-transport.d.ts +3 -0
- package/dist/types/data-platform/codec.d.ts +17 -0
- package/dist/types/data-platform/index.d.ts +8 -0
- package/dist/types/data-platform/invalidation.d.ts +8 -0
- package/dist/types/data-platform/trace.d.ts +4 -0
- package/dist/types/data-platform/types.d.ts +151 -0
- package/dist/types/data-platform/validation.d.ts +29 -0
- package/dist/types/effect/context.d.ts +5 -0
- package/dist/types/effect/dispatch.d.ts +13 -0
- package/dist/types/effect/edge-context.d.ts +5 -0
- package/dist/types/effect/edge-dispatcher.d.ts +37 -0
- package/dist/types/effect/edge.d.ts +1 -0
- package/dist/types/effect/endpoint-contracts.d.ts +67 -0
- package/dist/types/effect/entry-shape.d.ts +32 -0
- package/dist/types/effect/handler/batch-handler.d.ts +11 -0
- package/dist/types/effect/handler/batch.d.ts +15 -0
- package/dist/types/effect/handler/definition.d.ts +7 -0
- package/dist/types/effect/handler/envelope.d.ts +13 -0
- package/dist/types/effect/handler/http.d.ts +15 -0
- package/dist/types/effect/handler/openapi.d.ts +4 -0
- package/dist/types/effect/handler/routing.d.ts +5 -0
- package/dist/types/effect/handler/rpc.d.ts +7 -0
- package/dist/types/effect/handler/types.d.ts +153 -0
- package/dist/types/effect/handler.d.ts +13 -0
- package/dist/types/effect/index.d.ts +6 -0
- package/dist/types/effect/module.d.ts +36 -0
- package/dist/types/effect/operation-context.d.ts +15 -0
- package/dist/types/effect/rpcSerialization.d.ts +3 -0
- package/dist/types/effect-client/batch.d.ts +2 -0
- package/dist/types/effect-client/envelope.d.ts +15 -0
- package/dist/types/effect-client/guards.d.ts +2 -0
- package/dist/types/effect-client/index.d.ts +58 -0
- package/dist/types/effect-client/request-context.d.ts +3 -0
- package/dist/types/effect-client/request.d.ts +1 -0
- package/dist/types/effect-client/runtime.d.ts +5 -0
- package/dist/types/effect-client/types.d.ts +68 -0
- package/dist/types/headers.d.ts +1 -0
- package/dist/types/index.d.ts +3 -0
- package/package.json +164 -0
- package/src/data-platform/batch/protocol.ts +112 -0
- package/src/data-platform/batch/queue.ts +876 -0
- package/src/data-platform/batch/request.ts +130 -0
- package/src/data-platform/batch/response.ts +74 -0
- package/src/data-platform/batch/telemetry.ts +47 -0
- package/src/data-platform/batch/url.ts +54 -0
- package/src/data-platform/batch-transport.ts +22 -0
- package/src/data-platform/codec.ts +145 -0
- package/src/data-platform/index.ts +63 -0
- package/src/data-platform/invalidation.ts +57 -0
- package/src/data-platform/trace.ts +49 -0
- package/src/data-platform/types.ts +186 -0
- package/src/data-platform/validation.ts +303 -0
- package/src/effect/context.ts +37 -0
- package/src/effect/dispatch.ts +132 -0
- package/src/effect/edge-context.ts +51 -0
- package/src/effect/edge-dispatcher.ts +310 -0
- package/src/effect/edge.ts +1 -0
- package/src/effect/endpoint-contracts.ts +191 -0
- package/src/effect/entry-shape-registry.cjs +16 -0
- package/src/effect/entry-shape-registry.d.cts +6 -0
- package/src/effect/entry-shape.ts +155 -0
- package/src/effect/handler/batch-handler.ts +475 -0
- package/src/effect/handler/batch.ts +182 -0
- package/src/effect/handler/definition.ts +121 -0
- package/src/effect/handler/envelope.ts +133 -0
- package/src/effect/handler/http.ts +133 -0
- package/src/effect/handler/openapi.ts +45 -0
- package/src/effect/handler/routing.ts +91 -0
- package/src/effect/handler/rpc.ts +45 -0
- package/src/effect/handler/types.ts +255 -0
- package/src/effect/handler.ts +33 -0
- package/src/effect/index.ts +22 -0
- package/src/effect/module.ts +186 -0
- package/src/effect/operation-context.ts +144 -0
- package/src/effect/rpcSerialization.ts +20 -0
- package/src/effect-client/batch.ts +50 -0
- package/src/effect-client/envelope.ts +238 -0
- package/src/effect-client/guards.ts +6 -0
- package/src/effect-client/index.ts +325 -0
- package/src/effect-client/request-context.ts +54 -0
- package/src/effect-client/request.ts +51 -0
- package/src/effect-client/runtime.ts +122 -0
- package/src/effect-client/types.ts +84 -0
- package/src/headers.ts +7 -0
- package/src/index.ts +3 -0
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
import "node:module";
|
|
2
|
+
import { createRequestContextHeaders } from "@modern-js/create-request";
|
|
3
|
+
import * as __rspack_external_effect_Effect_41060786 from "effect/Effect";
|
|
4
|
+
import * as __rspack_external_effect_Layer_69c46453 from "effect/Layer";
|
|
5
|
+
import { FetchHttpClient, HttpClient, HttpClientRequest } from "effect/unstable/http";
|
|
6
|
+
import { HttpApi, HttpApiClient, HttpApiEndpoint, HttpApiGroup, HttpApiSchema } from "effect/unstable/httpapi";
|
|
7
|
+
import { Rpc, RpcClient, RpcGroup, RpcSchema, RpcSerialization } from "effect/unstable/rpc";
|
|
8
|
+
import { getRpcSerializationLayer } from "../effect/rpcSerialization.mjs";
|
|
9
|
+
import * as __rspack_external_effect_Schema_6065f72d from "effect/Schema";
|
|
10
|
+
import * as __rspack_external_effect_unstable_http_HttpClientError_4b9eaee6 from "effect/unstable/http/HttpClientError";
|
|
11
|
+
import * as __rspack_external_effect_Data_2b3f4efb from "effect/Data";
|
|
12
|
+
import * as __rspack_external_effect_Exit_1ca64b33 from "effect/Exit";
|
|
13
|
+
import * as __rspack_external_effect_ManagedRuntime_bfe218e3 from "effect/ManagedRuntime";
|
|
14
|
+
import * as __rspack_external_effect_Scope_f87b0bd6 from "effect/Scope";
|
|
15
|
+
class EffectRpcClientError extends __rspack_external_effect_Data_2b3f4efb.TaggedError('EffectRpcClientError') {
|
|
16
|
+
}
|
|
17
|
+
function isRecord(value) {
|
|
18
|
+
return 'object' == typeof value && null !== value && !Array.isArray(value);
|
|
19
|
+
}
|
|
20
|
+
function applySelection(value, selection) {
|
|
21
|
+
if (true === selection || void 0 === selection) return value;
|
|
22
|
+
if (Array.isArray(value)) return value.map((item)=>applySelection(item, selection));
|
|
23
|
+
if (!isRecord(value) || !isRecord(selection)) return value;
|
|
24
|
+
const masked = {};
|
|
25
|
+
for (const key of Object.keys(selection)){
|
|
26
|
+
const selected = selection[key];
|
|
27
|
+
if (void 0 !== selected && key in value && (true === selected || isRecord(selected))) masked[key] = applySelection(value[key], selected);
|
|
28
|
+
}
|
|
29
|
+
return masked;
|
|
30
|
+
}
|
|
31
|
+
function view() {
|
|
32
|
+
return (selection)=>selection;
|
|
33
|
+
}
|
|
34
|
+
function mask(value, selection) {
|
|
35
|
+
return applySelection(value, selection);
|
|
36
|
+
}
|
|
37
|
+
function runEffectView(request, selection) {
|
|
38
|
+
return new Promise((resolve, reject)=>{
|
|
39
|
+
request.then((value)=>resolve(mask(value, selection)), (reason)=>reject(reason));
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
function makeEffectHttpApiClient(api, options) {
|
|
43
|
+
const requestContextHeaders = createRequestContextHeaders(options?.requestContext);
|
|
44
|
+
const transformClient = (client)=>{
|
|
45
|
+
const contextClient = 0 === Object.keys(requestContextHeaders).length ? client : client.pipe(HttpClient.mapRequest((request)=>{
|
|
46
|
+
let nextRequest = request;
|
|
47
|
+
for (const [header, value] of Object.entries(requestContextHeaders))if (void 0 === nextRequest.headers[header.toLowerCase()]) nextRequest = HttpClientRequest.setHeader(nextRequest, header, value);
|
|
48
|
+
return nextRequest;
|
|
49
|
+
}));
|
|
50
|
+
return 'function' == typeof options?.transformClient ? options.transformClient(contextClient) : contextClient;
|
|
51
|
+
};
|
|
52
|
+
return HttpApiClient.make(api, {
|
|
53
|
+
baseUrl: options?.baseUrl,
|
|
54
|
+
transformClient,
|
|
55
|
+
transformResponse: options?.transformResponse
|
|
56
|
+
}).pipe(__rspack_external_effect_Effect_41060786.provide(FetchHttpClient.layer));
|
|
57
|
+
}
|
|
58
|
+
function makeEffectRpcClient(group, options) {
|
|
59
|
+
const protocolLayer = __rspack_external_effect_Layer_69c46453.provide(RpcClient.layerProtocolHttp({
|
|
60
|
+
url: options.url
|
|
61
|
+
}), __rspack_external_effect_Layer_69c46453.mergeAll(getRpcSerializationLayer(options.serialization), FetchHttpClient.layer));
|
|
62
|
+
const middlewareLayer = options.middlewareLayer ?? __rspack_external_effect_Layer_69c46453.empty;
|
|
63
|
+
const runtimeLayer = __rspack_external_effect_Layer_69c46453.mergeAll(protocolLayer, middlewareLayer);
|
|
64
|
+
return __rspack_external_effect_Effect_41060786.tryPromise({
|
|
65
|
+
try: async ()=>{
|
|
66
|
+
const runtime = __rspack_external_effect_ManagedRuntime_bfe218e3.make(runtimeLayer);
|
|
67
|
+
let scope;
|
|
68
|
+
try {
|
|
69
|
+
const clientScope = await runtime.runPromise(__rspack_external_effect_Scope_f87b0bd6.make());
|
|
70
|
+
scope = clientScope;
|
|
71
|
+
const client = await runtime.runPromise(RpcClient.make(group, {
|
|
72
|
+
flatten: options.flatten
|
|
73
|
+
}).pipe(__rspack_external_effect_Effect_41060786.provideService(__rspack_external_effect_Scope_f87b0bd6.Scope, clientScope)));
|
|
74
|
+
let disposePromise;
|
|
75
|
+
const clientWithDispose = Object.assign(client, {
|
|
76
|
+
dispose: ()=>{
|
|
77
|
+
disposePromise ??= (async ()=>{
|
|
78
|
+
let scopeCloseError;
|
|
79
|
+
try {
|
|
80
|
+
await runtime.runPromise(__rspack_external_effect_Scope_f87b0bd6.close(clientScope, __rspack_external_effect_Exit_1ca64b33["void"]));
|
|
81
|
+
} catch (error) {
|
|
82
|
+
scopeCloseError = error;
|
|
83
|
+
}
|
|
84
|
+
try {
|
|
85
|
+
await runtime.dispose();
|
|
86
|
+
} catch (error) {
|
|
87
|
+
if (void 0 === scopeCloseError) throw error;
|
|
88
|
+
}
|
|
89
|
+
if (void 0 !== scopeCloseError) throw scopeCloseError;
|
|
90
|
+
})();
|
|
91
|
+
return disposePromise;
|
|
92
|
+
}
|
|
93
|
+
});
|
|
94
|
+
return clientWithDispose;
|
|
95
|
+
} catch (error) {
|
|
96
|
+
if (void 0 !== scope) try {
|
|
97
|
+
await runtime.runPromise(__rspack_external_effect_Scope_f87b0bd6.close(scope, __rspack_external_effect_Exit_1ca64b33["void"]));
|
|
98
|
+
} catch {}
|
|
99
|
+
try {
|
|
100
|
+
await runtime.dispose();
|
|
101
|
+
} catch {}
|
|
102
|
+
throw error;
|
|
103
|
+
}
|
|
104
|
+
},
|
|
105
|
+
catch: (error)=>new EffectRpcClientError({
|
|
106
|
+
cause: error
|
|
107
|
+
})
|
|
108
|
+
});
|
|
109
|
+
}
|
|
110
|
+
const runEffectRequest = __rspack_external_effect_Effect_41060786.runPromise;
|
|
111
|
+
export { EffectRpcClientError, HttpApi, HttpApiClient, HttpApiEndpoint, HttpApiGroup, HttpApiSchema, Rpc, RpcClient, RpcGroup, RpcSchema, RpcSerialization, __rspack_external_effect_Effect_41060786 as Effect, __rspack_external_effect_Layer_69c46453 as Layer, __rspack_external_effect_Schema_6065f72d as Schema, __rspack_external_effect_unstable_http_HttpClientError_4b9eaee6 as HttpClientError, makeEffectHttpApiClient, makeEffectRpcClient, mask, runEffectRequest, runEffectView, view };
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import "node:module";
|
|
2
|
+
import { isRecord } from "./guards.mjs";
|
|
3
|
+
const createEffectRequestContext = (createRequestContextHeaders, requestContext)=>{
|
|
4
|
+
if (!isRecord(requestContext)) return {};
|
|
5
|
+
const headers = createRequestContextHeaders ? createRequestContextHeaders(requestContext) : {};
|
|
6
|
+
return {
|
|
7
|
+
...requestContext,
|
|
8
|
+
headers
|
|
9
|
+
};
|
|
10
|
+
};
|
|
11
|
+
const applyRequestContext = (normalizedRequest, request, createRequestContext)=>{
|
|
12
|
+
if (!isRecord(request) || !isRecord(request.requestContext)) return normalizedRequest;
|
|
13
|
+
const requestContext = createRequestContext(request.requestContext);
|
|
14
|
+
const requestHeaders = isRecord(requestContext.headers) ? requestContext.headers : {};
|
|
15
|
+
if (0 === Object.keys(requestHeaders).length) return normalizedRequest;
|
|
16
|
+
return {
|
|
17
|
+
...normalizedRequest,
|
|
18
|
+
headers: {
|
|
19
|
+
...isRecord(normalizedRequest.headers) ? normalizedRequest.headers : {},
|
|
20
|
+
...requestHeaders
|
|
21
|
+
}
|
|
22
|
+
};
|
|
23
|
+
};
|
|
24
|
+
export { applyRequestContext, createEffectRequestContext };
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import "node:module";
|
|
2
|
+
import { isRecord } from "./guards.mjs";
|
|
3
|
+
const METHODS_WITHOUT_BODY = new Set([
|
|
4
|
+
'GET',
|
|
5
|
+
'DELETE',
|
|
6
|
+
'HEAD',
|
|
7
|
+
'OPTIONS'
|
|
8
|
+
]);
|
|
9
|
+
const normalizeRequest = (method, request)=>{
|
|
10
|
+
if (!isRecord(request)) return {};
|
|
11
|
+
const payload = {
|
|
12
|
+
...request
|
|
13
|
+
};
|
|
14
|
+
if (isRecord(request.path) && !isRecord(payload.params)) payload.params = request.path;
|
|
15
|
+
if (isRecord(request.urlParams) && !isRecord(payload.query)) payload.query = request.urlParams;
|
|
16
|
+
if (isRecord(request.headers) && !isRecord(payload.headers)) payload.headers = request.headers;
|
|
17
|
+
if ('payload' in request && void 0 !== request.payload) if ("u" > typeof FormData && request.payload instanceof FormData && !('formData' in payload)) payload.formData = request.payload;
|
|
18
|
+
else if (METHODS_WITHOUT_BODY.has(method)) {
|
|
19
|
+
if (isRecord(request.payload)) payload.query = isRecord(payload.query) ? {
|
|
20
|
+
...payload.query,
|
|
21
|
+
...request.payload
|
|
22
|
+
} : request.payload;
|
|
23
|
+
else if (!('body' in payload)) payload.body = request.payload;
|
|
24
|
+
} else if (!isRecord(request.payload) || 'data' in payload) {
|
|
25
|
+
if (!('body' in payload)) payload.body = request.payload;
|
|
26
|
+
} else payload.data = request.payload;
|
|
27
|
+
return payload;
|
|
28
|
+
};
|
|
29
|
+
export { normalizeRequest };
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import "node:module";
|
|
2
|
+
import { configureGeneratedEffectClientRuntime } from "./batch.mjs";
|
|
3
|
+
import { prepareEffectRequest } from "./envelope.mjs";
|
|
4
|
+
import { createEffectRequestContext as external_request_context_mjs_createEffectRequestContext } from "./request-context.mjs";
|
|
5
|
+
const createGeneratedEffectClient = (manifest, config, requestRuntime)=>{
|
|
6
|
+
const createRequest = requestRuntime.createRequest;
|
|
7
|
+
const configureRequest = 'function' == typeof requestRuntime.configure ? requestRuntime.configure : void 0;
|
|
8
|
+
const createRequestContextHeaders = 'function' == typeof requestRuntime.createRequestContextHeaders ? requestRuntime.createRequestContextHeaders : void 0;
|
|
9
|
+
const httpMethodDecider = config.httpMethodDecider || 'functionName';
|
|
10
|
+
const port = config.useEnvPort && "u" > typeof process && process.env && process.env.PORT ? process.env.PORT : config.port;
|
|
11
|
+
configureGeneratedEffectClientRuntime(config, configureRequest);
|
|
12
|
+
const createEffectRequestContext = (requestContext)=>external_request_context_mjs_createEffectRequestContext(createRequestContextHeaders, requestContext);
|
|
13
|
+
const client = {};
|
|
14
|
+
const operationManifest = {};
|
|
15
|
+
for (const endpoint of manifest.endpoints){
|
|
16
|
+
const operationId = `${endpoint.method}:${endpoint.routePath}`;
|
|
17
|
+
const operation = {
|
|
18
|
+
appNamespace: config.appNamespace,
|
|
19
|
+
apiId: endpoint.apiId,
|
|
20
|
+
group: endpoint.group,
|
|
21
|
+
endpoint: endpoint.endpoint,
|
|
22
|
+
operationId,
|
|
23
|
+
routePath: endpoint.routePath,
|
|
24
|
+
method: endpoint.method,
|
|
25
|
+
operationVersion: endpoint.operationVersion,
|
|
26
|
+
schemaHash: endpoint.schemaHash,
|
|
27
|
+
version: endpoint.operationVersion
|
|
28
|
+
};
|
|
29
|
+
const sender = createRequest({
|
|
30
|
+
path: endpoint.routePath,
|
|
31
|
+
method: endpoint.method,
|
|
32
|
+
port,
|
|
33
|
+
operationContext: {
|
|
34
|
+
operationId,
|
|
35
|
+
routePath: endpoint.routePath,
|
|
36
|
+
method: endpoint.method,
|
|
37
|
+
schemaHash: endpoint.schemaHash,
|
|
38
|
+
operationVersion: endpoint.operationVersion
|
|
39
|
+
},
|
|
40
|
+
httpMethodDecider,
|
|
41
|
+
...config.requestId ? {
|
|
42
|
+
requestId: config.requestId
|
|
43
|
+
} : {}
|
|
44
|
+
});
|
|
45
|
+
const call = (request = {})=>sender(prepareEffectRequest({
|
|
46
|
+
endpoint,
|
|
47
|
+
operation,
|
|
48
|
+
request,
|
|
49
|
+
config,
|
|
50
|
+
createEffectRequestContext
|
|
51
|
+
}));
|
|
52
|
+
client[endpoint.group] ??= {};
|
|
53
|
+
client[endpoint.group][endpoint.endpoint] = call;
|
|
54
|
+
operationManifest[endpoint.group] ??= {};
|
|
55
|
+
operationManifest[endpoint.group][endpoint.endpoint] = operation;
|
|
56
|
+
}
|
|
57
|
+
return {
|
|
58
|
+
client,
|
|
59
|
+
operationManifest,
|
|
60
|
+
createEffectRequestContext
|
|
61
|
+
};
|
|
62
|
+
};
|
|
63
|
+
export { createGeneratedEffectClient };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import "node:module";
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import "node:module";
|
|
2
|
+
import * as __rspack_external__data_platform_index_mjs_e91ceab4 from "./data-platform/index.mjs";
|
|
3
|
+
import * as __rspack_external__effect_client_index_mjs_a83cfa33 from "./effect-client/index.mjs";
|
|
4
|
+
export * from "./effect/index.mjs";
|
|
5
|
+
export { __rspack_external__data_platform_index_mjs_e91ceab4 as DataPlatform, __rspack_external__effect_client_index_mjs_a83cfa33 as EffectClient };
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import "node:module";
|
|
2
|
+
var __webpack_modules__ = {};
|
|
3
|
+
var __webpack_module_cache__ = {};
|
|
4
|
+
function __webpack_require__(moduleId) {
|
|
5
|
+
var cachedModule = __webpack_module_cache__[moduleId];
|
|
6
|
+
if (void 0 !== cachedModule) return cachedModule.exports;
|
|
7
|
+
var module = __webpack_module_cache__[moduleId] = {
|
|
8
|
+
exports: {}
|
|
9
|
+
};
|
|
10
|
+
__webpack_modules__[moduleId](module, module.exports, __webpack_require__);
|
|
11
|
+
return module.exports;
|
|
12
|
+
}
|
|
13
|
+
__webpack_require__.m = __webpack_modules__;
|
|
14
|
+
(()=>{
|
|
15
|
+
__webpack_require__.add = function(modules) {
|
|
16
|
+
Object.assign(__webpack_require__.m, modules);
|
|
17
|
+
};
|
|
18
|
+
})();
|
|
19
|
+
export { __webpack_require__ };
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { DataBatchBody, DataBatchHeader, DataBatchResponseItem } from '../types';
|
|
2
|
+
export declare function encodeBatchBody(bytes: Uint8Array): DataBatchBody;
|
|
3
|
+
export declare function encodeBatchText(value: string): DataBatchBody;
|
|
4
|
+
export declare function decodeBatchBody(body: DataBatchBody): Uint8Array<ArrayBuffer>;
|
|
5
|
+
export declare function isBatchBody(value: unknown): value is DataBatchBody;
|
|
6
|
+
export declare function isBatchHeaderList(value: unknown): value is DataBatchHeader[];
|
|
7
|
+
export declare function isNullBodyStatus(status: number): boolean;
|
|
8
|
+
export declare function toBatchResponseHeaders(headers: Headers): DataBatchHeader[];
|
|
9
|
+
export declare function toBatchResponseItem(id: string, response: Response, omitBody?: boolean): Promise<DataBatchResponseItem>;
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import type { DataBatchRequestItem, DataBatchTransportOptions, DataTransportRequestInfo } from '../types';
|
|
2
|
+
type DataBatchFetch = NonNullable<DataBatchTransportOptions['fetch']>;
|
|
3
|
+
type CreateBatchTransportQueueOptions = {
|
|
4
|
+
options: DataBatchTransportOptions;
|
|
5
|
+
baseFetch: DataBatchFetch;
|
|
6
|
+
bucketRegistry?: BatchBucketRegistry;
|
|
7
|
+
};
|
|
8
|
+
type RequestLifetime = {
|
|
9
|
+
signal: AbortSignal;
|
|
10
|
+
timedOut: boolean;
|
|
11
|
+
dispose: () => void;
|
|
12
|
+
};
|
|
13
|
+
type QueuedBatchRequest = {
|
|
14
|
+
key: string;
|
|
15
|
+
bucketKey: string;
|
|
16
|
+
endpoint: string;
|
|
17
|
+
requestInput: DataTransportRequestInfo;
|
|
18
|
+
requestInit: RequestInit;
|
|
19
|
+
authorization: string | undefined;
|
|
20
|
+
cookie: string | undefined;
|
|
21
|
+
credentials: RequestCredentials;
|
|
22
|
+
item: DataBatchRequestItem;
|
|
23
|
+
lifetime: RequestLifetime;
|
|
24
|
+
phase: 'queued' | 'flushing' | 'settled';
|
|
25
|
+
promise: Promise<unknown>;
|
|
26
|
+
abortListener: () => void;
|
|
27
|
+
abortBatchIfUnused?: () => void;
|
|
28
|
+
resolve: (value: unknown) => void;
|
|
29
|
+
reject: (reason: unknown) => void;
|
|
30
|
+
};
|
|
31
|
+
type BatchBucket = {
|
|
32
|
+
items: QueuedBatchRequest[];
|
|
33
|
+
bytes: number;
|
|
34
|
+
batchId: string;
|
|
35
|
+
sentAt: number;
|
|
36
|
+
timer: ReturnType<typeof setTimeout> | null;
|
|
37
|
+
flushing: boolean;
|
|
38
|
+
};
|
|
39
|
+
export declare class BatchBucketRegistry {
|
|
40
|
+
private readonly buckets;
|
|
41
|
+
get size(): number;
|
|
42
|
+
get(bucketKey: string): BatchBucket | undefined;
|
|
43
|
+
ensure(bucketKey: string): BatchBucket;
|
|
44
|
+
releaseIfIdle(bucketKey: string, bucket: BatchBucket): boolean;
|
|
45
|
+
}
|
|
46
|
+
export declare function createBatchTransportQueue({ options, baseFetch, bucketRegistry, }: CreateBatchTransportQueueOptions): (input: DataTransportRequestInfo, init?: RequestInit) => Promise<any>;
|
|
47
|
+
export {};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { DataBatchBody } from '../types';
|
|
2
|
+
export declare function toHeaderRecord(headers: HeadersInit | undefined): Record<string, string>;
|
|
3
|
+
export declare function measureTextBytes(value: string): number;
|
|
4
|
+
export declare function createBatchId(): string;
|
|
5
|
+
export declare function normalizeMethod(method: string | undefined): string;
|
|
6
|
+
export type PreparedBatchRequestBody = {
|
|
7
|
+
body: DataBatchBody | undefined;
|
|
8
|
+
inferredContentType: string | undefined;
|
|
9
|
+
batchable: boolean;
|
|
10
|
+
};
|
|
11
|
+
export declare function toRequestBody(initBody: BodyInit | null | undefined): Promise<PreparedBatchRequestBody>;
|
|
12
|
+
export declare function shouldBatchRequest(input: {
|
|
13
|
+
method: string;
|
|
14
|
+
body: string | undefined;
|
|
15
|
+
headers: Record<string, string>;
|
|
16
|
+
allowedMethods: Set<string>;
|
|
17
|
+
batchEndpoint: string;
|
|
18
|
+
requestUrl: URL;
|
|
19
|
+
}): boolean;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { DataBatchTransportEvent, DataBatchTransportTelemetryAttributes } from '../types';
|
|
2
|
+
export declare const DATA_BATCH_TRANSPORT_OTEL_EVENT = "modernjs.data.batch";
|
|
3
|
+
export declare function createDataBatchTransportTelemetryAttributes(event: DataBatchTransportEvent): DataBatchTransportTelemetryAttributes;
|
|
4
|
+
export declare function emitDataBatchTransportEvent(onEvent: ((event: DataBatchTransportEvent) => void) | undefined, event: DataBatchTransportEvent): void;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { DataTransportRequestInfo } from '../types';
|
|
2
|
+
export declare function resolveRuntimeOrigin(): string;
|
|
3
|
+
export declare function toAbsoluteUrl(input: DataTransportRequestInfo): URL;
|
|
4
|
+
export declare function normalizeBatchEndpoint(requestUrl: URL, endpoint: string | undefined): URL;
|
|
@@ -0,0 +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>;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { CacheScope, DataRequestMode, OperationDescriptor, RequestEnvelope, SelectionPlan } from './types';
|
|
2
|
+
export declare function isPlainObject(value: unknown): value is Record<string, unknown>;
|
|
3
|
+
export declare function stableStringify(value: unknown): string;
|
|
4
|
+
export declare function encodeRequestEnvelopeHeader(envelope: RequestEnvelope): string;
|
|
5
|
+
export declare function decodeRequestEnvelopeHeader(value: string): RequestEnvelope | null;
|
|
6
|
+
export declare function hashString(value: string): string;
|
|
7
|
+
export declare function sanitizeSegment(segment: string): string;
|
|
8
|
+
export declare function normalizeOrigin(origin: string): string;
|
|
9
|
+
export declare function createOperationId(input: OperationDescriptor): string;
|
|
10
|
+
export declare function buildScopeKey(scope: CacheScope): string;
|
|
11
|
+
export declare function buildQueryKey(input: {
|
|
12
|
+
operationId: string;
|
|
13
|
+
scopeKey: string;
|
|
14
|
+
requestMode?: DataRequestMode;
|
|
15
|
+
requestInput?: unknown;
|
|
16
|
+
selectionPlan?: SelectionPlan;
|
|
17
|
+
}): string;
|
|
@@ -0,0 +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';
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { CacheScope, InvalidationEvent, InvalidationSubscriber, OperationDescriptor } from './types';
|
|
2
|
+
export declare function createInvalidationEvent(input: {
|
|
3
|
+
sourceOperation: OperationDescriptor;
|
|
4
|
+
sourceScope: CacheScope;
|
|
5
|
+
targetNamespaces?: string[];
|
|
6
|
+
targetOperations?: OperationDescriptor[];
|
|
7
|
+
}): InvalidationEvent;
|
|
8
|
+
export declare function shouldApplyInvalidation(event: InvalidationEvent, subscriber: InvalidationSubscriber): boolean;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { TraceContext } from './types';
|
|
2
|
+
export declare function parseTraceparentHeader(header: string): TraceContext | null;
|
|
3
|
+
export declare function formatTraceparentHeader(trace: TraceContext): string;
|
|
4
|
+
export declare function deriveChildTraceContext(parent: TraceContext, childSpanId: string): TraceContext;
|
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Data-platform envelope (`x-modernjs-data-envelope`): the TRANSPORT/CACHE
|
|
3
|
+
* contract of the effect lane — protocol versioning, cache scope keys,
|
|
4
|
+
* selection plans, batching and hydration checksums.
|
|
5
|
+
*
|
|
6
|
+
* Boundary note (one envelope system per concern): cross-project
|
|
7
|
+
* AUTHORIZATION is the bff-core policy's job (`x-modernjs-bff-envelope` +
|
|
8
|
+
* operation contracts, evaluated server-side in both the hono and effect
|
|
9
|
+
* lanes). Nothing in this module is a trust boundary; treat every value
|
|
10
|
+
* here as client-asserted cache metadata.
|
|
11
|
+
*/
|
|
12
|
+
export type DataRequestMode = 'cache-first' | 'stale-while-revalidate' | 'network-only';
|
|
13
|
+
export type DataMutationMode = 'optimistic' | 'pessimistic' | 'fire-and-forget';
|
|
14
|
+
export type SelectionPlan = {
|
|
15
|
+
[field: string]: true | SelectionPlan;
|
|
16
|
+
};
|
|
17
|
+
export interface OperationDescriptor {
|
|
18
|
+
appNamespace: string;
|
|
19
|
+
apiId: string;
|
|
20
|
+
group: string;
|
|
21
|
+
endpoint: string;
|
|
22
|
+
schemaHash?: string;
|
|
23
|
+
version?: number;
|
|
24
|
+
}
|
|
25
|
+
export interface CacheScope {
|
|
26
|
+
appNamespace: string;
|
|
27
|
+
origin: string;
|
|
28
|
+
tenantId?: string;
|
|
29
|
+
userId?: string;
|
|
30
|
+
sessionId?: string;
|
|
31
|
+
}
|
|
32
|
+
export interface TraceContext {
|
|
33
|
+
traceId: string;
|
|
34
|
+
spanId: string;
|
|
35
|
+
sampled: boolean;
|
|
36
|
+
parentSpanId?: string;
|
|
37
|
+
}
|
|
38
|
+
export interface RequestEnvelope<Input = unknown> {
|
|
39
|
+
protocolVersion: 1;
|
|
40
|
+
operationId: string;
|
|
41
|
+
appNamespace: string;
|
|
42
|
+
origin: string;
|
|
43
|
+
requestMode: DataRequestMode;
|
|
44
|
+
mutationMode?: DataMutationMode;
|
|
45
|
+
scopeKey: string;
|
|
46
|
+
input: Input;
|
|
47
|
+
inputHash: string;
|
|
48
|
+
selectionPlan?: SelectionPlan;
|
|
49
|
+
selectionHash?: string;
|
|
50
|
+
traceparent?: string;
|
|
51
|
+
timestamp: number;
|
|
52
|
+
}
|
|
53
|
+
export interface HydrationEnvelope<Payload = unknown> {
|
|
54
|
+
protocolVersion: 1;
|
|
55
|
+
runtimeVersion: string;
|
|
56
|
+
appNamespace: string;
|
|
57
|
+
origin: string;
|
|
58
|
+
createdAt: number;
|
|
59
|
+
payload: Payload;
|
|
60
|
+
checksum: string;
|
|
61
|
+
}
|
|
62
|
+
export interface InvalidationEvent {
|
|
63
|
+
sourceNamespace: string;
|
|
64
|
+
sourceOperationId: string;
|
|
65
|
+
scopeKey: string;
|
|
66
|
+
targetNamespaces?: string[];
|
|
67
|
+
targetOperationIds?: string[];
|
|
68
|
+
}
|
|
69
|
+
export interface InvalidationSubscriber {
|
|
70
|
+
namespace: string;
|
|
71
|
+
operationIds?: string[];
|
|
72
|
+
scopeKey?: string;
|
|
73
|
+
acceptCrossNamespace?: boolean;
|
|
74
|
+
}
|
|
75
|
+
export interface DataBatchRequestItem {
|
|
76
|
+
id: string;
|
|
77
|
+
path: string;
|
|
78
|
+
method: string;
|
|
79
|
+
headers?: Record<string, string>;
|
|
80
|
+
body?: DataBatchBody;
|
|
81
|
+
}
|
|
82
|
+
export interface DataBatchRequestPayload {
|
|
83
|
+
protocolVersion: 2;
|
|
84
|
+
batchId: string;
|
|
85
|
+
sentAt: number;
|
|
86
|
+
items: DataBatchRequestItem[];
|
|
87
|
+
}
|
|
88
|
+
export interface DataBatchResponseItem {
|
|
89
|
+
id: string;
|
|
90
|
+
status: number;
|
|
91
|
+
headers?: DataBatchHeader[];
|
|
92
|
+
body?: DataBatchBody;
|
|
93
|
+
}
|
|
94
|
+
export interface DataBatchBody {
|
|
95
|
+
encoding: 'base64';
|
|
96
|
+
data: string;
|
|
97
|
+
}
|
|
98
|
+
export type DataBatchHeader = [name: string, value: string];
|
|
99
|
+
export interface DataBatchResponsePayload {
|
|
100
|
+
protocolVersion: 2;
|
|
101
|
+
batchId: string;
|
|
102
|
+
receivedAt: number;
|
|
103
|
+
items: DataBatchResponseItem[];
|
|
104
|
+
}
|
|
105
|
+
export interface DataBatchTransportEvent {
|
|
106
|
+
type: 'enqueue' | 'flush' | 'fallback' | 'disable';
|
|
107
|
+
endpoint: string;
|
|
108
|
+
batchId?: string;
|
|
109
|
+
size?: number;
|
|
110
|
+
reason?: string;
|
|
111
|
+
}
|
|
112
|
+
export type DataBatchTransportTelemetryAttributes = Record<string, string | number | boolean>;
|
|
113
|
+
export interface DataBatchTransportOptions {
|
|
114
|
+
endpoint?: string;
|
|
115
|
+
fetch?: (input: DataTransportRequestInfo, init?: RequestInit) => Promise<Response>;
|
|
116
|
+
flushIntervalMs?: number;
|
|
117
|
+
maxBatchSize?: number;
|
|
118
|
+
maxBatchBytes?: number;
|
|
119
|
+
requestTimeoutMs?: number;
|
|
120
|
+
allowedMethods?: string[];
|
|
121
|
+
onEvent?: (event: DataBatchTransportEvent) => void;
|
|
122
|
+
}
|
|
123
|
+
export interface SelectionPlanValidationOptions {
|
|
124
|
+
maxDepth?: number;
|
|
125
|
+
maxFields?: number;
|
|
126
|
+
allowedLeafPaths?: ReadonlyArray<string>;
|
|
127
|
+
}
|
|
128
|
+
export interface SelectionPlanValidationResult {
|
|
129
|
+
ok: boolean;
|
|
130
|
+
errors: string[];
|
|
131
|
+
stats: {
|
|
132
|
+
maxDepth: number;
|
|
133
|
+
fieldCount: number;
|
|
134
|
+
};
|
|
135
|
+
}
|
|
136
|
+
export interface RequestEnvelopeValidationOptions {
|
|
137
|
+
expectedProtocolVersion?: number;
|
|
138
|
+
expectedNamespace?: string;
|
|
139
|
+
expectedOrigin?: string;
|
|
140
|
+
requireTraceContext?: boolean;
|
|
141
|
+
}
|
|
142
|
+
export interface HydrationEnvelopeValidationOptions {
|
|
143
|
+
expectedProtocolVersion?: number;
|
|
144
|
+
expectedNamespace?: string;
|
|
145
|
+
expectedOrigin?: string;
|
|
146
|
+
expectedRuntimeVersion?: string;
|
|
147
|
+
}
|
|
148
|
+
export declare const DEFAULT_DATA_ENVELOPE_HEADER = "x-modernjs-data-envelope";
|
|
149
|
+
export declare const DEFAULT_DATA_BATCH_ENDPOINT = "/_data/batch";
|
|
150
|
+
export declare const DEFAULT_DATA_BATCH_HEADER = "x-modernjs-data-batch";
|
|
151
|
+
export type DataTransportRequestInfo = string | URL | Request;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import type { CacheScope, DataMutationMode, DataRequestMode, HydrationEnvelope, HydrationEnvelopeValidationOptions, OperationDescriptor, RequestEnvelope, RequestEnvelopeValidationOptions, SelectionPlan, SelectionPlanValidationOptions, SelectionPlanValidationResult, TraceContext } from './types';
|
|
2
|
+
export declare function validateSelectionPlan(plan: SelectionPlan, options?: SelectionPlanValidationOptions): SelectionPlanValidationResult;
|
|
3
|
+
export declare function createRequestEnvelope<Input>(input: {
|
|
4
|
+
operation: OperationDescriptor;
|
|
5
|
+
scope: CacheScope;
|
|
6
|
+
requestInput: Input;
|
|
7
|
+
selectionPlan?: SelectionPlan;
|
|
8
|
+
requestMode?: DataRequestMode;
|
|
9
|
+
mutationMode?: DataMutationMode;
|
|
10
|
+
traceContext?: TraceContext;
|
|
11
|
+
requireTraceContext?: boolean;
|
|
12
|
+
timestamp?: number;
|
|
13
|
+
protocolVersion?: 1;
|
|
14
|
+
}): RequestEnvelope<Input>;
|
|
15
|
+
export declare function validateRequestEnvelope(envelope: RequestEnvelope, options?: RequestEnvelopeValidationOptions): {
|
|
16
|
+
ok: boolean;
|
|
17
|
+
errors: string[];
|
|
18
|
+
};
|
|
19
|
+
export declare function createHydrationEnvelope<Payload>(input: {
|
|
20
|
+
runtimeVersion: string;
|
|
21
|
+
scope: Pick<CacheScope, 'appNamespace' | 'origin'>;
|
|
22
|
+
payload: Payload;
|
|
23
|
+
createdAt?: number;
|
|
24
|
+
protocolVersion?: 1;
|
|
25
|
+
}): HydrationEnvelope<Payload>;
|
|
26
|
+
export declare function validateHydrationEnvelope(envelope: HydrationEnvelope, options?: HydrationEnvelopeValidationOptions): {
|
|
27
|
+
ok: boolean;
|
|
28
|
+
errors: string[];
|
|
29
|
+
};
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { type EffectContext } from './operation-context';
|
|
2
|
+
export { type CreateEffectOperationContextOptions, createEffectOperationContext, type EffectContext, } from './operation-context';
|
|
3
|
+
export declare const runWithEffectContext: <T>(context: EffectContext, cb: () => T) => T;
|
|
4
|
+
export declare const useEffectContext: () => EffectContext;
|
|
5
|
+
export declare const useOperationContext: () => import("@modern-js/create-request").OperationContext;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { EffectBffRequestHandler } from './module';
|
|
2
|
+
import { type EffectContext } from './operation-context';
|
|
3
|
+
type EffectDispatchContextRunner = <T>(context: EffectContext, cb: () => T) => T;
|
|
4
|
+
export type DispatchEffectBffRequestOptions = {
|
|
5
|
+
prefix?: string;
|
|
6
|
+
env?: Record<string, unknown>;
|
|
7
|
+
path?: string;
|
|
8
|
+
method?: string;
|
|
9
|
+
runWithEffectContext: EffectDispatchContextRunner;
|
|
10
|
+
onError?: (error: unknown, context: EffectContext) => Promise<Response> | Response;
|
|
11
|
+
};
|
|
12
|
+
export declare function dispatchEffectBffRequestWithContext(handler: EffectBffRequestHandler, request: Request, options: DispatchEffectBffRequestOptions): Promise<Response>;
|
|
13
|
+
export {};
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { type EffectContext } from './operation-context';
|
|
2
|
+
export { type CreateEffectOperationContextOptions, createEffectOperationContext, type EffectContext, } from './operation-context';
|
|
3
|
+
export declare const runWithEffectContext: <T>(context: EffectContext, cb: () => T) => T;
|
|
4
|
+
export declare const useEffectContext: () => EffectContext;
|
|
5
|
+
export declare const useOperationContext: () => import("@modern-js/create-request").OperationContext;
|