@tmlmobilidade/utils 20260803.15.9 → 20260805.229.7

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.
@@ -1,5 +1,4 @@
1
1
  export * from './fetch-data.js';
2
- export * from './http.js';
3
2
  export * from './multipart.js';
4
3
  export * from './response.js';
5
4
  export * from './swr.js';
@@ -1,5 +1,4 @@
1
1
  export * from './fetch-data.js';
2
- export * from './http.js';
3
2
  export * from './multipart.js';
4
3
  export * from './response.js';
5
4
  export * from './swr.js';
@@ -33,9 +33,9 @@ export declare function swrFetcher<T>(urlOrOptions: string | SwrFetcherOptions):
33
33
  * Fetches data from a URL using the SWR fetcher function.
34
34
  * @param urlOrOptions The URL to fetch from or the options object.
35
35
  * @returns Promise resolving to the fetched data
36
- * @deprecated Use `swrFetcher` with an options object instead.
36
+ * @example
37
37
  * ```ts
38
- * const data = await swrFetcher({ url: '/api/users/123', credentials: 'omit' });
38
+ * const data = await unauthenticatedSwrFetcher('/api/users/123');
39
39
  * ```
40
40
  */
41
- export declare function unauthenticatedSwrFetcher<T>(url: string): Promise<T>;
41
+ export declare function unauthenticatedSwrFetcher<T>(url: string): ReturnType<typeof swrFetcher<T>>;
package/dist/http/swr.js CHANGED
@@ -43,9 +43,9 @@ export async function swrFetcher(urlOrOptions) {
43
43
  * Fetches data from a URL using the SWR fetcher function.
44
44
  * @param urlOrOptions The URL to fetch from or the options object.
45
45
  * @returns Promise resolving to the fetched data
46
- * @deprecated Use `swrFetcher` with an options object instead.
46
+ * @example
47
47
  * ```ts
48
- * const data = await swrFetcher({ url: '/api/users/123', credentials: 'omit' });
48
+ * const data = await unauthenticatedSwrFetcher('/api/users/123');
49
49
  * ```
50
50
  */
51
51
  export async function unauthenticatedSwrFetcher(url) {
@@ -1,2 +1,8 @@
1
1
  import { z } from 'zod';
2
+ /**
3
+ * Validates the query params against the schema
4
+ * @param queryParams - The query params to validate
5
+ * @param schema - The schema to validate the query params against
6
+ * @returns The validated query params
7
+ */
2
8
  export declare function validateQueryParams<T>(queryParams: unknown, schema: z.ZodTypeAny): T;
@@ -1,5 +1,15 @@
1
- import { HttpException, HTTP_STATUS } from '@tmlmobilidade/consts';
1
+ /* * */
2
+ import { HTTP_STATUS, HttpException } from '@tmlmobilidade/consts';
3
+ /* * */
4
+ /**
5
+ * Validates the query params against the schema
6
+ * @param queryParams - The query params to validate
7
+ * @param schema - The schema to validate the query params against
8
+ * @returns The validated query params
9
+ */
2
10
  export function validateQueryParams(queryParams, schema) {
11
+ //
12
+ // Validate the query params
3
13
  const result = schema.safeParse(queryParams);
4
14
  if (!result.success) {
5
15
  throw new HttpException(HTTP_STATUS.BAD_REQUEST, result.error.errors.map(error => error.message).join(', '));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tmlmobilidade/utils",
3
- "version": "20260803.15.9",
3
+ "version": "20260805.229.7",
4
4
  "author": {
5
5
  "email": "iso@tmlmobilidade.pt",
6
6
  "name": "TML-ISO"
@@ -1,17 +0,0 @@
1
- export type WithPagination<T> = T & {
2
- pagination: {
3
- limit: number;
4
- page: number;
5
- total: number;
6
- };
7
- };
8
- /**
9
- * Fetches data from a URL using the SWR fetcher function without authentication.
10
- * @param url - The URL to fetch from
11
- * @returns Promise resolving to the fetched data
12
- * @example
13
- * ```ts
14
- * const data = await standardSwrFetcher('/api/users/123');
15
- * ```
16
- */
17
- export declare const standardSwrFetcher: <T>(url: string) => Promise<T>;
package/dist/http/http.js DELETED
@@ -1,18 +0,0 @@
1
- /* * */
2
- import { HttpException } from '@tmlmobilidade/consts';
3
- /**
4
- * Fetches data from a URL using the SWR fetcher function without authentication.
5
- * @param url - The URL to fetch from
6
- * @returns Promise resolving to the fetched data
7
- * @example
8
- * ```ts
9
- * const data = await standardSwrFetcher('/api/users/123');
10
- * ```
11
- */
12
- export const standardSwrFetcher = async (url) => {
13
- const res = await fetch(url, { credentials: 'omit' });
14
- if (!res.ok) {
15
- throw new HttpException(res.status, res.statusText);
16
- }
17
- return res.json();
18
- };