ag-common 0.0.678 → 0.0.679

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.
Files changed (54) hide show
  1. package/dist/api/helpers/api.js +1 -1
  2. package/dist/api/helpers/dynamo.js +5 -6
  3. package/dist/api/helpers/openApiHelpers.js +12 -12
  4. package/dist/api/helpers/s3.js +2 -2
  5. package/dist/api/helpers/ssmInfra/dynamo.js +1 -1
  6. package/dist/api/helpers/validateOpenApi.js +6 -6
  7. package/dist/api/helpers/validations.js +3 -3
  8. package/dist/common/helpers/array.js +1 -1
  9. package/dist/common/helpers/generator.js +1 -1
  10. package/dist/common/helpers/i18n.js +3 -3
  11. package/dist/common/helpers/log.js +1 -1
  12. package/dist/common/helpers/math.js +2 -2
  13. package/dist/common/helpers/object.js +1 -1
  14. package/dist/common/helpers/secondsInNearest.js +2 -2
  15. package/dist/common/helpers/string/contains.js +1 -1
  16. package/dist/common/helpers/string/object.js +0 -3
  17. package/dist/common/helpers/string/redact.js +1 -1
  18. package/dist/ui/components/DarkMode/Base.js +2 -4
  19. package/dist/ui/components/DropdownList/Base.js +2 -2
  20. package/dist/ui/components/HorizontalScrollBar/index.js +2 -2
  21. package/dist/ui/components/Icon/index.js +1 -1
  22. package/dist/ui/components/InfiniteScroll/index.js +1 -1
  23. package/dist/ui/components/LineChart/Base.js +2 -2
  24. package/dist/ui/components/LineChart/TooltipContent.js +2 -2
  25. package/dist/ui/components/LineChart/getLegendItems.js +1 -0
  26. package/dist/ui/components/OpenApiCodeBlock/OpenApiCodeBlock.js +1 -0
  27. package/dist/ui/components/OpenApiCodeBlock/curl/helpers/getCurlLines.js +2 -3
  28. package/dist/ui/components/OpenApiCodeBlock/types.d.ts +1 -1
  29. package/dist/ui/components/RadioGroup/index.js +3 -3
  30. package/dist/ui/components/Search/Inline.js +5 -5
  31. package/dist/ui/components/Search/Modal.js +1 -1
  32. package/dist/ui/components/Search/SearchBox.js +4 -5
  33. package/dist/ui/components/TextEdit/TextEdit.js +6 -2
  34. package/dist/ui/components/Timeline/index.js +1 -1
  35. package/dist/ui/components/TimelineChart/index.js +4 -4
  36. package/dist/ui/components/Toast/base.js +5 -5
  37. package/dist/ui/components/TreeChart/helpers.js +3 -1
  38. package/dist/ui/helpers/axiosHelper.js +1 -0
  39. package/dist/ui/helpers/callOpenApi/cached.js +3 -3
  40. package/dist/ui/helpers/callOpenApi/direct.js +8 -7
  41. package/dist/ui/helpers/callOpenApi/helpers.js +4 -2
  42. package/dist/ui/helpers/cookie/get.js +2 -2
  43. package/dist/ui/helpers/cookie/raw.d.ts +2 -2
  44. package/dist/ui/helpers/cookie/raw.js +4 -3
  45. package/dist/ui/helpers/date.js +0 -3
  46. package/dist/ui/helpers/extractAttributes.js +1 -1
  47. package/dist/ui/helpers/index.d.ts +0 -1
  48. package/dist/ui/helpers/index.js +0 -1
  49. package/dist/ui/helpers/routes.js +1 -1
  50. package/dist/ui/helpers/useInterval.js +1 -1
  51. package/dist/ui/helpers/useOnClickOutside.js +2 -2
  52. package/package.json +1 -1
  53. package/dist/ui/helpers/browserHelpers.d.ts +0 -1
  54. package/dist/ui/helpers/browserHelpers.js +0 -23
