strict-qs 8.0.3 → 10.0.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/CHANGELOG.md +4 -0
- package/dist/errors.d.ts +82 -0
- package/dist/errors.js +2 -0
- package/dist/errors.js.map +1 -0
- package/dist/index.d.ts +8 -11
- package/dist/index.js +29 -13
- package/dist/index.js.map +1 -1
- package/dist/index.test.js +102 -48
- package/dist/index.test.js.map +1 -1
- package/package.json +45 -60
- package/src/errors.ts +94 -0
- package/src/index.test.ts +160 -109
- package/src/index.ts +43 -41
package/package.json
CHANGED
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
}
|
|
26
26
|
},
|
|
27
27
|
"name": "strict-qs",
|
|
28
|
-
"version": "
|
|
28
|
+
"version": "10.0.0",
|
|
29
29
|
"description": "A stricter Query String parser",
|
|
30
30
|
"type": "module",
|
|
31
31
|
"main": "dist/index.js",
|
|
@@ -34,20 +34,19 @@
|
|
|
34
34
|
"build": "rimraf 'dist' && tsc --outDir dist",
|
|
35
35
|
"changelog": "conventional-changelog -p angular -i CHANGELOG.md -s && git add CHANGELOG.md",
|
|
36
36
|
"cli": "env NODE_ENV=${NODE_ENV:-cli}",
|
|
37
|
-
"
|
|
38
|
-
"
|
|
37
|
+
"commitlint": "commitlint",
|
|
38
|
+
"cover": "node --run jest -- --coverage",
|
|
39
39
|
"doc": "echo \"# API\" > API.md; jsdoc2md dist/*.js >> API.md && git add API.md",
|
|
40
|
-
"format": "
|
|
40
|
+
"format": "node --run prettier",
|
|
41
41
|
"jest": "NODE_OPTIONS=--experimental-vm-modules NODE_ENV=test jest",
|
|
42
42
|
"lint": "eslint src/*.ts",
|
|
43
43
|
"metapak": "metapak",
|
|
44
|
-
"
|
|
44
|
+
"precommit": "node --run test && node --run lint && node --run metapak -- -s && node --run build && node --run doc",
|
|
45
45
|
"prettier": "prettier --write src/*.ts",
|
|
46
|
-
"preversion": "
|
|
46
|
+
"preversion": "node --run test && node --run lint && node --run build && node --run doc && node --run metapak -- -s",
|
|
47
47
|
"rebuild": "swc ./src -s -d dist -C jsc.target=es2022",
|
|
48
|
-
"test": "
|
|
49
|
-
"
|
|
50
|
-
"version": "npm run changelog"
|
|
48
|
+
"test": "node --run jest",
|
|
49
|
+
"version": "node --run changelog"
|
|
51
50
|
},
|
|
52
51
|
"repository": {
|
|
53
52
|
"type": "git",
|
|
@@ -70,58 +69,33 @@
|
|
|
70
69
|
},
|
|
71
70
|
"homepage": "https://github.com/nfroidure/strict-qs#readme",
|
|
72
71
|
"devDependencies": {
|
|
73
|
-
"@
|
|
74
|
-
"@
|
|
75
|
-
"@
|
|
76
|
-
"@swc/
|
|
77
|
-
"@swc/
|
|
78
|
-
"
|
|
79
|
-
"
|
|
80
|
-
"
|
|
81
|
-
"eslint": "^
|
|
82
|
-
"eslint-config-prettier": "^
|
|
83
|
-
"eslint-plugin-jest": "^
|
|
84
|
-
"eslint-plugin-prettier": "^5.
|
|
85
|
-
"jest": "^
|
|
86
|
-
"jsdoc-to-markdown": "^
|
|
87
|
-
"metapak": "^
|
|
88
|
-
"metapak-nfroidure": "
|
|
89
|
-
"prettier": "^3.
|
|
90
|
-
"rimraf": "^6.
|
|
91
|
-
"typescript": "^
|
|
92
|
-
"typescript-eslint": "^
|
|
72
|
+
"@commitlint/cli": "^20.5.0",
|
|
73
|
+
"@commitlint/config-conventional": "^20.5.0",
|
|
74
|
+
"@eslint/js": "^10.0.1",
|
|
75
|
+
"@swc/cli": "^0.8.1",
|
|
76
|
+
"@swc/core": "^1.15.24",
|
|
77
|
+
"@swc/jest": "^0.2.39",
|
|
78
|
+
"@types/debug": "^4.1.13",
|
|
79
|
+
"conventional-changelog": "^7.2.0",
|
|
80
|
+
"eslint": "^10.2.0",
|
|
81
|
+
"eslint-config-prettier": "^10.1.8",
|
|
82
|
+
"eslint-plugin-jest": "^29.15.1",
|
|
83
|
+
"eslint-plugin-prettier": "^5.5.5",
|
|
84
|
+
"jest": "^30.3.0",
|
|
85
|
+
"jsdoc-to-markdown": "^9.1.3",
|
|
86
|
+
"metapak": "^7.1.0",
|
|
87
|
+
"metapak-nfroidure": "22.1.1",
|
|
88
|
+
"prettier": "^3.8.1",
|
|
89
|
+
"rimraf": "^6.1.3",
|
|
90
|
+
"typescript": "^6.0.2",
|
|
91
|
+
"typescript-eslint": "^8.58.0"
|
|
93
92
|
},
|
|
94
93
|
"dependencies": {
|
|
95
|
-
"debug": "^4.
|
|
96
|
-
"yerror": "^
|
|
94
|
+
"debug": "^4.4.0",
|
|
95
|
+
"yerror": "^11.0.0"
|
|
97
96
|
},
|
|
98
97
|
"engines": {
|
|
99
|
-
"node": ">=
|
|
100
|
-
},
|
|
101
|
-
"config": {
|
|
102
|
-
"commitizen": {
|
|
103
|
-
"path": "./node_modules/cz-conventional-changelog"
|
|
104
|
-
}
|
|
105
|
-
},
|
|
106
|
-
"greenkeeper": {
|
|
107
|
-
"ignore": [
|
|
108
|
-
"commitizen",
|
|
109
|
-
"cz-conventional-changelog",
|
|
110
|
-
"conventional-changelog-cli",
|
|
111
|
-
"typescript",
|
|
112
|
-
"rimraf",
|
|
113
|
-
"@swc/cli",
|
|
114
|
-
"@swc/core",
|
|
115
|
-
"@swc/helpers",
|
|
116
|
-
"eslint",
|
|
117
|
-
"prettier",
|
|
118
|
-
"eslint-config-prettier",
|
|
119
|
-
"eslint-plugin-prettier",
|
|
120
|
-
"typescript-eslint",
|
|
121
|
-
"jsdoc-to-markdown",
|
|
122
|
-
"jest",
|
|
123
|
-
"@swc/jest"
|
|
124
|
-
]
|
|
98
|
+
"node": ">=24.14.0"
|
|
125
99
|
},
|
|
126
100
|
"contributors": [],
|
|
127
101
|
"files": [
|
|
@@ -160,10 +134,21 @@
|
|
|
160
134
|
},
|
|
161
135
|
"extensionsToTreatAsEsm": [
|
|
162
136
|
".ts"
|
|
163
|
-
]
|
|
164
|
-
|
|
137
|
+
]
|
|
138
|
+
},
|
|
139
|
+
"funding": {
|
|
140
|
+
"type": "individual",
|
|
141
|
+
"url": "https://github.com/sponsors/nfroidure"
|
|
165
142
|
},
|
|
166
143
|
"overrides": {
|
|
167
|
-
"eslint":
|
|
144
|
+
"typescript-eslint": {
|
|
145
|
+
"typescript": "^6"
|
|
146
|
+
},
|
|
147
|
+
"@typescript-eslint/eslint-plugin": {
|
|
148
|
+
"typescript": "^6"
|
|
149
|
+
},
|
|
150
|
+
"@typescript-eslint/parser": {
|
|
151
|
+
"typescript": "^6"
|
|
152
|
+
}
|
|
168
153
|
}
|
|
169
154
|
}
|
package/src/errors.ts
ADDED
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
import { type QSValue } from './index.js';
|
|
2
|
+
|
|
3
|
+
declare module 'yerror' {
|
|
4
|
+
interface YErrorRegistry {
|
|
5
|
+
/**
|
|
6
|
+
* Thrown when the query string does not start with the search flag '?'.
|
|
7
|
+
* @param search The malformed search string.
|
|
8
|
+
*/
|
|
9
|
+
E_MALFORMED_SEARCH: [search: string];
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Thrown when the query string is empty (just '?') and allowEmptySearch is false.
|
|
13
|
+
* @param search The empty search string.
|
|
14
|
+
*/
|
|
15
|
+
E_EMPTY_SEARCH: [search: string];
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Thrown when an unknown query parameter is encountered and allowUnknownParams is false.
|
|
19
|
+
* @param paramName The name of the unauthorized parameter.
|
|
20
|
+
*/
|
|
21
|
+
E_UNAUTHORIZED_QUERY_PARAM: [paramName: string];
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* Thrown when a required query parameter is missing.
|
|
25
|
+
* @param paramName The name of the missing required parameter.
|
|
26
|
+
*/
|
|
27
|
+
E_REQUIRED_QUERY_PARAM: [paramName: string];
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* Thrown when query parameters are not in the expected order.
|
|
31
|
+
* @param name The parameter name.
|
|
32
|
+
* @param lastIndex The last expected index.
|
|
33
|
+
* @param index The actual index where the parameter was found.
|
|
34
|
+
*/
|
|
35
|
+
E_BAD_QUERY_PARAM_POSITION: [
|
|
36
|
+
name: string,
|
|
37
|
+
lastIndex: number,
|
|
38
|
+
index: number,
|
|
39
|
+
];
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* Thrown when an unsupported parameter type is specified.
|
|
43
|
+
* @param paramName The parameter name.
|
|
44
|
+
* @param type The unsupported type.
|
|
45
|
+
*/
|
|
46
|
+
E_UNSUPPORTED_TYPE: [paramName: string, type: string];
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* Thrown when a parameter is set to its default value and allowDefault is false.
|
|
50
|
+
* @param paramName The parameter name.
|
|
51
|
+
* @param value The default value that was set.
|
|
52
|
+
*/
|
|
53
|
+
E_CANNOT_SET_TO_DEFAULT: [paramName: string, value: QSValue];
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* Thrown when a parameter value is not in the allowed enum values.
|
|
57
|
+
* @param paramName The parameter name.
|
|
58
|
+
* @param value The invalid value.
|
|
59
|
+
*/
|
|
60
|
+
E_NOT_IN_ENUM: [paramName: string, value: QSValue];
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
* Thrown when a parameter value does not match the required pattern.
|
|
64
|
+
* @param paramName The parameter name.
|
|
65
|
+
* @param value The value that failed the pattern match.
|
|
66
|
+
* @param pattern The pattern that was not matched.
|
|
67
|
+
*/
|
|
68
|
+
E_PATTERN_DOES_NOT_MATCH: [
|
|
69
|
+
paramName: string,
|
|
70
|
+
value: QSValue,
|
|
71
|
+
pattern: string,
|
|
72
|
+
];
|
|
73
|
+
|
|
74
|
+
/**
|
|
75
|
+
* Thrown when array parameters are not in ascending order.
|
|
76
|
+
* @param value The current value.
|
|
77
|
+
* @param lastValue The previous value in the array.
|
|
78
|
+
*/
|
|
79
|
+
E_UNORDERED_QUERY_PARAMS: [value: QSValue, lastValue: QSValue];
|
|
80
|
+
|
|
81
|
+
/**
|
|
82
|
+
* Thrown when a number string cannot be parsed back to the same string (non-reentrant).
|
|
83
|
+
* @param str The original string.
|
|
84
|
+
* @param parsed The parsed and stringified version.
|
|
85
|
+
*/
|
|
86
|
+
E_NON_REENTRANT_NUMBER: [str: string, parsed: string];
|
|
87
|
+
|
|
88
|
+
/**
|
|
89
|
+
* Thrown when a boolean value is not 'true' or 'false'.
|
|
90
|
+
* @param str The invalid boolean string.
|
|
91
|
+
*/
|
|
92
|
+
E_BAD_BOOLEAN: [str: string];
|
|
93
|
+
}
|
|
94
|
+
}
|