ag-common 0.0.732 → 0.0.735
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/aws.js +1 -1
- package/dist/api/helpers/dynamo/delete.d.ts +13 -0
- package/dist/api/helpers/dynamo/delete.js +94 -0
- package/dist/api/helpers/dynamo/get.d.ts +30 -0
- package/dist/api/helpers/dynamo/get.js +229 -0
- package/dist/api/helpers/dynamo/index.d.ts +50 -0
- package/dist/api/helpers/dynamo/index.js +66 -0
- package/dist/api/helpers/dynamo/set.d.ts +18 -0
- package/dist/api/helpers/dynamo/set.js +72 -0
- package/dist/api/helpers/dynamo/types.d.ts +43 -0
- package/dist/api/helpers/dynamo/types.js +5 -0
- package/dist/api/helpers/s3.d.ts +9 -1
- package/dist/api/helpers/s3.js +39 -5
- package/dist/api/helpers/withRetry.js +3 -3
- package/dist/api/index.d.ts +1 -1
- package/dist/api/types/index.d.ts +3 -1
- package/dist/common/helpers/array.d.ts +13 -1
- package/dist/common/helpers/binary.d.ts +2 -2
- package/dist/common/helpers/date.d.ts +3 -1
- package/dist/common/helpers/object.d.ts +3 -1
- package/dist/common/helpers/stream.js +1 -1
- package/dist/ui/components/BorderGradient/index.js +2 -1
- package/dist/ui/helpers/cookie/get.js +1 -1
- package/dist/ui/helpers/cookie/raw.js +1 -1
- package/package.json +48 -45
- package/dist/api/helpers/dynamo.d.ts +0 -146
- package/dist/api/helpers/dynamo.js +0 -370
package/dist/api/helpers/s3.js
CHANGED
|
@@ -22,7 +22,7 @@ var __asyncGenerator = (this && this.__asyncGenerator) || function (thisArg, _ar
|
|
|
22
22
|
function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); }
|
|
23
23
|
};
|
|
24
24
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
25
|
-
exports.copyFile = exports.deleteFiles = exports.deleteFile = exports.putS3Object = exports.getS3Object = exports.s3 = exports.setS3 = void 0;
|
|
25
|
+
exports.copyFile = exports.deleteFiles = exports.deleteFile = exports.putS3Object = exports.getS3Object = exports.s3 = exports.setS3 = exports.createStorageClient = void 0;
|
|
26
26
|
exports.getS3Objects = getS3Objects;
|
|
27
27
|
exports.listFiles = listFiles;
|
|
28
28
|
exports.getPresignedPostURL = getPresignedPostURL;
|
|
@@ -31,12 +31,46 @@ const s3_presigned_post_1 = require("@aws-sdk/s3-presigned-post");
|
|
|
31
31
|
const array_1 = require("../../common/helpers/array");
|
|
32
32
|
const log_1 = require("../../common/helpers/log");
|
|
33
33
|
const object_1 = require("../../common/helpers/object");
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
34
|
+
// Cache for memoization
|
|
35
|
+
const clientCache = new Map();
|
|
36
|
+
const getCacheKey = (config) => {
|
|
37
|
+
return JSON.stringify({
|
|
38
|
+
provider: config.provider,
|
|
39
|
+
region: config.region,
|
|
40
|
+
endpoint: config.endpoint,
|
|
41
|
+
accountId: config.accountId,
|
|
42
|
+
});
|
|
37
43
|
};
|
|
44
|
+
const createStorageClient = (config) => {
|
|
45
|
+
const cacheKey = getCacheKey(config);
|
|
46
|
+
const cachedClient = clientCache.get(cacheKey);
|
|
47
|
+
if (cachedClient) {
|
|
48
|
+
return cachedClient;
|
|
49
|
+
}
|
|
50
|
+
const baseConfig = {
|
|
51
|
+
region: config.region,
|
|
52
|
+
};
|
|
53
|
+
let client;
|
|
54
|
+
if (config.provider === 'r2') {
|
|
55
|
+
const accountId = config.accountId || process.env.CLOUDFLARE_ACCOUNT_ID;
|
|
56
|
+
if (!accountId) {
|
|
57
|
+
throw new Error('Account ID is required for R2. Set CLOUDFLARE_ACCOUNT_ID env var or provide accountId in config');
|
|
58
|
+
}
|
|
59
|
+
client = new client_s3_1.S3Client(Object.assign(Object.assign({}, baseConfig), { endpoint: `https://${accountId}.r2.cloudflarestorage.com`, forcePathStyle: true }));
|
|
60
|
+
}
|
|
61
|
+
else {
|
|
62
|
+
client = new client_s3_1.S3Client(baseConfig);
|
|
63
|
+
}
|
|
64
|
+
clientCache.set(cacheKey, client);
|
|
65
|
+
return client;
|
|
66
|
+
};
|
|
67
|
+
exports.createStorageClient = createStorageClient;
|
|
68
|
+
const setS3 = (config) => (0, exports.createStorageClient)(config);
|
|
38
69
|
exports.setS3 = setS3;
|
|
39
|
-
exports.s3 = (0, exports.setS3)(
|
|
70
|
+
exports.s3 = (0, exports.setS3)({
|
|
71
|
+
provider: 's3',
|
|
72
|
+
region: 'ap-southeast-2',
|
|
73
|
+
});
|
|
40
74
|
const getS3Object = (_a) => __awaiter(void 0, [_a], void 0, function* ({ fileurl: { Bucket, Key }, }) {
|
|
41
75
|
try {
|
|
42
76
|
const r = yield exports.s3.send(new client_s3_1.GetObjectCommand({ Bucket, Key }));
|
|
@@ -14,8 +14,8 @@ const log_1 = require("../../common/helpers/log");
|
|
|
14
14
|
const sleep_1 = require("../../common/helpers/sleep");
|
|
15
15
|
const withRetry = (operation, operationName, opt) => __awaiter(void 0, void 0, void 0, function* () {
|
|
16
16
|
let retryCount = 0;
|
|
17
|
-
|
|
18
|
-
|
|
17
|
+
const baseDelay = 2000;
|
|
18
|
+
const { maxRetries = 3 } = opt !== null && opt !== void 0 ? opt : {};
|
|
19
19
|
// eslint-disable-next-line
|
|
20
20
|
while (true) {
|
|
21
21
|
try {
|
|
@@ -32,7 +32,7 @@ const withRetry = (operation, operationName, opt) => __awaiter(void 0, void 0, v
|
|
|
32
32
|
(0, log_1.warn)(`${operationName}: Max retries exceeded`);
|
|
33
33
|
throw error;
|
|
34
34
|
}
|
|
35
|
-
const delay = baseDelay *
|
|
35
|
+
const delay = baseDelay + retryCount * 1000;
|
|
36
36
|
(0, log_1.warn)(`${operationName}: Throttled. Retry ${retryCount}. Sleeping for ${delay}ms`);
|
|
37
37
|
yield (0, sleep_1.sleep)(delay);
|
|
38
38
|
continue;
|
package/dist/api/index.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export * from './helpers';
|
|
2
|
-
export type * from './types';
|
|
2
|
+
export type * from './types/index';
|
|
@@ -1,4 +1,16 @@
|
|
|
1
|
-
export declare const arrayToObject: <TIn, Indexer extends string | number, TOut>(
|
|
1
|
+
export declare const arrayToObject: <TIn, Indexer extends string | number, TOut>(
|
|
2
|
+
/**
|
|
3
|
+
* array items
|
|
4
|
+
*/
|
|
5
|
+
arr: TIn[],
|
|
6
|
+
/**
|
|
7
|
+
* from an array item, get the indexer
|
|
8
|
+
*/
|
|
9
|
+
keyF: (a: TIn) => Indexer,
|
|
10
|
+
/**
|
|
11
|
+
* from an array item, return the new value
|
|
12
|
+
*/
|
|
13
|
+
valueF: (a: TIn) => TOut) => { [a in Indexer]: TOut; };
|
|
2
14
|
export declare const flat: <T>(arr: T[][]) => T[];
|
|
3
15
|
export declare const take: <T>(array: T[], num: number) => {
|
|
4
16
|
part: T[];
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Buffer } from 'buffer';
|
|
2
|
-
export declare const toBuffer: (ab: ArrayBuffer) => Buffer<
|
|
2
|
+
export declare const toBuffer: (ab: ArrayBuffer) => Buffer<ArrayBuffer>;
|
|
3
3
|
export declare function bufferToArrayBuffer(buffer: Buffer): ArrayBuffer;
|
|
4
4
|
export declare function b64ToArrayBuffer(base64: string): ArrayBuffer;
|
|
5
5
|
/**
|
|
@@ -13,4 +13,4 @@ export declare function arrayBufferToBase64(buffer: ArrayBuffer): string;
|
|
|
13
13
|
* @param raw
|
|
14
14
|
* @returns
|
|
15
15
|
*/
|
|
16
|
-
export declare const base64ToBinary: (raw: string) => Buffer<
|
|
16
|
+
export declare const base64ToBinary: (raw: string) => Buffer<ArrayBuffer>;
|
|
@@ -37,7 +37,9 @@ export interface IUtcDateParams {
|
|
|
37
37
|
minutes: number;
|
|
38
38
|
seconds: number;
|
|
39
39
|
}
|
|
40
|
-
export declare const getUtcDateTime: (
|
|
40
|
+
export declare const getUtcDateTime: (
|
|
41
|
+
/** if true will 0 H,M,S */
|
|
42
|
+
skipTime?: boolean) => {
|
|
41
43
|
ticks: number;
|
|
42
44
|
};
|
|
43
45
|
export declare const toMs: ({ day, hours, minutes, month, seconds, year, }: IUtcDateParams) => number;
|
|
@@ -57,7 +57,9 @@ export declare const filterObject: <TA extends Record<string | number, TB>, TB>(
|
|
|
57
57
|
/** remove key values from an object where the value is null or undefined or other specific passed in values */
|
|
58
58
|
export declare const removeUndefValuesFromObject: <TA>(orig: Record<string, TA>) => Record<string, TA extends null | undefined ? never : TA>;
|
|
59
59
|
/** remove key values from an object where the value is null or undefined or other specific passed in values */
|
|
60
|
-
export declare const removeUndefValuesFromObjectAdditional: <T>(orig: Record<string, T>,
|
|
60
|
+
export declare const removeUndefValuesFromObjectAdditional: <T>(orig: Record<string, T>,
|
|
61
|
+
/** other than null or undefined */
|
|
62
|
+
...additionalRemoves: T[]) => Record<string, T>;
|
|
61
63
|
/**
|
|
62
64
|
* cast Record<string,string[]|string> to Record<string,string>. can be used for querystring params
|
|
63
65
|
* @param orig
|
|
@@ -17,7 +17,7 @@ function getStringFromStream(stream) {
|
|
|
17
17
|
const reader = stream.getReader();
|
|
18
18
|
let result = '';
|
|
19
19
|
try {
|
|
20
|
-
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
|
|
20
|
+
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
|
|
21
21
|
while (true) {
|
|
22
22
|
const { done, value } = yield reader.read();
|
|
23
23
|
if (done)
|
|
@@ -15,7 +15,8 @@ const BGcss = (0, react_1.css) `
|
|
|
15
15
|
display: flex;
|
|
16
16
|
border: 0;
|
|
17
17
|
padding: 3px;
|
|
18
|
-
background-image:
|
|
18
|
+
background-image:
|
|
19
|
+
linear-gradient(white, white),
|
|
19
20
|
linear-gradient(to bottom right, var(--left), var(--right));
|
|
20
21
|
background-origin: border-box;
|
|
21
22
|
background-clip: content-box, border-box;
|
|
@@ -23,7 +23,7 @@ function getCookieRawWrapper({ name, cookieDocument, defaultValue, parse: parseR
|
|
|
23
23
|
};
|
|
24
24
|
let raw = '';
|
|
25
25
|
let currentCount = 0;
|
|
26
|
-
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
|
|
26
|
+
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
|
|
27
27
|
while (true) {
|
|
28
28
|
const newv = (0, raw_1.getCookie)({
|
|
29
29
|
name: name + currentCount,
|
|
@@ -48,7 +48,7 @@ function wipeCookies(name) {
|
|
|
48
48
|
return;
|
|
49
49
|
}
|
|
50
50
|
let currentCount = 0;
|
|
51
|
-
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
|
|
51
|
+
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
|
|
52
52
|
while (true) {
|
|
53
53
|
if ((0, exports.getCookie)({
|
|
54
54
|
name: name + currentCount,
|
package/package.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"version": "0.0.
|
|
2
|
+
"version": "0.0.735",
|
|
3
3
|
"name": "ag-common",
|
|
4
4
|
"main": "./dist/index.js",
|
|
5
5
|
"types": "./dist/index.d.ts",
|
|
@@ -18,53 +18,56 @@
|
|
|
18
18
|
"test": "globstar -- node --import tsx --test \"src/**/*.test.ts\""
|
|
19
19
|
},
|
|
20
20
|
"dependencies": {
|
|
21
|
-
"@aws-sdk/client-dynamodb": "3.
|
|
22
|
-
"@aws-sdk/client-s3": "3.
|
|
23
|
-
"@aws-sdk/client-ses": "3.
|
|
24
|
-
"@aws-sdk/client-sqs": "3.
|
|
25
|
-
"@aws-sdk/client-sts": "3.
|
|
26
|
-
"@aws-sdk/lib-dynamodb": "3.
|
|
27
|
-
"@aws-sdk/s3-presigned-post": "3.
|
|
28
|
-
"@aws-sdk/util-dynamodb": "3.
|
|
29
|
-
"aws-cdk-lib": "2.
|
|
30
|
-
"axios": "1.
|
|
31
|
-
"buffer": "6.0.3",
|
|
32
|
-
"constructs": "10.4.2",
|
|
33
|
-
"jsonwebtoken": "9.0.2",
|
|
34
|
-
"jwks-rsa": "3.
|
|
35
|
-
"node-cache": "5.1.2",
|
|
36
|
-
"openapi-request-validator": "12.1.3",
|
|
37
|
-
"react": "19.
|
|
38
|
-
"react-dom": "19.
|
|
39
|
-
"typescript": "5.
|
|
21
|
+
"@aws-sdk/client-dynamodb": "^3.788.0",
|
|
22
|
+
"@aws-sdk/client-s3": "^3.787.0",
|
|
23
|
+
"@aws-sdk/client-ses": "^3.787.0",
|
|
24
|
+
"@aws-sdk/client-sqs": "^3.787.0",
|
|
25
|
+
"@aws-sdk/client-sts": "^3.787.0",
|
|
26
|
+
"@aws-sdk/lib-dynamodb": "^3.789.0",
|
|
27
|
+
"@aws-sdk/s3-presigned-post": "^3.787.0",
|
|
28
|
+
"@aws-sdk/util-dynamodb": "^3.788.0",
|
|
29
|
+
"aws-cdk-lib": "^2.189.1",
|
|
30
|
+
"axios": "^1.8.4",
|
|
31
|
+
"buffer": "^6.0.3",
|
|
32
|
+
"constructs": "^10.4.2",
|
|
33
|
+
"jsonwebtoken": "^9.0.2",
|
|
34
|
+
"jwks-rsa": "^3.2.0",
|
|
35
|
+
"node-cache": "^5.1.2",
|
|
36
|
+
"openapi-request-validator": "^12.1.3",
|
|
37
|
+
"react": "^19.1.0",
|
|
38
|
+
"react-dom": "^19.1.0",
|
|
39
|
+
"typescript": "^5.8.3"
|
|
40
40
|
},
|
|
41
41
|
"devDependencies": {
|
|
42
|
-
"@babel/core": "7.26.
|
|
43
|
-
"@babel/preset-typescript": "7.
|
|
44
|
-
"@babel/types": "7.
|
|
45
|
-
"@emotion/react": "11.14.0",
|
|
46
|
-
"@emotion/styled": "11.14.0",
|
|
47
|
-
"@smithy/types": "4.
|
|
48
|
-
"@storybook/addon-actions": "8.
|
|
42
|
+
"@babel/core": "^7.26.10",
|
|
43
|
+
"@babel/preset-typescript": "^7.27.0",
|
|
44
|
+
"@babel/types": "^7.27.0",
|
|
45
|
+
"@emotion/react": "^11.14.0",
|
|
46
|
+
"@emotion/styled": "^11.14.0",
|
|
47
|
+
"@smithy/types": "^4.2.0",
|
|
48
|
+
"@storybook/addon-actions": "^8.6.12",
|
|
49
49
|
"@storybook/addon-docs": "8.1.6",
|
|
50
|
-
"@storybook/addon-essentials": "8.
|
|
51
|
-
"@storybook/addon-interactions": "8.
|
|
52
|
-
"@storybook/addon-links": "8.
|
|
53
|
-
"@storybook/addon-webpack5-compiler-swc": "
|
|
54
|
-
"@storybook/addons": "7.6.17",
|
|
55
|
-
"@storybook/react": "8.
|
|
56
|
-
"@storybook/react-webpack5": "8.
|
|
57
|
-
"@storybook/theming": "8.
|
|
58
|
-
"@types/jsonwebtoken": "9.0.
|
|
59
|
-
"@types/node": "22.
|
|
60
|
-
"@types/react": "19.
|
|
61
|
-
"@types/react-dom": "19.
|
|
62
|
-
"
|
|
63
|
-
"eslint
|
|
64
|
-
"
|
|
65
|
-
"
|
|
66
|
-
"
|
|
67
|
-
"
|
|
50
|
+
"@storybook/addon-essentials": "^8.6.12",
|
|
51
|
+
"@storybook/addon-interactions": "^8.6.12",
|
|
52
|
+
"@storybook/addon-links": "^8.6.12",
|
|
53
|
+
"@storybook/addon-webpack5-compiler-swc": "^3.0.0",
|
|
54
|
+
"@storybook/addons": "^7.6.17",
|
|
55
|
+
"@storybook/react": "^8.6.12",
|
|
56
|
+
"@storybook/react-webpack5": "^8.6.12",
|
|
57
|
+
"@storybook/theming": "^8.6.12",
|
|
58
|
+
"@types/jsonwebtoken": "^9.0.9",
|
|
59
|
+
"@types/node": "^22.14.1",
|
|
60
|
+
"@types/react": "^19.1.2",
|
|
61
|
+
"@types/react-dom": "^19.1.2",
|
|
62
|
+
"@typescript-eslint/eslint-plugin": "^8.30.1",
|
|
63
|
+
"@typescript-eslint/parser": "^8.30.1",
|
|
64
|
+
"cross-env": "^7.0.3",
|
|
65
|
+
"eslint": "^9.24.0",
|
|
66
|
+
"eslint-config-e7npm": "^0.1.23",
|
|
67
|
+
"globstar": "^1.0.0",
|
|
68
|
+
"rimraf": "^6.0.1",
|
|
69
|
+
"storybook": "^8.6.12",
|
|
70
|
+
"tsx": "^4.19.3"
|
|
68
71
|
},
|
|
69
72
|
"resolutions": {
|
|
70
73
|
"globals": "15.14.0"
|
|
@@ -1,146 +0,0 @@
|
|
|
1
|
-
import { DynamoDBDocument } from '@aws-sdk/lib-dynamodb';
|
|
2
|
-
import type { AwsCredentialIdentity } from '@smithy/types';
|
|
3
|
-
type DynamoDBError = {
|
|
4
|
-
error: string;
|
|
5
|
-
};
|
|
6
|
-
type DynamoDBSuccess<T> = {
|
|
7
|
-
data: T;
|
|
8
|
-
};
|
|
9
|
-
type DynamoDBResult<T> = DynamoDBSuccess<T> | DynamoDBError;
|
|
10
|
-
interface Key {
|
|
11
|
-
[key: string]: string | number;
|
|
12
|
-
}
|
|
13
|
-
interface DynamoFilter {
|
|
14
|
-
filterExpression: string;
|
|
15
|
-
attrNames: Record<string, string>;
|
|
16
|
-
attrValues?: Record<string, unknown>;
|
|
17
|
-
}
|
|
18
|
-
interface ScanOptions {
|
|
19
|
-
/** eg
|
|
20
|
-
* filter: {
|
|
21
|
-
filterExpression: '#feedIcon = :empty',
|
|
22
|
-
attrNames: { '#feedIcon': 'feedIcon' },
|
|
23
|
-
attrValues: {
|
|
24
|
-
':empty': '',
|
|
25
|
-
},
|
|
26
|
-
},
|
|
27
|
-
*/
|
|
28
|
-
filter?: DynamoFilter;
|
|
29
|
-
requiredAttributeList?: string[];
|
|
30
|
-
indexName?: string;
|
|
31
|
-
}
|
|
32
|
-
interface DynamoQueryParams {
|
|
33
|
-
tableName: string;
|
|
34
|
-
pkName: string;
|
|
35
|
-
pkValue: string | number;
|
|
36
|
-
pkOperator?: '=' | '<' | '>' | '<=' | '>=';
|
|
37
|
-
skName?: string;
|
|
38
|
-
skValue?: string | number | [string | number, string | number];
|
|
39
|
-
skOperator?: '=' | '<' | '>' | '<=' | '>=' | 'BETWEEN' | 'BEGINS_WITH';
|
|
40
|
-
indexName?: string;
|
|
41
|
-
limit?: number;
|
|
42
|
-
startKey?: Key;
|
|
43
|
-
filterName?: string;
|
|
44
|
-
filterValue?: unknown;
|
|
45
|
-
filterOperator?: string;
|
|
46
|
-
sortAscending?: boolean;
|
|
47
|
-
}
|
|
48
|
-
export declare let dynamoDb: DynamoDBDocument;
|
|
49
|
-
/**
|
|
50
|
-
* Sets up the DynamoDB client with the specified region and credentials.
|
|
51
|
-
* @param region - AWS region to connect to
|
|
52
|
-
* @param credentials - Optional AWS credentials
|
|
53
|
-
* @returns Configured DynamoDBDocument client
|
|
54
|
-
*/
|
|
55
|
-
export declare const setDynamo: (region: string, credentials?: AwsCredentialIdentity) => DynamoDBDocument;
|
|
56
|
-
/**
|
|
57
|
-
* Puts a single item into a DynamoDB table.
|
|
58
|
-
* @param item - The item to put into the table
|
|
59
|
-
* @param tableName - Name of the DynamoDB table
|
|
60
|
-
* @param opt - Optional parameters including primary key name for conditional put
|
|
61
|
-
* @returns Promise resolving to void on success or error message on failure
|
|
62
|
-
*/
|
|
63
|
-
export declare const putDynamo: <T extends Record<string, unknown>>(item: T, tableName: string, opt?: {
|
|
64
|
-
pkName?: string;
|
|
65
|
-
}) => Promise<DynamoDBResult<void>>;
|
|
66
|
-
/**
|
|
67
|
-
* Writes multiple items to a DynamoDB table in batches.
|
|
68
|
-
* Automatically chunks items into batches of 20 (or specified size) to comply with DynamoDB limits.
|
|
69
|
-
* @param tableName - Name of the DynamoDB table
|
|
70
|
-
* @param items - Array of items to write
|
|
71
|
-
* @param opt - Optional parameters including batch size and retry behavior
|
|
72
|
-
* @returns Promise resolving to void on success or error message on failure
|
|
73
|
-
*/
|
|
74
|
-
export declare const batchWrite: <T extends Record<string, unknown>>(tableName: string, items: T[], opt?: {
|
|
75
|
-
/** option to always retry on 429 until done */
|
|
76
|
-
alwaysRetry?: boolean;
|
|
77
|
-
/** default 20 */
|
|
78
|
-
batchSize?: number;
|
|
79
|
-
}) => Promise<DynamoDBResult<void>>;
|
|
80
|
-
/**
|
|
81
|
-
* Deletes multiple items from a DynamoDB table in batches.
|
|
82
|
-
* Automatically chunks keys into batches of 20 (or specified size) to comply with DynamoDB limits.
|
|
83
|
-
* @param params - Parameters including table name, keys to delete, and options
|
|
84
|
-
* @returns Promise resolving to void on success or error message on failure
|
|
85
|
-
*/
|
|
86
|
-
export declare const batchDelete: (params: {
|
|
87
|
-
tableName: string;
|
|
88
|
-
keys: string[];
|
|
89
|
-
pkName: string;
|
|
90
|
-
opt?: {
|
|
91
|
-
/** default 20 */
|
|
92
|
-
batchSize?: number;
|
|
93
|
-
/** option to always retry on 429 until done. default false */
|
|
94
|
-
alwaysRetry?: boolean;
|
|
95
|
-
};
|
|
96
|
-
}) => Promise<DynamoDBResult<void>>;
|
|
97
|
-
/**
|
|
98
|
-
* Scans a DynamoDB table and returns all matching items.
|
|
99
|
-
* Handles pagination automatically and supports filtering and projection.
|
|
100
|
-
* @param tableName - Name of the DynamoDB table
|
|
101
|
-
* @param options - Optional parameters for filtering, projection, and index usage
|
|
102
|
-
* @returns Promise resolving to array of items on success or error message on failure
|
|
103
|
-
*/
|
|
104
|
-
export declare const scan: <T>(tableName: string, options?: ScanOptions) => Promise<DynamoDBResult<T[]>>;
|
|
105
|
-
/**
|
|
106
|
-
* Scans a DynamoDB table and yields items in batches.
|
|
107
|
-
* Useful for processing large tables without loading all items into memory.
|
|
108
|
-
* @param tableName - Name of the DynamoDB table
|
|
109
|
-
* @param options - Optional parameters including batch size, filtering, and projection
|
|
110
|
-
* @returns AsyncGenerator yielding batches of items
|
|
111
|
-
* @throws Error if the scan operation fails
|
|
112
|
-
*/
|
|
113
|
-
export declare function scanWithGenerator<T>(tableName: string, options?: ScanOptions & {
|
|
114
|
-
/** how many to return in scan generator. default 100 */
|
|
115
|
-
BATCH_SIZE?: number;
|
|
116
|
-
}): AsyncGenerator<T[], void, unknown>;
|
|
117
|
-
export declare const getItemsDynamo: <T>(params: {
|
|
118
|
-
tableName: string;
|
|
119
|
-
items: {
|
|
120
|
-
pkName: string;
|
|
121
|
-
pkValue: string;
|
|
122
|
-
}[];
|
|
123
|
-
}) => Promise<DynamoDBResult<T[]>>;
|
|
124
|
-
export declare const getItemDynamo: <T>(params: {
|
|
125
|
-
tableName: string;
|
|
126
|
-
pkName: string;
|
|
127
|
-
pkValue: string;
|
|
128
|
-
}) => Promise<DynamoDBResult<T>>;
|
|
129
|
-
export declare const queryDynamo: <T>(params: DynamoQueryParams) => Promise<{
|
|
130
|
-
data: T[];
|
|
131
|
-
startKey?: Key;
|
|
132
|
-
} | {
|
|
133
|
-
error: string;
|
|
134
|
-
}>;
|
|
135
|
-
export declare const getDynamoTtlDays: (days: number) => number;
|
|
136
|
-
export declare const getDynamoTtlMinutes: (minutes: number) => number;
|
|
137
|
-
export declare const wipeTable: (tableName: string) => Promise<DynamoDBResult<void>>;
|
|
138
|
-
export declare const getDynamoUpdates: <T extends Record<string, unknown>>(item: T, options?: {
|
|
139
|
-
excludeKeys?: string[];
|
|
140
|
-
}) => {
|
|
141
|
-
UpdateExpression: string;
|
|
142
|
-
ExpressionAttributeNames: Record<string, string>;
|
|
143
|
-
ExpressionAttributeValues: Record<string, unknown>;
|
|
144
|
-
ReturnValues: "UPDATED_NEW";
|
|
145
|
-
};
|
|
146
|
-
export {};
|