ag-common 0.0.901 → 0.0.903
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/cosmos/get.js +1 -1
- package/dist/api/helpers/cosmos/utils.js +0 -3
- package/dist/api/helpers/dynamo/batch.d.ts +8 -0
- package/dist/api/helpers/dynamo/batch.js +28 -0
- package/dist/api/helpers/dynamo/delete.js +8 -12
- package/dist/api/helpers/dynamo/get.js +10 -0
- package/dist/api/helpers/dynamo/set.js +9 -10
- package/dist/api/helpers/dynamo/types.d.ts +2 -0
- package/dist/api/helpers/google/gemini.js +3 -3
- package/dist/api/helpers/retryOnError.js +1 -1
- package/dist/api/helpers/validations.js +3 -3
- package/dist/common/helpers/array.js +1 -5
- package/dist/common/helpers/async.d.ts +1 -1
- package/dist/common/helpers/async.js +1 -1
- package/dist/common/helpers/groupBy.js +2 -2
- package/dist/common/helpers/i18n.js +1 -1
- package/dist/common/helpers/object.js +2 -5
- package/dist/common/helpers/stream.js +1 -1
- package/dist/common/helpers/withRetry.js +2 -2
- package/dist/common/helpers/xml.js +9 -7
- package/dist/ui/components/DarkMode/Base.js +1 -1
- package/dist/ui/components/DarkMode/types.d.ts +5 -5
- package/dist/ui/components/Markdown/index.js +1 -1
- package/dist/ui/components/shadcn/dropdown-list.js +1 -1
- package/dist/ui/components/shadcn/dropdown-menu.js +2 -2
- package/dist/ui/components/shadcn/scroll-area.js +1 -1
- package/dist/ui/components/shadcn/select.js +2 -2
- package/dist/ui/components/shadcn/textarea.js +1 -1
- package/dist/ui/components/shadcn/toast.js +1 -1
- package/dist/ui/helpers/cookie/get.js +1 -1
- package/dist/ui/helpers/cookie/raw.js +1 -1
- package/dist/ui/helpers/cookie/set.js +2 -3
- package/dist/ui/helpers/useGranularHook.js +4 -4
- package/dist/ui/helpers/useIsInViewport.d.ts +1 -1
- package/dist/ui/helpers/useLocalStorage.js +1 -1
- package/dist/ui/helpers/useOnScroll.js +5 -12
- package/dist/ui/helpers/useQueryString.js +2 -6
- package/dist/ui/helpers/useTooltip.d.ts +1 -1
- package/dist/ui/styles/common.js +1 -1
- package/package.json +3 -3
|
@@ -101,7 +101,7 @@ async function queryItemsByText(container, searchFields, operator = "AND") {
|
|
|
101
101
|
case "not_equals":
|
|
102
102
|
return `c.${field.fieldName} != @value${index}`;
|
|
103
103
|
default:
|
|
104
|
-
throw new Error(
|
|
104
|
+
throw new Error("Unsupported field type");
|
|
105
105
|
}
|
|
106
106
|
});
|
|
107
107
|
const query = `SELECT * FROM c WHERE ${conditions.join(` ${operator} `)}`;
|
|
@@ -11,8 +11,5 @@ function createContainer(settings) {
|
|
|
11
11
|
const client = new cosmos_1.CosmosClient(settings);
|
|
12
12
|
const database = client.database(settings.database_name);
|
|
13
13
|
const container = database.container(settings.container_name);
|
|
14
|
-
if (!container) {
|
|
15
|
-
throw new Error("error, cosmos container undefined!!");
|
|
16
|
-
}
|
|
17
14
|
return container;
|
|
18
15
|
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { type BatchWriteCommandInput } from "@aws-sdk/lib-dynamodb";
|
|
2
|
+
export type DynamoWriteRequest = NonNullable<NonNullable<BatchWriteCommandInput["RequestItems"]>[string]>[number];
|
|
3
|
+
export declare const sendAllBatchRequests: ({ maxRetries, operationName, requests, tableName, }: {
|
|
4
|
+
maxRetries?: number | null;
|
|
5
|
+
operationName: string;
|
|
6
|
+
requests: DynamoWriteRequest[];
|
|
7
|
+
tableName: string;
|
|
8
|
+
}) => Promise<void>;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.sendAllBatchRequests = void 0;
|
|
4
|
+
const lib_dynamodb_1 = require("@aws-sdk/lib-dynamodb");
|
|
5
|
+
const _1 = require(".");
|
|
6
|
+
const sleep_1 = require("../../../common/helpers/sleep");
|
|
7
|
+
const withRetry_1 = require("../../../common/helpers/withRetry");
|
|
8
|
+
const sendAllBatchRequests = async ({ maxRetries = 3, operationName, requests, tableName, }) => {
|
|
9
|
+
let pending = requests;
|
|
10
|
+
let unprocessedRetries = 0;
|
|
11
|
+
while (pending.length > 0) {
|
|
12
|
+
// oxlint-disable-next-line no-await-in-loop -- each request depends on DynamoDB's unprocessed set
|
|
13
|
+
const result = await (0, withRetry_1.withRetry)(() => _1.dynamoDb.send(new lib_dynamodb_1.BatchWriteCommand({
|
|
14
|
+
RequestItems: { [tableName]: pending },
|
|
15
|
+
})), operationName, { maxRetries });
|
|
16
|
+
pending = result.UnprocessedItems?.[tableName] ?? [];
|
|
17
|
+
if (pending.length === 0) {
|
|
18
|
+
return;
|
|
19
|
+
}
|
|
20
|
+
if (maxRetries !== null && unprocessedRetries >= maxRetries) {
|
|
21
|
+
throw new Error(`${operationName}: ${pending.length} items remained unprocessed`);
|
|
22
|
+
}
|
|
23
|
+
unprocessedRetries += 1;
|
|
24
|
+
// oxlint-disable-next-line no-await-in-loop -- unprocessed writes require backoff before retrying
|
|
25
|
+
await (0, sleep_1.sleep)(Math.min(2 ** unprocessedRetries * 25, 2000));
|
|
26
|
+
}
|
|
27
|
+
};
|
|
28
|
+
exports.sendAllBatchRequests = sendAllBatchRequests;
|
|
@@ -1,11 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.wipeTable = exports.batchDelete = void 0;
|
|
4
|
-
const lib_dynamodb_1 = require("@aws-sdk/lib-dynamodb");
|
|
5
|
-
const _1 = require(".");
|
|
6
4
|
const array_1 = require("../../../common/helpers/array");
|
|
7
5
|
const async_1 = require("../../../common/helpers/async");
|
|
8
|
-
const
|
|
6
|
+
const batch_1 = require("./batch");
|
|
9
7
|
const get_1 = require("./get");
|
|
10
8
|
const batchDelete = async (params) => {
|
|
11
9
|
try {
|
|
@@ -13,15 +11,13 @@ const batchDelete = async (params) => {
|
|
|
13
11
|
const chunked = (0, array_1.chunk)(params.keys, batchSize);
|
|
14
12
|
let processed = 0;
|
|
15
13
|
await (0, async_1.asyncForEach)(chunked, async (chunk) => {
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
await (0, withRetry_1.withRetry)(() => _1.dynamoDb.send(new lib_dynamodb_1.BatchWriteCommand(batchDeleteParams)), `batchdelete ${processed}/${params.keys.length}. size=${batchSize}`, {
|
|
24
|
-
maxRetries: maxRetries === undefined ? 3 : maxRetries,
|
|
14
|
+
await (0, batch_1.sendAllBatchRequests)({
|
|
15
|
+
tableName: params.tableName,
|
|
16
|
+
requests: chunk.map((key) => ({
|
|
17
|
+
DeleteRequest: { Key: { [params.pkName]: key } },
|
|
18
|
+
})),
|
|
19
|
+
operationName: `batchdelete ${processed}/${params.keys.length}. size=${batchSize}`,
|
|
20
|
+
maxRetries,
|
|
25
21
|
});
|
|
26
22
|
processed += chunk.length;
|
|
27
23
|
});
|
|
@@ -38,11 +38,16 @@ const executeQuery = async (params, exclusiveStartKey) => {
|
|
|
38
38
|
eav[`:${skName.toLowerCase()}`] = skValue;
|
|
39
39
|
}
|
|
40
40
|
}
|
|
41
|
+
const projectionAttrs = params.requiredAttributeList?.reduce((acc, attr, index) => {
|
|
42
|
+
acc[`#proj${index}`] = attr;
|
|
43
|
+
return acc;
|
|
44
|
+
}, {});
|
|
41
45
|
const queryParams = {
|
|
42
46
|
TableName: params.tableName,
|
|
43
47
|
KeyConditionExpression: kce,
|
|
44
48
|
ExpressionAttributeNames: {
|
|
45
49
|
...ean,
|
|
50
|
+
...projectionAttrs,
|
|
46
51
|
...params.filter?.attrNames,
|
|
47
52
|
},
|
|
48
53
|
ExpressionAttributeValues: {
|
|
@@ -53,6 +58,11 @@ const executeQuery = async (params, exclusiveStartKey) => {
|
|
|
53
58
|
Limit: params.limit === -1 ? undefined : params.limit,
|
|
54
59
|
IndexName: params.indexName,
|
|
55
60
|
ExclusiveStartKey: exclusiveStartKey,
|
|
61
|
+
...(params.requiredAttributeList && {
|
|
62
|
+
ProjectionExpression: params.requiredAttributeList
|
|
63
|
+
.map((_, index) => `#proj${index}`)
|
|
64
|
+
.join(", "),
|
|
65
|
+
}),
|
|
56
66
|
...(params.filter && {
|
|
57
67
|
FilterExpression: params.filter.filterExpression,
|
|
58
68
|
...(params.filter.attrValues && {
|
|
@@ -6,6 +6,7 @@ const _1 = require(".");
|
|
|
6
6
|
const array_1 = require("../../../common/helpers/array");
|
|
7
7
|
const async_1 = require("../../../common/helpers/async");
|
|
8
8
|
const withRetry_1 = require("../../../common/helpers/withRetry");
|
|
9
|
+
const batch_1 = require("./batch");
|
|
9
10
|
const putDynamo = async (item, tableName, opt) => {
|
|
10
11
|
const putParams = {
|
|
11
12
|
TableName: tableName,
|
|
@@ -17,7 +18,7 @@ const putDynamo = async (item, tableName, opt) => {
|
|
|
17
18
|
try {
|
|
18
19
|
const res = await (0, withRetry_1.withRetry)(() => _1.dynamoDb.send(new lib_dynamodb_1.PutCommand(putParams)), "putDynamo");
|
|
19
20
|
if (res.$metadata.httpStatusCode !== 200) {
|
|
20
|
-
return { error:
|
|
21
|
+
return { error: JSON.stringify(res) };
|
|
21
22
|
}
|
|
22
23
|
return { data: undefined };
|
|
23
24
|
}
|
|
@@ -32,13 +33,11 @@ const batchWrite = async (tableName, items, opt) => {
|
|
|
32
33
|
let processed = 0;
|
|
33
34
|
const chunked = (0, array_1.chunk)(items, batchSize);
|
|
34
35
|
await (0, async_1.asyncForEach)(chunked, async (chunk) => {
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
await (0, withRetry_1.withRetry)(() => _1.dynamoDb.send(new lib_dynamodb_1.BatchWriteCommand(batchWriteParams)), `batchwrite ${processed}/${items.length}. size=${batchSize}`, {
|
|
41
|
-
maxRetries: opt?.maxRetries === undefined ? 3 : opt.maxRetries,
|
|
36
|
+
await (0, batch_1.sendAllBatchRequests)({
|
|
37
|
+
tableName,
|
|
38
|
+
requests: chunk.map((Item) => ({ PutRequest: { Item } })),
|
|
39
|
+
operationName: `batchwrite ${processed}/${items.length}. size=${batchSize}`,
|
|
40
|
+
maxRetries: opt?.maxRetries,
|
|
42
41
|
});
|
|
43
42
|
processed += chunk.length;
|
|
44
43
|
});
|
|
@@ -49,7 +48,7 @@ const batchWrite = async (tableName, items, opt) => {
|
|
|
49
48
|
}
|
|
50
49
|
};
|
|
51
50
|
exports.batchWrite = batchWrite;
|
|
52
|
-
const incrementDynamo = async ({ tableName, pkName, pkValue, fieldName, incrementValue
|
|
51
|
+
const incrementDynamo = async ({ tableName, pkName, pkValue, fieldName, incrementValue, }) => {
|
|
53
52
|
const updateParams = {
|
|
54
53
|
TableName: tableName,
|
|
55
54
|
Key: { [pkName]: pkValue },
|
|
@@ -65,7 +64,7 @@ const incrementDynamo = async ({ tableName, pkName, pkValue, fieldName, incremen
|
|
|
65
64
|
try {
|
|
66
65
|
const res = await (0, withRetry_1.withRetry)(() => _1.dynamoDb.send(new lib_dynamodb_1.UpdateCommand(updateParams)), "incrementDynamo");
|
|
67
66
|
if (res.$metadata.httpStatusCode !== 200) {
|
|
68
|
-
return { error:
|
|
67
|
+
return { error: JSON.stringify(res) };
|
|
69
68
|
}
|
|
70
69
|
// Extract the updated value from the response
|
|
71
70
|
const updatedValue = res.Attributes?.[fieldName];
|
|
@@ -53,6 +53,8 @@ export interface DynamoQueryParams {
|
|
|
53
53
|
*/
|
|
54
54
|
limit?: number;
|
|
55
55
|
filter?: DynamoFilter;
|
|
56
|
+
/** Return only these attributes. */
|
|
57
|
+
requiredAttributeList?: string[];
|
|
56
58
|
sortAscending?: boolean;
|
|
57
59
|
/** default 3, set to null to disable retries */
|
|
58
60
|
maxRetries?: number | null;
|
|
@@ -9,7 +9,7 @@ const log_1 = require("../../../common/helpers/log");
|
|
|
9
9
|
const node_cache_1 = require("../../../common/helpers/node-cache");
|
|
10
10
|
const retryOnError_1 = require("../retryOnError");
|
|
11
11
|
const apikey_1 = require("./apikey");
|
|
12
|
-
let genAIs;
|
|
12
|
+
let genAIs = [];
|
|
13
13
|
const geminiModelsCache = new node_cache_1.TypedNodeCache({ stdTTL: 86400 });
|
|
14
14
|
const geminiModelsCacheKey = "gemini-models-v1";
|
|
15
15
|
const FALLBACK_GEMINI_MODELS = [
|
|
@@ -87,7 +87,7 @@ const getAvailableGeminiModels = async () => {
|
|
|
87
87
|
};
|
|
88
88
|
// Helper to get available key+model combinations
|
|
89
89
|
const getAvailableGeminiCombinations = async (prefer) => {
|
|
90
|
-
if (
|
|
90
|
+
if (genAIs.length === 0) {
|
|
91
91
|
const keyServiceCombinations = (0, apikey_1.getAvailableCombinations)("gemini");
|
|
92
92
|
const keys = keyServiceCombinations.map((combo) => combo.key);
|
|
93
93
|
genAIs = keys.map((k) => [k, new genai_1.GoogleGenAI({ apiKey: k })]);
|
|
@@ -111,7 +111,7 @@ const geminiPromptImage = async ({ prompt, urls, ident, prefer, }) => {
|
|
|
111
111
|
if (urls && urls.length > 0) {
|
|
112
112
|
images = await (0, async_1.asyncMap)(urls, (i) => (0, fetch_1.fetchToMemory)(i));
|
|
113
113
|
}
|
|
114
|
-
if (images.
|
|
114
|
+
if (images.some((image) => image === undefined)) {
|
|
115
115
|
throw new Error("image not downloaded correctly");
|
|
116
116
|
}
|
|
117
117
|
const r = await (0, exports.geminiPromptDirect)({
|
|
@@ -24,7 +24,7 @@ async function retryOnError(
|
|
|
24
24
|
/** so we can log retries with useful info */
|
|
25
25
|
debugIdent, fn, retries = 1, errorDelay = 2000, errorCheck = exports.isRetryableApiError) {
|
|
26
26
|
try {
|
|
27
|
-
return
|
|
27
|
+
return fn();
|
|
28
28
|
}
|
|
29
29
|
catch (error) {
|
|
30
30
|
const e = error;
|
|
@@ -107,10 +107,10 @@ const getAndValidateToken = async ({ tokenRaw, jwksRegion = "ap-southeast-2", CO
|
|
|
107
107
|
return { token, userProfile };
|
|
108
108
|
}
|
|
109
109
|
catch (e) {
|
|
110
|
-
const
|
|
110
|
+
const errorMessage = e instanceof Error ? e.message : String(e);
|
|
111
111
|
// expiry is too common to log
|
|
112
|
-
if (
|
|
113
|
-
(0, log_1.info)(`jwt fail:${
|
|
112
|
+
if (errorMessage.includes("jwt expired")) {
|
|
113
|
+
(0, log_1.info)(`jwt fail:${errorMessage}`);
|
|
114
114
|
}
|
|
115
115
|
throw e;
|
|
116
116
|
}
|
|
@@ -17,9 +17,6 @@ keyF,
|
|
|
17
17
|
*/
|
|
18
18
|
valueF) => {
|
|
19
19
|
const ret = {};
|
|
20
|
-
if (!arr || !keyF) {
|
|
21
|
-
return ret;
|
|
22
|
-
}
|
|
23
20
|
arr.forEach((v) => {
|
|
24
21
|
const k = keyF(v);
|
|
25
22
|
ret[k] = valueF(v);
|
|
@@ -42,8 +39,7 @@ exports.take = take;
|
|
|
42
39
|
const chunk = (array, max) => {
|
|
43
40
|
const rows = [];
|
|
44
41
|
let row = [];
|
|
45
|
-
for (const
|
|
46
|
-
const item = array[k];
|
|
42
|
+
for (const item of array) {
|
|
47
43
|
row.push(item);
|
|
48
44
|
if (row.length >= max) {
|
|
49
45
|
rows.push(row);
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* @param array
|
|
4
4
|
* @param callback
|
|
5
5
|
*/
|
|
6
|
-
export declare function asyncForEach<T>(array: T[], callback: (i: T, index: number, array: T[]) => void
|
|
6
|
+
export declare function asyncForEach<T>(array: T[], callback: (i: T, index: number, array: T[]) => void | PromiseLike<unknown>, opt?: {
|
|
7
7
|
/** default 1 */
|
|
8
8
|
maxConcurrency?: number;
|
|
9
9
|
}): Promise<void>;
|
|
@@ -15,7 +15,7 @@ async function asyncForEach(array, callback, opt) {
|
|
|
15
15
|
while (rem.length > 0) {
|
|
16
16
|
const { rest, part } = (0, array_1.take)(rem, maxConcurrency);
|
|
17
17
|
rem = rest;
|
|
18
|
-
const proms = part.map((p, i) => callback(p, start + i, array));
|
|
18
|
+
const proms = part.map((p, i) => Promise.resolve(callback(p, start + i, array)));
|
|
19
19
|
start += part.length;
|
|
20
20
|
// oxlint-disable-next-line no-await-in-loop -- concurrency is intentionally bounded per batch
|
|
21
21
|
await Promise.all(proms);
|
|
@@ -12,7 +12,7 @@ function groupBy(arr, getKey) {
|
|
|
12
12
|
const ret = {};
|
|
13
13
|
arr.forEach((item) => {
|
|
14
14
|
const key = getKey(item);
|
|
15
|
-
if (!ret
|
|
15
|
+
if (!Object.prototype.hasOwnProperty.call(ret, key)) {
|
|
16
16
|
ret[key] = [];
|
|
17
17
|
}
|
|
18
18
|
ret[key].push(item);
|
|
@@ -43,7 +43,7 @@ function groupByTwice(arr, getKey, getSubKey) {
|
|
|
43
43
|
arr.forEach((item) => {
|
|
44
44
|
const key = getKey(item);
|
|
45
45
|
const subkey = getSubKey(item);
|
|
46
|
-
if (!ret
|
|
46
|
+
if (!Object.prototype.hasOwnProperty.call(ret, key)) {
|
|
47
47
|
ret[key] = {};
|
|
48
48
|
}
|
|
49
49
|
ret[key][subkey] = item;
|
|
@@ -27,7 +27,7 @@ function isJson(str) {
|
|
|
27
27
|
return true;
|
|
28
28
|
}
|
|
29
29
|
const objectKeysToLowerCase = (origObj) => {
|
|
30
|
-
if (
|
|
30
|
+
if (Object.keys(origObj).length === 0) {
|
|
31
31
|
return {};
|
|
32
32
|
}
|
|
33
33
|
return Object.keys(origObj).reduce((newObj, key) => {
|
|
@@ -43,9 +43,6 @@ exports.objectKeysToLowerCase = objectKeysToLowerCase;
|
|
|
43
43
|
const getObjectKeysAsNumber = (o) => Object.keys(o).map((o2) => parseInt(o2, 10));
|
|
44
44
|
exports.getObjectKeysAsNumber = getObjectKeysAsNumber;
|
|
45
45
|
function objectToArray(obj) {
|
|
46
|
-
if (!obj) {
|
|
47
|
-
return [];
|
|
48
|
-
}
|
|
49
46
|
const ret = [];
|
|
50
47
|
Object.keys(obj).forEach((ok) => {
|
|
51
48
|
ret.push({ key: ok, value: obj[ok] });
|
|
@@ -101,7 +98,7 @@ function objectToString(obj,
|
|
|
101
98
|
joinKeyValue,
|
|
102
99
|
/** eg '&' */
|
|
103
100
|
joinKeys) {
|
|
104
|
-
if (
|
|
101
|
+
if (Object.keys(obj).length === 0) {
|
|
105
102
|
return "";
|
|
106
103
|
}
|
|
107
104
|
const raw = Object.entries(obj).map(([key, value]) => key + joinKeyValue + value);
|
|
@@ -7,7 +7,7 @@ async function getStringFromStream(stream) {
|
|
|
7
7
|
const reader = stream.getReader();
|
|
8
8
|
let result = "";
|
|
9
9
|
try {
|
|
10
|
-
|
|
10
|
+
for (;;) {
|
|
11
11
|
// oxlint-disable-next-line no-await-in-loop -- stream chunks must be read sequentially
|
|
12
12
|
const { done, value } = await reader.read();
|
|
13
13
|
if (done)
|
|
@@ -7,10 +7,10 @@ const withRetry = async (operation, operationName, opt) => {
|
|
|
7
7
|
let retryCount = 0;
|
|
8
8
|
const baseDelay = 2000;
|
|
9
9
|
const { maxRetries = 3 } = opt ?? {};
|
|
10
|
-
|
|
10
|
+
for (;;) {
|
|
11
11
|
try {
|
|
12
12
|
// oxlint-disable-next-line no-await-in-loop -- retries are intentionally sequential
|
|
13
|
-
return
|
|
13
|
+
return operation();
|
|
14
14
|
}
|
|
15
15
|
catch (e) {
|
|
16
16
|
const error = e;
|
|
@@ -21,15 +21,17 @@ class XMLParser {
|
|
|
21
21
|
const newObject = { ...attributes };
|
|
22
22
|
this.stack.push(this.currentObject);
|
|
23
23
|
const parent = this.stack[this.stack.length - 1];
|
|
24
|
-
|
|
25
|
-
if (existingValue === undefined) {
|
|
24
|
+
if (!Object.prototype.hasOwnProperty.call(parent, name)) {
|
|
26
25
|
parent[name] = newObject;
|
|
27
26
|
}
|
|
28
|
-
else if (Array.isArray(existingValue)) {
|
|
29
|
-
existingValue.push(newObject);
|
|
30
|
-
}
|
|
31
27
|
else {
|
|
32
|
-
|
|
28
|
+
const existingValue = parent[name];
|
|
29
|
+
if (Array.isArray(existingValue)) {
|
|
30
|
+
existingValue.push(newObject);
|
|
31
|
+
}
|
|
32
|
+
else {
|
|
33
|
+
parent[name] = [existingValue, newObject];
|
|
34
|
+
}
|
|
33
35
|
}
|
|
34
36
|
this.currentObject = newObject;
|
|
35
37
|
}
|
|
@@ -78,7 +80,7 @@ class XMLReader {
|
|
|
78
80
|
let match;
|
|
79
81
|
while ((match = attributePattern.exec(attributes))) {
|
|
80
82
|
const [, key, doubleQuotedValue, singleQuotedValue] = match;
|
|
81
|
-
parsedAttributes[key] = doubleQuotedValue
|
|
83
|
+
parsedAttributes[key] = doubleQuotedValue || singleQuotedValue;
|
|
82
84
|
}
|
|
83
85
|
return parsedAttributes;
|
|
84
86
|
}
|
|
@@ -118,7 +118,7 @@ const DarkModeAux = ({ iconSize = "2.5rem", className, mode, onSubmit, style, dm
|
|
|
118
118
|
dm.setDarkmode(newDarkMode);
|
|
119
119
|
onSubmit?.(newDarkMode);
|
|
120
120
|
};
|
|
121
|
-
return (react_1.default.createElement("div", { className: (0, utils_1.cn)("flex flex-row overflow-hidden justify-between items-center rounded-4xl", "border-2 border-solid p-
|
|
121
|
+
return (react_1.default.createElement("div", { className: (0, utils_1.cn)("flex flex-row overflow-hidden justify-between items-center rounded-4xl", "border-2 border-solid p-0.5 box-border", "data-[mode=vert]:flex-col", className), "data-mode": mode ?? "horiz", style: {
|
|
122
122
|
...style,
|
|
123
123
|
background,
|
|
124
124
|
borderColor: fill,
|
|
@@ -24,7 +24,7 @@ const injectGroup = ({ output, pos, wrap, }) => {
|
|
|
24
24
|
const sum = [];
|
|
25
25
|
for (let a = pos.outputIndex; a <= outputEndIndex; a += 1) {
|
|
26
26
|
sum.push(output[a]);
|
|
27
|
-
|
|
27
|
+
output.splice(a, 1);
|
|
28
28
|
}
|
|
29
29
|
output = (0, array_1.insertElementAtIndex)(output, wrap(sum), pos.outputIndex);
|
|
30
30
|
return output;
|
|
@@ -47,7 +47,7 @@ const DropdownList = ({ options, renderF, onChange, children, className, }) => {
|
|
|
47
47
|
return (React.createElement(DropdownMenuPrimitive.Root, { open: open, onOpenChange: setOpen },
|
|
48
48
|
React.createElement(DropdownMenuPrimitive.Trigger, { asChild: true, className: className }, children),
|
|
49
49
|
React.createElement(DropdownMenuPrimitive.Portal, null,
|
|
50
|
-
React.createElement(DropdownMenuPrimitive.Content, { className: (0, utils_1.cn)("z-
|
|
50
|
+
React.createElement(DropdownMenuPrimitive.Content, { className: (0, utils_1.cn)("z-1200 min-w-32 overflow-hidden rounded-md border border-main-fg-mid bg-main-bg text-main-fg shadow-md", "data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2"), align: "end" }, options.map((option, index) => {
|
|
51
51
|
const value = typeof option === "string" ? option : option.value;
|
|
52
52
|
const label = typeof option === "string" ? option : option.label;
|
|
53
53
|
const isLast = index === options.length - 1;
|
|
@@ -55,10 +55,10 @@ const DropdownMenuSubTrigger = ({ className, inset, children, ...props }) => (Re
|
|
|
55
55
|
children,
|
|
56
56
|
React.createElement(react_icons_1.ChevronRightIcon, { className: "ml-auto" })));
|
|
57
57
|
exports.DropdownMenuSubTrigger = DropdownMenuSubTrigger;
|
|
58
|
-
const DropdownMenuSubContent = ({ className, ...props }) => (React.createElement(DropdownMenuPrimitive.SubContent, { className: (0, utils_1.cn)("z-50 min-w-
|
|
58
|
+
const DropdownMenuSubContent = ({ className, ...props }) => (React.createElement(DropdownMenuPrimitive.SubContent, { className: (0, utils_1.cn)("z-50 min-w-32 overflow-hidden rounded-md border bg-popover p-1 text-popover-foreground shadow-lg data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2", className), ...props }));
|
|
59
59
|
exports.DropdownMenuSubContent = DropdownMenuSubContent;
|
|
60
60
|
const DropdownMenuContent = ({ className, sideOffset = 4, ...props }) => (React.createElement(DropdownMenuPrimitive.Portal, null,
|
|
61
|
-
React.createElement(DropdownMenuPrimitive.Content, { sideOffset: sideOffset, className: (0, utils_1.cn)("z-50 min-w-
|
|
61
|
+
React.createElement(DropdownMenuPrimitive.Content, { sideOffset: sideOffset, className: (0, utils_1.cn)("z-50 min-w-32 overflow-hidden rounded-md border bg-popover p-1 text-popover-foreground shadow-md", "data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2", className), ...props })));
|
|
62
62
|
exports.DropdownMenuContent = DropdownMenuContent;
|
|
63
63
|
const DropdownMenuItem = ({ className, inset, ...props }) => (React.createElement(DropdownMenuPrimitive.Item, { className: (0, utils_1.cn)("relative flex cursor-default select-none items-center gap-2 rounded-sm px-2 py-1.5 text-sm outline-hidden transition-colors focus:bg-accent focus:text-accent-foreground data-disabled:pointer-events-none data-disabled:opacity-50 [&>svg]:size-4 [&>svg]:shrink-0", inset && "pl-8", className), ...props }));
|
|
64
64
|
exports.DropdownMenuItem = DropdownMenuItem;
|
|
@@ -43,6 +43,6 @@ const ScrollArea = ({ className, children, ...props }) => (React.createElement(S
|
|
|
43
43
|
React.createElement(ScrollBar, null),
|
|
44
44
|
React.createElement(ScrollAreaPrimitive.Corner, null)));
|
|
45
45
|
exports.ScrollArea = ScrollArea;
|
|
46
|
-
const ScrollBar = ({ className, orientation = "vertical", ...props }) => (React.createElement(ScrollAreaPrimitive.ScrollAreaScrollbar, { orientation: orientation, className: (0, utils_1.cn)("flex touch-none select-none transition-colors", orientation === "vertical" && "h-full w-2.5 border-l border-l-transparent p-
|
|
46
|
+
const ScrollBar = ({ className, orientation = "vertical", ...props }) => (React.createElement(ScrollAreaPrimitive.ScrollAreaScrollbar, { orientation: orientation, className: (0, utils_1.cn)("flex touch-none select-none transition-colors", orientation === "vertical" && "h-full w-2.5 border-l border-l-transparent p-px", orientation === "horizontal" && "h-2.5 flex-col border-t border-t-transparent p-px", className), ...props },
|
|
47
47
|
React.createElement(ScrollAreaPrimitive.ScrollAreaThumb, { className: "relative flex-1 bg-border" })));
|
|
48
48
|
exports.ScrollBar = ScrollBar;
|
|
@@ -61,11 +61,11 @@ const SelectScrollDownButton = ({ className, ...props }) => (React.createElement
|
|
|
61
61
|
React.createElement(react_icons_1.ChevronDownIcon, { className: "h-4 w-4" })));
|
|
62
62
|
exports.SelectScrollDownButton = SelectScrollDownButton;
|
|
63
63
|
const SelectContent = ({ className, children, position = "popper", ...props }) => (React.createElement(SelectPrimitive.Portal, null,
|
|
64
|
-
React.createElement(SelectPrimitive.Content, { className: (0, utils_1.cn)("relative z-50 max-h-96 min-w-
|
|
64
|
+
React.createElement(SelectPrimitive.Content, { className: (0, utils_1.cn)("relative z-50 max-h-96 min-w-32 overflow-hidden rounded-md border bg-popover text-popover-foreground shadow-md data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2", position === "popper" &&
|
|
65
65
|
"data-[side=bottom]:translate-y-1 data-[side=left]:-translate-x-1 data-[side=right]:translate-x-1 data-[side=top]:-translate-y-1", className), position: position, ...props },
|
|
66
66
|
React.createElement(SelectScrollUpButton, null),
|
|
67
67
|
React.createElement(SelectPrimitive.Viewport, { className: (0, utils_1.cn)("p-1", position === "popper" &&
|
|
68
|
-
"h-
|
|
68
|
+
"h-(--radix-select-trigger-height) w-full min-w-(--radix-select-trigger-width)") }, children),
|
|
69
69
|
React.createElement(SelectScrollDownButton, null))));
|
|
70
70
|
exports.SelectContent = SelectContent;
|
|
71
71
|
const SelectLabel = ({ className, ...props }) => (React.createElement(SelectPrimitive.Label, { className: (0, utils_1.cn)("px-2 py-1.5 text-sm font-semibold", className), ...props }));
|
|
@@ -37,6 +37,6 @@ exports.Textarea = void 0;
|
|
|
37
37
|
const React = __importStar(require("react"));
|
|
38
38
|
const utils_1 = require("../../helpers/utils");
|
|
39
39
|
const Textarea = ({ className, ...props }) => {
|
|
40
|
-
return (React.createElement("textarea", { className: (0, utils_1.cn)("flex min-h-
|
|
40
|
+
return (React.createElement("textarea", { className: (0, utils_1.cn)("flex min-h-15 w-full rounded-md border border-input bg-transparent px-3 py-2 text-base shadow-xs placeholder:text-muted-foreground focus-visible:outline-hidden focus-visible:ring-1 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50 md:text-sm", className), ...props }));
|
|
41
41
|
};
|
|
42
42
|
exports.Textarea = Textarea;
|
|
@@ -116,7 +116,7 @@ const ToastItem = ({ toast }) => {
|
|
|
116
116
|
progressColor = "bg-yellow-100/80";
|
|
117
117
|
borderColor = "bg-yellow-500";
|
|
118
118
|
}
|
|
119
|
-
return (react_1.default.createElement("div", { className: "group flex flex-col relative overflow-hidden bg-white rounded-md shadow-md min-w-
|
|
119
|
+
return (react_1.default.createElement("div", { className: "group flex flex-col relative overflow-hidden bg-white rounded-md shadow-md min-w-xs max-w-sm animate-in slide-in-from-right-full pointer-events-auto", onMouseEnter: handleMouseEnter, onMouseLeave: handleMouseLeave },
|
|
120
120
|
toast.options.duration && toast.options.duration > 0 && (react_1.default.createElement("div", { className: `absolute inset-0 z-0 ${progressColor}`, style: {
|
|
121
121
|
animation: `toast-progress ${toast.options.duration}ms linear forwards`,
|
|
122
122
|
animationPlayState: isPaused ? "paused" : "running",
|
|
@@ -24,9 +24,8 @@ function setCookieRawWrapper(p) {
|
|
|
24
24
|
}
|
|
25
25
|
const str = (0, base64_1.toBase64)(stringify(p.value));
|
|
26
26
|
const chunks = (0, chunk_1.chunkString)(str, const_1.maxCookieLen);
|
|
27
|
-
for (const
|
|
28
|
-
|
|
29
|
-
(0, raw_1.setCookie)({ ...p, name: p.name + index1, value: chunk });
|
|
27
|
+
for (const [index, chunk] of chunks.entries()) {
|
|
28
|
+
(0, raw_1.setCookie)({ ...p, name: p.name + index, value: chunk });
|
|
30
29
|
}
|
|
31
30
|
}
|
|
32
31
|
const setCookieString = (p) => setCookieRawWrapper({ ...p, stringify: (s) => s });
|
|
@@ -4,10 +4,10 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
4
4
|
exports.useGranularEffect = exports.useGranularHook = void 0;
|
|
5
5
|
const react_1 = require("react");
|
|
6
6
|
const useGranularHook = (hook, callback, primaryDeps, secondaryDeps) => {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
return hook(callback,
|
|
7
|
+
// The dependency list is intentionally dynamic: only primary values control memoization.
|
|
8
|
+
// oxlint-disable-next-line react/use-memo, react-hooks/exhaustive-deps -- granular dependencies are the hook's purpose
|
|
9
|
+
const deps = (0, react_1.useMemo)(() => [...primaryDeps, ...secondaryDeps], [...primaryDeps]);
|
|
10
|
+
return hook(callback, deps);
|
|
11
11
|
};
|
|
12
12
|
exports.useGranularHook = useGranularHook;
|
|
13
13
|
const useGranularEffect = (effect, primaryDeps, secondaryDeps) => (0, exports.useGranularHook)(react_1.useEffect, effect, primaryDeps, secondaryDeps);
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import type { RefObject } from "react";
|
|
2
|
-
export declare function useIsInViewport(ref: RefObject<HTMLElement>): boolean;
|
|
2
|
+
export declare function useIsInViewport(ref: RefObject<HTMLElement | null>): boolean;
|
|
@@ -48,7 +48,7 @@ const setLocalStorageItem = (key, value, ttl) => {
|
|
|
48
48
|
window.localStorage.setItem(key, JSON.stringify(set));
|
|
49
49
|
}
|
|
50
50
|
catch (e) {
|
|
51
|
-
(0, log_1.error)(`set LS error:${key}-${e}`);
|
|
51
|
+
(0, log_1.error)(`set LS error:${key}-${String(e)}`);
|
|
52
52
|
(0, exports.clearLocalStorageItem)(key);
|
|
53
53
|
}
|
|
54
54
|
};
|
|
@@ -14,7 +14,7 @@ function useOnScroll({ onScroll, element, } = {}) {
|
|
|
14
14
|
scrollTopX: 0,
|
|
15
15
|
scrollTopY: 0,
|
|
16
16
|
});
|
|
17
|
-
const
|
|
17
|
+
const startScrollTopY = (0, react_1.useRef)(undefined);
|
|
18
18
|
(0, useGranularHook_1.useGranularEffect)(() => {
|
|
19
19
|
const listener = (e) => {
|
|
20
20
|
if (!element?.current) {
|
|
@@ -26,20 +26,18 @@ function useOnScroll({ onScroll, element, } = {}) {
|
|
|
26
26
|
y,
|
|
27
27
|
x,
|
|
28
28
|
scrolled: !!y || !!x,
|
|
29
|
-
isDown: startScrollTopY < y,
|
|
29
|
+
isDown: startScrollTopY.current !== undefined && startScrollTopY.current < y,
|
|
30
30
|
scrollTopX: x,
|
|
31
31
|
scrollTopY: y,
|
|
32
32
|
};
|
|
33
|
+
startScrollTopY.current ??= y;
|
|
33
34
|
setState(r);
|
|
34
35
|
onScroll?.(e, r);
|
|
35
36
|
return { y, x };
|
|
36
37
|
};
|
|
37
38
|
const listenDebounce = (e) => {
|
|
38
39
|
(0, debounce_1.debounce)(() => {
|
|
39
|
-
|
|
40
|
-
if (l) {
|
|
41
|
-
setStartScrollTopY(l.y);
|
|
42
|
-
}
|
|
40
|
+
listener(e);
|
|
43
41
|
}, { key: "onscroll", time: 20 });
|
|
44
42
|
};
|
|
45
43
|
(element?.current ?? document).addEventListener(`scroll`, listenDebounce, {
|
|
@@ -53,11 +51,6 @@ function useOnScroll({ onScroll, element, } = {}) {
|
|
|
53
51
|
//
|
|
54
52
|
}
|
|
55
53
|
};
|
|
56
|
-
}, [element], [element, onScroll
|
|
57
|
-
(0, react_1.useEffect)(() => {
|
|
58
|
-
if (startScrollTopY === -1 && !!element?.current) {
|
|
59
|
-
setStartScrollTopY(element.current.scrollTop);
|
|
60
|
-
}
|
|
61
|
-
}, [element, startScrollTopY]);
|
|
54
|
+
}, [element], [element, onScroll]);
|
|
62
55
|
return state;
|
|
63
56
|
}
|
|
@@ -34,12 +34,8 @@ const useQueryStringRaw = ({ name, queryValues, defaultValue, stringify, parse,
|
|
|
34
34
|
setStateRaw(v);
|
|
35
35
|
};
|
|
36
36
|
//
|
|
37
|
-
(
|
|
38
|
-
|
|
39
|
-
setStateRaw(qsv);
|
|
40
|
-
}
|
|
41
|
-
}, [name, parse, qsv, state]);
|
|
42
|
-
return [state, setState];
|
|
37
|
+
const currentState = JSON.stringify(state) === JSON.stringify(qsv) ? state : qsv;
|
|
38
|
+
return [currentState, setState];
|
|
43
39
|
};
|
|
44
40
|
exports.useQueryStringRaw = useQueryStringRaw;
|
|
45
41
|
/**
|
package/dist/ui/styles/common.js
CHANGED
|
@@ -60,7 +60,7 @@ const bounce = (isActive = false) => ({
|
|
|
60
60
|
},
|
|
61
61
|
});
|
|
62
62
|
exports.bounce = bounce;
|
|
63
|
-
const Card = ({ children, className = "", ...props }) => (react_1.default.createElement("div", { className: `bg-white m-2 relative rounded-lg max-w-
|
|
63
|
+
const Card = ({ children, className = "", ...props }) => (react_1.default.createElement("div", { className: `bg-white m-2 relative rounded-lg max-w-160 p-4 border-2 border-lighter ${className}`, ...props }, children));
|
|
64
64
|
exports.Card = Card;
|
|
65
65
|
const getVarStyles = (raw) => ({
|
|
66
66
|
...raw,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ag-common",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.903",
|
|
4
4
|
"license": "ISC",
|
|
5
5
|
"author": "admin@gec.dev",
|
|
6
6
|
"repository": {
|
|
@@ -63,7 +63,7 @@
|
|
|
63
63
|
"aws-cdk-lib": "^2.265.0",
|
|
64
64
|
"constructs": "^10.8.1",
|
|
65
65
|
"cross-env": "^10.1.0",
|
|
66
|
-
"eslint-config-e7npm": "0.1.
|
|
66
|
+
"eslint-config-e7npm": "0.1.62",
|
|
67
67
|
"globstar": "^1.0.0",
|
|
68
68
|
"jiti": "^2.7.0",
|
|
69
69
|
"oxfmt": "^0.60.0",
|
|
@@ -80,7 +80,7 @@
|
|
|
80
80
|
},
|
|
81
81
|
"scripts": {
|
|
82
82
|
"preinstall": "npx only-allow pnpm",
|
|
83
|
-
"format": "e7-oxfmt --config .oxfmtrc.json --disable-nested-config .",
|
|
83
|
+
"format": "e7-oxfmt --no-lint --config .oxfmtrc.json --disable-nested-config .",
|
|
84
84
|
"lint": "e7-oxlint --config .oxlintrc.json --deny-warnings . && pnpm run typecheck",
|
|
85
85
|
"typecheck": "tsc --noEmit",
|
|
86
86
|
"build": "rimraf dist && tsc -p tsconfig.build.json",
|