ag-common 0.0.869 → 0.0.870
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/api.js +2 -0
- package/dist/api/helpers/dynamo/get.js +1 -1
- package/dist/api/helpers/enforceDynamoProvisionCap.js +2 -1
- package/dist/api/helpers/s3.d.ts +16 -0
- package/dist/api/helpers/s3.js +23 -0
- package/dist/api/types/aws.js +1 -0
- package/dist/common/helpers/array.js +1 -1
- package/dist/common/helpers/async.js +2 -0
- package/dist/common/helpers/csv.js +1 -0
- package/dist/common/helpers/date.js +1 -3
- package/dist/common/helpers/generator.js +3 -1
- package/dist/common/helpers/groupBy.js +2 -0
- package/dist/common/helpers/memo.js +2 -0
- package/dist/common/helpers/object.d.ts +2 -2
- package/dist/common/helpers/object.js +5 -2
- package/dist/common/helpers/string/json.js +1 -1
- package/dist/ui/components/shadcn/toast.js +2 -1
- package/package.json +4 -5
package/dist/api/helpers/api.js
CHANGED
|
@@ -26,6 +26,7 @@ const returnCode = (statusCode, body, extraHeaders, fullSiteUrl) => {
|
|
|
26
26
|
return {
|
|
27
27
|
headers,
|
|
28
28
|
statusCode,
|
|
29
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
29
30
|
body: (!body ? undefined : JSON.stringify(body, null, 2)),
|
|
30
31
|
};
|
|
31
32
|
};
|
|
@@ -38,6 +39,7 @@ exports.returnCode = returnCode;
|
|
|
38
39
|
*/
|
|
39
40
|
const stripPKs = (record, keepPk = true) => {
|
|
40
41
|
if (!record) {
|
|
42
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
41
43
|
return null;
|
|
42
44
|
}
|
|
43
45
|
// @ts-ignore
|
|
@@ -113,7 +113,7 @@ const getItemsDynamo = (params) => __awaiter(void 0, void 0, void 0, function* (
|
|
|
113
113
|
const allItems = [];
|
|
114
114
|
responses.forEach((result) => {
|
|
115
115
|
var _a, _b;
|
|
116
|
-
const items = (_b = (_a = result.Responses) === null || _a === void 0 ? void 0 : _a[params.tableName]) !== null && _b !== void 0 ? _b : [];
|
|
116
|
+
const items = ((_b = (_a = result.Responses) === null || _a === void 0 ? void 0 : _a[params.tableName]) !== null && _b !== void 0 ? _b : []);
|
|
117
117
|
allItems.push(...items);
|
|
118
118
|
});
|
|
119
119
|
return { data: allItems };
|
|
@@ -12,10 +12,11 @@ const extractSum = ({ str, regex }) => {
|
|
|
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, }) => {
|
|
15
|
-
if (
|
|
15
|
+
if (tables.length === 0) {
|
|
16
16
|
(0, log_1.warn)('error in dynamo FT enforce');
|
|
17
17
|
return;
|
|
18
18
|
}
|
|
19
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
19
20
|
const t = tables[0];
|
|
20
21
|
const s = (0, json_1.safeStringify)(t.node._children.Resource.node.scope);
|
|
21
22
|
const reads = extractSum({ str: s, regex: /readCapacityUnits.*/gim });
|
package/dist/api/helpers/s3.d.ts
CHANGED
|
@@ -109,3 +109,19 @@ export declare function getPresignedPostURL({ bucket, key, maxMb, }: {
|
|
|
109
109
|
fields: Record<string, string>;
|
|
110
110
|
};
|
|
111
111
|
}>;
|
|
112
|
+
/**
|
|
113
|
+
* Generate a presigned PUT URL for direct browser upload.
|
|
114
|
+
* Unlike getPresignedPostURL (which returns url + fields for multipart form),
|
|
115
|
+
* this returns a single URL for a simple PUT request.
|
|
116
|
+
*/
|
|
117
|
+
export declare function getPresignedPutUrl({ bucket, key, contentType, expiresIn, }: {
|
|
118
|
+
bucket: string;
|
|
119
|
+
key: string;
|
|
120
|
+
contentType: string;
|
|
121
|
+
/** seconds until URL expires. default 600 (10 minutes) */
|
|
122
|
+
expiresIn?: number;
|
|
123
|
+
}): Promise<{
|
|
124
|
+
error: string;
|
|
125
|
+
} | {
|
|
126
|
+
data: string;
|
|
127
|
+
}>;
|
package/dist/api/helpers/s3.js
CHANGED
|
@@ -26,8 +26,10 @@ exports.copyFile = exports.deleteFiles = exports.deleteFile = exports.putS3Objec
|
|
|
26
26
|
exports.getS3Objects = getS3Objects;
|
|
27
27
|
exports.listFiles = listFiles;
|
|
28
28
|
exports.getPresignedPostURL = getPresignedPostURL;
|
|
29
|
+
exports.getPresignedPutUrl = getPresignedPutUrl;
|
|
29
30
|
const client_s3_1 = require("@aws-sdk/client-s3");
|
|
30
31
|
const s3_presigned_post_1 = require("@aws-sdk/s3-presigned-post");
|
|
32
|
+
const s3_request_presigner_1 = require("@aws-sdk/s3-request-presigner");
|
|
31
33
|
const array_1 = require("../../common/helpers/array");
|
|
32
34
|
const log_1 = require("../../common/helpers/log");
|
|
33
35
|
const object_1 = require("../../common/helpers/object");
|
|
@@ -257,3 +259,24 @@ function getPresignedPostURL(_a) {
|
|
|
257
259
|
}
|
|
258
260
|
});
|
|
259
261
|
}
|
|
262
|
+
/**
|
|
263
|
+
* Generate a presigned PUT URL for direct browser upload.
|
|
264
|
+
* Unlike getPresignedPostURL (which returns url + fields for multipart form),
|
|
265
|
+
* this returns a single URL for a simple PUT request.
|
|
266
|
+
*/
|
|
267
|
+
function getPresignedPutUrl(_a) {
|
|
268
|
+
return __awaiter(this, arguments, void 0, function* ({ bucket, key, contentType, expiresIn = 600, }) {
|
|
269
|
+
try {
|
|
270
|
+
const command = new client_s3_1.PutObjectCommand({
|
|
271
|
+
Bucket: bucket,
|
|
272
|
+
Key: key,
|
|
273
|
+
ContentType: contentType,
|
|
274
|
+
});
|
|
275
|
+
const url = yield (0, s3_request_presigner_1.getSignedUrl)(s3, command, { expiresIn });
|
|
276
|
+
return { data: url };
|
|
277
|
+
}
|
|
278
|
+
catch (e) {
|
|
279
|
+
return { error: e.toString() };
|
|
280
|
+
}
|
|
281
|
+
});
|
|
282
|
+
}
|
package/dist/api/types/aws.js
CHANGED
|
@@ -28,6 +28,7 @@ function asyncForEach(array, callback, opt) {
|
|
|
28
28
|
rem = rest;
|
|
29
29
|
const proms = part.map((p, i) => callback(p, start + i, array));
|
|
30
30
|
start += part.length;
|
|
31
|
+
// eslint-disable-next-line no-await-in-loop
|
|
31
32
|
yield Promise.all(proms);
|
|
32
33
|
}
|
|
33
34
|
});
|
|
@@ -50,6 +51,7 @@ function asyncMap(array, callback, opt) {
|
|
|
50
51
|
rem = rest;
|
|
51
52
|
const proms = part.map((p, i) => callback(p, start + i, array));
|
|
52
53
|
start += part.length;
|
|
54
|
+
// eslint-disable-next-line no-await-in-loop
|
|
53
55
|
const res = yield Promise.all(proms);
|
|
54
56
|
ret.push(...res);
|
|
55
57
|
}
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.loadCsvAsJson = loadCsvAsJson;
|
|
4
4
|
const math_1 = require("./math");
|
|
5
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
5
6
|
function loadCsvAsJson(p) {
|
|
6
7
|
const lines = p.fileData.split(/[\r]?\n/);
|
|
7
8
|
let sep = ',';
|
|
@@ -54,9 +54,7 @@ exports.CSharpToJs = CSharpToJs;
|
|
|
54
54
|
*/
|
|
55
55
|
const dateTimeToNearestMinute = (minutes, date) => {
|
|
56
56
|
const coeff = 1000 * 60 * minutes;
|
|
57
|
-
|
|
58
|
-
date = new Date();
|
|
59
|
-
}
|
|
57
|
+
date !== null && date !== void 0 ? date : (date = new Date());
|
|
60
58
|
const rounded = new Date(Math.round(date.getTime() / coeff) * coeff);
|
|
61
59
|
return rounded;
|
|
62
60
|
};
|
|
@@ -14,10 +14,12 @@ function runGenerator(iter, partialRun) {
|
|
|
14
14
|
return __awaiter(this, void 0, void 0, function* () {
|
|
15
15
|
let curr;
|
|
16
16
|
do {
|
|
17
|
+
// eslint-disable-next-line no-await-in-loop
|
|
17
18
|
curr = yield iter.next();
|
|
18
|
-
if (
|
|
19
|
+
if (curr.value.length === 0) {
|
|
19
20
|
return;
|
|
20
21
|
}
|
|
22
|
+
// eslint-disable-next-line no-await-in-loop
|
|
21
23
|
yield partialRun(curr.value);
|
|
22
24
|
} while (!curr.done);
|
|
23
25
|
});
|
|
@@ -12,6 +12,7 @@ function groupBy(arr, getKey) {
|
|
|
12
12
|
const ret = {};
|
|
13
13
|
arr.forEach((item) => {
|
|
14
14
|
const key = getKey(item);
|
|
15
|
+
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
|
|
15
16
|
if (!ret[key]) {
|
|
16
17
|
ret[key] = [];
|
|
17
18
|
}
|
|
@@ -43,6 +44,7 @@ function groupByTwice(arr, getKey, getSubKey) {
|
|
|
43
44
|
arr.forEach((item) => {
|
|
44
45
|
const key = getKey(item);
|
|
45
46
|
const subkey = getSubKey(item);
|
|
47
|
+
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
|
|
46
48
|
if (!ret[key]) {
|
|
47
49
|
ret[key] = {};
|
|
48
50
|
}
|
|
@@ -2,7 +2,9 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.memo = memo;
|
|
4
4
|
const hashCode_1 = require("./hashCode");
|
|
5
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
5
6
|
const memoData = {};
|
|
7
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
6
8
|
function memo(func, ...args) {
|
|
7
9
|
const hc = (0, hashCode_1.hashCode)(JSON.stringify(args));
|
|
8
10
|
if (!memoData[hc]) {
|
|
@@ -27,7 +27,7 @@ export declare const objectAlphaSort: <T>(object: T, depthLeft?: number) => T;
|
|
|
27
27
|
* @param entries Could be URLSearchParams
|
|
28
28
|
* @returns
|
|
29
29
|
*/
|
|
30
|
-
export declare function paramsToObject(entries:
|
|
30
|
+
export declare function paramsToObject(entries: Iterable<[string, string]>): Record<string, string>;
|
|
31
31
|
/**
|
|
32
32
|
* stringify an object of key values. Could be used to stringify a querystring url
|
|
33
33
|
* @param obj
|
|
@@ -66,5 +66,5 @@ export declare const removeUndefValuesFromObjectAdditional: <T>(orig: Record<str
|
|
|
66
66
|
* @returns
|
|
67
67
|
*/
|
|
68
68
|
export declare const castStringlyObject: (orig: Record<string, string | string[] | undefined>) => Record<string, string>;
|
|
69
|
-
export declare const isObject: (o:
|
|
69
|
+
export declare const isObject: (o: unknown) => unknown;
|
|
70
70
|
export declare const copy: <T>(v: T) => T;
|
|
@@ -35,6 +35,7 @@ const objectKeysToLowerCase = (origObj) => {
|
|
|
35
35
|
}
|
|
36
36
|
return Object.keys(origObj).reduce((newObj, key) => {
|
|
37
37
|
const val = origObj[key];
|
|
38
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
38
39
|
const newVal = typeof val === 'object'
|
|
39
40
|
? (0, exports.objectKeysToLowerCase)(val)
|
|
40
41
|
: val;
|
|
@@ -67,13 +68,14 @@ const objectAlphaSort = (object, depthLeft = -1) => {
|
|
|
67
68
|
return object;
|
|
68
69
|
}
|
|
69
70
|
if (object !== null && typeof object === 'object') {
|
|
70
|
-
return Object.keys(object)
|
|
71
|
+
return (Object.keys(object)
|
|
71
72
|
.sort((a, b) => (a.toLowerCase() < b.toLowerCase() ? -1 : 1))
|
|
73
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
72
74
|
.reduce((result, key) => {
|
|
73
75
|
//@ts-ignore
|
|
74
76
|
result[key] = (0, exports.objectAlphaSort)(object[key], depthLeft - 1);
|
|
75
77
|
return result;
|
|
76
|
-
}, {});
|
|
78
|
+
}, {}));
|
|
77
79
|
}
|
|
78
80
|
else if (Array.isArray(object)) {
|
|
79
81
|
//@ts-ignore
|
|
@@ -152,6 +154,7 @@ const removeUndefValuesFromObject = (orig) => {
|
|
|
152
154
|
const ret = {};
|
|
153
155
|
Object.entries(orig).forEach(([k, v]) => {
|
|
154
156
|
if (v !== null && v !== undefined) {
|
|
157
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
155
158
|
ret[k] = v;
|
|
156
159
|
}
|
|
157
160
|
});
|
|
@@ -14,7 +14,7 @@ const safeStringify = (obj, indent = 2) => {
|
|
|
14
14
|
? undefined // Duplicate reference found, discard key
|
|
15
15
|
: cache.push(value) && value // Store value in our collection
|
|
16
16
|
: value, indent);
|
|
17
|
-
cache =
|
|
17
|
+
cache = [];
|
|
18
18
|
return retVal;
|
|
19
19
|
};
|
|
20
20
|
exports.safeStringify = safeStringify;
|
|
@@ -68,8 +68,9 @@ const ToastIcon = ({ type }) => {
|
|
|
68
68
|
}
|
|
69
69
|
};
|
|
70
70
|
const ToastItem = ({ toast }) => {
|
|
71
|
+
var _a;
|
|
71
72
|
const [isPaused, setIsPaused] = (0, react_2.useState)(false);
|
|
72
|
-
const remainingTime = (0, react_2.useRef)(toast.options.duration
|
|
73
|
+
const remainingTime = (0, react_2.useRef)((_a = toast.options.duration) !== null && _a !== void 0 ? _a : 0);
|
|
73
74
|
const startTime = (0, react_2.useRef)(0);
|
|
74
75
|
const timerId = (0, react_2.useRef)(null);
|
|
75
76
|
(0, react_2.useEffect)(() => {
|
package/package.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"version": "0.0.
|
|
2
|
+
"version": "0.0.870",
|
|
3
3
|
"name": "ag-common",
|
|
4
4
|
"main": "./dist/index.js",
|
|
5
5
|
"types": "./dist/index.d.ts",
|
|
@@ -36,6 +36,7 @@
|
|
|
36
36
|
"@aws-sdk/client-sts": "^3.983.0",
|
|
37
37
|
"@aws-sdk/lib-dynamodb": "^3.983.0",
|
|
38
38
|
"@aws-sdk/s3-presigned-post": "^3.983.0",
|
|
39
|
+
"@aws-sdk/s3-request-presigner": "^3.983.0",
|
|
39
40
|
"@azure/cosmos": "^4.9.1",
|
|
40
41
|
"@google/genai": "^1.40.0",
|
|
41
42
|
"@radix-ui/react-accordion": "^1.2.12",
|
|
@@ -83,10 +84,8 @@
|
|
|
83
84
|
],
|
|
84
85
|
"scripts": {
|
|
85
86
|
"preinstall": "npx only-allow pnpm",
|
|
86
|
-
"format": "eslint src --fix && eslint stories --fix",
|
|
87
|
-
"lint
|
|
88
|
-
"lint:eslint": "eslint src",
|
|
89
|
-
"lint": "pnpm run /^lint:/",
|
|
87
|
+
"format": "eslint src --fix && eslint stories --fix && tsc --noEmit",
|
|
88
|
+
"lint": "eslint src && tsc --noEmit",
|
|
90
89
|
"build": "rimraf dist && tsc -p tsconfig.build.json",
|
|
91
90
|
"start": "cross-env BROWSER=none cross-env storybook dev -p 6006",
|
|
92
91
|
"build-storybook": "storybook build -o docs --quiet",
|