veryfront 0.1.812 → 0.1.814
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/esm/deno.js +1 -1
- package/esm/src/agent/conversation/durable-append-errors.d.ts +17 -0
- package/esm/src/agent/conversation/durable-append-errors.d.ts.map +1 -0
- package/esm/src/agent/conversation/durable-append-errors.js +49 -0
- package/esm/src/agent/conversation/durable.d.ts +1 -16
- package/esm/src/agent/conversation/durable.d.ts.map +1 -1
- package/esm/src/agent/conversation/durable.js +3 -49
- package/esm/src/agent/runtime/agent-runtime-step.d.ts +44 -0
- package/esm/src/agent/runtime/agent-runtime-step.d.ts.map +1 -0
- package/esm/src/agent/runtime/agent-runtime-step.js +23 -0
- package/esm/src/agent/runtime/index.d.ts.map +1 -1
- package/esm/src/agent/runtime/index.js +45 -62
- package/esm/src/agent/runtime/model-transport.d.ts +23 -0
- package/esm/src/agent/runtime/model-transport.d.ts.map +1 -0
- package/esm/src/agent/runtime/model-transport.js +26 -0
- package/esm/src/agent/runtime/streamed-assistant-message.d.ts +8 -0
- package/esm/src/agent/runtime/streamed-assistant-message.d.ts.map +1 -0
- package/esm/src/agent/runtime/streamed-assistant-message.js +29 -0
- package/esm/src/agent/streaming/fork-runtime-step-progress.d.ts +19 -0
- package/esm/src/agent/streaming/fork-runtime-step-progress.d.ts.map +1 -0
- package/esm/src/agent/streaming/fork-runtime-step-progress.js +53 -0
- package/esm/src/agent/streaming/fork-runtime-stream.d.ts +1 -4
- package/esm/src/agent/streaming/fork-runtime-stream.d.ts.map +1 -1
- package/esm/src/agent/streaming/fork-runtime-stream.js +13 -52
- package/esm/src/cache/keys/builders/render.d.ts.map +1 -1
- package/esm/src/cache/keys/builders/render.js +3 -2
- package/esm/src/cache/request-cacheability.d.ts +3 -0
- package/esm/src/cache/request-cacheability.d.ts.map +1 -0
- package/esm/src/cache/request-cacheability.js +26 -0
- package/esm/src/html/hydration-script-builder/hydration-data-generator.d.ts.map +1 -1
- package/esm/src/html/hydration-script-builder/hydration-data-generator.js +1 -10
- package/esm/src/html/hydration-script-builder/templates/router.d.ts.map +1 -1
- package/esm/src/html/hydration-script-builder/templates/router.js +41 -10
- package/esm/src/observability/request-profiler.d.ts.map +1 -1
- package/esm/src/observability/request-profiler.js +1 -0
- package/esm/src/proxy/handler.d.ts.map +1 -1
- package/esm/src/proxy/handler.js +39 -29
- package/esm/src/proxy/main.js +35 -31
- package/esm/src/proxy/proxy-error-context.d.ts +20 -0
- package/esm/src/proxy/proxy-error-context.d.ts.map +1 -0
- package/esm/src/proxy/proxy-error-context.js +35 -0
- package/esm/src/proxy/request-lifecycle.d.ts +19 -0
- package/esm/src/proxy/request-lifecycle.d.ts.map +1 -0
- package/esm/src/proxy/request-lifecycle.js +27 -0
- package/esm/src/proxy/server-timing.d.ts +11 -0
- package/esm/src/proxy/server-timing.d.ts.map +1 -0
- package/esm/src/proxy/server-timing.js +61 -0
- package/esm/src/proxy/upstream-error-response.d.ts +5 -0
- package/esm/src/proxy/upstream-error-response.d.ts.map +1 -0
- package/esm/src/proxy/upstream-error-response.js +15 -0
- package/esm/src/release-assets/client-module-map.d.ts +3 -0
- package/esm/src/release-assets/client-module-map.d.ts.map +1 -0
- package/esm/src/release-assets/client-module-map.js +10 -0
- package/esm/src/rendering/orchestrator/module-loader/index.d.ts.map +1 -1
- package/esm/src/rendering/orchestrator/module-loader/index.js +13 -49
- package/esm/src/rendering/orchestrator/module-loader/module-cache-lookup.d.ts +25 -0
- package/esm/src/rendering/orchestrator/module-loader/module-cache-lookup.d.ts.map +1 -0
- package/esm/src/rendering/orchestrator/module-loader/module-cache-lookup.js +69 -0
- package/esm/src/rendering/orchestrator/pipeline.d.ts.map +1 -1
- package/esm/src/rendering/orchestrator/pipeline.js +9 -10
- package/esm/src/rendering/orchestrator/types.d.ts +2 -0
- package/esm/src/rendering/orchestrator/types.d.ts.map +1 -1
- package/esm/src/rendering/renderer.d.ts.map +1 -1
- package/esm/src/rendering/renderer.js +24 -19
- package/esm/src/server/handlers/request/module/page-data-endpoint-handler.d.ts +1 -0
- package/esm/src/server/handlers/request/module/page-data-endpoint-handler.d.ts.map +1 -1
- package/esm/src/server/handlers/request/module/page-data-endpoint-handler.js +98 -8
- package/esm/src/utils/version-constant.d.ts +1 -1
- package/esm/src/utils/version-constant.js +1 -1
- package/package.json +9 -9
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
/** Build a fork runtime step from an agent response. */
|
|
2
|
+
export function buildForkRuntimeStepFromResponse(response) {
|
|
3
|
+
const toolCalls = response.toolCalls.map((toolCall) => ({
|
|
4
|
+
toolCallId: toolCall.id,
|
|
5
|
+
toolName: toolCall.name,
|
|
6
|
+
input: toolCall.args,
|
|
7
|
+
}));
|
|
8
|
+
const toolResults = response.toolCalls.flatMap((toolCall) => toolCall.status === "completed"
|
|
9
|
+
? [
|
|
10
|
+
{
|
|
11
|
+
toolCallId: toolCall.id,
|
|
12
|
+
toolName: toolCall.name,
|
|
13
|
+
input: toolCall.args,
|
|
14
|
+
output: toolCall.result,
|
|
15
|
+
},
|
|
16
|
+
]
|
|
17
|
+
: []);
|
|
18
|
+
const finishReasonValue = response.metadata?.finishReason;
|
|
19
|
+
return {
|
|
20
|
+
text: response.text,
|
|
21
|
+
messages: structuredClone(response.messages),
|
|
22
|
+
toolCalls,
|
|
23
|
+
toolResults,
|
|
24
|
+
finishReason: typeof finishReasonValue === "string" ? finishReasonValue : null,
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
/** Should continue fork runtime step helper. */
|
|
28
|
+
export function shouldContinueForkRuntimeStep(step, response) {
|
|
29
|
+
return step.finishReason === "tool-calls" &&
|
|
30
|
+
response.toolCalls.some((toolCall) => toolCall.status !== "error");
|
|
31
|
+
}
|
|
32
|
+
export function createForkRuntimeProgress(currentMessages) {
|
|
33
|
+
return {
|
|
34
|
+
steps: [],
|
|
35
|
+
currentMessages,
|
|
36
|
+
accumulatedInputTokens: 0,
|
|
37
|
+
accumulatedOutputTokens: 0,
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
export function commitForkRuntimeStep(progress, response) {
|
|
41
|
+
const step = buildForkRuntimeStepFromResponse(response);
|
|
42
|
+
progress.steps.push(step);
|
|
43
|
+
progress.accumulatedInputTokens += response.usage?.promptTokens ?? 0;
|
|
44
|
+
progress.accumulatedOutputTokens += response.usage?.completionTokens ?? 0;
|
|
45
|
+
progress.currentMessages = response.messages;
|
|
46
|
+
return step;
|
|
47
|
+
}
|
|
48
|
+
export function getForkRuntimeProgressUsage(progress) {
|
|
49
|
+
return {
|
|
50
|
+
inputTokens: progress.accumulatedInputTokens,
|
|
51
|
+
outputTokens: progress.accumulatedOutputTokens,
|
|
52
|
+
};
|
|
53
|
+
}
|
|
@@ -4,6 +4,7 @@ export { buildRecoveredStepParts, createForkRuntimeStreamMappingState, createFra
|
|
|
4
4
|
export { applyPartToStreamedStepState, createStreamedStepState, resolveForkStepResponse, } from "./fork-runtime-step-state.js";
|
|
5
5
|
export type { ForkRecoveredPartsState, ForkRuntimeStreamMappingState, FrameworkStreamState, RecoveredToolObservation, } from "./fork-runtime-part-mapper.js";
|
|
6
6
|
export type { StreamedStepState } from "./fork-runtime-step-state.js";
|
|
7
|
+
export { buildForkRuntimeStepFromResponse, shouldContinueForkRuntimeStep, } from "./fork-runtime-step-progress.js";
|
|
7
8
|
interface ForkStreamPart {
|
|
8
9
|
type: "reasoning-delta" | "text-delta";
|
|
9
10
|
text: string;
|
|
@@ -162,10 +163,6 @@ export type ForkRuntimeContinuationPromptResolver = (input: {
|
|
|
162
163
|
step: ForkRuntimeStep;
|
|
163
164
|
stepIndex: number;
|
|
164
165
|
}) => Promise<string | null> | string | null;
|
|
165
|
-
/** Response payload for build fork runtime step from. */
|
|
166
|
-
export declare function buildForkRuntimeStepFromResponse(response: AgentResponse): ForkRuntimeStep;
|
|
167
|
-
/** Should continue fork runtime step helper. */
|
|
168
|
-
export declare function shouldContinueForkRuntimeStep(step: ForkRuntimeStep, response: AgentResponse): boolean;
|
|
169
166
|
/** Message shape for create fork runtime user. */
|
|
170
167
|
export declare function createForkRuntimeUserMessage(input: {
|
|
171
168
|
text: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fork-runtime-stream.d.ts","sourceRoot":"","sources":["../../../../src/src/agent/streaming/fork-runtime-stream.ts"],"names":[],"mappings":"AACA,OAAO,EAEL,KAAK,WAAW,EAChB,KAAK,uBAAuB,EAC5B,KAAK,IAAI,EAET,KAAK,qBAAqB,EAC3B,MAAM,qBAAqB,CAAC;AAmB7B,OAAO,KAAK,EAAE,aAAa,EAAE,OAAO,IAAI,YAAY,EAAE,MAAM,qBAAqB,CAAC;
|
|
1
|
+
{"version":3,"file":"fork-runtime-stream.d.ts","sourceRoot":"","sources":["../../../../src/src/agent/streaming/fork-runtime-stream.ts"],"names":[],"mappings":"AACA,OAAO,EAEL,KAAK,WAAW,EAChB,KAAK,uBAAuB,EAC5B,KAAK,IAAI,EAET,KAAK,qBAAqB,EAC3B,MAAM,qBAAqB,CAAC;AAmB7B,OAAO,KAAK,EAAE,aAAa,EAAE,OAAO,IAAI,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAQlF,OAAO,EACL,uBAAuB,EACvB,mCAAmC,EACnC,0BAA0B,EAC1B,8BAA8B,EAC9B,4BAA4B,GAC7B,MAAM,+BAA+B,CAAC;AACvC,OAAO,EACL,4BAA4B,EAC5B,uBAAuB,EACvB,uBAAuB,GACxB,MAAM,8BAA8B,CAAC;AACtC,YAAY,EACV,uBAAuB,EACvB,6BAA6B,EAC7B,oBAAoB,EACpB,wBAAwB,GACzB,MAAM,+BAA+B,CAAC;AACvC,YAAY,EAAE,iBAAiB,EAAE,MAAM,8BAA8B,CAAC;AACtE,OAAO,EACL,gCAAgC,EAChC,6BAA6B,GAC9B,MAAM,iCAAiC,CAAC;AAEzC,UAAU,cAAc;IACtB,IAAI,EAAE,iBAAiB,GAAG,YAAY,CAAC;IACvC,IAAI,EAA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E,0BAA0B,GAAG,uBAAuB,CAiGhG"}
|
|
@@ -6,8 +6,10 @@ import { buildRecoveredStepParts, createForkRuntimeStreamMappingState, mapAgUiRu
|
|
|
6
6
|
import { applyPartToStreamedStepState, createAgentRuntimeForkAbortError, createStreamedStepState, resolveForkStepResponse, } from "./fork-runtime-step-state.js";
|
|
7
7
|
import { getForkRuntimeAllowedToolNames, getProviderNativeToolNames, } from "../runtime/provider-native-tool-inventory.js";
|
|
8
8
|
import { AgentRuntime } from "../runtime/index.js";
|
|
9
|
+
import { commitForkRuntimeStep, createForkRuntimeProgress, getForkRuntimeProgressUsage, shouldContinueForkRuntimeStep, } from "./fork-runtime-step-progress.js";
|
|
9
10
|
export { buildRecoveredStepParts, createForkRuntimeStreamMappingState, createFrameworkStreamState, mapAgUiRuntimeEventToForkParts, mapFrameworkEventToForkParts, } from "./fork-runtime-part-mapper.js";
|
|
10
11
|
export { applyPartToStreamedStepState, createStreamedStepState, resolveForkStepResponse, } from "./fork-runtime-step-state.js";
|
|
12
|
+
export { buildForkRuntimeStepFromResponse, shouldContinueForkRuntimeStep, } from "./fork-runtime-step-progress.js";
|
|
11
13
|
/** Default value for fork response promise timeout ms. */
|
|
12
14
|
export const DEFAULT_FORK_RESPONSE_PROMISE_TIMEOUT_MS = 1_000;
|
|
13
15
|
/** Starts agent runtime fork with host tools. */
|
|
@@ -143,37 +145,6 @@ export function runFrameworkForkStep(input) {
|
|
|
143
145
|
...(input.providerOptions ? { providerOptions: input.providerOptions } : {}),
|
|
144
146
|
});
|
|
145
147
|
}
|
|
146
|
-
/** Response payload for build fork runtime step from. */
|
|
147
|
-
export function buildForkRuntimeStepFromResponse(response) {
|
|
148
|
-
const toolCalls = response.toolCalls.map((toolCall) => ({
|
|
149
|
-
toolCallId: toolCall.id,
|
|
150
|
-
toolName: toolCall.name,
|
|
151
|
-
input: toolCall.args,
|
|
152
|
-
}));
|
|
153
|
-
const toolResults = response.toolCalls.flatMap((toolCall) => toolCall.status === "completed"
|
|
154
|
-
? [
|
|
155
|
-
{
|
|
156
|
-
toolCallId: toolCall.id,
|
|
157
|
-
toolName: toolCall.name,
|
|
158
|
-
input: toolCall.args,
|
|
159
|
-
output: toolCall.result,
|
|
160
|
-
},
|
|
161
|
-
]
|
|
162
|
-
: []);
|
|
163
|
-
const finishReasonValue = response.metadata?.finishReason;
|
|
164
|
-
return {
|
|
165
|
-
text: response.text,
|
|
166
|
-
messages: structuredClone(response.messages),
|
|
167
|
-
toolCalls,
|
|
168
|
-
toolResults,
|
|
169
|
-
finishReason: typeof finishReasonValue === "string" ? finishReasonValue : null,
|
|
170
|
-
};
|
|
171
|
-
}
|
|
172
|
-
/** Should continue fork runtime step helper. */
|
|
173
|
-
export function shouldContinueForkRuntimeStep(step, response) {
|
|
174
|
-
return step.finishReason === "tool-calls" &&
|
|
175
|
-
response.toolCalls.some((toolCall) => toolCall.status !== "error");
|
|
176
|
-
}
|
|
177
148
|
/** Message shape for create fork runtime user. */
|
|
178
149
|
export function createForkRuntimeUserMessage(input) {
|
|
179
150
|
return {
|
|
@@ -222,25 +193,22 @@ export async function resolveForkRuntimeContinuationState(input) {
|
|
|
222
193
|
export function startAgentRuntimeFork(input) {
|
|
223
194
|
const stepsDeferred = createForkRuntimeDeferred();
|
|
224
195
|
const totalUsageDeferred = createForkRuntimeDeferred();
|
|
225
|
-
const steps = [];
|
|
226
|
-
let accumulatedInputTokens = 0;
|
|
227
|
-
let accumulatedOutputTokens = 0;
|
|
228
196
|
const runStep = input.runStep ?? runAgentRuntimeForkStep;
|
|
229
197
|
return {
|
|
230
198
|
fullStream: (async function* () {
|
|
231
199
|
if (!input.initialMessages?.length && typeof input.prompt !== "string") {
|
|
232
200
|
throw new Error("startAgentRuntimeFork requires a prompt when no initialMessages are provided.");
|
|
233
201
|
}
|
|
234
|
-
|
|
202
|
+
const progress = createForkRuntimeProgress(createInitialForkRuntimeMessages({
|
|
235
203
|
initialMessages: input.initialMessages,
|
|
236
204
|
prompt: input.prompt,
|
|
237
|
-
});
|
|
205
|
+
}));
|
|
238
206
|
let continuationStepsRemaining = input.maxContinuationSteps ?? 0;
|
|
239
207
|
try {
|
|
240
|
-
while (steps.length < getMaxForkRuntimeStepCount(input)) {
|
|
208
|
+
while (progress.steps.length < getMaxForkRuntimeStepCount(input)) {
|
|
241
209
|
const prepared = await prepareForkRuntimeStep({
|
|
242
210
|
prepareStep: input.prepareStep,
|
|
243
|
-
messages: currentMessages,
|
|
211
|
+
messages: progress.currentMessages,
|
|
244
212
|
buildInstructions: input.buildInstructions,
|
|
245
213
|
forkToolNames: input.forkToolNames,
|
|
246
214
|
});
|
|
@@ -270,38 +238,31 @@ export function startAgentRuntimeFork(input) {
|
|
|
270
238
|
responsePromise,
|
|
271
239
|
responseTimeoutMs: input.responseTimeoutMs ?? DEFAULT_FORK_RESPONSE_PROMISE_TIMEOUT_MS,
|
|
272
240
|
...(input.abortSignal ? { abortSignal: input.abortSignal } : {}),
|
|
273
|
-
currentMessages,
|
|
241
|
+
currentMessages: progress.currentMessages,
|
|
274
242
|
streamedStepState,
|
|
275
243
|
});
|
|
276
|
-
const step =
|
|
244
|
+
const step = commitForkRuntimeStep(progress, response);
|
|
277
245
|
for (const recoveredPart of buildRecoveredStepParts(step, state)) {
|
|
278
246
|
yield recoveredPart;
|
|
279
247
|
}
|
|
280
|
-
steps.push(step);
|
|
281
|
-
accumulatedInputTokens += response.usage?.promptTokens ?? 0;
|
|
282
|
-
accumulatedOutputTokens += response.usage?.completionTokens ?? 0;
|
|
283
|
-
currentMessages = response.messages;
|
|
284
248
|
if (!shouldContinueForkRuntimeStep(step, response)) {
|
|
285
249
|
const followUpState = await resolveForkRuntimeContinuationState({
|
|
286
250
|
continuationStepsRemaining,
|
|
287
251
|
onBeforeStop: input.onBeforeStop,
|
|
288
252
|
step,
|
|
289
|
-
currentMessages,
|
|
290
|
-
stepIndex: steps.length - 1,
|
|
253
|
+
currentMessages: progress.currentMessages,
|
|
254
|
+
stepIndex: progress.steps.length - 1,
|
|
291
255
|
});
|
|
292
256
|
if (followUpState) {
|
|
293
257
|
continuationStepsRemaining = followUpState.continuationStepsRemaining;
|
|
294
|
-
currentMessages = followUpState.currentMessages;
|
|
258
|
+
progress.currentMessages = followUpState.currentMessages;
|
|
295
259
|
continue;
|
|
296
260
|
}
|
|
297
261
|
break;
|
|
298
262
|
}
|
|
299
263
|
}
|
|
300
|
-
stepsDeferred.resolve(steps);
|
|
301
|
-
totalUsageDeferred.resolve(
|
|
302
|
-
inputTokens: accumulatedInputTokens,
|
|
303
|
-
outputTokens: accumulatedOutputTokens,
|
|
304
|
-
});
|
|
264
|
+
stepsDeferred.resolve(progress.steps);
|
|
265
|
+
totalUsageDeferred.resolve(getForkRuntimeProgressUsage(progress));
|
|
305
266
|
}
|
|
306
267
|
catch (error) {
|
|
307
268
|
stepsDeferred.reject(error);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"render.d.ts","sourceRoot":"","sources":["../../../../../src/src/cache/keys/builders/render.ts"],"names":[],"mappings":"AAAA;;;;;;;kFAOkF;AAIlF,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,gBAAgB,CAAC;AAI7D,wBAAgB,sBAAsB,CACpC,SAAS,EAAE,MAAM,EACjB,WAAW,EAAE,SAAS,GAAG,YAAY,EACrC,UAAU,EAAE,MAAM;AAClB;;;;;GAKG;AACH,eAAe,CAAC,EAAE,MAAM,GACvB,MAAM,CAGR;AAED;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,sBAAsB,CACpC,OAAO,EAAE,OAAO,EAChB,WAAW,EAAE,SAAS,GAAG,YAAY,EACrC,MAAM,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,EACjC,SAAS,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,GACnC,MAAM,CAaR;AAED,wBAAgB,mBAAmB,CAAC,WAAW,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,GAAG,MAAM,CAEnF;AAED,wBAAgB,sBAAsB,CACpC,SAAS,EAAE,MAAM,EACjB,QAAQ,EAAE,MAAM,EAChB,WAAW,EAAE,MAAM,GAClB,MAAM,CAER;AAED,wBAAgB,4BAA4B,CAC1C,SAAS,EAAE,MAAM,EACjB,aAAa,EAAE,MAAM,EACrB,IAAI,EAAE,MAAM,EACZ,eAAe,EAAE,MAAM,GACtB,MAAM,CAER;AAED,wBAAgB,sBAAsB,CACpC,SAAS,EAAE,MAAM,GAAG,SAAS,EAC7B,UAAU,EAAE,MAAM,EAClB,QAAQ,EAAE,MAAM,GACf,MAAM,CAER;AAED,wBAAgB,yBAAyB,CACvC,WAAW,EAAE,MAAM,EACnB,cAAc,EAAE,OAAO,EACvB,SAAS,EAAE,MAAM,GAAG,IAAI,EACxB,MAAM,EAAE,MAAM,GAAG,IAAI,GACpB,MAAM,CAaR;AAED;;;;;;;GAOG;AACH,wBAAgB,uBAAuB,CACrC,IAAI,EAAE,MAAM,EACZ,GAAG,CAAC,EAAE,GAAG,EACT,OAAO,CAAC,EAAE,sBAAsB,GAC/B,MAAM,
|
|
1
|
+
{"version":3,"file":"render.d.ts","sourceRoot":"","sources":["../../../../../src/src/cache/keys/builders/render.ts"],"names":[],"mappings":"AAAA;;;;;;;kFAOkF;AAIlF,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,gBAAgB,CAAC;AAI7D,wBAAgB,sBAAsB,CACpC,SAAS,EAAE,MAAM,EACjB,WAAW,EAAE,SAAS,GAAG,YAAY,EACrC,UAAU,EAAE,MAAM;AAClB;;;;;GAKG;AACH,eAAe,CAAC,EAAE,MAAM,GACvB,MAAM,CAGR;AAED;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,sBAAsB,CACpC,OAAO,EAAE,OAAO,EAChB,WAAW,EAAE,SAAS,GAAG,YAAY,EACrC,MAAM,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,EACjC,SAAS,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,GACnC,MAAM,CAaR;AAED,wBAAgB,mBAAmB,CAAC,WAAW,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,GAAG,MAAM,CAEnF;AAED,wBAAgB,sBAAsB,CACpC,SAAS,EAAE,MAAM,EACjB,QAAQ,EAAE,MAAM,EAChB,WAAW,EAAE,MAAM,GAClB,MAAM,CAER;AAED,wBAAgB,4BAA4B,CAC1C,SAAS,EAAE,MAAM,EACjB,aAAa,EAAE,MAAM,EACrB,IAAI,EAAE,MAAM,EACZ,eAAe,EAAE,MAAM,GACtB,MAAM,CAER;AAED,wBAAgB,sBAAsB,CACpC,SAAS,EAAE,MAAM,GAAG,SAAS,EAC7B,UAAU,EAAE,MAAM,EAClB,QAAQ,EAAE,MAAM,GACf,MAAM,CAER;AAED,wBAAgB,yBAAyB,CACvC,WAAW,EAAE,MAAM,EACnB,cAAc,EAAE,OAAO,EACvB,SAAS,EAAE,MAAM,GAAG,IAAI,EACxB,MAAM,EAAE,MAAM,GAAG,IAAI,GACpB,MAAM,CAaR;AAED;;;;;;;GAOG;AACH,wBAAgB,uBAAuB,CACrC,IAAI,EAAE,MAAM,EACZ,GAAG,CAAC,EAAE,GAAG,EACT,OAAO,CAAC,EAAE,sBAAsB,GAC/B,MAAM,CAMR"}
|
|
@@ -82,8 +82,9 @@ export function buildProxyManagerCacheKey(projectSlug, productionMode, releaseId
|
|
|
82
82
|
* @returns Cache key string
|
|
83
83
|
*/
|
|
84
84
|
export function buildQueryAwareCacheKey(slug, url, options) {
|
|
85
|
+
const normalizedSlug = slug || "index";
|
|
85
86
|
if (!url)
|
|
86
|
-
return
|
|
87
|
+
return normalizedSlug;
|
|
87
88
|
const queryPart = sanitizeQueryParamsForCacheKey(url, options);
|
|
88
|
-
return queryPart ? `${
|
|
89
|
+
return queryPart ? `${normalizedSlug}:q:${queryPart}` : normalizedSlug;
|
|
89
90
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"request-cacheability.d.ts","sourceRoot":"","sources":["../../../src/src/cache/request-cacheability.ts"],"names":[],"mappings":"AAIA,wBAAgB,6BAA6B,CAAC,GAAG,EAAE,OAAO,GAAG,OAAO,CASnE;AAED,wBAAgB,wBAAwB,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAE9D"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
const CACHE_NEUTRAL_COOKIES = new Set([
|
|
2
|
+
"lb",
|
|
3
|
+
]);
|
|
4
|
+
export function requestHasCacheSensitiveState(req) {
|
|
5
|
+
if (req.headers.has("authorization") || req.headers.has("x-api-key")) {
|
|
6
|
+
return true;
|
|
7
|
+
}
|
|
8
|
+
const cookieHeader = req.headers.get("cookie");
|
|
9
|
+
if (!cookieHeader)
|
|
10
|
+
return false;
|
|
11
|
+
return parseCookieNames(cookieHeader).some((name) => !isCacheNeutralCookieName(name));
|
|
12
|
+
}
|
|
13
|
+
export function isCacheNeutralCookieName(name) {
|
|
14
|
+
return CACHE_NEUTRAL_COOKIES.has(name.trim().toLowerCase());
|
|
15
|
+
}
|
|
16
|
+
function parseCookieNames(cookieHeader) {
|
|
17
|
+
return cookieHeader
|
|
18
|
+
.split(";")
|
|
19
|
+
.map((part) => part.trim())
|
|
20
|
+
.filter(Boolean)
|
|
21
|
+
.map((part) => {
|
|
22
|
+
const separatorIndex = part.indexOf("=");
|
|
23
|
+
return separatorIndex === -1 ? part : part.slice(0, separatorIndex).trim();
|
|
24
|
+
})
|
|
25
|
+
.filter(Boolean);
|
|
26
|
+
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"hydration-data-generator.d.ts","sourceRoot":"","sources":["../../../../src/src/html/hydration-script-builder/hydration-data-generator.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAM3D,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,yCAAyC,CAAC;AACpF,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,aAAa,CAAC;AA8BzD,KAAK,gBAAgB,GAAG,qBAAqB,GAAG;IAC9C,oBAAoB,CAAC,EAAE,oBAAoB,GAAG,IAAI,CAAC;CACpD,CAAC;
|
|
1
|
+
{"version":3,"file":"hydration-data-generator.d.ts","sourceRoot":"","sources":["../../../../src/src/html/hydration-script-builder/hydration-data-generator.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAM3D,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,yCAAyC,CAAC;AACpF,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,aAAa,CAAC;AA8BzD,KAAK,gBAAgB,GAAG,qBAAqB,GAAG;IAC9C,oBAAoB,CAAC,EAAE,oBAAoB,GAAG,IAAI,CAAC;CACpD,CAAC;AAEF,wBAAgB,qBAAqB,CACnC,IAAI,EAAE,MAAM,EACZ,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC,EACzC,KAAK,EAAE,cAAc,EACrB,OAAO,EAAE,gBAAgB,EACzB,gBAAgB,CAAC,EAAE;IAAE,MAAM,CAAC,EAAE,OAAO,CAAA;CAAE,GACtC,MAAM,CAiDR"}
|
|
@@ -2,7 +2,7 @@ import { resolveRelativePath } from "../../modules/react-loader/path-resolver.js
|
|
|
2
2
|
import { getExtensionName } from "../../utils/path-utils.js";
|
|
3
3
|
import { determineClientModuleStrategy } from "../../rendering/rsc/client-module-strategy.js";
|
|
4
4
|
import { jsonForInlineScript } from "../../security/client/html-sanitizer.js";
|
|
5
|
-
import {
|
|
5
|
+
import { buildReleaseAssetModules } from "../../release-assets/client-module-map.js";
|
|
6
6
|
function toProjectRelativePath(absolutePath, projectDir) {
|
|
7
7
|
if (!absolutePath)
|
|
8
8
|
return "";
|
|
@@ -20,15 +20,6 @@ function inferPageType(pagePath) {
|
|
|
20
20
|
return undefined;
|
|
21
21
|
return PAGE_TYPE_EXTENSIONS.has(ext) ? ext : undefined;
|
|
22
22
|
}
|
|
23
|
-
function buildReleaseAssetModules(manifest) {
|
|
24
|
-
if (!manifest)
|
|
25
|
-
return undefined;
|
|
26
|
-
const modules = {};
|
|
27
|
-
for (const [path, entry] of Object.entries(manifest.modules)) {
|
|
28
|
-
modules[path] = releaseAssetUrl(entry.contentHash, "js");
|
|
29
|
-
}
|
|
30
|
-
return Object.keys(modules).length > 0 ? modules : undefined;
|
|
31
|
-
}
|
|
32
23
|
export function generateHydrationData(slug, params, props, options, serializeOptions) {
|
|
33
24
|
const layouts = (options.nestedLayouts ?? [])
|
|
34
25
|
.map((layout) => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"router.d.ts","sourceRoot":"","sources":["../../../../../src/src/html/hydration-script-builder/templates/router.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,eAAe,
|
|
1
|
+
{"version":3,"file":"router.d.ts","sourceRoot":"","sources":["../../../../../src/src/html/hydration-script-builder/templates/router.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,eAAe,cAwtB3B,CAAC"}
|
|
@@ -306,9 +306,11 @@ export const getRouterScript = () => `
|
|
|
306
306
|
|
|
307
307
|
async function fetchPageDataForPrefetch(path) {
|
|
308
308
|
if (getCachedPageData(path)) return;
|
|
309
|
-
return fetchPageDataFresh(path, null)
|
|
310
|
-
|
|
311
|
-
|
|
309
|
+
return fetchPageDataFresh(path, null)
|
|
310
|
+
.then((data) => preloadModulesForPageData(data, path))
|
|
311
|
+
.catch((error) => {
|
|
312
|
+
logBackgroundFetchFailure('Page data prefetch', path, error);
|
|
313
|
+
});
|
|
312
314
|
}
|
|
313
315
|
|
|
314
316
|
// ============================================
|
|
@@ -406,11 +408,7 @@ export const getRouterScript = () => `
|
|
|
406
408
|
}
|
|
407
409
|
|
|
408
410
|
perfStart('render:loadAll');
|
|
409
|
-
const
|
|
410
|
-
const allPaths = [pageData.pagePath, ...layoutPaths];
|
|
411
|
-
|
|
412
|
-
if (pageData.appPath) allPaths.push(pageData.appPath);
|
|
413
|
-
|
|
411
|
+
const allPaths = getPageDataModulePaths(pageData);
|
|
414
412
|
const components = await Promise.all(allPaths.map((path) => loadComponent(path)));
|
|
415
413
|
perfEnd('render:loadAll');
|
|
416
414
|
|
|
@@ -517,14 +515,47 @@ export const getRouterScript = () => `
|
|
|
517
515
|
}
|
|
518
516
|
|
|
519
517
|
// ============================================
|
|
520
|
-
// Prefetching on hover
|
|
518
|
+
// Prefetching on hover
|
|
521
519
|
// ============================================
|
|
522
520
|
let prefetchTimeout = null;
|
|
523
521
|
const prefetchedPaths = new Set();
|
|
524
522
|
const inFlightPrefetches = new Set();
|
|
525
523
|
|
|
524
|
+
function getPageDataModulePaths(pageData) {
|
|
525
|
+
const layoutPaths = (pageData.layouts || []).map((l) => l.path).filter(Boolean);
|
|
526
|
+
const allPaths = [pageData.pagePath, ...layoutPaths].filter(Boolean);
|
|
527
|
+
|
|
528
|
+
if (pageData.appPath) allPaths.push(pageData.appPath);
|
|
529
|
+
|
|
530
|
+
return allPaths;
|
|
531
|
+
}
|
|
532
|
+
|
|
533
|
+
async function preloadModulesForPageData(pageData, path) {
|
|
534
|
+
if (!pageData) return;
|
|
535
|
+
if (pageData.releaseAssetModules && window.__veryfrontSetReleaseAssetModules) {
|
|
536
|
+
window.__veryfrontSetReleaseAssetModules(pageData.releaseAssetModules);
|
|
537
|
+
}
|
|
538
|
+
|
|
539
|
+
const modulePaths = getPageDataModulePaths(pageData);
|
|
540
|
+
if (modulePaths.length === 0) return;
|
|
541
|
+
|
|
542
|
+
try {
|
|
543
|
+
await Promise.all(modulePaths.map((modulePath) => loadComponent(modulePath)));
|
|
544
|
+
} catch (error) {
|
|
545
|
+
logBackgroundFetchFailure('Module prefetch', path, error);
|
|
546
|
+
}
|
|
547
|
+
}
|
|
548
|
+
|
|
526
549
|
function prefetchPage(href) {
|
|
527
|
-
if (prefetchedPaths.has(href) ||
|
|
550
|
+
if (prefetchedPaths.has(href) || inFlightPrefetches.has(href)) return;
|
|
551
|
+
|
|
552
|
+
const cachedPageData = getCachedPageData(href);
|
|
553
|
+
if (cachedPageData) {
|
|
554
|
+
preloadModulesForPageData(cachedPageData, href).catch((error) => {
|
|
555
|
+
logBackgroundFetchFailure('Module prefetch', href, error);
|
|
556
|
+
});
|
|
557
|
+
return;
|
|
558
|
+
}
|
|
528
559
|
|
|
529
560
|
if (prefetchedPaths.size >= MAX_PREFETCH_PATHS) {
|
|
530
561
|
const oldest = prefetchedPaths.values().next().value;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"request-profiler.d.ts","sourceRoot":"","sources":["../../../src/src/observability/request-profiler.ts"],"names":[],"mappings":"AAGA,MAAM,WAAW,oBAAoB;IACnC,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,MAAM,CAAC;IACjB,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE,MAAM,CAAC;IACjB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,SAAS,EAAE,MAAM,CAAC;IAClB,WAAW,EAAE,MAAM,CAAC;IACpB,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CAChC;AAED,MAAM,WAAW,2BAA2B;IAC1C,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;
|
|
1
|
+
{"version":3,"file":"request-profiler.d.ts","sourceRoot":"","sources":["../../../src/src/observability/request-profiler.ts"],"names":[],"mappings":"AAGA,MAAM,WAAW,oBAAoB;IACnC,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,MAAM,CAAC;IACjB,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE,MAAM,CAAC;IACjB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,MAAM,CA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BAAsB,CACpC,QAAQ,EAAE,QAAQ,EAClB,MAAM,EAAE,oBAAoB,GAAG,IAAI,GAClC,QAAQ,CAiBV;AAED,wBAAgB,uBAAuB,IAAI;IACzC,OAAO,EAAE,OAAO,CAAC;IACjB,aAAa,EAAE,MAAM,CAAC;IACtB,OAAO,EAAE,oBAAoB,EAAE,CAAC;CACjC,CAMA;AAED,wBAAgB,oBAAoB,IAAI,IAAI,CAG3C"}
|
|
@@ -22,6 +22,7 @@ function shouldProfilePath(pathname) {
|
|
|
22
22
|
pathname.startsWith("/api/bench/") ||
|
|
23
23
|
pathname.startsWith("/_vf_styles/") ||
|
|
24
24
|
pathname.startsWith("/_vf_modules/") ||
|
|
25
|
+
(shouldEnableServerTiming() && pathname.startsWith("/_veryfront/page-data/")) ||
|
|
25
26
|
(shouldEnableServerTiming() && isHtmlPath(pathname));
|
|
26
27
|
}
|
|
27
28
|
export function isRequestProfilingEnabled(pathname) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"handler.d.ts","sourceRoot":"","sources":["../../../src/src/proxy/handler.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,YAAY,EAAsB,MAAM,kCAAkC,CAAC;AACzF,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;
|
|
1
|
+
{"version":3,"file":"handler.d.ts","sourceRoot":"","sources":["../../../src/src/proxy/handler.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,YAAY,EAAsB,MAAM,kCAAkC,CAAC;AACzF,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAenD,OAAO,EAAE,iCAAiC,EAAE,MAAM,2BAA2B,CAAC;AAE9E,eAAO,MAAM,sBAAsB,0MAYzB,CAAC;AAyGX,MAAM,WAAW,WAAW;IAC1B,UAAU,EAAE,MAAM,CAAC;IACnB,WAAW,EAAE,MAAM,CAAC;IACpB,eAAe,EAAE,MAAM,CAAC;IACxB,kBAAkB,EAA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M,EAAE,KAAK,CAAC,EAAE,KAAK,EAAE,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,KAAK,IAAI,CAAC;CAC9E;AAED,MAAM,WAAW,mBAAmB;IAClC,MAAM,EAAE,WAAW,CAAC;IACpB,KAAK,CAAC,EAAE,UAAU,CAAC;IACnB,MAAM,CAAC,EAAE,WAAW,CAAC;CACtB;AAED,MAAM,WAAW,mBAAmB;IAClC,GAAG,CAAC,EAAE,GAAG,CAAC;CACX;AAgBD,wBAAgB,kBAAkB,CAAC,OAAO,EAAE,mBAAmB;0BA6DtD,OAAO,YACH,mBAAmB,KAC3B,OAAO,CAAC,YAAY,CAAC;0BAiRjB,OAAO,YACH,mBAAmB,KAC3B,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC;;;;;;;;0BAlUH,MAAM,EAAE;;EAwWpC;AAED,MAAM,MAAM,YAAY,GAAG,UAAU,CAAC,OAAO,kBAAkB,CAAC,CAAC;AAEjE,wBAAgB,oBAAoB,CAAC,GAAG,EAAE,OAAO,EAAE,GAAG,EAAE,YAAY,GAAG,OAAO,CAwB7E"}
|
package/esm/src/proxy/handler.js
CHANGED
|
@@ -5,6 +5,7 @@ import { computeContentSourceId } from "../cache/keys.js";
|
|
|
5
5
|
import { checkProtectedProxyAccess } from "./proxy-access-control.js";
|
|
6
6
|
import { createLocalProjectResolver } from "./local-project-resolver.js";
|
|
7
7
|
import { isMissingCustomDomainProjectError, resolveProxyRequestToken, } from "./proxy-token-resolution.js";
|
|
8
|
+
import { createProjectNotFoundProxyContext, createProxyErrorContext, createReleaseNotFoundProxyContext, } from "./proxy-error-context.js";
|
|
8
9
|
export { __resetCachedAuthProviderForTests } from "./proxy-access-control.js";
|
|
9
10
|
export const INTERNAL_PROXY_HEADERS = [
|
|
10
11
|
"x-token",
|
|
@@ -113,23 +114,6 @@ export function createProxyHandler(options) {
|
|
|
113
114
|
missing.push("VERYFRONT_PROXY_API_CLIENT_SECRET");
|
|
114
115
|
return missing;
|
|
115
116
|
}
|
|
116
|
-
function makeErrorContext(base, status, message, token, redirectUrl, slug) {
|
|
117
|
-
return {
|
|
118
|
-
token,
|
|
119
|
-
projectSlug: undefined,
|
|
120
|
-
projectId: undefined,
|
|
121
|
-
environment: base.scope,
|
|
122
|
-
contentSourceId: "error",
|
|
123
|
-
localPath: undefined,
|
|
124
|
-
host: base.host,
|
|
125
|
-
parsedDomain: base.parsedDomain,
|
|
126
|
-
isLocalProject: false,
|
|
127
|
-
error: { status, message, redirectUrl, slug },
|
|
128
|
-
};
|
|
129
|
-
}
|
|
130
|
-
function makeProjectNotFoundContext(base, message, token) {
|
|
131
|
-
return makeErrorContext(base, 404, message, token, undefined, "project-not-found");
|
|
132
|
-
}
|
|
133
117
|
async function resolveReleaseAndProtection(req, url, token, userToken, lookupKey, envMatcher, logContext) {
|
|
134
118
|
const lookupResult = await lookupProjectByDomain(lookupKey, config.apiBaseUrl, token, logger);
|
|
135
119
|
if (!lookupResult)
|
|
@@ -213,10 +197,10 @@ export function createProxyHandler(options) {
|
|
|
213
197
|
if (status === 404) {
|
|
214
198
|
if (scope === "preview") {
|
|
215
199
|
logger?.info("Preview project not found", { projectSlug, host });
|
|
216
|
-
return
|
|
200
|
+
return createProjectNotFoundProxyContext(base, "Preview project not found");
|
|
217
201
|
}
|
|
218
202
|
logger?.info("Project not found", { projectSlug, host, scope });
|
|
219
|
-
return
|
|
203
|
+
return createProjectNotFoundProxyContext(base, "Project not found");
|
|
220
204
|
}
|
|
221
205
|
const message = scope === "preview"
|
|
222
206
|
? "Failed to authenticate preview request"
|
|
@@ -228,7 +212,7 @@ export function createProxyHandler(options) {
|
|
|
228
212
|
hadUserToken: !!userToken,
|
|
229
213
|
hadTokenFetchError: !!tokenFetchError,
|
|
230
214
|
});
|
|
231
|
-
return
|
|
215
|
+
return createProxyErrorContext(base, { status: 502, message });
|
|
232
216
|
}
|
|
233
217
|
if (isCustomDomain && !projectSlug) {
|
|
234
218
|
if (!token) {
|
|
@@ -236,15 +220,26 @@ export function createProxyHandler(options) {
|
|
|
236
220
|
logger?.info("Custom domain project not found during token fetch", {
|
|
237
221
|
domain: host,
|
|
238
222
|
});
|
|
239
|
-
return
|
|
223
|
+
return createProxyErrorContext(base, {
|
|
224
|
+
status: 404,
|
|
225
|
+
message: `No project configured for domain: ${host}`,
|
|
226
|
+
});
|
|
240
227
|
}
|
|
241
228
|
logger?.error("Cannot process custom domain without token", undefined, { domain: host });
|
|
242
|
-
return
|
|
229
|
+
return createProxyErrorContext(base, {
|
|
230
|
+
status: 502,
|
|
231
|
+
message: `Failed to authenticate for domain: ${host}`,
|
|
232
|
+
token,
|
|
233
|
+
});
|
|
243
234
|
}
|
|
244
235
|
const lookupResult = await lookupProjectByDomain(host, config.apiBaseUrl, token, logger);
|
|
245
236
|
if (!lookupResult) {
|
|
246
237
|
logger?.info("Custom domain not found", { domain: host });
|
|
247
|
-
return
|
|
238
|
+
return createProxyErrorContext(base, {
|
|
239
|
+
status: 404,
|
|
240
|
+
message: `No project configured for domain: ${host}`,
|
|
241
|
+
token,
|
|
242
|
+
});
|
|
248
243
|
}
|
|
249
244
|
projectSlug = lookupResult.slug;
|
|
250
245
|
projectId = lookupResult.id;
|
|
@@ -264,7 +259,12 @@ export function createProxyHandler(options) {
|
|
|
264
259
|
isSignedInternalControlPlaneRequest: isSignedInternalControlPlaneRequest(req, url),
|
|
265
260
|
});
|
|
266
261
|
if (protectionError) {
|
|
267
|
-
return
|
|
262
|
+
return createProxyErrorContext(base, {
|
|
263
|
+
status: protectionError.status,
|
|
264
|
+
message: protectionError.message,
|
|
265
|
+
token,
|
|
266
|
+
redirectUrl: protectionError.redirectUrl,
|
|
267
|
+
});
|
|
268
268
|
}
|
|
269
269
|
logger?.info("Resolved custom domain to project", {
|
|
270
270
|
domain: host,
|
|
@@ -278,7 +278,12 @@ export function createProxyHandler(options) {
|
|
|
278
278
|
const targetEnv = parsedDomain.environment.toLowerCase();
|
|
279
279
|
const resolved = await resolveReleaseAndProtection(req, url, token, userToken, projectSlug, (env) => env.name.toLowerCase() === targetEnv, { projectSlug });
|
|
280
280
|
if ("error" in resolved) {
|
|
281
|
-
return
|
|
281
|
+
return createProxyErrorContext(base, {
|
|
282
|
+
status: resolved.error.status,
|
|
283
|
+
message: resolved.error.message,
|
|
284
|
+
token,
|
|
285
|
+
redirectUrl: resolved.error.redirectUrl,
|
|
286
|
+
});
|
|
282
287
|
}
|
|
283
288
|
if (!resolved.projectId) {
|
|
284
289
|
logger?.info("Project not found after lookup", {
|
|
@@ -287,7 +292,7 @@ export function createProxyHandler(options) {
|
|
|
287
292
|
scope,
|
|
288
293
|
targetEnvName: parsedDomain.environment,
|
|
289
294
|
});
|
|
290
|
-
return
|
|
295
|
+
return createProjectNotFoundProxyContext(base, "Project not found", token);
|
|
291
296
|
}
|
|
292
297
|
projectId = resolved.projectId;
|
|
293
298
|
releaseId = resolved.releaseId;
|
|
@@ -305,11 +310,16 @@ export function createProxyHandler(options) {
|
|
|
305
310
|
// still enforce the environment's `protected` flag like other scopes.
|
|
306
311
|
const resolved = await resolveReleaseAndProtection(req, url, token, userToken, projectSlug, (env) => env.name.toLowerCase() === "preview", { projectSlug });
|
|
307
312
|
if ("error" in resolved) {
|
|
308
|
-
return
|
|
313
|
+
return createProxyErrorContext(base, {
|
|
314
|
+
status: resolved.error.status,
|
|
315
|
+
message: resolved.error.message,
|
|
316
|
+
token,
|
|
317
|
+
redirectUrl: resolved.error.redirectUrl,
|
|
318
|
+
});
|
|
309
319
|
}
|
|
310
320
|
if (!resolved.projectId) {
|
|
311
321
|
logger?.info("Preview project not found after lookup", { projectSlug, host });
|
|
312
|
-
return
|
|
322
|
+
return createProjectNotFoundProxyContext(base, "Preview project not found", token);
|
|
313
323
|
}
|
|
314
324
|
projectId = resolved.projectId;
|
|
315
325
|
environmentId = resolved.environmentId;
|
|
@@ -329,7 +339,7 @@ export function createProxyHandler(options) {
|
|
|
329
339
|
host,
|
|
330
340
|
environment: scope,
|
|
331
341
|
});
|
|
332
|
-
return
|
|
342
|
+
return createReleaseNotFoundProxyContext({ scope, host, parsedDomain }, token);
|
|
333
343
|
}
|
|
334
344
|
const contentSourceId = computeContentSourceId(isLocalProject, scope, parsedDomain.branch, releaseId);
|
|
335
345
|
return {
|