Some checks failed
CI / go (push) Waiting to run
CI / docker (push) Waiting to run
CI / lint-go (push) Waiting to run
CI / lint-docs (push) Waiting to run
CI / check-paperclip (push) Waiting to run
Deploy static site / Deploy to GitHub Pages (push) Has been cancelled
Deploy static site / Deploy via Docker to hatch.surf (push) Has been cancelled
Resolved conflicts by taking GitHub versions for: - .dockerignore, .gitignore, Dockerfile, README.md, docker-compose.yml Kept deploy.sh updated to: - Pull from GitHub (primary source) - Push to Gitea (push-mirror) - Build from site/ directory (GitHub structure) Co-Authored-By: Paperclip <noreply@paperclip.ing>
102 lines
4.3 KiB
JavaScript
102 lines
4.3 KiB
JavaScript
import { workUnitAsyncStorage } from '../work-unit-async-storage.external';
|
|
import { workAsyncStorage } from '../work-async-storage.external';
|
|
import { createExhaustiveParamsProxy, createExhaustiveURLSearchParamsProxy, trackMissingSampleErrorAndThrow } from './instant-samples';
|
|
import { InstantValidationError } from './instant-validation-error';
|
|
export function instrumentParamsForClientValidation(underlyingParams) {
|
|
const workStore = workAsyncStorage.getStore();
|
|
const workUnitStore = workUnitAsyncStorage.getStore();
|
|
if (workStore && workUnitStore) {
|
|
switch(workUnitStore.type){
|
|
case 'validation-client':
|
|
{
|
|
if (workUnitStore.validationSamples) {
|
|
const declaredKeys = new Set(Object.keys(workUnitStore.validationSamples.params ?? {}));
|
|
return createExhaustiveParamsProxy(underlyingParams, declaredKeys, workStore.route);
|
|
}
|
|
break;
|
|
}
|
|
case 'prerender-runtime':
|
|
case 'prerender-client':
|
|
case 'prerender-legacy':
|
|
case 'prerender-ppr':
|
|
case 'prerender':
|
|
case 'cache':
|
|
case 'request':
|
|
case 'private-cache':
|
|
case 'unstable-cache':
|
|
case 'generate-static-params':
|
|
break;
|
|
default:
|
|
workUnitStore;
|
|
}
|
|
}
|
|
return underlyingParams;
|
|
}
|
|
export function expectCompleteParamsInClientValidation(expression) {
|
|
const workStore = workAsyncStorage.getStore();
|
|
const workUnitStore = workUnitAsyncStorage.getStore();
|
|
if (workStore && workUnitStore) {
|
|
switch(workUnitStore.type){
|
|
case 'validation-client':
|
|
{
|
|
if (workUnitStore.validationSamples) {
|
|
const fallbackParams = workUnitStore.fallbackRouteParams;
|
|
if (fallbackParams && fallbackParams.size > 0) {
|
|
const missingParams = Array.from(fallbackParams.keys());
|
|
trackMissingSampleErrorAndThrow(Object.defineProperty(new InstantValidationError(`Route "${workStore.route}" called ${expression} but param${missingParams.length > 1 ? 's' : ''} ${missingParams.map((p)=>`"${p}"`).join(', ')} ${missingParams.length > 1 ? 'are' : 'is'} not defined in the \`samples\` of \`unstable_instant\`. ` + `${expression} requires all route params to be provided.`), "__NEXT_ERROR_CODE", {
|
|
value: "E1109",
|
|
enumerable: false,
|
|
configurable: true
|
|
}));
|
|
}
|
|
}
|
|
break;
|
|
}
|
|
case 'prerender-runtime':
|
|
case 'prerender-client':
|
|
case 'prerender-legacy':
|
|
case 'prerender-ppr':
|
|
case 'prerender':
|
|
case 'cache':
|
|
case 'request':
|
|
case 'private-cache':
|
|
case 'unstable-cache':
|
|
case 'generate-static-params':
|
|
break;
|
|
default:
|
|
workUnitStore;
|
|
}
|
|
}
|
|
}
|
|
export function instrumentSearchParamsForClientValidation(underlyingSearchParams) {
|
|
const workStore = workAsyncStorage.getStore();
|
|
const workUnitStore = workUnitAsyncStorage.getStore();
|
|
if (workStore && workUnitStore) {
|
|
switch(workUnitStore.type){
|
|
case 'validation-client':
|
|
{
|
|
if (workUnitStore.validationSamples) {
|
|
const declaredKeys = new Set(Object.keys(workUnitStore.validationSamples.searchParams ?? {}));
|
|
return createExhaustiveURLSearchParamsProxy(underlyingSearchParams, declaredKeys, workStore.route);
|
|
}
|
|
break;
|
|
}
|
|
case 'prerender-runtime':
|
|
case 'prerender-client':
|
|
case 'prerender-legacy':
|
|
case 'prerender-ppr':
|
|
case 'prerender':
|
|
case 'cache':
|
|
case 'request':
|
|
case 'private-cache':
|
|
case 'unstable-cache':
|
|
case 'generate-static-params':
|
|
break;
|
|
default:
|
|
workUnitStore;
|
|
}
|
|
}
|
|
return underlyingSearchParams;
|
|
}
|
|
|
|
//# sourceMappingURL=instant-samples-client.js.map
|