@tuyau/core 1.2.0 → 1.2.1

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,6 +1,6 @@
1
1
  import { UrlFor } from '@adonisjs/http-server/client/url_builder';
2
- import { T as TuyauRegistry, a as TuyauConfiguration, A as AdonisEndpoint, I as InferRoutes, b as TransformApiDefinition, c as InferTree, R as RegistryGroupedByMethod, P as PatternsByMethod, d as RequestArgs, E as EndpointByMethodPattern, e as TuyauPromise, f as ErrorResponseOf, S as StrKeys, M as Method, C as CurrentRouteOptions } from '../index-SVztBh2W.js';
3
- export { g as TuyauError, h as TuyauHTTPError, i as TuyauNetworkError } from '../index-SVztBh2W.js';
2
+ import { T as TuyauRegistry, a as TuyauConfiguration, A as AdonisEndpoint, I as InferRoutes, b as TransformApiDefinition, c as InferTree, R as RegistryGroupedByMethod, P as PatternsByMethod, d as RequestArgs, E as EndpointByMethodPattern, e as TuyauPromise, f as ErrorResponseOf, S as StrKeys, M as Method, C as CurrentRouteOptions } from '../index-0FlF5VBq.js';
3
+ export { g as TuyauError, h as TuyauHTTPError, i as TuyauNetworkError } from '../index-0FlF5VBq.js';
4
4
  import 'ky';
5
5
 
6
6
  /**
@@ -380,11 +380,13 @@ var Tuyau = class {
380
380
  /**
381
381
  * Checks if an object contains any file uploads
382
382
  */
