@ampless/mcp-server 0.2.0-alpha.0 → 0.2.0-alpha.1
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/bowser-WRHMEFK3.js +2822 -0
- package/dist/chunk-3NCQATCK.js +1385 -0
- package/dist/chunk-5PA6IP7O.js +435 -0
- package/dist/{chunk-27JGNXJE.js → chunk-6OXXSXKN.js} +8 -37
- package/dist/{chunk-YDYRXGHR.js → chunk-A4YPJIDF.js} +3 -3
- package/dist/chunk-CVNCRUML.js +1355 -0
- package/dist/chunk-IKXKDSVH.js +1414 -0
- package/dist/chunk-ISXSZYT4.js +1375 -0
- package/dist/{chunk-GSC7CBT2.js → chunk-IW52OUIR.js} +117 -1025
- package/dist/chunk-QBXY5RRO.js +3559 -0
- package/dist/chunk-UMEQ5ALV.js +14 -0
- package/dist/{chunk-OLRXGK7L.js → chunk-YHHXORQ4.js} +48 -32
- package/dist/{dist-es-J7V6TEWZ.js → dist-es-3P7CNKGV.js} +15 -16
- package/dist/{dist-es-6QUIY4X7.js → dist-es-NAMW5ZZ4.js} +21 -31
- package/dist/{dist-es-MQG4P6NF.js → dist-es-OI6XP2CN.js} +9 -10
- package/dist/{dist-es-W5H6GQXM.js → dist-es-OO5RVJZO.js} +10 -11
- package/dist/{dist-es-NGSDZSP2.js → dist-es-PRQWND46.js} +4 -3
- package/dist/{dist-es-2HK4JUU7.js → dist-es-T6J3WJJK.js} +32 -36
- package/dist/{dist-es-OYHIBJO3.js → dist-es-ZP52SD4G.js} +27 -32
- package/dist/event-streams-WFL2DK34.js +43 -0
- package/dist/index.js +2061 -2633
- package/dist/{loadSso-3FWOSWL4.js → loadSso-C2Y2WOQK.js} +56 -58
- package/dist/{signin-EATRRDTG.js → signin-IY5CLTYR.js} +59 -63
- package/dist/{sso-oidc-5GRHV5HA.js → sso-oidc-KZTDOR7Y.js} +59 -63
- package/dist/{sts-IMPWC7YM.js → sts-2UABQZ6D.js} +625 -740
- package/package.json +3 -3
- package/dist/chunk-44FZZOIP.js +0 -14
- package/dist/chunk-72G5HA35.js +0 -62
- package/dist/chunk-B57O737J.js +0 -52
- package/dist/chunk-E6YHJFDU.js +0 -44
- package/dist/chunk-FCBONYCH.js +0 -6008
- package/dist/chunk-GBNV7FEX.js +0 -164
- package/dist/chunk-MQF5MXOW.js +0 -1040
- package/dist/chunk-NZ2AQICN.js +0 -29
- package/dist/chunk-YVOTBVHL.js +0 -243
- package/dist/chunk-ZB7FTU7J.js +0 -39
- package/dist/event-streams-6T3GMAVH.js +0 -253
package/dist/chunk-NZ2AQICN.js
DELETED
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
import {
|
|
3
|
-
ProviderError
|
|
4
|
-
} from "./chunk-ZB7FTU7J.js";
|
|
5
|
-
|
|
6
|
-
// ../../node_modules/.pnpm/@smithy+property-provider@4.2.14/node_modules/@smithy/property-provider/dist-es/chain.js
|
|
7
|
-
var chain = (...providers) => async () => {
|
|
8
|
-
if (providers.length === 0) {
|
|
9
|
-
throw new ProviderError("No providers in chain");
|
|
10
|
-
}
|
|
11
|
-
let lastProviderError;
|
|
12
|
-
for (const provider of providers) {
|
|
13
|
-
try {
|
|
14
|
-
const credentials = await provider();
|
|
15
|
-
return credentials;
|
|
16
|
-
} catch (err) {
|
|
17
|
-
lastProviderError = err;
|
|
18
|
-
if (err?.tryNextLink) {
|
|
19
|
-
continue;
|
|
20
|
-
}
|
|
21
|
-
throw err;
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
throw lastProviderError;
|
|
25
|
-
};
|
|
26
|
-
|
|
27
|
-
export {
|
|
28
|
-
chain
|
|
29
|
-
};
|
package/dist/chunk-YVOTBVHL.js
DELETED
|
@@ -1,243 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
|
|
3
|
-
// ../../node_modules/.pnpm/@smithy+shared-ini-file-loader@4.4.9/node_modules/@smithy/shared-ini-file-loader/dist-es/getProfileName.js
|
|
4
|
-
var ENV_PROFILE = "AWS_PROFILE";
|
|
5
|
-
var DEFAULT_PROFILE = "default";
|
|
6
|
-
var getProfileName = (init) => init.profile || process.env[ENV_PROFILE] || DEFAULT_PROFILE;
|
|
7
|
-
|
|
8
|
-
// ../../node_modules/.pnpm/@smithy+shared-ini-file-loader@4.4.9/node_modules/@smithy/shared-ini-file-loader/dist-es/getConfigFilepath.js
|
|
9
|
-
import { join } from "path";
|
|
10
|
-
|
|
11
|
-
// ../../node_modules/.pnpm/@smithy+shared-ini-file-loader@4.4.9/node_modules/@smithy/shared-ini-file-loader/dist-es/getHomeDir.js
|
|
12
|
-
import { homedir } from "os";
|
|
13
|
-
import { sep } from "path";
|
|
14
|
-
var homeDirCache = {};
|
|
15
|
-
var getHomeDirCacheKey = () => {
|
|
16
|
-
if (process && process.geteuid) {
|
|
17
|
-
return `${process.geteuid()}`;
|
|
18
|
-
}
|
|
19
|
-
return "DEFAULT";
|
|
20
|
-
};
|
|
21
|
-
var getHomeDir = () => {
|
|
22
|
-
const { HOME, USERPROFILE, HOMEPATH, HOMEDRIVE = `C:${sep}` } = process.env;
|
|
23
|
-
if (HOME)
|
|
24
|
-
return HOME;
|
|
25
|
-
if (USERPROFILE)
|
|
26
|
-
return USERPROFILE;
|
|
27
|
-
if (HOMEPATH)
|
|
28
|
-
return `${HOMEDRIVE}${HOMEPATH}`;
|
|
29
|
-
const homeDirCacheKey = getHomeDirCacheKey();
|
|
30
|
-
if (!homeDirCache[homeDirCacheKey])
|
|
31
|
-
homeDirCache[homeDirCacheKey] = homedir();
|
|
32
|
-
return homeDirCache[homeDirCacheKey];
|
|
33
|
-
};
|
|
34
|
-
|
|
35
|
-
// ../../node_modules/.pnpm/@smithy+shared-ini-file-loader@4.4.9/node_modules/@smithy/shared-ini-file-loader/dist-es/getConfigFilepath.js
|
|
36
|
-
var ENV_CONFIG_PATH = "AWS_CONFIG_FILE";
|
|
37
|
-
var getConfigFilepath = () => process.env[ENV_CONFIG_PATH] || join(getHomeDir(), ".aws", "config");
|
|
38
|
-
|
|
39
|
-
// ../../node_modules/.pnpm/@smithy+types@4.14.1/node_modules/@smithy/types/dist-es/profile.js
|
|
40
|
-
var IniSectionType;
|
|
41
|
-
(function(IniSectionType2) {
|
|
42
|
-
IniSectionType2["PROFILE"] = "profile";
|
|
43
|
-
IniSectionType2["SSO_SESSION"] = "sso-session";
|
|
44
|
-
IniSectionType2["SERVICES"] = "services";
|
|
45
|
-
})(IniSectionType || (IniSectionType = {}));
|
|
46
|
-
|
|
47
|
-
// ../../node_modules/.pnpm/@smithy+shared-ini-file-loader@4.4.9/node_modules/@smithy/shared-ini-file-loader/dist-es/loadSharedConfigFiles.js
|
|
48
|
-
import { join as join3 } from "path";
|
|
49
|
-
|
|
50
|
-
// ../../node_modules/.pnpm/@smithy+shared-ini-file-loader@4.4.9/node_modules/@smithy/shared-ini-file-loader/dist-es/constants.js
|
|
51
|
-
var CONFIG_PREFIX_SEPARATOR = ".";
|
|
52
|
-
|
|
53
|
-
// ../../node_modules/.pnpm/@smithy+shared-ini-file-loader@4.4.9/node_modules/@smithy/shared-ini-file-loader/dist-es/getConfigData.js
|
|
54
|
-
var getConfigData = (data) => Object.entries(data).filter(([key]) => {
|
|
55
|
-
const indexOfSeparator = key.indexOf(CONFIG_PREFIX_SEPARATOR);
|
|
56
|
-
if (indexOfSeparator === -1) {
|
|
57
|
-
return false;
|
|
58
|
-
}
|
|
59
|
-
return Object.values(IniSectionType).includes(key.substring(0, indexOfSeparator));
|
|
60
|
-
}).reduce((acc, [key, value]) => {
|
|
61
|
-
const indexOfSeparator = key.indexOf(CONFIG_PREFIX_SEPARATOR);
|
|
62
|
-
const updatedKey = key.substring(0, indexOfSeparator) === IniSectionType.PROFILE ? key.substring(indexOfSeparator + 1) : key;
|
|
63
|
-
acc[updatedKey] = value;
|
|
64
|
-
return acc;
|
|
65
|
-
}, {
|
|
66
|
-
...data.default && { default: data.default }
|
|
67
|
-
});
|
|
68
|
-
|
|
69
|
-
// ../../node_modules/.pnpm/@smithy+shared-ini-file-loader@4.4.9/node_modules/@smithy/shared-ini-file-loader/dist-es/getCredentialsFilepath.js
|
|
70
|
-
import { join as join2 } from "path";
|
|
71
|
-
var ENV_CREDENTIALS_PATH = "AWS_SHARED_CREDENTIALS_FILE";
|
|
72
|
-
var getCredentialsFilepath = () => process.env[ENV_CREDENTIALS_PATH] || join2(getHomeDir(), ".aws", "credentials");
|
|
73
|
-
|
|
74
|
-
// ../../node_modules/.pnpm/@smithy+shared-ini-file-loader@4.4.9/node_modules/@smithy/shared-ini-file-loader/dist-es/parseIni.js
|
|
75
|
-
var prefixKeyRegex = /^([\w-]+)\s(["'])?([\w-@\+\.%:/]+)\2$/;
|
|
76
|
-
var profileNameBlockList = ["__proto__", "profile __proto__"];
|
|
77
|
-
var parseIni = (iniData) => {
|
|
78
|
-
const map = {};
|
|
79
|
-
let currentSection;
|
|
80
|
-
let currentSubSection;
|
|
81
|
-
for (const iniLine of iniData.split(/\r?\n/)) {
|
|
82
|
-
const trimmedLine = iniLine.split(/(^|\s)[;#]/)[0].trim();
|
|
83
|
-
const isSection = trimmedLine[0] === "[" && trimmedLine[trimmedLine.length - 1] === "]";
|
|
84
|
-
if (isSection) {
|
|
85
|
-
currentSection = void 0;
|
|
86
|
-
currentSubSection = void 0;
|
|
87
|
-
const sectionName = trimmedLine.substring(1, trimmedLine.length - 1);
|
|
88
|
-
const matches = prefixKeyRegex.exec(sectionName);
|
|
89
|
-
if (matches) {
|
|
90
|
-
const [, prefix, , name] = matches;
|
|
91
|
-
if (Object.values(IniSectionType).includes(prefix)) {
|
|
92
|
-
currentSection = [prefix, name].join(CONFIG_PREFIX_SEPARATOR);
|
|
93
|
-
}
|
|
94
|
-
} else {
|
|
95
|
-
currentSection = sectionName;
|
|
96
|
-
}
|
|
97
|
-
if (profileNameBlockList.includes(sectionName)) {
|
|
98
|
-
throw new Error(`Found invalid profile name "${sectionName}"`);
|
|
99
|
-
}
|
|
100
|
-
} else if (currentSection) {
|
|
101
|
-
const indexOfEqualsSign = trimmedLine.indexOf("=");
|
|
102
|
-
if (![0, -1].includes(indexOfEqualsSign)) {
|
|
103
|
-
const [name, value] = [
|
|
104
|
-
trimmedLine.substring(0, indexOfEqualsSign).trim(),
|
|
105
|
-
trimmedLine.substring(indexOfEqualsSign + 1).trim()
|
|
106
|
-
];
|
|
107
|
-
if (value === "") {
|
|
108
|
-
currentSubSection = name;
|
|
109
|
-
} else {
|
|
110
|
-
if (currentSubSection && iniLine.trimStart() === iniLine) {
|
|
111
|
-
currentSubSection = void 0;
|
|
112
|
-
}
|
|
113
|
-
map[currentSection] = map[currentSection] || {};
|
|
114
|
-
const key = currentSubSection ? [currentSubSection, name].join(CONFIG_PREFIX_SEPARATOR) : name;
|
|
115
|
-
map[currentSection][key] = value;
|
|
116
|
-
}
|
|
117
|
-
}
|
|
118
|
-
}
|
|
119
|
-
}
|
|
120
|
-
return map;
|
|
121
|
-
};
|
|
122
|
-
|
|
123
|
-
// ../../node_modules/.pnpm/@smithy+shared-ini-file-loader@4.4.9/node_modules/@smithy/shared-ini-file-loader/dist-es/readFile.js
|
|
124
|
-
import { readFile as fsReadFile } from "fs/promises";
|
|
125
|
-
var filePromises = {};
|
|
126
|
-
var fileIntercept = {};
|
|
127
|
-
var readFile = (path, options) => {
|
|
128
|
-
if (fileIntercept[path] !== void 0) {
|
|
129
|
-
return fileIntercept[path];
|
|
130
|
-
}
|
|
131
|
-
if (!filePromises[path] || options?.ignoreCache) {
|
|
132
|
-
filePromises[path] = fsReadFile(path, "utf8");
|
|
133
|
-
}
|
|
134
|
-
return filePromises[path];
|
|
135
|
-
};
|
|
136
|
-
|
|
137
|
-
// ../../node_modules/.pnpm/@smithy+shared-ini-file-loader@4.4.9/node_modules/@smithy/shared-ini-file-loader/dist-es/loadSharedConfigFiles.js
|
|
138
|
-
var swallowError = () => ({});
|
|
139
|
-
var loadSharedConfigFiles = async (init = {}) => {
|
|
140
|
-
const { filepath = getCredentialsFilepath(), configFilepath = getConfigFilepath() } = init;
|
|
141
|
-
const homeDir = getHomeDir();
|
|
142
|
-
const relativeHomeDirPrefix = "~/";
|
|
143
|
-
let resolvedFilepath = filepath;
|
|
144
|
-
if (filepath.startsWith(relativeHomeDirPrefix)) {
|
|
145
|
-
resolvedFilepath = join3(homeDir, filepath.slice(2));
|
|
146
|
-
}
|
|
147
|
-
let resolvedConfigFilepath = configFilepath;
|
|
148
|
-
if (configFilepath.startsWith(relativeHomeDirPrefix)) {
|
|
149
|
-
resolvedConfigFilepath = join3(homeDir, configFilepath.slice(2));
|
|
150
|
-
}
|
|
151
|
-
const parsedFiles = await Promise.all([
|
|
152
|
-
readFile(resolvedConfigFilepath, {
|
|
153
|
-
ignoreCache: init.ignoreCache
|
|
154
|
-
}).then(parseIni).then(getConfigData).catch(swallowError),
|
|
155
|
-
readFile(resolvedFilepath, {
|
|
156
|
-
ignoreCache: init.ignoreCache
|
|
157
|
-
}).then(parseIni).catch(swallowError)
|
|
158
|
-
]);
|
|
159
|
-
return {
|
|
160
|
-
configFile: parsedFiles[0],
|
|
161
|
-
credentialsFile: parsedFiles[1]
|
|
162
|
-
};
|
|
163
|
-
};
|
|
164
|
-
|
|
165
|
-
// ../../node_modules/.pnpm/@smithy+shared-ini-file-loader@4.4.9/node_modules/@smithy/shared-ini-file-loader/dist-es/getSsoSessionData.js
|
|
166
|
-
var getSsoSessionData = (data) => Object.entries(data).filter(([key]) => key.startsWith(IniSectionType.SSO_SESSION + CONFIG_PREFIX_SEPARATOR)).reduce((acc, [key, value]) => ({ ...acc, [key.substring(key.indexOf(CONFIG_PREFIX_SEPARATOR) + 1)]: value }), {});
|
|
167
|
-
|
|
168
|
-
// ../../node_modules/.pnpm/@smithy+shared-ini-file-loader@4.4.9/node_modules/@smithy/shared-ini-file-loader/dist-es/loadSsoSessionData.js
|
|
169
|
-
var swallowError2 = () => ({});
|
|
170
|
-
var loadSsoSessionData = async (init = {}) => readFile(init.configFilepath ?? getConfigFilepath()).then(parseIni).then(getSsoSessionData).catch(swallowError2);
|
|
171
|
-
|
|
172
|
-
// ../../node_modules/.pnpm/@smithy+shared-ini-file-loader@4.4.9/node_modules/@smithy/shared-ini-file-loader/dist-es/mergeConfigFiles.js
|
|
173
|
-
var mergeConfigFiles = (...files) => {
|
|
174
|
-
const merged = {};
|
|
175
|
-
for (const file of files) {
|
|
176
|
-
for (const [key, values] of Object.entries(file)) {
|
|
177
|
-
if (merged[key] !== void 0) {
|
|
178
|
-
Object.assign(merged[key], values);
|
|
179
|
-
} else {
|
|
180
|
-
merged[key] = values;
|
|
181
|
-
}
|
|
182
|
-
}
|
|
183
|
-
}
|
|
184
|
-
return merged;
|
|
185
|
-
};
|
|
186
|
-
|
|
187
|
-
// ../../node_modules/.pnpm/@smithy+shared-ini-file-loader@4.4.9/node_modules/@smithy/shared-ini-file-loader/dist-es/parseKnownFiles.js
|
|
188
|
-
var parseKnownFiles = async (init) => {
|
|
189
|
-
const parsedFiles = await loadSharedConfigFiles(init);
|
|
190
|
-
return mergeConfigFiles(parsedFiles.configFile, parsedFiles.credentialsFile);
|
|
191
|
-
};
|
|
192
|
-
|
|
193
|
-
// ../../node_modules/.pnpm/@smithy+shared-ini-file-loader@4.4.9/node_modules/@smithy/shared-ini-file-loader/dist-es/getSSOTokenFromFile.js
|
|
194
|
-
import { readFile as readFile2 } from "fs/promises";
|
|
195
|
-
|
|
196
|
-
// ../../node_modules/.pnpm/@smithy+shared-ini-file-loader@4.4.9/node_modules/@smithy/shared-ini-file-loader/dist-es/getSSOTokenFilepath.js
|
|
197
|
-
import { createHash } from "crypto";
|
|
198
|
-
import { join as join4 } from "path";
|
|
199
|
-
var getSSOTokenFilepath = (id) => {
|
|
200
|
-
const hasher = createHash("sha1");
|
|
201
|
-
const cacheName = hasher.update(id).digest("hex");
|
|
202
|
-
return join4(getHomeDir(), ".aws", "sso", "cache", `${cacheName}.json`);
|
|
203
|
-
};
|
|
204
|
-
|
|
205
|
-
// ../../node_modules/.pnpm/@smithy+shared-ini-file-loader@4.4.9/node_modules/@smithy/shared-ini-file-loader/dist-es/getSSOTokenFromFile.js
|
|
206
|
-
var tokenIntercept = {};
|
|
207
|
-
var getSSOTokenFromFile = async (id) => {
|
|
208
|
-
if (tokenIntercept[id]) {
|
|
209
|
-
return tokenIntercept[id];
|
|
210
|
-
}
|
|
211
|
-
const ssoTokenFilepath = getSSOTokenFilepath(id);
|
|
212
|
-
const ssoTokenText = await readFile2(ssoTokenFilepath, "utf8");
|
|
213
|
-
return JSON.parse(ssoTokenText);
|
|
214
|
-
};
|
|
215
|
-
|
|
216
|
-
// ../../node_modules/.pnpm/@smithy+shared-ini-file-loader@4.4.9/node_modules/@smithy/shared-ini-file-loader/dist-es/externalDataInterceptor.js
|
|
217
|
-
var externalDataInterceptor = {
|
|
218
|
-
getFileRecord() {
|
|
219
|
-
return fileIntercept;
|
|
220
|
-
},
|
|
221
|
-
interceptFile(path, contents) {
|
|
222
|
-
fileIntercept[path] = Promise.resolve(contents);
|
|
223
|
-
},
|
|
224
|
-
getTokenRecord() {
|
|
225
|
-
return tokenIntercept;
|
|
226
|
-
},
|
|
227
|
-
interceptToken(id, contents) {
|
|
228
|
-
tokenIntercept[id] = contents;
|
|
229
|
-
}
|
|
230
|
-
};
|
|
231
|
-
|
|
232
|
-
export {
|
|
233
|
-
ENV_PROFILE,
|
|
234
|
-
getProfileName,
|
|
235
|
-
getSSOTokenFilepath,
|
|
236
|
-
getSSOTokenFromFile,
|
|
237
|
-
CONFIG_PREFIX_SEPARATOR,
|
|
238
|
-
readFile,
|
|
239
|
-
loadSharedConfigFiles,
|
|
240
|
-
loadSsoSessionData,
|
|
241
|
-
parseKnownFiles,
|
|
242
|
-
externalDataInterceptor
|
|
243
|
-
};
|
package/dist/chunk-ZB7FTU7J.js
DELETED
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
|
|
3
|
-
// ../../node_modules/.pnpm/@smithy+property-provider@4.2.14/node_modules/@smithy/property-provider/dist-es/ProviderError.js
|
|
4
|
-
var ProviderError = class _ProviderError extends Error {
|
|
5
|
-
name = "ProviderError";
|
|
6
|
-
tryNextLink;
|
|
7
|
-
constructor(message, options = true) {
|
|
8
|
-
let logger;
|
|
9
|
-
let tryNextLink = true;
|
|
10
|
-
if (typeof options === "boolean") {
|
|
11
|
-
logger = void 0;
|
|
12
|
-
tryNextLink = options;
|
|
13
|
-
} else if (options != null && typeof options === "object") {
|
|
14
|
-
logger = options.logger;
|
|
15
|
-
tryNextLink = options.tryNextLink ?? true;
|
|
16
|
-
}
|
|
17
|
-
super(message);
|
|
18
|
-
this.tryNextLink = tryNextLink;
|
|
19
|
-
Object.setPrototypeOf(this, _ProviderError.prototype);
|
|
20
|
-
logger?.debug?.(`@smithy/property-provider ${tryNextLink ? "->" : "(!)"} ${message}`);
|
|
21
|
-
}
|
|
22
|
-
static from(error, options = true) {
|
|
23
|
-
return Object.assign(new this(error.message, options), error);
|
|
24
|
-
}
|
|
25
|
-
};
|
|
26
|
-
|
|
27
|
-
// ../../node_modules/.pnpm/@smithy+property-provider@4.2.14/node_modules/@smithy/property-provider/dist-es/CredentialsProviderError.js
|
|
28
|
-
var CredentialsProviderError = class _CredentialsProviderError extends ProviderError {
|
|
29
|
-
name = "CredentialsProviderError";
|
|
30
|
-
constructor(message, options = true) {
|
|
31
|
-
super(message, options);
|
|
32
|
-
Object.setPrototypeOf(this, _CredentialsProviderError.prototype);
|
|
33
|
-
}
|
|
34
|
-
};
|
|
35
|
-
|
|
36
|
-
export {
|
|
37
|
-
ProviderError,
|
|
38
|
-
CredentialsProviderError
|
|
39
|
-
};
|
|
@@ -1,253 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
import {
|
|
3
|
-
fromUtf8,
|
|
4
|
-
toUtf8
|
|
5
|
-
} from "./chunk-E6YHJFDU.js";
|
|
6
|
-
import "./chunk-LMMQX4CK.js";
|
|
7
|
-
|
|
8
|
-
// ../../node_modules/.pnpm/@smithy+core@3.23.17/node_modules/@smithy/core/dist-es/submodules/event-streams/EventStreamSerde.js
|
|
9
|
-
var EventStreamSerde = class {
|
|
10
|
-
marshaller;
|
|
11
|
-
serializer;
|
|
12
|
-
deserializer;
|
|
13
|
-
serdeContext;
|
|
14
|
-
defaultContentType;
|
|
15
|
-
constructor({ marshaller, serializer, deserializer, serdeContext, defaultContentType }) {
|
|
16
|
-
this.marshaller = marshaller;
|
|
17
|
-
this.serializer = serializer;
|
|
18
|
-
this.deserializer = deserializer;
|
|
19
|
-
this.serdeContext = serdeContext;
|
|
20
|
-
this.defaultContentType = defaultContentType;
|
|
21
|
-
}
|
|
22
|
-
async serializeEventStream({ eventStream, requestSchema, initialRequest }) {
|
|
23
|
-
const marshaller = this.marshaller;
|
|
24
|
-
const eventStreamMember = requestSchema.getEventStreamMember();
|
|
25
|
-
const unionSchema = requestSchema.getMemberSchema(eventStreamMember);
|
|
26
|
-
const serializer = this.serializer;
|
|
27
|
-
const defaultContentType = this.defaultContentType;
|
|
28
|
-
const initialRequestMarker = /* @__PURE__ */ Symbol("initialRequestMarker");
|
|
29
|
-
const eventStreamIterable = {
|
|
30
|
-
async *[Symbol.asyncIterator]() {
|
|
31
|
-
if (initialRequest) {
|
|
32
|
-
const headers = {
|
|
33
|
-
":event-type": { type: "string", value: "initial-request" },
|
|
34
|
-
":message-type": { type: "string", value: "event" },
|
|
35
|
-
":content-type": { type: "string", value: defaultContentType }
|
|
36
|
-
};
|
|
37
|
-
serializer.write(requestSchema, initialRequest);
|
|
38
|
-
const body = serializer.flush();
|
|
39
|
-
yield {
|
|
40
|
-
[initialRequestMarker]: true,
|
|
41
|
-
headers,
|
|
42
|
-
body
|
|
43
|
-
};
|
|
44
|
-
}
|
|
45
|
-
for await (const page of eventStream) {
|
|
46
|
-
yield page;
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
};
|
|
50
|
-
return marshaller.serialize(eventStreamIterable, (event) => {
|
|
51
|
-
if (event[initialRequestMarker]) {
|
|
52
|
-
return {
|
|
53
|
-
headers: event.headers,
|
|
54
|
-
body: event.body
|
|
55
|
-
};
|
|
56
|
-
}
|
|
57
|
-
let unionMember = "";
|
|
58
|
-
for (const key in event) {
|
|
59
|
-
if (key !== "__type") {
|
|
60
|
-
unionMember = key;
|
|
61
|
-
break;
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
const { additionalHeaders, body, eventType, explicitPayloadContentType } = this.writeEventBody(unionMember, unionSchema, event);
|
|
65
|
-
const headers = {
|
|
66
|
-
":event-type": { type: "string", value: eventType },
|
|
67
|
-
":message-type": { type: "string", value: "event" },
|
|
68
|
-
":content-type": { type: "string", value: explicitPayloadContentType ?? defaultContentType },
|
|
69
|
-
...additionalHeaders
|
|
70
|
-
};
|
|
71
|
-
return {
|
|
72
|
-
headers,
|
|
73
|
-
body
|
|
74
|
-
};
|
|
75
|
-
});
|
|
76
|
-
}
|
|
77
|
-
async deserializeEventStream({ response, responseSchema, initialResponseContainer }) {
|
|
78
|
-
const marshaller = this.marshaller;
|
|
79
|
-
const eventStreamMember = responseSchema.getEventStreamMember();
|
|
80
|
-
const unionSchema = responseSchema.getMemberSchema(eventStreamMember);
|
|
81
|
-
const memberSchemas = unionSchema.getMemberSchemas();
|
|
82
|
-
const initialResponseMarker = /* @__PURE__ */ Symbol("initialResponseMarker");
|
|
83
|
-
const asyncIterable = marshaller.deserialize(response.body, async (event) => {
|
|
84
|
-
let unionMember = "";
|
|
85
|
-
for (const key in event) {
|
|
86
|
-
if (key !== "__type") {
|
|
87
|
-
unionMember = key;
|
|
88
|
-
break;
|
|
89
|
-
}
|
|
90
|
-
}
|
|
91
|
-
const body = event[unionMember].body;
|
|
92
|
-
if (unionMember === "initial-response") {
|
|
93
|
-
const dataObject = await this.deserializer.read(responseSchema, body);
|
|
94
|
-
delete dataObject[eventStreamMember];
|
|
95
|
-
return {
|
|
96
|
-
[initialResponseMarker]: true,
|
|
97
|
-
...dataObject
|
|
98
|
-
};
|
|
99
|
-
} else if (unionMember in memberSchemas) {
|
|
100
|
-
const eventStreamSchema = memberSchemas[unionMember];
|
|
101
|
-
if (eventStreamSchema.isStructSchema()) {
|
|
102
|
-
const out = {};
|
|
103
|
-
let hasBindings = false;
|
|
104
|
-
for (const [name, member] of eventStreamSchema.structIterator()) {
|
|
105
|
-
const { eventHeader, eventPayload } = member.getMergedTraits();
|
|
106
|
-
hasBindings = hasBindings || Boolean(eventHeader || eventPayload);
|
|
107
|
-
if (eventPayload) {
|
|
108
|
-
if (member.isBlobSchema()) {
|
|
109
|
-
out[name] = body;
|
|
110
|
-
} else if (member.isStringSchema()) {
|
|
111
|
-
out[name] = (this.serdeContext?.utf8Encoder ?? toUtf8)(body);
|
|
112
|
-
} else if (member.isStructSchema()) {
|
|
113
|
-
out[name] = await this.deserializer.read(member, body);
|
|
114
|
-
}
|
|
115
|
-
} else if (eventHeader) {
|
|
116
|
-
const value = event[unionMember].headers[name]?.value;
|
|
117
|
-
if (value != null) {
|
|
118
|
-
if (member.isNumericSchema()) {
|
|
119
|
-
if (value && typeof value === "object" && "bytes" in value) {
|
|
120
|
-
out[name] = BigInt(value.toString());
|
|
121
|
-
} else {
|
|
122
|
-
out[name] = Number(value);
|
|
123
|
-
}
|
|
124
|
-
} else {
|
|
125
|
-
out[name] = value;
|
|
126
|
-
}
|
|
127
|
-
}
|
|
128
|
-
}
|
|
129
|
-
}
|
|
130
|
-
if (hasBindings) {
|
|
131
|
-
return {
|
|
132
|
-
[unionMember]: out
|
|
133
|
-
};
|
|
134
|
-
}
|
|
135
|
-
if (body.byteLength === 0) {
|
|
136
|
-
return {
|
|
137
|
-
[unionMember]: {}
|
|
138
|
-
};
|
|
139
|
-
}
|
|
140
|
-
}
|
|
141
|
-
return {
|
|
142
|
-
[unionMember]: await this.deserializer.read(eventStreamSchema, body)
|
|
143
|
-
};
|
|
144
|
-
} else {
|
|
145
|
-
return {
|
|
146
|
-
$unknown: event
|
|
147
|
-
};
|
|
148
|
-
}
|
|
149
|
-
});
|
|
150
|
-
const asyncIterator = asyncIterable[Symbol.asyncIterator]();
|
|
151
|
-
const firstEvent = await asyncIterator.next();
|
|
152
|
-
if (firstEvent.done) {
|
|
153
|
-
return asyncIterable;
|
|
154
|
-
}
|
|
155
|
-
if (firstEvent.value?.[initialResponseMarker]) {
|
|
156
|
-
if (!responseSchema) {
|
|
157
|
-
throw new Error("@smithy::core/protocols - initial-response event encountered in event stream but no response schema given.");
|
|
158
|
-
}
|
|
159
|
-
for (const key in firstEvent.value) {
|
|
160
|
-
initialResponseContainer[key] = firstEvent.value[key];
|
|
161
|
-
}
|
|
162
|
-
}
|
|
163
|
-
return {
|
|
164
|
-
async *[Symbol.asyncIterator]() {
|
|
165
|
-
if (!firstEvent?.value?.[initialResponseMarker]) {
|
|
166
|
-
yield firstEvent.value;
|
|
167
|
-
}
|
|
168
|
-
while (true) {
|
|
169
|
-
const { done, value } = await asyncIterator.next();
|
|
170
|
-
if (done) {
|
|
171
|
-
break;
|
|
172
|
-
}
|
|
173
|
-
yield value;
|
|
174
|
-
}
|
|
175
|
-
}
|
|
176
|
-
};
|
|
177
|
-
}
|
|
178
|
-
writeEventBody(unionMember, unionSchema, event) {
|
|
179
|
-
const serializer = this.serializer;
|
|
180
|
-
let eventType = unionMember;
|
|
181
|
-
let explicitPayloadMember = null;
|
|
182
|
-
let explicitPayloadContentType;
|
|
183
|
-
const isKnownSchema = (() => {
|
|
184
|
-
const struct = unionSchema.getSchema();
|
|
185
|
-
return struct[4].includes(unionMember);
|
|
186
|
-
})();
|
|
187
|
-
const additionalHeaders = {};
|
|
188
|
-
if (!isKnownSchema) {
|
|
189
|
-
const [type, value] = event[unionMember];
|
|
190
|
-
eventType = type;
|
|
191
|
-
serializer.write(15, value);
|
|
192
|
-
} else {
|
|
193
|
-
const eventSchema = unionSchema.getMemberSchema(unionMember);
|
|
194
|
-
if (eventSchema.isStructSchema()) {
|
|
195
|
-
for (const [memberName, memberSchema] of eventSchema.structIterator()) {
|
|
196
|
-
const { eventHeader, eventPayload } = memberSchema.getMergedTraits();
|
|
197
|
-
if (eventPayload) {
|
|
198
|
-
explicitPayloadMember = memberName;
|
|
199
|
-
} else if (eventHeader) {
|
|
200
|
-
const value = event[unionMember][memberName];
|
|
201
|
-
let type = "binary";
|
|
202
|
-
if (memberSchema.isNumericSchema()) {
|
|
203
|
-
if ((-2) ** 31 <= value && value <= 2 ** 31 - 1) {
|
|
204
|
-
type = "integer";
|
|
205
|
-
} else {
|
|
206
|
-
type = "long";
|
|
207
|
-
}
|
|
208
|
-
} else if (memberSchema.isTimestampSchema()) {
|
|
209
|
-
type = "timestamp";
|
|
210
|
-
} else if (memberSchema.isStringSchema()) {
|
|
211
|
-
type = "string";
|
|
212
|
-
} else if (memberSchema.isBooleanSchema()) {
|
|
213
|
-
type = "boolean";
|
|
214
|
-
}
|
|
215
|
-
if (value != null) {
|
|
216
|
-
additionalHeaders[memberName] = {
|
|
217
|
-
type,
|
|
218
|
-
value
|
|
219
|
-
};
|
|
220
|
-
delete event[unionMember][memberName];
|
|
221
|
-
}
|
|
222
|
-
}
|
|
223
|
-
}
|
|
224
|
-
if (explicitPayloadMember !== null) {
|
|
225
|
-
const payloadSchema = eventSchema.getMemberSchema(explicitPayloadMember);
|
|
226
|
-
if (payloadSchema.isBlobSchema()) {
|
|
227
|
-
explicitPayloadContentType = "application/octet-stream";
|
|
228
|
-
} else if (payloadSchema.isStringSchema()) {
|
|
229
|
-
explicitPayloadContentType = "text/plain";
|
|
230
|
-
}
|
|
231
|
-
serializer.write(payloadSchema, event[unionMember][explicitPayloadMember]);
|
|
232
|
-
} else {
|
|
233
|
-
serializer.write(eventSchema, event[unionMember]);
|
|
234
|
-
}
|
|
235
|
-
} else if (eventSchema.isUnitSchema()) {
|
|
236
|
-
serializer.write(eventSchema, {});
|
|
237
|
-
} else {
|
|
238
|
-
throw new Error("@smithy/core/event-streams - non-struct member not supported in event stream union.");
|
|
239
|
-
}
|
|
240
|
-
}
|
|
241
|
-
const messageSerialization = serializer.flush() ?? new Uint8Array();
|
|
242
|
-
const body = typeof messageSerialization === "string" ? (this.serdeContext?.utf8Decoder ?? fromUtf8)(messageSerialization) : messageSerialization;
|
|
243
|
-
return {
|
|
244
|
-
body,
|
|
245
|
-
eventType,
|
|
246
|
-
explicitPayloadContentType,
|
|
247
|
-
additionalHeaders
|
|
248
|
-
};
|
|
249
|
-
}
|
|
250
|
-
};
|
|
251
|
-
export {
|
|
252
|
-
EventStreamSerde
|
|
253
|
-
};
|