ag-common 0.0.181 → 0.0.184

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.
@@ -9,6 +9,16 @@ export declare const returnCode: <T>(statusCode: number, body?: T | undefined, e
9
9
  * @returns stripped record
10
10
  */
11
11
  export declare const stripPKs: <T>(record: T, keepPk?: boolean) => T;
12
+ /**
13
+ * generate dynamo PKs.
14
+ * PK = all Ls joined with #
15
+ * PK1 = L1
16
+ * PK2 = L1#L2
17
+ * PK3 = L1#L2#L3
18
+ * ...
19
+ * @param param0
20
+ * @returns
21
+ */
12
22
  export declare const generateDynamoPKS: ({ type, L1, L2, L3, L4, L5, L6, additionalPKValues, }: {
13
23
  type: string;
14
24
  L1: string;
@@ -57,6 +57,16 @@ const stripPKs = (record, keepPk = true) => {
57
57
  return rest;
58
58
  };
59
59
  exports.stripPKs = stripPKs;
60
+ /**
61
+ * generate dynamo PKs.
62
+ * PK = all Ls joined with #
63
+ * PK1 = L1
64
+ * PK2 = L1#L2
65
+ * PK3 = L1#L2#L3
66
+ * ...
67
+ * @param param0
68
+ * @returns
69
+ */
60
70
  const generateDynamoPKS = ({ type, L1, L2, L3, L4, L5, L6, additionalPKValues, }) => {
61
71
  const c = '#';
62
72
  const keys = [L1, L2, L3, L4, L5, L6].filter(array_1.notEmpty);
@@ -53,6 +53,16 @@ const setupLambda = ({ lambdaConfig, pathV, verb, seenPermissions, authorizers,
53
53
  const policies = [...(def.policies || []), ...((lp === null || lp === void 0 ? void 0 : lp.policies) || [])].filter(array_1.notEmpty);
54
54
  const layers = [...(def.layers || []), ...((lp === null || lp === void 0 ? void 0 : lp.layers) || [])].filter(array_1.notEmpty);
55
55
  const memory = (lp === null || lp === void 0 ? void 0 : lp.memory) || (def === null || def === void 0 ? void 0 : def.memory) || 128;
56
+ // null forces undefined, undefined forces 5
57
+ let reservedConcurrentExecutions = lp === null || lp === void 0 ? void 0 : lp.reservedConcurrentExecutions;
58
+ if (reservedConcurrentExecutions === undefined) {
59
+ reservedConcurrentExecutions = def === null || def === void 0 ? void 0 : def.reservedConcurrentExecutions;
60
+ }
61
+ if (reservedConcurrentExecutions === undefined) {
62
+ reservedConcurrentExecutions = 5;
63
+ }
64
+ reservedConcurrentExecutions = reservedConcurrentExecutions !== null && reservedConcurrentExecutions !== void 0 ? reservedConcurrentExecutions : undefined;
65
+ //
56
66
  const timeout = aws_cdk_lib_1.Duration.seconds((lp === null || lp === void 0 ? void 0 : lp.timeoutS) || (def === null || def === void 0 ? void 0 : def.timeoutS) || 30);
57
67
  let authorizerName = lp === null || lp === void 0 ? void 0 : lp.authorizerName;
58
68
  if (authorizerName === undefined) {
@@ -79,6 +89,7 @@ const setupLambda = ({ lambdaConfig, pathV, verb, seenPermissions, authorizers,
79
89
  authorizer,
80
90
  memory,
81
91
  timeout,
92
+ reservedConcurrentExecutions,
82
93
  };
83
94
  };
84
95
  const addApiPaths = (api, pathList, apiRoots) => {
@@ -133,7 +144,7 @@ const openApiImpl = (p) => {
133
144
  bundling: {
134
145
  externalModules: ['aws-sdk', 'aws-lambda'],
135
146
  },
136
- reservedConcurrentExecutions: 5,
147
+ reservedConcurrentExecutions: lc.reservedConcurrentExecutions,
137
148
  logRetention: aws_cdk_lib_1.aws_logs.RetentionDays.FIVE_DAYS,
138
149
  layers: lc.layers,
139
150
  });
@@ -37,6 +37,10 @@ export interface ILambdaConfig {
37
37
  * lambda memory. defaults to 128
38
38
  */
39
39
  memory?: number;
40
+ /**
41
+ * reserved lambda concurrency. defaults to 5. if null, doesnt apply
42
+ */
43
+ reservedConcurrentExecutions?: number | null;
40
44
  }
41
45
  /**
42
46
  * 'default' will be applied to all functions
@@ -46,13 +50,14 @@ export interface ILambdaConfigs {
46
50
  default?: ILambdaConfig;
47
51
  };
48
52
  }
53
+ export declare type TSkOperator = 'BETWEEN' | '<' | '<=' | '=' | '>=' | '>';
49
54
  export interface IQueryDynamo {
50
55
  pkName: string;
51
56
  pkValue: string | number;
52
57
  pkOperator?: string;
53
58
  skName?: string;
54
59
  skValue?: string | number | string[] | number[];
55
- skOperator?: string;
60
+ skOperator?: TSkOperator;
56
61
  tableName: string;
57
62
  indexName?: string;
58
63
  count?: number;
@@ -3,7 +3,10 @@ export declare const LoginButton: ({ className, text, invert, savePath, loginPat
3
3
  invert?: boolean | undefined;
4
4
  text: string;
5
5
  className?: string | undefined;
6
- savePath?: boolean | undefined;
6
+ /**
7
+ * pass in request.url.path to save redirect. undefined will not set redirect
8
+ */
9
+ savePath: string | undefined;
7
10
  loginPath: (state?: Record<string, unknown> | undefined) => string;
8
11
  style?: Record<string, string | number | boolean> | undefined;
9
12
  }) => JSX.Element;
@@ -10,12 +10,13 @@ const styled_components_1 = __importDefault(require("styled-components"));
10
10
  const Base = styled_components_1.default.a `
11
11
  ${Button_1.ButtonBase}
12
12
  `;
13
- const LoginButton = ({ className, text, invert, savePath = true, loginPath, style, }) => {
14
- const lp = loginPath(!savePath || typeof window === 'undefined'
13
+ const LoginButton = ({ className, text, invert, savePath, loginPath, style, }) => {
14
+ const state = !savePath
15
15
  ? undefined
16
16
  : {
17
- redirect: window.location.href.substring(window.location.origin.length),
18
- });
17
+ redirect: savePath,
18
+ };
19
+ const lp = loginPath(state);
19
20
  return (react_1.default.createElement(Base, { style: style, href: lp, title: text, "data-invert": invert, "data-disabled": false, className: className }, text));
20
21
  };
21
22
  exports.LoginButton = LoginButton;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ag-common",
3
- "version": "0.0.181",
3
+ "version": "0.0.184",
4
4
  "main": "./dist/index.js",
5
5
  "types": "./dist/index.d.ts",
6
6
  "author": "Andrei Gec <@andreigec> (https://gec.dev/)",
@@ -15,7 +15,7 @@
15
15
  },
16
16
  "dependencies": {
17
17
  "aws-cdk-lib": "2.x",
18
- "aws-sdk": "2.1095.0",
18
+ "aws-sdk": "2.1096.0",
19
19
  "axios": "0.26.1",
20
20
  "constructs": "10.x",
21
21
  "jsonwebtoken": "8.5.1",
@@ -31,13 +31,13 @@
31
31
  "devDependencies": {
32
32
  "@types/jsonwebtoken": "8.5.8",
33
33
  "@types/node": "17.0.21",
34
- "@types/react": "17.0.40",
35
- "@types/react-dom": "17.0.13",
34
+ "@types/react": "17.0.41",
35
+ "@types/react-dom": "17.0.14",
36
36
  "@types/styled-components": "5.1.24",
37
37
  "@typescript-eslint/eslint-plugin": "5.15.0",
38
38
  "@typescript-eslint/parser": "5.15.0",
39
39
  "eslint": "8.11.0",
40
- "eslint-config-airbnb-typescript": "16.1.3",
40
+ "eslint-config-airbnb-typescript": "16.1.4",
41
41
  "eslint-config-prettier": "8.5.0",
42
42
  "eslint-config-react-app": "7.0.0",
43
43
  "eslint-plugin-import": "2.25.4",