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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (142) hide show
  1. package/README.md +20 -4
  2. package/dist/cjs/assembly.js +50 -0
  3. package/dist/cjs/{effect-client/guards.js → data-platform/batch/options.js} +13 -9
  4. package/dist/cjs/data-platform/batch/queue.js +48 -83
  5. package/dist/cjs/data-platform/trace.js +2 -2
  6. package/dist/cjs/effect/context.js +28 -4
  7. package/dist/cjs/effect/edge-dispatcher.js +12 -12
  8. package/dist/cjs/effect/edge.js +36 -3
  9. package/dist/cjs/effect/endpoint-contracts.js +3 -4
  10. package/dist/cjs/effect/entry-shape.js +40 -12
  11. package/dist/cjs/effect/generated-entry.js +57 -0
  12. package/dist/cjs/effect/handler/batch-handler.js +7 -7
  13. package/dist/cjs/effect/handler/batch.js +8 -10
  14. package/dist/cjs/effect/handler/definition.js +1 -21
  15. package/dist/cjs/effect/index.js +8 -8
  16. package/dist/cjs/effect/module.js +8 -4
  17. package/dist/cjs/effect/operation-context.js +10 -14
  18. package/dist/cjs/effect/rpcSerialization.js +0 -2
  19. package/dist/cjs/effect-client/cross-project.js +89 -0
  20. package/dist/cjs/effect-client/index.js +5 -3
  21. package/dist/cjs/microvertical-api.js +120 -0
  22. package/dist/esm/assembly.mjs +12 -0
  23. package/dist/esm/data-platform/batch/options.mjs +10 -0
  24. package/dist/esm/data-platform/batch/queue.mjs +48 -83
  25. package/dist/esm/data-platform/trace.mjs +1 -1
  26. package/dist/esm/effect/context.mjs +21 -6
  27. package/dist/esm/effect/edge-dispatcher.mjs +6 -6
  28. package/dist/esm/effect/edge.mjs +3 -0
  29. package/dist/esm/effect/endpoint-contracts.mjs +2 -3
  30. package/dist/esm/effect/entry-shape-registry.mjs +2 -2
  31. package/dist/esm/effect/entry-shape.mjs +29 -6
  32. package/dist/esm/effect/generated-entry.mjs +19 -0
  33. package/dist/esm/effect/handler/batch-handler.mjs +8 -8
  34. package/dist/esm/effect/handler/batch.mjs +9 -8
  35. package/dist/esm/effect/handler/definition.mjs +1 -21
  36. package/dist/esm/effect/index.mjs +1 -1
  37. package/dist/esm/effect/module.mjs +8 -4
  38. package/dist/esm/effect/operation-context.mjs +3 -4
  39. package/dist/esm/effect/rpcSerialization.mjs +0 -2
  40. package/dist/esm/effect-client/cross-project.mjs +51 -0
  41. package/dist/esm/effect-client/index.mjs +4 -2
  42. package/dist/esm/microvertical-api.mjs +67 -0
  43. package/dist/esm-node/assembly.mjs +13 -0
  44. package/dist/esm-node/data-platform/batch/options.mjs +11 -0
  45. package/dist/esm-node/data-platform/batch/queue.mjs +48 -83
  46. package/dist/esm-node/data-platform/trace.mjs +1 -1
  47. package/dist/esm-node/effect/context.mjs +21 -6
  48. package/dist/esm-node/effect/edge-dispatcher.mjs +6 -6
  49. package/dist/esm-node/effect/edge.mjs +3 -0
  50. package/dist/esm-node/effect/endpoint-contracts.mjs +2 -3
  51. package/dist/esm-node/effect/entry-shape.mjs +29 -6
  52. package/dist/esm-node/effect/generated-entry.mjs +20 -0
  53. package/dist/esm-node/effect/handler/batch-handler.mjs +8 -8
  54. package/dist/esm-node/effect/handler/batch.mjs +9 -8
  55. package/dist/esm-node/effect/handler/definition.mjs +1 -21
  56. package/dist/esm-node/effect/index.mjs +1 -1
  57. package/dist/esm-node/effect/module.mjs +8 -4
  58. package/dist/esm-node/effect/operation-context.mjs +3 -4
  59. package/dist/esm-node/effect/rpcSerialization.mjs +0 -2
  60. package/dist/esm-node/effect-client/cross-project.mjs +52 -0
  61. package/dist/esm-node/effect-client/index.mjs +4 -2
  62. package/dist/esm-node/microvertical-api.mjs +68 -0
  63. package/dist/types/assembly.d.ts +10 -0
  64. package/dist/types/data-platform/batch/options.d.ts +7 -0
  65. package/dist/types/data-platform/batch/queue.d.ts +0 -1
  66. package/dist/types/effect/context.d.ts +15 -2
  67. package/dist/types/effect/edge-dispatcher.d.ts +3 -3
  68. package/dist/types/effect/edge.d.ts +3 -0
  69. package/dist/types/effect/endpoint-contracts.d.ts +2 -20
  70. package/dist/types/effect/entry-shape.d.ts +16 -2
  71. package/dist/types/effect/generated-entry.d.ts +7 -0
  72. package/dist/types/effect/handler/batch.d.ts +7 -2
  73. package/dist/types/effect/handler/types.d.ts +2 -17
  74. package/dist/types/effect/handler.d.ts +1 -1
  75. package/dist/types/effect/module.d.ts +2 -1
  76. package/dist/types/effect/operation-context.d.ts +1 -2
  77. package/dist/types/effect-client/cross-project.d.ts +10 -0
  78. package/dist/types/effect-client/index.d.ts +7 -4
  79. package/dist/types/microvertical-api.d.ts +65 -0
  80. package/package.json +47 -42
  81. package/src/assembly.ts +43 -0
  82. package/src/data-platform/batch/options.ts +20 -0
  83. package/src/data-platform/batch/queue.ts +63 -92
  84. package/src/data-platform/trace.ts +1 -1
  85. package/src/effect/context.ts +64 -12
  86. package/src/effect/edge-dispatcher.ts +14 -11
  87. package/src/effect/edge.ts +6 -0
  88. package/src/effect/endpoint-contracts.ts +3 -24
  89. package/src/effect/entry-shape.ts +105 -10
  90. package/src/effect/generated-entry.ts +36 -0
  91. package/src/effect/handler/batch-handler.ts +27 -28
  92. package/src/effect/handler/batch.ts +9 -13
  93. package/src/effect/handler/definition.ts +0 -45
  94. package/src/effect/handler/http.ts +2 -2
  95. package/src/effect/handler/types.ts +3 -32
  96. package/src/effect/handler.ts +0 -1
  97. package/src/effect/index.ts +1 -1
  98. package/src/effect/module.ts +11 -4
  99. package/src/effect/operation-context.ts +2 -6
  100. package/src/effect/rpcSerialization.ts +0 -2
  101. package/src/effect-client/cross-project.ts +104 -0
  102. package/src/effect-client/index.ts +17 -7
  103. package/src/microvertical-api.ts +102 -0
  104. package/dist/cjs/effect/edge-context.js +0 -61
  105. package/dist/cjs/effect-client/batch.js +0 -73
  106. package/dist/cjs/effect-client/envelope.js +0 -145
  107. package/dist/cjs/effect-client/request-context.js +0 -64
  108. package/dist/cjs/effect-client/request.js +0 -66
  109. package/dist/cjs/effect-client/runtime.js +0 -100
  110. package/dist/cjs/effect-client/types.js +0 -18
  111. package/dist/esm/effect/edge-context.mjs +0 -14
  112. package/dist/esm/effect-client/batch.mjs +0 -35
  113. package/dist/esm/effect-client/envelope.mjs +0 -104
  114. package/dist/esm/effect-client/guards.mjs +0 -3
  115. package/dist/esm/effect-client/request-context.mjs +0 -23
  116. package/dist/esm/effect-client/request.mjs +0 -28
  117. package/dist/esm/effect-client/runtime.mjs +0 -62
  118. package/dist/esm/effect-client/types.mjs +0 -0
  119. package/dist/esm-node/effect/edge-context.mjs +0 -15
  120. package/dist/esm-node/effect-client/batch.mjs +0 -36
  121. package/dist/esm-node/effect-client/envelope.mjs +0 -105
  122. package/dist/esm-node/effect-client/guards.mjs +0 -4
  123. package/dist/esm-node/effect-client/request-context.mjs +0 -24
  124. package/dist/esm-node/effect-client/request.mjs +0 -29
  125. package/dist/esm-node/effect-client/runtime.mjs +0 -63
  126. package/dist/esm-node/effect-client/types.mjs +0 -1
  127. package/dist/types/effect/edge-context.d.ts +0 -5
  128. package/dist/types/effect-client/batch.d.ts +0 -2
  129. package/dist/types/effect-client/envelope.d.ts +0 -15
  130. package/dist/types/effect-client/guards.d.ts +0 -2
  131. package/dist/types/effect-client/request-context.d.ts +0 -3
  132. package/dist/types/effect-client/request.d.ts +0 -1
  133. package/dist/types/effect-client/runtime.d.ts +0 -5
  134. package/dist/types/effect-client/types.d.ts +0 -68
  135. package/src/effect/edge-context.ts +0 -51
  136. package/src/effect-client/batch.ts +0 -50
  137. package/src/effect-client/envelope.ts +0 -238
  138. package/src/effect-client/guards.ts +0 -6
  139. package/src/effect-client/request-context.ts +0 -54
  140. package/src/effect-client/request.ts +0 -51
  141. package/src/effect-client/runtime.ts +0 -122
  142. package/src/effect-client/types.ts +0 -84
