@ttoss/relay-amplify 0.4.2 → 0.4.3
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 +13 -26
- package/dist/index.js +24 -21
- package/package.json +3 -3
package/dist/esm/index.js
CHANGED
|
@@ -2,24 +2,17 @@
|
|
|
2
2
|
|
|
3
3
|
// src/index.ts
|
|
4
4
|
import { API, Auth, graphqlOperation } from "aws-amplify";
|
|
5
|
-
import {
|
|
6
|
-
Environment,
|
|
7
|
-
Network,
|
|
8
|
-
RecordSource,
|
|
9
|
-
Store
|
|
10
|
-
} from "relay-runtime";
|
|
5
|
+
import { Environment, Network, RecordSource, Store } from "relay-runtime";
|
|
11
6
|
|
|
12
7
|
// src/encodeCredentials.ts
|
|
13
|
-
var encodeCredentials =
|
|
14
|
-
return Buffer.from(
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
})
|
|
20
|
-
).toString("base64");
|
|
8
|
+
var encodeCredentials = credentials => {
|
|
9
|
+
return Buffer.from(JSON.stringify({
|
|
10
|
+
accessKeyId: credentials.accessKeyId,
|
|
11
|
+
secretAccessKey: credentials.secretAccessKey,
|
|
12
|
+
sessionToken: credentials.sessionToken
|
|
13
|
+
})).toString("base64");
|
|
21
14
|
};
|
|
22
|
-
var decodeCredentials =
|
|
15
|
+
var decodeCredentials = credentials => {
|
|
23
16
|
return JSON.parse(Buffer.from(credentials, "base64").toString("utf8"));
|
|
24
17
|
};
|
|
25
18
|
|
|
@@ -38,10 +31,7 @@ var fetchQuery = async (operation, variables) => {
|
|
|
38
31
|
if (credentials) {
|
|
39
32
|
headers["x-credentials"] = credentials;
|
|
40
33
|
}
|
|
41
|
-
const response = await API.graphql(
|
|
42
|
-
graphqlOperation(operation.text, variables),
|
|
43
|
-
headers
|
|
44
|
-
);
|
|
34
|
+
const response = await API.graphql(graphqlOperation(operation.text, variables), headers);
|
|
45
35
|
return response;
|
|
46
36
|
} catch (error) {
|
|
47
37
|
if (error.errors && error.errors.length > 0) {
|
|
@@ -50,15 +40,12 @@ var fetchQuery = async (operation, variables) => {
|
|
|
50
40
|
throw error;
|
|
51
41
|
}
|
|
52
42
|
};
|
|
53
|
-
var createEnvironment = ({
|
|
43
|
+
var createEnvironment = ({
|
|
44
|
+
storeOptions
|
|
45
|
+
}) => {
|
|
54
46
|
return new Environment({
|
|
55
47
|
network: Network.create(fetchQuery),
|
|
56
48
|
store: new Store(new RecordSource(), storeOptions)
|
|
57
49
|
});
|
|
58
50
|
};
|
|
59
|
-
export {
|
|
60
|
-
createEnvironment,
|
|
61
|
-
decodeCredentials,
|
|
62
|
-
encodeCredentials,
|
|
63
|
-
fetchQuery
|
|
64
|
-
};
|
|
51
|
+
export { createEnvironment, decodeCredentials, encodeCredentials, fetchQuery };
|
package/dist/index.js
CHANGED
|
@@ -1,22 +1,28 @@
|
|
|
1
1
|
/** Powered by @ttoss/config. https://ttoss.dev/docs/modules/packages/config/ */
|
|
2
2
|
"use strict";
|
|
3
|
+
|
|
3
4
|
var __defProp = Object.defineProperty;
|
|
4
5
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
6
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
7
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
8
|
var __export = (target, all) => {
|
|
8
|
-
for (var name in all)
|
|
9
|
-
|
|
9
|
+
for (var name in all) __defProp(target, name, {
|
|
10
|
+
get: all[name],
|
|
11
|
+
enumerable: true
|
|
12
|
+
});
|
|
10
13
|
};
|
|
11
14
|
var __copyProps = (to, from, except, desc) => {
|
|
12
15
|
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
-
for (let key of __getOwnPropNames(from))
|
|
14
|
-
|
|
15
|
-
|
|
16
|
+
for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
17
|
+
get: () => from[key],
|
|
18
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
19
|
+
});
|
|
16
20
|
}
|
|
17
21
|
return to;
|
|
18
22
|
};
|
|
19
|
-
var __toCommonJS =
|
|
23
|
+
var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
|
|
24
|
+
value: true
|
|
25
|
+
}), mod);
|
|
20
26
|
|
|
21
27
|
// src/index.ts
|
|
22
28
|
var src_exports = {};
|
|
@@ -31,16 +37,14 @@ var import_aws_amplify = require("aws-amplify");
|
|
|
31
37
|
var import_relay_runtime = require("relay-runtime");
|
|
32
38
|
|
|
33
39
|
// src/encodeCredentials.ts
|
|
34
|
-
var encodeCredentials =
|
|
35
|
-
return Buffer.from(
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
})
|
|
41
|
-
).toString("base64");
|
|
40
|
+
var encodeCredentials = credentials => {
|
|
41
|
+
return Buffer.from(JSON.stringify({
|
|
42
|
+
accessKeyId: credentials.accessKeyId,
|
|
43
|
+
secretAccessKey: credentials.secretAccessKey,
|
|
44
|
+
sessionToken: credentials.sessionToken
|
|
45
|
+
})).toString("base64");
|
|
42
46
|
};
|
|
43
|
-
var decodeCredentials =
|
|
47
|
+
var decodeCredentials = credentials => {
|
|
44
48
|
return JSON.parse(Buffer.from(credentials, "base64").toString("utf8"));
|
|
45
49
|
};
|
|
46
50
|
|
|
@@ -59,10 +63,7 @@ var fetchQuery = async (operation, variables) => {
|
|
|
59
63
|
if (credentials) {
|
|
60
64
|
headers["x-credentials"] = credentials;
|
|
61
65
|
}
|
|
62
|
-
const response = await import_aws_amplify.API.graphql(
|
|
63
|
-
(0, import_aws_amplify.graphqlOperation)(operation.text, variables),
|
|
64
|
-
headers
|
|
65
|
-
);
|
|
66
|
+
const response = await import_aws_amplify.API.graphql((0, import_aws_amplify.graphqlOperation)(operation.text, variables), headers);
|
|
66
67
|
return response;
|
|
67
68
|
} catch (error) {
|
|
68
69
|
if (error.errors && error.errors.length > 0) {
|
|
@@ -71,7 +72,9 @@ var fetchQuery = async (operation, variables) => {
|
|
|
71
72
|
throw error;
|
|
72
73
|
}
|
|
73
74
|
};
|
|
74
|
-
var createEnvironment = ({
|
|
75
|
+
var createEnvironment = ({
|
|
76
|
+
storeOptions
|
|
77
|
+
}) => {
|
|
75
78
|
return new import_relay_runtime.Environment({
|
|
76
79
|
network: import_relay_runtime.Network.create(fetchQuery),
|
|
77
80
|
store: new import_relay_runtime.Store(new import_relay_runtime.RecordSource(), storeOptions)
|
|
@@ -83,4 +86,4 @@ var createEnvironment = ({ storeOptions }) => {
|
|
|
83
86
|
decodeCredentials,
|
|
84
87
|
encodeCredentials,
|
|
85
88
|
fetchQuery
|
|
86
|
-
});
|
|
89
|
+
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ttoss/relay-amplify",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.3",
|
|
4
4
|
"description": "",
|
|
5
5
|
"license": "UNLICENSED",
|
|
6
6
|
"author": "ttoss",
|
|
@@ -24,7 +24,7 @@
|
|
|
24
24
|
"relay-runtime": "^14.1.0"
|
|
25
25
|
},
|
|
26
26
|
"devDependencies": {
|
|
27
|
-
"@ttoss/config": "^1.29.
|
|
27
|
+
"@ttoss/config": "^1.29.2",
|
|
28
28
|
"aws-amplify": "^5.0.20",
|
|
29
29
|
"relay-runtime": "^14.1.0"
|
|
30
30
|
},
|
|
@@ -32,5 +32,5 @@
|
|
|
32
32
|
"publishConfig": {
|
|
33
33
|
"access": "public"
|
|
34
34
|
},
|
|
35
|
-
"gitHead": "
|
|
35
|
+
"gitHead": "0609bb0f6e6a1c0999c29e7a5c8f8ebb1c6d3d7a"
|
|
36
36
|
}
|