@awsless/awsless 0.0.118 → 0.0.120
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/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 +1 -40
- package/dist/index.js +0 -45
- package/package.json +7 -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
|
package/dist/index.d.ts
CHANGED
|
@@ -11264,45 +11264,6 @@ interface SearchResources {
|
|
|
11264
11264
|
}
|
|
11265
11265
|
declare const Search: SearchResources;
|
|
11266
11266
|
|
|
11267
|
-
interface HTTP {
|
|
11268
|
-
}
|
|
11269
|
-
type Method = 'GET' | 'POST';
|
|
11270
|
-
type Path = string;
|
|
11271
|
-
type Params = Record<string, string | number>;
|
|
11272
|
-
type Query = Record<string, string>;
|
|
11273
|
-
type Body = unknown;
|
|
11274
|
-
type Route = {
|
|
11275
|
-
param?: Params;
|
|
11276
|
-
query?: Query;
|
|
11277
|
-
body?: Body;
|
|
11278
|
-
response: unknown;
|
|
11279
|
-
};
|
|
11280
|
-
type Routes = Record<Path, Route>;
|
|
11281
|
-
type Schema = Partial<Record<Method, Routes>>;
|
|
11282
|
-
type GetRoute<S extends Schema, M extends keyof S, P extends keyof S[M]> = S[M] extends Routes ? S[M][P] : never;
|
|
11283
|
-
type Props<R extends Route> = {
|
|
11284
|
-
headers?: Record<string, string>;
|
|
11285
|
-
params?: R['param'] extends Params ? R['param'] : never;
|
|
11286
|
-
query?: R['query'] extends Query ? R['query'] : never;
|
|
11287
|
-
body?: R['body'] extends Body ? R['body'] : never;
|
|
11288
|
-
};
|
|
11289
|
-
type HttpFetcher = (props: {
|
|
11290
|
-
method: Method;
|
|
11291
|
-
path: Path;
|
|
11292
|
-
headers: Headers;
|
|
11293
|
-
query?: Query;
|
|
11294
|
-
body?: Body;
|
|
11295
|
-
}) => unknown;
|
|
11296
|
-
declare const createHttpFetcher: (host: string) => HttpFetcher;
|
|
11297
|
-
declare const createHttpClient: <S extends Partial<Record<Method, Routes>>>(fetcher: HttpFetcher) => {
|
|
11298
|
-
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"]>;
|
|
11299
|
-
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"]>;
|
|
11300
|
-
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"]>;
|
|
11301
|
-
};
|
|
11302
|
-
|
|
11303
|
-
interface GraphQL {
|
|
11304
|
-
}
|
|
11305
|
-
|
|
11306
11267
|
type FunctionProps<H extends Handler<S>, S extends BaseSchema> = {
|
|
11307
11268
|
handle: H;
|
|
11308
11269
|
schema?: S;
|
|
@@ -12163,4 +12124,4 @@ declare const defineStackConfig: (config: StackConfig) => StackConfig$1 | (Stack
|
|
|
12163
12124
|
});
|
|
12164
12125
|
declare const defineAppConfig: (config: AppConfig | AppConfigFactory<AppConfig>) => CombinedDefaultPluginsConfigInput | AppConfigFactory<CombinedDefaultPluginsConfigInput>;
|
|
12165
12126
|
|
|
12166
|
-
export { APP, AppConfig, Auth, AuthResources, Cache, CacheResources, Config, ConfigResources, CronProps, Fn, Function, FunctionMock, FunctionMockResponse, FunctionProps, FunctionResources,
|
|
12127
|
+
export { APP, AppConfig, Auth, AuthResources, Cache, CacheResources, Config, ConfigResources, CronProps, Fn, Function, FunctionMock, FunctionMockResponse, FunctionProps, FunctionResources, Plugin, Queue, QueueMock, QueueMockResponse, QueueProps, QueueResources, STACK, Search, SearchResources, StackConfig, Store, StoreResources, Table, TableResources, Topic, TopicMock, TopicMockResponse, TopicProps, TopicResources, cron, defineAppConfig, definePlugin, defineStackConfig, func, getAuthName, getAuthProps, getCacheProps, getConfigName, getFunctionName, getGlobalResourceName, getLocalResourceName, getQueueName, getSearchName, getStoreName, getTableName, getTopicName, mockFunction, mockQueue, mockTopic, queue, topic };
|
package/dist/index.js
CHANGED
|
@@ -250,49 +250,6 @@ var Search = /* @__PURE__ */ createProxy((stack) => {
|
|
|
250
250
|
});
|
|
251
251
|
});
|
|
252
252
|
|
|
253
|
-
// src/node/http.ts
|
|
254
|
-
var createHttpFetcher = (host) => {
|
|
255
|
-
return async ({ method, path, headers, body, query }) => {
|
|
256
|
-
const url = new URL(host, path);
|
|
257
|
-
if (query) {
|
|
258
|
-
for (const [key, value] of Object.entries(query)) {
|
|
259
|
-
url.searchParams.set(key, value);
|
|
260
|
-
}
|
|
261
|
-
}
|
|
262
|
-
headers.set("content-type", "application/json");
|
|
263
|
-
const response = await fetch(url, {
|
|
264
|
-
method,
|
|
265
|
-
headers,
|
|
266
|
-
body: body ? JSON.stringify(body) : void 0
|
|
267
|
-
});
|
|
268
|
-
const result = await response.json();
|
|
269
|
-
return result;
|
|
270
|
-
};
|
|
271
|
-
};
|
|
272
|
-
var createHttpClient = (fetcher) => {
|
|
273
|
-
const fetch2 = (method, routeKey, props) => {
|
|
274
|
-
const path = routeKey.replaceAll(/{([a-z0-1-]+)}/, (key) => {
|
|
275
|
-
return props?.params?.[key.substring(1, key.length - 1)].toString() ?? "";
|
|
276
|
-
});
|
|
277
|
-
return fetcher({
|
|
278
|
-
headers: new Headers(props?.headers),
|
|
279
|
-
query: props?.query,
|
|
280
|
-
body: props?.body,
|
|
281
|
-
method,
|
|
282
|
-
path
|
|
283
|
-
});
|
|
284
|
-
};
|
|
285
|
-
return {
|
|
286
|
-
fetch: fetch2,
|
|
287
|
-
get(routeKey, props) {
|
|
288
|
-
return fetch2("GET", routeKey, props);
|
|
289
|
-
},
|
|
290
|
-
post(routeKey, props) {
|
|
291
|
-
return fetch2("POST", routeKey, props);
|
|
292
|
-
}
|
|
293
|
-
};
|
|
294
|
-
};
|
|
295
|
-
|
|
296
253
|
// src/node/handle/function.ts
|
|
297
254
|
import { lambda } from "@awsless/lambda";
|
|
298
255
|
var func = (props) => {
|
|
@@ -407,8 +364,6 @@ export {
|
|
|
407
364
|
Store,
|
|
408
365
|
Table,
|
|
409
366
|
Topic,
|
|
410
|
-
createHttpClient,
|
|
411
|
-
createHttpFetcher,
|
|
412
367
|
cron,
|
|
413
368
|
defineAppConfig,
|
|
414
369
|
definePlugin,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@awsless/awsless",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.120",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"sideEffects": false,
|
|
@@ -21,6 +21,10 @@
|
|
|
21
21
|
".": {
|
|
22
22
|
"import": "./dist/index.js",
|
|
23
23
|
"types": "./dist/index.d.ts"
|
|
24
|
+
},
|
|
25
|
+
"./client": {
|
|
26
|
+
"import": "./dist/client.js",
|
|
27
|
+
"types": "./dist/client.d.ts"
|
|
24
28
|
}
|
|
25
29
|
},
|
|
26
30
|
"peerDependencies": {
|
|
@@ -28,8 +32,8 @@
|
|
|
28
32
|
"@awsless/redis": "^0.0.8",
|
|
29
33
|
"@awsless/sns": "^0.0.7",
|
|
30
34
|
"@awsless/sqs": "^0.0.7",
|
|
31
|
-
"@awsless/ssm": "^0.0.7",
|
|
32
35
|
"@awsless/validate": "^0.0.10",
|
|
36
|
+
"@awsless/ssm": "^0.0.7",
|
|
33
37
|
"@awsless/weak-cache": "^0.0.1"
|
|
34
38
|
},
|
|
35
39
|
"dependencies": {
|
|
@@ -85,7 +89,7 @@
|
|
|
85
89
|
"test": "pnpm code test",
|
|
86
90
|
"term": "zsh -c 'node dist/bin.js ${*} --config-file=./test/_data/config.ts' --",
|
|
87
91
|
"berm": "zsh -c 'pnpm build; pnpm build-features; node dist/bin.js ${*} --config-file=./test/_data/config.ts' --",
|
|
88
|
-
"build": "pnpm tsup src/index.ts src/bin.ts --format esm --dts --clean",
|
|
92
|
+
"build": "pnpm tsup src/index.ts src/bin.ts src/client.ts --format esm --dts --clean",
|
|
89
93
|
"build-features": "node ./features/build.js",
|
|
90
94
|
"prepublish": "if pnpm test schema; then pnpm build; pnpm build-features; else exit; fi"
|
|
91
95
|
}
|