@smithy/core 1.0.5 → 1.1.0
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-cjs/index.js +1 -0
- package/dist-cjs/protocols/requestBuilder.js +72 -0
- package/dist-es/index.js +1 -0
- package/dist-es/protocols/requestBuilder.js +67 -0
- package/dist-types/index.d.ts +1 -0
- package/dist-types/protocols/requestBuilder.d.ts +51 -0
- package/dist-types/ts3.4/index.d.ts +1 -0
- package/dist-types/ts3.4/protocols/requestBuilder.d.ts +51 -0
- package/package.json +2 -1
package/dist-cjs/index.js
CHANGED
|
@@ -6,3 +6,4 @@ tslib_1.__exportStar(require("./middleware-http-signing"), exports);
|
|
|
6
6
|
tslib_1.__exportStar(require("./util-identity-and-auth"), exports);
|
|
7
7
|
tslib_1.__exportStar(require("./getSmithyContext"), exports);
|
|
8
8
|
tslib_1.__exportStar(require("./normalizeProvider"), exports);
|
|
9
|
+
tslib_1.__exportStar(require("./protocols/requestBuilder"), exports);
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.RequestBuilder = exports.requestBuilder = void 0;
|
|
4
|
+
const protocol_http_1 = require("@smithy/protocol-http");
|
|
5
|
+
const smithy_client_1 = require("@smithy/smithy-client");
|
|
6
|
+
function requestBuilder(input, context) {
|
|
7
|
+
return new RequestBuilder(input, context);
|
|
8
|
+
}
|
|
9
|
+
exports.requestBuilder = requestBuilder;
|
|
10
|
+
class RequestBuilder {
|
|
11
|
+
constructor(input, context) {
|
|
12
|
+
this.input = input;
|
|
13
|
+
this.context = context;
|
|
14
|
+
this.query = {};
|
|
15
|
+
this.method = "";
|
|
16
|
+
this.headers = {};
|
|
17
|
+
this.path = "";
|
|
18
|
+
this.body = null;
|
|
19
|
+
this.hostname = "";
|
|
20
|
+
this.resolvePathStack = [];
|
|
21
|
+
}
|
|
22
|
+
async build() {
|
|
23
|
+
const { hostname, protocol = "https", port, path: basePath } = await this.context.endpoint();
|
|
24
|
+
this.path = basePath;
|
|
25
|
+
for (const resolvePath of this.resolvePathStack) {
|
|
26
|
+
resolvePath(this.path);
|
|
27
|
+
}
|
|
28
|
+
return new protocol_http_1.HttpRequest({
|
|
29
|
+
protocol,
|
|
30
|
+
hostname: this.hostname || hostname,
|
|
31
|
+
port,
|
|
32
|
+
method: this.method,
|
|
33
|
+
path: this.path,
|
|
34
|
+
query: this.query,
|
|
35
|
+
body: this.body,
|
|
36
|
+
headers: this.headers,
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
hn(hostname) {
|
|
40
|
+
this.hostname = hostname;
|
|
41
|
+
return this;
|
|
42
|
+
}
|
|
43
|
+
bp(uriLabel) {
|
|
44
|
+
this.resolvePathStack.push((basePath) => {
|
|
45
|
+
this.path = `${(basePath === null || basePath === void 0 ? void 0 : basePath.endsWith("/")) ? basePath.slice(0, -1) : basePath || ""}` + uriLabel;
|
|
46
|
+
});
|
|
47
|
+
return this;
|
|
48
|
+
}
|
|
49
|
+
p(memberName, labelValueProvider, uriLabel, isGreedyLabel) {
|
|
50
|
+
this.resolvePathStack.push((path) => {
|
|
51
|
+
this.path = (0, smithy_client_1.resolvedPath)(path, this.input, memberName, labelValueProvider, uriLabel, isGreedyLabel);
|
|
52
|
+
});
|
|
53
|
+
return this;
|
|
54
|
+
}
|
|
55
|
+
h(headers) {
|
|
56
|
+
this.headers = headers;
|
|
57
|
+
return this;
|
|
58
|
+
}
|
|
59
|
+
q(query) {
|
|
60
|
+
this.query = query;
|
|
61
|
+
return this;
|
|
62
|
+
}
|
|
63
|
+
b(body) {
|
|
64
|
+
this.body = body;
|
|
65
|
+
return this;
|
|
66
|
+
}
|
|
67
|
+
m(method) {
|
|
68
|
+
this.method = method;
|
|
69
|
+
return this;
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
exports.RequestBuilder = RequestBuilder;
|
package/dist-es/index.js
CHANGED
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import { HttpRequest } from "@smithy/protocol-http";
|
|
2
|
+
import { resolvedPath } from "@smithy/smithy-client";
|
|
3
|
+
export function requestBuilder(input, context) {
|
|
4
|
+
return new RequestBuilder(input, context);
|
|
5
|
+
}
|
|
6
|
+
export class RequestBuilder {
|
|
7
|
+
constructor(input, context) {
|
|
8
|
+
this.input = input;
|
|
9
|
+
this.context = context;
|
|
10
|
+
this.query = {};
|
|
11
|
+
this.method = "";
|
|
12
|
+
this.headers = {};
|
|
13
|
+
this.path = "";
|
|
14
|
+
this.body = null;
|
|
15
|
+
this.hostname = "";
|
|
16
|
+
this.resolvePathStack = [];
|
|
17
|
+
}
|
|
18
|
+
async build() {
|
|
19
|
+
const { hostname, protocol = "https", port, path: basePath } = await this.context.endpoint();
|
|
20
|
+
this.path = basePath;
|
|
21
|
+
for (const resolvePath of this.resolvePathStack) {
|
|
22
|
+
resolvePath(this.path);
|
|
23
|
+
}
|
|
24
|
+
return new HttpRequest({
|
|
25
|
+
protocol,
|
|
26
|
+
hostname: this.hostname || hostname,
|
|
27
|
+
port,
|
|
28
|
+
method: this.method,
|
|
29
|
+
path: this.path,
|
|
30
|
+
query: this.query,
|
|
31
|
+
body: this.body,
|
|
32
|
+
headers: this.headers,
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
hn(hostname) {
|
|
36
|
+
this.hostname = hostname;
|
|
37
|
+
return this;
|
|
38
|
+
}
|
|
39
|
+
bp(uriLabel) {
|
|
40
|
+
this.resolvePathStack.push((basePath) => {
|
|
41
|
+
this.path = `${basePath?.endsWith("/") ? basePath.slice(0, -1) : basePath || ""}` + uriLabel;
|
|
42
|
+
});
|
|
43
|
+
return this;
|
|
44
|
+
}
|
|
45
|
+
p(memberName, labelValueProvider, uriLabel, isGreedyLabel) {
|
|
46
|
+
this.resolvePathStack.push((path) => {
|
|
47
|
+
this.path = resolvedPath(path, this.input, memberName, labelValueProvider, uriLabel, isGreedyLabel);
|
|
48
|
+
});
|
|
49
|
+
return this;
|
|
50
|
+
}
|
|
51
|
+
h(headers) {
|
|
52
|
+
this.headers = headers;
|
|
53
|
+
return this;
|
|
54
|
+
}
|
|
55
|
+
q(query) {
|
|
56
|
+
this.query = query;
|
|
57
|
+
return this;
|
|
58
|
+
}
|
|
59
|
+
b(body) {
|
|
60
|
+
this.body = body;
|
|
61
|
+
return this;
|
|
62
|
+
}
|
|
63
|
+
m(method) {
|
|
64
|
+
this.method = method;
|
|
65
|
+
return this;
|
|
66
|
+
}
|
|
67
|
+
}
|
package/dist-types/index.d.ts
CHANGED
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { HttpRequest } from "@smithy/protocol-http";
|
|
2
|
+
import type { SerdeContext } from "@smithy/types";
|
|
3
|
+
/**
|
|
4
|
+
* @internal
|
|
5
|
+
* used in code-generated serde.
|
|
6
|
+
*/
|
|
7
|
+
export declare function requestBuilder(input: any, context: SerdeContext): RequestBuilder;
|
|
8
|
+
/**
|
|
9
|
+
* @internal
|
|
10
|
+
*/
|
|
11
|
+
export declare class RequestBuilder {
|
|
12
|
+
private input;
|
|
13
|
+
private context;
|
|
14
|
+
private query;
|
|
15
|
+
private method;
|
|
16
|
+
private headers;
|
|
17
|
+
private path;
|
|
18
|
+
private body;
|
|
19
|
+
private hostname;
|
|
20
|
+
private resolvePathStack;
|
|
21
|
+
constructor(input: any, context: SerdeContext);
|
|
22
|
+
build(): Promise<HttpRequest>;
|
|
23
|
+
/**
|
|
24
|
+
* Brevity setter for "hostname".
|
|
25
|
+
*/
|
|
26
|
+
hn(hostname: string): this;
|
|
27
|
+
/**
|
|
28
|
+
* Brevity initial builder for "basepath".
|
|
29
|
+
*/
|
|
30
|
+
bp(uriLabel: string): this;
|
|
31
|
+
/**
|
|
32
|
+
* Brevity incremental builder for "path".
|
|
33
|
+
*/
|
|
34
|
+
p(memberName: string, labelValueProvider: () => string | undefined, uriLabel: string, isGreedyLabel: boolean): this;
|
|
35
|
+
/**
|
|
36
|
+
* Brevity setter for "headers".
|
|
37
|
+
*/
|
|
38
|
+
h(headers: Record<string, string>): this;
|
|
39
|
+
/**
|
|
40
|
+
* Brevity setter for "query".
|
|
41
|
+
*/
|
|
42
|
+
q(query: Record<string, string>): this;
|
|
43
|
+
/**
|
|
44
|
+
* Brevity setter for "body".
|
|
45
|
+
*/
|
|
46
|
+
b(body: any): this;
|
|
47
|
+
/**
|
|
48
|
+
* Brevity setter for "method".
|
|
49
|
+
*/
|
|
50
|
+
m(method: string): this;
|
|
51
|
+
}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { HttpRequest } from "@smithy/protocol-http";
|
|
2
|
+
import { SerdeContext } from "@smithy/types";
|
|
3
|
+
/**
|
|
4
|
+
* @internal
|
|
5
|
+
* used in code-generated serde.
|
|
6
|
+
*/
|
|
7
|
+
export declare function requestBuilder(input: any, context: SerdeContext): RequestBuilder;
|
|
8
|
+
/**
|
|
9
|
+
* @internal
|
|
10
|
+
*/
|
|
11
|
+
export declare class RequestBuilder {
|
|
12
|
+
private input;
|
|
13
|
+
private context;
|
|
14
|
+
private query;
|
|
15
|
+
private method;
|
|
16
|
+
private headers;
|
|
17
|
+
private path;
|
|
18
|
+
private body;
|
|
19
|
+
private hostname;
|
|
20
|
+
private resolvePathStack;
|
|
21
|
+
constructor(input: any, context: SerdeContext);
|
|
22
|
+
build(): Promise<HttpRequest>;
|
|
23
|
+
/**
|
|
24
|
+
* Brevity setter for "hostname".
|
|
25
|
+
*/
|
|
26
|
+
hn(hostname: string): this;
|
|
27
|
+
/**
|
|
28
|
+
* Brevity initial builder for "basepath".
|
|
29
|
+
*/
|
|
30
|
+
bp(uriLabel: string): this;
|
|
31
|
+
/**
|
|
32
|
+
* Brevity incremental builder for "path".
|
|
33
|
+
*/
|
|
34
|
+
p(memberName: string, labelValueProvider: () => string | undefined, uriLabel: string, isGreedyLabel: boolean): this;
|
|
35
|
+
/**
|
|
36
|
+
* Brevity setter for "headers".
|
|
37
|
+
*/
|
|
38
|
+
h(headers: Record<string, string>): this;
|
|
39
|
+
/**
|
|
40
|
+
* Brevity setter for "query".
|
|
41
|
+
*/
|
|
42
|
+
q(query: Record<string, string>): this;
|
|
43
|
+
/**
|
|
44
|
+
* Brevity setter for "body".
|
|
45
|
+
*/
|
|
46
|
+
b(body: any): this;
|
|
47
|
+
/**
|
|
48
|
+
* Brevity setter for "method".
|
|
49
|
+
*/
|
|
50
|
+
m(method: string): this;
|
|
51
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@smithy/core",
|
|
3
|
-
"version": "1.0
|
|
3
|
+
"version": "1.1.0",
|
|
4
4
|
"scripts": {
|
|
5
5
|
"build": "concurrently 'yarn:build:cjs' 'yarn:build:es' 'yarn:build:types && yarn build:types:downlevel'",
|
|
6
6
|
"build:cjs": "yarn g:tsc -p tsconfig.cjs.json",
|
|
@@ -27,6 +27,7 @@
|
|
|
27
27
|
"@smithy/middleware-retry": "^2.0.24",
|
|
28
28
|
"@smithy/middleware-serde": "^2.0.15",
|
|
29
29
|
"@smithy/protocol-http": "^3.0.11",
|
|
30
|
+
"@smithy/smithy-client": "^2.1.18",
|
|
30
31
|
"@smithy/types": "^2.7.0",
|
|
31
32
|
"tslib": "^2.5.0"
|
|
32
33
|
},
|