Refactor routing in App component to enhance navigation and improve error handling by integrating dynamic routes and updating the NotFound route.
This commit is contained in:
1
node_modules/zod/dist/esm/v3/helpers/enumUtil.js
generated
vendored
Normal file
1
node_modules/zod/dist/esm/v3/helpers/enumUtil.js
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
export {};
|
6
node_modules/zod/dist/esm/v3/helpers/errorUtil.js
generated
vendored
Normal file
6
node_modules/zod/dist/esm/v3/helpers/errorUtil.js
generated
vendored
Normal file
@@ -0,0 +1,6 @@
|
||||
export var errorUtil;
|
||||
(function (errorUtil) {
|
||||
errorUtil.errToObj = (message) => typeof message === "string" ? { message } : message || {};
|
||||
// biome-ignore lint:
|
||||
errorUtil.toString = (message) => typeof message === "string" ? message : message?.message;
|
||||
})(errorUtil || (errorUtil = {}));
|
109
node_modules/zod/dist/esm/v3/helpers/parseUtil.js
generated
vendored
Normal file
109
node_modules/zod/dist/esm/v3/helpers/parseUtil.js
generated
vendored
Normal file
@@ -0,0 +1,109 @@
|
||||
import { getErrorMap } from "../errors.js";
|
||||
import defaultErrorMap from "../locales/en.js";
|
||||
export const makeIssue = (params) => {
|
||||
const { data, path, errorMaps, issueData } = params;
|
||||
const fullPath = [...path, ...(issueData.path || [])];
|
||||
const fullIssue = {
|
||||
...issueData,
|
||||
path: fullPath,
|
||||
};
|
||||
if (issueData.message !== undefined) {
|
||||
return {
|
||||
...issueData,
|
||||
path: fullPath,
|
||||
message: issueData.message,
|
||||
};
|
||||
}
|
||||
let errorMessage = "";
|
||||
const maps = errorMaps
|
||||
.filter((m) => !!m)
|
||||
.slice()
|
||||
.reverse();
|
||||
for (const map of maps) {
|
||||
errorMessage = map(fullIssue, { data, defaultError: errorMessage }).message;
|
||||
}
|
||||
return {
|
||||
...issueData,
|
||||
path: fullPath,
|
||||
message: errorMessage,
|
||||
};
|
||||
};
|
||||
export const EMPTY_PATH = [];
|
||||
export function addIssueToContext(ctx, issueData) {
|
||||
const overrideMap = getErrorMap();
|
||||
const issue = makeIssue({
|
||||
issueData: issueData,
|
||||
data: ctx.data,
|
||||
path: ctx.path,
|
||||
errorMaps: [
|
||||
ctx.common.contextualErrorMap, // contextual error map is first priority
|
||||
ctx.schemaErrorMap, // then schema-bound map if available
|
||||
overrideMap, // then global override map
|
||||
overrideMap === defaultErrorMap ? undefined : defaultErrorMap, // then global default map
|
||||
].filter((x) => !!x),
|
||||
});
|
||||
ctx.common.issues.push(issue);
|
||||
}
|
||||
export class ParseStatus {
|
||||
constructor() {
|
||||
this.value = "valid";
|
||||
}
|
||||
dirty() {
|
||||
if (this.value === "valid")
|
||||
this.value = "dirty";
|
||||
}
|
||||
abort() {
|
||||
if (this.value !== "aborted")
|
||||
this.value = "aborted";
|
||||
}
|
||||
static mergeArray(status, results) {
|
||||
const arrayValue = [];
|
||||
for (const s of results) {
|
||||
if (s.status === "aborted")
|
||||
return INVALID;
|
||||
if (s.status === "dirty")
|
||||
status.dirty();
|
||||
arrayValue.push(s.value);
|
||||
}
|
||||
return { status: status.value, value: arrayValue };
|
||||
}
|
||||
static async mergeObjectAsync(status, pairs) {
|
||||
const syncPairs = [];
|
||||
for (const pair of pairs) {
|
||||
const key = await pair.key;
|
||||
const value = await pair.value;
|
||||
syncPairs.push({
|
||||
key,
|
||||
value,
|
||||
});
|
||||
}
|
||||
return ParseStatus.mergeObjectSync(status, syncPairs);
|
||||
}
|
||||
static mergeObjectSync(status, pairs) {
|
||||
const finalObject = {};
|
||||
for (const pair of pairs) {
|
||||
const { key, value } = pair;
|
||||
if (key.status === "aborted")
|
||||
return INVALID;
|
||||
if (value.status === "aborted")
|
||||
return INVALID;
|
||||
if (key.status === "dirty")
|
||||
status.dirty();
|
||||
if (value.status === "dirty")
|
||||
status.dirty();
|
||||
if (key.value !== "__proto__" && (typeof value.value !== "undefined" || pair.alwaysSet)) {
|
||||
finalObject[key.value] = value.value;
|
||||
}
|
||||
}
|
||||
return { status: status.value, value: finalObject };
|
||||
}
|
||||
}
|
||||
export const INVALID = Object.freeze({
|
||||
status: "aborted",
|
||||
});
|
||||
export const DIRTY = (value) => ({ status: "dirty", value });
|
||||
export const OK = (value) => ({ status: "valid", value });
|
||||
export const isAborted = (x) => x.status === "aborted";
|
||||
export const isDirty = (x) => x.status === "dirty";
|
||||
export const isValid = (x) => x.status === "valid";
|
||||
export const isAsync = (x) => typeof Promise !== "undefined" && x instanceof Promise;
|
1
node_modules/zod/dist/esm/v3/helpers/partialUtil.js
generated
vendored
Normal file
1
node_modules/zod/dist/esm/v3/helpers/partialUtil.js
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
export {};
|
1
node_modules/zod/dist/esm/v3/helpers/typeAliases.js
generated
vendored
Normal file
1
node_modules/zod/dist/esm/v3/helpers/typeAliases.js
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
export {};
|
133
node_modules/zod/dist/esm/v3/helpers/util.js
generated
vendored
Normal file
133
node_modules/zod/dist/esm/v3/helpers/util.js
generated
vendored
Normal file
@@ -0,0 +1,133 @@
|
||||
export var util;
|
||||
(function (util) {
|
||||
util.assertEqual = (_) => { };
|
||||
function assertIs(_arg) { }
|
||||
util.assertIs = assertIs;
|
||||
function assertNever(_x) {
|
||||
throw new Error();
|
||||
}
|
||||
util.assertNever = assertNever;
|
||||
util.arrayToEnum = (items) => {
|
||||
const obj = {};
|
||||
for (const item of items) {
|
||||
obj[item] = item;
|
||||
}
|
||||
return obj;
|
||||
};
|
||||
util.getValidEnumValues = (obj) => {
|
||||
const validKeys = util.objectKeys(obj).filter((k) => typeof obj[obj[k]] !== "number");
|
||||
const filtered = {};
|
||||
for (const k of validKeys) {
|
||||
filtered[k] = obj[k];
|
||||
}
|
||||
return util.objectValues(filtered);
|
||||
};
|
||||
util.objectValues = (obj) => {
|
||||
return util.objectKeys(obj).map(function (e) {
|
||||
return obj[e];
|
||||
});
|
||||
};
|
||||
util.objectKeys = typeof Object.keys === "function" // eslint-disable-line ban/ban
|
||||
? (obj) => Object.keys(obj) // eslint-disable-line ban/ban
|
||||
: (object) => {
|
||||
const keys = [];
|
||||
for (const key in object) {
|
||||
if (Object.prototype.hasOwnProperty.call(object, key)) {
|
||||
keys.push(key);
|
||||
}
|
||||
}
|
||||
return keys;
|
||||
};
|
||||
util.find = (arr, checker) => {
|
||||
for (const item of arr) {
|
||||
if (checker(item))
|
||||
return item;
|
||||
}
|
||||
return undefined;
|
||||
};
|
||||
util.isInteger = typeof Number.isInteger === "function"
|
||||
? (val) => Number.isInteger(val) // eslint-disable-line ban/ban
|
||||
: (val) => typeof val === "number" && Number.isFinite(val) && Math.floor(val) === val;
|
||||
function joinValues(array, separator = " | ") {
|
||||
return array.map((val) => (typeof val === "string" ? `'${val}'` : val)).join(separator);
|
||||
}
|
||||
util.joinValues = joinValues;
|
||||
util.jsonStringifyReplacer = (_, value) => {
|
||||
if (typeof value === "bigint") {
|
||||
return value.toString();
|
||||
}
|
||||
return value;
|
||||
};
|
||||
})(util || (util = {}));
|
||||
export var objectUtil;
|
||||
(function (objectUtil) {
|
||||
objectUtil.mergeShapes = (first, second) => {
|
||||
return {
|
||||
...first,
|
||||
...second, // second overwrites first
|
||||
};
|
||||
};
|
||||
})(objectUtil || (objectUtil = {}));
|
||||
export const ZodParsedType = util.arrayToEnum([
|
||||
"string",
|
||||
"nan",
|
||||
"number",
|
||||
"integer",
|
||||
"float",
|
||||
"boolean",
|
||||
"date",
|
||||
"bigint",
|
||||
"symbol",
|
||||
"function",
|
||||
"undefined",
|
||||
"null",
|
||||
"array",
|
||||
"object",
|
||||
"unknown",
|
||||
"promise",
|
||||
"void",
|
||||
"never",
|
||||
"map",
|
||||
"set",
|
||||
]);
|
||||
export const getParsedType = (data) => {
|
||||
const t = typeof data;
|
||||
switch (t) {
|
||||
case "undefined":
|
||||
return ZodParsedType.undefined;
|
||||
case "string":
|
||||
return ZodParsedType.string;
|
||||
case "number":
|
||||
return Number.isNaN(data) ? ZodParsedType.nan : ZodParsedType.number;
|
||||
case "boolean":
|
||||
return ZodParsedType.boolean;
|
||||
case "function":
|
||||
return ZodParsedType.function;
|
||||
case "bigint":
|
||||
return ZodParsedType.bigint;
|
||||
case "symbol":
|
||||
return ZodParsedType.symbol;
|
||||
case "object":
|
||||
if (Array.isArray(data)) {
|
||||
return ZodParsedType.array;
|
||||
}
|
||||
if (data === null) {
|
||||
return ZodParsedType.null;
|
||||
}
|
||||
if (data.then && typeof data.then === "function" && data.catch && typeof data.catch === "function") {
|
||||
return ZodParsedType.promise;
|
||||
}
|
||||
if (typeof Map !== "undefined" && data instanceof Map) {
|
||||
return ZodParsedType.map;
|
||||
}
|
||||
if (typeof Set !== "undefined" && data instanceof Set) {
|
||||
return ZodParsedType.set;
|
||||
}
|
||||
if (typeof Date !== "undefined" && data instanceof Date) {
|
||||
return ZodParsedType.date;
|
||||
}
|
||||
return ZodParsedType.object;
|
||||
default:
|
||||
return ZodParsedType.unknown;
|
||||
}
|
||||
};
|
Reference in New Issue
Block a user