@@ -0,0 +1,104 @@
1
+ import {
2
+ BFF_ENVELOPE_HEADER,
3
+ BFF_OPERATION_CONTEXT_DETAIL_HEADER,
4
+ BFF_OPERATION_CONTEXT_HEADER,
5
+ digestOperationContract,
6
+ resolveCrossProjectRequestObservation,
7
+ } from '@modern-js/server-runtime-extensions/bff-policy';
8
+ import * as Effect from 'effect/Effect';
9
+ import * as Schema from 'effect/Schema';
10
+
11
+ const encodeJson = Schema.encodeSync(Schema.fromJsonString(Schema.Unknown));
12
+
13
+ import { HttpClient, HttpClientRequest } from 'effect/unstable/http';
14
+ import { HttpApi, type HttpApiGroup } from 'effect/unstable/httpapi';
15
+
16
+ export interface EffectCrossProjectClientOptions {
17
+ requestId: string;
18
+ operationVersion: number;
19
+ /** Server mount path, independent of the API origin. */
20
+ prefix: string;
21
+ }
22
+
23
+ /** Native transport middleware; endpoint encoding and inference stay in Effect. */
24
+ export function withCrossProjectPolicy<
25
+ Id extends string,
26
+ Groups extends HttpApiGroup.Constraint,
27
+ >(
28
+ api: HttpApi.HttpApi<Id, Groups>,
29
+ options: EffectCrossProjectClientOptions,
30
+ client: HttpClient.HttpClient,
31
+ ): HttpClient.HttpClient {
32
+ const contracts: Record<
33
+ string,
34
+ { operationId: string; name: string; method: string; routePath: string }
35
+ > = {};
36
+ const prefix = options.prefix.replace(/\/$/, '');
37
+ HttpApi.reflect(api, {
38
+ onGroup: () => {},
39
+ onEndpoint: ({ endpoint }) => {
40
+ const routePath =
41
+ `${prefix}${endpoint.path === '/' ? '' : endpoint.path}` || '/';
42
+ const name = endpoint.identifier;
43
+ contracts[`${endpoint.method}:${routePath}`] = {
44
+ operationId: `${options.requestId}:${name}`,
45
+ name,
46
+ method: endpoint.method,
47
+ routePath,
48
+ };
49
+ },
50
+ });
51
+ return client.pipe(
52
+ HttpClient.mapRequestEffect(request => {
53
+ const observed = resolveCrossProjectRequestObservation(
54
+ {
55
+ method: request.method,
56
+ pathname: new URL(request.url, 'http://effect.invalid').pathname,
57
+ },
58
+ { expectedOperationContracts: contracts },
59
+ );
60
+ const contract =
61
+ observed && contracts[`${observed.method}:${observed.routePath}`];
62
+ if (contract === undefined) {
63
+ return Effect.die(
64
+ new Error(
65
+ '[BFF][Effect] Request has no matching shared operation contract.',
66
+ ),
67
+ );
68
+ }
69
+ return Effect.gen(function* () {
70
+ const schemaHash = yield* Effect.promise(() =>
71
+ digestOperationContract(
72
+ {
73
+ httpMethod: contract.method,
74
+ name: contract.name,
75
+ routePath: contract.routePath,
76
+ },
77
+ options.requestId,
78
+ ),
79
+ );
80
+ return request.pipe(
81
+ HttpClientRequest.setHeader(
82
+ BFF_ENVELOPE_HEADER,
83
+ encodeJson({ requestId: options.requestId }),
84
+ ),
85
+ HttpClientRequest.setHeader(
86
+ BFF_OPERATION_CONTEXT_HEADER,
87
+ contract.operationId,
88
+ ),
89
+ HttpClientRequest.setHeader(
90
+ BFF_OPERATION_CONTEXT_DETAIL_HEADER,
91
+ encodeJson({
92
+ requestId: options.requestId,
93
+ operationId: contract.operationId,
94
+ method: contract.method,
95
+ routePath: contract.routePath,
96
+ schemaHash,
97
+ operationVersion: options.operationVersion,
98
+ }),
99
+ ),
100
+ );
101
+ });
102
+ }),
103
+ );
104
+ }
@@ -2,7 +2,7 @@
2
2
  import {
3
3
  createRequestContextHeaders,
4
4
  type RequestContextInput,
5
- } from '@modern-js/create-request';
5
+ } from '@modern-js/runtime-extensions/request-context';
6
6
  import * as Data from 'effect/Data';