@@ -70,7 +70,7 @@ exports.stripPKs = stripPKs;
70
70
  const generateDynamoPKS = ({ type, L1, L2, L3, L4, L5, L6, additionalPKValues, }) => {
71
71
  const c = '#';
72
72
  const keys = [L1, L2, L3, L4, L5, L6].filter(array_1.notEmpty);
73
- const additionalPK = additionalPKValues && (additionalPKValues === null || additionalPKValues === void 0 ? void 0 : additionalPKValues.length) > 0
73
+ const additionalPK = additionalPKValues && additionalPKValues.length > 0
74
74
  ? `#${additionalPKValues.join(c)}`
75
75
  : '';
76
76
  return Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({ PK: keys.join(c) + additionalPK, type,
@@ -163,9 +163,9 @@ const scan = (tableName, opt) => __awaiter(void 0, void 0, void 0, function* ()
163
163
  }
164
164
  } while (ExclusiveStartKey && (!(opt === null || opt === void 0 ? void 0 : opt.limit) || Items.length < opt.limit));
165
165
  if (opt === null || opt === void 0 ? void 0 : opt.limit) {
166
- ({ part: Items } = (0, array_1.take)(Items, opt === null || opt === void 0 ? void 0 : opt.limit));
166
+ ({ part: Items } = (0, array_1.take)(Items, opt.limit));
167
167
  }
168
- (0, log_1.debug)(`dynamo scan against ${tableName} ok, count=${Items === null || Items === void 0 ? void 0 : Items.length}`);
168
+ (0, log_1.debug)(`dynamo scan against ${tableName} ok, count=${Items.length}`);
169
169
  return { data: Items };
170
170
  }
171
171
  catch (e) {
@@ -270,7 +270,7 @@ const queryDynamo = (_f) => __awaiter(void 0, [_f], void 0, function* ({ tableNa
270
270
  return { error: e.toString() };
271
271
  }
272
272
  startKey = lek;
273
- (0, log_1.debug)(`dynamo query against ${params === null || params === void 0 ? void 0 : params.input.TableName} ok, count=${newItems === null || newItems === void 0 ? void 0 : newItems.length} ${JSON.stringify(params)}`, ` next startkey=${startKey}`);
273
+ (0, log_1.debug)(`dynamo query against ${params.input.TableName} ok, count=${newItems === null || newItems === void 0 ? void 0 : newItems.length} ${JSON.stringify(params)}`, ` next startkey=${startKey}`);
274
274
  if (!!limit && Items.length > limit) {
275
275
  return { data: Items, startKey };
276
276
  }
@@ -283,7 +283,6 @@ exports.getDynamoTtlDays = getDynamoTtlDays;
283
283
  const getDynamoTtlMinutes = (mins) => Math.ceil(new Date().getTime() / 1000) + mins * 60;
284
284
  exports.getDynamoTtlMinutes = getDynamoTtlMinutes;
285
285
  const wipeTable = (tableName) => __awaiter(void 0, void 0, void 0, function* () {
286
- var _g;
287
286
  try {
288
287
  let infoV = yield exports.dynamoDb.send(new client_dynamodb_1.DescribeTableCommand({ TableName: tableName }));
289
288
  // eslint-disable-next-line @typescript-eslint/ban-ts-comment
@@ -297,8 +296,8 @@ const wipeTable = (tableName) => __awaiter(void 0, void 0, void 0, function* ()
297
296
  throw allraw.error;
298
297
  }
299
298
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
300
- let all = ((_g = allraw === null || allraw === void 0 ? void 0 : allraw.data) === null || _g === void 0 ? void 0 : _g.map((d) => d)) || [];
301
- (0, log_1.warn)(`will delete ${all === null || all === void 0 ? void 0 : all.length} items from ${tableName}`);
299
+ let all = allraw.data.map((d) => d) || [];
300
+ (0, log_1.warn)(`will delete ${all.length} items from ${tableName}`);
302
301
  yield (0, exports.batchDelete)({
303
302
  tableName,
304
303
  keys: all.map((s) => s[keyHash]),
@@ -39,35 +39,35 @@ const setUpApiGw = ({ stack, NODE_ENV, shortStackName, r53, cors = {
39
39
  const setupLambda = ({ lambdaConfig, pathV, verb, seenPermissions, authorizers, }) => {
40
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
- const lp = lambdaConfig === null || lambdaConfig === void 0 ? void 0 : lambdaConfig[pathCompute];
42
+ const lp = lambdaConfig[pathCompute];
43
43
  if (lp) {
44
44
  seenPermissions[pathCompute] = true;
45
45
  }
46
46
  else {
47
47
  seenPermissions[pathCompute] = false;
48
48
  }
49
- const def = lambdaConfig === null || lambdaConfig === void 0 ? void 0 : lambdaConfig.default;
49
+ const def = lambdaConfig.default;
50
50
  if (def) {
51
51
  seenPermissions.default = true;
52
52
  }
53
53
  //
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;
54
+ const readTables = (0, array_1.distinctBy)([...((_b = (_a = def.dynamo) === null || _a === void 0 ? void 0 : _a.reads) !== null && _b !== void 0 ? _b : []), ...((_d = (_c = 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.dynamo) === null || _e === void 0 ? void 0 : _e.writes) !== null && _f !== void 0 ? _f : []), ...((_h = (_g = 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.policies) !== null && _k !== void 0 ? _k : [])].filter(array_1.notEmpty);
57
+ const layers = [...((_l = def.layers) !== null && _l !== void 0 ? _l : []), ...((_m = lp.layers) !== null && _m !== void 0 ? _m : [])].filter(array_1.notEmpty);
58
+ const memory = (_p = (_o = lp.memory) !== null && _o !== void 0 ? _o : def.memory) !== null && _p !== void 0 ? _p : 128;
59
59
  // null forces undefined, undefined forces 5
60
- let reservedConcurrentExecutions = lp === null || lp === void 0 ? void 0 : lp.reservedConcurrentExecutions;
60
+ let reservedConcurrentExecutions = lp.reservedConcurrentExecutions;
61
61
  if (reservedConcurrentExecutions === undefined) {
62
- reservedConcurrentExecutions = def === null || def === void 0 ? void 0 : def.reservedConcurrentExecutions;
62
+ reservedConcurrentExecutions = def.reservedConcurrentExecutions;
63
63
  }
64
64
  if (reservedConcurrentExecutions === undefined) {
65
65
  reservedConcurrentExecutions = 5;
66
66
  }
67
67
  reservedConcurrentExecutions = reservedConcurrentExecutions !== null && reservedConcurrentExecutions !== void 0 ? reservedConcurrentExecutions : undefined;
68
68
  //
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
- let authorizerName = lp === null || lp === void 0 ? void 0 : lp.authorizerName;
69
+ const timeout = aws_cdk_lib_1.Duration.seconds((_r = (_q = lp.timeoutS) !== null && _q !== void 0 ? _q : def.timeoutS) !== null && _r !== void 0 ? _r : 30);
70
+ let authorizerName = lp.authorizerName;
71
71
  if (authorizerName === undefined) {
72
72
  authorizerName = def.authorizerName;
73
73
  }
@@ -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({}, ((_s = def.env) !== null && _s !== void 0 ? _s : {})), ((_t = lp === null || lp === void 0 ? void 0 : lp.env) !== null && _t !== void 0 ? _t : {}));
80
+ const env = Object.assign(Object.assign({}, ((_s = def.env) !== null && _s !== void 0 ? _s : {})), ((_t = lp.env) !== null && _t !== void 0 ? _t : {}));
81
81
  const environment = env;
82
82
  return {
83
83
  environment,
@@ -143,7 +143,7 @@ const copyFile = (_f) => __awaiter(void 0, [_f], void 0, function* ({ Bucket, fr
143
143
  exports.copyFile = copyFile;
144
144
  function listFiles(bucketName, opt) {
145
145
  return __awaiter(this, void 0, void 0, function* () {
146
- var _a, _b;
146
+ var _a;
147
147
  try {
148
148
  const ret = [];
149
149
  let response;
@@ -153,7 +153,7 @@ function listFiles(bucketName, opt) {
153
153
  ContinuationToken: response === null || response === void 0 ? void 0 : response.NextContinuationToken,
154
154
  Prefix: opt === null || opt === void 0 ? void 0 : opt.prefix,
155
155
  }));
156
- (_b = (_a = response.Contents) === null || _a === void 0 ? void 0 : _a.filter((r) => r.Key)) === null || _b === void 0 ? void 0 : _b.map((c) => {
156
+ (_a = response.Contents) === null || _a === void 0 ? void 0 : _a.filter((r) => r.Key).map((c) => {
157
157
  ret.push(c.Key);
158
158
  });
159
159
  } while (response.IsTruncated);
@@ -23,7 +23,7 @@ const generateDynamoSSMParams = ({ stack, table, baseKey, gsi, }) => {
23
23
  value: table.tableStreamArn,
24
24
  });
25
25
  }
26
- if (gsi && (gsi === null || gsi === void 0 ? void 0 : gsi.length) > 0) {
26
+ if (gsi && gsi.length > 0) {
27
27
  (0, ssm_1.saveToSsm)({
28
28
  stack,
29
29
  path: `${baseKey}/gsi`,
@@ -40,12 +40,12 @@ const getOperation = ({ path, method, resource, schema, }) => {
40
40
  const re = new RegExp(resourcePath
41
41
  .replace(/\//gim, `\\/`)
42
42
  .replace(/\{(.+?)\}/gim, '(?<$1>[^\\\\]+)'), 'i').exec(path);
43
- const pathParams = (re === null || re === void 0 ? void 0 : re.groups) && JSON.parse(JSON.stringify(re === null || re === void 0 ? void 0 : re.groups));
43
+ const pathParams = (re === null || re === void 0 ? void 0 : re.groups) && JSON.parse(JSON.stringify(re.groups));
44
44
  return { operation, pathParams };
45
45
  };
46
46
  function validateOpenApi(_a) {
47
47
  return __awaiter(this, arguments, void 0, function* ({ event, next, authorized, schema, COGNITO_USER_POOL_ID, jwksRegion = 'ap-southeast-2', getAndValidateTokenOverride, }) {
48
- var _b, _c, _d, _e, _f, _g, _h, _j, _k;
48
+ var _b, _c, _d, _e, _f, _g, _h;
49
49
  if (!schema) {
50
50
  throw new Error('schema undefined!');
51
51
  }
@@ -59,7 +59,7 @@ function validateOpenApi(_a) {
59
59
  params: undefined,
60
60
  query: event.queryStringParameters,
61
61
  body: (0, object_1.tryJsonParse)(event.body, event.body),
62
- headers: (0, object_1.objectKeysToLowerCase)(event === null || event === void 0 ? void 0 : event.headers),
62
+ headers: (0, object_1.objectKeysToLowerCase)(event.headers),
63
63
  };
64
64
  const method = event.requestContext.httpMethod.toLowerCase();
65
65
  const pathParameters = (_b = event.pathParameters) !== null && _b !== void 0 ? _b : {};
@@ -71,7 +71,7 @@ function validateOpenApi(_a) {
71
71
  resource: event.resource,
72
72
  schema,
73
73
  });
74
- if (!(opm === null || opm === void 0 ? void 0 : opm.operation)) {
74
+ if (!opm.operation) {
75
75
  const msg = `no request handler found! for ${method} ${event.path} - cant validate`;
76
76
  (0, log_1.error)(msg);
77
77
  return (0, api_1.returnCode)(400, msg);
@@ -104,7 +104,7 @@ function validateOpenApi(_a) {
104
104
  }
105
105
  let userProfile;
106
106
  let error;
107
- const authHeader = ((_h = event.headers) === null || _h === void 0 ? void 0 : _h.Authorization) || ((_j = event.headers) === null || _j === void 0 ? void 0 : _j.authorization);
107
+ const authHeader = event.headers.Authorization || event.headers.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(_a) {
122
122
  event,
123
123
  body: (0, object_1.tryJsonParse)(event.body, event.body),
124
124
  userProfile,
125
- lang: (0, i18n_1.getValidatedLang)((_k = event.headers['x-lang']) !== null && _k !== void 0 ? _k : ''),
125
+ lang: (0, i18n_1.getValidatedLang)((_h = event.headers['x-lang']) !== null && _h !== void 0 ? _h : ''),
126
126
  });
127
127
  return res;
128
128
  });
@@ -64,7 +64,7 @@ const jwtVerify = (_a) => __awaiter(void 0, [_a], void 0, function* ({ token, jw
64
64
  });
65
65
  /** extracts user details from oauth token */
66
66
  const getAndValidateToken = (_b) => __awaiter(void 0, [_b], void 0, function* ({ tokenRaw, jwksRegion = 'ap-southeast-2', COGNITO_USER_POOL_ID, }) {
67
- var _c, _d;
67
+ var _c;
68
68
  const jwksUri = `https://cognito-idp.${jwksRegion}.amazonaws.com/${COGNITO_USER_POOL_ID}/.well-known/jwks.json`;
69
69
  const issuer = `https://cognito-idp.${jwksRegion}.amazonaws.com/${COGNITO_USER_POOL_ID}`;
70
70
  let token = '';
@@ -96,14 +96,14 @@ const getAndValidateToken = (_b) => __awaiter(void 0, [_b], void 0, function* ({
96
96
  error: (0, api_1.returnCode)(403, m),
97
97
  };
98
98
  }
99
- subject = decoded === null || decoded === void 0 ? void 0 : decoded.sub;
99
+ subject = decoded.sub;
100
100
  if (!subject) {
101
101
  const mess = 'user should have responded with subject (sub) field';
102
102
  (0, log_1.error)(mess);
103
103
  throw new Error(mess);
104
104
  }
105
105
  let { picture } = decoded;
106
- if (((_d = (_c = decoded === null || decoded === void 0 ? void 0 : decoded.identities) === null || _c === void 0 ? void 0 : _c[0]) === null || _d === void 0 ? void 0 : _d.providerName) === 'Facebook') {
106
+ if (((_c = decoded.identities[0]) === null || _c === void 0 ? void 0 : _c.providerName) === 'Facebook') {
107
107
  picture = JSON.parse(decoded.picture).data.url;
108
108
  }
109
109
  const userId = decoded.email.toLowerCase();
@@ -51,7 +51,7 @@ const chunk = (array, max) => {
51
51
  return rows;
52
52
  };
53
53
  exports.chunk = chunk;
54
- const partition = (array, func) => !(array === null || array === void 0 ? void 0 : array.length)
54
+ const partition = (array, func) => !array.length
55
55
  ? null
56
56
  : [array.filter((r) => func(r)), array.filter((r) => !func(r))];
57
57
  exports.partition = partition;
@@ -16,7 +16,7 @@ function runGenerator(iter, partialRun) {
16
16
  let curr;
17
17
  do {
18
18
  curr = yield iter.next();
19
- if (!(curr === null || curr === void 0 ? void 0 : curr.value) || curr.value.length === 0) {
19
+ if (!curr.value || curr.value.length === 0) {
20
20
  return;
21
21
  }
22
22
  yield partialRun(curr.value);
@@ -20,12 +20,12 @@ const t = (res, lang) => {
20
20
  exports.t = t;
21
21
  const useTranslation = (texts, lang) => {
22
22
  const ret = (lineText) => {
23
- var _a, _b;
24
- const v1 = (_a = texts[lineText]) === null || _a === void 0 ? void 0 : _a[lang];
23
+ var _a;
24
+ const v1 = texts[lineText][lang];
25
25
  if (v1 || v1 === null) {
26
26
  return v1 !== null && v1 !== void 0 ? v1 : '';
27
27
  }
28
- return (_b = texts[lineText].en) !== null && _b !== void 0 ? _b : '???';
28
+ return (_a = texts[lineText].en) !== null && _a !== void 0 ? _a : '???';
29
29
  };
30
30
  return ret;
31
31
  };
@@ -14,7 +14,7 @@ const SetLogShim = (ls) => {
14
14
  exports.SetLogShim = SetLogShim;
15
15
  let userLogLevel;
16
16
  const SetLogLevel = (l) => {
17
- const lu = l === null || l === void 0 ? void 0 : l.toUpperCase();
17
+ const lu = l.toUpperCase();
18
18
  if ((0, exports.GetLogLevel)(lu) === -1) {
19
19
  return;
20
20
  }
@@ -2,9 +2,9 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.interpolatePercentInRange = exports.rangePercentage = exports.toFixedDown = exports.isNumber = exports.sumArray = exports.clamp = exports.roundToHalf = exports.toFixed = void 0;
4
4
  const toFixed = (num, fixed) => {
5
- var _a, _b;
5
+ var _a;
6
6
  const re = new RegExp(`^-?\\d+(?:.\\d{0,${fixed || -1}})?`);
7
- const x = (_b = (_a = num === null || num === void 0 ? void 0 : num.toString()) === null || _a === void 0 ? void 0 : _a.match(re)) === null || _b === void 0 ? void 0 : _b[0];
7
+ const x = (_a = num.toString().match(re)) === null || _a === void 0 ? void 0 : _a[0];
8
8
  if (!x) {
9
9
  return num;
10
10
  }
@@ -165,7 +165,7 @@ const removeUndefValuesFromObjectAdditional = (orig,
165
165
  ...additionalRemoves) => {
166
166
  const ret = {};
167
167
  Object.entries(orig).forEach(([k, v]) => {
168
- if (v !== null && v !== undefined && !(additionalRemoves === null || additionalRemoves === void 0 ? void 0 : additionalRemoves.includes(v))) {
168
+ if (v !== null && v !== undefined && !additionalRemoves.includes(v)) {
169
169
  ret[k] = v;
170
170
  }
171
171
  });
@@ -2,9 +2,9 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.secondsInNearest = void 0;
4
4
  const toFixed = (num, fixed) => {
5
- var _a, _b;
5
+ var _a;
6
6
  const re = new RegExp(`^-?\\d+(?:.\\d{0,${fixed || -1}})?`);
7
- const x = (_b = (_a = num === null || num === void 0 ? void 0 : num.toString()) === null || _a === void 0 ? void 0 : _a.match(re)) === null || _b === void 0 ? void 0 : _b[0];
7
+ const x = (_a = num.toString().match(re)) === null || _a === void 0 ? void 0 : _a[0];
8
8
  if (!x) {
9
9
  return num;
10
10
  }
@@ -8,7 +8,7 @@ exports.containsInsensitiveIndexes = exports.containsInsensitive = exports.conta
8
8
  * @returns
9
9
  */
10
10
  function containsInsensitiveIndex({ str, fromLast = false, }, ...args) {
11
- if (!str || !args) {
11
+ if (!str) {
12
12
  return -1;
13
13
  }
14
14
  const largs = args.map((a) => a.toLowerCase());
@@ -9,9 +9,6 @@ exports.stringToObject = void 0;
9
9
  */
10
10
  function stringToObject(raw, splitKeyValue, splitKeys) {
11
11
  const ret = {};
12
- if (!stringToObject) {
13
- return ret;
14
- }
15
12
  raw.split(splitKeys).forEach((set) => {
16
13
  const [k, v] = set.split(splitKeyValue);
17
14
  if (k) {
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.redactObject = exports.redactString = void 0;
4
4
  function redactString(str) {
5
5
  let ret = str;
6
- ret = ret !== null && ret !== void 0 ? ret : '';
6
+ ret = ret || '';
7
7
  const repl = '$1<redacted>$2';
8
8
  ret = ret.replace(/(\b)grant_type.+?(\b)/gm, repl);
9
9
  ret = ret.replace(/(\b)Bearer .+?(\b)/gm, repl);
@@ -92,8 +92,7 @@ const UseDarkMode = ({ cookieDocument, }) => {
92
92
  stringify: (v) => v.toString(),
93
93
  });
94
94
  const calcDarkMode = () => {
95
- var _a;
96
- const isDarkMode = (_a = window.matchMedia) === null || _a === void 0 ? void 0 : _a.call(window, '(prefers-color-scheme: dark)').matches;
95
+ const isDarkMode = window.matchMedia('(prefers-color-scheme: dark)').matches;
97
96
  if (darkmode === types_1.TDarkMode.system) {
98
97
  return isDarkMode ? types_1.TDarkModeCalc.dark : types_1.TDarkModeCalc.light;
99
98
  }
@@ -112,8 +111,7 @@ exports.UseDarkMode = UseDarkMode;
112
111
  * this method has the darkmode passed in, so UseDarkMode can be used globally
113
112
  */
114
113
  const DarkModeAux = ({ iconSize = '2.5rem', className, mode, onSubmit, style, dm, }) => {
115
- var _a;
116
- const [index, setIndex] = (0, react_1.useState)((_a = modes.findIndex((d) => d.mode === dm.darkmode)) !== null && _a !== void 0 ? _a : 0);
114
+ const [index, setIndex] = (0, react_1.useState)(modes.findIndex((d) => d.mode === dm.darkmode));
117
115
  const [fill, background] = getColours(modes[index].mode, mode === 'vert');
118
116
  const twCalc = `calc(${iconSize} + ${iconSize} + ${iconSize} )`;
119
117
  const setDarkmode = (newDarkMode) => {
@@ -126,14 +126,14 @@ function DropdownList(p) {
126
126
  width: 'fit-content',
127
127
  };
128
128
  const minPx = (0, dom_1.convertRemToPixels)(2 + maxLen / 2);
129
- const offsetLeft = (_b = (_a = ref === null || ref === void 0 ? void 0 : ref.current) === null || _a === void 0 ? void 0 : _a.offsetLeft) !== null && _b !== void 0 ? _b : 0;
129
+ const offsetLeft = (_b = (_a = ref.current) === null || _a === void 0 ? void 0 : _a.offsetLeft) !== null && _b !== void 0 ? _b : 0;
130
130
  if (offsetLeft < minPx) {
131
131
  newStyle.left = '0';
132
132
  }
133
133
  else {
134
134
  newStyle.right = '0';
135
135
  }
136
- const b = (_d = (_c = ref === null || ref === void 0 ? void 0 : ref.current) === null || _c === void 0 ? void 0 : _c.getBoundingClientRect()) !== null && _d !== void 0 ? _d : { bottom: 0 };
136
+ const b = (_d = (_c = ref.current) === null || _c === void 0 ? void 0 : _c.getBoundingClientRect()) !== null && _d !== void 0 ? _d : { bottom: 0 };
137
137
  const ih = typeof window !== 'undefined' ? window.innerHeight : 0;
138
138
  //below screen
139
139
  if (b.bottom + 50 > ih) {
@@ -40,9 +40,9 @@ const HorizontalScrollBar = ({ children, className, }) => {
40
40
  };
41
41
  scrollRef.current.addEventListener('wheel', handleScroll);
42
42
  return () => {
43
- var _a, _b;
43
+ var _a;
44
44
  // eslint-disable-next-line react-hooks/exhaustive-deps
45
- (_b = (_a = scrollRef.current) === null || _a === void 0 ? void 0 : _a.removeEventListener) === null || _b === void 0 ? void 0 : _b.call(_a, 'wheel', handleScroll);
45
+ (_a = scrollRef.current) === null || _a === void 0 ? void 0 : _a.removeEventListener('wheel', handleScroll);
46
46
  };
47
47
  }, [scrollRef]);
48
48
  return (react_1.default.createElement("div", { ref: scrollRef, style: { overflowX: 'auto' }, className: className }, children));
@@ -63,7 +63,7 @@ const Icon = (pr) => {
63
63
  var _a, _b, _c, _d, _e, _f, _g, _h;
64
64
  const { className, children, disabled, onClick } = pr;
65
65
  const CHND = pr.canHover && !pr.disabled;
66
- const style = (0, object_1.removeUndefValuesFromObject)(Object.assign(Object.assign({}, ((_a = pr === null || pr === void 0 ? void 0 : pr.style) !== null && _a !== void 0 ? _a : {})), { '--fill': (_c = (_b = pr.style) === null || _b === void 0 ? void 0 : _b.fill) !== null && _c !== void 0 ? _c : null, width: (_d = pr.style) === null || _d === void 0 ? void 0 : _d.width, height: (_e = pr.style) === null || _e === void 0 ? void 0 : _e.height, padding: (_f = pr.style) === null || _f === void 0 ? void 0 : _f.padding, margin: (_g = pr.style) === null || _g === void 0 ? void 0 : _g.margin, transform: !pr.rotate ? null : `rotate(${pr.rotate || 0}deg)`, filter: !pr.disabled ? null : 'grayscale(1)', '--outlinecolour': pr.outline || null }));
66
+ const style = (0, object_1.removeUndefValuesFromObject)(Object.assign(Object.assign({}, ((_a = pr.style) !== null && _a !== void 0 ? _a : {})), { '--fill': (_c = (_b = pr.style) === null || _b === void 0 ? void 0 : _b.fill) !== null && _c !== void 0 ? _c : null, width: (_d = pr.style) === null || _d === void 0 ? void 0 : _d.width, height: (_e = pr.style) === null || _e === void 0 ? void 0 : _e.height, padding: (_f = pr.style) === null || _f === void 0 ? void 0 : _f.padding, margin: (_g = pr.style) === null || _g === void 0 ? void 0 : _g.margin, transform: !pr.rotate ? null : `rotate(${pr.rotate || 0}deg)`, filter: !pr.disabled ? null : 'grayscale(1)', '--outlinecolour': pr.outline || null }));
67
67
  return (react_1.default.createElement(exports.IconF, Object.assign({}, pr, { className: className, onClick: (e) => !disabled && (onClick === null || onClick === void 0 ? void 0 : onClick(e)), style: style, "data-chnd": CHND, "data-hasoutline": pr.outline, "data-hasfill": !!((_h = pr.style) === null || _h === void 0 ? void 0 : _h.fill), "data-type": "iconbox" }), children));
68
68
  };
69
69
  exports.Icon = Icon;
@@ -77,7 +77,7 @@ const InfiniteScroll = (p) => {
77
77
  (0, debounce_1.debounce)(() => {
78
78
  var _a;
79
79
  setStartScrollTop(scrollTop);
80
- (_a = p === null || p === void 0 ? void 0 : p.onScroll) === null || _a === void 0 ? void 0 : _a.call(p, { scrollTop, isDown: startScrollTop < scrollTop });
80
+ (_a = p.onScroll) === null || _a === void 0 ? void 0 : _a.call(p, { scrollTop, isDown: startScrollTop < scrollTop });
81
81
  }, {
82
82
  key: 'in-scr',
83
83
  time: 50,
@@ -83,10 +83,10 @@ const LineChart = (p) => {
83
83
  const sp1 = points
84
84
  .map((p) => (Object.assign(Object.assign({}, p), { gap: Math.abs(p.x1 - relativeX) })))
85
85
  .sort((a, b) => (a.gap < b.gap ? -1 : 1));
86
- const mingap = sp1 === null || sp1 === void 0 ? void 0 : sp1[0].gap;
86
+ const mingap = sp1[0].gap;
87
87
  selectedPoints = sp1.filter((r) => r.gap === mingap);
88
88
  }
89
- const selectedXs = (0, array_1.distinctBy)(p.data.filter(({ x, y }) => selectedPoints === null || selectedPoints === void 0 ? void 0 : selectedPoints.find((a) => a.origX === x && a.origY === y)), (s) => JSON.stringify(s));
89
+ const selectedXs = (0, array_1.distinctBy)(p.data.filter(({ x, y }) => selectedPoints.find((a) => a.origX === x && a.origY === y)), (s) => JSON.stringify(s));
90
90
  UT.setPos({
91
91
  element,
92
92
  parent,
@@ -32,8 +32,8 @@ const Total = styled_1.default.span `
32
32
  }
33
33
  `;
34
34
  const TooltipContent = (p) => {
35
- var _a, _b, _c, _d;
36
- const name = (_d = (_a = p.tt) === null || _a === void 0 ? void 0 : _a.call(p, (_c = (_b = p.selectedXs) === null || _b === void 0 ? void 0 : _b[0].x) !== null && _c !== void 0 ? _c : 0)) !== null && _d !== void 0 ? _d : '';
35
+ var _a, _b, _c;
36
+ const name = (_c = p.tt((_b = (_a = p.selectedXs) === null || _a === void 0 ? void 0 : _a[0].x) !== null && _b !== void 0 ? _b : 0)) !== null && _c !== void 0 ? _c : '';
37
37
  return (react_1.default.createElement(Base, { style: Object.assign(Object.assign({}, p.style), { border: `solid 1px ${p.style.borderColor}` }) },
38
38
  react_1.default.createElement(Title, null, name),
39
39
  react_1.default.createElement(Row, null,
@@ -7,6 +7,7 @@ const shownResults = 4;
7
7
  const getTopItems = ({ data, colours, }) => {
8
8
  const val = {};
9
9
  data.forEach((d) => {
10
+ // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
10
11
  if (!val[d.name]) {
11
12
  val[d.name] = { colour: colours[d.name], name: d.name, value: d.y };
12
13
  }
@@ -45,6 +45,7 @@ const Block = styled_1.default.div `
45
45
  const OpenApiCodeBlock = (p) => {
46
46
  var _a;
47
47
  const ops = (0, common_1.getOperation)(p);
48
+ // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
48
49
  if (ops.error || !ops.verb || !ops.operation) {
49
50
  return react_1.default.createElement(Base, null, ops.error);
50
51
  }
@@ -4,14 +4,13 @@ exports.getCurlLines = void 0;
4
4
  const body_1 = require("./body");
5
5
  const security_1 = require("./security");
6
6
  const getCurlLines = (ops, p) => {
7
- var _a;
8
7
  const { operation, path, verb, fullApiUrl } = ops;
9
8
  const withPath = fullApiUrl + path;
10
9
  const secline = (0, security_1.getSecurityLine)(p, { operation });
11
10
  if (secline.error) {
12
11
  return { error: secline.error };
13
12
  }
14
- const bodyLines = (_a = (0, body_1.getBody)(p)) !== null && _a !== void 0 ? _a : undefined;
13
+ const bodyLines = (0, body_1.getBody)(p);
15
14
  const headerLines = [];
16
15
  if (secline.content) {
17
16
  headerLines.push(secline.content);
@@ -25,7 +24,7 @@ const getCurlLines = (ops, p) => {
25
24
  error: undefined,
26
25
  headerLines: headerLines,
27
26
  fullApiUrl: withPath,
28
- bodyLine: bodyLines === null || bodyLines === void 0 ? void 0 : bodyLines.content,
27
+ bodyLine: bodyLines.content,
29
28
  operation,
30
29
  };
31
30
  };
@@ -1,6 +1,6 @@
1
1
  /// <reference types="react" />
2
2
  export interface IOpenApiOperation {
3
- description: string;
3
+ description?: string;
4
4
  operationId: string;
5
5
  security?: {
6
6
  [name: string]: string;
@@ -52,11 +52,11 @@ const Label = styled_1.default.label `
52
52
  }
53
53
  `;
54
54
  const RadioGroup = (p) => {
55
- var _a, _b;
55
+ var _a;
56
56
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
57
57
  const { renderLabel = (x) => x.toString() } = p;
58
- const [index, setIndex] = (0, react_1.useState)((_a = p.defaultIndex) !== null && _a !== void 0 ? _a : 0);
59
- return (react_1.default.createElement(Base, { className: p.className, style: p.style, "data-mode": (_b = p.mode) !== null && _b !== void 0 ? _b : 'horiz' }, p.values.map((v, i) => (react_1.default.createElement(Label
58
+ const [index, setIndex] = (0, react_1.useState)(p.defaultIndex);
59
+ return (react_1.default.createElement(Base, { className: p.className, style: p.style, "data-mode": (_a = p.mode) !== null && _a !== void 0 ? _a : 'horiz' }, p.values.map((v, i) => (react_1.default.createElement(Label
60
60
  // eslint-disable-next-line react/no-array-index-key
61
61
  , {
62
62
  // eslint-disable-next-line react/no-array-index-key
@@ -80,20 +80,20 @@ const RowCount = styled_1.default.div `
80
80
  const SearchInline = (p) => {
81
81
  var _a, _b, _c, _d, _e, _f;
82
82
  const { maxDisplayItems = 1000 } = p;
83
- const rowCountOptDisplay = (_b = (_a = p === null || p === void 0 ? void 0 : p.rowCountOpt) === null || _a === void 0 ? void 0 : _a.display) !== null && _b !== void 0 ? _b : 'bottom';
83
+ const rowCountOptDisplay = (_b = (_a = p.rowCountOpt) === null || _a === void 0 ? void 0 : _a.display) !== null && _b !== void 0 ? _b : 'bottom';
84
84
  const [searchText, setSearchText] = (0, react_1.useState)((_c = p.defaultValue) !== null && _c !== void 0 ? _c : '');
85
85
  (0, react_1.useImperativeHandle)(p.textBoxRef, () => ({
86
86
  setValue: (v) => {
87
87
  var _a, _b;
88
- const value = (_a = textBoxRef === null || textBoxRef === void 0 ? void 0 : textBoxRef.current) === null || _a === void 0 ? void 0 : _a.getValue();
88
+ const value = (_a = textBoxRef.current) === null || _a === void 0 ? void 0 : _a.getValue();
89
89
  if (v === value) {
90
90
  return;
91
91
  }
92
- (_b = textBoxRef === null || textBoxRef === void 0 ? void 0 : textBoxRef.current) === null || _b === void 0 ? void 0 : _b.setValue(v);
92
+ (_b = textBoxRef.current) === null || _b === void 0 ? void 0 : _b.setValue(v);
93
93
  setSearchText(v);
94
94
  },
95
- focus: () => { var _a; return (_a = textBoxRef === null || textBoxRef === void 0 ? void 0 : textBoxRef.current) === null || _a === void 0 ? void 0 : _a.focus(); },
96
- getValue: () => { var _a; return (_a = textBoxRef === null || textBoxRef === void 0 ? void 0 : textBoxRef.current) === null || _a === void 0 ? void 0 : _a.getValue(); },
95
+ focus: () => { var _a; return (_a = textBoxRef.current) === null || _a === void 0 ? void 0 : _a.focus(); },
96
+ getValue: () => { var _a; return (_a = textBoxRef.current) === null || _a === void 0 ? void 0 : _a.getValue(); },
97
97
  }));
98
98
  const textBoxRef = (0, react_1.useRef)(null);
99
99
  const resWrap = (foundItem, target) => {
@@ -23,6 +23,6 @@ const ModalStyled = (0, styled_1.default)(Modal_1.Modal) `
23
23
  max-width: 95vw;
24
24
  }
25
25
  `;
26
- const SearchModal = (p) => (react_1.default.createElement(ModalStyled, { position: "center", topPosition: "center", open: true, setOpen: () => { var _a; return (_a = p === null || p === void 0 ? void 0 : p.onSelectItem) === null || _a === void 0 ? void 0 : _a.call(p, undefined); }, showCloseButton: false, closeOnClickOutside: true },
26
+ const SearchModal = (p) => (react_1.default.createElement(ModalStyled, { position: "center", topPosition: "center", open: true, setOpen: () => { var _a; return (_a = p.onSelectItem) === null || _a === void 0 ? void 0 : _a.call(p, undefined); }, showCloseButton: false, closeOnClickOutside: true },
27
27
  react_1.default.createElement(Inline_1.SearchInline, Object.assign({}, p))));
28
28
  exports.SearchModal = SearchModal;
@@ -75,21 +75,20 @@ const SearchBox = (p) => {
75
75
  var _a, _b;
76
76
  const textBoxRef = (0, react_1.useRef)((_b = (_a = p.textBoxRef) === null || _a === void 0 ? void 0 : _a.current) !== null && _b !== void 0 ? _b : null);
77
77
  (0, react_1.useEffect)(() => {
78
- if (!(textBoxRef === null || textBoxRef === void 0 ? void 0 : textBoxRef.current) ||
79
- (textBoxRef === null || textBoxRef === void 0 ? void 0 : textBoxRef.current.getValue()) === p.searchText) {
78
+ if (!textBoxRef.current || textBoxRef.current.getValue() === p.searchText) {
80
79
  return;
81
80
  }
82
- textBoxRef === null || textBoxRef === void 0 ? void 0 : textBoxRef.current.setValue(p.searchText);
81
+ textBoxRef.current.setValue(p.searchText);
83
82
  p.setSearchText(p.searchText, true);
84
83
  }, [p]);
85
84
  return (react_1.default.createElement(Base, Object.assign({ "data-type": "search", className: p.className }, (0, dom_1.filterDataProps)(p)),
86
- react_1.default.createElement(TextEditStyled, { ref: textBoxRef, defaultValue: p.searchText, placeholder: p.placeholderText, defaultEditing: { focus: true }, singleLine: true, leftContent: react_1.default.createElement(MagnifyIcon, { onClick: () => { var _a; return p.setSearchText(((_a = textBoxRef === null || textBoxRef === void 0 ? void 0 : textBoxRef.current) === null || _a === void 0 ? void 0 : _a.getValue()) || '', true); } },
85
+ react_1.default.createElement(TextEditStyled, { ref: textBoxRef, defaultValue: p.searchText, placeholder: p.placeholderText, defaultEditing: { focus: true }, singleLine: true, leftContent: react_1.default.createElement(MagnifyIcon, { onClick: () => { var _a; return p.setSearchText(((_a = textBoxRef.current) === null || _a === void 0 ? void 0 : _a.getValue()) || '', true); } },
87
86
  react_1.default.createElement(icons_1.Magnify, null)), allowUndo: false, onClickOutsideWithNoValue: null, onSubmit: (v, enterPressed) => (0, debounce_1.debounce)(() => {
88
87
  p.setSearchText(v, enterPressed);
89
88
  }, { key: 'pagesearch', time: 200 }) }),
90
89
  p.searchText && (react_1.default.createElement(CrossIconStyled, { onClick: () => {
91
90
  var _a;
92
- (_a = textBoxRef === null || textBoxRef === void 0 ? void 0 : textBoxRef.current) === null || _a === void 0 ? void 0 : _a.setValue('');
91
+ (_a = textBoxRef.current) === null || _a === void 0 ? void 0 : _a.setValue('');
93
92
  p.setSearchText('', true);
94
93
  } }))));
95
94
  };
@@ -153,7 +153,11 @@ exports.TextEdit = (0, react_2.forwardRef)((p, ref) => {
153
153
  return (react_2.default.createElement(ValueBoxEdit, Object.assign({}, common_1.noDrag, { className: p.className, "data-editing": "true",
154
154
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
155
155
  ref: ref, tabIndex: -1, "data-nogrow": noGrow }, (0, dom_1.filterDataProps)(p)), (_b = p.leftContent) !== null && _b !== void 0 ? _b : null,
156
- react_2.default.createElement(Comp, { tabIndex: editing ? 0 : undefined, "data-editing": "true", "data-valuechange": valueChange.toString(),
156
+ react_2.default.createElement(Comp
157
+ // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
158
+ , {
159
+ // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
160
+ tabIndex: editing ? 0 : undefined, "data-editing": "true", "data-valuechange": valueChange.toString(),
157
161
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
158
162
  ref: taref, "data-type": "text", value: value, onChange: (v) => {
159
163
  setValue(v.currentTarget.value);
@@ -175,7 +179,7 @@ exports.TextEdit = (0, react_2.forwardRef)((p, ref) => {
175
179
  p.maxLength && (react_2.default.createElement(Right, { "data-singleline": singleLine },
176
180
  react_2.default.createElement(LengthBox_1.TextEditLengthBox, { min: value.length, max: p.maxLength }))),
177
181
  allowUndo && (react_2.default.createElement(Right, null,
178
- valueChange && (react_2.default.createElement(Icon, { style: common_2.iconLeft, onClick: () => valueChange && p.onSubmit(value, false) },
182
+ valueChange && (react_2.default.createElement(Icon, { style: common_2.iconLeft, onClick: () => p.onSubmit(value, false) },
179
183
  react_2.default.createElement(Save_1.Save, null))),
180
184
  (valueChange || editing !== !!defaultEditing) && (react_2.default.createElement(Icon, { style: Object.assign(Object.assign({}, common_2.iconRight), { fill: '#134563' }), onClick: () => {
181
185
  setEditing(!!defaultEditing);
@@ -58,7 +58,7 @@ const Timeline = ({ lineColour = '#ccc', items, onClick, maxCircleSize = 'min(5v
58
58
  if (p.checked) {
59
59
  cursor = '';
60
60
  }
61
- return (react_1.default.createElement(Item, { key: p.key, title: p === null || p === void 0 ? void 0 : p.title },
61
+ return (react_1.default.createElement(Item, { key: p.key, title: p.title },
62
62
  react_1.default.createElement(Icon_1.Icon, { style: {
63
63
  maxWidth: maxCircleSize,
64
64
  cursor,
@@ -30,13 +30,13 @@ const TimelineChart = ({ series, strokeWidth = 3, className, }) => {
30
30
  const xMax = Math.max(...xValues);
31
31
  const yMin = Math.min(...yValues);
32
32
  const yMax = Math.max(...yValues);
33
- const xScale = (x) => { var _a; return (_a = Math.ceil(width * ((x - xMin) / (xMax - xMin)))) !== null && _a !== void 0 ? _a : 0; };
33
+ const xScale = (x) => Math.ceil(width * ((x - xMin) / (xMax - xMin)));
34
34
  const yScale = (y) => {
35
35
  let ret = Math.ceil(height * ((yMax - y) / (yMax - yMin)));
36
36
  if (isNaN(ret)) {
37
37
  ret = y;
38
38
  }
39
- return ret !== null && ret !== void 0 ? ret : y;
39
+ return ret;
40
40
  };
41
41
  const getPathData = ({ data }) => {
42
42
  const pd1 = data
@@ -56,8 +56,8 @@ const TimelineChart = ({ series, strokeWidth = 3, className, }) => {
56
56
  react_1.default.createElement("title", null, title || label),
57
57
  react_1.default.createElement("path", { d: getPathData({ color, data, label, key }), fill: "none", stroke: color, strokeWidth: strokeWidth, onClick: () => onClick === null || onClick === void 0 ? void 0 : onClick(), style: { cursor: onClick ? 'pointer' : 'default' } }),
58
58
  label && (react_1.default.createElement(react_1.default.Fragment, null,
59
- react_1.default.createElement("text", { x: xScale((_a = data === null || data === void 0 ? void 0 : data[0]) === null || _a === void 0 ? void 0 : _a.x) + strokeWidth * 2, y: yScale((_b = data[data.length - 1]) === null || _b === void 0 ? void 0 : _b.y), fontSize: "12", textAnchor: "middle", dominantBaseline: "middle", stroke: "white", strokeWidth: '3px' }, label),
60
- react_1.default.createElement("text", { x: xScale((_c = data === null || data === void 0 ? void 0 : data[0]) === null || _c === void 0 ? void 0 : _c.x) + strokeWidth * 2, y: yScale((_d = data[data.length - 1]) === null || _d === void 0 ? void 0 : _d.y), fontSize: "12", textAnchor: "middle", dominantBaseline: "middle", fill: "black" }, label)))));
59
+ react_1.default.createElement("text", { x: xScale((_a = data[0]) === null || _a === void 0 ? void 0 : _a.x) + strokeWidth * 2, y: yScale((_b = data[data.length - 1]) === null || _b === void 0 ? void 0 : _b.y), fontSize: "12", textAnchor: "middle", dominantBaseline: "middle", stroke: "white", strokeWidth: '3px' }, label),
60
+ react_1.default.createElement("text", { x: xScale((_c = data[0]) === null || _c === void 0 ? void 0 : _c.x) + strokeWidth * 2, y: yScale((_d = data[data.length - 1]) === null || _d === void 0 ? void 0 : _d.y), fontSize: "12", textAnchor: "middle", dominantBaseline: "middle", fill: "black" }, label)))));
61
61
  }))));
62
62
  };
63
63
  exports.TimelineChart = TimelineChart;
@@ -94,13 +94,13 @@ const ProgressBarStyled = (0, styled_1.default)(ProgressBar_1.ProgressBar) `
94
94
  margin-top: 0.5rem;
95
95
  `;
96
96
  const Toast = ({ toast, close, style, }) => {
97
- var _a, _b, _c, _d, _e;
97
+ var _a, _b, _c, _d;
98
98
  let closeMs;
99
99
  if ((_a = toast.options) === null || _a === void 0 ? void 0 : _a.autoClose) {
100
- closeMs = (_b = toast.options) === null || _b === void 0 ? void 0 : _b.autoClose;
100
+ closeMs = toast.options.autoClose;
101
101
  }
102
- else if (((_c = toast.options) === null || _c === void 0 ? void 0 : _c.autoClose) === undefined) {
103
- if (((_d = toast === null || toast === void 0 ? void 0 : toast.options) === null || _d === void 0 ? void 0 : _d.appearance) === 'success') {
102
+ else if (((_b = toast.options) === null || _b === void 0 ? void 0 : _b.autoClose) === undefined) {
103
+ if (((_c = toast.options) === null || _c === void 0 ? void 0 : _c.appearance) === 'success') {
104
104
  closeMs = 5000;
105
105
  }
106
106
  else {
@@ -108,7 +108,7 @@ const Toast = ({ toast, close, style, }) => {
108
108
  }
109
109
  }
110
110
  let icon = react_1.default.createElement(Tick_1.Tick, null);
111
- switch ((_e = toast === null || toast === void 0 ? void 0 : toast.options) === null || _e === void 0 ? void 0 : _e.appearance) {
111
+ switch ((_d = toast.options) === null || _d === void 0 ? void 0 : _d.appearance) {
112
112
  case 'error': {
113
113
  icon = react_1.default.createElement(Cross_1.Cross, null);
114
114
  break;
@@ -2,7 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.toArray = exports.convertToRaw = void 0;
4
4
  const convertToRaw = ({ tnd: { data, pathDelimiter }, }) => {
5
- if (!data || data.length === 0) {
5
+ if (data.length === 0) {
6
6
  return { children: {}, size: 0, name: '', depth: 0 };
7
7
  }
8
8
  const dm = { size: 0, children: {}, name: '', depth: 0 };
@@ -12,9 +12,11 @@ const convertToRaw = ({ tnd: { data, pathDelimiter }, }) => {
12
12
  let a = 0;
13
13
  do {
14
14
  node.size += line.size;
15
+ // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
15
16
  if (names[a] === undefined) {
16
17
  break;
17
18
  }
19
+ // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
18
20
  if (!node.children[names[a]]) {
19
21
  node.children[names[a]] = {
20
22
  children: {},
@@ -49,6 +49,7 @@ const axiosHelper = (_a) => __awaiter(void 0, [_a], void 0, function* ({ verb, u
49
49
  }
50
50
  else if (verb === 'patch') {
51
51
  axiosV = axios_1.default.patch;
52
+ // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
52
53
  }
53
54
  else if (verb === 'delete') {
54
55
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
@@ -55,7 +55,7 @@ exports.setOpenApiCacheRaw = setOpenApiCacheRaw;
55
55
  * @returns undefined if no cache item
56
56
  */
57
57
  const callOpenApiCachedRaw = (p) => {
58
- var _a, _b, _c, _d, _e;
58
+ var _a, _b, _c, _d;
59
59
  const userPrefixedCacheKey = getCacheKey(p);
60
60
  if (!userPrefixedCacheKey) {
61
61
  return undefined;
@@ -64,13 +64,13 @@ const callOpenApiCachedRaw = (p) => {
64
64
  callOpenApiCache = new node_cache_1.default({ stdTTL: (_a = p.cacheTtl) !== null && _a !== void 0 ? _a : 120 });
65
65
  }
66
66
  //get ssr cache value
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
+ const ssrCached = (_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.data;
68
68
  //if we have ssr cache and there is no existing cache then set
69
69
  if (!callOpenApiCache.get(userPrefixedCacheKey) && ssrCached) {
70
70
  callOpenApiCache.set(userPrefixedCacheKey, ssrCached);
71
71
  }
72
72
  //return cached data, or ssr data if that has already expired (ttl <=0)
73
- const data = (_e = callOpenApiCache.get(userPrefixedCacheKey)) !== null && _e !== void 0 ? _e : ssrCached;
73
+ const data = (_d = callOpenApiCache.get(userPrefixedCacheKey)) !== null && _d !== void 0 ? _d : ssrCached;
74
74
  if (!data) {
75
75
  return undefined;
76
76
  }
@@ -24,7 +24,7 @@ function getIdTokenAuthHeaderRaw({ overrideAuth, }) {
24
24
  let idToken;
25
25
  //if override supplied will only use that and not refresh
26
26
  if (overrideAuth === null || overrideAuth === void 0 ? void 0 : overrideAuth.id_token) {
27
- idToken = overrideAuth === null || overrideAuth === void 0 ? void 0 : overrideAuth.id_token;
27
+ idToken = overrideAuth.id_token;
28
28
  }
29
29
  else {
30
30
  idToken = (0, cookie_1.getCookieString)({
@@ -46,20 +46,20 @@ exports.getIdTokenAuthHeaderRaw = getIdTokenAuthHeaderRaw;
46
46
  */
47
47
  function getIdTokenAuthHeader(_a) {
48
48
  return __awaiter(this, arguments, void 0, function* ({ overrideAuth, refreshToken, }) {
49
- var _b, _c;
49
+ var _b;
50
50
  let idToken = getIdTokenAuthHeaderRaw({ overrideAuth });
51
51
  //if we have a cookie token, can try to refresh
52
52
  if (idToken) {
53
53
  const updated = yield refreshToken();
54
54
  if ((_b = updated === null || updated === void 0 ? void 0 : updated.jwt) === null || _b === void 0 ? void 0 : _b.id_token) {
55
- idToken = (_c = updated === null || updated === void 0 ? void 0 : updated.jwt) === null || _c === void 0 ? void 0 : _c.id_token;
55
+ idToken = updated.jwt.id_token;
56
56
  }
57
57
  }
58
58
  return idToken;
59
59
  });
60
60
  }
61
61
  const callOpenApi = (p) => __awaiter(void 0, void 0, void 0, function* () {
62
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q;
62
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
63
63
  const { func, apiUrl, logout, newDefaultApi, headers } = p;
64
64
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
65
65
  let error;
@@ -113,9 +113,10 @@ const callOpenApi = (p) => __awaiter(void 0, void 0, void 0, function* () {
113
113
  (_d = ae.status) !== null && _d !== void 0 ? _d : '',
114
114
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
115
115
  (_g = (_f = (_e = ae.response) === null || _e === void 0 ? void 0 : _e.data) === null || _f === void 0 ? void 0 : _f.toString()) !== null && _g !== void 0 ? _g : '',
116
- (_k = (_j = (_h = ae.response) === null || _h === void 0 ? void 0 : _h.statusText) === null || _j === void 0 ? void 0 : _j.toString()) !== null && _k !== void 0 ? _k : '',
117
- (_o = (_m = (_l = ae.response) === null || _l === void 0 ? void 0 : _l.status) === null || _m === void 0 ? void 0 : _m.toString()) !== null && _o !== void 0 ? _o : '',
118
- (_q = (_p = ae.message) === null || _p === void 0 ? void 0 : _p.toString()) !== null && _q !== void 0 ? _q : '',
116
+ (_j = (_h = ae.response) === null || _h === void 0 ? void 0 : _h.statusText.toString()) !== null && _j !== void 0 ? _j : '',
117
+ (_l = (_k = ae.response) === null || _k === void 0 ? void 0 : _k.status.toString()) !== null && _l !== void 0 ? _l : '',
118
+ // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
119
+ (_m = ae.message.toString()) !== null && _m !== void 0 ? _m : '',
119
120
  ]
120
121
  .filter(array_1.notEmpty)
121
122
  .sort((a, b) => (a.length < b.length ? -1 : 1))
@@ -34,7 +34,7 @@ const apiResponseToAxiosResponse = (p) => __awaiter(void 0, void 0, void 0, func
34
34
  catch (e) {
35
35
  const er = e;
36
36
  //try and get body
37
- let statusText = er.statusText || (e === null || e === void 0 ? void 0 : e.stack) || '';
37
+ let statusText = er.statusText || e.stack || '';
38
38
  if (er.body) {
39
39
  try {
40
40
  const st = yield (0, stream_1.getStringFromStream)(er.body);
@@ -48,7 +48,9 @@ const apiResponseToAxiosResponse = (p) => __awaiter(void 0, void 0, void 0, func
48
48
  data: undefined,
49
49
  status: er.status,
50
50
  statusText,
51
- headers: er.headers &&
51
+ headers:
52
+ // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
53
+ er.headers &&
52
54
  (0, array_1.arrayToObject)(Object.entries(er.headers), (s) => s[0], (s) => s[1]),
53
55
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
54
56
  config: {},
@@ -22,13 +22,13 @@ function getCookieRawWrapper({ name, cookieDocument, defaultValue, parse: parseR
22
22
  };
23
23
  let raw = '';
24
24
  let currentCount = 0;
25
- // eslint-disable-next-line no-constant-condition
25
+ // eslint-disable-next-line no-constant-condition, @typescript-eslint/no-unnecessary-condition
26
26
  while (true) {
27
27
  const newv = (0, raw_1.getCookie)({
28
28
  name: name + currentCount,
29
29
  cookieDocument,
30
30
  });
31
- if (newv === undefined || newv === null) {
31
+ if (newv === undefined) {
32
32
  break;
33
33
  }
34
34
  raw += newv;
@@ -3,12 +3,12 @@
3
3
  * @param cookieString
4
4
  * @returns
5
5
  */
6
- export declare const getAllCookies: (cookieString?: string) => Record<string, string>;
6
+ export declare const getAllCookies: (cookieString?: string) => Partial<Record<string, string>>;
7
7
  /** get a cookie by name*/
8
8
  export declare const getCookie: ({ name, cookieDocument, }: {
9
9
  name: string;
10
10
  cookieDocument?: string | undefined;
11
- }) => string;
11
+ }) => string | undefined;
12
12
  /**
13
13
  * expiryDays <0 will delete
14
14
  * @param param0
@@ -9,6 +9,7 @@ const const_1 = require("./const");
9
9
  * @returns
10
10
  */
11
11
  const getAllCookies = (cookieString) => {
12
+ var _a;
12
13
  const cookieKeyValuePairs = {};
13
14
  if (!cookieString) {
14
15
  return cookieKeyValuePairs;
@@ -16,13 +17,13 @@ const getAllCookies = (cookieString) => {
16
17
  const cookieArr = cookieString.split(';');
17
18
  for (let i = 0; i < cookieArr.length; i++) {
18
19
  const cookieKeyValue = cookieArr[i].split('=');
19
- cookieKeyValuePairs[cookieKeyValue[0].trim()] = cookieKeyValue[1].trim();
20
+ cookieKeyValuePairs[cookieKeyValue[0].trim()] = (_a = cookieKeyValue[1]) === null || _a === void 0 ? void 0 : _a.trim();
20
21
  }
21
22
  return cookieKeyValuePairs;
22
23
  };
23
24
  exports.getAllCookies = getAllCookies;
24
25
  /** get a cookie by name*/
25
- const getCookie = ({ name, cookieDocument, }) => { var _a; return (_a = (0, exports.getAllCookies)(cookieDocument)) === null || _a === void 0 ? void 0 : _a[name]; };
26
+ const getCookie = ({ name, cookieDocument, }) => (0, exports.getAllCookies)(cookieDocument)[name];
26
27
  exports.getCookie = getCookie;
27
28
  /**
28
29
  * expiryDays <0 will delete
@@ -46,7 +47,7 @@ function wipeCookies(name) {
46
47
  return;
47
48
  }
48
49
  let currentCount = 0;
49
- // eslint-disable-next-line no-constant-condition
50
+ // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition, no-constant-condition
50
51
  while (true) {
51
52
  if ((0, exports.getCookie)({
52
53
  name: name + currentCount,
@@ -10,9 +10,6 @@ const plural_1 = require("./plural");
10
10
  * @returns
11
11
  */
12
12
  const dateDiffToString = (lowDate, highDate) => {
13
- if (!lowDate) {
14
- return '';
15
- }
16
13
  const d = (0, date_1.dateDiff)(lowDate, highDate !== null && highDate !== void 0 ? highDate : new Date());
17
14
  if (isNaN(d.totalYears)) {
18
15
  return '';
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.extractAttributes = void 0;
4
4
  const extractAttributes = ({ idName }) => {
5
5
  var _a;
6
- if (!((_a = document === null || document === void 0 ? void 0 : document.getElementById(idName)) === null || _a === void 0 ? void 0 : _a.attributes)) {
6
+ if (!((_a = document.getElementById(idName)) === null || _a === void 0 ? void 0 : _a.attributes)) {
7
7
  return {};
8
8
  }
9
9
  const ret = {};
@@ -1,5 +1,4 @@
1
1
  export * from './axiosHelper';
2
- export * from './browserHelpers';
3
2
  export * from './callOpenApi';
4
3
  export * from './cognito';
5
4
  export * from './cookie';
@@ -15,7 +15,6 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
17
  __exportStar(require("./axiosHelper"), exports);
18
- __exportStar(require("./browserHelpers"), exports);
19
18
  __exportStar(require("./callOpenApi"), exports);
20
19
  __exportStar(require("./cognito"), exports);
21
20
  __exportStar(require("./cookie"), exports);
@@ -71,7 +71,7 @@ const getServerReq = ({ pathname, query, headers, }) => {
71
71
  host: headers.host || 'testhost',
72
72
  pathname,
73
73
  });
74
- const parsedQuery = !query || Object.keys(query).length === 0 ? {} : (0, object_1.castStringlyObject)(query);
74
+ const parsedQuery = Object.keys(query).length === 0 ? {} : (0, object_1.castStringlyObject)(query);
75
75
  const ret = (0, exports.getClientOrServerReqHref)({
76
76
  url: !href ? undefined : new URL(href),
77
77
  query: parsedQuery,
@@ -24,7 +24,7 @@ delay, opt) {
24
24
  const res = savedCallback.current();
25
25
  if ((_a = opt === null || opt === void 0 ? void 0 : opt.determineEnd) === null || _a === void 0 ? void 0 : _a.call(opt, res)) {
26
26
  clearInterval(id);
27
- (_b = opt === null || opt === void 0 ? void 0 : opt.onEnd) === null || _b === void 0 ? void 0 : _b.call(opt);
27
+ (_b = opt.onEnd) === null || _b === void 0 ? void 0 : _b.call(opt);
28
28
  }
29
29
  }, delay);
30
30
  return () => {
@@ -7,7 +7,7 @@ const dom_1 = require("./dom");
7
7
  function useOnClickOutside(p, handler) {
8
8
  (0, react_1.useEffect)(() => {
9
9
  const listener = (event) => {
10
- var _a, _b;
10
+ var _a;
11
11
  const disabled = !p.disabled || typeof p.disabled === 'boolean'
12
12
  ? (_a = p.disabled) !== null && _a !== void 0 ? _a : false
13
13
  : p.disabled();
@@ -19,7 +19,7 @@ function useOnClickOutside(p, handler) {
19
19
  if (isRightMB) {
20
20
  return;
21
21
  }
22
- const el = (_b = p.ref) === null || _b === void 0 ? void 0 : _b.current;
22
+ const el = p.ref.current;
23
23
  if (!el) {
24
24
  return;
25
25
  }
package/package.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "0.0.678",
2
+ "version": "0.0.679",
3
3
  "name": "ag-common",
4
4
  "main": "./dist/index.js",
5
5
  "types": "./dist/index.d.ts",
@@ -1 +0,0 @@
1
- export declare function supportsWebp(): Promise<boolean>;
@@ -1,23 +0,0 @@
1
- "use strict";
2
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
- return new (P || (P = Promise))(function (resolve, reject) {
5
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
- step((generator = generator.apply(thisArg, _arguments || [])).next());
9
- });
10
- };
11
- Object.defineProperty(exports, "__esModule", { value: true });
12
- exports.supportsWebp = void 0;
13
- function supportsWebp() {
14
- return __awaiter(this, void 0, void 0, function* () {
15
- if (!window.createImageBitmap) {
16
- return false;
17
- }
18
- const webpData = 'data:image/webp;base64,UklGRh4AAABXRUJQVlA4TBEAAAAvAAAAAAfQ//73v/+BiOh/AAA=';
19
- const blob = yield fetch(webpData).then((r) => r.blob());
20
- return createImageBitmap(blob).then(() => true, () => false);
21
- });
22
- }
23
- exports.supportsWebp = supportsWebp;