383
- #hasFile(obj) {
384
- if (!obj) return false;
383
+ #hasFile(obj, depth = 0) {
384
+ if (!obj || depth > 5) return false;
385
385
  return Object.values(obj).some((val) => {
386
- if (Array.isArray(val)) return val.some(this.#isFile);
387
- return this.#isFile(val);
386
+ if (this.#isFile(val)) return true;
387
+ if (Array.isArray(val)) return val.some((item) => this.#isFile(item) || isObject(item) && this.#hasFile(item, depth + 1));
388
+ if (isObject(val)) return this.#hasFile(val, depth + 1);
389
+ return false;
388
390
  });
389
391
  }
390
392
  #getLowercaseMethod(method) {
@@ -1,3 +1,3 @@
1
- export { A as AdonisEndpoint, q as AdonisRegistry, B as BaseRequestOptions, C as CurrentRouteOptions, E as EndpointByMethodPattern, s as EndpointByName, x as EndpointFn, j as EndpointTypes, r as Endpoints, y as EndpointsByMethod, f as ErrorResponseOf, n as ExtractBody, p as ExtractErrorResponse, l as ExtractQuery, m as ExtractQueryForGet, o as ExtractResponse, I as InferRoutes, c as InferTree, N as KnownStatuses, F as MaybeArray, M as Method, K as Path, H as PathWithRegistry, P as PatternsByMethod, Q as QueryParameters, v as RawRequestArgs, z as RegValues, R as RegistryGroupedByMethod, d as RequestArgs, w as ResponseOf, t as ResponseType, L as Route, J as RouteWithRegistry, k as SchemaEndpoint, S as StrKeys, b as TransformApiDefinition, a as TuyauConfiguration, D as TuyauPlugin, T as TuyauRegistry, u as TuyauRequestOptions, U as UnionToIntersection, G as UserRegistry, V as ValueOf } from '../../index-SVztBh2W.js';
1
+ export { A as AdonisEndpoint, q as AdonisRegistry, B as BaseRequestOptions, C as CurrentRouteOptions, E as EndpointByMethodPattern, s as EndpointByName, y as EndpointFn, j as EndpointTypes, r as Endpoints, z as EndpointsByMethod, x as ErrorOf, f as ErrorResponseOf, n as ExtractBody, p as ExtractErrorResponse, l as ExtractQuery, m as ExtractQueryForGet, o as ExtractResponse, I as InferRoutes, c as InferTree, W as KnownStatuses, G as MaybeArray, M as Method, N as NormalizeError, L as Path, J as PathWithRegistry, P as PatternsByMethod, Q as QueryParameters, v as RawRequestArgs, D as RegValues, R as RegistryGroupedByMethod, d as RequestArgs, w as ResponseOf, t as ResponseType, O as Route, K as RouteWithRegistry, k as SchemaEndpoint, S as StrKeys, b as TransformApiDefinition, a as TuyauConfiguration, F as TuyauPlugin, T as TuyauRegistry, u as TuyauRequestOptions, U as UnionToIntersection, H as UserRegistry, V as ValueOf } from '../../index-0FlF5VBq.js';
2
2
  import 'ky';
3
3
  import '@adonisjs/http-server/client/url_builder';
@@ -177,6 +177,10 @@ type NormalizeError$1<E> = (E extends {
177
177
  status: number;
178
178
  response: unknown;
179
179
  };
180
+ /**
181
+ * Extracts the typed TuyauError contract from an endpoint.
182
+ */
183
+ type ErrorOf<E extends SchemaEndpoint> = TuyauError<NormalizeError$1<ErrorResponseOf<E>>>;
180
184
  /**
181
185
  * Function type for calling an endpoint
182
186
  */
@@ -256,7 +260,7 @@ declare namespace PathWithRegistry {
256
260
  type Params<Reg extends Record<string, AdonisEndpoint>, M extends Method, P extends PatternsByMethod<Reg, M>> = FilterByMethodPathForRegistry<Reg, M, P>['types']['params'];
257
261
  type Body<Reg extends Record<string, AdonisEndpoint>, M extends Method, P extends PatternsByMethod<Reg, M>> = FilterByMethodPathForRegistry<Reg, M, P>['types']['body'];
258
262
  type Query<Reg extends Record<string, AdonisEndpoint>, M extends Method, P extends PatternsByMethod<Reg, M>> = FilterByMethodPathForRegistry<Reg, M, P>['types']['query'];
259
- type Error<Reg extends Record<string, AdonisEndpoint>, M extends Method, P extends PatternsByMethod<Reg, M>> = TuyauError<NormalizeError$1<ErrorResponseOf<FilterByMethodPathForRegistry<Reg, M, P>>>>;
263
+ type Error<Reg extends Record<string, AdonisEndpoint>, M extends Method, P extends PatternsByMethod<Reg, M>> = ErrorOf<FilterByMethodPathForRegistry<Reg, M, P>>;
260
264
  }
261
265
  /**
262
266
  * Internal type utilities for working with endpoints by route name
@@ -268,7 +272,7 @@ declare namespace RouteWithRegistry {
268
272
  type Params<Reg extends Record<string, AdonisEndpoint>, Name extends keyof Reg> = EndpointByNameForRegistry<Reg, Name>['types']['params'];
269
273
  type Body<Reg extends Record<string, AdonisEndpoint>, Name extends keyof Reg> = EndpointByNameForRegistry<Reg, Name>['types']['body'];
270
274
  type Query<Reg extends Record<string, AdonisEndpoint>, Name extends keyof Reg> = EndpointByNameForRegistry<Reg, Name>['types']['query'];
271
- type Error<Reg extends Record<string, AdonisEndpoint>, Name extends keyof Reg> = TuyauError<NormalizeError$1<ErrorResponseOf<EndpointByNameForRegistry<Reg, Name>>>>;
275
+ type Error<Reg extends Record<string, AdonisEndpoint>, Name extends keyof Reg> = ErrorOf<EndpointByNameForRegistry<Reg, Name>>;
272
276
  }
273
277
  /**
274
278
  * Type utilities for working with endpoints by HTTP method and path pattern
@@ -280,7 +284,7 @@ declare namespace Path {
280
284
  type Params<M extends Method, P extends PatternsByMethod<UserAdonisRegistry, M>> = FilterByMethodPathForRegistry<UserAdonisRegistry, M, P>['types']['params'];
281
285
  type Body<M extends Method, P extends PatternsByMethod<UserAdonisRegistry, M>> = FilterByMethodPathForRegistry<UserAdonisRegistry, M, P>['types']['body'];
282
286
  type Query<M extends Method, P extends PatternsByMethod<UserAdonisRegistry, M>> = FilterByMethodPathForRegistry<UserAdonisRegistry, M, P>['types']['query'];
283
- type Error<M extends Method, P extends PatternsByMethod<UserAdonisRegistry, M>> = TuyauError<NormalizeError$1<ErrorResponseOf<FilterByMethodPathForRegistry<UserAdonisRegistry, M, P>>>>;
287
+ type Error<M extends Method, P extends PatternsByMethod<UserAdonisRegistry, M>> = ErrorOf<FilterByMethodPathForRegistry<UserAdonisRegistry, M, P>>;
284
288
  }
285
289
  /**
286
290
  * Type utilities for working with endpoints by route name
@@ -292,7 +296,7 @@ declare namespace Route {
292
296
  type Params<Name extends keyof UserAdonisRegistry> = UserEndpointByName<Name>['types']['params'];
293
297
  type Body<Name extends keyof UserAdonisRegistry> = UserEndpointByName<Name>['types']['body'];
294
298
  type Query<Name extends keyof UserAdonisRegistry> = UserEndpointByName<Name>['types']['query'];
295
- type Error<Name extends keyof UserAdonisRegistry> = TuyauError<NormalizeError$1<ErrorResponseOf<UserEndpointByName<Name>>>>;
299
+ type Error<Name extends keyof UserAdonisRegistry> = ErrorOf<UserEndpointByName<Name>>;
296
300
  }
297
301
  /**
298
302
  * Extracts literal status codes from E, filtering out the wide `number` from the fallback.
@@ -435,4 +439,4 @@ declare class TuyauPromise<Data, Errors = unknown> implements PromiseLike<Data>
435
439
  ] | [data: null, error: TuyauError<NormalizeError<Errors>>]>;
436
440
  }
437
441
 
438
- export { type AdonisEndpoint as A, type BaseRequestOptions as B, type CurrentRouteOptions as C, type TuyauPlugin as D, type EndpointByMethodPattern as E, type MaybeArray as F, type UserRegistry as G, PathWithRegistry as H, type InferRoutes as I, RouteWithRegistry as J, Path as K, Route as L, type Method as M, type KnownStatuses as N, type PatternsByMethod as P, type QueryParameters as Q, type RegistryGroupedByMethod as R, type StrKeys as S, type TuyauRegistry as T, type UnionToIntersection as U, type ValueOf as V, type TuyauConfiguration as a, type TransformApiDefinition as b, type InferTree as c, type RequestArgs as d, TuyauPromise as e, type ErrorResponseOf as f, TuyauError as g, TuyauHTTPError as h, TuyauNetworkError as i, type EndpointTypes as j, type SchemaEndpoint as k, type ExtractQuery as l, type ExtractQueryForGet as m, type ExtractBody as n, type ExtractResponse as o, type ExtractErrorResponse as p, type AdonisRegistry as q, type Endpoints as r, type EndpointByName as s, type ResponseType as t, type TuyauRequestOptions as u, type RawRequestArgs as v, type ResponseOf as w, type EndpointFn as x, type EndpointsByMethod as y, type RegValues as z };
442
+ export { type AdonisEndpoint as A, type BaseRequestOptions as B, type CurrentRouteOptions as C, type RegValues as D, type EndpointByMethodPattern as E, type TuyauPlugin as F, type MaybeArray as G, type UserRegistry as H, type InferRoutes as I, PathWithRegistry as J, RouteWithRegistry as K, Path as L, type Method as M, type NormalizeError$1 as N, Route as O, type PatternsByMethod as P, type QueryParameters as Q, type RegistryGroupedByMethod as R, type StrKeys as S, type TuyauRegistry as T, type UnionToIntersection as U, type ValueOf as V, type KnownStatuses as W, type TuyauConfiguration as a, type TransformApiDefinition as b, type InferTree as c, type RequestArgs as d, TuyauPromise as e, type ErrorResponseOf as f, TuyauError as g, TuyauHTTPError as h, TuyauNetworkError as i, type EndpointTypes as j, type SchemaEndpoint as k, type ExtractQuery as l, type ExtractQueryForGet as m, type ExtractBody as n, type ExtractResponse as o, type ExtractErrorResponse as p, type AdonisRegistry as q, type Endpoints as r, type EndpointByName as s, type ResponseType as t, type TuyauRequestOptions as u, type RawRequestArgs as v, type ResponseOf as w, type ErrorOf as x, type EndpointFn as y, type EndpointsByMethod as z };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@tuyau/core",
3
3
  "type": "module",
4
- "version": "1.2.0",
4
+ "version": "1.2.1",
5
5
  "description": "E2E typesafe client for AdonisJS",
6
6
  "author": "Julien Ripouteau <julien@ripouteau.com>",
7
7
  "license": "MIT",