ag-common 0.0.721 → 0.0.723

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.
@@ -30,11 +30,13 @@ export declare function getS3Objects({ bucket, keys, }: {
30
30
  data: IS3Object;
31
31
  error?: undefined;
32
32
  }, void, unknown>;
33
- export declare const putS3Object: ({ Body, Bucket, Key, ContentType, }: {
33
+ export declare const putS3Object: ({ Body, Bucket, Key, ContentType, CacheControl, }: {
34
34
  ContentType?: string;
35
35
  Body: string | Blob | Buffer;
36
36
  Bucket: string;
37
37
  Key: string;
38
+ /** default public, max-age=300 */
39
+ CacheControl?: string;
38
40
  }) => Promise<{
39
41
  error?: string;
40
42
  }>;
@@ -27,6 +27,7 @@ const client_s3_1 = require("@aws-sdk/client-s3");
27
27
  const s3_presigned_post_1 = require("@aws-sdk/s3-presigned-post");
28
28
  const array_1 = require("../../common/helpers/array");
29
29
  const log_1 = require("../../common/helpers/log");
30
+ const object_1 = require("../../common/helpers/object");
30
31
  const setS3 = (region) => {
31
32
  const raw = new client_s3_1.S3Client({ region });
32
33
  return raw;
@@ -73,9 +74,9 @@ function getS3Objects(_a) {
73
74
  });
74
75
  }
75
76
  exports.getS3Objects = getS3Objects;
76
- const putS3Object = (_b) => __awaiter(void 0, [_b], void 0, function* ({ Body, Bucket, Key, ContentType, }) {
77
+ const putS3Object = (_b) => __awaiter(void 0, [_b], void 0, function* ({ Body, Bucket, Key, ContentType, CacheControl = 'public, max-age=300', }) {
77
78
  try {
78
- yield exports.s3.send(new client_s3_1.PutObjectCommand({ Body, Bucket, Key, ContentType }));
79
+ yield exports.s3.send(new client_s3_1.PutObjectCommand({ Body, Bucket, Key, ContentType, CacheControl }));
79
80
  return {};
80
81
  }
81
82
  catch (e) {
@@ -191,7 +192,7 @@ function getPresignedPostURL(_a) {
191
192
  ['starts-with', '$Content-Type', 'image/'],
192
193
  ],
193
194
  });
194
- const fields = JSON.parse(JSON.stringify(ps.fields));
195
+ const fields = (0, object_1.copy)(ps.fields);
195
196
  return { data: { fields, url: ps.url } };
196
197
  }
197
198
  catch (e) {
@@ -40,7 +40,7 @@ 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.groups));
43
+ const pathParams = (re === null || re === void 0 ? void 0 : re.groups) && (0, object_1.copy)(re.groups);
44
44
  return { operation, pathParams };
45
45
  };
46
46
  function validateOpenApi(_a) {
@@ -65,3 +65,4 @@ export declare const removeUndefValuesFromObjectAdditional: <T>(orig: Record<str
65
65
  */
66
66
  export declare const castStringlyObject: (orig: Record<string, string | string[] | undefined>) => Record<string, string>;
67
67
  export declare const isObject: (o: any) => any;
68
+ export declare const copy: <T>(v: T) => T;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.isObject = exports.castStringlyObject = exports.removeUndefValuesFromObjectAdditional = exports.removeUndefValuesFromObject = exports.filterObject = exports.castObject = exports.objectToString = exports.paramsToObject = exports.objectAlphaSort = exports.objectToArray = exports.getObjectKeysAsNumber = exports.objectKeysToLowerCase = exports.isJson = exports.tryJsonParse = void 0;
3
+ exports.copy = exports.isObject = exports.castStringlyObject = exports.removeUndefValuesFromObjectAdditional = exports.removeUndefValuesFromObject = exports.filterObject = exports.castObject = exports.objectToString = exports.paramsToObject = exports.objectAlphaSort = exports.objectToArray = exports.getObjectKeysAsNumber = exports.objectKeysToLowerCase = exports.isJson = exports.tryJsonParse = void 0;
4
4
  const tryJsonParse = (str, defaultValue) => {
5
5
  if (!str) {
6
6
  return null;
@@ -193,3 +193,5 @@ exports.castStringlyObject = castStringlyObject;
193
193
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
194
194
  const isObject = (o) => o && typeof o === 'object' && !Array.isArray(o);
195
195
  exports.isObject = isObject;
196
+ const copy = (v) => JSON.parse(JSON.stringify(v));
197
+ exports.copy = copy;
@@ -3,11 +3,12 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.getLegendItems = void 0;
4
4
  const array_1 = require("../../../common/helpers/array");
5
5
  const math_1 = require("../../../common/helpers/math");
6
+ const object_1 = require("../../../common/helpers/object");
6
7
  const getLegendItems = ({ data, selectedKey, }) => {
7
8
  const min = data.total * 0.1;
8
9
  const shownResults = 4;
9
10
  const part = (0, array_1.take)(data.values.filter((r) => r.value > min), shownResults).part;
10
- const rest = JSON.parse(JSON.stringify(data.values)).filter((r) => !part.find((p) => p.name === r.name));
11
+ const rest = (0, object_1.copy)(data.values).filter((r) => !part.find((p) => p.name === r.name));
11
12
  //if we want to ensure this value exists in the returned results
12
13
  if (selectedKey) {
13
14
  const pi = part.findIndex((r) => r.name === selectedKey);
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.getLegendItems = void 0;
4
4
  const array_1 = require("../../../common/helpers/array");
5
5
  const math_1 = require("../../../common/helpers/math");
6
+ const object_1 = require("../../../common/helpers/object");
6
7
  const shownResults = 4;
7
8
  const getTopItems = ({ data, colours, }) => {
8
9
  const val = {};
@@ -41,7 +42,7 @@ const getLegendItems = (p) => {
41
42
  let rest = [];
42
43
  if (part.length > shownResults) {
43
44
  part = (0, array_1.take)(part.filter((r) => r.y > min), shownResults).part;
44
- rest = JSON.parse(JSON.stringify(values)).filter((r) => !part.find((p) => p.name === r.name));
45
+ rest = (0, object_1.copy)(values).filter((r) => !part.find((p) => p.name === r.name));
45
46
  }
46
47
  const restTotal = (0, math_1.sumArray)(rest.map((s) => s.y));
47
48
  return { part, rest, restTotal, total };
package/package.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "0.0.721",
2
+ "version": "0.0.723",
3
3
  "name": "ag-common",
4
4
  "main": "./dist/index.js",
5
5
  "types": "./dist/index.d.ts",