@bleedingdev/modern-js-plugin-bff 3.5.0-ultramodern.30 → 3.5.0-ultramodern.31
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/cli/compress.js +52 -0
- package/dist/cjs/cli/generator.js +149 -0
- package/dist/cjs/cli/prefix.js +50 -0
- package/dist/cjs/cli/watch.js +51 -0
- package/dist/cjs/cli.js +11 -130
- package/dist/cjs/runtime/data-platform/batch/queue.js +287 -0
- package/dist/cjs/runtime/data-platform/batch/request.js +98 -0
- package/dist/cjs/runtime/data-platform/batch/response.js +67 -0
- package/dist/cjs/runtime/data-platform/batch/telemetry.js +67 -0
- package/dist/cjs/runtime/data-platform/batch/url.js +69 -0
- package/dist/cjs/runtime/data-platform/batch-transport.js +59 -0
- package/dist/cjs/runtime/data-platform/codec.js +155 -0
- package/dist/cjs/runtime/data-platform/index.js +30 -633
- package/dist/cjs/runtime/data-platform/invalidation.js +61 -0
- package/dist/cjs/runtime/data-platform/trace.js +73 -0
- package/dist/cjs/runtime/data-platform/types.js +48 -0
- package/dist/cjs/runtime/data-platform/validation.js +178 -0
- package/dist/cjs/runtime/effect/adapter/constants.js +44 -0
- package/dist/cjs/runtime/effect/adapter/cross-project-policy.js +61 -0
- package/dist/cjs/runtime/effect/adapter/entry.js +77 -0
- package/dist/cjs/runtime/effect/adapter/error-response.js +79 -0
- package/dist/cjs/runtime/effect/adapter/handler.js +53 -0
- package/dist/cjs/runtime/effect/adapter.js +12 -115
- package/dist/cjs/runtime/effect/backend-federation/entry.js +99 -0
- package/dist/cjs/runtime/effect/backend-federation/load.js +57 -0
- package/dist/cjs/runtime/effect/backend-federation/plugin.js +53 -0
- package/dist/cjs/runtime/effect/backend-federation/remotes.js +50 -0
- package/dist/cjs/runtime/effect/backend-federation/runtime.js +64 -0
- package/dist/cjs/runtime/effect/backend-federation/types.js +18 -0
- package/dist/cjs/runtime/effect/backend-federation/utils.js +48 -0
- package/dist/cjs/runtime/effect/backend-federation-manifest/errors.js +83 -0
- package/dist/cjs/runtime/effect/backend-federation-manifest/index.js +55 -0
- package/dist/cjs/runtime/effect/backend-federation-manifest/load.js +74 -0
- package/dist/cjs/runtime/effect/backend-federation-manifest/metadata.js +101 -0
- package/dist/cjs/runtime/effect/backend-federation-manifest/reference.js +117 -0
- package/dist/cjs/runtime/effect/backend-federation-manifest/remote.js +68 -0
- package/dist/cjs/runtime/effect/backend-federation-manifest/types.js +18 -0
- package/dist/cjs/runtime/effect/backend-federation-manifest/validation.js +108 -0
- package/dist/cjs/runtime/effect/backend-federation-manifest.js +32 -257
- package/dist/cjs/runtime/effect/backend-federation.js +11 -139
- package/dist/cjs/runtime/effect/handler/batch-handler.js +161 -0
- package/dist/cjs/runtime/effect/handler/batch.js +195 -0
- package/dist/cjs/runtime/effect/handler/definition.js +101 -0
- package/dist/cjs/runtime/effect/handler/envelope.js +104 -0
- package/dist/cjs/runtime/effect/handler/http.js +96 -0
- package/dist/cjs/runtime/effect/handler/openapi.js +57 -0
- package/dist/cjs/runtime/effect/handler/routing.js +100 -0
- package/dist/cjs/runtime/effect/handler/rpc.js +63 -0
- package/dist/cjs/runtime/effect/handler/types.js +43 -0
- package/dist/cjs/runtime/effect/handler.js +35 -526
- package/dist/cjs/runtime/effect/rpcSerialization.js +54 -0
- package/dist/cjs/runtime/effect-client/batch.js +73 -0
- package/dist/cjs/runtime/effect-client/envelope.js +145 -0
- package/dist/cjs/runtime/effect-client/guards.js +44 -0
- package/dist/cjs/runtime/effect-client/index.js +6 -16
- package/dist/cjs/runtime/effect-client/request-context.js +64 -0
- package/dist/cjs/runtime/effect-client/request.js +66 -0
- package/dist/cjs/runtime/effect-client/runtime.js +12 -178
- package/dist/cjs/runtime/effect-client/types.js +18 -0
- package/dist/cjs/runtime/safe-failure.js +2 -1
- package/dist/cjs/utils/client-generator/files.js +152 -0
- package/dist/cjs/utils/client-generator/generate.js +138 -0
- package/dist/cjs/utils/client-generator/index.js +83 -0
- package/dist/cjs/utils/client-generator/package-json.js +132 -0
- package/dist/cjs/utils/client-generator/write-package.js +125 -0
- package/dist/cjs/utils/clientGenerator.js +26 -303
- package/dist/cjs/utils/effect-client-generator/generator.js +64 -0
- package/dist/cjs/utils/effect-client-generator/index.js +51 -0
- package/dist/cjs/utils/effect-client-generator/paths.js +73 -0
- package/dist/cjs/utils/effect-client-generator/rendering.js +231 -0
- package/dist/cjs/utils/effect-client-generator/runtime.js +84 -0
- package/dist/cjs/utils/effect-client-generator/types.js +18 -0
- package/dist/cjs/utils/effectClientGenerator.js +5 -262
- package/dist/esm/cli/compress.mjs +14 -0
- package/dist/esm/cli/generator.mjs +98 -0
- package/dist/esm/cli/prefix.mjs +9 -0
- package/dist/esm/cli/watch.mjs +13 -0
- package/dist/esm/cli.mjs +7 -121
- package/dist/esm/runtime/data-platform/batch/queue.mjs +246 -0
- package/dist/esm/runtime/data-platform/batch/request.mjs +45 -0
- package/dist/esm/runtime/data-platform/batch/response.mjs +23 -0
- package/dist/esm/runtime/data-platform/batch/telemetry.mjs +23 -0
- package/dist/esm/runtime/data-platform/batch/url.mjs +25 -0
- package/dist/esm/runtime/data-platform/batch-transport.mjs +12 -0
- package/dist/esm/runtime/data-platform/codec.mjs +90 -0
- package/dist/esm/runtime/data-platform/index.mjs +6 -610
- package/dist/esm/runtime/data-platform/invalidation.mjs +20 -0
- package/dist/esm/runtime/data-platform/trace.mjs +29 -0
- package/dist/esm/runtime/data-platform/types.mjs +4 -0
- package/dist/esm/runtime/data-platform/validation.mjs +128 -0
- package/dist/esm/runtime/effect/adapter/constants.mjs +6 -0
- package/dist/esm/runtime/effect/adapter/cross-project-policy.mjs +23 -0
- package/dist/esm/runtime/effect/adapter/entry.mjs +29 -0
- package/dist/esm/runtime/effect/adapter/error-response.mjs +41 -0
- package/dist/esm/runtime/effect/adapter/handler.mjs +15 -0
- package/dist/esm/runtime/effect/adapter.mjs +12 -105
- package/dist/esm/runtime/effect/backend-federation/entry.mjs +61 -0
- package/dist/esm/runtime/effect/backend-federation/load.mjs +19 -0
- package/dist/esm/runtime/effect/backend-federation/plugin.mjs +15 -0
- package/dist/esm/runtime/effect/backend-federation/remotes.mjs +12 -0
- package/dist/esm/runtime/effect/backend-federation/runtime.mjs +26 -0
- package/dist/esm/runtime/effect/backend-federation/types.mjs +0 -0
- package/dist/esm/runtime/effect/backend-federation/utils.mjs +7 -0
- package/dist/esm/runtime/effect/backend-federation-manifest/errors.mjs +32 -0
- package/dist/esm/runtime/effect/backend-federation-manifest/index.mjs +4 -0
- package/dist/esm/runtime/effect/backend-federation-manifest/load.mjs +36 -0
- package/dist/esm/runtime/effect/backend-federation-manifest/metadata.mjs +42 -0
- package/dist/esm/runtime/effect/backend-federation-manifest/reference.mjs +76 -0
- package/dist/esm/runtime/effect/backend-federation-manifest/remote.mjs +30 -0
- package/dist/esm/runtime/effect/backend-federation-manifest/types.mjs +0 -0
- package/dist/esm/runtime/effect/backend-federation-manifest/validation.mjs +64 -0
- package/dist/esm/runtime/effect/backend-federation-manifest.mjs +1 -237
- package/dist/esm/runtime/effect/backend-federation.mjs +4 -132
- package/dist/esm/runtime/effect/handler/batch-handler.mjs +123 -0
- package/dist/esm/runtime/effect/handler/batch.mjs +124 -0
- package/dist/esm/runtime/effect/handler/definition.mjs +60 -0
- package/dist/esm/runtime/effect/handler/envelope.mjs +63 -0
- package/dist/esm/runtime/effect/handler/http.mjs +58 -0
- package/dist/esm/runtime/effect/handler/openapi.mjs +19 -0
- package/dist/esm/runtime/effect/handler/routing.mjs +50 -0
- package/dist/esm/runtime/effect/handler/rpc.mjs +22 -0
- package/dist/esm/runtime/effect/handler/types.mjs +5 -0
- package/dist/esm/runtime/effect/handler.mjs +7 -499
- package/dist/esm/runtime/effect/rpcSerialization.mjs +16 -0
- package/dist/esm/runtime/effect-client/batch.mjs +35 -0
- package/dist/esm/runtime/effect-client/envelope.mjs +104 -0
- package/dist/esm/runtime/effect-client/guards.mjs +3 -0
- package/dist/esm/runtime/effect-client/index.mjs +5 -15
- package/dist/esm/runtime/effect-client/request-context.mjs +23 -0
- package/dist/esm/runtime/effect-client/request.mjs +28 -0
- package/dist/esm/runtime/effect-client/runtime.mjs +12 -178
- package/dist/esm/runtime/effect-client/types.mjs +0 -0
- package/dist/esm/runtime/safe-failure.mjs +2 -1
- package/dist/esm/utils/client-generator/files.mjs +68 -0
- package/dist/esm/utils/client-generator/generate.mjs +88 -0
- package/dist/esm/utils/client-generator/index.mjs +4 -0
- package/dist/esm/utils/client-generator/package-json.mjs +78 -0
- package/dist/esm/utils/client-generator/write-package.mjs +74 -0
- package/dist/esm/utils/clientGenerator.mjs +2 -293
- package/dist/esm/utils/effect-client-generator/generator.mjs +23 -0
- package/dist/esm/utils/effect-client-generator/index.mjs +3 -0
- package/dist/esm/utils/effect-client-generator/paths.mjs +25 -0
- package/dist/esm/utils/effect-client-generator/rendering.mjs +180 -0
- package/dist/esm/utils/effect-client-generator/runtime.mjs +33 -0
- package/dist/esm/utils/effect-client-generator/types.mjs +0 -0
- package/dist/esm/utils/effectClientGenerator.mjs +1 -249
- package/dist/esm-node/cli/compress.mjs +15 -0
- package/dist/esm-node/cli/generator.mjs +99 -0
- package/dist/esm-node/cli/prefix.mjs +10 -0
- package/dist/esm-node/cli/watch.mjs +14 -0
- package/dist/esm-node/cli.mjs +7 -121
- package/dist/esm-node/runtime/data-platform/batch/queue.mjs +247 -0
- package/dist/esm-node/runtime/data-platform/batch/request.mjs +46 -0
- package/dist/esm-node/runtime/data-platform/batch/response.mjs +24 -0
- package/dist/esm-node/runtime/data-platform/batch/telemetry.mjs +24 -0
- package/dist/esm-node/runtime/data-platform/batch/url.mjs +26 -0
- package/dist/esm-node/runtime/data-platform/batch-transport.mjs +13 -0
- package/dist/esm-node/runtime/data-platform/codec.mjs +91 -0
- package/dist/esm-node/runtime/data-platform/index.mjs +6 -610
- package/dist/esm-node/runtime/data-platform/invalidation.mjs +21 -0
- package/dist/esm-node/runtime/data-platform/trace.mjs +30 -0
- package/dist/esm-node/runtime/data-platform/types.mjs +5 -0
- package/dist/esm-node/runtime/data-platform/validation.mjs +129 -0
- package/dist/esm-node/runtime/effect/adapter/constants.mjs +7 -0
- package/dist/esm-node/runtime/effect/adapter/cross-project-policy.mjs +24 -0
- package/dist/esm-node/runtime/effect/adapter/entry.mjs +30 -0
- package/dist/esm-node/runtime/effect/adapter/error-response.mjs +42 -0
- package/dist/esm-node/runtime/effect/adapter/handler.mjs +16 -0
- package/dist/esm-node/runtime/effect/adapter.mjs +12 -105
- package/dist/esm-node/runtime/effect/backend-federation/entry.mjs +62 -0
- package/dist/esm-node/runtime/effect/backend-federation/load.mjs +20 -0
- package/dist/esm-node/runtime/effect/backend-federation/plugin.mjs +16 -0
- package/dist/esm-node/runtime/effect/backend-federation/remotes.mjs +13 -0
- package/dist/esm-node/runtime/effect/backend-federation/runtime.mjs +27 -0
- package/dist/esm-node/runtime/effect/backend-federation/types.mjs +1 -0
- package/dist/esm-node/runtime/effect/backend-federation/utils.mjs +8 -0
- package/dist/esm-node/runtime/effect/backend-federation-manifest/errors.mjs +33 -0
- package/dist/esm-node/runtime/effect/backend-federation-manifest/index.mjs +5 -0
- package/dist/esm-node/runtime/effect/backend-federation-manifest/load.mjs +37 -0
- package/dist/esm-node/runtime/effect/backend-federation-manifest/metadata.mjs +43 -0
- package/dist/esm-node/runtime/effect/backend-federation-manifest/reference.mjs +77 -0
- package/dist/esm-node/runtime/effect/backend-federation-manifest/remote.mjs +31 -0
- package/dist/esm-node/runtime/effect/backend-federation-manifest/types.mjs +1 -0
- package/dist/esm-node/runtime/effect/backend-federation-manifest/validation.mjs +65 -0
- package/dist/esm-node/runtime/effect/backend-federation-manifest.mjs +1 -237
- package/dist/esm-node/runtime/effect/backend-federation.mjs +4 -132
- package/dist/esm-node/runtime/effect/handler/batch-handler.mjs +124 -0
- package/dist/esm-node/runtime/effect/handler/batch.mjs +125 -0
- package/dist/esm-node/runtime/effect/handler/definition.mjs +61 -0
- package/dist/esm-node/runtime/effect/handler/envelope.mjs +64 -0
- package/dist/esm-node/runtime/effect/handler/http.mjs +59 -0
- package/dist/esm-node/runtime/effect/handler/openapi.mjs +20 -0
- package/dist/esm-node/runtime/effect/handler/routing.mjs +51 -0
- package/dist/esm-node/runtime/effect/handler/rpc.mjs +23 -0
- package/dist/esm-node/runtime/effect/handler/types.mjs +6 -0
- package/dist/esm-node/runtime/effect/handler.mjs +7 -499
- package/dist/esm-node/runtime/effect/rpcSerialization.mjs +17 -0
- package/dist/esm-node/runtime/effect-client/batch.mjs +36 -0
- package/dist/esm-node/runtime/effect-client/envelope.mjs +105 -0
- package/dist/esm-node/runtime/effect-client/guards.mjs +4 -0
- package/dist/esm-node/runtime/effect-client/index.mjs +5 -15
- package/dist/esm-node/runtime/effect-client/request-context.mjs +24 -0
- package/dist/esm-node/runtime/effect-client/request.mjs +29 -0
- package/dist/esm-node/runtime/effect-client/runtime.mjs +12 -178
- package/dist/esm-node/runtime/effect-client/types.mjs +1 -0
- package/dist/esm-node/runtime/safe-failure.mjs +2 -1
- package/dist/esm-node/utils/client-generator/files.mjs +69 -0
- package/dist/esm-node/utils/client-generator/generate.mjs +89 -0
- package/dist/esm-node/utils/client-generator/index.mjs +5 -0
- package/dist/esm-node/utils/client-generator/package-json.mjs +79 -0
- package/dist/esm-node/utils/client-generator/write-package.mjs +75 -0
- package/dist/esm-node/utils/clientGenerator.mjs +2 -293
- package/dist/esm-node/utils/effect-client-generator/generator.mjs +24 -0
- package/dist/esm-node/utils/effect-client-generator/index.mjs +4 -0
- package/dist/esm-node/utils/effect-client-generator/paths.mjs +26 -0
- package/dist/esm-node/utils/effect-client-generator/rendering.mjs +181 -0
- package/dist/esm-node/utils/effect-client-generator/runtime.mjs +35 -0
- package/dist/esm-node/utils/effect-client-generator/types.mjs +1 -0
- package/dist/esm-node/utils/effectClientGenerator.mjs +2 -251
- package/dist/types/cli/compress.d.ts +2 -0
- package/dist/types/cli/generator.d.ts +7 -0
- package/dist/types/cli/prefix.d.ts +2 -0
- package/dist/types/cli/watch.d.ts +1 -0
- package/dist/types/cli.d.ts +0 -1
- package/dist/types/runtime/data-platform/batch/queue.d.ts +25 -0
- package/dist/types/runtime/data-platform/batch/request.d.ts +13 -0
- package/dist/types/runtime/data-platform/batch/response.d.ts +4 -0
- package/dist/types/runtime/data-platform/batch/telemetry.d.ts +4 -0
- package/dist/types/runtime/data-platform/batch/url.d.ts +4 -0
- package/dist/types/runtime/data-platform/batch-transport.d.ts +3 -0
- package/dist/types/runtime/data-platform/codec.d.ts +17 -0
- package/dist/types/runtime/data-platform/index.d.ts +7 -191
- package/dist/types/runtime/data-platform/invalidation.d.ts +8 -0
- package/dist/types/runtime/data-platform/trace.d.ts +4 -0
- package/dist/types/runtime/data-platform/types.d.ts +146 -0
- package/dist/types/runtime/data-platform/validation.d.ts +29 -0
- package/dist/types/runtime/effect/adapter/constants.d.ts +1 -0
- package/dist/types/runtime/effect/adapter/cross-project-policy.d.ts +4 -0
- package/dist/types/runtime/effect/adapter/entry.d.ts +2 -0
- package/dist/types/runtime/effect/adapter/error-response.d.ts +2 -0
- package/dist/types/runtime/effect/adapter/handler.d.ts +4 -0
- package/dist/types/runtime/effect/adapter.d.ts +4 -13
- package/dist/types/runtime/effect/backend-federation/entry.d.ts +2 -0
- package/dist/types/runtime/effect/backend-federation/load.d.ts +2 -0
- package/dist/types/runtime/effect/backend-federation/plugin.d.ts +3 -0
- package/dist/types/runtime/effect/backend-federation/remotes.d.ts +2 -0
- package/dist/types/runtime/effect/backend-federation/runtime.d.ts +3 -0
- package/dist/types/runtime/effect/backend-federation/types.d.ts +58 -0
- package/dist/types/runtime/effect/backend-federation/utils.d.ts +2 -0
- package/dist/types/runtime/effect/backend-federation-manifest/errors.d.ts +11 -0
- package/dist/types/runtime/effect/backend-federation-manifest/index.d.ts +6 -0
- package/dist/types/runtime/effect/backend-federation-manifest/load.d.ts +3 -0
- package/dist/types/runtime/effect/backend-federation-manifest/metadata.d.ts +18 -0
- package/dist/types/runtime/effect/backend-federation-manifest/reference.d.ts +3 -0
- package/dist/types/runtime/effect/backend-federation-manifest/remote.d.ts +3 -0
- package/dist/types/runtime/effect/backend-federation-manifest/types.d.ts +51 -0
- package/dist/types/runtime/effect/backend-federation-manifest/validation.d.ts +5 -0
- package/dist/types/runtime/effect/backend-federation-manifest.d.ts +1 -60
- package/dist/types/runtime/effect/backend-federation.d.ts +6 -60
- package/dist/types/runtime/effect/handler/batch-handler.d.ts +11 -0
- package/dist/types/runtime/effect/handler/batch.d.ts +17 -0
- package/dist/types/runtime/effect/handler/definition.d.ts +17 -0
- package/dist/types/runtime/effect/handler/envelope.d.ts +13 -0
- package/dist/types/runtime/effect/handler/http.d.ts +14 -0
- package/dist/types/runtime/effect/handler/openapi.d.ts +4 -0
- package/dist/types/runtime/effect/handler/routing.d.ts +5 -0
- package/dist/types/runtime/effect/handler/rpc.d.ts +7 -0
- package/dist/types/runtime/effect/handler/types.d.ts +148 -0
- package/dist/types/runtime/effect/handler.d.ts +3 -173
- package/dist/types/runtime/effect/rpcSerialization.d.ts +3 -0
- package/dist/types/runtime/effect-client/batch.d.ts +2 -0
- package/dist/types/runtime/effect-client/envelope.d.ts +15 -0
- package/dist/types/runtime/effect-client/guards.d.ts +2 -0
- package/dist/types/runtime/effect-client/request-context.d.ts +3 -0
- package/dist/types/runtime/effect-client/request.d.ts +1 -0
- package/dist/types/runtime/effect-client/runtime.d.ts +2 -68
- package/dist/types/runtime/effect-client/types.d.ts +68 -0
- package/dist/types/utils/client-generator/files.d.ts +28 -0
- package/dist/types/utils/client-generator/generate.d.ts +26 -0
- package/dist/types/utils/client-generator/index.d.ts +7 -0
- package/dist/types/utils/client-generator/package-json.d.ts +16 -0
- package/dist/types/utils/client-generator/write-package.d.ts +6 -0
- package/dist/types/utils/clientGenerator.d.ts +2 -37
- package/dist/types/utils/crossProjectServerPolicy.d.ts +3 -2
- package/dist/types/utils/effect-client-generator/generator.d.ts +10 -0
- package/dist/types/utils/effect-client-generator/index.d.ts +4 -0
- package/dist/types/utils/effect-client-generator/paths.d.ts +5 -0
- package/dist/types/utils/effect-client-generator/rendering.d.ts +4 -0
- package/dist/types/utils/effect-client-generator/runtime.d.ts +8 -0
- package/dist/types/utils/effect-client-generator/types.d.ts +26 -0
- package/dist/types/utils/effectClientGenerator.d.ts +2 -41
- package/package.json +12 -12
|
@@ -1,251 +1,2 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
import { deriveOperationVersion } from "@modern-js/bff-core";
|
|
4
|
-
import { compatibleRequire, findExists, fs, logger } from "@modern-js/utils";
|
|
5
|
-
import path from "path";
|
|
6
|
-
import { collectEffectEndpoints, createEffectEndpointContractHash, ensureLeadingSlash, extractHttpApiFromModule, normalizeEffectPrefix } from "../runtime/effect/endpoint-contracts.mjs";
|
|
7
|
-
const JS_OR_TS_EXTS = [
|
|
8
|
-
'.js',
|
|
9
|
-
'.jsx',
|
|
10
|
-
'.ts',
|
|
11
|
-
'.tsx',
|
|
12
|
-
'.mjs',
|
|
13
|
-
'.mts',
|
|
14
|
-
'.cjs',
|
|
15
|
-
'.cts'
|
|
16
|
-
];
|
|
17
|
-
const DEFAULT_REQUEST_CREATOR = '@modern-js/plugin-bff/client';
|
|
18
|
-
const EFFECT_CLIENT_RUNTIME_IMPORT = '@modern-js/plugin-bff/effect-client-runtime';
|
|
19
|
-
let httpApiRuntimePromise;
|
|
20
|
-
function isRecord(value) {
|
|
21
|
-
return 'object' == typeof value && null !== value;
|
|
22
|
-
}
|
|
23
|
-
function isAbsoluteUrl(value) {
|
|
24
|
-
try {
|
|
25
|
-
new URL(value);
|
|
26
|
-
return true;
|
|
27
|
-
} catch {
|
|
28
|
-
return false;
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
function resolveBatchEndpoint(prefix, endpoint) {
|
|
32
|
-
const value = endpoint || '/_data/batch';
|
|
33
|
-
if (isAbsoluteUrl(value)) return value;
|
|
34
|
-
const normalizedPrefix = normalizeEffectPrefix(prefix);
|
|
35
|
-
const normalizedEndpoint = ensureLeadingSlash(value);
|
|
36
|
-
if (!normalizedPrefix) return normalizedEndpoint;
|
|
37
|
-
if (normalizedEndpoint === normalizedPrefix || normalizedEndpoint.startsWith(`${normalizedPrefix}/`)) return normalizedEndpoint;
|
|
38
|
-
return `${normalizedPrefix}${'/' === normalizedEndpoint ? '' : normalizedEndpoint}`;
|
|
39
|
-
}
|
|
40
|
-
function getPackageInfo(appDir) {
|
|
41
|
-
try {
|
|
42
|
-
const packageJsonPath = path.resolve(appDir, './package.json');
|
|
43
|
-
const packageJson = fs.readJSONSync(packageJsonPath);
|
|
44
|
-
return {
|
|
45
|
-
name: packageJson.name,
|
|
46
|
-
version: packageJson.version
|
|
47
|
-
};
|
|
48
|
-
} catch {
|
|
49
|
-
return {};
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
async function getHttpApiRuntime() {
|
|
53
|
-
if (!httpApiRuntimePromise) httpApiRuntimePromise = (async ()=>{
|
|
54
|
-
let mod;
|
|
55
|
-
try {
|
|
56
|
-
mod = await compatibleRequire('effect/unstable/httpapi', false);
|
|
57
|
-
} catch (error) {
|
|
58
|
-
const message = error instanceof Error ? error.message : String(error);
|
|
59
|
-
if (!message.includes("Cannot find module 'effect/unstable/httpapi'")) throw error;
|
|
60
|
-
const effectPackageJson = require.resolve('effect/package.json');
|
|
61
|
-
const effectHttpApiRuntimePath = path.join(path.dirname(effectPackageJson), 'dist', 'unstable', 'httpapi', 'index.js');
|
|
62
|
-
mod = await compatibleRequire(effectHttpApiRuntimePath, false);
|
|
63
|
-
}
|
|
64
|
-
if (isRecord(mod) && isRecord(mod.HttpApi)) {
|
|
65
|
-
const maybeHttpApi = mod.HttpApi;
|
|
66
|
-
if ('function' == typeof maybeHttpApi.isHttpApi && 'function' == typeof maybeHttpApi.reflect) return maybeHttpApi;
|
|
67
|
-
}
|
|
68
|
-
throw new Error('[BFF][Effect] Unable to resolve HttpApi runtime from effect/unstable/httpapi.');
|
|
69
|
-
})();
|
|
70
|
-
return httpApiRuntimePromise;
|
|
71
|
-
}
|
|
72
|
-
async function loadEffectApi(resourcePath) {
|
|
73
|
-
const httpApiRuntime = await getHttpApiRuntime();
|
|
74
|
-
const mod = await compatibleRequire(resourcePath, false);
|
|
75
|
-
return extractHttpApiFromModule(mod, httpApiRuntime.isHttpApi);
|
|
76
|
-
}
|
|
77
|
-
function renderEffectClientCode(endpoints, options) {
|
|
78
|
-
const requestCreator = options.requestCreator || DEFAULT_REQUEST_CREATOR;
|
|
79
|
-
const httpMethodDecider = options.httpMethodDecider || 'functionName';
|
|
80
|
-
const packageInfo = getPackageInfo(options.appDir);
|
|
81
|
-
const packageName = packageInfo.name;
|
|
82
|
-
const dataPlatformAppNamespace = packageName || 'unknown-app';
|
|
83
|
-
const requestId = 'bundle' === options.target ? packageName || process.env.npm_package_name : void 0;
|
|
84
|
-
const normalizedRequestId = requestId || 'default';
|
|
85
|
-
const operationVersion = deriveOperationVersion(packageInfo.version);
|
|
86
|
-
const batchConfig = options.dataPlatformBatch;
|
|
87
|
-
const batchEndpoint = resolveBatchEndpoint(options.prefix, batchConfig?.endpoint);
|
|
88
|
-
const manifest = {
|
|
89
|
-
endpoints: endpoints.map((endpoint)=>({
|
|
90
|
-
apiId: endpoint.apiId,
|
|
91
|
-
group: endpoint.groupName,
|
|
92
|
-
endpoint: endpoint.endpointName,
|
|
93
|
-
method: endpoint.method,
|
|
94
|
-
routePath: endpoint.routePath,
|
|
95
|
-
schemaHash: createEffectEndpointContractHash(endpoint, normalizedRequestId),
|
|
96
|
-
operationVersion
|
|
97
|
-
}))
|
|
98
|
-
};
|
|
99
|
-
const config = {
|
|
100
|
-
appNamespace: dataPlatformAppNamespace,
|
|
101
|
-
...requestId ? {
|
|
102
|
-
requestId
|
|
103
|
-
} : {},
|
|
104
|
-
port: options.port,
|
|
105
|
-
useEnvPort: 'server' === options.target,
|
|
106
|
-
defaultOrigin: `http://localhost:${String(options.port)}`,
|
|
107
|
-
httpMethodDecider,
|
|
108
|
-
batch: {
|
|
109
|
-
enabled: batchConfig?.enabled ?? true,
|
|
110
|
-
endpoint: batchEndpoint,
|
|
111
|
-
flushIntervalMs: batchConfig?.flushIntervalMs ?? 8,
|
|
112
|
-
maxBatchSize: batchConfig?.maxBatchSize ?? 16,
|
|
113
|
-
maxBatchBytes: batchConfig?.maxBatchBytes ?? 65536,
|
|
114
|
-
requestTimeoutMs: batchConfig?.requestTimeoutMs ?? 10000,
|
|
115
|
-
allowedMethods: batchConfig?.allowedMethods && batchConfig.allowedMethods.length > 0 ? batchConfig.allowedMethods : [
|
|
116
|
-
'GET'
|
|
117
|
-
]
|
|
118
|
-
}
|
|
119
|
-
};
|
|
120
|
-
return `import * as __requestRuntime from ${JSON.stringify(requestCreator)};
|
|
121
|
-
import { createGeneratedEffectClient } from ${JSON.stringify(EFFECT_CLIENT_RUNTIME_IMPORT)};
|
|
122
|
-
|
|
123
|
-
const __manifest = ${JSON.stringify(manifest, null, 2)};
|
|
124
|
-
|
|
125
|
-
const __config = ${JSON.stringify(config, null, 2)};
|
|
126
|
-
|
|
127
|
-
const __generated = createGeneratedEffectClient(__manifest, __config, __requestRuntime);
|
|
128
|
-
|
|
129
|
-
const client = __generated.client;
|
|
130
|
-
const operationManifest = __generated.operationManifest;
|
|
131
|
-
const createEffectRequestContext = __generated.createEffectRequestContext;
|
|
132
|
-
const apiModule = {
|
|
133
|
-
client,
|
|
134
|
-
operationManifest,
|
|
135
|
-
createEffectRequestContext,
|
|
136
|
-
};
|
|
137
|
-
|
|
138
|
-
export { client, createEffectRequestContext, operationManifest };
|
|
139
|
-
export default apiModule;
|
|
140
|
-
`;
|
|
141
|
-
}
|
|
142
|
-
function renderClientShape(endpoints, valueType) {
|
|
143
|
-
if (0 === endpoints.length) return `Record<string, Record<string, ${valueType}>>`;
|
|
144
|
-
const groups = new Map();
|
|
145
|
-
for (const endpoint of endpoints){
|
|
146
|
-
const group = groups.get(endpoint.groupName) || [];
|
|
147
|
-
group.push(endpoint.endpointName);
|
|
148
|
-
groups.set(endpoint.groupName, group);
|
|
149
|
-
}
|
|
150
|
-
const groupEntries = [
|
|
151
|
-
...groups.entries()
|
|
152
|
-
].map(([groupName, names])=>{
|
|
153
|
-
const endpointEntries = names.map((name)=>` ${JSON.stringify(name)}: ${valueType};`).join('\n');
|
|
154
|
-
return ` ${JSON.stringify(groupName)}: {\n${endpointEntries}\n };`;
|
|
155
|
-
});
|
|
156
|
-
return `{\n${groupEntries.join('\n')}\n}`;
|
|
157
|
-
}
|
|
158
|
-
function renderEffectClientDeclaration(endpoints = []) {
|
|
159
|
-
return `export type EffectClientOperation = (
|
|
160
|
-
request?: unknown,
|
|
161
|
-
) => Promise<unknown>;
|
|
162
|
-
export type EffectClientGroup = Record<string, EffectClientOperation>;
|
|
163
|
-
export type EffectClient = Record<string, EffectClientGroup>;
|
|
164
|
-
export type EffectOperationDescriptor = {
|
|
165
|
-
appNamespace: string;
|
|
166
|
-
apiId: string;
|
|
167
|
-
group: string;
|
|
168
|
-
endpoint: string;
|
|
169
|
-
operationId: string;
|
|
170
|
-
routePath: string;
|
|
171
|
-
method: string;
|
|
172
|
-
operationVersion: number;
|
|
173
|
-
schemaHash: string;
|
|
174
|
-
version: number;
|
|
175
|
-
};
|
|
176
|
-
export type EffectOperationManifest = Record<
|
|
177
|
-
string,
|
|
178
|
-
Record<string, EffectOperationDescriptor>
|
|
179
|
-
>;
|
|
180
|
-
export type EffectOperationContext = {
|
|
181
|
-
requestId?: string;
|
|
182
|
-
operationId?: string;
|
|
183
|
-
routePath?: string;
|
|
184
|
-
method?: string;
|
|
185
|
-
schemaHash?: string;
|
|
186
|
-
operationVersion?: number;
|
|
187
|
-
locale?: string;
|
|
188
|
-
traceparent?: string;
|
|
189
|
-
traceId?: string;
|
|
190
|
-
spanId?: string;
|
|
191
|
-
source?: string;
|
|
192
|
-
scope?: Record<string, unknown>;
|
|
193
|
-
sessionClaims?: Record<string, unknown>;
|
|
194
|
-
attributes?: Record<string, unknown>;
|
|
195
|
-
};
|
|
196
|
-
export type EffectRequestContext = {
|
|
197
|
-
headers?: Record<string, string>;
|
|
198
|
-
locale?: string;
|
|
199
|
-
operationContext?: EffectOperationContext;
|
|
200
|
-
traceparent?: string;
|
|
201
|
-
traceId?: string;
|
|
202
|
-
spanId?: string;
|
|
203
|
-
};
|
|
204
|
-
export type GeneratedEffectClient = ${renderClientShape(endpoints, 'EffectClientOperation')};
|
|
205
|
-
export type GeneratedEffectOperationManifest = ${renderClientShape(endpoints, "EffectOperationDescriptor")};
|
|
206
|
-
|
|
207
|
-
export declare const client: GeneratedEffectClient;
|
|
208
|
-
export declare const createEffectRequestContext: (
|
|
209
|
-
requestContext: Record<string, unknown>,
|
|
210
|
-
) => EffectRequestContext;
|
|
211
|
-
export declare const operationManifest: GeneratedEffectOperationManifest;
|
|
212
|
-
declare const apiModule: {
|
|
213
|
-
client: GeneratedEffectClient;
|
|
214
|
-
createEffectRequestContext: typeof createEffectRequestContext;
|
|
215
|
-
operationManifest: GeneratedEffectOperationManifest;
|
|
216
|
-
};
|
|
217
|
-
|
|
218
|
-
export default apiModule;
|
|
219
|
-
`;
|
|
220
|
-
}
|
|
221
|
-
async function generateEffectClient(options) {
|
|
222
|
-
const api = await loadEffectApi(options.resourcePath);
|
|
223
|
-
if (!api) {
|
|
224
|
-
logger.warn(`[BFF][Effect] Failed to generate client for ${options.resourcePath}: unable to resolve exported HttpApi.`);
|
|
225
|
-
return null;
|
|
226
|
-
}
|
|
227
|
-
const httpApiRuntime = await getHttpApiRuntime();
|
|
228
|
-
const endpoints = collectEffectEndpoints(httpApiRuntime.reflect, api, options.prefix);
|
|
229
|
-
return {
|
|
230
|
-
code: renderEffectClientCode(endpoints, options),
|
|
231
|
-
declaration: renderEffectClientDeclaration(endpoints),
|
|
232
|
-
endpoints
|
|
233
|
-
};
|
|
234
|
-
}
|
|
235
|
-
async function generateEffectClientCode(options) {
|
|
236
|
-
const artifacts = await generateEffectClient(options);
|
|
237
|
-
return artifacts ? artifacts.code : null;
|
|
238
|
-
}
|
|
239
|
-
function resolveEffectEntryFile(options) {
|
|
240
|
-
const { appDir, apiDir, effectEntry } = options;
|
|
241
|
-
const resolveEntry = (entryWithoutExt)=>{
|
|
242
|
-
if (path.extname(entryWithoutExt)) return fs.existsSync(entryWithoutExt) ? entryWithoutExt : void 0;
|
|
243
|
-
return findExists(JS_OR_TS_EXTS.map((ext)=>`${entryWithoutExt}${ext}`));
|
|
244
|
-
};
|
|
245
|
-
if (effectEntry) {
|
|
246
|
-
const entryWithoutExt = path.isAbsolute(effectEntry) ? effectEntry : path.resolve(appDir, effectEntry);
|
|
247
|
-
return resolveEntry(entryWithoutExt);
|
|
248
|
-
}
|
|
249
|
-
return resolveEntry(path.resolve(apiDir, 'index'));
|
|
250
|
-
}
|
|
251
|
-
export { generateEffectClient, generateEffectClientCode, renderEffectClientDeclaration, resolveEffectEntryFile };
|
|
1
|
+
import "node:module";
|
|
2
|
+
export { generateEffectClient, generateEffectClientCode, renderEffectClientDeclaration, resolveEffectEntryFile } from "./effect-client-generator/index.mjs";
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { AppTools } from '@modern-js/app-tools';
|
|
2
|
+
import type { CLIPluginAPI } from '@modern-js/plugin';
|
|
3
|
+
export declare const createBffGenerator: (api: CLIPluginAPI<AppTools>) => {
|
|
4
|
+
compileApi: () => Promise<void>;
|
|
5
|
+
generate: () => Promise<void>;
|
|
6
|
+
handleCrossProjectInvocation: (isBuild?: boolean) => Promise<void>;
|
|
7
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const isWatchableBffFile: (filename: string) => boolean;
|
package/dist/types/cli.d.ts
CHANGED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type { DataBatchRequestItem, DataBatchTransportOptions, DataTransportRequestInfo } from '../types';
|
|
2
|
+
type DataBatchFetch = NonNullable<DataBatchTransportOptions['fetch']>;
|
|
3
|
+
type CreateBatchTransportQueueOptions = {
|
|
4
|
+
options: DataBatchTransportOptions;
|
|
5
|
+
baseFetch: DataBatchFetch;
|
|
6
|
+
};
|
|
7
|
+
export type QueuedBatchRequest = {
|
|
8
|
+
key: string;
|
|
9
|
+
endpoint: string;
|
|
10
|
+
requestUrl: string;
|
|
11
|
+
requestInit: RequestInit;
|
|
12
|
+
item: DataBatchRequestItem;
|
|
13
|
+
size: number;
|
|
14
|
+
resolve: (value: unknown) => void;
|
|
15
|
+
reject: (reason: unknown) => void;
|
|
16
|
+
};
|
|
17
|
+
export type BatchBucket = {
|
|
18
|
+
items: QueuedBatchRequest[];
|
|
19
|
+
bytes: number;
|
|
20
|
+
timer: ReturnType<typeof setTimeout> | null;
|
|
21
|
+
flushing: boolean;
|
|
22
|
+
};
|
|
23
|
+
export declare function ensureBucket(buckets: Map<string, BatchBucket>, endpoint: string): BatchBucket;
|
|
24
|
+
export declare function createBatchTransportQueue({ options, baseFetch, }: CreateBatchTransportQueueOptions): (input: DataTransportRequestInfo, init?: RequestInit) => Promise<any>;
|
|
25
|
+
export {};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export declare function toHeaderRecord(headers: HeadersInit | undefined): Record<string, string>;
|
|
2
|
+
export declare function measureTextBytes(value: string): number;
|
|
3
|
+
export declare function createBatchId(): string;
|
|
4
|
+
export declare function normalizeMethod(method: string | undefined): string;
|
|
5
|
+
export declare function toRequestBody(initBody: BodyInit | null | undefined): string | undefined;
|
|
6
|
+
export declare function shouldBatchRequest(input: {
|
|
7
|
+
method: string;
|
|
8
|
+
body: string | undefined;
|
|
9
|
+
headers: Record<string, string>;
|
|
10
|
+
allowedMethods: Set<string>;
|
|
11
|
+
batchEndpoint: string;
|
|
12
|
+
requestUrl: URL;
|
|
13
|
+
}): boolean;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { DataBatchResponseItem, DataBatchResponsePayload } from '../types';
|
|
2
|
+
export declare function isBatchResponseItem(value: unknown): value is DataBatchResponseItem;
|
|
3
|
+
export declare function isBatchResponsePayload(value: unknown): value is DataBatchResponsePayload;
|
|
4
|
+
export declare function parseResponseLikeCreateRequest(response: Response): Promise<any>;
|
|
@@ -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;
|
|
@@ -1,191 +1,7 @@
|
|
|
1
|
-
export
|
|
2
|
-
export
|
|
3
|
-
export
|
|
4
|
-
|
|
5
|
-
};
|
|
6
|
-
export
|
|
7
|
-
|
|
8
|
-
apiId: string;
|
|
9
|
-
group: string;
|
|
10
|
-
endpoint: string;
|
|
11
|
-
schemaHash?: string;
|
|
12
|
-
version?: number;
|
|
13
|
-
}
|
|
14
|
-
export interface CacheScope {
|
|
15
|
-
appNamespace: string;
|
|
16
|
-
origin: string;
|
|
17
|
-
tenantId?: string;
|
|
18
|
-
userId?: string;
|
|
19
|
-
sessionId?: string;
|
|
20
|
-
}
|
|
21
|
-
export interface TraceContext {
|
|
22
|
-
traceId: string;
|
|
23
|
-
spanId: string;
|
|
24
|
-
sampled: boolean;
|
|
25
|
-
parentSpanId?: string;
|
|
26
|
-
}
|
|
27
|
-
export interface RequestEnvelope<Input = unknown> {
|
|
28
|
-
protocolVersion: 1;
|
|
29
|
-
operationId: string;
|
|
30
|
-
appNamespace: string;
|
|
31
|
-
origin: string;
|
|
32
|
-
requestMode: DataRequestMode;
|
|
33
|
-
mutationMode?: DataMutationMode;
|
|
34
|
-
scopeKey: string;
|
|
35
|
-
input: Input;
|
|
36
|
-
inputHash: string;
|
|
37
|
-
selectionPlan?: SelectionPlan;
|
|
38
|
-
selectionHash?: string;
|
|
39
|
-
traceparent?: string;
|
|
40
|
-
timestamp: number;
|
|
41
|
-
}
|
|
42
|
-
export interface HydrationEnvelope<Payload = unknown> {
|
|
43
|
-
protocolVersion: 1;
|
|
44
|
-
runtimeVersion: string;
|
|
45
|
-
appNamespace: string;
|
|
46
|
-
origin: string;
|
|
47
|
-
createdAt: number;
|
|
48
|
-
payload: Payload;
|
|
49
|
-
checksum: string;
|
|
50
|
-
}
|
|
51
|
-
export interface InvalidationEvent {
|
|
52
|
-
sourceNamespace: string;
|
|
53
|
-
sourceOperationId: string;
|
|
54
|
-
scopeKey: string;
|
|
55
|
-
targetNamespaces?: string[];
|
|
56
|
-
targetOperationIds?: string[];
|
|
57
|
-
}
|
|
58
|
-
export interface InvalidationSubscriber {
|
|
59
|
-
namespace: string;
|
|
60
|
-
operationIds?: string[];
|
|
61
|
-
scopeKey?: string;
|
|
62
|
-
acceptCrossNamespace?: boolean;
|
|
63
|
-
}
|
|
64
|
-
export interface DataBatchRequestItem {
|
|
65
|
-
id: string;
|
|
66
|
-
path: string;
|
|
67
|
-
method: string;
|
|
68
|
-
headers?: Record<string, string>;
|
|
69
|
-
body?: string;
|
|
70
|
-
}
|
|
71
|
-
export interface DataBatchRequestPayload {
|
|
72
|
-
protocolVersion: 1;
|
|
73
|
-
batchId: string;
|
|
74
|
-
sentAt: number;
|
|
75
|
-
items: DataBatchRequestItem[];
|
|
76
|
-
}
|
|
77
|
-
export interface DataBatchResponseItem {
|
|
78
|
-
id: string;
|
|
79
|
-
status: number;
|
|
80
|
-
headers?: Record<string, string>;
|
|
81
|
-
body?: string;
|
|
82
|
-
}
|
|
83
|
-
export interface DataBatchResponsePayload {
|
|
84
|
-
protocolVersion: 1;
|
|
85
|
-
batchId: string;
|
|
86
|
-
receivedAt: number;
|
|
87
|
-
items: DataBatchResponseItem[];
|
|
88
|
-
}
|
|
89
|
-
export interface DataBatchTransportEvent {
|
|
90
|
-
type: 'enqueue' | 'flush' | 'fallback' | 'disable';
|
|
91
|
-
endpoint: string;
|
|
92
|
-
batchId?: string;
|
|
93
|
-
size?: number;
|
|
94
|
-
reason?: string;
|
|
95
|
-
}
|
|
96
|
-
export type DataBatchTransportTelemetryAttributes = Record<string, string | number | boolean>;
|
|
97
|
-
export interface DataBatchTransportOptions {
|
|
98
|
-
endpoint?: string;
|
|
99
|
-
fetch?: (input: DataTransportRequestInfo, init?: RequestInit) => Promise<Response>;
|
|
100
|
-
flushIntervalMs?: number;
|
|
101
|
-
maxBatchSize?: number;
|
|
102
|
-
maxBatchBytes?: number;
|
|
103
|
-
requestTimeoutMs?: number;
|
|
104
|
-
allowedMethods?: string[];
|
|
105
|
-
onEvent?: (event: DataBatchTransportEvent) => void;
|
|
106
|
-
}
|
|
107
|
-
export declare const DATA_BATCH_TRANSPORT_OTEL_EVENT = "modernjs.data.batch";
|
|
108
|
-
export declare function createDataBatchTransportTelemetryAttributes(event: DataBatchTransportEvent): DataBatchTransportTelemetryAttributes;
|
|
109
|
-
export declare function emitDataBatchTransportEvent(onEvent: ((event: DataBatchTransportEvent) => void) | undefined, event: DataBatchTransportEvent): void;
|
|
110
|
-
export interface SelectionPlanValidationOptions {
|
|
111
|
-
maxDepth?: number;
|
|
112
|
-
maxFields?: number;
|
|
113
|
-
allowedLeafPaths?: ReadonlyArray<string>;
|
|
114
|
-
}
|
|
115
|
-
export interface SelectionPlanValidationResult {
|
|
116
|
-
ok: boolean;
|
|
117
|
-
errors: string[];
|
|
118
|
-
stats: {
|
|
119
|
-
maxDepth: number;
|
|
120
|
-
fieldCount: number;
|
|
121
|
-
};
|
|
122
|
-
}
|
|
123
|
-
export interface RequestEnvelopeValidationOptions {
|
|
124
|
-
expectedProtocolVersion?: number;
|
|
125
|
-
expectedNamespace?: string;
|
|
126
|
-
expectedOrigin?: string;
|
|
127
|
-
requireTraceContext?: boolean;
|
|
128
|
-
}
|
|
129
|
-
export interface HydrationEnvelopeValidationOptions {
|
|
130
|
-
expectedProtocolVersion?: number;
|
|
131
|
-
expectedNamespace?: string;
|
|
132
|
-
expectedOrigin?: string;
|
|
133
|
-
expectedRuntimeVersion?: string;
|
|
134
|
-
}
|
|
135
|
-
export declare const DEFAULT_DATA_ENVELOPE_HEADER = "x-modernjs-data-envelope";
|
|
136
|
-
export declare const DEFAULT_DATA_BATCH_ENDPOINT = "/_data/batch";
|
|
137
|
-
export declare const DEFAULT_DATA_BATCH_HEADER = "x-modernjs-data-batch";
|
|
138
|
-
type DataTransportRequestInfo = string | URL | Request;
|
|
139
|
-
export declare function stableStringify(value: unknown): string;
|
|
140
|
-
export declare function encodeRequestEnvelopeHeader(envelope: RequestEnvelope): string;
|
|
141
|
-
export declare function decodeRequestEnvelopeHeader(value: string): RequestEnvelope | null;
|
|
142
|
-
export declare function normalizeOrigin(origin: string): string;
|
|
143
|
-
export declare function createOperationId(input: OperationDescriptor): string;
|
|
144
|
-
export declare function buildScopeKey(scope: CacheScope): string;
|
|
145
|
-
export declare function buildQueryKey(input: {
|
|
146
|
-
operationId: string;
|
|
147
|
-
scopeKey: string;
|
|
148
|
-
requestMode?: DataRequestMode;
|
|
149
|
-
requestInput?: unknown;
|
|
150
|
-
selectionPlan?: SelectionPlan;
|
|
151
|
-
}): string;
|
|
152
|
-
export declare function parseTraceparentHeader(header: string): TraceContext | null;
|
|
153
|
-
export declare function formatTraceparentHeader(trace: TraceContext): string;
|
|
154
|
-
export declare function deriveChildTraceContext(parent: TraceContext, childSpanId: string): TraceContext;
|
|
155
|
-
export declare function validateSelectionPlan(plan: SelectionPlan, options?: SelectionPlanValidationOptions): SelectionPlanValidationResult;
|
|
156
|
-
export declare function createRequestEnvelope<Input>(input: {
|
|
157
|
-
operation: OperationDescriptor;
|
|
158
|
-
scope: CacheScope;
|
|
159
|
-
requestInput: Input;
|
|
160
|
-
selectionPlan?: SelectionPlan;
|
|
161
|
-
requestMode?: DataRequestMode;
|
|
162
|
-
mutationMode?: DataMutationMode;
|
|
163
|
-
traceContext?: TraceContext;
|
|
164
|
-
requireTraceContext?: boolean;
|
|
165
|
-
timestamp?: number;
|
|
166
|
-
protocolVersion?: 1;
|
|
167
|
-
}): RequestEnvelope<Input>;
|
|
168
|
-
export declare function validateRequestEnvelope(envelope: RequestEnvelope, options?: RequestEnvelopeValidationOptions): {
|
|
169
|
-
ok: boolean;
|
|
170
|
-
errors: string[];
|
|
171
|
-
};
|
|
172
|
-
export declare function createHydrationEnvelope<Payload>(input: {
|
|
173
|
-
runtimeVersion: string;
|
|
174
|
-
scope: Pick<CacheScope, 'appNamespace' | 'origin'>;
|
|
175
|
-
payload: Payload;
|
|
176
|
-
createdAt?: number;
|
|
177
|
-
protocolVersion?: 1;
|
|
178
|
-
}): HydrationEnvelope<Payload>;
|
|
179
|
-
export declare function validateHydrationEnvelope(envelope: HydrationEnvelope, options?: HydrationEnvelopeValidationOptions): {
|
|
180
|
-
ok: boolean;
|
|
181
|
-
errors: string[];
|
|
182
|
-
};
|
|
183
|
-
export declare function createInvalidationEvent(input: {
|
|
184
|
-
sourceOperation: OperationDescriptor;
|
|
185
|
-
sourceScope: CacheScope;
|
|
186
|
-
targetNamespaces?: string[];
|
|
187
|
-
targetOperations?: OperationDescriptor[];
|
|
188
|
-
}): InvalidationEvent;
|
|
189
|
-
export declare function shouldApplyInvalidation(event: InvalidationEvent, subscriber: InvalidationSubscriber): boolean;
|
|
190
|
-
export declare function createDataBatchTransport(options?: DataBatchTransportOptions): (input: DataTransportRequestInfo, init?: RequestInit) => Promise<any>;
|
|
191
|
-
export {};
|
|
1
|
+
export { createDataBatchTransport, createDataBatchTransportTelemetryAttributes, DATA_BATCH_TRANSPORT_OTEL_EVENT, emitDataBatchTransportEvent, } from './batch-transport';
|
|
2
|
+
export { buildQueryKey, buildScopeKey, createOperationId, decodeRequestEnvelopeHeader, encodeRequestEnvelopeHeader, normalizeOrigin, stableStringify, } from './codec';
|
|
3
|
+
export { createInvalidationEvent, shouldApplyInvalidation, } from './invalidation';
|
|
4
|
+
export { deriveChildTraceContext, formatTraceparentHeader, parseTraceparentHeader, } from './trace';
|
|
5
|
+
export type { CacheScope, DataBatchRequestItem, DataBatchRequestPayload, DataBatchResponseItem, DataBatchResponsePayload, DataBatchTransportEvent, DataBatchTransportOptions, DataBatchTransportTelemetryAttributes, DataMutationMode, DataRequestMode, HydrationEnvelope, HydrationEnvelopeValidationOptions, InvalidationEvent, InvalidationSubscriber, OperationDescriptor, RequestEnvelope, RequestEnvelopeValidationOptions, SelectionPlan, SelectionPlanValidationOptions, SelectionPlanValidationResult, TraceContext, } from './types';
|
|
6
|
+
export { DEFAULT_DATA_BATCH_ENDPOINT, DEFAULT_DATA_BATCH_HEADER, DEFAULT_DATA_ENVELOPE_HEADER, } from './types';
|
|
7
|
+
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;
|