ag-common 0.0.742 → 0.0.744

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.
@@ -0,0 +1,22 @@
1
+ import type { Stack } from 'aws-cdk-lib';
2
+ import { aws_iam as iam } from 'aws-cdk-lib';
3
+ import type { IWebSocketApi, WebSocketStage } from 'aws-cdk-lib/aws-apigatewayv2';
4
+ import { WebSocketApi } from 'aws-cdk-lib/aws-apigatewayv2';
5
+ import type { IUser } from 'aws-cdk-lib/aws-iam';
6
+ export declare const generateApigwRef: ({ stack, baseKey, }: {
7
+ stack: Stack;
8
+ baseKey: string;
9
+ }) => {
10
+ api: IWebSocketApi;
11
+ stageName: string;
12
+ };
13
+ export declare const generateApigwSSMParams: ({ stack, api, baseKey, stage, }: {
14
+ stack: Stack;
15
+ api: WebSocketApi;
16
+ baseKey: string;
17
+ stage: WebSocketStage;
18
+ }) => void;
19
+ export declare function grantWebSocketManageConnectionsToUser(stack: Stack, apiGw: IWebSocketApi, stage: string, user: IUser): void;
20
+ export declare function grantWebSocketManageConnectionsToRole(stack: Stack, apiGw: IWebSocketApi, stage: string, ref: {
21
+ addToRolePolicy: (statement: iam.PolicyStatement) => void;
22
+ }): void;
@@ -0,0 +1,46 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.generateApigwSSMParams = exports.generateApigwRef = void 0;
4
+ exports.grantWebSocketManageConnectionsToUser = grantWebSocketManageConnectionsToUser;
5
+ exports.grantWebSocketManageConnectionsToRole = grantWebSocketManageConnectionsToRole;
6
+ const aws_cdk_lib_1 = require("aws-cdk-lib");
7
+ const aws_apigatewayv2_1 = require("aws-cdk-lib/aws-apigatewayv2");
8
+ const ssm_1 = require("../ssm");
9
+ const generateApigwRef = ({ stack, baseKey, }) => {
10
+ const webSocketId = (0, ssm_1.loadSsmString)({ stack, path: `${baseKey}/id` });
11
+ const apiEndpoint = (0, ssm_1.loadSsmString)({ stack, path: `${baseKey}/endpoint` });
12
+ const stageName = (0, ssm_1.loadSsmString)({ stack, path: `${baseKey}/stage` });
13
+ const api = aws_apigatewayv2_1.WebSocketApi.fromWebSocketApiAttributes(stack, baseKey, {
14
+ webSocketId,
15
+ apiEndpoint,
16
+ });
17
+ return { api, stageName };
18
+ };
19
+ exports.generateApigwRef = generateApigwRef;
20
+ const generateApigwSSMParams = ({ stack, api, baseKey, stage, }) => {
21
+ (0, ssm_1.saveToSsm)({ stack, path: `${baseKey}/id`, value: api.apiId });
22
+ (0, ssm_1.saveToSsm)({ stack, path: `${baseKey}/endpoint`, value: api.apiEndpoint });
23
+ (0, ssm_1.saveToSsm)({ stack, path: `${baseKey}/stage`, value: stage.stageName });
24
+ };
25
+ exports.generateApigwSSMParams = generateApigwSSMParams;
26
+ function grantWebSocketManageConnectionsToUser(stack, apiGw, stage, user) {
27
+ const statement = new aws_cdk_lib_1.aws_iam.PolicyStatement({
28
+ actions: ['execute-api:ManageConnections'],
29
+ resources: [
30
+ `arn:aws:execute-api:${stack.region}:${stack.account}:${apiGw.apiId}/${stage}/*`,
31
+ ],
32
+ });
33
+ const policy = new aws_cdk_lib_1.aws_iam.ManagedPolicy(stack, 'WebSocketConnectionPolicy', {
34
+ statements: [statement],
35
+ });
36
+ user.addManagedPolicy(policy);
37
+ }
38
+ function grantWebSocketManageConnectionsToRole(stack, apiGw, stage, ref) {
39
+ const statement = new aws_cdk_lib_1.aws_iam.PolicyStatement({
40
+ actions: ['execute-api:ManageConnections'],
41
+ resources: [
42
+ `arn:aws:execute-api:${stack.region}:${stack.account}:${apiGw.apiId}/${stage}/*`,
43
+ ],
44
+ });
45
+ ref.addToRolePolicy(statement);
46
+ }
@@ -1,3 +1,4 @@
1
+ export * from './apigw';
1
2
  export * from './dynamo';
2
3
  export * from './s3';
3
4
  export * from './sqs';
@@ -14,6 +14,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
14
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./apigw"), exports);
17
18
  __exportStar(require("./dynamo"), exports);
18
19
  __exportStar(require("./s3"), exports);
19
20
  __exportStar(require("./sqs"), exports);
@@ -21,6 +21,7 @@ const BarChartBase = styled_1.default.div `
21
21
  `;
22
22
  const ItemStyled = (0, styled_1.default)(Item_1.Item) `
23
23
  margin-bottom: 0.75rem;
24
+ height: auto;
24
25
 
25
26
  &:last-of-type {
26
27
  margin-bottom: 0;
package/package.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "0.0.742",
2
+ "version": "0.0.744",
3
3
  "name": "ag-common",
4
4
  "main": "./dist/index.js",
5
5
  "types": "./dist/index.d.ts",