@awsless/awsless 0.0.139 → 0.0.140
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/bin.d.ts +1 -0
- package/dist/bin.js +8543 -0
- package/dist/chunk-PFTL6L4F.js +6 -0
- package/dist/client.d.ts +40 -0
- package/dist/client.js +46 -0
- package/dist/features/cognito-client-secret/bundle.zip +0 -0
- package/dist/features/delete-bucket/bundle.zip +0 -0
- package/dist/features/delete-hosted-zone/bundle.zip +0 -0
- package/dist/features/global-exports/bundle.zip +0 -0
- package/dist/features/invalidate-cache/bundle.zip +0 -0
- package/dist/features/upload-bucket-asset/bundle.zip +0 -0
- package/dist/index.d.ts +9462 -0
- package/dist/index.js +383 -0
- package/package.json +3 -3
package/dist/client.d.ts
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
interface HTTP {
|
|
2
|
+
}
|
|
3
|
+
type Method = 'GET' | 'POST';
|
|
4
|
+
type Path = string;
|
|
5
|
+
type Params = Record<string, string | number>;
|
|
6
|
+
type Query = Record<string, string>;
|
|
7
|
+
type Body = unknown;
|
|
8
|
+
type Route = {
|
|
9
|
+
param?: Params;
|
|
10
|
+
query?: Query;
|
|
11
|
+
body?: Body;
|
|
12
|
+
response: unknown;
|
|
13
|
+
};
|
|
14
|
+
type Routes = Record<Path, Route>;
|
|
15
|
+
type Schema = Partial<Record<Method, Routes>>;
|
|
16
|
+
type GetRoute<S extends Schema, M extends keyof S, P extends keyof S[M]> = S[M] extends Routes ? S[M][P] : never;
|
|
17
|
+
type Props<R extends Route> = {
|
|
18
|
+
headers?: Record<string, string>;
|
|
19
|
+
params?: R['param'] extends Params ? R['param'] : never;
|
|
20
|
+
query?: R['query'] extends Query ? R['query'] : never;
|
|
21
|
+
body?: R['body'] extends Body ? R['body'] : never;
|
|
22
|
+
};
|
|
23
|
+
type HttpFetcher = (props: {
|
|
24
|
+
method: Method;
|
|
25
|
+
path: Path;
|
|
26
|
+
headers: Headers;
|
|
27
|
+
query?: Query;
|
|
28
|
+
body?: Body;
|
|
29
|
+
}) => unknown;
|
|
30
|
+
declare const createHttpFetcher: (host: string) => HttpFetcher;
|
|
31
|
+
declare const createHttpClient: <S extends Partial<Record<Method, Routes>>>(fetcher: HttpFetcher) => {
|
|
32
|
+
fetch: <M extends keyof S, P extends keyof S[M]>(method: M, routeKey: Extract<P, string>, props?: Props<GetRoute<S, M, P>> | undefined) => Promise<GetRoute<S, M, P>["response"]>;
|
|
33
|
+
get<P_1 extends keyof S["GET"]>(routeKey: Extract<P_1, string>, props?: Props<GetRoute<S, "GET", P_1>> | undefined): Promise<GetRoute<S, "GET", P_1>["response"]>;
|
|
34
|
+
post<P_2 extends keyof S["POST"]>(routeKey: Extract<P_2, string>, props?: Props<GetRoute<S, "POST", P_2>> | undefined): Promise<GetRoute<S, "POST", P_2>["response"]>;
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
interface GraphQL {
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
export { GraphQL, HTTP, HttpFetcher, createHttpClient, createHttpFetcher };
|
package/dist/client.js
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
// src/node/http.ts
|
|
2
|
+
var createHttpFetcher = (host) => {
|
|
3
|
+
return async ({ method, path, headers, body, query }) => {
|
|
4
|
+
const url = new URL(host, path);
|
|
5
|
+
if (query) {
|
|
6
|
+
for (const [key, value] of Object.entries(query)) {
|
|
7
|
+
url.searchParams.set(key, value);
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
headers.set("content-type", "application/json");
|
|
11
|
+
const response = await fetch(url, {
|
|
12
|
+
method,
|
|
13
|
+
headers,
|
|
14
|
+
body: body ? JSON.stringify(body) : void 0
|
|
15
|
+
});
|
|
16
|
+
const result = await response.json();
|
|
17
|
+
return result;
|
|
18
|
+
};
|
|
19
|
+
};
|
|
20
|
+
var createHttpClient = (fetcher) => {
|
|
21
|
+
const fetch2 = (method, routeKey, props) => {
|
|
22
|
+
const path = routeKey.replaceAll(/{([a-z0-1-]+)}/, (key) => {
|
|
23
|
+
return props?.params?.[key.substring(1, key.length - 1)].toString() ?? "";
|
|
24
|
+
});
|
|
25
|
+
return fetcher({
|
|
26
|
+
headers: new Headers(props?.headers),
|
|
27
|
+
query: props?.query,
|
|
28
|
+
body: props?.body,
|
|
29
|
+
method,
|
|
30
|
+
path
|
|
31
|
+
});
|
|
32
|
+
};
|
|
33
|
+
return {
|
|
34
|
+
fetch: fetch2,
|
|
35
|
+
get(routeKey, props) {
|
|
36
|
+
return fetch2("GET", routeKey, props);
|
|
37
|
+
},
|
|
38
|
+
post(routeKey, props) {
|
|
39
|
+
return fetch2("POST", routeKey, props);
|
|
40
|
+
}
|
|
41
|
+
};
|
|
42
|
+
};
|
|
43
|
+
export {
|
|
44
|
+
createHttpClient,
|
|
45
|
+
createHttpFetcher
|
|
46
|
+
};
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|