7
7
  import * as Effect from 'effect/Effect';
8
8
  import * as Exit from 'effect/Exit';
@@ -24,17 +24,23 @@ import {
24
24
  import {
25
25
  Rpc,
26
26
  RpcClient,
27
+ RpcClientError,
27
28
  RpcGroup,
28
29
  RpcSchema,
29
30
  RpcSerialization,
30
31
  } from 'effect/unstable/rpc';
31
32
 
32
33
  import { getRpcSerializationLayer } from '../effect/rpcSerialization';
34
+ import {
35
+ type EffectCrossProjectClientOptions,
36
+ withCrossProjectPolicy,
37
+ } from './cross-project';
33
38
 
34
39
  export * as Effect from 'effect/Effect';
35
40
  export * as Layer from 'effect/Layer';
36
41
  export * as Schema from 'effect/Schema';
37
42
  export * as HttpClientError from 'effect/unstable/http/HttpClientError';
43
+ export type { EffectCrossProjectClientOptions } from './cross-project';
38
44
  export {
39
45
  HttpApi,
40
46
  HttpApiClient,
@@ -49,6 +55,7 @@ export {
49
55
  };
50
56
 
51
57
  export type EffectHttpApiClientOptions = {
58
+ crossProject?: EffectCrossProjectClientOptions;
52
59
  baseUrl?: URL | string;
53
60
  requestContext?: RequestContextInput;
54
61
  transformClient?: (client: HttpClient.HttpClient) => HttpClient.HttpClient;
@@ -100,8 +107,7 @@ export type EffectRpcSerialization =
100
107
  | 'json'
101
108
  | 'ndjson'
102
109
  | 'jsonRpc'
103
- | 'ndJsonRpc'
104
- | 'msgPack';
110
+ | 'ndJsonRpc';
105
111
 
106
112
  export class EffectRpcClientError extends Data.TaggedError(
107
113
  'EffectRpcClientError',
@@ -132,8 +138,8 @@ export type EffectRpcClientHandle<
132
138
  Rpcs extends Rpc.Any,
133
139
  Flatten extends boolean = false,
134
140
  > = (Flatten extends true
135
- ? RpcClient.RpcClient.Flat<Rpcs, unknown>
136
- : RpcClient.RpcClient<Rpcs, unknown>) & {
141
+ ? RpcClient.RpcClient.Flat<Rpcs, RpcClientError.RpcClientError>
142
+ : RpcClient.RpcClient<Rpcs, RpcClientError.RpcClientError>) & {
137
143
  dispose: () => Promise<void>;
138
144
  };
139
145
 
@@ -233,9 +239,13 @@ export function makeEffectHttpApiClient<
233
239
  }),
234
240
  );
235
241
 
242
+ const policyClient =
243
+ options?.crossProject !== undefined
244
+ ? withCrossProjectPolicy(api, options.crossProject, contextClient)
245
+ : contextClient;
236
246
  return typeof options?.transformClient === 'function'
237
- ? options.transformClient(contextClient)
238
- : contextClient;
247
+ ? options.transformClient(policyClient)
248
+ : policyClient;
239
249
  };
