ag-common 0.0.84 → 0.0.85
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.
|
@@ -34,7 +34,8 @@ const setUpApiGw = ({ stack, NODE_ENV, baseUrl, certificate, hostedZone, shortSt
|
|
|
34
34
|
});
|
|
35
35
|
return api;
|
|
36
36
|
};
|
|
37
|
-
const
|
|
37
|
+
const setupLambda = ({ lambdaPermissions, pathV, verb, seenPermissions, }) => {
|
|
38
|
+
var _a, _b, _c, _d;
|
|
38
39
|
const pathCompute = pathV + '/' + verb;
|
|
39
40
|
const lp = lambdaPermissions === null || lambdaPermissions === void 0 ? void 0 : lambdaPermissions[pathCompute];
|
|
40
41
|
if (lp) {
|
|
@@ -48,11 +49,12 @@ const getDynamoPermissions = ({ lambdaPermissions, pathV, verb, seenPermissions,
|
|
|
48
49
|
seenPermissions.default = true;
|
|
49
50
|
}
|
|
50
51
|
//
|
|
51
|
-
const readTables = (0, distinctBy_1.distinctBy)([...((def === null || def === void 0 ? void 0 : def.reads) || []), ...((lp === null || lp === void 0 ? void 0 : lp.reads) || [])], (s) => s.shortName);
|
|
52
|
-
const writeTables = (0, distinctBy_1.distinctBy)([...((def === null || def === void 0 ? void 0 : def.writes) || []), ...((lp === null || lp === void 0 ? void 0 : lp.writes) || [])], (s) => s.shortName);
|
|
52
|
+
const readTables = (0, distinctBy_1.distinctBy)([...(((_a = def === null || def === void 0 ? void 0 : def.dynamo) === null || _a === void 0 ? void 0 : _a.reads) || []), ...(((_b = lp === null || lp === void 0 ? void 0 : lp.dynamo) === null || _b === void 0 ? void 0 : _b.reads) || [])], (s) => s.shortName);
|
|
53
|
+
const writeTables = (0, distinctBy_1.distinctBy)([...(((_c = def === null || def === void 0 ? void 0 : def.dynamo) === null || _c === void 0 ? void 0 : _c.writes) || []), ...(((_d = lp === null || lp === void 0 ? void 0 : lp.dynamo) === null || _d === void 0 ? void 0 : _d.writes) || [])], (s) => s.shortName);
|
|
53
54
|
const policies = [...(def.policies || []), ...((lp === null || lp === void 0 ? void 0 : lp.policies) || [])].filter(__1.notEmpty);
|
|
55
|
+
const env = Object.assign(Object.assign({}, (def.env || {})), ((lp === null || lp === void 0 ? void 0 : lp.env) || {}));
|
|
54
56
|
const tables = [...readTables, ...writeTables];
|
|
55
|
-
const environment =
|
|
57
|
+
const environment = env;
|
|
56
58
|
Object.values(tables).forEach((v) => {
|
|
57
59
|
environment[v.shortName] = v.table.tableName;
|
|
58
60
|
});
|
|
@@ -89,7 +91,7 @@ const openApiImpl = (p) => {
|
|
|
89
91
|
paths.forEach(({ fullPath, verbs, pathList }) => {
|
|
90
92
|
const apiPath = addApiPaths(api, pathList, apiRoots);
|
|
91
93
|
verbs.forEach((verb) => {
|
|
92
|
-
const { environment, readTables, writeTables, policies } =
|
|
94
|
+
const { environment, readTables, writeTables, policies } = setupLambda({
|
|
93
95
|
lambdaPermissions,
|
|
94
96
|
pathV: fullPath,
|
|
95
97
|
verb,
|
|
@@ -17,17 +17,17 @@ export interface IGeneratedDynamoData {
|
|
|
17
17
|
table: dynamodb.ITable;
|
|
18
18
|
shortName: string;
|
|
19
19
|
}
|
|
20
|
-
export interface
|
|
21
|
-
|
|
20
|
+
export interface ILambdaPermission {
|
|
21
|
+
dynamo?: {
|
|
22
22
|
reads?: IGeneratedDynamoData[];
|
|
23
23
|
writes?: IGeneratedDynamoData[];
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
24
|
+
};
|
|
25
|
+
policies?: iam.PolicyStatement[];
|
|
26
|
+
env?: Record<string, string>;
|
|
27
|
+
}
|
|
28
|
+
export interface ILambdaPermissions {
|
|
29
|
+
[pathHyphenVerb: string]: ILambdaPermission & {
|
|
30
|
+
default?: ILambdaPermission;
|
|
31
31
|
};
|
|
32
32
|
}
|
|
33
33
|
export interface IQueryDynamo {
|
|
@@ -34,7 +34,7 @@ const useCallOpenApi = (p) => {
|
|
|
34
34
|
});
|
|
35
35
|
}
|
|
36
36
|
const { error, loaded, loading, loadcount } = data;
|
|
37
|
-
if (loaded || loading || (error && loadcount < 2)) {
|
|
37
|
+
if (p.disabled || loaded || loading || (error && loadcount < 2)) {
|
|
38
38
|
return;
|
|
39
39
|
}
|
|
40
40
|
setData((d) => (Object.assign(Object.assign({}, d), { loading: true })));
|