@tuyau/core 1.2.1 → 1.2.2

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-0FlF5VBq.js';
3
- export { g as TuyauError, h as TuyauHTTPError, i as TuyauNetworkError } from '../index-0FlF5VBq.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-BPATPJFD.js';
3
+ export { g as TuyauError, h as TuyauHTTPError, i as TuyauNetworkError } from '../index-BPATPJFD.js';
4
4
  import 'ky';
5
5
 
6
6
  /**
@@ -179,6 +179,7 @@ var TuyauRouter = class _TuyauRouter {
179
179
 
180
180
  // src/client/promise.ts
181
181
  var TuyauPromise = class {
182
+ [Symbol.toStringTag] = "TuyauPromise";
182
183
  #promise;
183
184
  constructor(promise) {
184
185
  this.#promise = promise;
@@ -1,3 +1,3 @@
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';
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-BPATPJFD.js';
2
2
  import 'ky';
3
3
  import '@adonisjs/http-server/client/url_builder';
@@ -39,6 +39,13 @@ interface SchemaEndpoint {
39
39
  interface AdonisEndpoint extends SchemaEndpoint {
40
40
  tokens: ClientRouteMatchItTokens[];
41
41
  }
42
+ /**
43
+ * Like `Omit` but distributes over union types.
44
+ * Standard `Omit<A | B, K>` collapses to `{}` when A and B have disjoint keys
45
+ * because `keyof (A | B)` returns only common keys. This variant applies
46
+ * `Omit` to each union member individually.
47
+ */
48
+ type DistributiveOmit<T, K extends keyof any> = T extends any ? Omit<T, K> : never;
42
49
  /**
43
50
  * Extract query params from a validator type if it has a 'query' property.
44
51
  * Used in generated registry to separate query params from body for POST/PUT/PATCH/DELETE.
@@ -51,12 +58,12 @@ type ExtractQuery<T> = 'query' extends keyof T ? T extends {
51
58
  * Extract query params for GET/HEAD requests.
52
59
  * Excludes headers, cookies, and params from the validator type since these are not query params.
53
60
  */
54
- type ExtractQueryForGet<T> = Omit<T, 'headers' | 'cookies' | 'params'>;
61
+ type ExtractQueryForGet<T> = DistributiveOmit<T, 'headers' | 'cookies' | 'params'>;
55
62
  /**
56
63
  * Extract body from a validator type, excluding reserved properties.
57
64
  * Excludes 'query', 'params', 'headers', and 'cookies' as these are handled separately by AdonisJS.
58
65
  */
59
- type ExtractBody<T> = Omit<T, 'query' | 'params' | 'headers' | 'cookies'>;
66
+ type ExtractBody<T> = DistributiveOmit<T, 'query' | 'params' | 'headers' | 'cookies'>;
60
67
  /**
61
68
  * Success status codes (2xx)
62
69
  */
@@ -128,19 +135,29 @@ type TuyauRequestOptions = {
128
135
  */
129
136
  type BaseRequestOptions = Omit<Options, 'body' | 'params' | 'searchParams' | 'method' | 'json' | 'prefixUrl'>;
130
137
  /**
131
- * Helper types for optional/required fields - using literal types instead of mapped types
138
+ * Helper types for optional/required fields - using literal types instead of mapped types.
139
+ *
140
+ * When `keyof T` is `never`, we distinguish true empty objects (where `{} extends T`)
141
+ * from union types with disjoint keys (e.g. `{ a: string } | { b: string }`) where
142
+ * `keyof` is also `never` but the type is not empty.
132
143
  */
133
- type ParamsArg<T> = keyof T extends never ? {} : {} extends T ? {
144
+ type ParamsArg<T> = keyof T extends never ? {} extends T ? {} : {
145
+ params: T;
146
+ } : {} extends T ? {
134
147
  params?: T;
135
148
  } : {
136
149
  params: T;
137
150
  };
138
- type QueryArg<T> = keyof T extends never ? {} : {} extends T ? {
151
+ type QueryArg<T> = keyof T extends never ? {} extends T ? {} : {
152
+ query: T;
153
+ } : {} extends T ? {
139
154
  query?: T;
140
155
  } : {
141
156
  query: T;
142
157
  };
143
- type BodyArg<T> = keyof T extends never ? {} : {} extends T ? {
158
+ type BodyArg<T> = keyof T extends never ? {} extends T ? {} : {
159
+ body: T;
160
+ } : {} extends T ? {
144
161
  body?: T;
145
162
  } : {
146
163
  body: T;
@@ -420,10 +437,12 @@ type NormalizeError<E> = (E extends {
420
437
  };
421
438
  /**
422
439
  * A promise wrapper that adds `.safe()` for non-throwing error handling.
423
- * Implements PromiseLike so `await` works transparently.
440
+ * Implements Promise so it's fully compatible with TanStack Query and other
441
+ * libraries that expect `Promise<T>` return types.
424
442
  */
425
- declare class TuyauPromise<Data, Errors = unknown> implements PromiseLike<Data> {
443
+ declare class TuyauPromise<Data, Errors = unknown> implements Promise<Data> {
426
444
  #private;
445
+ readonly [Symbol.toStringTag]: string;
427
446
  constructor(promise: Promise<Data>);
428
447
  then<R1 = Data, R2 = never>(onfulfilled?: ((value: Data) => R1 | PromiseLike<R1>) | null, onrejected?: ((reason: any) => R2 | PromiseLike<R2>) | null): Promise<R1 | R2>;
429
448
  catch<R = never>(onrejected?: ((reason: any) => R | PromiseLike<R>) | null): Promise<Data | R>;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@tuyau/core",
3
3
  "type": "module",
4
- "version": "1.2.1",
4
+ "version": "1.2.2",
5
5
  "description": "E2E typesafe client for AdonisJS",
6
6
  "author": "Julien Ripouteau <julien@ripouteau.com>",
7
7
  "license": "MIT",
@@ -52,12 +52,12 @@
52
52
  "object-to-formdata": "^4.5.1"
53
53
  },
54
54
  "devDependencies": {
55
- "@adonisjs/assembler": "^8.0.0",
55
+ "@adonisjs/assembler": "^8.0.1",
56
56
  "@adonisjs/core": "^7.0.1",
57
57
  "@adonisjs/http-server": "^8.0.0",
58
58
  "@faker-js/faker": "^10.3.0",
59
59
  "@poppinss/ts-exec": "^1.4.4",
60
- "@types/node": "^25.3.3",
60
+ "@types/node": "^25.5.0",
61
61
  "@typescript/analyze-trace": "^0.10.1",
62
62
  "@vinejs/vine": "^4.3.0"
63
63
  },