@ttoss/aws-appsync-nodejs 1.5.6 → 1.5.7
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/esm/index.js +19 -9
- package/dist/index.js +39 -20
- package/package.json +3 -3
package/dist/esm/index.js
CHANGED
|
@@ -7,11 +7,14 @@ import { Sha256 } from "@aws-crypto/sha256-js";
|
|
|
7
7
|
import { SignatureV4 } from "@aws-sdk/signature-v4";
|
|
8
8
|
import { defaultProvider } from "@aws-sdk/credential-provider-node";
|
|
9
9
|
var _config;
|
|
10
|
-
var setConfig =
|
|
10
|
+
var setConfig = config => {
|
|
11
11
|
_config = config;
|
|
12
12
|
};
|
|
13
13
|
var queryWithApiKey = async (query2, variables) => {
|
|
14
|
-
const {
|
|
14
|
+
const {
|
|
15
|
+
apiEndpoint,
|
|
16
|
+
apiKey
|
|
17
|
+
} = _config;
|
|
15
18
|
if (!apiKey) {
|
|
16
19
|
throw new Error("No API Key set");
|
|
17
20
|
}
|
|
@@ -20,14 +23,17 @@ var queryWithApiKey = async (query2, variables) => {
|
|
|
20
23
|
headers: {
|
|
21
24
|
"x-api-key": apiKey
|
|
22
25
|
},
|
|
23
|
-
body: JSON.stringify({
|
|
26
|
+
body: JSON.stringify({
|
|
27
|
+
query: query2,
|
|
28
|
+
variables
|
|
29
|
+
})
|
|
24
30
|
};
|
|
25
31
|
const request = new Request(apiEndpoint, options);
|
|
26
32
|
const response = await fetch(request);
|
|
27
33
|
const body = await response.json();
|
|
28
34
|
return body;
|
|
29
35
|
};
|
|
30
|
-
var getRegionFromEndpoint =
|
|
36
|
+
var getRegionFromEndpoint = endpoint => {
|
|
31
37
|
const matcher = /\.[a-z]+-[a-z]+-[0-9]\./;
|
|
32
38
|
const regexResponse = endpoint.match(matcher);
|
|
33
39
|
let region = "";
|
|
@@ -37,7 +43,10 @@ var getRegionFromEndpoint = (endpoint) => {
|
|
|
37
43
|
return region;
|
|
38
44
|
};
|
|
39
45
|
var queryWithCredentials = async (query2, variables) => {
|
|
40
|
-
const {
|
|
46
|
+
const {
|
|
47
|
+
apiEndpoint,
|
|
48
|
+
awsCredentials
|
|
49
|
+
} = _config;
|
|
41
50
|
const endpoint = new URL(apiEndpoint);
|
|
42
51
|
const region = getRegionFromEndpoint(apiEndpoint);
|
|
43
52
|
const signer = new SignatureV4({
|
|
@@ -53,7 +62,10 @@ var queryWithCredentials = async (query2, variables) => {
|
|
|
53
62
|
host: endpoint.host
|
|
54
63
|
},
|
|
55
64
|
hostname: endpoint.host,
|
|
56
|
-
body: JSON.stringify({
|
|
65
|
+
body: JSON.stringify({
|
|
66
|
+
query: query2,
|
|
67
|
+
variables
|
|
68
|
+
}),
|
|
57
69
|
path: endpoint.pathname
|
|
58
70
|
});
|
|
59
71
|
const signed = await signer.sign(requestToBeSigned);
|
|
@@ -75,6 +87,4 @@ var appSyncClient = {
|
|
|
75
87
|
return _config;
|
|
76
88
|
}
|
|
77
89
|
};
|
|
78
|
-
export {
|
|
79
|
-
appSyncClient
|
|
80
|
-
};
|
|
90
|
+
export { appSyncClient };
|
package/dist/index.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
/** Powered by @ttoss/config. https://ttoss.dev/docs/modules/packages/config/ */
|
|
2
2
|
"use strict";
|
|
3
|
+
|
|
3
4
|
var __create = Object.create;
|
|
4
5
|
var __defProp = Object.defineProperty;
|
|
5
6
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
@@ -7,26 +8,32 @@ var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
|
7
8
|
var __getProtoOf = Object.getPrototypeOf;
|
|
8
9
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
9
10
|
var __export = (target, all) => {
|
|
10
|
-
for (var name in all)
|
|
11
|
-
|
|
11
|
+
for (var name in all) __defProp(target, name, {
|
|
12
|
+
get: all[name],
|
|
13
|
+
enumerable: true
|
|
14
|
+
});
|
|
12
15
|
};
|
|
13
16
|
var __copyProps = (to, from, except, desc) => {
|
|
14
17
|
if (from && typeof from === "object" || typeof from === "function") {
|
|
15
|
-
for (let key of __getOwnPropNames(from))
|
|
16
|
-
|
|
17
|
-
|
|
18
|
+
for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
19
|
+
get: () => from[key],
|
|
20
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
21
|
+
});
|
|
18
22
|
}
|
|
19
23
|
return to;
|
|
20
24
|
};
|
|
21
25
|
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
mod
|
|
28
|
-
|
|
29
|
-
|
|
26
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
27
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
28
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
29
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
30
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
|
|
31
|
+
value: mod,
|
|
32
|
+
enumerable: true
|
|
33
|
+
}) : target, mod));
|
|
34
|
+
var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
|
|
35
|
+
value: true
|
|
36
|
+
}), mod);
|
|
30
37
|
|
|
31
38
|
// src/index.ts
|
|
32
39
|
var src_exports = {};
|
|
@@ -40,11 +47,14 @@ var import_sha256_js = require("@aws-crypto/sha256-js");
|
|
|
40
47
|
var import_signature_v4 = require("@aws-sdk/signature-v4");
|
|
41
48
|
var import_credential_provider_node = require("@aws-sdk/credential-provider-node");
|
|
42
49
|
var _config;
|
|
43
|
-
var setConfig =
|
|
50
|
+
var setConfig = config => {
|
|
44
51
|
_config = config;
|
|
45
52
|
};
|
|
46
53
|
var queryWithApiKey = async (query2, variables) => {
|
|
47
|
-
const {
|
|
54
|
+
const {
|
|
55
|
+
apiEndpoint,
|
|
56
|
+
apiKey
|
|
57
|
+
} = _config;
|
|
48
58
|
if (!apiKey) {
|
|
49
59
|
throw new Error("No API Key set");
|
|
50
60
|
}
|
|
@@ -53,14 +63,17 @@ var queryWithApiKey = async (query2, variables) => {
|
|
|
53
63
|
headers: {
|
|
54
64
|
"x-api-key": apiKey
|
|
55
65
|
},
|
|
56
|
-
body: JSON.stringify({
|
|
66
|
+
body: JSON.stringify({
|
|
67
|
+
query: query2,
|
|
68
|
+
variables
|
|
69
|
+
})
|
|
57
70
|
};
|
|
58
71
|
const request = new import_node_fetch.Request(apiEndpoint, options);
|
|
59
72
|
const response = await (0, import_node_fetch.default)(request);
|
|
60
73
|
const body = await response.json();
|
|
61
74
|
return body;
|
|
62
75
|
};
|
|
63
|
-
var getRegionFromEndpoint =
|
|
76
|
+
var getRegionFromEndpoint = endpoint => {
|
|
64
77
|
const matcher = /\.[a-z]+-[a-z]+-[0-9]\./;
|
|
65
78
|
const regexResponse = endpoint.match(matcher);
|
|
66
79
|
let region = "";
|
|
@@ -70,7 +83,10 @@ var getRegionFromEndpoint = (endpoint) => {
|
|
|
70
83
|
return region;
|
|
71
84
|
};
|
|
72
85
|
var queryWithCredentials = async (query2, variables) => {
|
|
73
|
-
const {
|
|
86
|
+
const {
|
|
87
|
+
apiEndpoint,
|
|
88
|
+
awsCredentials
|
|
89
|
+
} = _config;
|
|
74
90
|
const endpoint = new URL(apiEndpoint);
|
|
75
91
|
const region = getRegionFromEndpoint(apiEndpoint);
|
|
76
92
|
const signer = new import_signature_v4.SignatureV4({
|
|
@@ -86,7 +102,10 @@ var queryWithCredentials = async (query2, variables) => {
|
|
|
86
102
|
host: endpoint.host
|
|
87
103
|
},
|
|
88
104
|
hostname: endpoint.host,
|
|
89
|
-
body: JSON.stringify({
|
|
105
|
+
body: JSON.stringify({
|
|
106
|
+
query: query2,
|
|
107
|
+
variables
|
|
108
|
+
}),
|
|
90
109
|
path: endpoint.pathname
|
|
91
110
|
});
|
|
92
111
|
const signed = await signer.sign(requestToBeSigned);
|
|
@@ -111,4 +130,4 @@ var appSyncClient = {
|
|
|
111
130
|
// Annotate the CommonJS export names for ESM import in node:
|
|
112
131
|
0 && (module.exports = {
|
|
113
132
|
appSyncClient
|
|
114
|
-
});
|
|
133
|
+
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ttoss/aws-appsync-nodejs",
|
|
3
|
-
"version": "1.5.
|
|
3
|
+
"version": "1.5.7",
|
|
4
4
|
"description": "",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "ttoss",
|
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
"node-fetch": "2"
|
|
24
24
|
},
|
|
25
25
|
"devDependencies": {
|
|
26
|
-
"@ttoss/config": "^1.29.
|
|
26
|
+
"@ttoss/config": "^1.29.2",
|
|
27
27
|
"@types/jest": "^29.5.0",
|
|
28
28
|
"jest": "^29.5.0"
|
|
29
29
|
},
|
|
@@ -31,5 +31,5 @@
|
|
|
31
31
|
"publishConfig": {
|
|
32
32
|
"access": "public"
|
|
33
33
|
},
|
|
34
|
-
"gitHead": "
|
|
34
|
+
"gitHead": "0609bb0f6e6a1c0999c29e7a5c8f8ebb1c6d3d7a"
|
|
35
35
|
}
|