240
250
 
241
251
  return HttpApiClient.make(api, {
@@ -0,0 +1,102 @@
1
+ import { Schema } from 'effect';
2
+
3
+ const MicroVerticalAppIdSchema = Schema.String.pipe(
4
+ Schema.brand('MicroVerticalAppId'),
5
+ Schema.decodeTo(Schema.String),
6
+ );
7
+ const MicroVerticalUnitIdSchema = Schema.String.pipe(
8
+ Schema.brand('MicroVerticalUnitId'),
9
+ Schema.decodeTo(Schema.String),
10
+ );
11
+ const MicroVerticalOperationIdSchema = Schema.String.pipe(
12
+ Schema.brand('MicroVerticalOperationId'),
13
+ Schema.decodeTo(Schema.String),
14
+ );
15
+ const MicroVerticalTraceIdSchema = Schema.String.pipe(
16
+ Schema.brand('MicroVerticalTraceId'),
17
+ Schema.decodeTo(Schema.String),
18
+ );
19
+
20
+ export const MicroVerticalBuildMarkerSchema = Schema.Struct({
21
+ appId: MicroVerticalAppIdSchema,
22
+ build: Schema.String,
23
+ buildMarker: Schema.String,
24
+ deployProfile: Schema.String,
25
+ packageName: Schema.String,
26
+ sourceRevision: Schema.String,
27
+ surface: Schema.String,
28
+ unitId: MicroVerticalUnitIdSchema,
29
+ version: Schema.String,
30
+ });
31
+ export type MicroVerticalBuildMarker =
32
+ typeof MicroVerticalBuildMarkerSchema.Type;
33
+
34
+ export const MicroVerticalReadinessSchema = Schema.Struct({
35
+ checks: Schema.Struct({
36
+ api: Schema.Literal('ready'),
37
+ moduleFederation: Schema.Literal('ready'),
38
+ ssr: Schema.Literal('ready'),
39
+ translations: Schema.Literal('ready'),
40
+ }),
41
+ marker: MicroVerticalBuildMarkerSchema,
42
+ status: Schema.Literal('ready'),
43
+ versionSkew: Schema.Literal('none'),
44
+ });
45
+ export type MicroVerticalReadiness = typeof MicroVerticalReadinessSchema.Type;
46
+
47
+ export const MicroVerticalOperationSourceSchema = Schema.Literals([
48
+ 'client',
49
+ 'server',
50
+ 'generated-client',
51
+ 'effect-server',
52
+ 'data-platform',
53
+ 'unknown',
54
+ ]);
55
+ export type MicroVerticalOperationSource =
56
+ typeof MicroVerticalOperationSourceSchema.Type;
57
+
58
+ export const MicroVerticalOperationContextSchema = Schema.Struct({
59
+ method: Schema.String,
60
+ operationId: MicroVerticalOperationIdSchema,
61
+ routePath: Schema.String,
62
+ source: MicroVerticalOperationSourceSchema,
63
+ traceId: Schema.optionalKey(MicroVerticalTraceIdSchema),
64
+ });
65
+ export type MicroVerticalOperationContext =
66
+ typeof MicroVerticalOperationContextSchema.Type;
67
+
68
+ export const createMicroVerticalOperationContext = <
69
+ const Method extends string,
70
+ const OperationId extends string,
71
+ const RoutePath extends string,
72
+ >(input: {
73
+ readonly method: Method;
74
+ readonly operationId: OperationId;
75
+ readonly routePath: RoutePath;
76
+ // eslint-disable-next-line effect-native/no-threaded-correlation-parameter -- This pure browser-safe contract deliberately carries optional trace metadata; it does not perform ambient request work.
77
+ readonly traceId?: string;
78
+ }): Readonly<typeof input & { source: 'generated-client' }> => {
79
+ const context = {
80
+ method: input.method,
81
+ operationId: input.operationId,
82
+ routePath: input.routePath,
83
+ source: 'generated-client' as const,
84
+ };
85
+ return input.traceId === undefined
86
+ ? context
87
+ : { ...context, traceId: input.traceId };
88
+ };
89
+
90
+ export const microVerticalOperationAttributes = (
91
+ operationContext: MicroVerticalOperationContext,
92
+ ) => {
93
+ const attributes = {
94
+ 'modernjs.operation.id': operationContext.operationId,
95
+ 'modernjs.operation.method': operationContext.method,
96
+ 'modernjs.operation.route': operationContext.routePath,
97
+ 'modernjs.operation.source': operationContext.source,
98
+ };
99
+ return operationContext.traceId === undefined
100
+ ? attributes
101
+ : { ...attributes, 'modernjs.trace.id': operationContext.traceId };
102
+ };
@@ -1,61 +0,0 @@
1
- "use strict";
2
- var __webpack_require__ = {};
3
- (()=>{
4
- __webpack_require__.d = (exports1, getters, values)=>{
5
- var define = (defs, kind)=>{
6
- for(var key in defs)if (__webpack_require__.o(defs, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
7
- enumerable: true,
8
- [kind]: defs[key]
9
- });
10
- };
11
- define(getters, "get");
12
- define(values, "value");
13
- };
14
- })();
15
- (()=>{
16
- __webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
17
- })();
18
- (()=>{
19
- __webpack_require__.r = (exports1)=>{
20
- if ("u" > typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
21
- value: 'Module'
22
- });
23
- Object.defineProperty(exports1, '__esModule', {
24
- value: true
25
- });
26
- };
27
- })();
28
- var __webpack_exports__ = {};
29
- __webpack_require__.r(__webpack_exports__);
30
- __webpack_require__.d(__webpack_exports__, {
31
- createEffectOperationContext: ()=>external_operation_context_js_namespaceObject.createEffectOperationContext,
32
- runWithEffectContext: ()=>runWithEffectContext,
33
- useEffectContext: ()=>useEffectContext,
34
- useOperationContext: ()=>useOperationContext
35
- });
36
- const external_operation_context_js_namespaceObject = require("./operation-context.js");
37
- const globalStore = globalThis;
38
- const asyncHooks = globalStore.process?.getBuiltinModule?.('node:async_hooks');
39
- const AsyncLocalStorage = asyncHooks?.AsyncLocalStorage;
40
- if ('function' != typeof AsyncLocalStorage) throw new Error('[BFF][Effect] The edge runtime must provide AsyncLocalStorage. Enable Node.js compatibility or the nodejs_als compatibility flag.');
41
- const effectContextStorage = globalStore[external_operation_context_js_namespaceObject.kEffectContextStorage] ?? (globalStore[external_operation_context_js_namespaceObject.kEffectContextStorage] = new AsyncLocalStorage());
42
- const runWithEffectContext = (context, cb)=>effectContextStorage.run(context, cb);
43
- const useEffectContext = ()=>{
44
- const context = effectContextStorage.getStore();
45
- if (!context) throw new Error("Can't call useEffectContext out of Effect runtime scope");
46
- return context;
47
- };
48
- const useOperationContext = ()=>useEffectContext().operationContext;
49
- exports.createEffectOperationContext = __webpack_exports__.createEffectOperationContext;
50
- exports.runWithEffectContext = __webpack_exports__.runWithEffectContext;
51
- exports.useEffectContext = __webpack_exports__.useEffectContext;
52
- exports.useOperationContext = __webpack_exports__.useOperationContext;
53
- for(var __rspack_i in __webpack_exports__)if (-1 === [
54
- "createEffectOperationContext",
55
- "runWithEffectContext",
56
- "useEffectContext",
57
- "useOperationContext"
58
- ].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
59
- Object.defineProperty(exports, '__esModule', {
60
- value: true
61
- });
@@ -1,73 +0,0 @@
1
- "use strict";
2
- var __webpack_require__ = {};
3
- (()=>{
4
- __webpack_require__.d = (exports1, getters, values)=>{
5
- var define = (defs, kind)=>{
6
- for(var key in defs)if (__webpack_require__.o(defs, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
7
- enumerable: true,
8
- [kind]: defs[key]
9
- });
10
- };
11
- define(getters, "get");
12
- define(values, "value");
13
- };
14
- })();
15
- (()=>{
16
- __webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
17
- })();
18
- (()=>{
19
- __webpack_require__.r = (exports1)=>{
20
- if ("u" > typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
21
- value: 'Module'
22
- });
23
- Object.defineProperty(exports1, '__esModule', {
24
- value: true
25
- });
26
- };
27
- })();
28
- var __webpack_exports__ = {};
29
- __webpack_require__.r(__webpack_exports__);
30
- __webpack_require__.d(__webpack_exports__, {
31
- configureGeneratedEffectClientRuntime: ()=>configureGeneratedEffectClientRuntime
32
- });
33
- const index_js_namespaceObject = require("../data-platform/index.js");
34
- const external_envelope_js_namespaceObject = require("./envelope.js");
35
- const resolveRuntimeFetch = ()=>'function' == typeof fetch ? fetch.bind(globalThis) : void 0;
36
- const configureGeneratedEffectClientRuntime = (config, configureRequest)=>{
37
- const defaultOrigin = config.defaultOrigin;
38
- if (config.requestId && configureRequest) {
39
- const configurePayload = {
40
- requestId: config.requestId,
41
- requireEnvelope: true,
42
- identityBinding: {
43
- enabled: true,
44
- strict: true
45
- },
46
- operationContract: {
47
- enabled: true,
48
- strict: true,
49
- requireSchemaHash: true,
50
- requireOperationVersion: true
51
- },
52
- setDomain: ()=>(0, external_envelope_js_namespaceObject.resolveOrigin)(defaultOrigin)
53
- };
54
- const runtimeFetch = resolveRuntimeFetch();
55
- if (false !== config.batch.enabled && runtimeFetch) configurePayload.request = (0, index_js_namespaceObject.createDataBatchTransport)({
56
- fetch: runtimeFetch,
57
- endpoint: config.batch.endpoint,
58
- flushIntervalMs: config.batch.flushIntervalMs,
59
- maxBatchSize: config.batch.maxBatchSize,
60
- maxBatchBytes: config.batch.maxBatchBytes,
61
- requestTimeoutMs: config.batch.requestTimeoutMs,
62
- allowedMethods: config.batch.allowedMethods
63
- });
64
- configureRequest(configurePayload);
65
- }
66
- };
67
- exports.configureGeneratedEffectClientRuntime = __webpack_exports__.configureGeneratedEffectClientRuntime;
68
- for(var __rspack_i in __webpack_exports__)if (-1 === [
69
- "configureGeneratedEffectClientRuntime"
70
- ].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
71
- Object.defineProperty(exports, '__esModule', {
72
- value: true
73
- });
@@ -1,145 +0,0 @@
1
- "use strict";
2
- var __webpack_require__ = {};
3
- (()=>{
4
- __webpack_require__.d = (exports1, getters, values)=>{
5
- var define = (defs, kind)=>{
6
- for(var key in defs)if (__webpack_require__.o(defs, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
7
- enumerable: true,
8
- [kind]: defs[key]
9
- });
10
- };
11
- define(getters, "get");
12
- define(values, "value");
13
- };
14
- })();
15
- (()=>{
16
- __webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
17
- })();
18
- (()=>{
19
- __webpack_require__.r = (exports1)=>{
20
- if ("u" > typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
21
- value: 'Module'
22
- });
23
- Object.defineProperty(exports1, '__esModule', {
24
- value: true
25
- });
26
- };
27
- })();
28
- var __webpack_exports__ = {};
29
- __webpack_require__.r(__webpack_exports__);
30
- __webpack_require__.d(__webpack_exports__, {
31
- prepareEffectRequest: ()=>prepareEffectRequest,
32
- resolveOrigin: ()=>resolveOrigin
33
- });
34
- const index_js_namespaceObject = require("../data-platform/index.js");
35
- const external_guards_js_namespaceObject = require("./guards.js");
36
- const external_request_js_namespaceObject = require("./request.js");
37
- const external_request_context_js_namespaceObject = require("./request-context.js");
38
- const DATA_REQUEST_MODES = new Set([
39
- 'cache-first',
40
- 'stale-while-revalidate',
41
- 'network-only'
42
- ]);
43
- const DATA_MUTATION_MODES = new Set([
44
- 'optimistic',
45
- 'pessimistic',
46
- 'fire-and-forget'
47
- ]);
48
- const isDataRequestMode = (value)=>'string' == typeof value && DATA_REQUEST_MODES.has(value);
49
- const isDataMutationMode = (value)=>'string' == typeof value && DATA_MUTATION_MODES.has(value);
50
- const normalizeOrigin = (value)=>{
51
- if ('string' != typeof value || 0 === value.length) return;
52
- try {
53
- return new URL(value).origin;
54
- } catch {
55
- return;
56
- }
57
- };
58
- const resolveOrigin = (defaultOrigin)=>{
59
- if ("u" > typeof window && window.location && 'string' == typeof window.location.origin && window.location.origin) return window.location.origin;
60
- const globalLocation = globalThis?.location;
61
- if (globalLocation && 'string' == typeof globalLocation.origin && globalLocation.origin) return globalLocation.origin;
62
- return defaultOrigin;
63
- };
64
- const resolveTargetOrigin = (dataPlatform, defaultOrigin)=>{
65
- const explicitTargetOrigin = (0, external_guards_js_namespaceObject.stringOrUndefined)(dataPlatform.targetOrigin) || (0, external_guards_js_namespaceObject.stringOrUndefined)(dataPlatform.endpointOrigin);
66
- if (explicitTargetOrigin) return explicitTargetOrigin;
67
- return defaultOrigin;
68
- };
69
- const shouldAttachEnvelopeHeader = (dataPlatform, defaultOrigin)=>{
70
- if (true === dataPlatform.allowCrossOriginEnvelope) return true;
71
- const currentOrigin = normalizeOrigin(resolveOrigin(defaultOrigin));
72
- const targetOrigin = normalizeOrigin(resolveTargetOrigin(dataPlatform, defaultOrigin));
73
- if (!currentOrigin || !targetOrigin) return true;
74
- return currentOrigin === targetOrigin;
75
- };
76
- const toEnvelopeInput = (normalizedRequest)=>{
77
- const payload = {};
78
- if ((0, external_guards_js_namespaceObject.isRecord)(normalizedRequest.params)) payload.path = normalizedRequest.params;
79
- if ((0, external_guards_js_namespaceObject.isRecord)(normalizedRequest.query)) payload.query = normalizedRequest.query;
80
- if ('data' in normalizedRequest && void 0 !== normalizedRequest.data) payload.data = normalizedRequest.data;
81
- if ('body' in normalizedRequest && void 0 !== normalizedRequest.body) payload.body = normalizedRequest.body;
82
- if ("u" > typeof FormData && normalizedRequest.formData instanceof FormData) payload.formData = Array.from(normalizedRequest.formData.entries()).map(([key, value])=>[
83
- key,
84
- String(value)
85
- ]);
86
- if ("u" > typeof URLSearchParams && normalizedRequest.formUrlencoded instanceof URLSearchParams) payload.formUrlencoded = normalizedRequest.formUrlencoded.toString();
87
- return payload;
88
- };
89
- const prepareEffectRequest = (options)=>{
90
- const { endpoint, operation, request, config, createEffectRequestContext } = options;
91
- const defaultOrigin = config.defaultOrigin;
92
- const normalizedRequest = (0, external_request_context_js_namespaceObject.applyRequestContext)((0, external_request_js_namespaceObject.normalizeRequest)(endpoint.method, request), request, createEffectRequestContext);
93
- const dataPlatform = (0, external_guards_js_namespaceObject.isRecord)(request) && (0, external_guards_js_namespaceObject.isRecord)(request.dataPlatform) ? request.dataPlatform : {};
94
- const strictEnvelope = true === dataPlatform.requireEnvelope || true === dataPlatform.strict;
95
- if (!strictEnvelope && !shouldAttachEnvelopeHeader(dataPlatform, defaultOrigin)) return normalizedRequest;
96
- try {
97
- const namespace = (0, external_guards_js_namespaceObject.stringOrUndefined)(dataPlatform.appNamespace) || config.appNamespace;
98
- const origin = (0, external_guards_js_namespaceObject.stringOrUndefined)(dataPlatform.origin) || resolveOrigin(defaultOrigin);
99
- const envelope = (0, index_js_namespaceObject.createRequestEnvelope)({
100
- operation: {
101
- ...operation,
102
- appNamespace: namespace
103
- },
104
- scope: {
105
- appNamespace: namespace,
106
- origin,
107
- tenantId: (0, external_guards_js_namespaceObject.stringOrUndefined)(dataPlatform.tenantId),
108
- userId: (0, external_guards_js_namespaceObject.stringOrUndefined)(dataPlatform.userId),
109
- sessionId: (0, external_guards_js_namespaceObject.stringOrUndefined)(dataPlatform.sessionId)
110
- },
111
- requestInput: {
112
- method: endpoint.method,
113
- routePath: endpoint.routePath,
114
- payload: toEnvelopeInput(normalizedRequest)
115
- },
116
- requestMode: isDataRequestMode(dataPlatform.requestMode) ? dataPlatform.requestMode : void 0,
117
- mutationMode: isDataMutationMode(dataPlatform.mutationMode) ? dataPlatform.mutationMode : void 0,
118
- selectionPlan: (0, external_guards_js_namespaceObject.isRecord)(dataPlatform.selectionPlan) ? dataPlatform.selectionPlan : void 0,
119
- traceContext: (0, external_guards_js_namespaceObject.isRecord)(dataPlatform.traceContext) ? dataPlatform.traceContext : void 0,
120
- requireTraceContext: true === dataPlatform.requireTraceContext
121
- });
122
- const headerName = (0, external_guards_js_namespaceObject.stringOrUndefined)(dataPlatform.envelopeHeader) || index_js_namespaceObject.DEFAULT_DATA_ENVELOPE_HEADER;
123
- const headers = (0, external_guards_js_namespaceObject.isRecord)(normalizedRequest.headers) ? {
124
- ...normalizedRequest.headers
125
- } : {};
126
- if (false === dataPlatform.batch) headers[index_js_namespaceObject.DEFAULT_DATA_BATCH_HEADER] = 'off';
127
- headers[headerName] = (0, index_js_namespaceObject.encodeRequestEnvelopeHeader)(envelope);
128
- return {
129
- ...normalizedRequest,
130
- headers
131
- };
132
- } catch (error) {
133
- if (strictEnvelope) throw error;
134
- return normalizedRequest;
135
- }
136
- };
137
- exports.prepareEffectRequest = __webpack_exports__.prepareEffectRequest;
138
- exports.resolveOrigin = __webpack_exports__.resolveOrigin;
139
- for(var __rspack_i in __webpack_exports__)if (-1 === [
140
- "prepareEffectRequest",
141
- "resolveOrigin"
142
- ].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
143
- Object.defineProperty(exports, '__esModule', {
144
- value: true
145
- });
@@ -1,64 +0,0 @@
1
- "use strict";
2
- var __webpack_require__ = {};
3
- (()=>{
4
- __webpack_require__.d = (exports1, getters, values)=>{
5
- var define = (defs, kind)=>{
6
- for(var key in defs)if (__webpack_require__.o(defs, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
7
- enumerable: true,
8
- [kind]: defs[key]
9
- });
10
- };
11
- define(getters, "get");
12
- define(values, "value");
13
- };
14
- })();
15
- (()=>{
16
- __webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
17
- })();
18
- (()=>{
19
- __webpack_require__.r = (exports1)=>{
20
- if ("u" > typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
21
- value: 'Module'
22
- });
23
- Object.defineProperty(exports1, '__esModule', {
24
- value: true
25
- });
26
- };
27
- })();
28
- var __webpack_exports__ = {};
29
- __webpack_require__.r(__webpack_exports__);
30
- __webpack_require__.d(__webpack_exports__, {
31
- applyRequestContext: ()=>applyRequestContext,
32
- createEffectRequestContext: ()=>createEffectRequestContext
33
- });
34
- const external_guards_js_namespaceObject = require("./guards.js");
35
- const createEffectRequestContext = (createRequestContextHeaders, requestContext)=>{
36
- if (!(0, external_guards_js_namespaceObject.isRecord)(requestContext)) return {};
37
- const headers = createRequestContextHeaders ? createRequestContextHeaders(requestContext) : {};
38
- return {
39
- ...requestContext,
40
- headers
41
- };
42
- };
43
- const applyRequestContext = (normalizedRequest, request, createRequestContext)=>{
44
- if (!(0, external_guards_js_namespaceObject.isRecord)(request) || !(0, external_guards_js_namespaceObject.isRecord)(request.requestContext)) return normalizedRequest;
45
- const requestContext = createRequestContext(request.requestContext);
46
- const requestHeaders = (0, external_guards_js_namespaceObject.isRecord)(requestContext.headers) ? requestContext.headers : {};
47
- if (0 === Object.keys(requestHeaders).length) return normalizedRequest;
48
- return {
49
- ...normalizedRequest,
50
- headers: {
51
- ...(0, external_guards_js_namespaceObject.isRecord)(normalizedRequest.headers) ? normalizedRequest.headers : {},
52
- ...requestHeaders
53
- }
54
- };
55
- };
56
- exports.applyRequestContext = __webpack_exports__.applyRequestContext;
57
- exports.createEffectRequestContext = __webpack_exports__.createEffectRequestContext;
58
- for(var __rspack_i in __webpack_exports__)if (-1 === [
59
- "applyRequestContext",
60
- "createEffectRequestContext"
61
- ].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
62
- Object.defineProperty(exports, '__esModule', {
63
- value: true
64
- });