tychat-contracts 1.0.103 → 1.0.104
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.
|
@@ -6,6 +6,8 @@
|
|
|
6
6
|
* - array de objetos (já parseado pelo framework)
|
|
7
7
|
* - array com um único string (JSON do array inteiro) — UI Swagger “array” com um item
|
|
8
8
|
* - array de strings, cada uma um JSON de um único objeto filtro
|
|
9
|
+
* - string JSON de um único objeto `{ key, op, value }` (comum quando o array externo
|
|
10
|
+
* serializa o objeto interno como string, ex.: Swagger/curl)
|
|
9
11
|
*/
|
|
10
12
|
export declare function parseFilterObjectsFromQuery<T>(value: unknown): T[] | undefined;
|
|
11
13
|
//# sourceMappingURL=parse-filters-from-query.util.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"parse-filters-from-query.util.d.ts","sourceRoot":"","sources":["../../src/utils/parse-filters-from-query.util.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"parse-filters-from-query.util.d.ts","sourceRoot":"","sources":["../../src/utils/parse-filters-from-query.util.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AACH,wBAAgB,2BAA2B,CAAC,CAAC,EAAE,KAAK,EAAE,OAAO,GAAG,CAAC,EAAE,GAAG,SAAS,CAoE9E"}
|
|
@@ -9,6 +9,8 @@ exports.parseFilterObjectsFromQuery = parseFilterObjectsFromQuery;
|
|
|
9
9
|
* - array de objetos (já parseado pelo framework)
|
|
10
10
|
* - array com um único string (JSON do array inteiro) — UI Swagger “array” com um item
|
|
11
11
|
* - array de strings, cada uma um JSON de um único objeto filtro
|
|
12
|
+
* - string JSON de um único objeto `{ key, op, value }` (comum quando o array externo
|
|
13
|
+
* serializa o objeto interno como string, ex.: Swagger/curl)
|
|
12
14
|
*/
|
|
13
15
|
function parseFilterObjectsFromQuery(value) {
|
|
14
16
|
if (value === undefined || value === null || value === '') {
|
|
@@ -27,7 +29,15 @@ function parseFilterObjectsFromQuery(value) {
|
|
|
27
29
|
if (typeof value === 'string') {
|
|
28
30
|
try {
|
|
29
31
|
const parsed = JSON.parse(value);
|
|
30
|
-
|
|
32
|
+
const direct = asObjectArray(parsed);
|
|
33
|
+
if (direct)
|
|
34
|
+
return direct;
|
|
35
|
+
if (parsed !== null &&
|
|
36
|
+
typeof parsed === 'object' &&
|
|
37
|
+
!Array.isArray(parsed)) {
|
|
38
|
+
return [parsed];
|
|
39
|
+
}
|
|
40
|
+
return undefined;
|
|
31
41
|
}
|
|
32
42
|
catch {
|
|
33
43
|
return undefined;
|
package/package.json
CHANGED
|
@@ -6,6 +6,8 @@
|
|
|
6
6
|
* - array de objetos (já parseado pelo framework)
|
|
7
7
|
* - array com um único string (JSON do array inteiro) — UI Swagger “array” com um item
|
|
8
8
|
* - array de strings, cada uma um JSON de um único objeto filtro
|
|
9
|
+
* - string JSON de um único objeto `{ key, op, value }` (comum quando o array externo
|
|
10
|
+
* serializa o objeto interno como string, ex.: Swagger/curl)
|
|
9
11
|
*/
|
|
10
12
|
export function parseFilterObjectsFromQuery<T>(value: unknown): T[] | undefined {
|
|
11
13
|
if (value === undefined || value === null || value === '') {
|
|
@@ -29,7 +31,16 @@ export function parseFilterObjectsFromQuery<T>(value: unknown): T[] | undefined
|
|
|
29
31
|
if (typeof value === 'string') {
|
|
30
32
|
try {
|
|
31
33
|
const parsed = JSON.parse(value) as unknown;
|
|
32
|
-
|
|
34
|
+
const direct = asObjectArray(parsed);
|
|
35
|
+
if (direct) return direct;
|
|
36
|
+
if (
|
|
37
|
+
parsed !== null &&
|
|
38
|
+
typeof parsed === 'object' &&
|
|
39
|
+
!Array.isArray(parsed)
|
|
40
|
+
) {
|
|
41
|
+
return [parsed as T];
|
|
42
|
+
}
|
|
43
|
+
return undefined;
|
|
33
44
|
} catch {
|
|
34
45
|
return undefined;
|
|
35
46
|
}
|