ag-common 0.0.476 → 0.0.477
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/api/helpers/enforceDynamoProvisionCap.js +3 -3
- package/dist/api/helpers/openApiHelpers.js +8 -8
- package/dist/api/helpers/s3.d.ts +1 -1
- package/dist/api/helpers/sqs.js +2 -2
- package/dist/api/helpers/validateOpenApi.js +7 -7
- package/dist/api/types/aws.d.ts +1 -1
- package/dist/common/helpers/binary.d.ts +1 -0
- package/dist/common/helpers/binary.js +2 -1
- package/dist/common/helpers/log.js +1 -1
- package/dist/common/helpers/random.js +2 -2
- package/dist/common/helpers/string/base64.js +3 -2
- package/dist/ui/components/Button/index.js +2 -2
- package/dist/ui/components/OpenApiCodeBlock/curl/helpers/body.js +2 -1
- package/dist/ui/components/OpenApiCodeBlock/curl/index.js +1 -1
- package/dist/ui/components/OpenApiCodeBlock/fetch/helpers/req.js +2 -1
- package/dist/ui/components/TextEdit/TextEdit.js +3 -4
- package/dist/ui/components/Toast/base.js +1 -1
- package/dist/ui/helpers/callOpenApi/cached.js +6 -5
- package/dist/ui/helpers/callOpenApi/direct.js +1 -1
- package/dist/ui/helpers/date.js +1 -1
- package/dist/ui/helpers/jwt.d.ts +3 -3
- package/dist/ui/helpers/useOnScroll.js +4 -2
- package/dist/ui/helpers/useQueryString.js +1 -1
- package/package.json +14 -13
|
@@ -6,9 +6,9 @@ const math_1 = require("../../common/helpers/math");
|
|
|
6
6
|
const json_1 = require("../../common/helpers/string/json");
|
|
7
7
|
const trim_1 = require("../../common/helpers/string/trim");
|
|
8
8
|
const extractSum = ({ str, regex }) => {
|
|
9
|
-
var _a;
|
|
10
|
-
return (0, math_1.sumArray)(((_a = str
|
|
11
|
-
.match(regex)) === null || _a === void 0 ? void 0 : _a.map((s2) => (0, trim_1.trim)(s2.substring(s2.indexOf(':') + 1), ':', ',', ' ')).filter((r) => r && Number(r)).map((r) => Number(r)))
|
|
9
|
+
var _a, _b;
|
|
10
|
+
return (0, math_1.sumArray)((_b = (_a = str
|
|
11
|
+
.match(regex)) === null || _a === void 0 ? void 0 : _a.map((s2) => (0, trim_1.trim)(s2.substring(s2.indexOf(':') + 1), ':', ',', ' ')).filter((r) => r && Number(r)).map((r) => Number(r))) !== null && _b !== void 0 ? _b : []);
|
|
12
12
|
};
|
|
13
13
|
/** ensure that dynamo tables in stack dont exceed passed in provisioned limits */
|
|
14
14
|
const enforceDynamoProvisionCap = ({ tables, readsMax = 25, writesMax = 25, mustEqual = false, }) => {
|
|
@@ -37,7 +37,7 @@ const setUpApiGw = ({ stack, NODE_ENV, certificate, shortStackName, r53, cors =
|
|
|
37
37
|
return api;
|
|
38
38
|
};
|
|
39
39
|
const setupLambda = ({ lambdaConfig, pathV, verb, seenPermissions, authorizers, }) => {
|
|
40
|
-
var _a, _b, _c, _d;
|
|
40
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t;
|
|
41
41
|
const pathCompute = pathV + '/' + verb;
|
|
42
42
|
const lp = lambdaConfig === null || lambdaConfig === void 0 ? void 0 : lambdaConfig[pathCompute];
|
|
43
43
|
if (lp) {
|
|
@@ -51,11 +51,11 @@ const setupLambda = ({ lambdaConfig, pathV, verb, seenPermissions, authorizers,
|
|
|
51
51
|
seenPermissions.default = true;
|
|
52
52
|
}
|
|
53
53
|
//
|
|
54
|
-
const readTables = (0, array_1.distinctBy)([...(((_a = def === null || def === void 0 ? void 0 : def.dynamo) === null || _a === void 0 ? void 0 : _a.reads)
|
|
55
|
-
const writeTables = (0, array_1.distinctBy)([...(((
|
|
56
|
-
const policies = [...(def.policies
|
|
57
|
-
const layers = [...(def.layers
|
|
58
|
-
const memory = (lp === null || lp === void 0 ? void 0 : lp.memory)
|
|
54
|
+
const readTables = (0, array_1.distinctBy)([...((_b = (_a = def === null || def === void 0 ? void 0 : def.dynamo) === null || _a === void 0 ? void 0 : _a.reads) !== null && _b !== void 0 ? _b : []), ...((_d = (_c = lp === null || lp === void 0 ? void 0 : lp.dynamo) === null || _c === void 0 ? void 0 : _c.reads) !== null && _d !== void 0 ? _d : [])], (s) => s.tableName);
|
|
55
|
+
const writeTables = (0, array_1.distinctBy)([...((_f = (_e = def === null || def === void 0 ? void 0 : def.dynamo) === null || _e === void 0 ? void 0 : _e.writes) !== null && _f !== void 0 ? _f : []), ...((_h = (_g = lp === null || lp === void 0 ? void 0 : lp.dynamo) === null || _g === void 0 ? void 0 : _g.writes) !== null && _h !== void 0 ? _h : [])], (s) => s.tableName);
|
|
56
|
+
const policies = [...((_j = def.policies) !== null && _j !== void 0 ? _j : []), ...((_k = lp === null || lp === void 0 ? void 0 : lp.policies) !== null && _k !== void 0 ? _k : [])].filter(array_1.notEmpty);
|
|
57
|
+
const layers = [...((_l = def.layers) !== null && _l !== void 0 ? _l : []), ...((_m = lp === null || lp === void 0 ? void 0 : lp.layers) !== null && _m !== void 0 ? _m : [])].filter(array_1.notEmpty);
|
|
58
|
+
const memory = (_p = (_o = lp === null || lp === void 0 ? void 0 : lp.memory) !== null && _o !== void 0 ? _o : def === null || def === void 0 ? void 0 : def.memory) !== null && _p !== void 0 ? _p : 128;
|
|
59
59
|
// null forces undefined, undefined forces 5
|
|
60
60
|
let reservedConcurrentExecutions = lp === null || lp === void 0 ? void 0 : lp.reservedConcurrentExecutions;
|
|
61
61
|
if (reservedConcurrentExecutions === undefined) {
|
|
@@ -66,7 +66,7 @@ const setupLambda = ({ lambdaConfig, pathV, verb, seenPermissions, authorizers,
|
|
|
66
66
|
}
|
|
67
67
|
reservedConcurrentExecutions = reservedConcurrentExecutions !== null && reservedConcurrentExecutions !== void 0 ? reservedConcurrentExecutions : undefined;
|
|
68
68
|
//
|
|
69
|
-
const timeout = aws_cdk_lib_1.Duration.seconds((lp === null || lp === void 0 ? void 0 : lp.timeoutS)
|
|
69
|
+
const timeout = aws_cdk_lib_1.Duration.seconds((_r = (_q = lp === null || lp === void 0 ? void 0 : lp.timeoutS) !== null && _q !== void 0 ? _q : def === null || def === void 0 ? void 0 : def.timeoutS) !== null && _r !== void 0 ? _r : 30);
|
|
70
70
|
let authorizerName = lp === null || lp === void 0 ? void 0 : lp.authorizerName;
|
|
71
71
|
if (authorizerName === undefined) {
|
|
72
72
|
authorizerName = def.authorizerName;
|
|
@@ -77,7 +77,7 @@ const setupLambda = ({ lambdaConfig, pathV, verb, seenPermissions, authorizers,
|
|
|
77
77
|
const authorizer = !authorizerName
|
|
78
78
|
? undefined
|
|
79
79
|
: authorizers === null || authorizers === void 0 ? void 0 : authorizers[authorizerName];
|
|
80
|
-
const env = Object.assign(Object.assign({}, (def.env
|
|
80
|
+
const env = Object.assign(Object.assign({}, ((_s = def.env) !== null && _s !== void 0 ? _s : {})), ((_t = lp === null || lp === void 0 ? void 0 : lp.env) !== null && _t !== void 0 ? _t : {}));
|
|
81
81
|
const environment = env;
|
|
82
82
|
return {
|
|
83
83
|
environment,
|
package/dist/api/helpers/s3.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
/// <reference types="node" />
|
|
2
1
|
import { S3Client } from '@aws-sdk/client-s3';
|
|
3
2
|
import type { StreamingBlobPayloadOutputTypes } from '@smithy/types';
|
|
3
|
+
import type { Buffer } from 'buffer';
|
|
4
4
|
import { error } from '../../common/helpers/log';
|
|
5
5
|
export declare const setS3: (region: string) => S3Client;
|
|
6
6
|
export declare const s3: S3Client;
|
package/dist/api/helpers/sqs.js
CHANGED
|
@@ -19,7 +19,7 @@ const setSqs = (region) => {
|
|
|
19
19
|
exports.setSqs = setSqs;
|
|
20
20
|
exports.sqs = (0, exports.setSqs)('ap-southeast-2');
|
|
21
21
|
const sendMessages = (items, queueUrl) => __awaiter(void 0, void 0, void 0, function* () {
|
|
22
|
-
var _a;
|
|
22
|
+
var _a, _b;
|
|
23
23
|
const p = yield exports.sqs.send(new client_sqs_1.SendMessageBatchCommand({
|
|
24
24
|
QueueUrl: queueUrl,
|
|
25
25
|
Entries: items.map((i) => ({
|
|
@@ -28,7 +28,7 @@ const sendMessages = (items, queueUrl) => __awaiter(void 0, void 0, void 0, func
|
|
|
28
28
|
})),
|
|
29
29
|
}));
|
|
30
30
|
if (((_a = p.Failed) !== null && _a !== void 0 ? _a : []).length > 0) {
|
|
31
|
-
return { error: `failed: ${JSON.stringify(p.Failed
|
|
31
|
+
return { error: `failed: ${JSON.stringify((_b = p.Failed) !== null && _b !== void 0 ? _b : [], null, 2)}` };
|
|
32
32
|
}
|
|
33
33
|
return {};
|
|
34
34
|
});
|
|
@@ -44,7 +44,7 @@ const getOperation = ({ path, method, resource, schema, }) => {
|
|
|
44
44
|
return { operation, pathParams };
|
|
45
45
|
};
|
|
46
46
|
function validateOpenApi({ event, next, authorized, schema, COGNITO_USER_POOL_ID, jwksRegion = 'ap-southeast-2', getAndValidateTokenOverride, }) {
|
|
47
|
-
var _a, _b, _c, _d, _e, _f, _g;
|
|
47
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j;
|
|
48
48
|
return __awaiter(this, void 0, void 0, function* () {
|
|
49
49
|
if (!schema) {
|
|
50
50
|
throw new Error('schema undefined!');
|
|
@@ -62,8 +62,8 @@ function validateOpenApi({ event, next, authorized, schema, COGNITO_USER_POOL_ID
|
|
|
62
62
|
headers: (0, object_1.objectKeysToLowerCase)(event === null || event === void 0 ? void 0 : event.headers),
|
|
63
63
|
};
|
|
64
64
|
const method = event.requestContext.httpMethod.toLowerCase();
|
|
65
|
-
const pathParameters = event.pathParameters
|
|
66
|
-
const queryStringParameters = event.queryStringParameters
|
|
65
|
+
const pathParameters = (_a = event.pathParameters) !== null && _a !== void 0 ? _a : {};
|
|
66
|
+
const queryStringParameters = (_b = event.queryStringParameters) !== null && _b !== void 0 ? _b : {};
|
|
67
67
|
//
|
|
68
68
|
const opm = getOperation({
|
|
69
69
|
path: event.path,
|
|
@@ -86,7 +86,7 @@ function validateOpenApi({ event, next, authorized, schema, COGNITO_USER_POOL_ID
|
|
|
86
86
|
else {
|
|
87
87
|
try {
|
|
88
88
|
request.params = opm.pathParams;
|
|
89
|
-
(0, log_1.info)('req=', JSON.stringify(Object.assign(Object.assign({}, request), { body: ((
|
|
89
|
+
(0, log_1.info)('req=', JSON.stringify(Object.assign(Object.assign({}, request), { body: ((_d = (_c = request.body) === null || _c === void 0 ? void 0 : _c.length) !== null && _d !== void 0 ? _d : 0) > 2000
|
|
90
90
|
? '(truncating long body)'
|
|
91
91
|
: request.body }), null, 2));
|
|
92
92
|
const resp = new openapi_request_validator_1.default(Object.assign(Object.assign({}, opm.operation), { schemas: schema.components.schemas })).validateRequest(request);
|
|
@@ -94,7 +94,7 @@ function validateOpenApi({ event, next, authorized, schema, COGNITO_USER_POOL_ID
|
|
|
94
94
|
(0, log_1.warn)('bad request');
|
|
95
95
|
(0, log_1.warn)('opm=', JSON.stringify(opm, null, 2));
|
|
96
96
|
(0, log_1.warn)('resp=', JSON.stringify(resp, null, 2));
|
|
97
|
-
return (0, api_1.returnCode)(400, `error:${(
|
|
97
|
+
return (0, api_1.returnCode)(400, `error:${(_f = (_e = resp === null || resp === void 0 ? void 0 : resp.errors) === null || _e === void 0 ? void 0 : _e[0]) === null || _f === void 0 ? void 0 : _f.message}`);
|
|
98
98
|
}
|
|
99
99
|
(0, log_1.debug)(`validated request:`, event.path);
|
|
100
100
|
}
|
|
@@ -104,7 +104,7 @@ function validateOpenApi({ event, next, authorized, schema, COGNITO_USER_POOL_ID
|
|
|
104
104
|
}
|
|
105
105
|
let userProfile;
|
|
106
106
|
let error;
|
|
107
|
-
const authHeader = ((
|
|
107
|
+
const authHeader = ((_g = event.headers) === null || _g === void 0 ? void 0 : _g.Authorization) || ((_h = event.headers) === null || _h === void 0 ? void 0 : _h.authorization);
|
|
108
108
|
if (authorized === true || (authorized === 'optional' && authHeader)) {
|
|
109
109
|
const vf = getAndValidateTokenOverride !== null && getAndValidateTokenOverride !== void 0 ? getAndValidateTokenOverride : validations_1.getAndValidateToken;
|
|
110
110
|
({ error, userProfile } = yield vf({
|
|
@@ -122,7 +122,7 @@ function validateOpenApi({ event, next, authorized, schema, COGNITO_USER_POOL_ID
|
|
|
122
122
|
event,
|
|
123
123
|
body: (0, object_1.tryJsonParse)(event.body, event.body),
|
|
124
124
|
userProfile,
|
|
125
|
-
lang: (0, i18n_1.getValidatedLang)((
|
|
125
|
+
lang: (0, i18n_1.getValidatedLang)((_j = event.headers['x-lang']) !== null && _j !== void 0 ? _j : ''),
|
|
126
126
|
});
|
|
127
127
|
return res;
|
|
128
128
|
});
|
package/dist/api/types/aws.d.ts
CHANGED
|
@@ -5,7 +5,7 @@ export interface APIGatewayProxyResult {
|
|
|
5
5
|
[header: string]: boolean | number | string;
|
|
6
6
|
} | undefined;
|
|
7
7
|
multiValueHeaders?: {
|
|
8
|
-
[header: string]:
|
|
8
|
+
[header: string]: (boolean | number | string)[];
|
|
9
9
|
} | undefined;
|
|
10
10
|
body: string;
|
|
11
11
|
isBase64Encoded?: boolean | undefined;
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.base64ToBinary = exports.arrayBufferToBase64 = exports.toBuffer = void 0;
|
|
4
|
+
const buffer_1 = require("buffer");
|
|
4
5
|
const base64_1 = require("./string/base64");
|
|
5
|
-
const toBuffer = (ab) => Buffer.from(ab);
|
|
6
|
+
const toBuffer = (ab) => buffer_1.Buffer.from(ab);
|
|
6
7
|
exports.toBuffer = toBuffer;
|
|
7
8
|
function toArrayBuffer(base64) {
|
|
8
9
|
const binary_string = (0, base64_1.fromBase64)(base64);
|
|
@@ -24,7 +24,7 @@ function logprocess(type, args) {
|
|
|
24
24
|
if (!userLogLevel) {
|
|
25
25
|
(0, exports.SetLogLevel)(process.env.LOG_LEVEL);
|
|
26
26
|
}
|
|
27
|
-
const min = (0, exports.GetLogLevel)(userLogLevel
|
|
27
|
+
const min = (0, exports.GetLogLevel)(userLogLevel !== null && userLogLevel !== void 0 ? userLogLevel : 'WARN');
|
|
28
28
|
const typesLogLevel = (0, exports.GetLogLevel)(type);
|
|
29
29
|
// env ignores it
|
|
30
30
|
if (typesLogLevel < min) {
|
|
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.shuffle = exports.randomDecimal = exports.random = void 0;
|
|
4
4
|
/** random number up to max. seed defaults to now.getTime() */
|
|
5
5
|
function random(max, seed) {
|
|
6
|
-
seed = seed
|
|
6
|
+
seed = seed !== null && seed !== void 0 ? seed : new Date().getTime();
|
|
7
7
|
const ret = (seed * 9301 + 49297) % 233280;
|
|
8
8
|
const rnd = ret / 233280;
|
|
9
9
|
return Math.ceil(rnd * max);
|
|
@@ -11,7 +11,7 @@ function random(max, seed) {
|
|
|
11
11
|
exports.random = random;
|
|
12
12
|
/** between 0 and 1. seed defaults to now.getTime() */
|
|
13
13
|
const randomDecimal = function (seed) {
|
|
14
|
-
seed = seed
|
|
14
|
+
seed = seed !== null && seed !== void 0 ? seed : new Date().getTime();
|
|
15
15
|
const x = Math.sin((seed += 1)) * 10000;
|
|
16
16
|
return x - Math.floor(x);
|
|
17
17
|
};
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.fromBase64 = exports.toBase64 = void 0;
|
|
4
|
-
const
|
|
4
|
+
const buffer_1 = require("buffer");
|
|
5
|
+
const toBase64 = (str) => buffer_1.Buffer.from(str).toString('base64');
|
|
5
6
|
exports.toBase64 = toBase64;
|
|
6
|
-
const fromBase64 = (str) => Buffer.from(decodeURIComponent(str), 'base64').toString();
|
|
7
|
+
const fromBase64 = (str) => buffer_1.Buffer.from(decodeURIComponent(str), 'base64').toString();
|
|
7
8
|
exports.fromBase64 = fromBase64;
|
|
@@ -59,12 +59,12 @@ const BaseA = styled_1.default.a `
|
|
|
59
59
|
${exports.ButtonBase}
|
|
60
60
|
`;
|
|
61
61
|
const Button = (props) => {
|
|
62
|
-
var _a;
|
|
62
|
+
var _a, _b;
|
|
63
63
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
64
64
|
const Component = props.href
|
|
65
65
|
? // eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
66
66
|
BaseA
|
|
67
67
|
: BaseButton;
|
|
68
|
-
return (react_2.default.createElement(Component, Object.assign({ className: props.className, "data-invert": props.invert, "data-disabled": (_a = props.disabled) !== null && _a !== void 0 ? _a : false, role: "button", title: props.title || undefined, "data-theme": props.colourTheme
|
|
68
|
+
return (react_2.default.createElement(Component, Object.assign({ className: props.className, "data-invert": props.invert, "data-disabled": (_a = props.disabled) !== null && _a !== void 0 ? _a : false, role: "button", title: props.title || undefined, "data-theme": (_b = props.colourTheme) !== null && _b !== void 0 ? _b : 'green' }, props), props.children));
|
|
69
69
|
};
|
|
70
70
|
exports.Button = Button;
|
|
@@ -7,7 +7,8 @@ exports.getBody = void 0;
|
|
|
7
7
|
const react_1 = __importDefault(require("react"));
|
|
8
8
|
const common_1 = require("../../helpers/common");
|
|
9
9
|
const getBody = (p) => {
|
|
10
|
-
|
|
10
|
+
var _a;
|
|
11
|
+
const { nice } = (_a = (0, common_1.getBodyJson)(p)) !== null && _a !== void 0 ? _a : {};
|
|
11
12
|
if (!nice) {
|
|
12
13
|
return { content: undefined, header: undefined };
|
|
13
14
|
}
|
|
@@ -26,7 +26,7 @@ const Curl = ({ ops, p, }) => {
|
|
|
26
26
|
"'",
|
|
27
27
|
fullApiUrl,
|
|
28
28
|
"'")),
|
|
29
|
-
...(headerLines
|
|
29
|
+
...(headerLines !== null && headerLines !== void 0 ? headerLines : []),
|
|
30
30
|
bodyLine,
|
|
31
31
|
].filter(array_1.notEmpty);
|
|
32
32
|
return react_1.default.createElement(Base, null, (0, joinJsx_1.joinJsxWithSlash)(rows));
|
|
@@ -14,7 +14,8 @@ const Lpad = styled_1.default.div `
|
|
|
14
14
|
padding-left: 0.5rem;
|
|
15
15
|
`;
|
|
16
16
|
const getRequestOptions = (p, ops) => {
|
|
17
|
-
|
|
17
|
+
var _a;
|
|
18
|
+
const { nice } = (_a = (0, common_1.getBodyJson)(p)) !== null && _a !== void 0 ? _a : {};
|
|
18
19
|
if (!nice) {
|
|
19
20
|
return undefined;
|
|
20
21
|
}
|
|
@@ -90,6 +90,7 @@ const Icon = styled_1.default.div `
|
|
|
90
90
|
}
|
|
91
91
|
`;
|
|
92
92
|
exports.TextEdit = (0, react_2.forwardRef)((p, ref) => {
|
|
93
|
+
var _a, _b;
|
|
93
94
|
const { defaultValue = '', defaultEditing, disableEdit = false, singleLine = false, noGrow = false, allowUndo = true, } = p;
|
|
94
95
|
const divRef = (0, react_2.useRef)(null);
|
|
95
96
|
const taref = (0, react_2.useRef)(null);
|
|
@@ -137,8 +138,7 @@ exports.TextEdit = (0, react_2.forwardRef)((p, ref) => {
|
|
|
137
138
|
}
|
|
138
139
|
}, [defaultEditing === null || defaultEditing === void 0 ? void 0 : defaultEditing.focus]);
|
|
139
140
|
if (!editing || disableEdit) {
|
|
140
|
-
return (react_2.default.createElement(common_2.ValueBox, Object.assign({}, common_1.noDrag, { className: p.className, "data-editing": "false", onClick: () => { var _a; return (_a = p.onClickNotEditing) === null || _a === void 0 ? void 0 : _a.call(p); }, "data-pointer": p.onClickNotEditing ? 'true' : 'false', "data-nogrow": noGrow }, (0, dom_1.filterDataProps)(p)),
|
|
141
|
-
p.leftContent || null,
|
|
141
|
+
return (react_2.default.createElement(common_2.ValueBox, Object.assign({}, common_1.noDrag, { className: p.className, "data-editing": "false", onClick: () => { var _a; return (_a = p.onClickNotEditing) === null || _a === void 0 ? void 0 : _a.call(p); }, "data-pointer": p.onClickNotEditing ? 'true' : 'false', "data-nogrow": noGrow }, (0, dom_1.filterDataProps)(p)), (_a = p.leftContent) !== null && _a !== void 0 ? _a : null,
|
|
142
142
|
react_2.default.createElement(exports.ValueReadonly, { "data-type": "text" }, value || react_2.default.createElement("span", { style: { color: '#ccc' } }, p.placeholder)),
|
|
143
143
|
react_2.default.createElement(Right, null, !disableEdit && (react_2.default.createElement(Icon, { style: common_2.iconRight, onClick: (e) => {
|
|
144
144
|
e.stopPropagation();
|
|
@@ -150,8 +150,7 @@ exports.TextEdit = (0, react_2.forwardRef)((p, ref) => {
|
|
|
150
150
|
const Comp = !singleLine ? ValueTextArea : ValueTextBox;
|
|
151
151
|
return (react_2.default.createElement(ValueBoxEdit, Object.assign({}, common_1.noDrag, { className: p.className, "data-editing": "true",
|
|
152
152
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
153
|
-
ref: ref, tabIndex: -1, "data-nogrow": noGrow }, (0, dom_1.filterDataProps)(p)),
|
|
154
|
-
p.leftContent || null,
|
|
153
|
+
ref: ref, tabIndex: -1, "data-nogrow": noGrow }, (0, dom_1.filterDataProps)(p)), (_b = p.leftContent) !== null && _b !== void 0 ? _b : null,
|
|
155
154
|
react_2.default.createElement(Comp, { tabIndex: editing ? 0 : undefined, "data-editing": "true", "data-valuechange": valueChange.toString(),
|
|
156
155
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
157
156
|
ref: taref, "data-type": "text", value: value, onChange: (v) => {
|
|
@@ -144,6 +144,6 @@ const ToastProvider = ({ children, providerOptions, }) => {
|
|
|
144
144
|
const contextValue = (0, react_1.useMemo)(() => ({ addToast }), []);
|
|
145
145
|
return (react_1.default.createElement(exports.ToastContext.Provider, { value: contextValue },
|
|
146
146
|
children,
|
|
147
|
-
react_1.default.createElement(ToastContainerStyle, null, toasts.map((toast) => (react_1.default.createElement(exports.Toast, { key: toast.id, toast: toast, close: close, providerOptions: providerOptions
|
|
147
|
+
react_1.default.createElement(ToastContainerStyle, null, toasts.map((toast) => (react_1.default.createElement(exports.Toast, { key: toast.id, toast: toast, close: close, providerOptions: providerOptions !== null && providerOptions !== void 0 ? providerOptions : {} }))))));
|
|
148
148
|
};
|
|
149
149
|
exports.ToastProvider = ToastProvider;
|
|
@@ -38,12 +38,13 @@ function getCacheKey({ cacheKey, overrideAuth, ssrCacheItems, }) {
|
|
|
38
38
|
return cacheKeyRet;
|
|
39
39
|
}
|
|
40
40
|
const setOpenApiCacheRaw = (p, data) => __awaiter(void 0, void 0, void 0, function* () {
|
|
41
|
+
var _a;
|
|
41
42
|
const userPrefixedCacheKey = getCacheKey(p);
|
|
42
43
|
if (!userPrefixedCacheKey) {
|
|
43
44
|
return;
|
|
44
45
|
}
|
|
45
46
|
if (!callOpenApiCache) {
|
|
46
|
-
callOpenApiCache = new node_cache_1.default({ stdTTL: p.cacheTtl
|
|
47
|
+
callOpenApiCache = new node_cache_1.default({ stdTTL: (_a = p.cacheTtl) !== null && _a !== void 0 ? _a : 120 });
|
|
47
48
|
}
|
|
48
49
|
callOpenApiCache.set(userPrefixedCacheKey, data);
|
|
49
50
|
});
|
|
@@ -54,22 +55,22 @@ exports.setOpenApiCacheRaw = setOpenApiCacheRaw;
|
|
|
54
55
|
* @returns undefined if no cache item
|
|
55
56
|
*/
|
|
56
57
|
const callOpenApiCachedRaw = (p) => {
|
|
57
|
-
var _a, _b, _c;
|
|
58
|
+
var _a, _b, _c, _d, _e;
|
|
58
59
|
const userPrefixedCacheKey = getCacheKey(p);
|
|
59
60
|
if (!userPrefixedCacheKey) {
|
|
60
61
|
return undefined;
|
|
61
62
|
}
|
|
62
63
|
if (!callOpenApiCache) {
|
|
63
|
-
callOpenApiCache = new node_cache_1.default({ stdTTL: p.cacheTtl
|
|
64
|
+
callOpenApiCache = new node_cache_1.default({ stdTTL: (_a = p.cacheTtl) !== null && _a !== void 0 ? _a : 120 });
|
|
64
65
|
}
|
|
65
66
|
//get ssr cache value
|
|
66
|
-
const ssrCached = (
|
|
67
|
+
const ssrCached = (_d = (_c = (_b = p.ssrCacheItems) === null || _b === void 0 ? void 0 : _b.find((s) => s.cacheKey === p.cacheKey)) === null || _c === void 0 ? void 0 : _c.prefillData) === null || _d === void 0 ? void 0 : _d.data;
|
|
67
68
|
//if we have ssr cache and there is no existing cache then set
|
|
68
69
|
if (!callOpenApiCache.get(userPrefixedCacheKey) && ssrCached) {
|
|
69
70
|
callOpenApiCache.set(userPrefixedCacheKey, ssrCached);
|
|
70
71
|
}
|
|
71
72
|
//return cached data, or ssr data if that has already expired (ttl <=0)
|
|
72
|
-
const data = callOpenApiCache.get(userPrefixedCacheKey)
|
|
73
|
+
const data = (_e = callOpenApiCache.get(userPrefixedCacheKey)) !== null && _e !== void 0 ? _e : ssrCached;
|
|
73
74
|
if (!data) {
|
|
74
75
|
return undefined;
|
|
75
76
|
}
|
|
@@ -65,7 +65,7 @@ const callOpenApi = (p) => __awaiter(void 0, void 0, void 0, function* () {
|
|
|
65
65
|
let data = undefined;
|
|
66
66
|
const config = {
|
|
67
67
|
basePath: apiUrl,
|
|
68
|
-
baseOptions: { headers: headers
|
|
68
|
+
baseOptions: { headers: headers !== null && headers !== void 0 ? headers : {} },
|
|
69
69
|
middleware: [],
|
|
70
70
|
};
|
|
71
71
|
//comes from either id_token cookie OR auth override param
|
package/dist/ui/helpers/date.js
CHANGED
|
@@ -31,7 +31,7 @@ const dateDiffToString = (lowDate, highDate) => {
|
|
|
31
31
|
};
|
|
32
32
|
exports.dateDiffToString = dateDiffToString;
|
|
33
33
|
const getDMY = (date, dayOffset) => {
|
|
34
|
-
const date1 = (0, date_1.addDays)(date, dayOffset
|
|
34
|
+
const date1 = (0, date_1.addDays)(date, dayOffset !== null && dayOffset !== void 0 ? dayOffset : 0);
|
|
35
35
|
const d = String(date1.getDate()).padStart(2, '0');
|
|
36
36
|
const m = String(date1.getMonth() + 1).padStart(2, '0'); // January is 0!
|
|
37
37
|
const y = date1.getFullYear();
|
package/dist/ui/helpers/jwt.d.ts
CHANGED
|
@@ -9,7 +9,7 @@ export interface Jwt {
|
|
|
9
9
|
}
|
|
10
10
|
export interface Identity {
|
|
11
11
|
dateCreated: string;
|
|
12
|
-
issuer?: string |
|
|
12
|
+
issuer?: string | string[];
|
|
13
13
|
primary: string;
|
|
14
14
|
providerName: string;
|
|
15
15
|
providerType: string;
|
|
@@ -19,13 +19,13 @@ export interface IdJwt {
|
|
|
19
19
|
at_hash: string;
|
|
20
20
|
aud: string;
|
|
21
21
|
auth_time: number;
|
|
22
|
-
'cognito:groups':
|
|
22
|
+
'cognito:groups': string[];
|
|
23
23
|
'cognito:preferred_role': string;
|
|
24
24
|
'cognito:username': string;
|
|
25
25
|
email: string;
|
|
26
26
|
exp: number;
|
|
27
27
|
iat: number;
|
|
28
|
-
identities:
|
|
28
|
+
identities: Identity[];
|
|
29
29
|
iss: string;
|
|
30
30
|
name: string;
|
|
31
31
|
nickname: string;
|
|
@@ -15,6 +15,7 @@ function useOnScroll({ onScroll, element, } = {}) {
|
|
|
15
15
|
});
|
|
16
16
|
const [startScrollTopY, setStartScrollTopY] = (0, react_1.useState)(-1);
|
|
17
17
|
(0, useGranularHook_1.useGranularEffect)(() => {
|
|
18
|
+
var _a;
|
|
18
19
|
const listener = (e) => {
|
|
19
20
|
var _a, _b, _c, _d;
|
|
20
21
|
const y = (_b = (_a = element === null || element === void 0 ? void 0 : element.current) === null || _a === void 0 ? void 0 : _a.scrollTop) !== null && _b !== void 0 ? _b : window.scrollY;
|
|
@@ -37,11 +38,12 @@ function useOnScroll({ onScroll, element, } = {}) {
|
|
|
37
38
|
setStartScrollTopY(y);
|
|
38
39
|
}, { key: 'onscroll', time: 20 });
|
|
39
40
|
};
|
|
40
|
-
((element === null || element === void 0 ? void 0 : element.current)
|
|
41
|
+
((_a = element === null || element === void 0 ? void 0 : element.current) !== null && _a !== void 0 ? _a : document).addEventListener(`scroll`, listenDebounce, {
|
|
41
42
|
passive: true,
|
|
42
43
|
});
|
|
43
44
|
return () => {
|
|
44
|
-
|
|
45
|
+
var _a;
|
|
46
|
+
((_a = element === null || element === void 0 ? void 0 : element.current) !== null && _a !== void 0 ? _a : document).removeEventListener(`scroll`, listenDebounce);
|
|
45
47
|
};
|
|
46
48
|
}, [element], [element, onScroll, startScrollTopY]);
|
|
47
49
|
(0, react_1.useEffect)(() => {
|
|
@@ -12,7 +12,7 @@ exports.isServer = typeof window === 'undefined';
|
|
|
12
12
|
*/
|
|
13
13
|
const useQueryStringRaw = ({ name, queryValues, defaultValue, stringify, parse, }) => {
|
|
14
14
|
const qv = exports.isServer
|
|
15
|
-
? queryValues
|
|
15
|
+
? queryValues !== null && queryValues !== void 0 ? queryValues : {}
|
|
16
16
|
: (0, object_1.paramsToObject)(new URLSearchParams(window.location.search));
|
|
17
17
|
const qsv = parse(qv[name]) || defaultValue;
|
|
18
18
|
const [state, setStateRaw] = (0, react_1.useState)(qsv);
|
package/package.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"version": "0.0.
|
|
2
|
+
"version": "0.0.477",
|
|
3
3
|
"name": "ag-common",
|
|
4
4
|
"main": "./dist/index.js",
|
|
5
5
|
"types": "./dist/index.d.ts",
|
|
@@ -26,6 +26,7 @@
|
|
|
26
26
|
"@aws-sdk/util-dynamodb": "^3.379",
|
|
27
27
|
"aws-cdk-lib": "^2",
|
|
28
28
|
"axios": "^1",
|
|
29
|
+
"buffer": "^6",
|
|
29
30
|
"constructs": "^10",
|
|
30
31
|
"jsonwebtoken": "^9",
|
|
31
32
|
"jwks-rsa": "^3",
|
|
@@ -41,26 +42,26 @@
|
|
|
41
42
|
"@babel/types": "7.22.10",
|
|
42
43
|
"@emotion/react": "11.11.1",
|
|
43
44
|
"@emotion/styled": "11.11.0",
|
|
44
|
-
"@smithy/types": "2.2.
|
|
45
|
-
"@storybook/addon-actions": "7.
|
|
46
|
-
"@storybook/addon-docs": "7.
|
|
47
|
-
"@storybook/addon-essentials": "7.
|
|
48
|
-
"@storybook/addon-interactions": "7.
|
|
49
|
-
"@storybook/addon-links": "7.
|
|
50
|
-
"@storybook/addons": "7.
|
|
51
|
-
"@storybook/react": "7.
|
|
52
|
-
"@storybook/react-webpack5": "7.
|
|
53
|
-
"@storybook/theming": "7.
|
|
45
|
+
"@smithy/types": "2.2.1",
|
|
46
|
+
"@storybook/addon-actions": "7.3.0",
|
|
47
|
+
"@storybook/addon-docs": "7.3.0",
|
|
48
|
+
"@storybook/addon-essentials": "7.3.0",
|
|
49
|
+
"@storybook/addon-interactions": "7.3.0",
|
|
50
|
+
"@storybook/addon-links": "7.3.0",
|
|
51
|
+
"@storybook/addons": "7.3.0",
|
|
52
|
+
"@storybook/react": "7.3.0",
|
|
53
|
+
"@storybook/react-webpack5": "7.3.0",
|
|
54
|
+
"@storybook/theming": "7.3.0",
|
|
54
55
|
"@types/jest": "29.5.3",
|
|
55
56
|
"@types/jsonwebtoken": "9.0.2",
|
|
56
57
|
"@types/node": "20.5.0",
|
|
57
58
|
"@types/react": "18.2.20",
|
|
58
59
|
"@types/react-dom": "18.2.7",
|
|
59
60
|
"cross-env": "7.0.3",
|
|
60
|
-
"eslint-config-e7npm": "0.0.
|
|
61
|
+
"eslint-config-e7npm": "0.0.25",
|
|
61
62
|
"jest": "29.6.2",
|
|
62
63
|
"rimraf": "5.0.1",
|
|
63
|
-
"storybook": "7.
|
|
64
|
+
"storybook": "7.3.0",
|
|
64
65
|
"ts-jest": "29.1.1"
|
|
65
66
|
},
|
|
66
67
|
"files": [
|