@uxf/router 11.85.0 → 11.86.0
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/helper.test.js +13 -13
- package/package.json +4 -4
- package/router.d.ts +2 -1
package/helper.test.js
CHANGED
|
@@ -10,7 +10,7 @@ describe("Query Parameter Functions", () => {
|
|
|
10
10
|
expect((0, helper_1.queryParamToString)(undefined)).toBeUndefined();
|
|
11
11
|
});
|
|
12
12
|
it("should throw an error when provided an array", () => {
|
|
13
|
-
expect(() => (0, helper_1.queryParamToString)(["test"])).
|
|
13
|
+
expect(() => (0, helper_1.queryParamToString)(["test"])).toThrow("Query parameter is array. Should be string.");
|
|
14
14
|
});
|
|
15
15
|
});
|
|
16
16
|
describe("queryParamToStringStrict", () => {
|
|
@@ -18,10 +18,10 @@ describe("Query Parameter Functions", () => {
|
|
|
18
18
|
expect((0, helper_1.queryParamToStringStrict)("test")).toBe("test");
|
|
19
19
|
});
|
|
20
20
|
it("should throw an error when provided as undefined", () => {
|
|
21
|
-
expect(() => (0, helper_1.queryParamToStringStrict)(undefined)).
|
|
21
|
+
expect(() => (0, helper_1.queryParamToStringStrict)(undefined)).toThrow("Parameter not found.");
|
|
22
22
|
});
|
|
23
23
|
it("should throw an error when provided an array", () => {
|
|
24
|
-
expect(() => (0, helper_1.queryParamToStringStrict)(["test"])).
|
|
24
|
+
expect(() => (0, helper_1.queryParamToStringStrict)(["test"])).toThrow("Query parameter is array. Should be string.");
|
|
25
25
|
});
|
|
26
26
|
});
|
|
27
27
|
describe("queryParamToBoolean", () => {
|
|
@@ -35,10 +35,10 @@ describe("Query Parameter Functions", () => {
|
|
|
35
35
|
expect((0, helper_1.queryParamToBoolean)(undefined)).toBeUndefined();
|
|
36
36
|
});
|
|
37
37
|
it("should throw an error when provided as an invalid boolean string", () => {
|
|
38
|
-
expect(() => (0, helper_1.queryParamToBoolean)("invalid")).
|
|
38
|
+
expect(() => (0, helper_1.queryParamToBoolean)("invalid")).toThrow("Parameter should be boolean (true|false). Given 'invalid'.");
|
|
39
39
|
});
|
|
40
40
|
it("should throw an error when provided an array", () => {
|
|
41
|
-
expect(() => (0, helper_1.queryParamToBoolean)(["true"])).
|
|
41
|
+
expect(() => (0, helper_1.queryParamToBoolean)(["true"])).toThrow("Query parameter is array. Should be string.");
|
|
42
42
|
});
|
|
43
43
|
});
|
|
44
44
|
describe("queryParamToBooleanStrict", () => {
|
|
@@ -49,13 +49,13 @@ describe("Query Parameter Functions", () => {
|
|
|
49
49
|
expect((0, helper_1.queryParamToBooleanStrict)("false")).toBe(false);
|
|
50
50
|
});
|
|
51
51
|
it("should throw an error when provided as undefined", () => {
|
|
52
|
-
expect(() => (0, helper_1.queryParamToBooleanStrict)(undefined)).
|
|
52
|
+
expect(() => (0, helper_1.queryParamToBooleanStrict)(undefined)).toThrow("Parameter not found.");
|
|
53
53
|
});
|
|
54
54
|
it("should throw an error when provided an invalid boolean string", () => {
|
|
55
|
-
expect(() => (0, helper_1.queryParamToBooleanStrict)("invalid")).
|
|
55
|
+
expect(() => (0, helper_1.queryParamToBooleanStrict)("invalid")).toThrow("Parameter should be boolean (true|false). Given 'invalid'.");
|
|
56
56
|
});
|
|
57
57
|
it("should throw an error when provided an array", () => {
|
|
58
|
-
expect(() => (0, helper_1.queryParamToBooleanStrict)(["true"])).
|
|
58
|
+
expect(() => (0, helper_1.queryParamToBooleanStrict)(["true"])).toThrow("Query parameter is array. Should be string.");
|
|
59
59
|
});
|
|
60
60
|
});
|
|
61
61
|
describe("queryParamToNumber", () => {
|
|
@@ -66,10 +66,10 @@ describe("Query Parameter Functions", () => {
|
|
|
66
66
|
expect((0, helper_1.queryParamToNumber)(undefined)).toBeUndefined();
|
|
67
67
|
});
|
|
68
68
|
it("should throw an error when provided as an invalid number string", () => {
|
|
69
|
-
expect(() => (0, helper_1.queryParamToNumber)("invalid")).
|
|
69
|
+
expect(() => (0, helper_1.queryParamToNumber)("invalid")).toThrow("Query parameter is NaN. Should be number.");
|
|
70
70
|
});
|
|
71
71
|
it("should throw an error when provided an array", () => {
|
|
72
|
-
expect(() => (0, helper_1.queryParamToNumber)(["123"])).
|
|
72
|
+
expect(() => (0, helper_1.queryParamToNumber)(["123"])).toThrow("Query parameter is array. Should be number.");
|
|
73
73
|
});
|
|
74
74
|
});
|
|
75
75
|
describe("queryParamToNumberStrict", () => {
|
|
@@ -77,13 +77,13 @@ describe("Query Parameter Functions", () => {
|
|
|
77
77
|
expect((0, helper_1.queryParamToNumberStrict)("123")).toBe(123);
|
|
78
78
|
});
|
|
79
79
|
it("should throw an error when provided as undefined", () => {
|
|
80
|
-
expect(() => (0, helper_1.queryParamToNumberStrict)(undefined)).
|
|
80
|
+
expect(() => (0, helper_1.queryParamToNumberStrict)(undefined)).toThrow("Parameter not found.");
|
|
81
81
|
});
|
|
82
82
|
it("should throw an error when provided as an invalid number string", () => {
|
|
83
|
-
expect(() => (0, helper_1.queryParamToNumberStrict)("invalid")).
|
|
83
|
+
expect(() => (0, helper_1.queryParamToNumberStrict)("invalid")).toThrow("Query parameter is NaN. Should be number.");
|
|
84
84
|
});
|
|
85
85
|
it("should throw an error when provided an array", () => {
|
|
86
|
-
expect(() => (0, helper_1.queryParamToNumberStrict)(["123"])).
|
|
86
|
+
expect(() => (0, helper_1.queryParamToNumberStrict)(["123"])).toThrow("Query parameter is array. Should be number.");
|
|
87
87
|
});
|
|
88
88
|
});
|
|
89
89
|
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@uxf/router",
|
|
3
|
-
"version": "11.
|
|
3
|
+
"version": "11.86.0",
|
|
4
4
|
"description": "UXF Router",
|
|
5
5
|
"author": "UXFans <dev@uxf.cz>",
|
|
6
6
|
"homepage": "https://gitlab.com/uxf-npm/router#readme",
|
|
@@ -23,14 +23,14 @@
|
|
|
23
23
|
"url": "https://gitlab.com/uxf-npm/router/issues"
|
|
24
24
|
},
|
|
25
25
|
"dependencies": {
|
|
26
|
-
"qs": "6.
|
|
26
|
+
"qs": "6.14.0",
|
|
27
27
|
"superstruct": "2.0.2"
|
|
28
28
|
},
|
|
29
29
|
"peerDependencies": {
|
|
30
30
|
"next": ">= 12"
|
|
31
31
|
},
|
|
32
32
|
"devDependencies": {
|
|
33
|
-
"@types/qs": "6.
|
|
34
|
-
"next": "
|
|
33
|
+
"@types/qs": "6.14.0",
|
|
34
|
+
"next": "15.5.6"
|
|
35
35
|
}
|
|
36
36
|
}
|
package/router.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { Params } from "next/dist/server/request/params";
|
|
1
2
|
import { LinkProps } from "next/link";
|
|
2
3
|
import { Infer, Struct } from "superstruct";
|
|
3
4
|
import { SitemapGeneratorOptions, SitemapGeneratorType, SitemapRouteResolvers } from "./sitemap-generator";
|
|
@@ -52,7 +53,7 @@ type Router<Locales extends string[], RouteList extends RoutesDefinition<Locales
|
|
|
52
53
|
/**
|
|
53
54
|
* Returns path params merged with search params
|
|
54
55
|
*/
|
|
55
|
-
usePageParams: () =>
|
|
56
|
+
usePageParams: () => Params | null;
|
|
56
57
|
useQueryParams: <T extends keyof RouteList>(routeName: T) => QueryParamsResult<false, T, Locales, RouteList>;
|
|
57
58
|
useQueryParamsStatic: <T extends keyof RouteList>(routeName: T) => QueryParamsResult<true, T, Locales, RouteList>;
|
|
58
59
|
createRouteMatcher: (...args: FunctionParametersGeneratorWithPartialParams<Locales, RouteList>) => RouteMatcher;
|