enlace 0.0.0-alpha.2 → 0.0.0-alpha.3
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/dist/index.d.mts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/next/index.d.mts +6 -8
- package/dist/next/index.d.ts +6 -8
- package/dist/next/index.js +1 -1
- package/dist/next/index.mjs +1 -1
- package/dist/{types-B-6qIYag.d.mts → types-BX5MGIgP.d.mts} +22 -22
- package/dist/{types-B-6qIYag.d.ts → types-BX5MGIgP.d.ts} +22 -22
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { E as EnlaceOptions, F as FetchExecutor, R as RequestOptions, H as HttpMethod, a as EnlaceResponse, W as WildcardClient, b as EnlaceClient } from './types-
|
|
2
|
-
export { c as Endpoint, M as MethodDefinition, S as SchemaMethod } from './types-
|
|
1
|
+
import { E as EnlaceOptions, F as FetchExecutor, R as RequestOptions, H as HttpMethod, a as EnlaceResponse, W as WildcardClient, b as EnlaceClient } from './types-BX5MGIgP.mjs';
|
|
2
|
+
export { c as Endpoint, M as MethodDefinition, S as SchemaMethod } from './types-BX5MGIgP.mjs';
|
|
3
3
|
|
|
4
4
|
declare function createProxyHandler<TSchema extends object, TOptions = EnlaceOptions>(baseUrl: string, defaultOptions: TOptions, path?: string[], fetchExecutor?: FetchExecutor<TOptions, RequestOptions<unknown>>): TSchema;
|
|
5
5
|
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { E as EnlaceOptions, F as FetchExecutor, R as RequestOptions, H as HttpMethod, a as EnlaceResponse, W as WildcardClient, b as EnlaceClient } from './types-
|
|
2
|
-
export { c as Endpoint, M as MethodDefinition, S as SchemaMethod } from './types-
|
|
1
|
+
import { E as EnlaceOptions, F as FetchExecutor, R as RequestOptions, H as HttpMethod, a as EnlaceResponse, W as WildcardClient, b as EnlaceClient } from './types-BX5MGIgP.js';
|
|
2
|
+
export { c as Endpoint, M as MethodDefinition, S as SchemaMethod } from './types-BX5MGIgP.js';
|
|
3
3
|
|
|
4
4
|
declare function createProxyHandler<TSchema extends object, TOptions = EnlaceOptions>(baseUrl: string, defaultOptions: TOptions, path?: string[], fetchExecutor?: FetchExecutor<TOptions, RequestOptions<unknown>>): TSchema;
|
|
5
5
|
|
package/dist/next/index.d.mts
CHANGED
|
@@ -1,18 +1,16 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export { c as Endpoint,
|
|
1
|
+
import { E as EnlaceOptions, W as WildcardClient, b as EnlaceClient } from '../types-BX5MGIgP.mjs';
|
|
2
|
+
export { c as Endpoint, a as EnlaceResponse, F as FetchExecutor, H as HttpMethod, M as MethodDefinition, R as RequestOptions, S as SchemaMethod } from '../types-BX5MGIgP.mjs';
|
|
3
3
|
|
|
4
4
|
type NextFetchOptions = {
|
|
5
5
|
revalidate?: number | false;
|
|
6
6
|
tags?: string[];
|
|
7
7
|
};
|
|
8
|
-
type NextEnlaceOptions =
|
|
9
|
-
|
|
10
|
-
};
|
|
11
|
-
type NextRequestOptions<TBody = never> = RequestOptions<TBody> & {
|
|
8
|
+
type NextEnlaceOptions = EnlaceOptions;
|
|
9
|
+
type NextRequestOptionsBase = {
|
|
12
10
|
cache?: 'force-cache' | 'no-store';
|
|
13
11
|
next?: NextFetchOptions;
|
|
14
12
|
};
|
|
15
13
|
|
|
16
|
-
declare function createEnlace<TSchema = unknown>(baseUrl: string, defaultOptions?: NextEnlaceOptions): unknown extends TSchema ? WildcardClient : EnlaceClient<TSchema>;
|
|
14
|
+
declare function createEnlace<TSchema = unknown>(baseUrl: string, defaultOptions?: NextEnlaceOptions): unknown extends TSchema ? WildcardClient<NextRequestOptionsBase> : EnlaceClient<TSchema, NextRequestOptionsBase>;
|
|
17
15
|
|
|
18
|
-
export { EnlaceClient, type NextEnlaceOptions, type NextFetchOptions, type
|
|
16
|
+
export { EnlaceClient, EnlaceOptions, type NextEnlaceOptions, type NextFetchOptions, type NextRequestOptionsBase, WildcardClient, createEnlace };
|
package/dist/next/index.d.ts
CHANGED
|
@@ -1,18 +1,16 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export { c as Endpoint,
|
|
1
|
+
import { E as EnlaceOptions, W as WildcardClient, b as EnlaceClient } from '../types-BX5MGIgP.js';
|
|
2
|
+
export { c as Endpoint, a as EnlaceResponse, F as FetchExecutor, H as HttpMethod, M as MethodDefinition, R as RequestOptions, S as SchemaMethod } from '../types-BX5MGIgP.js';
|
|
3
3
|
|
|
4
4
|
type NextFetchOptions = {
|
|
5
5
|
revalidate?: number | false;
|
|
6
6
|
tags?: string[];
|
|
7
7
|
};
|
|
8
|
-
type NextEnlaceOptions =
|
|
9
|
-
|
|
10
|
-
};
|
|
11
|
-
type NextRequestOptions<TBody = never> = RequestOptions<TBody> & {
|
|
8
|
+
type NextEnlaceOptions = EnlaceOptions;
|
|
9
|
+
type NextRequestOptionsBase = {
|
|
12
10
|
cache?: 'force-cache' | 'no-store';
|
|
13
11
|
next?: NextFetchOptions;
|
|
14
12
|
};
|
|
15
13
|
|
|
16
|
-
declare function createEnlace<TSchema = unknown>(baseUrl: string, defaultOptions?: NextEnlaceOptions): unknown extends TSchema ? WildcardClient : EnlaceClient<TSchema>;
|
|
14
|
+
declare function createEnlace<TSchema = unknown>(baseUrl: string, defaultOptions?: NextEnlaceOptions): unknown extends TSchema ? WildcardClient<NextRequestOptionsBase> : EnlaceClient<TSchema, NextRequestOptionsBase>;
|
|
17
15
|
|
|
18
|
-
export { EnlaceClient, type NextEnlaceOptions, type NextFetchOptions, type
|
|
16
|
+
export { EnlaceClient, EnlaceOptions, type NextEnlaceOptions, type NextFetchOptions, type NextRequestOptionsBase, WildcardClient, createEnlace };
|
package/dist/next/index.js
CHANGED
|
@@ -135,7 +135,7 @@ function generateTags(path) {
|
|
|
135
135
|
async function executeNextFetch(baseUrl, path, method, defaultOptions, requestOptions) {
|
|
136
136
|
const url = buildUrl(baseUrl, path, requestOptions?.query);
|
|
137
137
|
let headers = mergeHeaders(defaultOptions.headers, requestOptions?.headers);
|
|
138
|
-
const nextOptions = requestOptions?.next
|
|
138
|
+
const nextOptions = requestOptions?.next;
|
|
139
139
|
const tags = nextOptions?.tags ?? generateTags(path);
|
|
140
140
|
const fetchOptions = {
|
|
141
141
|
...defaultOptions,
|
package/dist/next/index.mjs
CHANGED
|
@@ -12,7 +12,7 @@ function generateTags(path) {
|
|
|
12
12
|
async function executeNextFetch(baseUrl, path, method, defaultOptions, requestOptions) {
|
|
13
13
|
const url = buildUrl(baseUrl, path, requestOptions?.query);
|
|
14
14
|
let headers = mergeHeaders(defaultOptions.headers, requestOptions?.headers);
|
|
15
|
-
const nextOptions = requestOptions?.next
|
|
15
|
+
const nextOptions = requestOptions?.next;
|
|
16
16
|
const tags = nextOptions?.tags ?? generateTags(path);
|
|
17
17
|
const fetchOptions = {
|
|
18
18
|
...defaultOptions,
|
|
@@ -61,7 +61,7 @@ type ExtractBody<TSchema, TMethod extends SchemaMethod> = ExtractMethodDef<TSche
|
|
|
61
61
|
type HasMethod<TSchema, TMethod extends SchemaMethod> = TSchema extends {
|
|
62
62
|
[K in TMethod]: MethodDefinition;
|
|
63
63
|
} ? true : false;
|
|
64
|
-
type MethodFn<TSchema, TMethod extends SchemaMethod> = HasMethod<TSchema, TMethod> extends true ? ExtractBody<TSchema, TMethod> extends never ? (options?: RequestOptions<never>) => Promise<EnlaceResponse<ExtractData<TSchema, TMethod>, ExtractError<TSchema, TMethod>>> : (options: RequestOptions<ExtractBody<TSchema, TMethod>>) => Promise<EnlaceResponse<ExtractData<TSchema, TMethod>, ExtractError<TSchema, TMethod>>> : never;
|
|
64
|
+
type MethodFn<TSchema, TMethod extends SchemaMethod, TRequestOptionsBase = object> = HasMethod<TSchema, TMethod> extends true ? ExtractBody<TSchema, TMethod> extends never ? (options?: RequestOptions<never> & TRequestOptionsBase) => Promise<EnlaceResponse<ExtractData<TSchema, TMethod>, ExtractError<TSchema, TMethod>>> : (options: RequestOptions<ExtractBody<TSchema, TMethod>> & TRequestOptionsBase) => Promise<EnlaceResponse<ExtractData<TSchema, TMethod>, ExtractError<TSchema, TMethod>>> : never;
|
|
65
65
|
type IsSpecialKey<K> = K extends SchemaMethod | '_' ? true : false;
|
|
66
66
|
type StaticPathKeys<TSchema> = {
|
|
67
67
|
[K in keyof TSchema as IsSpecialKey<K> extends true ? never : K extends string ? K : never]: TSchema[K];
|
|
@@ -69,36 +69,36 @@ type StaticPathKeys<TSchema> = {
|
|
|
69
69
|
type ExtractDynamicSchema<TSchema> = TSchema extends {
|
|
70
70
|
_: infer D;
|
|
71
71
|
} ? D : never;
|
|
72
|
-
type MethodOrPath<TSchema, TMethodName extends string, TSchemaMethod extends SchemaMethod> = TMethodName extends keyof TSchema ? EnlaceClient<TSchema[TMethodName]> : MethodFn<TSchema, TSchemaMethod>;
|
|
73
|
-
type HttpMethods<TSchema> = {
|
|
74
|
-
get: MethodOrPath<TSchema, 'get', '$get'>;
|
|
75
|
-
post: MethodOrPath<TSchema, 'post', '$post'>;
|
|
76
|
-
put: MethodOrPath<TSchema, 'put', '$put'>;
|
|
77
|
-
patch: MethodOrPath<TSchema, 'patch', '$patch'>;
|
|
78
|
-
delete: MethodOrPath<TSchema, 'delete', '$delete'>;
|
|
72
|
+
type MethodOrPath<TSchema, TMethodName extends string, TSchemaMethod extends SchemaMethod, TRequestOptionsBase = object> = TMethodName extends keyof TSchema ? EnlaceClient<TSchema[TMethodName], TRequestOptionsBase> : MethodFn<TSchema, TSchemaMethod, TRequestOptionsBase>;
|
|
73
|
+
type HttpMethods<TSchema, TRequestOptionsBase = object> = {
|
|
74
|
+
get: MethodOrPath<TSchema, 'get', '$get', TRequestOptionsBase>;
|
|
75
|
+
post: MethodOrPath<TSchema, 'post', '$post', TRequestOptionsBase>;
|
|
76
|
+
put: MethodOrPath<TSchema, 'put', '$put', TRequestOptionsBase>;
|
|
77
|
+
patch: MethodOrPath<TSchema, 'patch', '$patch', TRequestOptionsBase>;
|
|
78
|
+
delete: MethodOrPath<TSchema, 'delete', '$delete', TRequestOptionsBase>;
|
|
79
79
|
};
|
|
80
|
-
type DynamicAccess<TSchema> = ExtractDynamicSchema<TSchema> extends never ? object : {
|
|
81
|
-
[key: string]: EnlaceClient<ExtractDynamicSchema<TSchema
|
|
82
|
-
[key: number]: EnlaceClient<ExtractDynamicSchema<TSchema
|
|
80
|
+
type DynamicAccess<TSchema, TRequestOptionsBase = object> = ExtractDynamicSchema<TSchema> extends never ? object : {
|
|
81
|
+
[key: string]: EnlaceClient<ExtractDynamicSchema<TSchema>, TRequestOptionsBase>;
|
|
82
|
+
[key: number]: EnlaceClient<ExtractDynamicSchema<TSchema>, TRequestOptionsBase>;
|
|
83
83
|
};
|
|
84
84
|
type MethodNameKeys = 'get' | 'post' | 'put' | 'patch' | 'delete';
|
|
85
|
-
type EnlaceClient<TSchema> = HttpMethods<TSchema> & DynamicAccess<TSchema> & {
|
|
86
|
-
[K in keyof StaticPathKeys<TSchema> as K extends MethodNameKeys ? never : K]: EnlaceClient<TSchema[K]>;
|
|
85
|
+
type EnlaceClient<TSchema, TRequestOptionsBase = object> = HttpMethods<TSchema, TRequestOptionsBase> & DynamicAccess<TSchema, TRequestOptionsBase> & {
|
|
86
|
+
[K in keyof StaticPathKeys<TSchema> as K extends MethodNameKeys ? never : K]: EnlaceClient<TSchema[K], TRequestOptionsBase>;
|
|
87
87
|
};
|
|
88
|
-
type WildcardMethodFn = (options?: RequestOptions<unknown>) => Promise<EnlaceResponse<unknown, unknown>>;
|
|
88
|
+
type WildcardMethodFn<TRequestOptionsBase = object> = (options?: RequestOptions<unknown> & TRequestOptionsBase) => Promise<EnlaceResponse<unknown, unknown>>;
|
|
89
89
|
/**
|
|
90
90
|
* Wildcard client type - allows any path access when no schema is provided.
|
|
91
91
|
* All methods are available at every level and return unknown types.
|
|
92
92
|
*/
|
|
93
|
-
type WildcardClient = {
|
|
94
|
-
get: WildcardMethodFn
|
|
95
|
-
post: WildcardMethodFn
|
|
96
|
-
put: WildcardMethodFn
|
|
97
|
-
patch: WildcardMethodFn
|
|
98
|
-
delete: WildcardMethodFn
|
|
93
|
+
type WildcardClient<TRequestOptionsBase = object> = {
|
|
94
|
+
get: WildcardMethodFn<TRequestOptionsBase>;
|
|
95
|
+
post: WildcardMethodFn<TRequestOptionsBase>;
|
|
96
|
+
put: WildcardMethodFn<TRequestOptionsBase>;
|
|
97
|
+
patch: WildcardMethodFn<TRequestOptionsBase>;
|
|
98
|
+
delete: WildcardMethodFn<TRequestOptionsBase>;
|
|
99
99
|
} & {
|
|
100
|
-
[key: string]: WildcardClient
|
|
101
|
-
[key: number]: WildcardClient
|
|
100
|
+
[key: string]: WildcardClient<TRequestOptionsBase>;
|
|
101
|
+
[key: number]: WildcardClient<TRequestOptionsBase>;
|
|
102
102
|
};
|
|
103
103
|
|
|
104
104
|
export type { EnlaceOptions as E, FetchExecutor as F, HttpMethod as H, MethodDefinition as M, RequestOptions as R, SchemaMethod as S, WildcardClient as W, EnlaceResponse as a, EnlaceClient as b, Endpoint as c };
|
|
@@ -61,7 +61,7 @@ type ExtractBody<TSchema, TMethod extends SchemaMethod> = ExtractMethodDef<TSche
|
|
|
61
61
|
type HasMethod<TSchema, TMethod extends SchemaMethod> = TSchema extends {
|
|
62
62
|
[K in TMethod]: MethodDefinition;
|
|
63
63
|
} ? true : false;
|
|
64
|
-
type MethodFn<TSchema, TMethod extends SchemaMethod> = HasMethod<TSchema, TMethod> extends true ? ExtractBody<TSchema, TMethod> extends never ? (options?: RequestOptions<never>) => Promise<EnlaceResponse<ExtractData<TSchema, TMethod>, ExtractError<TSchema, TMethod>>> : (options: RequestOptions<ExtractBody<TSchema, TMethod>>) => Promise<EnlaceResponse<ExtractData<TSchema, TMethod>, ExtractError<TSchema, TMethod>>> : never;
|
|
64
|
+
type MethodFn<TSchema, TMethod extends SchemaMethod, TRequestOptionsBase = object> = HasMethod<TSchema, TMethod> extends true ? ExtractBody<TSchema, TMethod> extends never ? (options?: RequestOptions<never> & TRequestOptionsBase) => Promise<EnlaceResponse<ExtractData<TSchema, TMethod>, ExtractError<TSchema, TMethod>>> : (options: RequestOptions<ExtractBody<TSchema, TMethod>> & TRequestOptionsBase) => Promise<EnlaceResponse<ExtractData<TSchema, TMethod>, ExtractError<TSchema, TMethod>>> : never;
|
|
65
65
|
type IsSpecialKey<K> = K extends SchemaMethod | '_' ? true : false;
|
|
66
66
|
type StaticPathKeys<TSchema> = {
|
|
67
67
|
[K in keyof TSchema as IsSpecialKey<K> extends true ? never : K extends string ? K : never]: TSchema[K];
|
|
@@ -69,36 +69,36 @@ type StaticPathKeys<TSchema> = {
|
|
|
69
69
|
type ExtractDynamicSchema<TSchema> = TSchema extends {
|
|
70
70
|
_: infer D;
|
|
71
71
|
} ? D : never;
|
|
72
|
-
type MethodOrPath<TSchema, TMethodName extends string, TSchemaMethod extends SchemaMethod> = TMethodName extends keyof TSchema ? EnlaceClient<TSchema[TMethodName]> : MethodFn<TSchema, TSchemaMethod>;
|
|
73
|
-
type HttpMethods<TSchema> = {
|
|
74
|
-
get: MethodOrPath<TSchema, 'get', '$get'>;
|
|
75
|
-
post: MethodOrPath<TSchema, 'post', '$post'>;
|
|
76
|
-
put: MethodOrPath<TSchema, 'put', '$put'>;
|
|
77
|
-
patch: MethodOrPath<TSchema, 'patch', '$patch'>;
|
|
78
|
-
delete: MethodOrPath<TSchema, 'delete', '$delete'>;
|
|
72
|
+
type MethodOrPath<TSchema, TMethodName extends string, TSchemaMethod extends SchemaMethod, TRequestOptionsBase = object> = TMethodName extends keyof TSchema ? EnlaceClient<TSchema[TMethodName], TRequestOptionsBase> : MethodFn<TSchema, TSchemaMethod, TRequestOptionsBase>;
|
|
73
|
+
type HttpMethods<TSchema, TRequestOptionsBase = object> = {
|
|
74
|
+
get: MethodOrPath<TSchema, 'get', '$get', TRequestOptionsBase>;
|
|
75
|
+
post: MethodOrPath<TSchema, 'post', '$post', TRequestOptionsBase>;
|
|
76
|
+
put: MethodOrPath<TSchema, 'put', '$put', TRequestOptionsBase>;
|
|
77
|
+
patch: MethodOrPath<TSchema, 'patch', '$patch', TRequestOptionsBase>;
|
|
78
|
+
delete: MethodOrPath<TSchema, 'delete', '$delete', TRequestOptionsBase>;
|
|
79
79
|
};
|
|
80
|
-
type DynamicAccess<TSchema> = ExtractDynamicSchema<TSchema> extends never ? object : {
|
|
81
|
-
[key: string]: EnlaceClient<ExtractDynamicSchema<TSchema
|
|
82
|
-
[key: number]: EnlaceClient<ExtractDynamicSchema<TSchema
|
|
80
|
+
type DynamicAccess<TSchema, TRequestOptionsBase = object> = ExtractDynamicSchema<TSchema> extends never ? object : {
|
|
81
|
+
[key: string]: EnlaceClient<ExtractDynamicSchema<TSchema>, TRequestOptionsBase>;
|
|
82
|
+
[key: number]: EnlaceClient<ExtractDynamicSchema<TSchema>, TRequestOptionsBase>;
|
|
83
83
|
};
|
|
84
84
|
type MethodNameKeys = 'get' | 'post' | 'put' | 'patch' | 'delete';
|
|
85
|
-
type EnlaceClient<TSchema> = HttpMethods<TSchema> & DynamicAccess<TSchema> & {
|
|
86
|
-
[K in keyof StaticPathKeys<TSchema> as K extends MethodNameKeys ? never : K]: EnlaceClient<TSchema[K]>;
|
|
85
|
+
type EnlaceClient<TSchema, TRequestOptionsBase = object> = HttpMethods<TSchema, TRequestOptionsBase> & DynamicAccess<TSchema, TRequestOptionsBase> & {
|
|
86
|
+
[K in keyof StaticPathKeys<TSchema> as K extends MethodNameKeys ? never : K]: EnlaceClient<TSchema[K], TRequestOptionsBase>;
|
|
87
87
|
};
|
|
88
|
-
type WildcardMethodFn = (options?: RequestOptions<unknown>) => Promise<EnlaceResponse<unknown, unknown>>;
|
|
88
|
+
type WildcardMethodFn<TRequestOptionsBase = object> = (options?: RequestOptions<unknown> & TRequestOptionsBase) => Promise<EnlaceResponse<unknown, unknown>>;
|
|
89
89
|
/**
|
|
90
90
|
* Wildcard client type - allows any path access when no schema is provided.
|
|
91
91
|
* All methods are available at every level and return unknown types.
|
|
92
92
|
*/
|
|
93
|
-
type WildcardClient = {
|
|
94
|
-
get: WildcardMethodFn
|
|
95
|
-
post: WildcardMethodFn
|
|
96
|
-
put: WildcardMethodFn
|
|
97
|
-
patch: WildcardMethodFn
|
|
98
|
-
delete: WildcardMethodFn
|
|
93
|
+
type WildcardClient<TRequestOptionsBase = object> = {
|
|
94
|
+
get: WildcardMethodFn<TRequestOptionsBase>;
|
|
95
|
+
post: WildcardMethodFn<TRequestOptionsBase>;
|
|
96
|
+
put: WildcardMethodFn<TRequestOptionsBase>;
|
|
97
|
+
patch: WildcardMethodFn<TRequestOptionsBase>;
|
|
98
|
+
delete: WildcardMethodFn<TRequestOptionsBase>;
|
|
99
99
|
} & {
|
|
100
|
-
[key: string]: WildcardClient
|
|
101
|
-
[key: number]: WildcardClient
|
|
100
|
+
[key: string]: WildcardClient<TRequestOptionsBase>;
|
|
101
|
+
[key: number]: WildcardClient<TRequestOptionsBase>;
|
|
102
102
|
};
|
|
103
103
|
|
|
104
104
|
export type { EnlaceOptions as E, FetchExecutor as F, HttpMethod as H, MethodDefinition as M, RequestOptions as R, SchemaMethod as S, WildcardClient as W, EnlaceResponse as a, EnlaceClient as b, Endpoint as c };
|